maindb-procedure-3.sql 687 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490
  1. GO
  2. /****** Object: StoredProcedure [dbo].[bsCaFeedBackReplyUpdate] Script Date: 2018/12/13 19:05:27 ******/
  3. SET ANSI_NULLS ON
  4. GO
  5. SET QUOTED_IDENTIFIER ON
  6. GO
  7. -- =============================================
  8. -- 创建日期:2010-9-19
  9. -- 创建人:Lucifer
  10. -- 功能:答复企业用户的反馈
  11. -- 应用于/BackStage/Consultant/CompanyFeedBackReplyProc.asp页面
  12. -- 修改时间:2015-2-27
  13. -- 修改人:harry
  14. -- =============================================
  15. CREATE PROCEDURE [dbo].[bsCaFeedBackReplyUpdate]
  16. (
  17. @ID INT,
  18. @ReplyMan INT,
  19. @ReplyMessage NVARCHAR(2000),
  20. @HomePage BIT,
  21. @sendMsg INT
  22. )
  23. AS
  24. BEGIN
  25. SET @ReplyMessage = dbo.SafeSql(@ReplyMessage)
  26. IF @HomePage = 0
  27. UPDATE caFeedBack SET ReplyMan=@ReplyMan,IsReply=1,ReplyDate=GETDATE(),ReplyMessage=@ReplyMessage,HomePage=NULL
  28. WHERE ID=@ID
  29. ELSE
  30. UPDATE caFeedBack SET ReplyMan=@ReplyMan,IsReply=1,ReplyDate=GETDATE(),ReplyMessage=@ReplyMessage,HomePage=1
  31. WHERE ID=@ID
  32. --短信发送
  33. IF @sendMsg = 1
  34. BEGIN
  35. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  36. SELECT @ReplyMan, NULL, NULL, a.ID, a.Mobile, 6, 0,
  37. ISNULL(a.Name,'') + '您好,您在' + c.subsitename + c.EmailSite + '上提出的问题已经答复,请及时登录网站查看,祝您招聘顺利!'
  38. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK), dcSubSite c WITH(NOLOCK),caFeedBack d WITH(NOLOCK)
  39. WHERE a.cpMainID = b.ID
  40. AND b.dcSubSiteID = c.ID
  41. AND a.ID = d.caMainID
  42. AND a.Mobile > ''
  43. AND d.ID = @ID
  44. AND a.IsReceiveSms = 1
  45. END
  46. END
  47. GO
  48. /****** Object: StoredProcedure [dbo].[bsCaFeedBackSelect] Script Date: 2018/12/13 19:05:27 ******/
  49. SET ANSI_NULLS ON
  50. GO
  51. SET QUOTED_IDENTIFIER ON
  52. GO
  53. CREATE PROCEDURE [dbo].[bsCaFeedBackSelect]
  54. (
  55. @WHERE VARCHAR(2000)
  56. )
  57. AS
  58. BEGIN
  59. DECLARE @SQL AS VARCHAR(2000)
  60. SET @Where = dbo.SafeSql(@Where)
  61. SET @SQL = 'SELECT TOP 2000 dbo.ReplyInterval(a.AddDate, ISNULL(a.ReplyDate, GETDATE())) ReplyInterval,a.ReplyDate,a.ID,a.Message content,a.AddDate,a.name,a.Telephone,a.Email,b.Name companyname,b.ID companyid,b.RegDate,b.dcProvinceID province_id,a.ViewDate seedate,b.ConsultantID manageruserid,a.ReplyMessage reply_content,a.HomePage,a.IP,d.status,d.name ManagerUserName
  62. FROM caFeedBack a WITH(NOLOCK)
  63. INNER JOIN caMain c WITH(NOLOCK) ON c.ID=a.caMainID
  64. INNER JOIN cpMain b WITH(NOLOCK) ON b.ID=c.cpMainID
  65. LEFT JOIN Manageruser d WITH(NOLOCK) ON d.ID=b.ConsultantID
  66. WHERE 1=1' + @Where + '
  67. ORDER BY a.adddate DESC'
  68. EXEC(@SQL)
  69. END
  70. GO
  71. /****** Object: StoredProcedure [dbo].[bsCaMainUpdateByCaMainid] Script Date: 2018/12/13 19:05:27 ******/
  72. SET ANSI_NULLS ON
  73. GO
  74. SET QUOTED_IDENTIFIER ON
  75. GO
  76. --更新是否添加了qq好友,是否添加了微信好友
  77. --创建人:harry
  78. --2018-1-15
  79. --20181107 Sunshine 修改删除qq删除微信
  80. CREATE PROCEDURE [dbo].[bsCaMainUpdateByCaMainid]
  81. (
  82. @type INT,
  83. @caMainId INT,
  84. @managerUserId INT
  85. )
  86. AS
  87. BEGIN
  88. IF @type = 1--添加qq
  89. BEGIN
  90. UPDATE caMain
  91. SET qqaddMan = @managerUserId
  92. WHERE id = @caMainId
  93. END
  94. IF @type = 2--添加微信
  95. BEGIN
  96. UPDATE caMain
  97. SET wechataddMan = @managerUserId
  98. WHERE id = @caMainId
  99. END
  100. IF @type = 3--删除qq
  101. BEGIN
  102. UPDATE caMain
  103. SET qqaddMan = NULL
  104. WHERE id = @caMainId
  105. END
  106. IF @type = 4--删除微信
  107. BEGIN
  108. UPDATE caMain
  109. SET wechataddMan = NULL
  110. WHERE id = @caMainId
  111. END
  112. END
  113. GO
  114. /****** Object: StoredProcedure [dbo].[bsCaOrderByIDSelect] Script Date: 2018/12/13 19:05:27 ******/
  115. SET ANSI_NULLS ON
  116. GO
  117. SET QUOTED_IDENTIFIER ON
  118. GO
  119. /*****20140721 nick update ****/
  120. /*****20140805 lambo 增加InvoiceReConfirmDate,InvoiceReConfirmMan ****/
  121. /*****20140822 mice 增加 PaidCoin PaidPoint******/
  122. /*****2015-7-9 harry 增加 手动扣除的积分****/
  123. /*****2017-11-11 harry 增加 职位刷新数****/
  124. /*****2018-5-17 harry 增加 invoiceconfirmFile,isdocopen****/
  125. CREATE PROCEDURE [dbo].[bsCaOrderByIDSelect]
  126. (
  127. @ID INT
  128. )
  129. AS
  130. BEGIN
  131. SELECT a.id cpmainid,a.ResumeQuota, b.SmsQuota,b.jobRefreshQuota, b.manageruserid manageruserid, a.dcSubSiteID, b.paid, b.dcFeeDetailID,a.dcregionID,
  132. b.placeweek, b.id orderid, b.activequota, b.jobnumber, b.Usernumber, a.UnlimitedDate,
  133. a.id companyid, a.Name companyname, b.paymethod, b.provinceID, b.opendate, b.servicetype,
  134. b.linkman, a.ConsultantID, ReceiveMan, b.InvoiceCompany, a.Balance, a.BalanceDate,
  135. b.telephone, b.linkremark, b.needinvoice, b.invoicetitle, b.mailaddress, b.recipient,
  136. b.zip, b.accounts, a.RegDate, b.OpenMan, b.BeginDate, b.EndDate, b.InvoiceMonth,
  137. b.ordertype, b.adddate, a.dcprovinceid, b.posttelephone, b.InvoiceConfirmDate, b.RemittanceFile,
  138. a.HasLicence, b.InvoiceAskDate, b.MainOrderID, b.InvoiceConfirmMan, b.receivedate, a.address,
  139. a.zip zip2, c.mobile, c.email caemail, a.dcRegionID, d.FullName, b.Tariff, b.RegisterAddress,
  140. b.RegisterTel, b.BankName, b.BankAccount, b.InvoiceReConfirmDate,b.InvoiceReConfirmMan,
  141. b.PaidCoin, b.PaidPoint, b.RemittanceDate,b.contractfile,
  142. (SELECT ISNULL(SUM(RemainQuota), 0)
  143. FROM caOrder WITH(NOLOCK)
  144. WHERE MainOrderID=b.MainOrderID
  145. Or ID = b.MainOrderID) caRemainQuota,
  146. b.Balance OrderBalance, a.MemberType, c.ID caMainID,
  147. b.IsDeleted,b.invoiceconfirmFile,b.isdocopen
  148. FROM cpMain a WITH(NOLOCK),
  149. caorder b WITH(NOLOCK),
  150. camain c WITH(NOLOCK),
  151. dcregion d with(NOLOCK)
  152. WHERE b.cpmainid = a.id and d.id = a.dcRegionID
  153. AND a.id = b.cpMainid
  154. AND c.cpMainID = a.ID
  155. AND c.AccountType = 1
  156. AND b.id = @ID
  157. END
  158. GO
  159. /****** Object: StoredProcedure [dbo].[bsCaorderByPaidCoinUpdate] Script Date: 2018/12/13 19:05:28 ******/
  160. SET ANSI_NULLS ON
  161. GO
  162. SET QUOTED_IDENTIFIER ON
  163. GO
  164. ---后台订单修改支付金币
  165. ---harry-2017-10-19
  166. CREATE PROCEDURE [dbo].[bsCaorderByPaidCoinUpdate]
  167. (
  168. @cpMainID INT,
  169. @PaidCoin INT,
  170. @caOrderId INT
  171. )
  172. AS
  173. BEGIN
  174. IF EXISTS(SELECT 'X' FROM caorder WHERE ID = @caOrderId AND ISNULL(paidCoin,0)>0)
  175. RETURN
  176. DECLARE @RemainCoin INT
  177. SELECT @RemainCoin = ISNULL(RemainCoin, 0) FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainID
  178. IF(@RemainCoin<@PaidCoin)
  179. RETURN
  180. ELSE
  181. BEGIN
  182. UPDATE cpMain
  183. SET RemainCoin = (RemainCoin-@PaidCoin)
  184. WHERE ID = @cpMainID
  185. UPDATE caorder
  186. SET PaidCoin = @PaidCoin
  187. WHERE ID = @caOrderId
  188. END
  189. END
  190. GO
  191. /****** Object: StoredProcedure [dbo].[bscaOrderCountByOpenDate] Script Date: 2018/12/13 19:05:28 ******/
  192. SET ANSI_NULLS ON
  193. GO
  194. SET QUOTED_IDENTIFIER ON
  195. GO
  196. -- =============================================
  197. -- 创建日期:2010-9-21
  198. -- 创建人:Lucifer
  199. -- 功能:根据订单的OpenDate来取某个招聘顾问在某一时间段的订单总金额
  200. -- 应用于/BackStage/Consultant/ConsultantCheck.asp页面
  201. -- 修改时间:
  202. -- 修改人:
  203. -- =============================================
  204. CREATE PROCEDURE [dbo].[bscaOrderCountByOpenDate]
  205. (
  206. @manageruserid INT,
  207. @BeginDate SMALLDATETIME,
  208. @EndDate SMALLDATETIME
  209. )
  210. AS
  211. BEGIN
  212. SELECT SUM(Paid) cnt
  213. FROM caOrder WITH(NOLOCK)
  214. WHERE Manageruserid=@manageruserid
  215. AND OpenDate BETWEEN @BeginDate AND @EndDate
  216. AND IsDeleted = 0
  217. END
  218. GO
  219. /****** Object: StoredProcedure [dbo].[bscaOrderCountByReceiveDate] Script Date: 2018/12/13 19:05:28 ******/
  220. SET ANSI_NULLS ON
  221. GO
  222. SET QUOTED_IDENTIFIER ON
  223. GO
  224. -- =============================================
  225. -- 创建日期:2010-9-21
  226. -- 创建人:Lucifer
  227. -- 功能:根据订单的ReceiveDate来取某个招聘顾问在某一时间段的订单总金额
  228. -- 应用于/BackStage/Consultant/ConsultantCheck.asp页面
  229. -- 修改时间:
  230. -- 修改人:
  231. -- =============================================
  232. CREATE PROCEDURE [dbo].[bscaOrderCountByReceiveDate]
  233. (
  234. @manageruserid INT,
  235. @BeginDate SMALLDATETIME,
  236. @EndDate SMALLDATETIME
  237. )
  238. AS
  239. BEGIN
  240. SELECT SUM(Paid) cnt FROM caOrder WITH(NOLOCK) WHERE Manageruserid=@manageruserid
  241. AND OpenDate>@BeginDate AND OpenDate<@EndDate
  242. END
  243. GO
  244. /****** Object: StoredProcedure [dbo].[bsCaOrderDIYInsert] Script Date: 2018/12/13 19:05:28 ******/
  245. SET ANSI_NULLS ON
  246. GO
  247. SET QUOTED_IDENTIFIER ON
  248. GO
  249. CREATE PROCEDURE [dbo].[bsCaOrderDIYInsert]
  250. (
  251. @cpMainID INT,
  252. @caMainID INT,
  253. @ProvinceID INT,
  254. @ServiceType INT,
  255. @PlaceWeek TINYINT=NULL,
  256. @PayMethod TINYINT,
  257. @OrderType TINYINT,
  258. @Accounts NUMERIC(18,2),
  259. @Paid NUMERIC(18,2),
  260. @Balance NUMERIC(18,2)=NULL,
  261. @LinkMan NVARCHAR(50),
  262. @Telephone VARCHAR(50),
  263. @LinkRemark NVARCHAR(1000),
  264. @Manageruserid SMALLINT,
  265. @ActiveQuota SMALLINT=NULL,
  266. @JobNumber SMALLINT=NULL,
  267. @CompanyName VARCHAR(100),
  268. @MainOrderID INT=NULL,
  269. @InvoiceCompany SMALLINT,
  270. @NeedInvoice bit=null,
  271. @InvoiceTitle NVARCHAR(50)=null,
  272. @MailAddress NVARCHAR(100)=null,
  273. @Recipient NVARCHAR(100)=null,
  274. @PostTelephone NVARCHAR(50)=null,
  275. @Zip CHAR(6)=null,
  276. @InvoiceConfirmDate VARCHAR(20)=null,
  277. @InvoiceConfirmMan SMALLINT=null,
  278. @UserNumber SMALLINT=NULL,
  279. @dcFeeDetailsID INT=NULL
  280. )
  281. AS
  282. BEGIN TRAN
  283. Declare @MaxId AS INT
  284. BEGIN TRY
  285. IF @InvoiceConfirmDate = ''
  286. SET @InvoiceConfirmDate = NULL
  287. IF @dcFeeDetailsID = 0
  288. SET @dcFeeDetailsID = NULL
  289. IF @OrderType = 8
  290. BEGIN
  291. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  292. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID,2) AND b.ID = @dcFeeDetailsID AND a.startDate<GETDATE() AND a.endDate > GETDATE())
  293. GOTO ERR2 --检查是否套餐已过期
  294. DECLARE @MinResumeNumber AS INT,@MinJobNumber AS INT,@MinUserNumber AS INT,@MinPrice AS INT
  295. SELECT @Accounts = (b.PriceMonth * a.[Month]+@ActiveQuota*b.PriceResume+@JobNumber*b.PriceJob+@UserNumber*b.PriceUser),
  296. @Paid = (b.PriceMonth * a.[Month]+@ActiveQuota*b.PriceResume+@JobNumber*b.PriceJob+@UserNumber*b.PriceUser)*Discount/100,
  297. @MinResumeNumber = a.ResumeNumber,
  298. @MinJobNumber = a.JobNumber,
  299. @MinUserNumber = a.UserNumber,
  300. @MinPrice = a.Price
  301. FROM dcVipDetail a WITH(NOLOCK) ,dcVip b WITH(NOLOCK)
  302. WHERE a.ID = @dcFeeDetailsID
  303. AND StartDate < GETDATE() AND EndDate > GETDATE()
  304. AND a.dcVipID = b.ID
  305. IF @ActiveQuota < @MinResumeNumber OR @JobNumber < @MinJobNumber OR @UserNumber < @MinUserNumber OR @Paid < @MinPrice
  306. GOTO ERR1 --小于最低标准
  307. DECLARE @IsAgent AS BIT
  308. SELECT @IsAgent = IsAgent FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  309. IF @IsAgent = 1
  310. SET @Paid = @Accounts
  311. END
  312. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,
  313. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,
  314. NeedInvoice,InvoiceTitle,MailAddress,Recipient,PostTelephone,Zip,InvoiceConfirmDate,InvoiceConfirmMan,UserNumber,dcFeeDetailID,IsBackSubmit)
  315. VALUES(@cpMainID,@ProvinceID,@ServiceType,@PlaceWeek,@PayMethod,
  316. @OrderType,@Accounts,@Paid,@Balance,@LinkMan,@Telephone,@LinkRemark,@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,
  317. @NeedInvoice,@InvoiceTitle,@MailAddress,@Recipient,@PostTelephone,@Zip,@InvoiceConfirmDate,@InvoiceConfirmMan,@UserNumber,@dcFeeDetailsID,1)
  318. SET @MaxID = @@IDENTITY
  319. DECLARE @Temp AS NUMERIC(18,2)
  320. SET @Temp = @Paid -- 1 + CONVERT(NUMERIC(18,2),'0.'+RIGHT(STR(@cpMainID),2))
  321. UPDATE caOrder SET Paid = @Temp WHERE ID = @MaxID
  322. END TRY
  323. BEGIN CATCH
  324. GOTO ERR
  325. END CATCH
  326. COMMIT TRAN
  327. RETURN @MaxID
  328. ERR:
  329. BEGIN
  330. ROLLBACK TRAN
  331. RETURN 0
  332. END
  333. ERR1:
  334. BEGIN
  335. ROLLBACK TRAN
  336. RETURN -2
  337. END
  338. ERR2:
  339. BEGIN
  340. ROLLBACK TRAN
  341. RETURN -1
  342. END
  343. GO
  344. /****** Object: StoredProcedure [dbo].[bsCaOrderDIYInsert2] Script Date: 2018/12/13 19:05:28 ******/
  345. SET ANSI_NULLS ON
  346. GO
  347. SET QUOTED_IDENTIFIER ON
  348. GO
  349. -- =============================================
  350. -- 修改记录: 2015.1.16 John 添加后台提交DIY订单使用金币
  351. -- 修改:harry 增加短信数
  352. -- 短信、刷新书为赠送。原价与实际都不计算在内
  353. -- =============================================
  354. CREATE PROCEDURE [dbo].[bsCaOrderDIYInsert2]
  355. (
  356. @cpMainID INT,
  357. @caMainID INT,
  358. @ProvinceID INT,
  359. @ServiceType INT,
  360. @PlaceWeek TINYINT=NULL,
  361. @PayMethod TINYINT,
  362. @OrderType TINYINT,
  363. @Accounts NUMERIC(18,2),
  364. @Paid NUMERIC(18,2),
  365. @Balance NUMERIC(18,2)=NULL,
  366. @LinkMan NVARCHAR(50),
  367. @Telephone VARCHAR(50),
  368. @LinkRemark NVARCHAR(1000),
  369. @Manageruserid SMALLINT,
  370. @ActiveQuota SMALLINT=NULL,
  371. @JobNumber SMALLINT=NULL,
  372. @CompanyName VARCHAR(100),
  373. @MainOrderID INT=NULL,
  374. @InvoiceCompany SMALLINT,
  375. @NeedInvoice bit=null,
  376. @InvoiceTitle NVARCHAR(50)=null,
  377. @MailAddress NVARCHAR(100)=null,
  378. @Recipient NVARCHAR(100)=null,
  379. @PostTelephone NVARCHAR(50)=null,
  380. @Zip CHAR(6)=null,
  381. @InvoiceConfirmDate VARCHAR(20)=null,
  382. @InvoiceConfirmMan SMALLINT=null,
  383. @UserNumber SMALLINT=NULL,
  384. @dcFeeDetailsID INT=NULL,
  385. @UseCoin INT = NULL,
  386. @SmsNumber INT=NULL,
  387. @jobRefreshQuota INT=NULL
  388. )
  389. AS
  390. SET NOCOUNT ON
  391. BEGIN TRAN
  392. Declare @MaxId AS INT
  393. BEGIN TRY
  394. IF @InvoiceConfirmDate = ''
  395. SET @InvoiceConfirmDate = NULL
  396. IF @dcFeeDetailsID = 0
  397. SET @dcFeeDetailsID = NULL
  398. IF @OrderType = 8
  399. BEGIN
  400. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  401. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID,2) AND b.ID = @dcFeeDetailsID AND a.startDate < GETDATE() AND a.endDate > GETDATE())
  402. GOTO ERR2 --检查是否套餐已过期
  403. DECLARE @MinResumeNumber AS INT,@MinJobNumber AS INT,@MinUserNumber AS INT,@MinPrice AS INT,@MinSmsNumber AS INT
  404. SELECT @Accounts = (b.PriceMonth * a.[Month]+@ActiveQuota*b.PriceResume+@JobNumber*b.PriceJob+@UserNumber*b.PriceUser+@SmsNumber*b.PriceSms+@jobRefreshQuota*b.priceJobrefreshNumber),
  405. @Paid = (b.PriceMonth * a.[Month]+@ActiveQuota*b.PriceResume+@JobNumber*b.PriceJob+@UserNumber*b.PriceUser+@SmsNumber*b.PriceSms+@jobRefreshQuota*b.priceJobrefreshNumber)*Discount/100,
  406. @MinResumeNumber = a.ResumeNumber,
  407. @MinJobNumber = a.JobNumber,
  408. @MinUserNumber = a.UserNumber,
  409. @MinSmsNumber = a.SmsNumber,
  410. @MinPrice = a.Price
  411. FROM dcVipDetail a WITH(NOLOCK) ,dcVip b WITH(NOLOCK)
  412. WHERE a.ID = @dcFeeDetailsID
  413. AND StartDate < GETDATE() AND EndDate > GETDATE()
  414. AND a.dcVipID = b.ID
  415. --IF @ActiveQuota < @MinResumeNumber OR @JobNumber < @MinJobNumber OR @UserNumber < @MinUserNumber OR @Paid < @MinPrice
  416. -- GOTO ERR1 --小于最低标准
  417. -- IF @ActiveQuota < @MinResumeNumber
  418. -- SET @ActiveQuota = @MinResumeNumber
  419. -- IF @JobNumber < @MinJobNumber
  420. -- SET @JobNumber = @MinJobNumber
  421. -- IF @UserNumber < @MinUserNumber
  422. -- SET @UserNumber = @MinUserNumber
  423. IF @Paid < @MinPrice
  424. SET @Paid = @MinPrice
  425. DECLARE @IsAgent AS BIT
  426. SELECT @IsAgent = IsAgent FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  427. IF @IsAgent = 1
  428. SET @Paid = @Accounts
  429. --金币支付
  430. DECLARE @CoinBalance AS INT
  431. IF @UseCoin IS NOT NULL
  432. BEGIN
  433. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainCoin >= @UseCoin)
  434. GOTO ERR --检查剩余金币数量是否足够支付
  435. SET @Paid = @Paid - @UseCoin
  436. END
  437. IF @Paid < 0
  438. SET @Paid = 0
  439. END
  440. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,
  441. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,
  442. NeedInvoice,InvoiceTitle,MailAddress,Recipient,PostTelephone,Zip,InvoiceConfirmDate,InvoiceConfirmMan,UserNumber,dcFeeDetailID,IsBackSubmit,PaidCoin,SmsQuota,RemainSmsQuota,jobRefreshQuota, remainJobRefreshQuota)
  443. VALUES(@cpMainID,@ProvinceID,@ServiceType,@PlaceWeek,@PayMethod,
  444. @OrderType,Convert(INT,@Accounts),@Paid,@Balance,@LinkMan,@Telephone,@LinkRemark,@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,
  445. @NeedInvoice,@InvoiceTitle,@MailAddress,@Recipient,@PostTelephone,@Zip,@InvoiceConfirmDate,@InvoiceConfirmMan,@UserNumber,@dcFeeDetailsID,1,@UseCoin,@SmsNumber,@SmsNumber, @jobRefreshQuota,@jobRefreshQuota)
  446. SET @MaxID = @@IDENTITY
  447. DECLARE @Temp AS NUMERIC(18,2)
  448. SET @Temp = @Paid -- 1 + CONVERT(NUMERIC(18,2),'0.'+RIGHT(STR(@cpMainID),2))
  449. --金币或订单全额支付
  450. IF @Temp < 0
  451. SET @Temp = 0
  452. UPDATE caOrder SET Paid = @Temp WHERE ID = @MaxID
  453. IF @UseCoin IS NOT NULL
  454. BEGIN
  455. --插入金币记录
  456. INSERT INTO cpCoin (cpMainID,caOrderID,Coin,Balance,AddDate)
  457. VALUES(@cpMainID,@MaxID,0-@UseCoin,0,GETDATE())
  458. END
  459. END TRY
  460. BEGIN CATCH
  461. GOTO ERR
  462. END CATCH
  463. COMMIT TRAN
  464. RETURN @MaxID
  465. ERR:
  466. BEGIN
  467. ROLLBACK TRAN
  468. RETURN 0
  469. END
  470. ERR1:
  471. BEGIN
  472. ROLLBACK TRAN
  473. RETURN -2
  474. END
  475. ERR2:
  476. BEGIN
  477. ROLLBACK TRAN
  478. RETURN -1
  479. END
  480. GO
  481. /****** Object: StoredProcedure [dbo].[bsCaOrderInsert] Script Date: 2018/12/13 19:05:29 ******/
  482. SET ANSI_NULLS ON
  483. GO
  484. SET QUOTED_IDENTIFIER ON
  485. GO
  486. CREATE PROCEDURE [dbo].[bsCaOrderInsert]
  487. (
  488. @cpMainID INT,
  489. @caMainID INT,
  490. @ProvinceID INT,
  491. @ServiceType INT,
  492. @PlaceWeek TINYINT=NULL,
  493. @PayMethod TINYINT,
  494. @OrderType TINYINT,
  495. @Accounts NUMERIC(18,2),
  496. @Paid NUMERIC(18,2),
  497. @Balance NUMERIC(18,2)=NULL,
  498. @LinkMan NVARCHAR(50),
  499. @Telephone VARCHAR(50),
  500. @LinkRemark NVARCHAR(1000),
  501. @Manageruserid SMALLINT,
  502. @ActiveQuota SMALLINT=NULL,
  503. @JobNumber SMALLINT=NULL,
  504. @CompanyName VARCHAR(100),
  505. @MainOrderID INT=NULL,
  506. @InvoiceCompany SMALLINT,
  507. @NeedInvoice bit=null,
  508. @InvoiceTitle NVARCHAR(50)=null,
  509. @MailAddress NVARCHAR(100)=null,
  510. @Recipient NVARCHAR(100)=null,
  511. @PostTelephone NVARCHAR(50)=null,
  512. @Zip CHAR(6)=null,
  513. @InvoiceConfirmDate VARCHAR(20)=null,
  514. @InvoiceConfirmMan SMALLINT=null,
  515. @UserNumber SMALLINT=NULL,
  516. @dcFeeDetailsID INT=NULL
  517. )
  518. AS
  519. IF @ManagerUserId = 0
  520. SET @ManagerUserId = NULL
  521. BEGIN TRAN
  522. Declare @MaxId AS INT
  523. BEGIN TRY
  524. IF @InvoiceConfirmDate = ''
  525. SET @InvoiceConfirmDate = NULL
  526. IF @dcFeeDetailsID = 0
  527. SET @dcFeeDetailsID = NULL
  528. IF NOT(@Paid = 0 AND @Accounts = 0)
  529. BEGIN
  530. IF @OrderType = 8
  531. BEGIN
  532. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  533. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID,2) AND b.ID = @dcFeeDetailsID AND a.startDate<GETDATE() AND a.endDate > GETDATE())
  534. GOTO ERR --检查是否套餐已过期
  535. SELECT @Accounts = (b.PriceMonth * a.[Month]+a.ResumeNumber*b.PriceResume+JobNumber*b.PriceJob+UserNumber*b.PriceUser),
  536. @Paid = a.Price,
  537. @ActiveQuota = a.ResumeNumber,
  538. @JobNumber = a.JobNumber,
  539. @UserNumber = a.UserNumber
  540. FROM dcVipDetail a WITH(NOLOCK) ,dcVip b WITH(NOLOCK)
  541. WHERE a.ID = @dcFeeDetailsID
  542. AND StartDate < GETDATE() AND EndDate > GETDATE()
  543. AND a.dcVipID = b.ID
  544. END
  545. Else IF @OrderType = 4 AND @ServiceType=6 ----根据周数查询1/6广告的资费信息
  546. BEGIN
  547. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  548. @Paid = a.Price * @PlaceWeek,
  549. @dcFeeDetailsID = a.ID
  550. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  551. WHERE a.dcFeeID = b.ID
  552. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  553. AND b.type = 4
  554. AND StartDate < GETDATE() AND EndDate > GETDATE()
  555. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  556. IF @dcFeeDetailsID IS NULL
  557. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  558. FROM dcFee WITH(NOLOCK)
  559. WHERE type = 4
  560. AND dcProvinceID = LEFT(@ProvinceID,2)
  561. AND StartDate < GETDATE() AND EndDate > GETDATE()
  562. END
  563. ELSE IF @OrderType = 4 AND @ServiceType=7 ----根据周数查询2/6广告的资费信息
  564. BEGIN
  565. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  566. @Paid = a.Price * @PlaceWeek,
  567. @dcFeeDetailsID = a.ID
  568. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  569. WHERE b.type = 5
  570. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  571. AND StartDate < GETDATE() AND EndDate > GETDATE()
  572. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  573. AND a.dcFeeID = b.ID
  574. IF @dcFeeDetailsID IS NULL
  575. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  576. FROM dcFee WITH(NOLOCK)
  577. WHERE type = 5
  578. AND dcProvinceID = LEFT(@ProvinceID,2)
  579. AND StartDate < GETDATE() AND EndDate > GETDATE()
  580. END
  581. Else IF @OrderType = 4 AND @ServiceType=8 ----根据周数查询3/6广告的资费信息
  582. BEGIN
  583. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  584. @Paid = a.Price * @PlaceWeek,
  585. @dcFeeDetailsID = a.ID
  586. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  587. WHERE a.dcFeeID = b.ID
  588. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  589. AND b.type = 20
  590. AND StartDate < GETDATE() AND EndDate > GETDATE()
  591. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  592. IF @dcFeeDetailsID IS NULL
  593. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  594. FROM dcFee WITH(NOLOCK)
  595. WHERE type = 20
  596. AND dcProvinceID = LEFT(@ProvinceID,2)
  597. AND StartDate < GETDATE() AND EndDate > GETDATE()
  598. END
  599. ELSE IF @OrderType = 4 AND @ServiceType=9 ----根据周数查询6/6广告的资费信息
  600. BEGIN
  601. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  602. @Paid = a.Price * @PlaceWeek,
  603. @dcFeeDetailsID = a.ID
  604. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  605. WHERE b.type = 21
  606. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  607. AND StartDate < GETDATE() AND EndDate > GETDATE()
  608. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  609. AND a.dcFeeID = b.ID
  610. IF @dcFeeDetailsID IS NULL
  611. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  612. FROM dcFee WITH(NOLOCK)
  613. WHERE type = 21
  614. AND dcProvinceID = LEFT(@ProvinceID,2)
  615. AND StartDate < GETDATE() AND EndDate > GETDATE()
  616. END
  617. ELSE IF @OrderType = 4 AND @ServiceType=10 ----根据周数查询6/6广告的资费信息
  618. BEGIN
  619. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  620. @Paid = a.Price * @PlaceWeek,
  621. @dcFeeDetailsID = a.ID
  622. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  623. WHERE b.type = 23
  624. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  625. AND StartDate < GETDATE() AND EndDate > GETDATE()
  626. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  627. AND a.dcFeeID = b.ID
  628. IF @dcFeeDetailsID IS NULL
  629. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  630. FROM dcFee WITH(NOLOCK)
  631. WHERE type = 23
  632. AND dcProvinceID = LEFT(@ProvinceID,2)
  633. AND StartDate < GETDATE() AND EndDate > GETDATE()
  634. END
  635. ELSE IF @OrderType =7 ----根据周数查询固定位置的资费信息
  636. BEGIN
  637. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  638. @Paid = a.Price * @PlaceWeek,
  639. @dcFeeDetailsID = a.ID
  640. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  641. WHERE b.type = 7
  642. AND a.dcFeeID = b.ID
  643. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  644. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  645. AND StartDate < GETDATE() AND EndDate > GETDATE()
  646. IF @dcFeeDetailsID IS NULL
  647. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  648. FROM dcFee WITH(NOLOCK)
  649. WHERE type = 7
  650. AND dcProvinceID = LEFT(@ProvinceID,2)
  651. AND StartDate < GETDATE() AND EndDate > GETDATE()
  652. END
  653. ELSE IF @OrderType = 12 ----根据周数查询职位置顶位置的资费信息
  654. BEGIN
  655. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  656. @Paid = a.Price * @PlaceWeek,
  657. @dcFeeDetailsID = a.ID
  658. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  659. WHERE b.type = 22
  660. AND a.dcFeeID = b.ID
  661. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  662. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  663. AND StartDate < GETDATE() AND EndDate > GETDATE()
  664. IF @dcFeeDetailsID IS NULL
  665. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  666. FROM dcFee WITH(NOLOCK)
  667. WHERE type = 22
  668. AND dcProvinceID = LEFT(@ProvinceID,2)
  669. AND StartDate < GETDATE() AND EndDate > GETDATE()
  670. END
  671. ELSE IF @OrderType = 13 ----根据周数查询职位置顶位置的资费信息
  672. BEGIN
  673. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  674. @Paid = a.Price * @PlaceWeek,
  675. @dcFeeDetailsID = a.ID
  676. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  677. WHERE b.type = 24
  678. AND a.dcFeeID = b.ID
  679. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  680. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  681. AND StartDate < GETDATE() AND EndDate > GETDATE()
  682. IF @dcFeeDetailsID IS NULL
  683. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  684. FROM dcFee WITH(NOLOCK)
  685. WHERE type = 24
  686. AND dcProvinceID = LEFT(@ProvinceID,2)
  687. AND StartDate < GETDATE() AND EndDate > GETDATE()
  688. END
  689. ELSE IF @OrderType = 9 ----根据周数查询简历下载的资费信息
  690. BEGIN
  691. SELECT TOP 1 @Accounts = b.Price * @ActiveQuota,
  692. @Paid = a.Price * @ActiveQuota,
  693. @dcFeeDetailsID = a.ID
  694. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  695. WHERE b.type = 9
  696. AND a.dcFeeID = b.ID
  697. AND ((MinValue<=@ActiveQuota AND MaxValue>=@ActiveQuota) OR (MinValue<=@ActiveQuota AND MaxValue=0))
  698. AND StartDate < GETDATE() AND EndDate > GETDATE()
  699. IF @dcFeeDetailsID IS NULL
  700. SELECT TOP 1 @Accounts = Price, @Paid = Price * @ActiveQuota
  701. FROM dcFee WITH(NOLOCK)
  702. WHERE type = 9
  703. AND dcProvinceID = LEFT(@ProvinceID,2)
  704. AND StartDate < GETDATE() AND EndDate > GETDATE()
  705. END
  706. ELSE IF @OrderType = 10 ----根据周数查询职位数的资费信息
  707. BEGIN
  708. SELECT TOP 1 @Accounts = b.Price * @JobNumber,
  709. @Paid = a.Price * @JobNumber,
  710. @dcFeeDetailsID = a.ID
  711. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  712. WHERE b.type = 10
  713. AND a.dcFeeID = b.ID
  714. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  715. AND ((MinValue<=@JobNumber AND MaxValue>=@JobNumber) OR (MinValue<=@JobNumber AND MaxValue=0))
  716. AND StartDate < GETDATE() AND EndDate > GETDATE()
  717. IF @dcFeeDetailsID IS NULL
  718. SELECT TOP 1 @Accounts = Price, @Paid = Price * @JobNumber
  719. FROM dcFee WITH(NOLOCK)
  720. WHERE type = 10
  721. AND dcProvinceID = LEFT(@ProvinceID,2)
  722. AND StartDate < GETDATE() AND EndDate > GETDATE()
  723. END
  724. ELSE IF @OrderType = 11 ----根据周数查询用户数的资费信息
  725. BEGIN
  726. SELECT TOP 1 @Accounts = b.Price * @UserNumber,
  727. @Paid = a.Price * @UserNumber,
  728. @dcFeeDetailsID = a.ID
  729. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  730. WHERE b.type = 11
  731. AND a.dcFeeID = b.ID
  732. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  733. AND ((MinValue<=@UserNumber AND MaxValue>=@UserNumber) OR (MinValue<=@UserNumber AND MaxValue=0))
  734. AND StartDate < GETDATE() AND EndDate > GETDATE()
  735. IF @dcFeeDetailsID IS NULL
  736. SELECT TOP 1 @Accounts = Price, @Paid = Price * @UserNumber
  737. FROM dcFee WITH(NOLOCK)
  738. WHERE type = 11
  739. AND dcProvinceID = LEFT(@ProvinceID,2)
  740. AND StartDate < GETDATE() AND EndDate > GETDATE()
  741. END
  742. END
  743. ELSE
  744. BEGIN
  745. IF @OrderType = 8
  746. BEGIN
  747. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  748. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID,2) AND b.ID = @dcFeeDetailsID AND a.startDate<GETDATE() AND a.endDate > GETDATE())
  749. GOTO ERR --检查是否套餐已过期
  750. SELECT @Accounts = (b.PriceMonth * a.[Month]+a.ResumeNumber*b.PriceResume+JobNumber*b.PriceJob+UserNumber*b.PriceUser),
  751. @dcFeeDetailsID = a.Price
  752. FROM dcVipDetail a WITH(NOLOCK) ,dcVip b WITH(NOLOCK)
  753. WHERE a.ID = @dcFeeDetailsID
  754. AND StartDate < GETDATE() AND EndDate > GETDATE()
  755. AND a.dcVipID = b.ID
  756. END
  757. Else IF @OrderType = 4 AND @ServiceType=6 ----根据周数查询1/6广告的资费信息
  758. BEGIN
  759. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  760. @dcFeeDetailsID = a.ID
  761. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  762. WHERE a.dcFeeID = b.ID
  763. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  764. AND b.type = 4
  765. AND StartDate < GETDATE() AND EndDate > GETDATE()
  766. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  767. IF @dcFeeDetailsID IS NULL
  768. SELECT TOP 1 @Accounts = Price
  769. FROM dcFee WITH(NOLOCK)
  770. WHERE type = 4
  771. AND dcProvinceID = LEFT(@ProvinceID,2)
  772. AND StartDate < GETDATE() AND EndDate > GETDATE()
  773. END
  774. ELSE IF @OrderType = 4 AND @ServiceType=7 ----根据周数查询2/6广告的资费信息
  775. BEGIN
  776. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  777. @dcFeeDetailsID = a.ID
  778. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  779. WHERE b.type = 5
  780. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  781. AND StartDate < GETDATE() AND EndDate > GETDATE()
  782. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  783. AND a.dcFeeID = b.ID
  784. IF @dcFeeDetailsID IS NULL
  785. SELECT TOP 1 @Accounts = Price
  786. FROM dcFee WITH(NOLOCK)
  787. WHERE type = 5
  788. AND dcProvinceID = LEFT(@ProvinceID,2)
  789. AND StartDate < GETDATE() AND EndDate > GETDATE()
  790. END
  791. Else IF @OrderType = 4 AND @ServiceType=8 ----根据周数查询3/6广告的资费信息
  792. BEGIN
  793. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  794. @dcFeeDetailsID = a.ID
  795. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  796. WHERE a.dcFeeID = b.ID
  797. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  798. AND b.type = 20
  799. AND StartDate < GETDATE() AND EndDate > GETDATE()
  800. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  801. IF @dcFeeDetailsID IS NULL
  802. SELECT TOP 1 @Accounts = Price
  803. FROM dcFee WITH(NOLOCK)
  804. WHERE type = 20
  805. AND dcProvinceID = LEFT(@ProvinceID,2)
  806. AND StartDate < GETDATE() AND EndDate > GETDATE()
  807. END
  808. ELSE IF @OrderType = 4 AND @ServiceType=9 ----根据周数查询6/6广告的资费信息
  809. BEGIN
  810. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  811. @dcFeeDetailsID = a.ID
  812. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  813. WHERE b.type = 21
  814. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  815. AND StartDate < GETDATE() AND EndDate > GETDATE()
  816. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  817. AND a.dcFeeID = b.ID
  818. IF @dcFeeDetailsID IS NULL
  819. SELECT TOP 1 @Accounts = Price
  820. FROM dcFee WITH(NOLOCK)
  821. WHERE type = 21
  822. AND dcProvinceID = LEFT(@ProvinceID,2)
  823. AND StartDate < GETDATE() AND EndDate > GETDATE()
  824. END
  825. ELSE IF @OrderType = 4 AND @ServiceType=10 ----根据周数查询6/6广告的资费信息
  826. BEGIN
  827. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  828. @dcFeeDetailsID = a.ID
  829. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  830. WHERE b.type = 23
  831. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  832. AND StartDate < GETDATE() AND EndDate > GETDATE()
  833. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  834. AND a.dcFeeID = b.ID
  835. IF @dcFeeDetailsID IS NULL
  836. SELECT TOP 1 @Accounts = Price
  837. FROM dcFee WITH(NOLOCK)
  838. WHERE type = 23
  839. AND dcProvinceID = LEFT(@ProvinceID,2)
  840. AND StartDate < GETDATE() AND EndDate > GETDATE()
  841. END
  842. ELSE IF @OrderType =7 ----根据周数查询固定位置的资费信息
  843. BEGIN
  844. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  845. @dcFeeDetailsID = a.ID
  846. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  847. WHERE b.type = 7
  848. AND a.dcFeeID = b.ID
  849. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  850. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  851. AND StartDate < GETDATE() AND EndDate > GETDATE()
  852. IF @dcFeeDetailsID IS NULL
  853. SELECT TOP 1 @Accounts = Price
  854. FROM dcFee WITH(NOLOCK)
  855. WHERE type = 7
  856. AND dcProvinceID = LEFT(@ProvinceID,2)
  857. AND StartDate < GETDATE() AND EndDate > GETDATE()
  858. END
  859. ELSE IF @OrderType = 12 ----根据周数查询职位置顶位置的资费信息
  860. BEGIN
  861. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  862. @dcFeeDetailsID = a.ID
  863. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  864. WHERE b.type = 22
  865. AND a.dcFeeID = b.ID
  866. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  867. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  868. AND StartDate < GETDATE() AND EndDate > GETDATE()
  869. IF @dcFeeDetailsID IS NULL
  870. SELECT TOP 1 @Accounts = Price
  871. FROM dcFee WITH(NOLOCK)
  872. WHERE type = 22
  873. AND dcProvinceID = LEFT(@ProvinceID,2)
  874. AND StartDate < GETDATE() AND EndDate > GETDATE()
  875. END
  876. ELSE IF @OrderType = 13 ----根据周数查询职位置顶位置的资费信息
  877. BEGIN
  878. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  879. @dcFeeDetailsID = a.ID
  880. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  881. WHERE b.type = 24
  882. AND a.dcFeeID = b.ID
  883. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  884. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  885. AND StartDate < GETDATE() AND EndDate > GETDATE()
  886. IF @dcFeeDetailsID IS NULL
  887. SELECT TOP 1 @Accounts = Price
  888. FROM dcFee WITH(NOLOCK)
  889. WHERE type = 24
  890. AND dcProvinceID = LEFT(@ProvinceID,2)
  891. AND StartDate < GETDATE() AND EndDate > GETDATE()
  892. END
  893. ELSE IF @OrderType = 9 ----根据周数查询简历下载的资费信息
  894. BEGIN
  895. SELECT TOP 1 @Accounts = b.Price * @ActiveQuota,
  896. @dcFeeDetailsID = a.ID
  897. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  898. WHERE b.type = 9
  899. AND a.dcFeeID = b.ID
  900. AND ((MinValue<=@ActiveQuota AND MaxValue>=@ActiveQuota) OR (MinValue<=@ActiveQuota AND MaxValue=0))
  901. AND StartDate < GETDATE() AND EndDate > GETDATE()
  902. IF @dcFeeDetailsID IS NULL
  903. SELECT TOP 1 @Accounts = Price
  904. FROM dcFee WITH(NOLOCK)
  905. WHERE type = 9
  906. AND dcProvinceID = LEFT(@ProvinceID,2)
  907. AND StartDate < GETDATE() AND EndDate > GETDATE()
  908. END
  909. ELSE IF @OrderType = 10 ----根据周数查询职位数的资费信息
  910. BEGIN
  911. SELECT TOP 1 @Accounts = b.Price * @JobNumber,
  912. @dcFeeDetailsID = a.ID
  913. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  914. WHERE b.type = 10
  915. AND a.dcFeeID = b.ID
  916. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  917. AND ((MinValue<=@JobNumber AND MaxValue>=@JobNumber) OR (MinValue<=@JobNumber AND MaxValue=0))
  918. AND StartDate < GETDATE() AND EndDate > GETDATE()
  919. IF @dcFeeDetailsID IS NULL
  920. SELECT TOP 1 @Accounts = Price
  921. FROM dcFee WITH(NOLOCK)
  922. WHERE type = 10
  923. AND dcProvinceID = LEFT(@ProvinceID,2)
  924. AND StartDate < GETDATE() AND EndDate > GETDATE()
  925. END
  926. ELSE IF @OrderType = 11 ----根据周数查询用户数的资费信息
  927. BEGIN
  928. SELECT TOP 1 @Accounts = b.Price * @UserNumber,
  929. @dcFeeDetailsID = a.ID
  930. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  931. WHERE b.type = 11
  932. AND a.dcFeeID = b.ID
  933. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  934. AND ((MinValue<=@UserNumber AND MaxValue>=@UserNumber) OR (MinValue<=@UserNumber AND MaxValue=0))
  935. AND StartDate < GETDATE() AND EndDate > GETDATE()
  936. IF @dcFeeDetailsID IS NULL
  937. SELECT TOP 1 @Accounts = Price
  938. FROM dcFee WITH(NOLOCK)
  939. WHERE type = 11
  940. AND dcProvinceID = LEFT(@ProvinceID,2)
  941. AND StartDate < GETDATE() AND EndDate > GETDATE()
  942. END
  943. END
  944. IF @MainOrderID IS NOT NULL
  945. IF NOT EXISTS(SELECT 'x' FROM caOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND ID = @MainOrderID AND OrderType = 8 AND EndDate >GETDATE())
  946. AND @OrderType in (9,10,11)
  947. GOTO ERR --检查是否是自己有效的主订单号
  948. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,
  949. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,
  950. NeedInvoice,InvoiceTitle,MailAddress,Recipient,PostTelephone,Zip,InvoiceConfirmDate,InvoiceConfirmMan,UserNumber,dcFeeDetailID,IsBackSubmit)
  951. VALUES(@cpMainID,@ProvinceID,@ServiceType,@PlaceWeek,@PayMethod,
  952. @OrderType,@Accounts,@Paid,@Balance,@LinkMan,@Telephone,@LinkRemark,@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,
  953. @NeedInvoice,@InvoiceTitle,@MailAddress,@Recipient,@PostTelephone,@Zip,@InvoiceConfirmDate,@InvoiceConfirmMan,@UserNumber,@dcFeeDetailsID,1)
  954. SET @MaxID = @@IDENTITY
  955. IF @Paid != 0
  956. BEGIN
  957. DECLARE @Temp AS NUMERIC(18,2)
  958. SET @Temp = @Paid -- 1 + CONVERT(NUMERIC(18,2),'0.'+RIGHT(STR(@cpMainID),2))
  959. UPDATE caOrder SET Paid = @Temp WHERE ID = @MaxID
  960. END
  961. END TRY
  962. BEGIN CATCH
  963. GOTO ERR
  964. END CATCH
  965. COMMIT TRAN
  966. RETURN @MaxID
  967. ERR:
  968. BEGIN
  969. ROLLBACK TRAN
  970. RETURN 0
  971. END
  972. GO
  973. /****** Object: StoredProcedure [dbo].[bsCaOrderInsert2] Script Date: 2018/12/13 19:05:29 ******/
  974. SET ANSI_NULLS ON
  975. GO
  976. SET QUOTED_IDENTIFIER ON
  977. GO
  978. -- =============================================
  979. -- 修改记录: 2015.1.15 John 添加后台提交订单使用金币
  980. -- 修改记录:2017.6.8 Harry 添加后台提交短信订单
  981. -- 修改记录:2017.11.17 Harry 添加后台提交职位刷新数订单
  982. -- =============================================
  983. CREATE PROCEDURE [dbo].[bsCaOrderInsert2]
  984. (
  985. @cpMainID INT,
  986. @caMainID INT,
  987. @ProvinceID INT,
  988. @ServiceType INT,
  989. @PlaceWeek TINYINT=NULL,
  990. @PayMethod TINYINT,
  991. @OrderType TINYINT,
  992. @Accounts NUMERIC(18,2),
  993. @Paid NUMERIC(18,2),
  994. @Balance NUMERIC(18,2)=NULL,
  995. @LinkMan NVARCHAR(50),
  996. @Telephone VARCHAR(50),
  997. @LinkRemark NVARCHAR(1000),
  998. @Manageruserid SMALLINT,
  999. @ActiveQuota SMALLINT=NULL,
  1000. @JobNumber SMALLINT=NULL,
  1001. @CompanyName VARCHAR(100),
  1002. @MainOrderID INT=NULL,
  1003. @InvoiceCompany SMALLINT,
  1004. @NeedInvoice bit=null,
  1005. @InvoiceTitle NVARCHAR(50)=null,
  1006. @MailAddress NVARCHAR(100)=null,
  1007. @Recipient NVARCHAR(100)=null,
  1008. @PostTelephone NVARCHAR(50)=null,
  1009. @Zip CHAR(6)=null,
  1010. @InvoiceConfirmDate VARCHAR(20)=null,
  1011. @InvoiceConfirmMan SMALLINT=null,
  1012. @UserNumber SMALLINT=NULL,
  1013. @dcFeeDetailsID INT=NULL,
  1014. @UseCoin INT=NULL,
  1015. @SmsQuota INT=NULL,
  1016. @jobRefreshQuota INT=NULL
  1017. )
  1018. AS
  1019. SET NOCOUNT ON
  1020. IF @ManagerUserId = 0
  1021. SET @ManagerUserId = NULL
  1022. BEGIN TRAN
  1023. Declare @MaxId AS INT
  1024. --BEGIN TRY
  1025. IF @InvoiceConfirmDate = ''
  1026. SET @InvoiceConfirmDate = NULL
  1027. IF @dcFeeDetailsID = 0
  1028. SET @dcFeeDetailsID = NULL
  1029. IF NOT(@Paid = 0 AND @Accounts = 0)
  1030. BEGIN
  1031. IF @OrderType = 8
  1032. BEGIN
  1033. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  1034. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID,2) AND b.ID = @dcFeeDetailsID AND a.startDate<GETDATE() AND a.endDate > GETDATE())
  1035. GOTO ERR --检查是否套餐已过期
  1036. SELECT @Accounts = (b.PriceMonth * a.[Month]+a.ResumeNumber*b.PriceResume+JobNumber*b.PriceJob+UserNumber*b.PriceUser+isNULL(b.PriceSms,0)*ISNULL(SmsNumber,0)+isNULL(b.PriceJobRefreshNumber,0)*ISNULL(JobRefreshNumber,0)),
  1037. @Paid = a.Price,
  1038. @ActiveQuota = a.ResumeNumber,
  1039. @JobNumber = a.JobNumber,
  1040. @UserNumber = a.UserNumber,
  1041. @SmsQuota = a.SmsNumber,
  1042. @jobRefreshQuota =a.JobRefreshNumber
  1043. FROM dcVipDetail a WITH(NOLOCK) ,dcVip b WITH(NOLOCK)
  1044. WHERE a.ID = @dcFeeDetailsID
  1045. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1046. AND a.dcVipID = b.ID
  1047. END
  1048. Else IF @OrderType = 4 AND @ServiceType=6 ----根据周数查询1/6广告的资费信息
  1049. BEGIN
  1050. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1051. @Paid = a.Price * @PlaceWeek,
  1052. @dcFeeDetailsID = a.ID
  1053. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1054. WHERE a.dcFeeID = b.ID
  1055. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1056. AND b.type = 4
  1057. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1058. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1059. IF @dcFeeDetailsID IS NULL
  1060. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  1061. FROM dcFee WITH(NOLOCK)
  1062. WHERE type = 4
  1063. AND dcProvinceID = LEFT(@ProvinceID,2)
  1064. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1065. END
  1066. ELSE IF @OrderType = 4 AND @ServiceType=7 ----根据周数查询2/6广告的资费信息
  1067. BEGIN
  1068. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1069. @Paid = a.Price * @PlaceWeek,
  1070. @dcFeeDetailsID = a.ID
  1071. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1072. WHERE b.type = 5
  1073. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1074. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1075. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1076. AND a.dcFeeID = b.ID
  1077. IF @dcFeeDetailsID IS NULL
  1078. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  1079. FROM dcFee WITH(NOLOCK)
  1080. WHERE type = 5
  1081. AND dcProvinceID = LEFT(@ProvinceID,2)
  1082. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1083. END
  1084. Else IF @OrderType = 4 AND @ServiceType=8 ----根据周数查询3/6广告的资费信息
  1085. BEGIN
  1086. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1087. @Paid = a.Price * @PlaceWeek,
  1088. @dcFeeDetailsID = a.ID
  1089. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1090. WHERE a.dcFeeID = b.ID
  1091. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1092. AND b.type = 20
  1093. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1094. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1095. IF @dcFeeDetailsID IS NULL
  1096. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  1097. FROM dcFee WITH(NOLOCK)
  1098. WHERE type = 20
  1099. AND dcProvinceID = LEFT(@ProvinceID,2)
  1100. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1101. END
  1102. ELSE IF @OrderType = 4 AND @ServiceType=9 ----根据周数查询6/6广告的资费信息
  1103. BEGIN
  1104. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1105. @Paid = a.Price * @PlaceWeek,
  1106. @dcFeeDetailsID = a.ID
  1107. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1108. WHERE b.type = 21
  1109. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1110. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1111. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1112. AND a.dcFeeID = b.ID
  1113. IF @dcFeeDetailsID IS NULL
  1114. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  1115. FROM dcFee WITH(NOLOCK)
  1116. WHERE type = 21
  1117. AND dcProvinceID = LEFT(@ProvinceID,2)
  1118. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1119. END
  1120. ELSE IF @OrderType = 4 AND @ServiceType=10 ----根据周数查询6/6广告的资费信息
  1121. BEGIN
  1122. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1123. @Paid = a.Price * @PlaceWeek,
  1124. @dcFeeDetailsID = a.ID
  1125. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1126. WHERE b.type = 23
  1127. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1128. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1129. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1130. AND a.dcFeeID = b.ID
  1131. IF @dcFeeDetailsID IS NULL
  1132. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  1133. FROM dcFee WITH(NOLOCK)
  1134. WHERE type = 23
  1135. AND dcProvinceID = LEFT(@ProvinceID,2)
  1136. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1137. END
  1138. ELSE IF @OrderType =7 ----根据周数查询固定位置的资费信息
  1139. BEGIN
  1140. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1141. @Paid = a.Price * @PlaceWeek,
  1142. @dcFeeDetailsID = a.ID
  1143. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1144. WHERE b.type = 7
  1145. AND a.dcFeeID = b.ID
  1146. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1147. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1148. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1149. IF @dcFeeDetailsID IS NULL
  1150. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  1151. FROM dcFee WITH(NOLOCK)
  1152. WHERE type = 7
  1153. AND dcProvinceID = LEFT(@ProvinceID,2)
  1154. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1155. END
  1156. ELSE IF @OrderType = 12 ----根据周数查询职位置顶位置的资费信息
  1157. BEGIN
  1158. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1159. @Paid = a.Price * @PlaceWeek,
  1160. @dcFeeDetailsID = a.ID
  1161. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1162. WHERE b.type = 22
  1163. AND a.dcFeeID = b.ID
  1164. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1165. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1166. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1167. IF @dcFeeDetailsID IS NULL
  1168. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  1169. FROM dcFee WITH(NOLOCK)
  1170. WHERE type = 22
  1171. AND dcProvinceID = LEFT(@ProvinceID,2)
  1172. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1173. END
  1174. ELSE IF @OrderType = 13 ----根据周数查询职位置顶位置的资费信息
  1175. BEGIN
  1176. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1177. @Paid = a.Price * @PlaceWeek,
  1178. @dcFeeDetailsID = a.ID
  1179. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1180. WHERE b.type = 24
  1181. AND a.dcFeeID = b.ID
  1182. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1183. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1184. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1185. IF @dcFeeDetailsID IS NULL
  1186. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  1187. FROM dcFee WITH(NOLOCK)
  1188. WHERE type = 24
  1189. AND dcProvinceID = LEFT(@ProvinceID,2)
  1190. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1191. END
  1192. ELSE IF @OrderType = 9 ----根据周数查询简历下载的资费信息
  1193. BEGIN
  1194. SELECT TOP 1 @Accounts = b.Price * @ActiveQuota,
  1195. @Paid = a.Price * @ActiveQuota,
  1196. @dcFeeDetailsID = a.ID
  1197. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1198. WHERE b.type = 9
  1199. AND a.dcFeeID = b.ID
  1200. AND ((MinValue<=@ActiveQuota AND MaxValue>=@ActiveQuota) OR (MinValue<=@ActiveQuota AND MaxValue=0))
  1201. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1202. IF @dcFeeDetailsID IS NULL
  1203. SELECT TOP 1 @Accounts = Price, @Paid = Price * @ActiveQuota
  1204. FROM dcFee WITH(NOLOCK)
  1205. WHERE type = 9
  1206. AND dcProvinceID = LEFT(@ProvinceID,2)
  1207. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1208. END
  1209. ELSE IF @OrderType = 10 ----根据周数查询职位数的资费信息
  1210. BEGIN
  1211. SELECT TOP 1 @Accounts = b.Price * @JobNumber,
  1212. @Paid = a.Price * @JobNumber,
  1213. @dcFeeDetailsID = a.ID
  1214. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1215. WHERE b.type = 10
  1216. AND a.dcFeeID = b.ID
  1217. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1218. AND ((MinValue<=@JobNumber AND MaxValue>=@JobNumber) OR (MinValue<=@JobNumber AND MaxValue=0))
  1219. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1220. IF @dcFeeDetailsID IS NULL
  1221. SELECT TOP 1 @Accounts = Price, @Paid = Price * @JobNumber
  1222. FROM dcFee WITH(NOLOCK)
  1223. WHERE type = 10
  1224. AND dcProvinceID = LEFT(@ProvinceID,2)
  1225. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1226. END
  1227. ELSE IF @OrderType = 11 ----根据周数查询用户数的资费信息
  1228. BEGIN
  1229. SELECT TOP 1 @Accounts = b.Price * @UserNumber,
  1230. @Paid = a.Price * @UserNumber,
  1231. @dcFeeDetailsID = a.ID
  1232. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1233. WHERE b.type = 11
  1234. AND a.dcFeeID = b.ID
  1235. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1236. AND ((MinValue<=@UserNumber AND MaxValue>=@UserNumber) OR (MinValue<=@UserNumber AND MaxValue=0))
  1237. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1238. IF @dcFeeDetailsID IS NULL
  1239. SELECT TOP 1 @Accounts = Price, @Paid = Price * @UserNumber
  1240. FROM dcFee WITH(NOLOCK)
  1241. WHERE type = 11
  1242. AND dcProvinceID = LEFT(@ProvinceID,2)
  1243. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1244. END
  1245. ELSE IF @OrderType = 14 ----根据周数查询短信数的资费信息
  1246. BEGIN
  1247. SELECT TOP 1 @Accounts = b.Price * @SmsQuota,
  1248. @Paid = a.Price * @SmsQuota,
  1249. @dcFeeDetailsID = a.ID
  1250. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1251. WHERE b.type = 14
  1252. AND a.dcFeeID = b.ID
  1253. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1254. AND ((MinValue<=@SmsQuota AND MaxValue>=@SmsQuota) OR (MinValue<=@SmsQuota AND MaxValue=0))
  1255. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1256. IF @dcFeeDetailsID IS NULL
  1257. SELECT TOP 1 @Accounts = Price, @Paid = Price * @SmsQuota
  1258. FROM dcFee WITH(NOLOCK)
  1259. WHERE type = 14
  1260. AND dcProvinceID = LEFT(@ProvinceID,2)
  1261. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1262. END
  1263. ELSE IF @OrderType = 15 ----职位刷新数
  1264. BEGIN
  1265. SELECT TOP 1 @Accounts = b.Price * @jobRefreshQuota,
  1266. @Paid = a.Price * @jobRefreshQuota,
  1267. @dcFeeDetailsID = a.ID
  1268. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1269. WHERE b.type = 15
  1270. AND a.dcFeeID = b.ID
  1271. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1272. AND ((MinValue<=@jobRefreshQuota AND MaxValue>=@jobRefreshQuota) OR (MinValue<=@jobRefreshQuota AND MaxValue=0))
  1273. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1274. IF @dcFeeDetailsID IS NULL
  1275. SELECT TOP 1 @Accounts = Price, @Paid = Price * @jobRefreshQuota
  1276. FROM dcFee WITH(NOLOCK)
  1277. WHERE type = 15
  1278. AND dcProvinceID = LEFT(@ProvinceID,2)
  1279. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1280. END
  1281. END
  1282. ELSE
  1283. BEGIN
  1284. IF @OrderType = 8
  1285. BEGIN
  1286. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK),dcVipDetail b WITH(NOLOCK)
  1287. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID,2) AND b.ID = @dcFeeDetailsID AND a.startDate<GETDATE() AND a.endDate > GETDATE())
  1288. GOTO ERR --检查是否套餐已过期
  1289. SELECT @Accounts = (b.PriceMonth * a.[Month]+a.ResumeNumber*b.PriceResume+JobNumber*b.PriceJob+UserNumber*b.PriceUser+ISNULL(SmsNumber,0)*ISNULL(b.PriceSms,0)+ISNULL(JobRefreshNumber,0)*ISNULL(b.PriceJobRefreshNumber,0)),
  1290. @dcFeeDetailsID = a.Price
  1291. FROM dcVipDetail a WITH(NOLOCK) ,dcVip b WITH(NOLOCK)
  1292. WHERE a.ID = @dcFeeDetailsID
  1293. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1294. AND a.dcVipID = b.ID
  1295. END
  1296. Else IF @OrderType = 4 AND @ServiceType=6 ----根据周数查询1/6广告的资费信息
  1297. BEGIN
  1298. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1299. @dcFeeDetailsID = a.ID
  1300. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1301. WHERE a.dcFeeID = b.ID
  1302. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1303. AND b.type = 4
  1304. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1305. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1306. IF @dcFeeDetailsID IS NULL
  1307. SELECT TOP 1 @Accounts = Price
  1308. FROM dcFee WITH(NOLOCK)
  1309. WHERE type = 4
  1310. AND dcProvinceID = LEFT(@ProvinceID,2)
  1311. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1312. END
  1313. ELSE IF @OrderType = 4 AND @ServiceType=7 ----根据周数查询2/6广告的资费信息
  1314. BEGIN
  1315. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1316. @dcFeeDetailsID = a.ID
  1317. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1318. WHERE b.type = 5
  1319. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1320. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1321. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1322. AND a.dcFeeID = b.ID
  1323. IF @dcFeeDetailsID IS NULL
  1324. SELECT TOP 1 @Accounts = Price
  1325. FROM dcFee WITH(NOLOCK)
  1326. WHERE type = 5
  1327. AND dcProvinceID = LEFT(@ProvinceID,2)
  1328. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1329. END
  1330. Else IF @OrderType = 4 AND @ServiceType=8 ----根据周数查询3/6广告的资费信息
  1331. BEGIN
  1332. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1333. @dcFeeDetailsID = a.ID
  1334. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1335. WHERE a.dcFeeID = b.ID
  1336. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1337. AND b.type = 20
  1338. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1339. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1340. IF @dcFeeDetailsID IS NULL
  1341. SELECT TOP 1 @Accounts = Price
  1342. FROM dcFee WITH(NOLOCK)
  1343. WHERE type = 20
  1344. AND dcProvinceID = LEFT(@ProvinceID,2)
  1345. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1346. END
  1347. ELSE IF @OrderType = 4 AND @ServiceType=9 ----根据周数查询6/6广告的资费信息
  1348. BEGIN
  1349. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1350. @dcFeeDetailsID = a.ID
  1351. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1352. WHERE b.type = 21
  1353. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1354. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1355. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1356. AND a.dcFeeID = b.ID
  1357. IF @dcFeeDetailsID IS NULL
  1358. SELECT TOP 1 @Accounts = Price
  1359. FROM dcFee WITH(NOLOCK)
  1360. WHERE type = 21
  1361. AND dcProvinceID = LEFT(@ProvinceID,2)
  1362. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1363. END
  1364. ELSE IF @OrderType = 4 AND @ServiceType=10 ----根据周数查询6/6广告的资费信息
  1365. BEGIN
  1366. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1367. @dcFeeDetailsID = a.ID
  1368. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1369. WHERE b.type = 23
  1370. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1371. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1372. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1373. AND a.dcFeeID = b.ID
  1374. IF @dcFeeDetailsID IS NULL
  1375. SELECT TOP 1 @Accounts = Price
  1376. FROM dcFee WITH(NOLOCK)
  1377. WHERE type = 23
  1378. AND dcProvinceID = LEFT(@ProvinceID,2)
  1379. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1380. END
  1381. ELSE IF @OrderType =7 ----根据周数查询固定位置的资费信息
  1382. BEGIN
  1383. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1384. @dcFeeDetailsID = a.ID
  1385. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1386. WHERE b.type = 7
  1387. AND a.dcFeeID = b.ID
  1388. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1389. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1390. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1391. IF @dcFeeDetailsID IS NULL
  1392. SELECT TOP 1 @Accounts = Price
  1393. FROM dcFee WITH(NOLOCK)
  1394. WHERE type = 7
  1395. AND dcProvinceID = LEFT(@ProvinceID,2)
  1396. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1397. END
  1398. ELSE IF @OrderType = 12 ----根据周数查询职位置顶位置的资费信息
  1399. BEGIN
  1400. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1401. @dcFeeDetailsID = a.ID
  1402. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1403. WHERE b.type = 22
  1404. AND a.dcFeeID = b.ID
  1405. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1406. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1407. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1408. IF @dcFeeDetailsID IS NULL
  1409. SELECT TOP 1 @Accounts = Price
  1410. FROM dcFee WITH(NOLOCK)
  1411. WHERE type = 22
  1412. AND dcProvinceID = LEFT(@ProvinceID,2)
  1413. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1414. END
  1415. ELSE IF @OrderType = 13 ----根据周数查询职位置顶位置的资费信息
  1416. BEGIN
  1417. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  1418. @dcFeeDetailsID = a.ID
  1419. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1420. WHERE b.type = 24
  1421. AND a.dcFeeID = b.ID
  1422. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1423. AND ((MinValue<=@PlaceWeek AND MaxValue>=@PlaceWeek) OR (MinValue<=@PlaceWeek AND MaxValue=0))
  1424. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1425. IF @dcFeeDetailsID IS NULL
  1426. SELECT TOP 1 @Accounts = Price
  1427. FROM dcFee WITH(NOLOCK)
  1428. WHERE type = 24
  1429. AND dcProvinceID = LEFT(@ProvinceID,2)
  1430. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1431. END
  1432. ELSE IF @OrderType = 9 ----根据周数查询简历下载的资费信息
  1433. BEGIN
  1434. SELECT TOP 1 @Accounts = b.Price * @ActiveQuota,
  1435. @dcFeeDetailsID = a.ID
  1436. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1437. WHERE b.type = 9
  1438. AND a.dcFeeID = b.ID
  1439. AND ((MinValue<=@ActiveQuota AND MaxValue>=@ActiveQuota) OR (MinValue<=@ActiveQuota AND MaxValue=0))
  1440. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1441. IF @dcFeeDetailsID IS NULL
  1442. SELECT TOP 1 @Accounts = Price
  1443. FROM dcFee WITH(NOLOCK)
  1444. WHERE type = 9
  1445. AND dcProvinceID = LEFT(@ProvinceID,2)
  1446. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1447. END
  1448. ELSE IF @OrderType = 10 ----根据周数查询职位数的资费信息
  1449. BEGIN
  1450. SELECT TOP 1 @Accounts = b.Price * @JobNumber,
  1451. @dcFeeDetailsID = a.ID
  1452. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1453. WHERE b.type = 10
  1454. AND a.dcFeeID = b.ID
  1455. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1456. AND ((MinValue<=@JobNumber AND MaxValue>=@JobNumber) OR (MinValue<=@JobNumber AND MaxValue=0))
  1457. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1458. IF @dcFeeDetailsID IS NULL
  1459. SELECT TOP 1 @Accounts = Price
  1460. FROM dcFee WITH(NOLOCK)
  1461. WHERE type = 10
  1462. AND dcProvinceID = LEFT(@ProvinceID,2)
  1463. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1464. END
  1465. ELSE IF @OrderType = 11 ----根据周数查询用户数的资费信息
  1466. BEGIN
  1467. SELECT TOP 1 @Accounts = b.Price * @UserNumber,
  1468. @dcFeeDetailsID = a.ID
  1469. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1470. WHERE b.type = 11
  1471. AND a.dcFeeID = b.ID
  1472. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1473. AND ((MinValue<=@UserNumber AND MaxValue>=@UserNumber) OR (MinValue<=@UserNumber AND MaxValue=0))
  1474. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1475. IF @dcFeeDetailsID IS NULL
  1476. SELECT TOP 1 @Accounts = Price
  1477. FROM dcFee WITH(NOLOCK)
  1478. WHERE type = 11
  1479. AND dcProvinceID = LEFT(@ProvinceID,2)
  1480. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1481. END
  1482. ELSE IF @OrderType = 14 ----根据周数查询短信数的资费信息
  1483. BEGIN
  1484. SELECT TOP 1 @Accounts = b.Price * @SmsQuota,
  1485. @dcFeeDetailsID = a.ID
  1486. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1487. WHERE b.type = 14
  1488. AND a.dcFeeID = b.ID
  1489. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1490. AND ((MinValue<=@SmsQuota AND MaxValue>=@SmsQuota ) OR (MinValue<=@SmsQuota AND MaxValue=0))
  1491. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1492. IF @dcFeeDetailsID IS NULL
  1493. SELECT TOP 1 @Accounts = Price
  1494. FROM dcFee WITH(NOLOCK)
  1495. WHERE type = 14
  1496. AND dcProvinceID = LEFT(@ProvinceID,2)
  1497. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1498. END
  1499. ELSE IF @OrderType = 15 ----职位刷新数
  1500. BEGIN
  1501. SELECT TOP 1 @Accounts = b.Price * @jobRefreshQuota,
  1502. @dcFeeDetailsID = a.ID
  1503. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  1504. WHERE b.type = 15
  1505. AND a.dcFeeID = b.ID
  1506. AND b.dcProvinceID = LEFT(@ProvinceID,2)
  1507. AND ((MinValue<=@jobRefreshQuota AND MaxValue>=@jobRefreshQuota ) OR (MinValue<=@jobRefreshQuota AND MaxValue=0))
  1508. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1509. IF @dcFeeDetailsID IS NULL
  1510. SELECT TOP 1 @Accounts = Price
  1511. FROM dcFee WITH(NOLOCK)
  1512. WHERE type = 15
  1513. AND dcProvinceID = LEFT(@ProvinceID,2)
  1514. AND StartDate < GETDATE() AND EndDate > GETDATE()
  1515. END
  1516. END
  1517. IF @MainOrderID IS NOT NULL
  1518. IF NOT EXISTS(SELECT 'x' FROM caOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND ID = @MainOrderID AND OrderType = 8 AND EndDate >GETDATE())
  1519. AND @OrderType in (9,10,11,14)
  1520. GOTO ERR --检查是否是自己有效的主订单号
  1521. DECLARE @CoinBalance AS INT
  1522. IF @UseCoin IS NOT NULL --金币支付
  1523. BEGIN
  1524. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainCoin >= @UseCoin)
  1525. GOTO ERR --检查剩余金币数量是否足够支付
  1526. SET @Paid = @Paid - @UseCoin
  1527. END
  1528. IF @Paid < 0
  1529. SET @Paid = 0
  1530. INSERT INTO caOrder (cpMainID,ProvinceID,ServiceType,PlaceWeek,PayMethod,
  1531. OrderType,Accounts,Paid,Balance,LinkMan,Telephone,LinkRemark,Manageruserid,ActiveQuota,RemainQuota,JobNumber,CompanyName,MainOrderID,InvoiceCompany,
  1532. NeedInvoice,InvoiceTitle,MailAddress,Recipient,PostTelephone,Zip,InvoiceConfirmDate,InvoiceConfirmMan,UserNumber,dcFeeDetailID,IsBackSubmit,PaidCoin,SmsQuota,RemainSmsQuota, jobRefreshQuota, remainJobRefreshQuota)
  1533. VALUES(@cpMainID,@ProvinceID,@ServiceType,@PlaceWeek,@PayMethod,
  1534. @OrderType,@Accounts,@Paid,@Balance,@LinkMan,@Telephone,@LinkRemark,@Manageruserid,@ActiveQuota,@ActiveQuota,@JobNumber,@CompanyName,@MainOrderID,@InvoiceCompany,
  1535. @NeedInvoice,@InvoiceTitle,@MailAddress,@Recipient,@PostTelephone,@Zip,@InvoiceConfirmDate,@InvoiceConfirmMan,@UserNumber,@dcFeeDetailsID,1,@UseCoin,@SmsQuota,@SmsQuota, @jobRefreshQuota, @jobRefreshQuota)
  1536. SET @MaxID = @@IDENTITY
  1537. IF @Paid != 0
  1538. BEGIN
  1539. DECLARE @Temp AS NUMERIC(18,2)
  1540. SET @Temp = @Paid -- 1 + CONVERT(NUMERIC(18,2),'0.'+RIGHT(STR(@cpMainID),2))
  1541. --金币或订单全额支付
  1542. IF @Temp < 0
  1543. SET @Temp = 0
  1544. UPDATE caOrder SET Paid = @Temp WHERE ID = @MaxID
  1545. END
  1546. IF @UseCoin IS NOT NULL
  1547. BEGIN
  1548. --插入金币记录
  1549. INSERT INTO cpCoin (cpMainID, caOrderID, Coin, Balance, AddDate)
  1550. VALUES(@cpMainID, @MaxID, 0 - @UseCoin, 0, GETDATE())
  1551. END
  1552. --END TRY
  1553. --BEGIN CATCH
  1554. -- GOTO ERR
  1555. --END CATCH
  1556. COMMIT TRAN
  1557. RETURN @MaxID
  1558. ERR:
  1559. BEGIN
  1560. ROLLBACK TRAN
  1561. RETURN 0
  1562. END
  1563. SET NOCOUNT OFF
  1564. GO
  1565. /****** Object: StoredProcedure [dbo].[bsColdcustomerByAddManSelect] Script Date: 2018/12/13 19:05:30 ******/
  1566. SET ANSI_NULLS ON
  1567. GO
  1568. SET QUOTED_IDENTIFIER ON
  1569. GO
  1570. --推广冷客户认证等数据统计
  1571. --harry 2018-1-23
  1572. --bsColdcustomerByAddManSelect '2017-1-1','2018-12-1'
  1573. CREATE PROCEDURE [dbo].[bsColdcustomerByAddManSelect]
  1574. (
  1575. @begin DATETIME,
  1576. @end DATETIME,
  1577. @managerUserId INT=0
  1578. )
  1579. AS
  1580. BEGIN
  1581. SET NOCOUNT ON
  1582. CREATE TABLE #t(managerUserid INT,name VARCHAR(10), addCount INT , cerPassCount INT, cerIngCount INT,uncerCount INT, regCount INT,superior INT)
  1583. IF @managerUserId IN(201,302,304,363,701,105)
  1584. BEGIN
  1585. INSERT INTO #t(managerUserId)
  1586. SELECT DISTINCT AddMan FROM coldcustomer where addMan IN(select id from manageruser where deptid=15)
  1587. END
  1588. ELSE
  1589. BEGIN
  1590. INSERT INTO #t(managerUserId)
  1591. SELECT DISTINCT AddMan FROM coldcustomer where addMan =@managerUserId
  1592. END
  1593. UPDATE #t
  1594. SET #t.Name= a.NAME,#t.superior = a.superior
  1595. FROM #t, managerUser a
  1596. WHERE #t.managerUserid =a.id
  1597. --添加量
  1598. UPDATE a
  1599. SET a.addCount =(SELECT COUNT(1)FROM coldcustomer b WHERE a.manageruSerId =b.AddMan AND b.AddDate BETWEEN @begin AND @end)
  1600. FROM #t a
  1601. --认证通过量
  1602. SELECT *
  1603. INTO #tcer
  1604. from logdb..coldcustomerCerLog
  1605. where (CerDate BETWEEN @begin AND @end)
  1606. AND addMan IN(select id from manageruser where deptid=15)
  1607. UPDATE a
  1608. SET a.cerPassCount= (SELECT COUNT(1) FROM #tcer b WHERE a.manageruSerId =b.AddMan)
  1609. FROM #t a
  1610. DROP TABLE #tcer
  1611. /*--认证中的数量
  1612. SELECT a.*,b.addMan
  1613. INTO #tcerIng
  1614. from cpCertification a, coldcustomer b
  1615. where CerStatus!=1 AND (a.AddDate BETWEEN @begin AND @end)
  1616. AND a.cpMainID IN(select id from cpmain where name IN(select Name from cpmain where id IN(select CpMainID FROM coldcustomer where addMan IN(select id from manageruser where deptid=15) )))
  1617. AND a.cpMainID NOT IN(SELECT cpMainID FROM cpCertification WHERE CerStatus =1 )
  1618. AND (a.CompanyName= b.CompanyName OR a.cpMainId = b.cpMainId)
  1619. AND b.addMan is not NULL
  1620. UPDATE a
  1621. SET a.cerIngCount= (SELECT COUNT(DISTINCT CompanyName) FROM #tcerIng b WHERE a.managerUserId =b.AddMan)
  1622. FROM #t a
  1623. DROP TABLE #tcerIng
  1624. */
  1625. --未认证数量(有营业执照,但未认证)
  1626. SELECT b.*
  1627. INTO #tuncer
  1628. FROM cpMain a,coldcustomer b
  1629. WHERE a.MemberType = 1
  1630. AND a.id=b.cpmainid AND EXISTS(SELECT 'X' FROM cpLicence WHERE cpMainID = a.ID AND HasPassed = 1)
  1631. AND b.addMan IN(select id from manageruser where deptid=15)
  1632. UPDATE a
  1633. SET a.uncerCount= (SELECT COUNT(1) FROM #tuncer b WHERE a.managerUserId =b.AddMan)
  1634. FROM #t a
  1635. DROP TABLE #tuncer
  1636. --注册量
  1637. SELECT *
  1638. INTO #tReg
  1639. FROM coldcustomer
  1640. WHERE Status =2 AND (RegisterDate BETWEEN @begin AND @end)
  1641. UPDATE a
  1642. SET a.regCount =(SELECT COUNT(1) FROM #tReg b WHERE a.manageruSerId =b.AddMan)
  1643. FROM #t a
  1644. DROP TABLE #tReg
  1645. SELECT *FROM #t
  1646. DROP TABLE #t
  1647. SET NOCOUNT OFF
  1648. END
  1649. GO
  1650. /****** Object: StoredProcedure [dbo].[bsColdcustomerUpdate] Script Date: 2018/12/13 19:05:30 ******/
  1651. SET ANSI_NULLS ON
  1652. GO
  1653. SET QUOTED_IDENTIFIER ON
  1654. GO
  1655. --修改冷客户企业名称
  1656. --harry
  1657. --2018-7-3
  1658. CREATE PROCEDURE [dbo].[bsColdcustomerUpdate]
  1659. (
  1660. @cpname NVARCHAR(100),
  1661. @coldcustomerId INT
  1662. )
  1663. AS
  1664. BEGIN
  1665. IF EXISTS(select 'x' FROM coldcustomer where CompanyName=@cpname AND id !=@coldcustomerId)
  1666. BEGIN
  1667. select -1 as result--存在重名的冷客户
  1668. return
  1669. END
  1670. IF EXISTS(select 'x' FROM cpmain where Name=@cpname AND ISNULL(ConsultantID,0)!=0)
  1671. BEGIN
  1672. select -2 as result--存在重名的公司且有顾问的企业
  1673. return
  1674. END
  1675. UPDATE coldcustomer SET CompanyName= @cpname WHERE id=@coldcustomerId
  1676. IF EXISTS( select 'x' FROM cpmain where Name=@cpname AND ISNULL(ConsultantID,0)=0)
  1677. BEGIN
  1678. SELECT id INTO #t FROM cpmain where Name=@cpname AND ISNULL(ConsultantID,0)=0
  1679. DECLARE @cpmainid INT, @manageruserId INT
  1680. SELECT @manageruserId=ManagerUserId
  1681. FROM oadb..workuser where id=(select AddWorkUserID FROM coldcustomer where id=@coldcustomerId )
  1682. SET @cpmainid=0
  1683. IF ISNULL(@manageruserId,0)!=0
  1684. BEGIN
  1685. WHILE EXISTS ( SELECT 'x' FROM #t)
  1686. BEGIN
  1687. SELECT TOP 1 @cpmainid= id FROM #t ORDER BY id
  1688. UPDATE cpmain set ConsultantId = @manageruserId, ConsultantDate = GETDATE()
  1689. WHERE id=@cpmainid
  1690. DELETE FROM #t where id=@cpmainid
  1691. END
  1692. END
  1693. DROP TABLE #t
  1694. END
  1695. SELECT 1 AS result
  1696. END
  1697. GO
  1698. /****** Object: StoredProcedure [dbo].[bsCompany_XinxiByEmailExist] Script Date: 2018/12/13 19:05:30 ******/
  1699. SET ANSI_NULLS ON
  1700. GO
  1701. SET QUOTED_IDENTIFIER ON
  1702. GO
  1703. --###########################################
  1704. --sean 2010-12-2
  1705. --信息员推广用,提交前先检查邮件是否已经注册过
  1706. -- -1 黑名单
  1707. -- -10 半年内信息员注册过
  1708. -- -11 已经是会员
  1709. --###########################################
  1710. CREATE PROCEDURE [dbo].[bsCompany_XinxiByEmailExist]
  1711. (
  1712. @Email VARCHAR(50)
  1713. )
  1714. AS
  1715. BEGIN
  1716. IF EXISTS(SELECT 'x' FROM Company_Xinxi WITH (NOLOCK INDEX(IX_Company_Xinxi_Email)) WHERE Email = @Email AND IsHistory = 0)
  1717. RETURN -10
  1718. IF EXISTS(SELECT 'x' FROM caMain WITH (NOLOCK INDEX(IX_caMain_Email)) WHERE Email = @Email)
  1719. RETURN -11
  1720. IF EXISTS(SELECT 'x' FROM Company_Black WITH(NOLOCK) WHERE Email = @Email)
  1721. RETURN -1
  1722. RETURN 1
  1723. END
  1724. GO
  1725. /****** Object: StoredProcedure [dbo].[bsCompany_XinxiInsert] Script Date: 2018/12/13 19:05:31 ******/
  1726. SET ANSI_NULLS ON
  1727. GO
  1728. SET QUOTED_IDENTIFIER ON
  1729. GO
  1730. -- =============================================
  1731. -- sean 2010-12-1
  1732. -- 用于信息员注册, 判断email是否存在
  1733. --返回值:
  1734. -- -1 邮件黑名单
  1735. -- -2 单位名称已被我们列入黑名单,不再接受注册。
  1736. -- -3 不要注册保险公司。
  1737. -- -4 不要注册娱乐公司。
  1738. -- -5 单位名称已重复(最近登录时间一个月内,而且有营业执照、而且登录次数大于0),不再接受注册
  1739. -- -6 不符合本地区规则,请放弃
  1740. -- -10 邮件半年内信息员注册过
  1741. -- -11 邮件已经是会员
  1742. -- -20 其他错误
  1743. -- =============================================
  1744. CREATE PROCEDURE [dbo].[bsCompany_XinxiInsert]
  1745. (
  1746. @CompanyName NVARCHAR(50),
  1747. @Username VARCHAR(50),
  1748. @Email VARCHAR(50),
  1749. @Password VARCHAR(50),
  1750. @ManagerUserID SMALLINT,
  1751. @ProvinceID TINYINT,
  1752. @un VARCHAR(50) OUTPUT,
  1753. @DBPassword VARCHAR(50) OUTPUT
  1754. )
  1755. AS
  1756. SET NOCOUNT ON;
  1757. IF LEN(ISNULL(@CompanyName, '')) = 0
  1758. GOTO Err
  1759. IF LEN(ISNULL(@Username, '')) = 0
  1760. GOTO Err
  1761. IF LEN(ISNULL(@Email, '')) = 0
  1762. GOTO Err
  1763. IF LEN(ISNULL(@Password, '')) = 0
  1764. GOTO Err
  1765. IF ISNULL(@ManagerUserID, 0) = 0
  1766. GOTO Err
  1767. IF ISNULL(@ProvinceID, 0) = 0
  1768. GOTO Err
  1769. IF dbo.IsEmail(@Email) = 0
  1770. GOTO Err
  1771. IF dbo.IsAccount(@UserName) = 0
  1772. GOTO Err
  1773. BEGIN TRY
  1774. DECLARE @r AS INT
  1775. DECLARE @Pass AS INT
  1776. IF @CompanyName LIKE '%人寿%'
  1777. RETURN -3 --不要注册保险公司。
  1778. IF @CompanyName LIKE '%娱乐%'
  1779. RETURN -4 --cont=不要注册娱乐公司。
  1780. --单位名称已重复(最近登录时间一个月内,而且有营业执照),不再接受注册
  1781. IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK)
  1782. WHERE HasLicence = 1
  1783. AND Name = @CompanyName
  1784. AND LastLoginDate > GETDATE() - 30
  1785. )
  1786. RETURN -5
  1787. --Email重复
  1788. EXEC @r = bsCompany_XinxiByEmailExist @Email
  1789. IF @r < 1
  1790. RETURN @r
  1791. --检查黑名单
  1792. IF EXISTS(SELECT 'x' FROM Company_Black WITH(NOLOCK) WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)), @CompanyName) > 0)
  1793. RETURN -2 --单位名称已被我们列入黑名单,不再接受注册。
  1794. IF dbo.CompanyNameNoCheck(@CompanyName) = 1
  1795. SET @Pass = 1
  1796. ELSE
  1797. BEGIN
  1798. DECLARE @CompanyNameFilter AS NVARCHAR(50)
  1799. SET @CompanyNameFilter = REPLACE(REPLACE(@CompanyName, '高新', ''), '开发', '')
  1800. --本省,含有省市名称关键字
  1801. IF EXISTS(SELECT 'x' FROM dcRegion WITH(NOLOCK)
  1802. WHERE LEFT(ID, 2) = @ProvinceID AND CHARINDEX(LEFT(LTRIM(RTRIM(Description)), 2), @CompanyNameFilter) > 0)
  1803. SET @Pass = 1
  1804. ELSE --非本省,含有省市名称关键字
  1805. IF EXISTS(SELECT 'x' FROM dcRegion WITH(NOLOCK)
  1806. WHERE LEFT(ID, 2) <> @ProvinceID AND CHARINDEX(LEFT(LTRIM(RTRIM(Description)), 2), @CompanyNameFilter)>0)
  1807. SET @Pass = 0
  1808. ELSE
  1809. SET @Pass = 1
  1810. IF(@Pass = 0)
  1811. IF(@ProvinceID = 83 AND CHARINDEX('巴州', @CompanyNameFilter) > 0)
  1812. SET @Pass = 1
  1813. IF(@Pass = 1)
  1814. IF(@ProvinceID = 21 AND CHARINDEX('马鞍山', @CompanyNameFilter) > 0)
  1815. SET @Pass = 0
  1816. IF(@Pass = 0)
  1817. IF CHARINDEX('中国', @CompanyNameFilter) > 0
  1818. SET @Pass = 1
  1819. END
  1820. IF @Pass = 0
  1821. RETURN -6
  1822. --获取用户名,如果重名则加后缀,直至不重复
  1823. EXEC spGenUserName @UserName, @un OUTPUT
  1824. SELECT @DbPassWord = @PassWord
  1825. BEGIN TRAN
  1826. DECLARE @CountDate AS INT, @CompanyXinxiID AS INT, @TmpID INT,@Addman INT,@RegDate SMALLDATETIME
  1827. SET @CountDate = LTRIM(STR(CONVERT(VARCHAR(8), GETDATE(), 112)))
  1828. --如果在非活动区域则激活,否则增加
  1829. SELECT TOP 1 @CompanyXinxiID = ID,@Addman = Addman,@RegDate = RegDate FROM Company_Xinxi WITH (NOLOCK INDEX(IX_Company_Xinxi_Email))
  1830. WHERE Email = @Email AND IsHistory = 1
  1831. ORDER BY RegDate DESC
  1832. IF @CompanyXinxiID IS NULL
  1833. BEGIN
  1834. INSERT INTO Company_Xinxi(UserName, Password, CompanyName, Email, Province_ID, AddMan, RegDate)
  1835. VALUES(@un, @Password, @CompanyName, @Email, @ProvinceID, @ManagerUserID, GETDATE())
  1836. SELECT @TmpId = @@IDENTITY
  1837. END
  1838. ELSE --激活
  1839. BEGIN
  1840. UPDATE Company_Xinxi SET CompanyName = @CompanyName,
  1841. Province_ID = @ProvinceID, AddMan = @ManagerUSerID,
  1842. IsHistory = 0, RegDate = GETDATE()
  1843. WHERE ID = @CompanyXinxiID
  1844. --将企业信息插入到ActivationCpDetail中 max 2013-08-23
  1845. INSERT INTO LogDB..ActivationCpDetail(Username,Email,AddmanOld,AddmanNew,RegdateOld,RegdateNew)
  1846. VALUES (@Email,@Email,@Addman,@ManagerUserID,@RegDate,GETDATE())
  1847. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  1848. WHERE Infomanager_ID = @ManagerUserID
  1849. AND Province_ID = @ProvinceID
  1850. AND CountDate = @CountDate)
  1851. INSERT INTO Info_DateReport(Province_Id, InfoManager_Id, CountDate)
  1852. VALUES(@ProvinceId, @ManageruserId, @CountDate)
  1853. UPDATE Info_DateReport SET CompanyActivationCount= CompanyActivationCount+ 1
  1854. WHERE Infomanager_ID = @ManagerUserID
  1855. AND Province_ID = @ProvinceID
  1856. AND CountDate = @CountDate
  1857. SELECT @Un = UserName, @DbPassWord = Password FROM Company_Xinxi WITH(NOLOCK)
  1858. WHERE ID = @CompanyXinxiID
  1859. DELETE FROM Company_Xinxi
  1860. WHERE Email = @Email AND IsHistory = 1
  1861. SELECT @TmpId = @CompanyXinxiID
  1862. END
  1863. UPDATE DateReport SET CompanyRegNum_Our = CompanyRegNum_Our + 1
  1864. WHERE Province_ID = @ProvinceID AND CountDate=@CountDate
  1865. --INSERT INTO pamainDatereport SELECT @TmpId, 6, GETDATE() -- SEAN 20130911
  1866. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  1867. WHERE Infomanager_ID = @ManagerUserID
  1868. AND Province_ID = @ProvinceID
  1869. AND CountDate = @CountDate)
  1870. INSERT INTO Info_DateReport(Province_Id, InfoManager_Id, CountDate)
  1871. VALUES(@ProvinceId, @ManageruserId, @CountDate)
  1872. UPDATE Info_DateReport SET CompanyRegNum_Our = CompanyRegNum_Our + 1
  1873. WHERE Infomanager_ID = @ManagerUserID
  1874. AND Province_ID = @ProvinceID
  1875. AND CountDate = @CountDate
  1876. COMMIT
  1877. RETURN 1
  1878. END TRY
  1879. BEGIN CATCH
  1880. GOTO Err
  1881. END CATCH
  1882. Err:
  1883. BEGIN
  1884. ROLLBACK TRAN
  1885. RETURN -20
  1886. END
  1887. GO
  1888. /****** Object: StoredProcedure [dbo].[bsConsultant_FactorByIDSelect] Script Date: 2018/12/13 19:05:31 ******/
  1889. SET ANSI_NULLS ON
  1890. GO
  1891. SET QUOTED_IDENTIFIER ON
  1892. GO
  1893. -- =============================================
  1894. -- 创建日期:2010-9-25
  1895. -- 创建人:Lucifer
  1896. -- 功能:根据ID提取表中的数据
  1897. -- 应用于/BackStage/Consultant/ConsultantCheckCloseProc.asp页面
  1898. -- 修改时间:
  1899. -- 修改人:
  1900. -- =============================================
  1901. CREATE PROCEDURE [dbo].[bsConsultant_FactorByIDSelect]
  1902. (
  1903. @ID INT
  1904. )
  1905. AS
  1906. BEGIN
  1907. SELECT *
  1908. FROM Consultant_Factor WITH(NOLOCK)
  1909. WHERE ID=@ID
  1910. END
  1911. GO
  1912. /****** Object: StoredProcedure [dbo].[bsConsultant_FactorInsert] Script Date: 2018/12/13 19:05:31 ******/
  1913. SET ANSI_NULLS ON
  1914. GO
  1915. SET QUOTED_IDENTIFIER ON
  1916. GO
  1917. -- =============================================
  1918. -- 创建日期:2010-9-25
  1919. -- 创建人:Lucifer
  1920. -- 功能:
  1921. -- 应用于/BackStage/Consultant/ConsultantFactorAddProc.asp页面
  1922. -- 修改时间:
  1923. -- 修改人:
  1924. -- =============================================
  1925. CREATE PROCEDURE [dbo].[bsConsultant_FactorInsert]
  1926. (
  1927. @yearmonth INT,
  1928. @factor_wuxianzhi SMALLINT,
  1929. @factor_chuzhi SMALLINT,
  1930. @factor_vip SMALLINT,
  1931. @factor_nocontinue SMALLINT,
  1932. @factor_new SMALLINT,
  1933. @factor_active_first SMALLINT,
  1934. @factor_passive_first SMALLINT,
  1935. @factor_dead_first SMALLINT,
  1936. @factor_active_second SMALLINT,
  1937. @factor_passive_second SMALLINT,
  1938. @factor_dead_second SMALLINT,
  1939. @Sn TINYINT
  1940. )
  1941. AS
  1942. BEGIN TRY
  1943. INSERT INTO Consultant_Factor(factor_wuxianzhi,factor_chuzhi,factor_vip,factor_nocontinue,factor_new,factor_active_first,
  1944. factor_passive_first,factor_dead_first,factor_active_second,factor_passive_second,factor_dead_second,
  1945. yearmonth,Sn) VALUES(@factor_wuxianzhi,@factor_chuzhi,@factor_vip,@factor_nocontinue,@factor_new,@factor_active_first,
  1946. @factor_passive_first,@factor_dead_first,@factor_active_second,@factor_passive_second,@factor_dead_second,
  1947. @yearmonth,@Sn)
  1948. RETURN 1
  1949. END TRY
  1950. BEGIN CATCH
  1951. RETURN 0
  1952. END CATCH
  1953. GO
  1954. /****** Object: StoredProcedure [dbo].[bsConsultant_FactorSelect] Script Date: 2018/12/13 19:05:31 ******/
  1955. SET ANSI_NULLS ON
  1956. GO
  1957. SET QUOTED_IDENTIFIER ON
  1958. GO
  1959. -- =============================================
  1960. -- 创建日期:2010-9-25
  1961. -- 创建人:Lucifer
  1962. -- 功能:根据年月和南北方提取表中的数据
  1963. -- 应用于/BackStage/Consultant/ConsultantCheckCloseProc.asp页面
  1964. -- 修改时间:
  1965. -- 修改人:
  1966. -- =============================================
  1967. CREATE PROCEDURE [dbo].[bsConsultant_FactorSelect]
  1968. (
  1969. @yearmonth INT,
  1970. @Sn INT
  1971. )
  1972. AS
  1973. BEGIN
  1974. SELECT *
  1975. FROM Consultant_Factor WITH(NOLOCK)
  1976. WHERE yearmonth=@yearmonth AND Sn=@Sn
  1977. END
  1978. GO
  1979. /****** Object: StoredProcedure [dbo].[bsConsultant_FactorUpdate] Script Date: 2018/12/13 19:05:32 ******/
  1980. SET ANSI_NULLS ON
  1981. GO
  1982. SET QUOTED_IDENTIFIER ON
  1983. GO
  1984. -- =============================================
  1985. -- 创建日期:2010-9-25
  1986. -- 创建人:Lucifer
  1987. -- 功能:
  1988. -- 应用于/BackStage/Consultant/ConsultantFactorEditProc.asp页面
  1989. -- 修改时间:
  1990. -- 修改人:
  1991. -- =============================================
  1992. CREATE PROCEDURE [dbo].[bsConsultant_FactorUpdate]
  1993. (
  1994. @id INT,
  1995. @factor_wuxianzhi SMALLINT,
  1996. @factor_chuzhi SMALLINT,
  1997. @factor_vip SMALLINT,
  1998. @factor_nocontinue SMALLINT,
  1999. @factor_new SMALLINT,
  2000. @factor_active_first SMALLINT,
  2001. @factor_passive_first SMALLINT,
  2002. @factor_dead_first SMALLINT,
  2003. @factor_active_second SMALLINT,
  2004. @factor_passive_second SMALLINT,
  2005. @factor_dead_second SMALLINT
  2006. )
  2007. AS
  2008. BEGIN TRY
  2009. UPDATE Consultant_Factor SET
  2010. factor_wuxianzhi=@factor_wuxianzhi,
  2011. factor_chuzhi=@factor_chuzhi,
  2012. factor_vip = @factor_vip,
  2013. factor_nocontinue=@factor_nocontinue,
  2014. factor_new=@factor_new,
  2015. factor_active_first=@factor_active_first,
  2016. factor_passive_first=@factor_passive_first,
  2017. factor_dead_first=@factor_dead_first,
  2018. factor_active_second=@factor_active_second,
  2019. factor_passive_second=@factor_passive_second,
  2020. factor_dead_second=@factor_dead_second
  2021. WHERE id=@id
  2022. RETURN 1
  2023. END TRY
  2024. BEGIN CATCH
  2025. RETURN 0
  2026. END CATCH
  2027. GO
  2028. /****** Object: StoredProcedure [dbo].[bsconsultant_manageruser_monthByIDSelect] Script Date: 2018/12/13 19:05:32 ******/
  2029. SET ANSI_NULLS ON
  2030. GO
  2031. SET QUOTED_IDENTIFIER ON
  2032. GO
  2033. -- =============================================
  2034. -- 创建日期:2010-9-21
  2035. -- 创建人:Lucifer
  2036. -- 功能:根据条件提取招聘顾问销售进度表中的数据
  2037. -- 应用于/BackStage/Consultant/ConsultantCheck.asp页面
  2038. -- 修改时间:
  2039. -- 修改人:
  2040. -- =============================================
  2041. CREATE PROCEDURE [dbo].[bsconsultant_manageruser_monthByIDSelect]
  2042. (
  2043. @ID INT
  2044. )
  2045. AS
  2046. BEGIN
  2047. SELECT *
  2048. FROM consultant_manageruser_month WITH(NOLOCK) WHERE ID=@ID
  2049. END
  2050. GO
  2051. /****** Object: StoredProcedure [dbo].[bsconsultant_manageruser_monthDelete] Script Date: 2018/12/13 19:05:32 ******/
  2052. SET ANSI_NULLS ON
  2053. GO
  2054. SET QUOTED_IDENTIFIER ON
  2055. GO
  2056. -- =============================================
  2057. -- 创建日期:2010-9-25
  2058. -- 创建人:Lucifer
  2059. -- 功能:根据ID删除招聘顾问销售进度表中的数据
  2060. -- 应用于/BackStage/Consultant/ConsultantCheckDelete.asp页面
  2061. -- 修改时间:
  2062. -- 修改人:
  2063. -- =============================================
  2064. CREATE PROCEDURE [dbo].[bsconsultant_manageruser_monthDelete]
  2065. (
  2066. @ID INT
  2067. )
  2068. AS
  2069. BEGIN
  2070. DELETE FROM consultant_manageruser_month WHERE ID=@ID
  2071. END
  2072. GO
  2073. /****** Object: StoredProcedure [dbo].[bsconsultant_manageruser_monthInsert] Script Date: 2018/12/13 19:05:32 ******/
  2074. SET ANSI_NULLS ON
  2075. GO
  2076. SET QUOTED_IDENTIFIER ON
  2077. GO
  2078. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  2079. -- 创建日期:2010-9-21
  2080. -- 创建人:Lucifer
  2081. -- 功能:增加一行招聘顾问销售进度,包括年月和招聘顾问ID
  2082. -- 应用于/BackStage/Consultant/ConsultantCheckAddProc.asp页面
  2083. -- 修改时间:
  2084. -- 修改人:
  2085. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  2086. CREATE PROCEDURE [dbo].[bsconsultant_manageruser_monthInsert]
  2087. (
  2088. @yearmonth INT,
  2089. @consultantid INT
  2090. )
  2091. AS
  2092. BEGIN
  2093. --INSERT INTO consultant_manageruser_month(consultantid, yearmonth)
  2094. --VALUES(@consultantid, @yearmonth)
  2095. --Richard 2011年8月6日修改
  2096. DECLARE @deptid INT, @name NVARCHAR(50), @name_eng VARCHAR(50), @status SMALLINT
  2097. SELECT @deptid = deptid, @name = name, @name_eng = name_eng, @status = status
  2098. FROM manageruser WITH(NOLOCK) WHERE id = @consultantid
  2099. INSERT INTO consultant_manageruser_month(consultantid, yearmonth, deptid, name, name_eng, status)
  2100. VALUES(@consultantid, @yearmonth, @deptid, @name, @name_eng, @status)
  2101. RETURN 1
  2102. END
  2103. GO
  2104. /****** Object: StoredProcedure [dbo].[bsconsultant_manageruser_monthSelect] Script Date: 2018/12/13 19:05:33 ******/
  2105. SET ANSI_NULLS ON
  2106. GO
  2107. SET QUOTED_IDENTIFIER ON
  2108. GO
  2109. -- =============================================
  2110. -- 创建日期:2010-9-21
  2111. -- 创建人:Lucifer
  2112. -- 功能:根据条件提取招聘顾问销售进度表中的数据
  2113. -- 应用于/BackStage/Consultant/ConsultantCheck.asp页面
  2114. -- 修改时间:
  2115. -- 修改人:
  2116. -- =============================================
  2117. CREATE PROCEDURE [dbo].[bsconsultant_manageruser_monthSelect]
  2118. (
  2119. @WHERE VARCHAR(1000)
  2120. )
  2121. AS
  2122. BEGIN
  2123. DECLARE @SQL AS VARCHAR(2000)
  2124. --SET @SQL = 'SELECT TOP 400 a.id id,b.id consultantid,b.name name,a.yearmonth,a.obj_sales_first,'
  2125. --SET @SQL = @SQL + ' a.obj_sales_second,a.obj_sales_new,a.real_sales_first,a.real_sales_second,'
  2126. --SET @SQL = @SQL + ' a.real_sales_new,b.deptid,b.name_eng,b.status,a.customer_num,a.obj_sales,a.real_sales,'
  2127. --SET @SQL = @SQL + ' a.ordernum_first,a.ordernum_second,a.ordernum_new,a.remarks'
  2128. --SET @SQL = @SQL + ' FROM consultant_manageruser_month a WITH(NOLOCK),manageruser b WITH(NOLOCK)'
  2129. --SET @SQL = @SQL + ' WHERE a.consultantid=b.id'
  2130. --SET @SQL = @SQL + @Where
  2131. --SET @SQL = @SQL + ' ORDER BY a.yearmonth DESC,b.id'
  2132. --Richard 2011年8月6日修改
  2133. SET @Where = dbo.SafeSql(@Where)
  2134. SET @SQL = 'SELECT TOP 400 a.id id,a.consultantid,a.name name,a.yearmonth,a.obj_sales_first,'
  2135. SET @SQL = @SQL + ' a.obj_sales_second,a.obj_sales_new,a.real_sales_first,a.real_sales_second,'
  2136. SET @SQL = @SQL + ' a.real_sales_new,a.deptid,a.name_eng,a.status,a.customer_num,a.obj_sales,a.real_sales,'
  2137. SET @SQL = @SQL + ' a.ordernum_first,a.ordernum_second,a.ordernum_new,a.remarks'
  2138. SET @SQL = @SQL + ' FROM consultant_manageruser_month a WITH(NOLOCK)'
  2139. SET @SQL = @SQL + ' WHERE 1=1'
  2140. SET @SQL = @SQL + @Where
  2141. --SET @SQL = @SQL + ' ORDER BY a.yearmonth DESC, LEFT(consultantid, 1), deptid, a.consultantid'
  2142. SET @SQL = @SQL + ' ORDER BY yearmonth DESC, (SELECT DeptName FROM MainDb..Dept WHERE Id = deptid), consultantid'
  2143. EXEC(@SQL)
  2144. END
  2145. GO
  2146. /****** Object: StoredProcedure [dbo].[bsconsultant_manageruser_monthUpdate] Script Date: 2018/12/13 19:05:33 ******/
  2147. SET ANSI_NULLS ON
  2148. GO
  2149. SET QUOTED_IDENTIFIER ON
  2150. GO
  2151. -- =============================================
  2152. -- 创建日期:2011-3-24
  2153. -- 创建人:Lucifer
  2154. -- 功能:修改招聘顾问销售进度
  2155. -- 应用于/BackStage/Consultant/ConsultantCheckAdjustProc.asp页面
  2156. -- 修改时间:
  2157. -- 修改人:
  2158. -- =============================================
  2159. CREATE PROCEDURE [dbo].[bsconsultant_manageruser_monthUpdate]
  2160. (
  2161. @ID INT,
  2162. @obj_sales INT,
  2163. @real_sales INT,
  2164. @remarks NVARCHAR(200)
  2165. )
  2166. AS
  2167. BEGIN
  2168. UPDATE consultant_manageruser_month SET
  2169. obj_sales=@obj_sales,
  2170. real_sales=@real_sales,
  2171. remarks=@remarks
  2172. WHERE ID=@ID
  2173. END
  2174. GO
  2175. /****** Object: StoredProcedure [dbo].[bsConsultantlistInsert] Script Date: 2018/12/13 19:05:33 ******/
  2176. SET ANSI_NULLS ON
  2177. GO
  2178. SET QUOTED_IDENTIFIER ON
  2179. GO
  2180. CREATE PROCEDURE [dbo].[bsConsultantlistInsert]
  2181. AS
  2182. BEGIN
  2183. TRUNCATE TABLE bsConsultantlist
  2184. --插入所有cpMainID
  2185. INSERT INTO bsConsultantlist(cpMainID) SELECT Id FROM cpmain WITH(NOLOCK)
  2186. --更新Vip类型 Vip套餐
  2187. UPDATE a SET a.vipType = c.DetailName, a.VipMonth = c.Month
  2188. FROM bsConsultantList a WITH(NOLOCK),
  2189. caOrder b WITH(NOLOCK),
  2190. dcVipDetail c WITH(NOLOCK)
  2191. WHERE b.cpMainID=a.cpMainID
  2192. AND b.OpenDate IS NOT NULL
  2193. AND GETDATE() BETWEEN b.BeginDate AND b.EndDate
  2194. AND c.ID = b.dcFeeDetailID
  2195. --更新服务到期时间
  2196. UPDATE a SET a.serviceEndDate=b.UnlimitedDate
  2197. FROM bsConsultantList a WITH(NOLOCK),cpMain b WITH(NOLOCK)
  2198. WHERE a.cpMainID = b.ID
  2199. AND b.MemberType=10
  2200. UPDATE a SET a.serviceEndDate=b.BalanceDate
  2201. FROM bsConsultantList a WITH(NOLOCK),cpMain b WITH(NOLOCK)
  2202. WHERE a.cpMainID=b.ID
  2203. AND b.MemberType=11
  2204. UPDATE a SET a.serviceEndDate=b.EndDate
  2205. FROM bsConsultantList a WITH(NOLOCK),caOrder b WITH(NOLOCK)
  2206. WHERE a.cpMainID=b.cpMainID
  2207. AND b.OrderType=8
  2208. AND b.OpenDate IS NOT NULL
  2209. AND b.BeginDate<GETDATE()
  2210. AND b.EndDate>GETDATE()
  2211. --更新下载简历数(VIP)
  2212. UPDATE bsConsultantList
  2213. SET RemainQuotaSum= a.RemainQuota
  2214. FROM (SELECT cpMainId, SUM(RemainQuota) RemainQuota FROM caOrder WITH(NOLOCK)
  2215. WHERE OrderType IN (8, 9)
  2216. AND BeginDate<=GETDATE()
  2217. AND EndDate>=GETDATE()
  2218. AND OpenDate IS NOT NULL
  2219. GROUP BY cpMainId) a
  2220. WHERE bsConsultantList.cpMainId = a.cpMainID
  2221. --更新最后一次订单开通时间
  2222. UPDATE bsConsultantList
  2223. SET caOrderLastOpenDate = a.OpenDate
  2224. FROM (SELECT cpMainID, Max(OpenDate) OpenDate FROM caOrder WITH(NOLOCK)
  2225. GROUP BY cpMainId) a
  2226. WHERE bsConsultantList.cpMainID = a.cpMainId
  2227. --更新营业执照审核时间
  2228. UPDATE bsConsultantList
  2229. SET LicenceVerifyDate=a.CheckDate
  2230. FROM (SELECT cpMainId, Max(CheckDate) CheckDate
  2231. FROM cpLicence WITH(NOLOCK)
  2232. GROUP BY CpMainId) a
  2233. WHERE bsConsultantList.cpMainID = a.cpMainId
  2234. --更新今天简历消费数(正式、储值)
  2235. UPDATE bsConsultantList
  2236. SET CaCvQuotaCount=a.Cnt
  2237. FROM (SELECT cpMainId, COUNT(1) cnt
  2238. FROM CaCvQuotaLog WITH(NOLOCK)
  2239. WHERE AddDate>CONVERT(VARCHAR(10),GETDATE(),120)
  2240. GROUP BY cpMainId) a
  2241. WHERE bsConsultantList.cpMainID = a.cpMainId
  2242. --更新限制时间
  2243. UPDATE bsConsultantList
  2244. SET bsCpStatusAddDate=a.AddDate
  2245. FROM (
  2246. SELECT cpMainId, Max(AddDate) AddDate
  2247. FROM bsCpStatus WITH(NOLOCK)
  2248. WHERE statusID=9
  2249. GROUP BY cpMainId) a
  2250. WHERE bsConsultantList.cpMainID = a.cpMainId
  2251. --更新简历隐藏时间
  2252. --UPDATE bsConsultantList SET bsCpVerifyDate=(
  2253. -- SELECT TOP 1 VerifyDate FROM bsCpVerifyLog
  2254. -- WHERE cpMainID=bsConsultantList.cpMainID)
  2255. --更新今天简历下载数
  2256. UPDATE bsConsultantList
  2257. SET caActiveCount=a.Cnt
  2258. FROM (SELECT cpMainId, COUNT(1) Cnt
  2259. FROM CaActiveLog WITH(NOLOCK)
  2260. WHERE AddDate > CONVERT(VARCHAR(10), GETDATE(), 23)
  2261. GROUP BY cpMainId) a
  2262. WHERE bsConsultantList.cpMainID = a.cpMainId
  2263. --更新单位点击资费标准时间
  2264. UPDATE a
  2265. SET a.caFeePageViewAddDate=c.AddDate
  2266. FROM bsConsultantList a,
  2267. (SELECT a.cpMainId, MAX(b.AddDate) AddDate
  2268. FROM caMain a WITH(NOLOCK), caFeePageViewLog b WITH(NOLOCK)
  2269. WHERE a.Id = b.caMainID
  2270. GROUP BY a.cpMainId) c
  2271. WHERE a.cpmainid = c.cpmainid
  2272. UPDATE a
  2273. SET a.CvViewNumber = c.CvViewNumber
  2274. FROM bsConsultantList a,
  2275. (SELECT a.cpMainId, COUNT(*) CvViewNumber
  2276. FROM caMain a WITH(NOLOCK), cacvviewlog b WITH(NOLOCK)
  2277. WHERE a.Id = b.caMainID
  2278. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 23)
  2279. GROUP BY a.cpMainId) c
  2280. WHERE a.cpmainid = c.cpmainid
  2281. --更新最后一次未完成联系时间
  2282. UPDATE bsConsultantList
  2283. SET LastContactDate=a.begintime,LastContactID=a.ID,LastContactAddDate=a.AddDate
  2284. FROM (SELECT b.id,b.companyID, b.begintime,b.addDate
  2285. FROM contact as b WITH(NOLOCK),(
  2286. SELECT CompanyId,MAX(begintime) begintime
  2287. FROM contact WITH(NOLOCK)
  2288. WHERE status=1
  2289. GROUP BY CompanyId) c
  2290. WHERE b.CompanyID=c.CompanyId
  2291. AND b.begintime=c.begintime) a
  2292. WHERE bsConsultantList.cpMainID = a.companyID
  2293. --更新最后一次完成联系时间
  2294. UPDATE bsConsultantList
  2295. SET contactLastCloseDate=a.closedate,ContactLastCloseID=a.ID,ContactLastCloseAddDate=a.AddDate
  2296. FROM (SELECT b.id,b.companyID, b.closedate,b.addDate
  2297. FROM contact as b WITH(NOLOCK),(
  2298. SELECT CompanyId,MAX(closedate) CloseDate
  2299. FROM contact WITH(NOLOCK)
  2300. WHERE status=2
  2301. GROUP BY CompanyId) c
  2302. WHERE b.CompanyID=c.CompanyId
  2303. AND b.CloseDate=c.CloseDate) a
  2304. WHERE bsConsultantList.cpMainID = a.companyID
  2305. --更新职位被浏览数量
  2306. UPDATE a
  2307. SET a.JobViewNumber = b.Cnt
  2308. FROM bsConsultantList a, (SELECT b.cpMainId, COUNT(1) Cnt
  2309. FROM paJobViewLog a WITH(nolock), Job b WITH(nolock)
  2310. WHERE a.JobID = b.ID
  2311. AND b.valid=1
  2312. AND a.Adddate>GETDATE()-30
  2313. GROUP BY b.cpMainId
  2314. ) b
  2315. WHERE a.cpMainId = b.cpMainId
  2316. --更新投递的非开放简历数量
  2317. UPDATE a
  2318. SET a.NotOpen1 = b.Cnt
  2319. FROM bsConsultantList a, (SELECT b.cpMainId, COUNT(1) Cnt
  2320. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2321. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2322. AND c.IsOpen = 0
  2323. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE(),120)
  2324. GROUP BY b.cpMainId
  2325. ) b
  2326. WHERE a.cpMainId = b.cpMainId
  2327. UPDATE a
  2328. SET a.NotOpen2 = b.Cnt
  2329. FROM bsConsultantList a, (SELECT b.cpMainId, COUNT(1) Cnt
  2330. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2331. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2332. AND c.IsOpen = 0
  2333. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-1,120)
  2334. GROUP BY b.cpMainId
  2335. ) b
  2336. WHERE a.cpMainId = b.cpMainId
  2337. UPDATE a
  2338. SET a.NotOpen3 = b.Cnt
  2339. FROM bsConsultantList a, (SELECT b.cpMainId, COUNT(1) Cnt
  2340. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2341. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2342. AND c.IsOpen = 0
  2343. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-2,120)
  2344. GROUP BY b.cpMainId
  2345. ) b
  2346. WHERE a.cpMainId = b.cpMainId
  2347. UPDATE a
  2348. SET a.NotOpen7 = b.Cnt
  2349. FROM bsConsultantList a, (SELECT b.cpMainId, COUNT(1) Cnt
  2350. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2351. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2352. AND c.IsOpen = 0
  2353. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-6,120)
  2354. GROUP BY b.cpMainId
  2355. ) b
  2356. WHERE a.cpMainId = b.cpMainId
  2357. UPDATE a
  2358. SET a.NotOpen14 = b.Cnt
  2359. FROM bsConsultantList a, (SELECT b.cpMainId, COUNT(1) Cnt
  2360. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2361. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2362. AND c.IsOpen = 0
  2363. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-13,120)
  2364. GROUP BY b.cpMainId
  2365. ) b
  2366. WHERE a.cpMainId = b.cpMainId
  2367. UPDATE a
  2368. SET a.NotOpen30 = b.Cnt
  2369. FROM bsConsultantList a, (SELECT b.cpMainId, COUNT(1) Cnt
  2370. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2371. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2372. AND c.IsOpen = 0
  2373. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-29,120)
  2374. GROUP BY b.cpMainId
  2375. ) b
  2376. WHERE a.cpMainId = b.cpMainId
  2377. END
  2378. GO
  2379. /****** Object: StoredProcedure [dbo].[bsConsultantlistUpdate] Script Date: 2018/12/13 19:05:33 ******/
  2380. SET ANSI_NULLS ON
  2381. GO
  2382. SET QUOTED_IDENTIFIER ON
  2383. GO
  2384. CREATE PROCEDURE [dbo].[bsConsultantlistUpdate]
  2385. AS
  2386. BEGIN
  2387. SELECT TOP 0 * INTO #t FROM bsConsultantlist
  2388. INSERT INTO #t(cpMainID) SELECT Id FROM cpmain WITH(NOLOCK INDEX(IX_cpMain_LastModifyDate)) WHERE LastModifyDate > DATEADD(MINUTE, -20, GETDATE())
  2389. INSERT INTO #t(cpMainID)
  2390. SELECT Id FROM cpmain WITH(NOLOCK)
  2391. WHERE (UnLimitedDate BETWEEN DATEADD(MINUTE, -20, GETDATE()) AND GETDATE()
  2392. OR BalanceDate BETWEEN DATEADD(MINUTE, -20, GETDATE()) AND GETDATE())
  2393. AND Id Not In(SELECT ID FROM #t)
  2394. INSERT INTO #t(cpMainID)
  2395. SELECT cpMainId FROM bsConsultantlist WITH(NOLOCK)
  2396. WHERE ServiceEndDate BETWEEN DATEADD(MINUTE, -20, GETDATE()) AND GETDATE()
  2397. AND cpMainId Not In(SELECT cpMainID FROM #t)
  2398. --更新Vip类型 Vip套餐
  2399. UPDATE a SET a.vipType = c.DetailName, a.VipMonth = c.Month
  2400. FROM #t a WITH(NOLOCK),
  2401. caOrder b WITH(NOLOCK),
  2402. dcVipDetail c WITH(NOLOCK)
  2403. WHERE b.cpMainID=a.cpMainID
  2404. AND b.OpenDate IS NOT NULL
  2405. AND GETDATE() BETWEEN b.BeginDate AND b.EndDate
  2406. AND c.ID = b.dcFeeDetailID
  2407. --更新服务到期时间
  2408. UPDATE a SET a.serviceEndDate=b.UnlimitedDate
  2409. FROM #t a WITH(NOLOCK),cpMain b WITH(NOLOCK)
  2410. WHERE a.cpMainID = b.ID
  2411. AND b.MemberType=10
  2412. UPDATE a SET a.serviceEndDate=b.BalanceDate
  2413. FROM #t a WITH(NOLOCK),cpMain b WITH(NOLOCK)
  2414. WHERE a.cpMainID=b.ID
  2415. AND b.MemberType=11
  2416. UPDATE a SET a.serviceEndDate=b.EndDate
  2417. FROM #t a WITH(NOLOCK),caOrder b WITH(NOLOCK)
  2418. WHERE a.cpMainID=b.cpMainID
  2419. AND b.OrderType=8
  2420. AND b.OpenDate IS NOT NULL
  2421. AND b.BeginDate<GETDATE()
  2422. AND b.EndDate>GETDATE()
  2423. --更新下载简历数(VIP)
  2424. UPDATE #t
  2425. SET RemainQuotaSum= a.RemainQuota
  2426. FROM (SELECT cpMainId, SUM(RemainQuota) RemainQuota FROM caOrder WITH(NOLOCK)
  2427. WHERE OrderType IN (8, 9)
  2428. AND BeginDate<=GETDATE()
  2429. AND EndDate>=GETDATE()
  2430. AND OpenDate IS NOT NULL
  2431. GROUP BY cpMainId) a
  2432. WHERE #t.cpMainId = a.cpMainID
  2433. --更新最后一次订单开通时间
  2434. UPDATE #t
  2435. SET caOrderLastOpenDate = a.OpenDate
  2436. FROM (SELECT cpMainID, Max(OpenDate) OpenDate FROM caOrder WITH(NOLOCK)
  2437. GROUP BY cpMainId) a
  2438. WHERE #t.cpMainID = a.cpMainId
  2439. --更新营业执照审核时间
  2440. UPDATE #t
  2441. SET LicenceVerifyDate=a.CheckDate
  2442. FROM (SELECT cpMainId, Max(CheckDate) CheckDate
  2443. FROM cpLicence WITH(NOLOCK)
  2444. GROUP BY CpMainId) a
  2445. WHERE #t.cpMainID = a.cpMainId
  2446. --更新今天简历消费数(正式、储值)
  2447. UPDATE #t
  2448. SET CaCvQuotaCount=a.Cnt
  2449. FROM (SELECT cpMainId, COUNT(1) cnt
  2450. FROM CaCvQuotaLog WITH(NOLOCK)
  2451. WHERE AddDate>CONVERT(VARCHAR(10),GETDATE(),120)
  2452. GROUP BY cpMainId) a
  2453. WHERE #t.cpMainID = a.cpMainId
  2454. --更新限制时间
  2455. UPDATE #t
  2456. SET bsCpStatusAddDate=a.AddDate
  2457. FROM (
  2458. SELECT cpMainId, Max(AddDate) AddDate
  2459. FROM bsCpStatus WITH(NOLOCK)
  2460. WHERE statusID=9
  2461. GROUP BY cpMainId) a
  2462. WHERE #t.cpMainID = a.cpMainId
  2463. --更新简历隐藏时间
  2464. --UPDATE #t SET bsCpVerifyDate=(
  2465. -- SELECT TOP 1 VerifyDate FROM bsCpVerifyLog
  2466. -- WHERE cpMainID=#t.cpMainID)
  2467. --更新今天简历下载数
  2468. UPDATE #t
  2469. SET caActiveCount=a.Cnt
  2470. FROM (SELECT cpMainId, COUNT(1) Cnt
  2471. FROM CaActiveLog WITH(NOLOCK)
  2472. WHERE AddDate > CONVERT(VARCHAR(10), GETDATE(), 23)
  2473. GROUP BY cpMainId) a
  2474. WHERE #t.cpMainID = a.cpMainId
  2475. --更新单位点击资费标准时间
  2476. UPDATE a
  2477. SET a.caFeePageViewAddDate=c.AddDate
  2478. FROM #t a,
  2479. (SELECT a.cpMainId, MAX(b.AddDate) AddDate
  2480. FROM caMain a WITH(NOLOCK), caFeePageViewLog b WITH(NOLOCK)
  2481. WHERE a.Id = b.caMainID
  2482. GROUP BY a.cpMainId) c
  2483. WHERE a.cpmainid = c.cpmainid
  2484. --更新最后一次未完成联系时间
  2485. UPDATE #t
  2486. SET LastContactDate=a.begintime,LastContactID=a.ID,LastContactAddDate=a.AddDate
  2487. FROM (SELECT b.id,b.companyID, b.begintime,b.addDate
  2488. FROM contact as b WITH(NOLOCK),(
  2489. SELECT CompanyId,MAX(begintime) begintime
  2490. FROM contact WITH(NOLOCK)
  2491. WHERE status=1
  2492. GROUP BY CompanyId) c
  2493. WHERE b.CompanyID=c.CompanyId
  2494. AND b.begintime=c.begintime) a
  2495. WHERE #t.cpMainID = a.companyID
  2496. --更新最后一次完成联系时间
  2497. UPDATE #t
  2498. SET contactLastCloseDate=a.closedate,ContactLastCloseID=a.ID,ContactLastCloseAddDate=a.AddDate
  2499. FROM (SELECT b.id,b.companyID, b.closedate,b.addDate
  2500. FROM contact as b WITH(NOLOCK),(
  2501. SELECT CompanyId,MAX(closedate) CloseDate
  2502. FROM contact WITH(NOLOCK)
  2503. WHERE status=2
  2504. GROUP BY CompanyId) c
  2505. WHERE b.CompanyID=c.CompanyId
  2506. AND b.CloseDate=c.CloseDate) a
  2507. WHERE #t.cpMainID = a.companyID
  2508. UPDATE a
  2509. SET a.JobViewNumber = b.Cnt
  2510. FROM #t a, (SELECT b.cpMainId, COUNT(1) Cnt
  2511. FROM paJobViewLog a WITH(nolock), Job b WITH(nolock)
  2512. WHERE a.JobID = b.ID
  2513. AND b.valid=1
  2514. AND a.Adddate>GETDATE()-30
  2515. GROUP BY b.cpMainId
  2516. ) b
  2517. WHERE a.cpMainId = b.cpMainId
  2518. --更新投递的非开放简历数量
  2519. UPDATE a
  2520. SET a.NotOpen1 = b.Cnt
  2521. FROM #t a, (SELECT b.cpMainId, COUNT(1) Cnt
  2522. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2523. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2524. AND c.IsOpen = 0
  2525. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE(),120)
  2526. GROUP BY b.cpMainId
  2527. ) b
  2528. WHERE a.cpMainId = b.cpMainId
  2529. UPDATE a
  2530. SET a.NotOpen2 = b.Cnt
  2531. FROM #t a, (SELECT b.cpMainId, COUNT(1) Cnt
  2532. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2533. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2534. AND c.IsOpen = 0
  2535. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-1,120)
  2536. GROUP BY b.cpMainId
  2537. ) b
  2538. WHERE a.cpMainId = b.cpMainId
  2539. UPDATE a
  2540. SET a.NotOpen3 = b.Cnt
  2541. FROM #t a, (SELECT b.cpMainId, COUNT(1) Cnt
  2542. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2543. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2544. AND c.IsOpen = 0
  2545. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-2,120)
  2546. GROUP BY b.cpMainId
  2547. ) b
  2548. WHERE a.cpMainId = b.cpMainId
  2549. UPDATE a
  2550. SET a.NotOpen7 = b.Cnt
  2551. FROM #t a, (SELECT b.cpMainId, COUNT(1) Cnt
  2552. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2553. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2554. AND c.IsOpen = 0
  2555. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-6,120)
  2556. GROUP BY b.cpMainId
  2557. ) b
  2558. WHERE a.cpMainId = b.cpMainId
  2559. UPDATE a
  2560. SET a.NotOpen14 = b.Cnt
  2561. FROM #t a, (SELECT b.cpMainId, COUNT(1) Cnt
  2562. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2563. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2564. AND c.IsOpen = 0
  2565. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-13,120)
  2566. GROUP BY b.cpMainId
  2567. ) b
  2568. WHERE a.cpMainId = b.cpMainId
  2569. UPDATE a
  2570. SET a.NotOpen30 = b.Cnt
  2571. FROM #t a, (SELECT b.cpMainId, COUNT(1) Cnt
  2572. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2573. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2574. AND c.IsOpen = 0
  2575. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-29,120)
  2576. GROUP BY b.cpMainId
  2577. ) b
  2578. WHERE a.cpMainId = b.cpMainId
  2579. DELETE bsConsultantlist WHERE cpMainId IN(SELECT cpMainId FROM #t)
  2580. INSERT INTO bsConsultantlist SELECT * FROM #t
  2581. ------------------------------------------------------------------
  2582. --更新下载简历数(VIP)
  2583. UPDATE bsConsultantList
  2584. SET RemainQuotaSum= a.RemainQuota
  2585. FROM (SELECT cpMainId, SUM(RemainQuota) RemainQuota FROM caOrder WITH(NOLOCK)
  2586. WHERE OrderType IN (8, 9)
  2587. AND BeginDate<=GETDATE()
  2588. AND EndDate>=GETDATE()
  2589. AND OpenDate IS NOT NULL
  2590. AND cpMainId IN(SELECT cpMainId FROM caActiveLog WITH(NOLOCK) WHERE AddDate > DATEADD(HOUR, -1, GETDATE()))
  2591. GROUP BY cpMainId) a
  2592. WHERE bsConsultantList.cpMainId = a.cpMainID
  2593. --更新今天简历消费数(正式、储值)
  2594. UPDATE bsConsultantList
  2595. SET CaCvQuotaCount=a.Cnt
  2596. FROM (SELECT cpMainId, COUNT(1) cnt
  2597. FROM CaCvQuotaLog WITH(NOLOCK)
  2598. WHERE AddDate > CONVERT(VARCHAR(10),GETDATE(),120)
  2599. GROUP BY cpMainId) a
  2600. WHERE bsConsultantList.cpMainID = a.cpMainId
  2601. --更新今天简历下载数
  2602. UPDATE bsConsultantList
  2603. SET caActiveCount=a.Cnt
  2604. FROM (SELECT cpMainId, COUNT(1) Cnt
  2605. FROM CaActiveLog WITH(NOLOCK)
  2606. WHERE AddDate > CONVERT(VARCHAR(10), GETDATE(), 23)
  2607. GROUP BY cpMainId) a
  2608. WHERE bsConsultantList.cpMainID = a.cpMainId
  2609. --更新单位点击资费标准时间
  2610. UPDATE a
  2611. SET a.caFeePageViewAddDate=c.AddDate
  2612. FROM bsConsultantList a,
  2613. (SELECT a.cpMainId, MAX(b.AddDate) AddDate
  2614. FROM caMain a WITH(NOLOCK), caFeePageViewLog b WITH(NOLOCK)
  2615. WHERE a.Id = b.caMainID
  2616. AND AddDate > DATEADD(HOUR, -1, GETDATE())
  2617. GROUP BY a.cpMainId) c
  2618. WHERE a.cpmainid = c.cpmainid
  2619. --更新最后一次联系时间
  2620. UPDATE bsConsultantList
  2621. SET LastContactDate=a.begintime,LastContactID=a.ID,LastContactAddDate=a.AddDate
  2622. FROM (SELECT b.id,b.companyID, b.begintime,b.addDate
  2623. FROM contact as b WITH(NOLOCK),(
  2624. SELECT CompanyId,MAX(begintime) begintime
  2625. FROM contact WITH(NOLOCK)
  2626. WHERE status=1
  2627. AND begintime > DATEADD(HOUR, -1, GETDATE())
  2628. GROUP BY CompanyId) c
  2629. WHERE b.CompanyID=c.CompanyId
  2630. AND b.begintime=c.begintime) a
  2631. WHERE bsConsultantList.cpMainID = a.companyID
  2632. --更新最后一次完成联系时间
  2633. UPDATE bsConsultantList
  2634. SET contactLastCloseDate=a.closedate,ContactLastCloseID=a.ID,ContactLastCloseAddDate=a.AddDate
  2635. FROM (SELECT b.id,b.companyID, b.closedate,b.addDate
  2636. FROM contact as b WITH(NOLOCK),(
  2637. SELECT CompanyId,MAX(closedate) CloseDate
  2638. FROM contact WITH(NOLOCK)
  2639. WHERE status=2
  2640. AND CloseDate > DATEADD(HOUR, -1, GETDATE())
  2641. GROUP BY CompanyId) c
  2642. WHERE b.CompanyID=c.CompanyId
  2643. AND b.CloseDate=c.CloseDate) a
  2644. WHERE bsConsultantList.cpMainID = a.companyID
  2645. --更新职位浏览数
  2646. UPDATE a
  2647. SET a.JobViewNumber = b.Cnt
  2648. FROM bsConsultantList a, (SELECT b.cpMainId, COUNT(1) Cnt
  2649. FROM paJobViewLog a WITH(nolock), Job b WITH(nolock)
  2650. WHERE a.JobID = b.ID
  2651. AND b.valid=1
  2652. AND a.Adddate>GETDATE()-30
  2653. AND a.AddDate > DATEADD(HOUR, -1, GETDATE())
  2654. GROUP BY b.cpMainId
  2655. ) b
  2656. WHERE a.cpMainId = b.cpMainId
  2657. --更新投递的非开放简历数量
  2658. UPDATE a
  2659. SET a.NotOpen1 = b.Cnt
  2660. FROM bsConsultantList a, (
  2661. SELECT b.cpMainId, COUNT(1) Cnt
  2662. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2663. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2664. AND c.IsOpen = 0
  2665. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE(),120)
  2666. GROUP BY b.cpMainId
  2667. ) b
  2668. WHERE a.cpMainId = b.cpMainId
  2669. UPDATE a
  2670. SET a.NotOpen2 = b.Cnt
  2671. FROM bsConsultantList a, (
  2672. SELECT b.cpMainId, COUNT(1) Cnt
  2673. FROM exJobApply a WITH(nolock), Job b, cvMain c WITH(NOLOCK)
  2674. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2675. AND c.IsOpen = 0
  2676. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-1,120)
  2677. GROUP BY b.cpMainId
  2678. ) b
  2679. WHERE a.cpMainId = b.cpMainId
  2680. SELECT cpMainId INTO #tt FROM Job a WITH(NOLOCK), ExJobApply b WITH(NOLOCK) WHERE a.ID = b.JobId AND b.AddDate > DATEADD(MINUTE, -20, GETDATE())
  2681. UPDATE a
  2682. SET a.NotOpen3 = b.Cnt
  2683. FROM bsConsultantList a, (SELECT b.cpMainId, COUNT(1) Cnt
  2684. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2685. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2686. AND c.IsOpen = 0
  2687. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-2,120)
  2688. AND b.cpMainID IN(SELECT cpMainId FROM #tt)
  2689. GROUP BY b.cpMainId
  2690. ) b
  2691. WHERE a.cpMainId = b.cpMainId
  2692. UPDATE a
  2693. SET a.NotOpen7 = b.Cnt
  2694. FROM bsConsultantList a, (SELECT b.cpMainId, COUNT(1) Cnt
  2695. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2696. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2697. AND c.IsOpen = 0
  2698. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-6,120)
  2699. AND b.cpMainID IN(SELECT cpMainId FROM #tt)
  2700. GROUP BY b.cpMainId
  2701. ) b
  2702. WHERE a.cpMainId = b.cpMainId
  2703. UPDATE a
  2704. SET a.NotOpen14 = b.Cnt
  2705. FROM bsConsultantList a, (
  2706. SELECT b.cpMainId, COUNT(1) Cnt
  2707. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2708. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2709. AND c.IsOpen = 0
  2710. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-13,120)
  2711. AND b.cpMainID IN(SELECT cpMainId FROM #tt)
  2712. GROUP BY b.cpMainId
  2713. ) b
  2714. WHERE a.cpMainId = b.cpMainId
  2715. UPDATE a
  2716. SET a.NotOpen30 = b.Cnt
  2717. FROM bsConsultantList a, (
  2718. SELECT b.cpMainId, COUNT(1) Cnt
  2719. FROM exJobApply a WITH(nolock), Job b WITH(nolock), cvMain c WITH(NOLOCK)
  2720. WHERE a.JobID = b.ID AND a.cvMainID = c.ID
  2721. AND c.IsOpen = 0
  2722. AND a.Adddate > CONVERT(VARCHAR(10),GETDATE()-29,120)
  2723. AND b.cpMainID IN(SELECT cpMainId FROM #tt)
  2724. GROUP BY b.cpMainId
  2725. ) b
  2726. WHERE a.cpMainId = b.cpMainId
  2727. END
  2728. GO
  2729. /****** Object: StoredProcedure [dbo].[bscpmainByNameUpdate] Script Date: 2018/12/13 19:05:33 ******/
  2730. SET ANSI_NULLS ON
  2731. GO
  2732. SET QUOTED_IDENTIFIER ON
  2733. GO
  2734. --后台冷客户注册
  2735. --harry 2018-6-28
  2736. CREATE PROCEDURE [dbo].[bscpmainByNameUpdate]
  2737. (
  2738. @addman INT,
  2739. @dcProvinceID INT,
  2740. @cpName NVARCHAR(100)
  2741. )
  2742. AS
  2743. BEGIN
  2744. SELECT Id INTO #a FROM cpmain
  2745. WHERE dcProvinceID=@dcProvinceID and Name=@cpName
  2746. DECLARE @a1 INT
  2747. SET @a1=0
  2748. WHILE EXISTS(select 'x' FROM #a )
  2749. BEGIN
  2750. SELECT TOP 1 @a1=id FROM #a WHERE id>@a1 ORDER BY ID
  2751. UPDATE cpMain SET ConsultantId = @addman, ConsultantDate = GETDATE() WHERE Id=@a1
  2752. DELETE FROM #a WHERE id=@a1
  2753. END
  2754. DROP TABLE #a
  2755. END
  2756. GO
  2757. /****** Object: StoredProcedure [dbo].[bsCpMainByOpenNotPayUpdate] Script Date: 2018/12/13 19:05:34 ******/
  2758. SET ANSI_NULLS ON
  2759. GO
  2760. SET QUOTED_IDENTIFIER ON
  2761. GO
  2762. CREATE PROCEDURE [dbo].[bsCpMainByOpenNotPayUpdate]
  2763. AS
  2764. BEGIN
  2765. DECLARE @cpMainID AS INT
  2766. DECLARE curNotPay CURSOR FOR
  2767. SELECT cpMain.ID FROM caOrder WITH(NOLOCK),cpMain WITH(NOLOCK),caMain WITH(NOLOCK)
  2768. WHERE caOrder.cpMainID=cpMain.id AND cpMain.ID=caMain.cpMainID AND AccountType=1
  2769. AND caOrder.Paid>0 AND caOrder.OpenDate IS NOT NULL AND caOrder.ReceiveDate IS NULL
  2770. AND caOrder.OpenDate < CONVERT(VARCHAR(10), GETDATE()-10, 120)
  2771. AND caOrder.OpenDate > GETDATE()-90 AND cpMain.IsLimitLogin=0
  2772. ORDER BY caOrder.OpenDate DESC
  2773. OPEN curNotPay
  2774. FETCH NEXT FROM curNotPay INTO @cpMainID
  2775. IF @@FETCH_STATUS >= 0
  2776. BEGIN
  2777. WHILE @@FETCH_STATUS = 0
  2778. BEGIN
  2779. INSERT INTO bsCpStatus(cpMainID,statusID,verifyMan,verifyInfo,verifyDate) VALUES(@cpMainID,11,1,'订单开通十天未到账',GETDATE())
  2780. UPDATE cpMain SET IsLimitLogin=1 WHERE ID=@cpMainID
  2781. FETCH NEXT FROM curNotPay INTO @cpMainID
  2782. END
  2783. END
  2784. CLOSE curNotPay
  2785. DEALLOCATE curNotPay
  2786. END
  2787. GO
  2788. /****** Object: StoredProcedure [dbo].[bsCpMainLocked] Script Date: 2018/12/13 19:05:34 ******/
  2789. SET ANSI_NULLS ON
  2790. GO
  2791. SET QUOTED_IDENTIFIER ON
  2792. GO
  2793. CREATE PROCEDURE [dbo].[bsCpMainLocked]
  2794. (
  2795. @cpMainId INT
  2796. )
  2797. AS
  2798. BEGIN
  2799. SET NOCOUNT ON
  2800. DECLARE @Email NVARCHAR(100)
  2801. DECLARE @Name NVARCHAR(50)
  2802. DECLARE @CompanyName NVARCHAR(50)
  2803. DECLARE @BodyStr NVARCHAR(200)
  2804. SELECT @CompanyName = a.Name, @Name = b.Name, @Email = b.Email
  2805. FROM cpMain a WITH(NOLOCK), ManagerUser b WITH(NOLOCK)
  2806. WHERE a.ConsultantID = b.ID AND a.ID = @cpMainID
  2807. SET @BodyStr = @Name + ',' + @CompanyName + '(编号' + CAST(@cpMainID AS VARCHAR(50)) + ')于'
  2808. SET @BodyStr = @BodyStr + CONVERT(VARCHAR(20), GETDATE(), 120) + ' 登录前台,请予以关注。'
  2809. IF LEN(@Email) > 0
  2810. BEGIN TRY
  2811. EXEC msdb.dbo.sp_send_dbmail @recipients = @email,
  2812. @body = @BodyStr, @body_format ='HTML',
  2813. @subject ='客户登录监控通知', @profile_Name ='service'
  2814. END TRY
  2815. BEGIN CATCH
  2816. END CATCH
  2817. SET NOCOUNT OFF
  2818. END
  2819. GO
  2820. /****** Object: StoredProcedure [dbo].[bsCpModifyByCpMainIDSelect] Script Date: 2018/12/13 19:05:34 ******/
  2821. SET ANSI_NULLS ON
  2822. GO
  2823. SET QUOTED_IDENTIFIER ON
  2824. GO
  2825. CREATE PROCEDURE [dbo].[bsCpModifyByCpMainIDSelect]
  2826. (
  2827. @cpMainID INT
  2828. )
  2829. AS
  2830. BEGIN
  2831. SELECT
  2832. ID,
  2833. cpMainID,
  2834. caMainID,
  2835. SubID,
  2836. Location,
  2837. AddDate,
  2838. ColValue,
  2839. VerifyInfo,
  2840. FilterWord
  2841. FROM bsCpModify WITH(NOLOCK)
  2842. WHERE cpMainID = @cpMainID
  2843. ORDER BY caMainID, SubID, Location
  2844. END
  2845. GO
  2846. /****** Object: StoredProcedure [dbo].[bsCpRemarkInsert] Script Date: 2018/12/13 19:05:35 ******/
  2847. SET ANSI_NULLS ON
  2848. GO
  2849. SET QUOTED_IDENTIFIER ON
  2850. GO
  2851. CREATE PROCEDURE [dbo].[bsCpRemarkInsert]
  2852. (
  2853. @CpMainId INT,
  2854. @AddMan INT,
  2855. @Description VARCHAR(1000)
  2856. )
  2857. AS
  2858. SET NOCOUNT ON
  2859. BEGIN
  2860. INSERT INTO cpRemark(CpMainId, AddMan ,[Description]) VALUES (@CpMainId, @AddMan, @Description)
  2861. END
  2862. SET NOCOUNT OFF
  2863. GO
  2864. /****** Object: StoredProcedure [dbo].[bsCpRemarkSelect] Script Date: 2018/12/13 19:05:35 ******/
  2865. SET ANSI_NULLS ON
  2866. GO
  2867. SET QUOTED_IDENTIFIER ON
  2868. GO
  2869. CREATE PROCEDURE [dbo].[bsCpRemarkSelect]
  2870. (
  2871. @CpMainId INT
  2872. )
  2873. AS
  2874. SET NOCOUNT ON
  2875. BEGIN
  2876. SELECT a.*,b.Name AddName,c.Name ConsulantName, d.ConsultantID
  2877. FROM cpRemark a WITH(NOLOCK)
  2878. INNER JOIN cpMain d WITH(NOLOCK) ON a.cpMainId = d.ID
  2879. INNER JOIN manageruser b WITH(NOLOCK) ON a.AddMan = b.ID
  2880. INNER JOIN manageruser c WITH(NOLOCK) ON d.ConsultantId = c.ID
  2881. WHERE a.CpMainId = @CpMainId ORDER BY a.AddDate DESC
  2882. END
  2883. SET NOCOUNT OFF
  2884. GO
  2885. /****** Object: StoredProcedure [dbo].[bsCvModifyByCvMainIDLocationSelect] Script Date: 2018/12/13 19:05:36 ******/
  2886. SET ANSI_NULLS ON
  2887. GO
  2888. SET QUOTED_IDENTIFIER ON
  2889. GO
  2890. CREATE PROCEDURE [dbo].[bsCvModifyByCvMainIDLocationSelect]
  2891. (
  2892. @cvMainID INT,
  2893. @Location VARCHAR(4)
  2894. )
  2895. AS
  2896. BEGIN
  2897. DECLARE @paMainID AS INT
  2898. SELECT @paMainID=paMainID FROM cvMain
  2899. WITH(NOLOCK)
  2900. WHERE ID=@cvMainID
  2901. SET @Location = LTRIM(RTRIM(@Location))
  2902. SELECT
  2903. ID,
  2904. paMainID,
  2905. cvMainID,
  2906. SubID,
  2907. Location,
  2908. AddDate,
  2909. ColValue,
  2910. VerifyInfo
  2911. FROM bsCvModify WITH(NOLOCK INDEX(IX_bsCvModify_paMainID))
  2912. WHERE paMainID=@paMainID AND ISNULL(cvMainID,@cvMainID)=@cvMainID
  2913. AND Location LIKE @Location + '%'
  2914. ORDER BY Location
  2915. END
  2916. GO
  2917. /****** Object: StoredProcedure [dbo].[bsCvModifyByCvMainIDSelect] Script Date: 2018/12/13 19:05:36 ******/
  2918. SET ANSI_NULLS ON
  2919. GO
  2920. SET QUOTED_IDENTIFIER ON
  2921. GO
  2922. CREATE PROCEDURE [dbo].[bsCvModifyByCvMainIDSelect]
  2923. (
  2924. @cvMainID INT
  2925. )
  2926. AS
  2927. BEGIN
  2928. DECLARE @paMainID AS INT
  2929. SELECT @paMainID=paMainID FROM cvMain WITH(NOLOCK) WHERE ID=@cvMainID
  2930. SELECT
  2931. ID,
  2932. paMainID,
  2933. cvMainID,
  2934. SubID,
  2935. Location,
  2936. AddDate,
  2937. ColValue,
  2938. VerifyInfo
  2939. FROM bsCvModify WITH(NOLOCK INDEX(IX_bsCvModify_paMainID))
  2940. WHERE paMainID=@paMainID AND ISNULL(cvMainID,@cvMainID)=@cvMainID
  2941. ORDER BY Location
  2942. END
  2943. GO
  2944. /****** Object: StoredProcedure [dbo].[bsCvModifyByNotifySelect] Script Date: 2018/12/13 19:05:36 ******/
  2945. SET ANSI_NULLS ON
  2946. GO
  2947. SET QUOTED_IDENTIFIER ON
  2948. GO
  2949. CREATE PROCEDURE [dbo].[bsCvModifyByNotifySelect]
  2950. (
  2951. @paMainID INT
  2952. )
  2953. AS
  2954. BEGIN
  2955. SELECT
  2956. ID,
  2957. paMainID,
  2958. cvMainID,
  2959. SubID,
  2960. Location,
  2961. AddDate,
  2962. ColValue,
  2963. VerifyInfo
  2964. FROM bsCvModify WITH(NOLOCK INDEX(IX_bsCvModify_paMainID))
  2965. WHERE paMainID=@paMainID
  2966. AND VerifyInfo > ''
  2967. ORDER BY cvMainID,SubID,Location
  2968. END
  2969. GO
  2970. /****** Object: StoredProcedure [dbo].[bsCvModifyByPaMainIDSelect] Script Date: 2018/12/13 19:05:36 ******/
  2971. SET ANSI_NULLS ON
  2972. GO
  2973. SET QUOTED_IDENTIFIER ON
  2974. GO
  2975. CREATE PROCEDURE [dbo].[bsCvModifyByPaMainIDSelect]
  2976. (
  2977. @paMainID INT
  2978. )
  2979. AS
  2980. BEGIN
  2981. SELECT
  2982. ID,
  2983. paMainID,
  2984. cvMainID,
  2985. SubID,
  2986. Location,
  2987. AddDate,
  2988. ColValue,
  2989. VerifyInfo
  2990. FROM bsCvModify WITH(NOLOCK INDEX(IX_bsCvModify_paMainID))
  2991. WHERE paMainID=@paMainID AND cvMainID IS NULL
  2992. ORDER BY cvMainID,SubID,Location
  2993. END
  2994. GO
  2995. /****** Object: StoredProcedure [dbo].[bsDoubanMailInsert] Script Date: 2018/12/13 19:05:37 ******/
  2996. SET ANSI_NULLS ON
  2997. GO
  2998. SET QUOTED_IDENTIFIER ON
  2999. GO
  3000. CREATE PROCEDURE [dbo].[bsDoubanMailInsert]
  3001. @dcProvinceID INT,
  3002. @ManageruserID INT,
  3003. @UserID VARCHAR(250),
  3004. @Title VARCHAR(100),
  3005. @Body VARCHAR(2000)
  3006. AS
  3007. BEGIN
  3008. DECLARE @MaxID AS INT
  3009. INSERT INTO DoubanMail(CountDate,dcProvinceID,ManageruserID,UserID,Title) VALUES(CONVERT(varchar(8),getdate(),112),@dcProvinceID,@ManageruserID,@UserID,@Title)
  3010. SET @MaxID = @@IDENTITY
  3011. SET @Body = REPLACE(@Body,'#doubanid',@MaxID)
  3012. UPDATE DoubanMail SET Body=@Body WHERE ID=@MaxID
  3013. RETURN @MaxID
  3014. END
  3015. GO
  3016. /****** Object: StoredProcedure [dbo].[bsEmailCheckDelete] Script Date: 2018/12/13 19:05:37 ******/
  3017. SET ANSI_NULLS ON
  3018. GO
  3019. SET QUOTED_IDENTIFIER ON
  3020. GO
  3021. -- =============================================
  3022. -- 创建日期:2010-9-26
  3023. -- 创建人:Lucifer
  3024. -- 功能:删除EmailCheck数据
  3025. -- 应用于/BackStage/Consultant/EmailCheckDelete.asp页面
  3026. -- 修改时间:
  3027. -- 修改人:
  3028. -- =============================================
  3029. CREATE PROCEDURE [dbo].[bsEmailCheckDelete]
  3030. @ID INT
  3031. AS
  3032. BEGIN
  3033. DELETE FROM EmailCheck WHERE ID=@ID
  3034. END
  3035. GO
  3036. /****** Object: StoredProcedure [dbo].[bsEmailCheckSelect] Script Date: 2018/12/13 19:05:37 ******/
  3037. SET ANSI_NULLS ON
  3038. GO
  3039. SET QUOTED_IDENTIFIER ON
  3040. GO
  3041. -- =============================================
  3042. -- 创建日期:2010-9-26
  3043. -- 创建人:Lucifer
  3044. -- 功能:根据条件读取企业用户反馈表中的数据
  3045. -- 应用于/BackStage/Consultant/EmailCheck.asp页面
  3046. -- 修改时间:
  3047. -- 修改人:
  3048. -- =============================================
  3049. CREATE PROCEDURE [dbo].[bsEmailCheckSelect]
  3050. @WHERE VARCHAR(2000)
  3051. AS
  3052. BEGIN
  3053. DECLARE @SQL AS VARCHAR(2000)
  3054. SET @Where = dbo.SafeSql(@Where)
  3055. SET @SQL = 'SELECT a.id,a.testdate,a.planhour,a.sendtime,a.replylong,a.manageruserid,
  3056. b.email,b.name,a.planminute,a.remarks
  3057. FROM emailcheck a WITH(NOLOCK),manageruser b WITH(NOLOCK)
  3058. WHERE a.manageruserid=b.id ' +
  3059. @Where +
  3060. ' ORDER BY a.testdate DESC,a.planhour DESC'
  3061. EXEC(@SQL)
  3062. END
  3063. GO
  3064. /****** Object: StoredProcedure [dbo].[bsEmailCheckUpdate] Script Date: 2018/12/13 19:05:37 ******/
  3065. SET ANSI_NULLS ON
  3066. GO
  3067. SET QUOTED_IDENTIFIER ON
  3068. GO
  3069. -- =============================================
  3070. -- 创建日期:2010-9-26
  3071. -- 创建人:Lucifer
  3072. -- 功能:更新EmailCheck数据
  3073. -- 应用于/BackStage/Consultant/EmailCheckEditProc.asp页面
  3074. -- 修改时间:
  3075. -- 修改人:
  3076. -- =============================================
  3077. CREATE PROCEDURE [dbo].[bsEmailCheckUpdate]
  3078. @ID INT,
  3079. @replylong SMALLINT,
  3080. @remarks NVARCHAR(50)
  3081. AS
  3082. BEGIN
  3083. UPDATE EmailCheck SET replylong=@replylong,remarks=@remarks
  3084. WHERE ID=@ID
  3085. END
  3086. GO
  3087. /****** Object: StoredProcedure [dbo].[bsFaqByIdSelect] Script Date: 2018/12/13 19:05:37 ******/
  3088. SET ANSI_NULLS ON
  3089. GO
  3090. SET QUOTED_IDENTIFIER ON
  3091. GO
  3092. CREATE PROCEDURE [dbo].[bsFaqByIdSelect]
  3093. (
  3094. @ID INT
  3095. )
  3096. AS
  3097. BEGIN
  3098. SELECT *
  3099. FROM Faq WITH(NOLOCK)
  3100. WHERE ID = @ID
  3101. UPDATE Faq Set ClickNum = ClickNum +1 WHERE ID = @ID
  3102. END
  3103. GO
  3104. /****** Object: StoredProcedure [dbo].[bsInfo_DateReportByMobileTodayUpdate] Script Date: 2018/12/13 19:05:38 ******/
  3105. SET ANSI_NULLS ON
  3106. GO
  3107. SET QUOTED_IDENTIFIER ON
  3108. GO
  3109. CREATE PROCEDURE [dbo].[bsInfo_DateReportByMobileTodayUpdate]
  3110. AS
  3111. BEGIN
  3112. DECLARE @AddMan INT, @ProvinceID INT, @MobileReturn INT, @MobileAccount INT, @CountDate VARCHAR(8)
  3113. SET @CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  3114. --个人部分
  3115. DECLARE curMobile CURSOR FOR
  3116. SELECT AddMan, ProvinceId, SUM(HasReturn), SUM(HasAccount)
  3117. FROM bsMobileSpread WITH(NOLOCK)
  3118. WHERE (
  3119. CONVERT(VARCHAR(8), ReturnDate, 112) = @CountDate
  3120. OR CONVERT(VARCHAR(8), AccountDate, 112) = @CountDate
  3121. )
  3122. AND UserType=1
  3123. GROUP BY AddMan, ProvinceId
  3124. OPEN curMobile
  3125. FETCH NEXT FROM curMobile INTO @AddMan, @ProvinceID, @MobileReturn, @MobileAccount
  3126. WHILE @@FETCH_STATUS = 0
  3127. BEGIN
  3128. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK) WHERE CountDate = @CountDate AND Province_ID = @ProvinceID AND InfoManager_ID = @AddMan)
  3129. BEGIN
  3130. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, CountDate, MobileReturn, MobileAccount)
  3131. VALUES(@ProvinceID, @AddMan, @CountDate, @MobileReturn, @MobileAccount)
  3132. END
  3133. ELSE
  3134. BEGIN
  3135. UPDATE Info_DateReport SET MobileReturn = @MobileReturn, MobileAccount = @MobileAccount
  3136. WHERE CountDate = @CountDate
  3137. AND Province_ID = @ProvinceID
  3138. AND InfoManager_ID = @AddMan
  3139. END
  3140. FETCH NEXT FROM curMobile INTO @AddMan, @ProvinceID, @MobileReturn, @MobileAccount
  3141. END
  3142. CLOSE curMobile
  3143. DEALLOCATE curMobile
  3144. --企业部分
  3145. DECLARE curCpMobile CURSOR FOR
  3146. SELECT AddMan, ProvinceId, SUM(HasReturn), SUM(HasAccount)
  3147. FROM bsMobileSpread WITH(NOLOCK)
  3148. WHERE (
  3149. CONVERT(VARCHAR(8), ReturnDate, 112) = @CountDate
  3150. OR CONVERT(VARCHAR(8), AccountDate, 112) = @CountDate
  3151. )
  3152. AND UserType=0
  3153. GROUP BY AddMan, ProvinceId
  3154. OPEN curCpMobile
  3155. FETCH NEXT FROM curCpMobile INTO @AddMan, @ProvinceID, @MobileReturn, @MobileAccount
  3156. WHILE @@FETCH_STATUS = 0
  3157. BEGIN
  3158. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK) WHERE CountDate = @CountDate AND Province_ID = @ProvinceID AND InfoManager_ID = @AddMan)
  3159. BEGIN
  3160. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, CountDate, cpMobileRetNum, cpMobileAccountNum)
  3161. VALUES(@ProvinceID, @AddMan, @CountDate, @MobileReturn, @MobileAccount)
  3162. END
  3163. ELSE
  3164. BEGIN
  3165. UPDATE Info_DateReport SET cpMobileRetNum = @MobileReturn, cpMobileAccountNum = @MobileAccount
  3166. WHERE CountDate = @CountDate
  3167. AND Province_ID = @ProvinceID
  3168. AND InfoManager_ID = @AddMan
  3169. END
  3170. FETCH NEXT FROM curCpMobile INTO @AddMan, @ProvinceID, @MobileReturn, @MobileAccount
  3171. END
  3172. CLOSE curCpMobile
  3173. DEALLOCATE curCpMobile
  3174. END
  3175. GO
  3176. /****** Object: StoredProcedure [dbo].[bsInfo_DateReportByMobileUpdate] Script Date: 2018/12/13 19:05:38 ******/
  3177. SET ANSI_NULLS ON
  3178. GO
  3179. SET QUOTED_IDENTIFIER ON
  3180. GO
  3181. CREATE PROCEDURE [dbo].[bsInfo_DateReportByMobileUpdate]
  3182. AS
  3183. BEGIN
  3184. DECLARE @AddMan INT, @ProvinceID INT, @MobileReturn INT, @MobileAccount INT, @CountDate VARCHAR(8)
  3185. SET @CountDate = CONVERT(VARCHAR(8), GETDATE() - 1, 112)
  3186. --个人部分
  3187. DECLARE curMobile CURSOR FOR
  3188. SELECT AddMan, ProvinceId, SUM(HasReturn), SUM(HasAccount)
  3189. FROM bsMobileSpread WITH(NOLOCK)
  3190. WHERE (
  3191. CONVERT(VARCHAR(8), ReturnDate, 112) = @CountDate
  3192. OR CONVERT(VARCHAR(8), AccountDate, 112) = @CountDate
  3193. )
  3194. AND UserType=1
  3195. GROUP BY AddMan, ProvinceId
  3196. OPEN curMobile
  3197. FETCH NEXT FROM curMobile INTO @AddMan, @ProvinceID, @MobileReturn, @MobileAccount
  3198. WHILE @@FETCH_STATUS = 0
  3199. BEGIN
  3200. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK) WHERE CountDate = @CountDate AND Province_ID = @ProvinceID AND InfoManager_ID = @AddMan)
  3201. BEGIN
  3202. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, CountDate, MobileReturn, MobileAccount)
  3203. VALUES(@ProvinceID, @AddMan, @CountDate, @MobileReturn, @MobileAccount)
  3204. END
  3205. ELSE
  3206. BEGIN
  3207. UPDATE Info_DateReport SET MobileReturn = @MobileReturn, MobileAccount = @MobileAccount
  3208. WHERE CountDate = @CountDate
  3209. AND Province_ID = @ProvinceID
  3210. AND InfoManager_ID = @AddMan
  3211. END
  3212. FETCH NEXT FROM curMobile INTO @AddMan, @ProvinceID, @MobileReturn, @MobileAccount
  3213. END
  3214. CLOSE curMobile
  3215. DEALLOCATE curMobile
  3216. --企业部分
  3217. DECLARE curCpMobile CURSOR FOR
  3218. SELECT AddMan, ProvinceId, SUM(HasReturn), SUM(HasAccount)
  3219. FROM bsMobileSpread WITH(NOLOCK)
  3220. WHERE (
  3221. CONVERT(VARCHAR(8), ReturnDate, 112) = @CountDate
  3222. OR CONVERT(VARCHAR(8), AccountDate, 112) = @CountDate
  3223. )
  3224. AND UserType=0
  3225. GROUP BY AddMan, ProvinceId
  3226. OPEN curCpMobile
  3227. FETCH NEXT FROM curCpMobile INTO @AddMan, @ProvinceID, @MobileReturn, @MobileAccount
  3228. WHILE @@FETCH_STATUS = 0
  3229. BEGIN
  3230. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK) WHERE CountDate = @CountDate AND Province_ID = @ProvinceID AND InfoManager_ID = @AddMan)
  3231. BEGIN
  3232. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, CountDate, cpMobileRetNum, cpMobileAccountNum)
  3233. VALUES(@ProvinceID, @AddMan, @CountDate, @MobileReturn, @MobileAccount)
  3234. END
  3235. ELSE
  3236. BEGIN
  3237. UPDATE Info_DateReport SET cpMobileRetNum = @MobileReturn, cpMobileAccountNum = @MobileAccount
  3238. WHERE CountDate = @CountDate
  3239. AND Province_ID = @ProvinceID
  3240. AND InfoManager_ID = @AddMan
  3241. END
  3242. FETCH NEXT FROM curCpMobile INTO @AddMan, @ProvinceID, @MobileReturn, @MobileAccount
  3243. END
  3244. CLOSE curCpMobile
  3245. DEALLOCATE curCpMobile
  3246. END
  3247. GO
  3248. /****** Object: StoredProcedure [dbo].[bsJobByJobFinderOutput] Script Date: 2018/12/13 19:05:39 ******/
  3249. SET ANSI_NULLS ON
  3250. GO
  3251. SET QUOTED_IDENTIFIER ON
  3252. GO
  3253. CREATE PROCEDURE [dbo].[bsJobByJobFinderOutput]
  3254. (
  3255. @dcJobTypeID VARCHAR(100),
  3256. @dcRegionID VARCHAR(100),
  3257. @dcIndustryID VARCHAR(100),
  3258. @dcSalaryID TINYINT,
  3259. @IsNegotiable BIT,
  3260. @MinExperience TINYINT,
  3261. @dcEducationID TINYINT,
  3262. @EmployType VARCHAR(10),
  3263. @EmailNumber SMALLINT,
  3264. @JobDesc VARCHAR(MAX) OUTPUT
  3265. )
  3266. AS
  3267. BEGIN
  3268. SET @JobDesc = ''
  3269. DECLARE @SQL AS VARCHAR(5000)
  3270. IF @dcJobTypeID IS NULL
  3271. SET @dcJobTypeID = ''
  3272. IF @dcRegionID IS NULL
  3273. SET @dcRegionID = ''
  3274. IF @dcIndustryID IS NULL
  3275. Set @dcIndustryID = ''
  3276. IF @dcSalaryID IS NULL
  3277. SET @dcSalaryID = 0
  3278. IF @IsNegotiable IS NULL
  3279. SET @IsNegotiable = 0
  3280. IF @MinExperience IS NULL
  3281. SET @MinExperience = 100
  3282. IF @dcEducationID IS NULL
  3283. SET @dcEducationID = 0
  3284. IF @EmployType IS NULL
  3285. SET @EmployType = ''
  3286. ELSE
  3287. IF @EmployType = '2'
  3288. SET @EmployType = '1,3'
  3289. DECLARE @T_JobPlace AS TABLE(ID INT)
  3290. DECLARE @T_JobType AS TABLE(ID INT)
  3291. DECLARE @JobType AS VARCHAR(3000)
  3292. DECLARE @JobPlace AS VARCHAR(2000)
  3293. SET @JobPlace = ''
  3294. SET @JobType=''
  3295. ----生成工作地点的表变量
  3296. IF LEN(@dcRegionID) > 0
  3297. BEGIN
  3298. INSERT INTO @T_JobPlace
  3299. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  3300. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  3301. IF LeN(@JobPlace) > 0
  3302. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  3303. END
  3304. ----生成求聘职位的表变量
  3305. IF LEN(@dcJobTypeID) > 0
  3306. BEGIN
  3307. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  3308. INSERT INTO @T_Temp
  3309. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  3310. INSERT INTO @T_JobType
  3311. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  3312. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  3313. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  3314. OR ID IN(SELECT ID FROM @T_TEMP)
  3315. ----生成in字符串
  3316. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  3317. IF RIGHT(@JobType, 1) = ','
  3318. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  3319. END
  3320. CREATE TABLE #t(
  3321. JobName NVARCHAR(50),
  3322. cpName VARCHAR(100),
  3323. JobID INT,
  3324. Region VARCHAR(100),
  3325. RefreshDate SMALLDATETIME
  3326. )
  3327. SET @SQL='
  3328. INSERT INTO #t
  3329. SELECT Top ' + CONVERT(VARCHAR(5),@EmailNumber) + ' a.Name,b.Name cpName,a.ID,
  3330. (SELECT Description FROM dcRegion WITH(NOLOCK) WHERE dcRegion.ID = a.dcRegionId) Region,
  3331. a.RefreshDate
  3332. FROM Job a WITH(NOLOCK)
  3333. INNER JOIN cpMain b WITH(NOLOCK) ON a.cpMainID=b.ID'
  3334. IF LEN(@dcIndustryID) > 0
  3335. SET @SQL = @SQL + '
  3336. INNER JOIN cpIndustry c WITH(NOLOCK) ON c.cpMainID=b.ID
  3337. AND c.dcIndustryId in(' + @dcIndustryID + ')'
  3338. SET @SQL = @SQL + '
  3339. WHERE a.IsDelete=0
  3340. AND a.IssueDate<Getdate()
  3341. AND a.IssueEND>Getdate()
  3342. AND b.Valid = 1'
  3343. ----职位类别
  3344. IF LEN(@dcJobTypeID) > 0
  3345. SET @SQL = @SQL + '
  3346. AND (a.dcJobTypeID IN(' + @JobType +')
  3347. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  3348. IF LEN(@JobPlace) > 0
  3349. SET @SQL = @SQL + '
  3350. AND (' + @JobPlace + ')'
  3351. ----月薪是本级和上级别的薪金
  3352. IF @dcSalaryID > 0
  3353. BEGIN
  3354. SET @SQL = @SQL + '
  3355. AND (a.dcSalaryID=' + LTRIM(STR(@dcSalaryID)) + ' OR a.dcSalaryID = ' + LTRIM(STR(@dcSalaryID + 1))
  3356. IF @IsNegotiable = 1 --包括面议
  3357. SET @SQL = @SQL + ' OR a.dcSalaryID = 100'
  3358. SET @SQL = @SQL + ')'
  3359. END
  3360. ----工作经验要求
  3361. IF @MinExperience < 100
  3362. SET @SQL = @SQL + '
  3363. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  3364. ----学历要求
  3365. ----'1初中','2\3\4高中、中技、中专','5大专','6本科','7硕士','8博士
  3366. IF @dcEducationID > 0
  3367. IF @dcEducationID = 2
  3368. SET @SQL = @SQL + '
  3369. AND a.dcEducationID IN(2,3,4)'
  3370. ELSE
  3371. SET @SQL = @SQL + '
  3372. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  3373. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  3374. IF LEN(@EmployType) > 0
  3375. SET @SQL = @SQL + '
  3376. AND a.EmployType IN (' + @EmployType + ')'
  3377. ----把符合条件的职位全部列出
  3378. SET @SQL = @SQL + 'ORDER BY RefreshDate DESC,a.ID DESC'
  3379. EXEC(@SQL)
  3380. SELECT @JobDesc = @JobDesc + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + cpName
  3381. + ' 招聘:<a href="http://@@/personal/jb'+ CONVERT(VARCHAR,JobID) + '.html target="_blank">'
  3382. + JobName + '</a>[职位编号' + CONVERT(VARCHAR,JobID) + '] 工作地点:' + Region + '[' + CONVERT(VARCHAR,RefreshDate,120) + ']<br>'
  3383. FROM #t
  3384. DROP TABLE #t
  3385. END
  3386. GO
  3387. /****** Object: StoredProcedure [dbo].[bsJobByJobFinderSelect] Script Date: 2018/12/13 19:05:39 ******/
  3388. SET ANSI_NULLS ON
  3389. GO
  3390. SET QUOTED_IDENTIFIER ON
  3391. GO
  3392. CREATE PROCEDURE [dbo].[bsJobByJobFinderSelect]
  3393. (
  3394. @dcJobTypeID VARCHAR(100),
  3395. @dcRegionID VARCHAR(100),
  3396. @dcIndustryID VARCHAR(100),
  3397. @dcSalaryID TINYINT,
  3398. @IsNegotiable BIT,
  3399. @MinExperience TINYINT,
  3400. @dcEducationID TINYINT,
  3401. @EmployType VARCHAR(10),
  3402. @EmailNumber SMALLINT
  3403. )
  3404. AS
  3405. BEGIN
  3406. DECLARE @SQL AS VARCHAR(5000)
  3407. IF @dcJobTypeID IS NULL
  3408. SET @dcJobTypeID = ''
  3409. IF @dcRegionID IS NULL
  3410. SET @dcRegionID = ''
  3411. IF @dcIndustryID IS NULL
  3412. Set @dcIndustryID = ''
  3413. IF @dcSalaryID IS NULL
  3414. SET @dcSalaryID = 0
  3415. IF @IsNegotiable IS NULL
  3416. SET @IsNegotiable = 0
  3417. IF @MinExperience IS NULL
  3418. SET @MinExperience = 100
  3419. IF @dcEducationID IS NULL
  3420. SET @dcEducationID = 0
  3421. IF @EmployType IS NULL
  3422. SET @EmployType = ''
  3423. ELSE
  3424. IF @EmployType = '2'
  3425. SET @EmployType = '1,3'
  3426. DECLARE @T_JobPlace AS TABLE(ID INT)
  3427. DECLARE @T_JobType AS TABLE(ID INT)
  3428. DECLARE @JobType AS VARCHAR(3000)
  3429. DECLARE @JobPlace AS VARCHAR(2000)
  3430. SET @JobPlace = ''
  3431. SET @JobType=''
  3432. ----生成工作地点的表变量
  3433. IF LEN(@dcRegionID) > 0
  3434. BEGIN
  3435. INSERT INTO @T_JobPlace
  3436. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  3437. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  3438. IF LeN(@JobPlace) > 0
  3439. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  3440. END
  3441. ----生成求聘职位的表变量
  3442. IF LEN(@dcJobTypeID) > 0
  3443. BEGIN
  3444. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  3445. INSERT INTO @T_Temp
  3446. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  3447. INSERT INTO @T_JobType
  3448. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  3449. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  3450. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  3451. OR ID IN(SELECT ID FROM @T_TEMP)
  3452. ----生成in字符串
  3453. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  3454. IF RIGHT(@JobType, 1) = ','
  3455. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  3456. END
  3457. SET @SQL='
  3458. SELECT Top ' + CONVERT(VARCHAR(5),@EmailNumber) + ' a.Name,b.Name cpName,a.ID,a.dcJobTypeID,
  3459. a.dcJobTypeIDMinor,a.dcSalaryID,
  3460. a.dcRegionID,(SELECT Description FROM dcRegion WITH(NOLOCK) WHERE dcRegion.ID = a.dcRegionId) Region, a.dcEducationID,a.MinExperience,
  3461. a.RefreshDate
  3462. FROM Job a WITH(NOLOCK)
  3463. INNER JOIN cpMain b WITH(NOLOCK) ON a.cpMainID=b.ID'
  3464. IF LEN(@dcIndustryID) > 0
  3465. SET @SQL = @SQL + '
  3466. INNER JOIN cpIndustry c WITH(NOLOCK) ON c.cpMainID=b.ID
  3467. AND c.dcIndustryId in(' + @dcIndustryID + ')'
  3468. SET @SQL = @SQL + '
  3469. WHERE a.IsDelete=0
  3470. AND a.IssueDate<Getdate()
  3471. AND a.IssueEND>Getdate()
  3472. AND b.Valid = 1'
  3473. ----职位类别
  3474. IF LEN(@dcJobTypeID) > 0
  3475. SET @SQL = @SQL + '
  3476. AND (a.dcJobTypeID IN(' + @JobType +')
  3477. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  3478. IF LEN(@JobPlace) > 0
  3479. SET @SQL = @SQL + '
  3480. AND (' + @JobPlace + ')'
  3481. ----月薪是本级和上级别的薪金
  3482. IF @dcSalaryID > 0
  3483. BEGIN
  3484. SET @SQL = @SQL + '
  3485. AND (a.dcSalaryID=' + LTRIM(STR(@dcSalaryID)) + ' OR a.dcSalaryID = ' + LTRIM(STR(@dcSalaryID + 1))
  3486. IF @IsNegotiable = 1 --包括面议
  3487. SET @SQL = @SQL + ' OR a.dcSalaryID = 100'
  3488. SET @SQL = @SQL + ')'
  3489. END
  3490. ----工作经验要求
  3491. IF @MinExperience < 100
  3492. SET @SQL = @SQL + '
  3493. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  3494. ----学历要求
  3495. ----'1初中','2\3\4高中、中技、中专','5大专','6本科','7硕士','8博士
  3496. IF @dcEducationID > 0
  3497. IF @dcEducationID = 2
  3498. SET @SQL = @SQL + '
  3499. AND a.dcEducationID IN(2,3,4)'
  3500. ELSE
  3501. SET @SQL = @SQL + '
  3502. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  3503. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  3504. IF LEN(@EmployType) > 0
  3505. SET @SQL = @SQL + '
  3506. AND a.EmployType IN (' + @EmployType + ')'
  3507. ----把符合条件的职位全部列出
  3508. SET @SQL = @SQL + 'ORDER BY RefreshDate DESC,a.ID DESC'
  3509. EXEC(@SQL)
  3510. END
  3511. GO
  3512. /****** Object: StoredProcedure [dbo].[bsJobByJobFinderSelectNew] Script Date: 2018/12/13 19:05:39 ******/
  3513. SET ANSI_NULLS ON
  3514. GO
  3515. SET QUOTED_IDENTIFIER ON
  3516. GO
  3517. CREATE PROCEDURE [dbo].[bsJobByJobFinderSelectNew]
  3518. (
  3519. @dcProvinceID INT
  3520. )
  3521. AS
  3522. BEGIN
  3523. SET NOCOUNT ON;
  3524. DECLARE @dcJobTypeID AS VARCHAR(100), @dcRegionID AS VARCHAR(100), @dcIndustryID AS VARCHAR(100),
  3525. @dcSalaryID AS TINYINT, @MinExperience AS TINYINT, @dcEducationID AS TINYINT,
  3526. @EmployType AS VARCHAR(10), @EmailNumber AS SMALLINT, @ID AS INT, @JobDESC VARCHAR(MAX)
  3527. CREATE TABLE #Job(
  3528. ID INT IDENTITY(1, 1),
  3529. Email VARCHAR(50),
  3530. FinderName VARCHAR(50),
  3531. paName NVARCHAR(20),
  3532. UserName VARCHAR(50),
  3533. EmailSite VARCHAR(50),
  3534. SubSiteName VARCHAR(20),
  3535. dcJobTypeID VARCHAR(100),
  3536. dcRegionID VARCHAR(100),
  3537. dcIndustryID VARCHAR(100),
  3538. dcSalaryID TINYINT,
  3539. MinExperience TINYINT,
  3540. dcEducationID TINYINT,
  3541. EmployType VARCHAR(10),
  3542. EmailNumber SMALLINT,
  3543. JobDESC VARCHAR(MAX)
  3544. )
  3545. INSERT INTO #Job(Email, FinderName, paName, UserName, EmailSite, SubSiteName, dcJobTypeID, dcRegionID, dcIndustryID,
  3546. dcSalaryID, MinExperience, dcEducationID, EmployType, EmailNumber)
  3547. SELECT b.Email, b.Name, CASE LEN(a.Name) WHEN 0 then '亲爱的个人用户' ELSE a.Name END as paname, a.UserName,
  3548. CASE LEN(a.dcsubsiteid) WHEN 2 then '' ELSE c.emailsite END as emailsite, c.subsitename,
  3549. dcjobtypeid, dcregionid, dcindustryid, salary, minexperience, education, employtype, emailnumber
  3550. FROM paMain a, paJobFinder b, dcSubSite c
  3551. WHERE c.ID = a.dcSubSiteID
  3552. AND a.ID = b.paMainID
  3553. AND b.EmailSent > 0
  3554. AND b.Email IS NOT NULL
  3555. AND b.EmailNumber IS NOT NULL
  3556. AND a.dcProvinceID = @dcProvinceID
  3557. AND EmaiLEndDate > GETDATE()
  3558. AND (b.LastEmailDate IS NULL
  3559. OR DATEDIFF(d, b.LastEmailDate, GETDATE()) >= b.EmailSent
  3560. )
  3561. AND LEN(a.Email) > 0
  3562. AND a.LastLoginDate > GETDATE() - 183
  3563. ORDER BY LastLoginDate DESC
  3564. DECLARE curJob CURSOR FOR
  3565. SELECT id, dcjobtypeid, dcregionid, dcindustryid, dcSalaryID,
  3566. minexperience, dcEducationID, employtype, emailnumber
  3567. FROM #Job WITH(NOLOCK)
  3568. OPEN curJob
  3569. FETCH NEXT FROM curJob INTO @ID, @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcSalaryID,
  3570. @MinExperience, @dcEducationID, @EmployType, @EmailNumber
  3571. IF @@FETCH_STATUS >= 0
  3572. BEGIN
  3573. WHILE @@FETCH_STATUS = 0
  3574. BEGIN
  3575. EXEC bsJobByJobFinderOutput @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcSalaryID, 1,
  3576. @MinExperience, @dcEducationID, @EmployType, @EmailNumber, @JobDESC OUTPUT
  3577. UPDATE #Job SET JobDESC = @JobDESC WHERE ID = @ID
  3578. UPDATE paJobFinder SET LastEmailDate = GETDATE() WHERE ID = @ID
  3579. FETCH NEXT FROM curJob INTO @ID, @dcJobTypeID, @dcRegionID, @dcIndustryID, @dcSalaryID, @MinExperience, @dcEducationID, @EmployType, @EmailNumber
  3580. END
  3581. END
  3582. CLOSE curJob
  3583. DEALLOCATE curJob
  3584. SELECT * FROM #Job WHERE LEN(JobDESC) > 0
  3585. DROP TABLE #Job
  3586. END
  3587. GO
  3588. /****** Object: StoredProcedure [dbo].[bsJobByPaJobFinderIdSelect] Script Date: 2018/12/13 19:05:39 ******/
  3589. SET ANSI_NULLS ON
  3590. GO
  3591. SET QUOTED_IDENTIFIER ON
  3592. GO
  3593. --**********************************************
  3594. --2012 11 1 nick
  3595. --根据个人的职位搜索器编号获取订阅的职位
  3596. --2013 0731 nick
  3597. --加入邮件发送参数
  3598. --2015-6-2 harry
  3599. --修改参数错误
  3600. --**********************************************
  3601. CREATE PROCEDURE [dbo].[bsJobByPaJobFinderIdSelect]
  3602. (
  3603. @paJobFinderID INT
  3604. )
  3605. AS
  3606. BEGIN
  3607. DECLARE @dcJobTypeID VARCHAR(100),
  3608. @dcRegionID VARCHAR(100),
  3609. @dcIndustryID VARCHAR(100),
  3610. @dcSalaryID TINYINT,
  3611. @IsNegotiable BIT,
  3612. @MinExperience TINYINT,
  3613. @dcEducationID TINYINT,
  3614. @EmployType VARCHAR(10),
  3615. @EmailNumber SMALLINT,
  3616. @Email VARCHAR(100)
  3617. --根据搜索器编号获取email 20130731 nick
  3618. select top 1 @Email = email from pamain where id in (select pamainid from PAJOBFINDER where id=@paJobFinderID)
  3619. SELECT @dcJobTypeID=dcJobTypeID,@dcRegionID=dcRegionID ,@dcIndustryID=dcIndustryID,@dcSalaryID=Salary,
  3620. @IsNegotiable=1,@MinExperience=MinExperience,@dcEducationID=Education,@EmployType=EmployType,@EmailNumber=EmailNumber
  3621. FROM PAJOBFINDER
  3622. WHERE ID=@paJobFinderID AND EmailNumber > 0
  3623. IF @EmailNumber IS NULL
  3624. BEGIN
  3625. SELECT TOP 0 '' JobName, '' cpName, 0 JobID, '' Region, NULL RefreshDate
  3626. RETURN
  3627. END
  3628. DECLARE @SQL AS VARCHAR(5000)
  3629. IF @dcJobTypeID IS NULL
  3630. SET @dcJobTypeID = ''
  3631. IF @dcRegionID IS NULL
  3632. SET @dcRegionID = ''
  3633. IF @dcIndustryID IS NULL
  3634. Set @dcIndustryID = ''
  3635. IF @dcSalaryID IS NULL
  3636. SET @dcSalaryID = 0
  3637. IF @IsNegotiable IS NULL
  3638. SET @IsNegotiable = 0
  3639. IF @MinExperience IS NULL
  3640. SET @MinExperience = 100
  3641. IF @dcEducationID IS NULL
  3642. SET @dcEducationID = 0
  3643. IF @EmployType IS NULL
  3644. SET @EmployType = ''
  3645. ELSE
  3646. IF @EmployType = '2'
  3647. SET @EmployType = '1,3'
  3648. DECLARE @T_JobPlace AS TABLE(ID INT)
  3649. DECLARE @T_JobType AS TABLE(ID INT)
  3650. DECLARE @JobType AS VARCHAR(3000)
  3651. DECLARE @JobPlace AS VARCHAR(2000)
  3652. SET @JobPlace = ''
  3653. SET @JobType=''
  3654. ----生成工作地点的表变量
  3655. IF LEN(@dcRegionID) > 0
  3656. BEGIN
  3657. INSERT INTO @T_JobPlace
  3658. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  3659. SELECT @JobPlace = (@JobPlace + ' OR a.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  3660. IF LeN(@JobPlace) > 0
  3661. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  3662. END
  3663. ----生成求聘职位的表变量
  3664. IF LEN(@dcJobTypeID) > 0
  3665. BEGIN
  3666. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  3667. INSERT INTO @T_Temp
  3668. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  3669. INSERT INTO @T_JobType
  3670. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  3671. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  3672. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  3673. OR ID IN(SELECT ID FROM @T_TEMP)
  3674. ----生成in字符串
  3675. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  3676. IF RIGHT(@JobType, 1) = ','
  3677. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  3678. END
  3679. CREATE TABLE #t(
  3680. JobName NVARCHAR(50),
  3681. cpName VARCHAR(100),
  3682. JobID INT,
  3683. EnJobID VARCHAR(50),
  3684. Region VARCHAR(100),
  3685. RefreshDate SMALLDATETIME,
  3686. utm_campaign VARCHAR(100),
  3687. utm_source VARCHAR(100)
  3688. )
  3689. SET @SQL='
  3690. INSERT INTO #t
  3691. SELECT TOP ' + CONVERT(VARCHAR(2), @EmailNumber) + ' a.Name,b.Name cpName,a.ID, a.SecondId,
  3692. (SELECT Description FROM dcRegion WITH(NOLOCK) WHERE dcRegion.ID = a.dcRegionId) Region,
  3693. a.RefreshDate,''Email_23&utm_medium=Email'',''utm_source=Mail_'+substring(@Email,PATINDEX('%@%.%',@Email),Len(@Email)-PATINDEX('%@%.%',@Email)+1)+'''
  3694. FROM Job a WITH(NOLOCK)
  3695. INNER JOIN cpMain b WITH(NOLOCK) ON a.cpMainID=b.ID'
  3696. IF LEN(@dcIndustryID) > 0
  3697. SET @SQL = @SQL + '
  3698. INNER JOIN cpIndustry c WITH(NOLOCK) ON c.cpMainID=b.ID
  3699. AND c.dcIndustryId in(' + @dcIndustryID + ')'
  3700. SET @SQL = @SQL + '
  3701. WHERE a.IsDelete=0
  3702. AND a.IssueDate<Getdate()
  3703. AND a.IssueEND>Getdate()
  3704. AND b.Valid = 1'
  3705. ----职位类别
  3706. IF LEN(@dcJobTypeID) > 0
  3707. SET @SQL = @SQL + '
  3708. AND (a.dcJobTypeID IN(' + @JobType +')
  3709. OR a.dcJobTypeIDMinor IN(' +@JobType + '))'
  3710. IF LEN(@JobPlace) > 0
  3711. SET @SQL = @SQL + '
  3712. AND (' + @JobPlace + ')'
  3713. ----月薪是本级和上级别的薪金
  3714. IF @dcSalaryID > 0
  3715. BEGIN
  3716. SET @SQL = @SQL + '
  3717. AND (a.dcSalaryID=' + LTRIM(STR(@dcSalaryID)) + ' OR a.dcSalaryID = ' + LTRIM(STR(@dcSalaryID + 1))
  3718. IF @IsNegotiable = 1 --包括面议
  3719. SET @SQL = @SQL + ' OR a.dcSalaryID = 100'
  3720. SET @SQL = @SQL + ')'
  3721. END
  3722. ----工作经验要求
  3723. IF @MinExperience < 100
  3724. SET @SQL = @SQL + '
  3725. AND a.MinExperience = ' + LTRIM(STR(@MinExperience))
  3726. ----学历要求
  3727. ----'1初中','2\3\4高中、中技、中专','5大专','6本科','7硕士','8博士
  3728. IF @dcEducationID > 0
  3729. IF @dcEducationID = 2
  3730. SET @SQL = @SQL + '
  3731. AND a.dcEducationID IN(2,3,4)'
  3732. ELSE
  3733. SET @SQL = @SQL + '
  3734. AND a.dcEducationID = ' + LTRIM(STR(@dcEducationID))
  3735. ----1、全职;3、兼职;4实习。 2、全职/兼职 职位中无此项
  3736. IF LEN(@EmployType) > 0
  3737. SET @SQL = @SQL + '
  3738. AND a.EmployType IN (' + @EmployType + ')'
  3739. SET @Sql = @Sql + '
  3740. AND a.Id NOT IN(SELECT JobId FROM JobSubScription WITH(NOLOCK) WHERE paJobFinderID = ' + LTRIM(STR(@paJobFinderID)) + ')'
  3741. ----把符合条件的职位全部列出
  3742. SET @SQL = @SQL + ' ORDER BY RefreshDate DESC, a.ID DESC'
  3743. PRINT @SQL
  3744. EXEC(@SQL)
  3745. INSERT JobSubScription(paJobFinderID, JobId) SELECT @paJobFinderID, JobId FROM #t
  3746. SELECT * FROM #t
  3747. END
  3748. GO
  3749. /****** Object: StoredProcedure [dbo].[bsJobByRenrenSelect] Script Date: 2018/12/13 19:05:40 ******/
  3750. SET ANSI_NULLS ON
  3751. GO
  3752. SET QUOTED_IDENTIFIER ON
  3753. GO
  3754. -- =============================================
  3755. -- Author: PETER
  3756. -- Create date: 2012-11-05
  3757. -- Description: 生成人人XML
  3758. -- =============================================
  3759. CREATE PROCEDURE [dbo].[bsJobByRenrenSelect]
  3760. AS
  3761. BEGIN
  3762. CREATE TABLE #Job(
  3763. [ID] [int],
  3764. [cpMainID] [int] NOT NULL,
  3765. [Name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NOT NULL,
  3766. [dcJobTypeID] [smallint] NOT NULL,
  3767. [NeedNumber] [tinyint] NULL,
  3768. [dcSalaryID] [tinyint] NOT NULL,
  3769. [EmployType] [tinyint] NOT NULL,
  3770. [Responsibility] [varchar](max) COLLATE Chinese_PRC_CI_AS NOT NULL,
  3771. [Demand] [varchar](max) COLLATE Chinese_PRC_CI_AS NOT NULL,
  3772. [dcEducationID] [tinyint] NOT NULL,
  3773. [IssueDate] [smalldatetime] NULL,
  3774. [IssueEnd] [smalldatetime] NULL,
  3775. [CompanyName] [Nvarchar](50),
  3776. [SubSiteName] [varchar](50),
  3777. [SubSiteUrl] [varchar](50),
  3778. [RegionName] [nvarchar](50),
  3779. [dcIndustryID] [varchar](50),
  3780. [dcRegionID] [varchar](6),
  3781. [SecondID] [VARCHAR](30)
  3782. )
  3783. CREATE TABLE #cpMain(
  3784. [ID] [int],
  3785. [Name] [varchar](100) COLLATE Chinese_PRC_CI_AS NOT NULL,
  3786. [ShortName] [varchar](40) COLLATE Chinese_PRC_CI_AS NULL,
  3787. [dcCompanyKindID] [smallint] NULL,
  3788. [dcCompanySizeID] [tinyint] NULL,
  3789. [Address] [nvarchar](60) COLLATE Chinese_PRC_CI_AS NULL,
  3790. [HomePage] [varchar](100) COLLATE Chinese_PRC_CI_AS NULL,
  3791. [Brief] [varchar](6000) COLLATE Chinese_PRC_CI_AS NULL,
  3792. [dcIndustryID] [varchar](50),
  3793. [SecondID] [VARCHAR](30)
  3794. )
  3795. INSERT INTO #Job
  3796. SELECT a.ID,a.cpMainID,a.Name,a.dcJobTypeID,a.NeedNumber,a.dcSalaryID,a.EmployType,a.Responsibility,
  3797. a.Demand,a.dcEducationID,a.IssueDate,a.IssueEnd,b.Name CompanyName,c.SubSiteName,c.SubSiteUrl,
  3798. d.MapBarName RegionName ,dbo.GetCpIndustryId(a.cpMainID) dcIndustryID,a.dcRegionID,a.SecondID
  3799. FROM Job AS a WITH(NOLOCK)
  3800. INNER JOIN cpMain AS b WITH(NOLOCK) ON b.ID=a.cpMainID
  3801. INNER JOIN dcsubsite AS c WITH(NOLOCK) ON c.id=b.dcsubsiteID
  3802. INNER JOIN dcRegion as d WITH(NOLOCK) on d.id=a.dcregionID
  3803. WHERE (minexperience=5 or minexperience=0) AND a.valid=1 and b.valid=1
  3804. ORDER BY a.id DESC
  3805. INSERT INTO #cpMain
  3806. SELECT a.ID,a.Name,a.ShortName,a.dcCompanyKindID,a.dcCompanySizeID,a.Address,a.HomePage,a.Brief,
  3807. dbo.GetCpIndustryId(ID) dcIndustryID,a.SecondID
  3808. FROM cpMain a WITH(NOLOCK)
  3809. WHERE id IN(
  3810. SELECT cpMainID
  3811. FROM #Job)
  3812. SELECT * FROM #Job
  3813. SELECT * FROM #Cpmain
  3814. END
  3815. GO
  3816. /****** Object: StoredProcedure [dbo].[bsManagerUserByLowerSelect] Script Date: 2018/12/13 19:05:40 ******/
  3817. SET ANSI_NULLS ON
  3818. GO
  3819. SET QUOTED_IDENTIFIER ON
  3820. GO
  3821. CREATE PROCEDURE [dbo].[bsManagerUserByLowerSelect]
  3822. (
  3823. @ID AS INT
  3824. )
  3825. AS
  3826. BEGIN
  3827. WITH T(ID,Name,Name_Eng,Superior,DispID)
  3828. AS
  3829. (
  3830. SELECT ID,Name,Name_Eng,Superior, CONVERT(BigINT,ID) AS DispID
  3831. FROM ManagerUSer WITH(NOLOCK)
  3832. WHERE ID = 1
  3833. UNION ALL
  3834. SELECT a.ID,a.Name,a.Name_Eng,a.Superior, DispID*100 + a.ID
  3835. FROM ManagerUSer a WITH(NOLOCK), T
  3836. WHERE a.Superior = T.ID
  3837. AND Status<>3
  3838. )
  3839. SELECT * FROM T ORDER BY CONVERT(VARCHAR(20),DispID)
  3840. END
  3841. GO
  3842. /****** Object: StoredProcedure [dbo].[bsMobileReceivedInsert] Script Date: 2018/12/13 19:05:40 ******/
  3843. SET ANSI_NULLS ON
  3844. GO
  3845. SET QUOTED_IDENTIFIER ON
  3846. GO
  3847. --=============================================
  3848. -- Lambo 20101020
  3849. -- 在现版的基础上修改,用于增加收到的短信记录
  3850. -- sean 20110505
  3851. -- 增加手机回复请假信息
  3852. --=============================================
  3853. CREATE PROCEDURE [dbo].[bsMobileReceivedInsert]
  3854. (
  3855. @Mobile VARCHAR(13),
  3856. @Msg NVARCHAR(200),
  3857. @ManagerUserId INT OUTPUT,
  3858. @CompanyID INT OUTPUT,
  3859. @CompanyName NVARCHAR(100) OUTPUT
  3860. )
  3861. AS
  3862. BEGIN
  3863. SET NOCOUNT ON;
  3864. DECLARE @MaxID AS INT
  3865. SELECT @MaxID = MAX(ID+1) FROM MobileReceived WITH(NOLOCK)
  3866. -- IF ISNULL(@MaxID, 0) < 4000
  3867. -- SET @MaxID = 4000
  3868. INSERT INTO MobileReceived(ID, Mobile, Msg, MessageCenter, Type) VALUES(@MaxID, @Mobile, @Msg, 'qxt', 0)
  3869. SELECT TOP 1 @CompanyID = CompanyID, @ManagerUserId = ManagerUserId FROM MobileSend WITH(NOLOCK) WHERE Mobile = @Mobile ORDER BY ID DESC
  3870. IF @CompanyID IS NOT NULL
  3871. BEGIN
  3872. SELECT @CompanyName = Name FROM cpMain WITH(NOLOCK) WHERE ID = @CompanyID
  3873. UPDATE MobileReceived SET CompanyID = @CompanyID, ManagerUserId = @ManagerUserId, Type = 2 WHERE ID = @MaxID
  3874. RETURN
  3875. END
  3876. SELECT TOP 1 @CompanyID = a.ID, @ManagerUserId = a.ConsultantId, @CompanyName = a.Name FROM cpMain a WITH(NOLOCK), caMain b WITH(NOLOCK) WHERE a.ID = b.cpMainID AND b.Mobile = @Mobile OR b.TelePhone = @Mobile
  3877. IF @CompanyID IS NOT NULL
  3878. BEGIN
  3879. UPDATE MobileReceived SET CompanyID = @CompanyID, ManagerUserId = @ManagerUserId, Type = 1 WHERE ID = @MaxID
  3880. RETURN
  3881. END
  3882. SELECT TOP 1 @CompanyID = a.cpMainID FROM JOB a WITH(NOLOCK), caMain b WITH(NOLOCK) WHERE a.caMainID = b.ID AND b.Mobile = @Mobile OR b.TelePhone = @Mobile
  3883. IF @CompanyID IS NOT NULL
  3884. BEGIN
  3885. SELECT @ManagerUserId = ConsultantId, @CompanyName = CompanyName FROM Company WITH(NOLOCK) WHERE ID = @CompanyID
  3886. UPDATE MobileReceived SET CompanyID = @CompanyID, ManagerUserId = @ManagerUserId, Type = 1 WHERE ID = @MaxID
  3887. RETURN
  3888. END
  3889. END
  3890. GO
  3891. /****** Object: StoredProcedure [dbo].[bsMobileSpendByMobileExist] Script Date: 2018/12/13 19:05:40 ******/
  3892. SET ANSI_NULLS ON
  3893. GO
  3894. SET QUOTED_IDENTIFIER ON
  3895. GO
  3896. CREATE PROCEDURE [dbo].[bsMobileSpendByMobileExist]
  3897. (
  3898. @Mobile VARCHAR(11),
  3899. @ProvinceId SMALLINT,
  3900. @UserType TINYINT --0 企业 1 个人
  3901. )
  3902. AS
  3903. BEGIN
  3904. --个人手机已经注册
  3905. IF @UserType = 1 AND EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK) WHERE Mobile = @Mobile)
  3906. RETURN -2
  3907. --企业手机已经注册
  3908. IF @UserType = 0 AND EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE Mobile = @Mobile)
  3909. RETURN -3
  3910. --手机已经推广注册
  3911. IF EXISTS(SELECT 'x' FROM bsMobileSpread WITH(NOLOCK) WHERE MobileNo = @Mobile AND UserType = @UserType)
  3912. RETURN -4
  3913. --个人手机黑名单
  3914. IF @UserType = 1 AND EXISTS(SELECT 'x' FROM Person_Black WITH(NOLOCK) WHERE Mobile = @Mobile)
  3915. RETURN -5
  3916. --企业手机黑名单
  3917. IF @UserType = 0 AND EXISTS(SELECT 'x' FROM company_black WITH(NOLOCK) WHERE Mobile = @Mobile)
  3918. RETURN -6
  3919. --短信号码和推广地区不一致
  3920. IF NOT EXISTS(SELECT 'x' FROM dcMobileArea WITH(NOLOCK) WHERE num = LEFT(@Mobile, 7) AND dcRegionId LIKE LTRIM(STR(@ProvinceId)) + '%')
  3921. RETURN -7
  3922. RETURN 1
  3923. END
  3924. GO
  3925. /****** Object: StoredProcedure [dbo].[bsMobileSpreadInsert] Script Date: 2018/12/13 19:05:41 ******/
  3926. SET ANSI_NULLS ON
  3927. GO
  3928. SET QUOTED_IDENTIFIER ON
  3929. GO
  3930. --###############################################
  3931. --Create Date:2012-05-16
  3932. --Creator:labmo
  3933. --个人和企业短信推广,前台验证通过后,插入数据
  3934. --去掉try,catch,查看出错的原因--harry2015-8-12
  3935. --###############################################
  3936. CREATE PROCEDURE [dbo].[bsMobileSpreadInsert]
  3937. (
  3938. @Mobile VARCHAR(11),
  3939. @ProvinceId SMALLINT,
  3940. @AddMan SMALLINT,
  3941. @UserType BIT, --0企业; 1个人
  3942. @CompanyName VARCHAR(100)=''
  3943. )
  3944. AS
  3945. SET NOCOUNT ON;
  3946. IF dbo.IsMobile(@Mobile) = 0
  3947. RETURN -1
  3948. --个人手机已经注册
  3949. IF @UserType = 1 AND EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK) WHERE Mobile = @Mobile)
  3950. RETURN -2
  3951. --企业手机已经注册
  3952. IF @UserType = 0 AND EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE Mobile = @Mobile)
  3953. RETURN -3
  3954. --个人手机已经推广注册
  3955. IF EXISTS(SELECT 'x' FROM bsMobileSpread WITH(NOLOCK) WHERE MobileNo = @Mobile AND UserType = @UserType)
  3956. RETURN -4
  3957. --个人手机黑名单
  3958. IF @UserType = 1 AND EXISTS(SELECT 'x' FROM Person_Black WITH(NOLOCK) WHERE Mobile = @Mobile)
  3959. RETURN -5
  3960. --企业手机黑名单
  3961. IF @UserType = 0 AND EXISTS(SELECT 'x' FROM Company_Black WITH(NOLOCK) WHERE Mobile = @Mobile)
  3962. RETURN -6
  3963. --短信号码和推广地区不一致
  3964. IF NOT EXISTS(SELECT 'x' FROM dcMobileArea WITH(NOLOCK) WHERE num = LEFT(@Mobile, 7) AND dcRegionId LIKE LTRIM(STR(@ProvinceId)) + '%')
  3965. RETURN -7
  3966. --检查是否超出最大范围
  3967. DECLARE @MobileNum AS INT
  3968. DECLARE @Sms_Limit AS INT
  3969. SELECT @MobileNum = CASE @UserType WHEN 1 THEN MobileNum ELSE cpMobileNum END
  3970. FROM Info_DateReport WITH(NOLOCK)
  3971. WHERE InfoManager_ID = @AddMan
  3972. AND Province_ID = @ProvinceId
  3973. AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  3974. SELECT @Sms_Limit = ISNULL(CASE @UserType WHEN 1 THEN Sms_Limit ELSE cpSms_Limit END,2000) FROM Group_Province WITH(NOLOCK)
  3975. WHERE Province_ID = @ProvinceID
  3976. IF @MobileNum >= @Sms_Limit
  3977. RETURN -8
  3978. BEGIN
  3979. DECLARE @R AS INT
  3980. BEGIN TRAN
  3981. INSERT INTO bsMobileSpread(MobileNo, ProvinceId, AddMan,UserType,CompanyName) VALUES(@Mobile, @ProvinceId, @AddMan,@UserType,@CompanyName)
  3982. SELECT @R = @@IDENTITY
  3983. DECLARE @CountDate AS VARCHAR(8)
  3984. SET @CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  3985. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK) WHERE CountDate = @CountDate
  3986. AND Province_ID = @ProvinceID
  3987. AND InfoManager_ID = @AddMan)
  3988. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, CountDate)
  3989. VALUES(@ProvinceID, @AddMan, @CountDate)
  3990. IF @UserType = 1
  3991. UPDATE Info_DateReport SET MobileNum = MobileNum + 1
  3992. WHERE CountDate = @CountDate
  3993. AND Province_ID = @ProvinceID
  3994. AND InfoManager_ID = @AddMan
  3995. ELSE
  3996. UPDATE Info_DateReport SET cpMobileNum = cpMobileNum + 1
  3997. WHERE CountDate = @CountDate
  3998. AND Province_ID = @ProvinceID
  3999. AND InfoManager_ID = @AddMan
  4000. COMMIT
  4001. RETURN @R
  4002. END
  4003. GO
  4004. /****** Object: StoredProcedure [dbo].[bsPaPushLogSchedule] Script Date: 2018/12/13 19:05:41 ******/
  4005. SET ANSI_NULLS ON
  4006. GO
  4007. SET QUOTED_IDENTIFIER ON
  4008. GO
  4009. --前台客户端推送 Lucifer 20160217
  4010. --职位订阅,添加推送
  4011. --关注的职位未申请的还有两天过期的,添加推送
  4012. --每天早上9点执行
  4013. CREATE PROCEDURE [dbo].[bsPaPushLogSchedule]
  4014. AS
  4015. SET NOCOUNT ON
  4016. BEGIN
  4017. INSERT INTO paPushLog(paMainID, PushMessage, PushType, DetailID)
  4018. SELECT b.paMainID, '智能职位搜索根据您的订阅,查询出了最近更新的部分职位,快来看看吧!', 7, a.paJobFinderID
  4019. FROM JobSubScription a, paJobFinder b
  4020. WHERE a.paJobFinderID = b.ID AND a.AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  4021. AND EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = b.paMainID)
  4022. GROUP BY a.paJobFinderID, b.paMainID
  4023. INSERT INTO paPushLog(paMainID, PushMessage, PushType, DetailID)
  4024. SELECT b.paMainID, '亲,您关注的1个职位即将到期,赶快来申请吧!', 8, a.ID FROM Job a INNER JOIN paAttention b
  4025. ON a.ID = b.AttentionID AND b.AttentionType = 2
  4026. WHERE a.Valid = 1 AND DATEDIFF(d, GETDATE(), a.IssueEnd) = 2
  4027. AND NOT EXISTS(SELECT 'X' FROM exJobApply c, cvMain d WHERE c.cvMainID = d.ID AND d.paMainID = b.paMainID AND c.JobID = a.ID)
  4028. AND EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = b.paMainID)
  4029. INSERT wxMessageSend2(Templatetype, WxFansID, CpMainID, AddDate, JobId)
  4030. SELECT 18, b.ID, c.cpMainID, GETDATE(), c.Id
  4031. FROM paLoginContact a WITH(NOLOCK), wxFans b WITH(NOLOCK), Job c WITH(NOLOCK)
  4032. WHERE a.OpenID = b.OpenID AND c.caMainID = a.paMainID AND a.ContactType = 101 AND c.Valid = 1 AND DATEDIFF(d, GETDATE(), c.IssueEnd) = 2
  4033. END
  4034. GO
  4035. /****** Object: StoredProcedure [dbo].[bsResume_XinxiInsert] Script Date: 2018/12/13 19:05:41 ******/
  4036. SET ANSI_NULLS ON
  4037. GO
  4038. SET QUOTED_IDENTIFIER ON
  4039. GO
  4040. -- =============================================
  4041. -- sean 2010-12-1
  4042. -- 用于信息员注册, 判断email是否存在
  4043. --返回值:
  4044. -- -1 黑名单
  4045. -- -2 QQ超限
  4046. -- -10 paMAin重复
  4047. -- -11 Resume_xinxi重复
  4048. -- ----返回asp发送邮件 2011-5-17 sean
  4049. -- =============================================
  4050. CREATE PROCEDURE [dbo].[bsResume_XinxiInsert]
  4051. (
  4052. @Email VARCHAR(50),
  4053. @Password VARCHAR(10),
  4054. @ManagerUserID SMALLINT,
  4055. @ProvinceID TINYINT,
  4056. @UserName VARCHAR(50) OUTPUT,
  4057. @DbPassword VARCHAR(50) OUTPUT
  4058. )
  4059. AS
  4060. SET NOCOUNT ON;
  4061. SELECT @UserName = '', @DbPassword = ''
  4062. IF LEN(ISNULL(@Email, '')) = 0
  4063. GOTO Err
  4064. IF LEN(ISNULL(@Password, '')) = 0
  4065. GOTO Err
  4066. IF ISNULL(@ManagerUserID, 0) = 0
  4067. GOTO Err
  4068. IF ISNULL(@ProvinceID, 0) = 0
  4069. GOTO Err
  4070. IF dbo.IsEmail(@Email) = 0
  4071. GOTO Err
  4072. BEGIN TRAN
  4073. BEGIN TRY
  4074. ----检查黑名单
  4075. IF EXISTS(SELECT 'x' FROM Person_Black WITH(NOLOCK INDEX(IX_Person_Black_Email)) WHERE Email = @Email)
  4076. GOTO Err1
  4077. ----检查qq
  4078. IF @Email LIKE '%@QQ.com%'
  4079. BEGIN
  4080. DECLARE @PersonRegNum_Our_QQ AS INT
  4081. DECLARE @QQLimit AS INT
  4082. SELECT @PersonRegNum_Our_QQ = PersonRegNum_Our_QQ
  4083. FROM Info_DateReport WITH(NOLOCK)
  4084. WHERE InfoManager_ID = @ManagerUserID
  4085. AND Province_ID = @ProvinceID
  4086. AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  4087. SELECT @QQLimit = QQ_Limit FROM Group_Province WITH(NOLOCK)
  4088. WHERE Province_ID = @ProvinceID
  4089. SELECT @QQLimit = @QQLimit / 5 FROM ManagerUser WITH(NOLOCK) WHERE RoleId = 52 AND ID <> 364 AND ID = @ManagerUserID
  4090. IF @PersonRegNum_Our_QQ > @QQLimit
  4091. GOTO Err2
  4092. END
  4093. ----检查活动区
  4094. IF EXISTS(SELECT 'x' FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_xinxi_Email)) WHERE Email = @Email AND IsHistory = 0)
  4095. GOTO Err11
  4096. ----检查账号
  4097. IF EXISTS(SELECT 'x' FROM paMain WITH(NOLOCK INDEX(IX_pamain_Email)) WHERE Email = @Email)
  4098. GOTO Err10
  4099. ----检查非活动区
  4100. DECLARE @ResumeXinxiID AS INT, @TmpID INT,@Addman INT,@RegDate SMALLDATETIME
  4101. SELECT TOP 1 @ResumeXinxiID = ID,
  4102. @Addman = Addman,
  4103. @RegDate = RegDate
  4104. FROM Resume_Xinxi WITH(NOLOCK INDEX(IX_Resume_xinxi_Email))
  4105. WHERE Email = @Email
  4106. AND IsHistory = 1
  4107. ORDER BY RegDate DESC
  4108. IF @ResumeXinxiID IS NULL --未注册,增加
  4109. BEGIN
  4110. INSERT INTO Resume_Xinxi(Username, Password, Email, Province_ID, AddMan, RegDate)
  4111. VALUES(@Email, @Password, @Email, @ProvinceID, @ManagerUserID, GETDATE())
  4112. SELECT @TmpID = @@Identity
  4113. END
  4114. ELSE --已注册,激活,不修改用户名和密码
  4115. BEGIN
  4116. UPDATE Resume_Xinxi SET RegDate = GETDATE(), AddMan = @ManagerUSerID, Province_ID = @ProvinceID, IsHistory = 0
  4117. WHERE ID = @ResumeXinxiID
  4118. --将用户信息插入到ActivationCvDetail中 max 2013-08-23
  4119. INSERT INTO LogDB..ActivationCvDetail(Username,Email,AddmanOld,AddmanNew,RegdateOld,RegdateNew)
  4120. VALUES (@Email,@Email,@Addman,@ManagerUserID,@RegDate,GETDATE())
  4121. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  4122. WHERE Infomanager_ID = @ManagerUserID
  4123. AND Province_ID = @ProvinceID
  4124. AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112))
  4125. INSERT INTO Info_DateReport(Province_Id, InfoManager_Id, CountDate)
  4126. VALUES(@ProvinceId, @ManageruserId, CONVERT(VARCHAR(8), GETDATE(), 112))
  4127. UPDATE Info_DateReport SET PersonalActivationCount = PersonalActivationCount + 1
  4128. WHERE Infomanager_ID = @ManagerUserID
  4129. AND Province_ID = @ProvinceID
  4130. AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  4131. ----返回asp发送邮件
  4132. SELECT @UserName = UserName, @DbPassword = Password FROM Resume_Xinxi WITH(NOLOCK)
  4133. WHERE ID = @ResumeXinxiID
  4134. DELETE FROM Resume_Xinxi
  4135. WHERE Email = @Email AND IsHistory = 1
  4136. SELECT @TmpID = @ResumeXinxiID
  4137. END
  4138. -----统计值是否放在这里????????????????????????????
  4139. UPDATE DateReport SET PersonRegNum_Our = PersonRegNum_Our + 1
  4140. WHERE Province_ID = @ProvinceID
  4141. AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  4142. --INSERT INTO pamainDatereport SELECT @TmpID, 7, GETDATE() -- SEAN 20130911
  4143. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK)
  4144. WHERE InfoManager_ID = @ManagerUserID
  4145. AND Province_ID = @ProvinceID
  4146. AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  4147. )
  4148. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, Countdate)
  4149. VALUES(@ProvinceID, @ManagerUserID, CONVERT(VARCHAR(8), GETDATE(), 112))
  4150. IF @Email LIKE '%@QQ.com%'
  4151. UPDATE Info_DateReport
  4152. SET PersonRegNum_Our = PersonRegNum_Our + 1,
  4153. PersonRegNum_Our_QQ = PersonRegNum_Our_QQ + 1
  4154. WHERE InfoManager_ID = @ManageruserID
  4155. AND Province_ID = @ProvinceID
  4156. AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  4157. ELSE
  4158. UPDATE Info_DateReport SET PersonRegNum_Our = PersonRegNum_Our + 1
  4159. WHERE InfoManager_ID = @ManageruserID
  4160. AND Province_ID = @ProvinceID
  4161. AND CountDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  4162. END TRY
  4163. BEGIN CATCH
  4164. GOTO Err
  4165. END CATCH
  4166. COMMIT
  4167. RETURN 1
  4168. Err:
  4169. BEGIN
  4170. RETURN 0
  4171. END
  4172. Err1:
  4173. BEGIN
  4174. ROLLBACK TRAN
  4175. RETURN -1
  4176. END
  4177. Err2:
  4178. BEGIN
  4179. ROLLBACK TRAN
  4180. RETURN -2
  4181. END
  4182. Err10:
  4183. BEGIN
  4184. ROLLBACK TRAN
  4185. RETURN -10
  4186. END
  4187. Err11:
  4188. BEGIN
  4189. ROLLBACK TRAN
  4190. RETURN -11
  4191. END
  4192. GO
  4193. /****** Object: StoredProcedure [dbo].[bsschMailPrevJobResumeCreatebak2] Script Date: 2018/12/13 19:05:42 ******/
  4194. SET ANSI_NULLS ON
  4195. GO
  4196. SET QUOTED_IDENTIFIER ON
  4197. GO
  4198. /****** 对象: StoredProcedure [dbo].[bsschMailPrev2JobResumeCreate] 脚本日期: 10/18/2016 15:06:19 ******/
  4199. create PROCEDURE [dbo].[bsschMailPrevJobResumeCreatebak2]
  4200. AS
  4201. SET NOCOUNT ON
  4202. BEGIN
  4203. IF ISNULL((SELECT TOP 1 CONVERT(VARCHAR(8), AddDate, 112) FROM schMailPrev2), '') <> CONVERT(VARCHAR(8), GETDATE(), 112)
  4204. BEGIN
  4205. TRUNCATE TABLE schMailPrev2
  4206. --需要推荐简历的职位
  4207. CREATE TABLE #TCaNeedPush(CaMainID INT)
  4208. INSERT INTO #TCaNeedPush
  4209. SELECT b.caMainID
  4210. FROM caPushSet b WITH(NOLOCK)
  4211. WHERE ISNULL(b.PushNo,10) < 10
  4212. AND b.LastPushdate > CONVERT(CHAR(10), GETDATE(), 120) + ' 00:00:00'
  4213. INSERT INTO schMailPrev2
  4214. SELECT 1,ISNULL(c.dcProvinceID,0),a.caMainID,ISNULL(b.Name,''),ISNULL(b.UserName,''),ISNULL(b.cpMainID,0),ISNULL(b.Name,'')+'您好,您发布的职位推荐简历',0,CASE LEN(c.dcsubsiteid) WHEN 2 THEN '' ELSE ISNULL(d.emailsite,'') END,ISNULL(b.Email,''),ISNULL(d.SubsiteName,''),NULL,0,GETDATE(),NULL,NULL,NULL,c.dcRegionID,NULL,NULL
  4215. FROM #TCaNeedPush a
  4216. LEFT JOIN caMain b WITH(NOLOCK) ON b.id = a.caMainID
  4217. LEFT JOIN cpMain c WITH(NOLOCK) ON c.id = b.cpMainID
  4218. LEFT JOIN dcSubsite d WITH(NOLOCK) ON d.id = c.dcSubsiteID
  4219. DELETE FROM schMailPrev2 WHERE Email LIKE '%qq.com'
  4220. END
  4221. DECLARE @Rows AS INT, @i AS INT, @Content AS VARCHAR(MAX), @MinID AS INT
  4222. SELECT @Rows = COUNT(*), @MinID = MIN(ID), @I=0 FROM schMailPrev2 WITH(NOLOCK) WHERE MailBody IS NULL
  4223. DECLARE @TJob AS TABLE(JobID INT,JobName NVARCHAR(50),JobSecondID VARCHAR(20))
  4224. IF @Rows = 0
  4225. RETURN
  4226. WHILE @i < @Rows
  4227. BEGIN
  4228. DELETE FROM @TJob
  4229. INSERT INTO @TJob
  4230. SELECT a.JobID,b.Name JobName,b.SecondID JobSecondID
  4231. FROM caJobCvMatch a WITH(NOLOCK)
  4232. LEFT JOIN JobPublish b WITH(NOLOCK) ON b.ID = a.JobID
  4233. WHERE a.JobID IN (
  4234. SELECT ID
  4235. FROM JobPublish WITH(NOLOCK)
  4236. WHERE caMainID = (
  4237. SELECT TOP 1 AccountID
  4238. FROM schMailPrev2 WITH(NOLOCK)
  4239. WHERE id = @i + @MinID
  4240. )
  4241. )
  4242. DECLARE @PushJobID INT,@PushJobName NVARCHAR(50),@PushJobSecondID VARCHAR(20)
  4243. SET @Content = ''
  4244. WHILE EXISTS(SELECT 'x' FROM @TJob)
  4245. BEGIN
  4246. SELECT TOP 1 @PushJobID = JobID,@PushJobName = JobName,@PushJobSecondID = JobSecondID
  4247. FROM @TJob
  4248. ORDER BY JobID ASC
  4249. SET @Content = @Content + '<tr><td colspan=5><a href="http://##SiteUrl##/personal/jb' + @PushJobSecondID + '.html" target="_blank">' + @PushJobName + '</a></td></tr>'
  4250. SELECT @Content = @Content + '<tr>' +
  4251. '<td>'+ISNULL(b.Name, ' ')+'[<a href="http://##SiteUrl##/Company/cv/cvview?id=' + CONVERT(VARCHAR, b.ResumeID) + '" target="_blank">' + CONVERT(VARCHAR, b.ResumeID) + '</a>]</td>'+
  4252. '<td>'+(CASE ISNULL(b.Sex, 0) WHEN 0 THEN '男' WHEN 1 THEN '女' END)+'</td>'+
  4253. '<td>'+CONVERT(VARCHAR, ISNULL(b.Age, 30))+'</td>'+
  4254. '<td>'+ISNULL(b.JobType, ' ')+'</td>'+
  4255. '<td>'+ISNULL(b.AtPlaceDesc, ' ')+'</td>'+
  4256. '</tr>'
  4257. FROM caJobCvMatch a WITH(NOLOCK),caJobResumePre b WITH(NOLOCK)
  4258. WHERE a.MatchCvMainID = b.ResumeID
  4259. AND a.JobID = @PushJobID
  4260. AND a.PushDate IS NULL
  4261. ORDER BY b.LastLoginDate DESC
  4262. UPDATE caJobCvMatch
  4263. SET PushDate = GETDATE()
  4264. WHERE JobID = @PushJobID
  4265. DELETE FROM @TJob WHERE JobID = @PushJobID
  4266. END
  4267. IF LEN(LTRIM(RTRIM(ISNULL(@Content, '')))) = 0
  4268. UPDATE schMailPrev2
  4269. SET MailBody = '<br>&nbsp;&nbsp;符合您招聘职位的推荐简历已经全部发送,暂时没有新的简历出现。您可以登录网站后使用“职位管理”-->“发布中的职位”,修改给你推荐的频率。<br>&nbsp;&nbsp;',
  4270. RefreshDate = GETDATE()
  4271. WHERE ID = @I+@MinID
  4272. ELSE
  4273. UPDATE schMailPrev2
  4274. SET MailBody = '以下是贵单位招聘职位推荐的部分简历。<br><table style="font-size:12px"><tr style="FONT-WEIGHT: bold; background-color:#f7b666;"><td>求职者</td><td>性别</td><td>年龄</td><td>求职意向</td><td>所在地</td></tr>' + @Content + '</table>详细情况请登录网站后使用“简历搜索”-->“<a href="http://##SiteUrl##/Company/cvSearch/Search" target="_blank">搜索简历</a>”-->点击“更多搜索条件”-->输入“简历编号”搜索。',
  4275. RefreshDate = GETDATE()
  4276. WHERE ID = @I+@MinID
  4277. UPDATE a
  4278. SET a.MailBody = REPLACE(a.MailBody, '##SiteUrl##', 'www.' + b.ProvinceDomain)
  4279. FROM schMailPrev2 a,dcProvince b
  4280. WHERE a.dcProvinceId = b.Id
  4281. AND a.Id = @I+@MinID
  4282. SET @i = @i + 1
  4283. END
  4284. DELETE schMailPrev2 WHERE Email LIKE '%qq.com'
  4285. END
  4286. GO
  4287. /****** Object: StoredProcedure [dbo].[ccActiveDownExist] Script Date: 2018/12/13 19:05:42 ******/
  4288. SET ANSI_NULLS ON
  4289. GO
  4290. SET QUOTED_IDENTIFIER ON
  4291. GO
  4292. --######################################3
  4293. --创建:Lambo,修改Sean
  4294. --检查企业账号是否消耗日配额看过简历联系方式
  4295. --企业有多账号的情况,一个企业内部的查看共享
  4296. --######################################3
  4297. CREATE PROCEDURE [dbo].[ccActiveDownExist]
  4298. (
  4299. @cpMainID INT,
  4300. @cvMainID INT
  4301. )
  4302. AS
  4303. BEGIN
  4304. DECLARE @paMainId INT
  4305. SELECT @paMainID = paMainID FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  4306. IF EXISTS(SELECT 'x' FROM caActiveLog WITH(NOLOCK)
  4307. WHERE cpMainID = @cpMainID
  4308. AND cvMainId IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID)
  4309. )
  4310. RETURN 1
  4311. IF EXISTS(SELECT 'x' FROM caDailyGiftLog WITH(NOLOCK) WHERE cpMainID = @cpMainID AND cvMainID = @cvMainID)
  4312. RETURN 1
  4313. IF EXISTS (
  4314. SELECT 'x' FROM ExJobApply a WITH(NOLOCK),Job b
  4315. WHERE a.JobID = b.ID
  4316. AND a.IsPassed = 1
  4317. AND a.cvMainID IN(SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainID = @paMainID)
  4318. AND b.cpMainID = @cpMainID
  4319. )
  4320. RETURN 1
  4321. RETURN 0
  4322. END
  4323. GO
  4324. /****** Object: StoredProcedure [dbo].[ccAdverProjectByProvinceIDSelect] Script Date: 2018/12/13 19:05:42 ******/
  4325. SET ANSI_NULLS ON
  4326. GO
  4327. SET QUOTED_IDENTIFIER ON
  4328. GO
  4329. --#####################################################
  4330. --创建时间:2014.10.31
  4331. --创建人:Nick
  4332. --说明:获取需要显示的图片
  4333. --#####################################################
  4334. CREATE PROCEDURE [dbo].[ccAdverProjectByProvinceIDSelect]
  4335. (
  4336. @ProvinceID INT,
  4337. @TopNum INT,
  4338. @TypeID INT
  4339. )
  4340. AS
  4341. BEGIN TRY
  4342. DECLARE @SQL VARCHAR(500)
  4343. SET @SQL = 'SELECT TOP '+CONVERT(VARCHAR(4),@TopNum)+' * FROM [MainDb]..[AdverProject] '
  4344. SET @SQL = @SQL + ' WHERE Province_Id = ' + CONVERT(VARCHAR(6),@ProvinceID)
  4345. + ' AND TYPE = ' + CONVERT(VARCHAR(4),@TypeID) + ' AND VALID = 1 '
  4346. SET @SQL = @SQL + ' AND BeginTime <'''+CONVERT(VARCHAR(20),GETDATE()) +''' AND EndTime> ''' + CONVERT(VARCHAR(20),GETDATE()) +''''
  4347. SET @SQL = @SQL + ' ORDER BY OrderBy ASC '
  4348. PRINT(@SQL)
  4349. EXEC(@SQL)
  4350. END TRY
  4351. BEGIN CATCH
  4352. RETURN 0
  4353. END CATCH
  4354. GO
  4355. /****** Object: StoredProcedure [dbo].[ccAssessCpInviteInsert] Script Date: 2018/12/13 19:05:42 ******/
  4356. SET ANSI_NULLS ON
  4357. GO
  4358. SET QUOTED_IDENTIFIER ON
  4359. GO
  4360. --#####################################################
  4361. --创建时间:20181105
  4362. --创建人:Peter
  4363. --插入企业邀请个人测评记录
  4364. --#####################################################
  4365. CREATE PROCEDURE [dbo].[ccAssessCpInviteInsert]
  4366. (
  4367. @caMainID INT,
  4368. @paMainID INT,
  4369. @assessTypeID INT,
  4370. @strEmail VARCHAR(50),
  4371. @strMobile VARCHAR(20),
  4372. @strEndDate SMALLDATETIME,
  4373. @cvMainID INT,
  4374. @paName VARCHAR(20),
  4375. @IP VARCHAR(100)
  4376. )
  4377. AS
  4378. SET NOCOUNT ON
  4379. BEGIN
  4380. DECLARE @OrderID INT
  4381. DECLARE @CpMainID INT
  4382. SELECT @CpMainID = CpMainID
  4383. FROM CaMain WITH(NOLOCK)
  4384. WHERE ID = @caMainID
  4385. SELECT TOP 1 @OrderID = ID
  4386. FROM caOrder WITH(NOLOCK)
  4387. WHERE cpMainID = @CpMainID
  4388. AND RemainAssessReportQuota > 0
  4389. AND BeginDate < GETDATE()
  4390. AND EndDate > GETDATE()
  4391. AND IsDeleted = 0
  4392. IF @OrderID > 0
  4393. BEGIN
  4394. DECLARE @AssessCpInviteID INT
  4395. INSERT INTO AssessCpInvite (CaMainID,PaMainID,AssessTypeID,Email,Mobile,EndDate,AddDate,CvMainID,PaName)
  4396. VALUES(@caMainID,@paMainID,@assessTypeID,@strEmail,@strMobile,@strEndDate,GETDATE(),@cvMainID,@paName)
  4397. SELECT @AssessCpInviteID = SCOPE_IDENTITY()
  4398. UPDATE CaOrder SET RemainAssessReportQuota = RemainAssessReportQuota - 1
  4399. WHERE ID = @OrderID
  4400. DECLARE @RemainQuota INT
  4401. SELECT @RemainQuota = SUM(RemainAssessReportQuota)
  4402. FROM CaOrder WITH(NOLOCK)
  4403. WHERE cpMainID = @CpMainID
  4404. AND RemainAssessReportQuota > 0
  4405. AND BeginDate < GETDATE()
  4406. AND EndDate > GETDATE()
  4407. AND IsDeleted = 0
  4408. INSERT INTO AssessOrderUseLog (CaOrderID,RelateID,RelateType,UseCnt,CaMainID,IP,RemainCnt)
  4409. VALUES(@OrderID,@AssessCpInviteID,2,1,@caMainID,@IP,@RemainQuota)
  4410. RETURN @AssessCpInviteID
  4411. END
  4412. ELSE
  4413. BEGIN
  4414. RETURN -1
  4415. END
  4416. END
  4417. GO
  4418. /****** Object: StoredProcedure [dbo].[ccAssessJobApplyByViewUpdate] Script Date: 2018/12/13 19:05:43 ******/
  4419. SET ANSI_NULLS ON
  4420. GO
  4421. SET QUOTED_IDENTIFIER ON
  4422. GO
  4423. --#####################################################
  4424. --创建时间:20181025
  4425. --创建人:Peter
  4426. --添加企业查看某个人测评报告
  4427. --#####################################################
  4428. CREATE PROCEDURE [dbo].[ccAssessJobApplyByViewUpdate]
  4429. (
  4430. @caMainID INT,
  4431. @cpMainID INT,
  4432. @AssessJobApplyID INT,
  4433. @Ip VARCHAR(100)
  4434. )
  4435. AS
  4436. SET NOCOUNT ON
  4437. BEGIN
  4438. SELECT a.CpViewDate,a.AssessTestLogID,b.CvMainID,LEFT(dbo.GetPersonName(b.cvMainID, @cpMainID), 20) PaName,0 AssessStatus
  4439. INTO #T
  4440. FROM AssessJobApply a WITH(NOLOCK)
  4441. LEFT JOIN ExJobApply b WITH(NOLOCK) ON b.id = a.ExJobApplyID
  4442. LEFT JOIN JobPublish c WITH(NOLOCK) ON c.id = b.JobID
  4443. WHERE a.ID = @AssessJobApplyID
  4444. AND c.CpMainID = @cpMainID
  4445. IF (SELECT COUNT(1) FROM #T) > 0 AND (SELECT CpViewDate FROM #T) IS NULL
  4446. BEGIN
  4447. DECLARE @OrderID INT
  4448. SELECT TOP 1 @OrderID = ID
  4449. FROM caOrder WITH(NOLOCK)
  4450. WHERE cpMainID = @cpMainID
  4451. AND RemainAssessReportQuota > 0
  4452. AND BeginDate < GETDATE()
  4453. AND EndDate > GETDATE()
  4454. AND IsDeleted = 0
  4455. IF @OrderID > 0
  4456. BEGIN
  4457. UPDATE AssessJobApply SET CpViewDate = GETDATE() WHERE ID = @AssessJobApplyID
  4458. UPDATE CaOrder SET RemainAssessReportQuota = RemainAssessReportQuota - 1
  4459. WHERE ID = @OrderID
  4460. DECLARE @RemainQuota INT
  4461. SELECT @RemainQuota = SUM(RemainAssessReportQuota)
  4462. FROM CaOrder WITH(NOLOCK)
  4463. WHERE cpMainID = @cpMainID
  4464. AND RemainAssessReportQuota > 0
  4465. AND BeginDate < GETDATE()
  4466. AND EndDate > GETDATE()
  4467. AND IsDeleted = 0
  4468. INSERT INTO AssessOrderUseLog (CaOrderID,RelateID,RelateType,UseCnt,CaMainID,IP,RemainCnt)
  4469. VALUES(@OrderID,@AssessJobApplyID,1,1,@caMainID,@Ip,@RemainQuota)
  4470. END
  4471. ELSE
  4472. BEGIN
  4473. UPDATE #T SET AssessStatus = 1
  4474. END
  4475. END
  4476. SELECT * FROM #T
  4477. DROP TABLE #T
  4478. END
  4479. GO
  4480. /****** Object: StoredProcedure [dbo].[ccAssessOrderUseLogSelect] Script Date: 2018/12/13 19:05:43 ******/
  4481. SET ANSI_NULLS ON
  4482. GO
  4483. SET QUOTED_IDENTIFIER ON
  4484. GO
  4485. --#####################################################
  4486. --创建时间:20181113
  4487. --创建人:Peter
  4488. --查询测评使用记录
  4489. --#####################################################
  4490. CREATE PROCEDURE [dbo].[ccAssessOrderUseLogSelect]
  4491. (
  4492. @CaOrderID INT,
  4493. @AssessTypeID INT,
  4494. @EventType INT,
  4495. @CpMainID INT
  4496. )
  4497. AS
  4498. SET NOCOUNT ON
  4499. BEGIN
  4500. SELECT a.*,0 AssessTestLogID,CONVERT(VARCHAR(100),'') AssessTypeName,CONVERT(VARCHAR(100),'') PaName,b.Name CaName,0 CvMainID,0 AssessType
  4501. INTO #T
  4502. FROM assessOrderUseLog a WITH(NOLOCK)
  4503. LEFT JOIN caMain b WITH(NOLOCK) ON b.ID = a.CaMainID
  4504. WHERE a.CaOrderID IN(
  4505. SELECT ID
  4506. FROM caOrder WITH(NOLOCK)
  4507. WHERE cpMainID =@CpMainID
  4508. )
  4509. IF @CaOrderID > 0
  4510. BEGIN
  4511. DELETE FROM #T WHERE CaOrderID <> @CaOrderID
  4512. END
  4513. IF(@EventType>0)
  4514. BEGIN
  4515. DELETE FROM #T WHERE RelateType <> @EventType
  4516. END
  4517. UPDATE a
  4518. SET a.AssessTestLogID = b.AssessTestLogID,a.AssessTypeName = d.Name,a.CvMainID = e.cvMainID,a.AssessType = c.AssessTypeID
  4519. FROM #T a,AssessJobApply b WITH(NOLOCK),AssessTestLog c WITH(NOLOCK),AssessType d WITH(NOLOCK),ExJobAPply e WITH(NOLOCK)
  4520. WHERE RelateType = 1
  4521. AND b.id = a.RelateID
  4522. AND c.id = b.AssessTestLogID
  4523. AND d.id = c.AssessTypeID
  4524. AND e.id = b.ExJobApplyID
  4525. UPDATE a
  4526. SET a.PaName = c.PaName,a.AssessTypeName = d.Name,a.CvMainID = c.CvMainID,a.AssessType = c.AssessTypeID
  4527. FROM #T a,AssessTestLog b WITH(NOLOCK),AssessCpInvite c WITH(NOLOCK),AssessType d WITH(NOLOCK)
  4528. WHERE (RelateType = 2 OR RelateType = 3)
  4529. AND c.ID = a.RelateID
  4530. AND d.ID = c.AssessTypeID
  4531. IF @AssessTypeID > 0
  4532. BEGIN
  4533. DELETE FROM #T WHERE AssessType <> @AssessTypeID
  4534. END
  4535. DELETE FROM #T WHERE AssessTypeName IS NULL OR LEN(AssessTypeName) = 0
  4536. UPDATE #T
  4537. SET PaName= dbo.GetPersonName(#T.CvMainID,@CpMainID)
  4538. WHERE PaName IS NULL OR LEN(PaName) = 0
  4539. SELECT * FROM #T
  4540. ORDER BY AddDate DESC
  4541. DROP TABLE #T
  4542. END
  4543. GO
  4544. /****** Object: StoredProcedure [dbo].[ccBsCpModifyVerifyInfoCheckSelect] Script Date: 2018/12/13 19:05:43 ******/
  4545. SET ANSI_NULLS ON
  4546. GO
  4547. SET QUOTED_IDENTIFIER ON
  4548. GO
  4549. --#####################################################
  4550. --创建时间:2014.10.30
  4551. --创建人:Nick
  4552. --说明:用于判断,企业简介
  4553. --#####################################################
  4554. CREATE PROCEDURE [dbo].[ccBsCpModifyVerifyInfoCheckSelect]
  4555. (
  4556. @CpMainID INT
  4557. )
  4558. AS
  4559. BEGIN
  4560. SELECT VerifyInfo
  4561. FROM bsCpModify
  4562. WHERE VerifyInfo > ''
  4563. AND cpMainID = @CpMainID
  4564. AND Location = 'a5'
  4565. END
  4566. GO
  4567. /****** Object: StoredProcedure [dbo].[ccBsCpModifyVerifyInfoSelect] Script Date: 2018/12/13 19:05:43 ******/
  4568. SET ANSI_NULLS ON
  4569. GO
  4570. SET QUOTED_IDENTIFIER ON
  4571. GO
  4572. --#####################################################
  4573. --创建时间:2014.10.30
  4574. --创建人:Nick
  4575. --说明:得到修改信息
  4576. --#####################################################
  4577. CREATE PROCEDURE [dbo].[ccBsCpModifyVerifyInfoSelect]
  4578. (
  4579. @CpMainID INT
  4580. )
  4581. AS
  4582. BEGIN
  4583. SELECT 'x'
  4584. FROM bsCpModify
  4585. WHERE VerifyInfo Is Null
  4586. AND cpMainID = @CpMainID
  4587. END
  4588. GO
  4589. /****** Object: StoredProcedure [dbo].[ccbsCpVerifyByCpMainIDSelect] Script Date: 2018/12/13 19:05:43 ******/
  4590. SET ANSI_NULLS ON
  4591. GO
  4592. SET QUOTED_IDENTIFIER ON
  4593. GO
  4594. --#####################################################
  4595. --创建时间:2014.10.30
  4596. --创建人:Nick
  4597. --说明:获取企业审核信息
  4598. --#####################################################
  4599. CREATE PROCEDURE [dbo].[ccbsCpVerifyByCpMainIDSelect]
  4600. (
  4601. @cpMainID INT
  4602. )
  4603. AS
  4604. BEGIN TRY
  4605. SELECT Top 1 * FROM bsCpVerify WITH(NOLOCK)
  4606. WHERE cpMainID = @cpMainID
  4607. ORDER BY ID DESC
  4608. END TRY
  4609. BEGIN CATCH
  4610. RETURN 0
  4611. END CATCH
  4612. GO
  4613. /****** Object: StoredProcedure [dbo].[ccbsCvModifyByPaMainIDSelect] Script Date: 2018/12/13 19:05:43 ******/
  4614. SET ANSI_NULLS ON
  4615. GO
  4616. SET QUOTED_IDENTIFIER ON
  4617. GO
  4618. -----------------
  4619. --创建日期:2010-9-26
  4620. --创建人:lambo
  4621. --功能说明:根据个人编号和简历编号查询一份简历的审核结果记录
  4622. --用于前台简历显示页面
  4623. -----------------
  4624. CREATE PROCEDURE [dbo].[ccbsCvModifyByPaMainIDSelect]
  4625. (
  4626. @PaMainID INT,
  4627. @cvMainID INT
  4628. )
  4629. AS
  4630. BEGIN
  4631. SELECT SubID,location,VerifyInfo FROM bsCvModify WITH(NOLOCK)
  4632. WHERE VerifyInfo IS NOT NULL AND paMainID=@PaMainID AND cvMainID=@cvMainID AND VerifyInfo <> (
  4633. SELECT TOP 1 VerifyInfo FROM bsCvVerify WHERE paMainID=@PaMainID ORDER BY VerifyDate DESC)
  4634. END
  4635. GO
  4636. /****** Object: StoredProcedure [dbo].[cccaActiveLogByCvMainIDSelect] Script Date: 2018/12/13 19:05:44 ******/
  4637. SET ANSI_NULLS ON
  4638. GO
  4639. SET QUOTED_IDENTIFIER ON
  4640. GO
  4641. --Lambo 20101022
  4642. --查询某单位是否用简历下载点数或者用每日赠送的点数下载过该简历或者是否在申请的记录中不检查权限
  4643. --用于简历显示页面
  4644. CREATE PROCEDURE [dbo].[cccaActiveLogByCvMainIDSelect]
  4645. (
  4646. @cpMainID INT,
  4647. @cvMainID INT
  4648. )
  4649. AS
  4650. SET NOCOUNT ON
  4651. BEGIN
  4652. DECLARE @isInActiveLog INT, @isInDailyGiftLog INT, @paMainID INT
  4653. SELECT @isInDailyGiftLog = COUNT(1)
  4654. FROM caDailyGiftLog WITH(NOLOCK INDEX(PK_caDailyGiftLog))
  4655. WHERE cpMainID = @cpMainID
  4656. AND cvMainID = @cvMainID
  4657. IF @isInDailyGiftLog>0
  4658. RETURN 1
  4659. SELECT @paMainId = paMainId FROM cvMain WITH(NOLOCK) WHERE ID = @cvMainID
  4660. DECLARE @t AS TABLE(ID INT)
  4661. INSERT INTO @t
  4662. SELECT ID FROM cvMain WITH(NOLOCK) WHERE paMainId = @paMainID
  4663. SELECT @isInActiveLog = COUNT(1)
  4664. FROM caActiveLog WITH(NOLOCK INDEX(IX_caActiveLog_cpMainID))
  4665. WHERE cpMainID = @cpMainID
  4666. AND cvMainID IN(SELECT ID FROM @t)
  4667. If @isInActiveLog>0
  4668. RETURN 1
  4669. IF EXISTS (
  4670. SELECT 'x' FROM ExJobApply a WITH(NOLOCK),Job b
  4671. WHERE a.JobID = b.ID
  4672. AND a.IsPassed = 1
  4673. AND a.cvMainID IN(SELECT ID FROM @t)
  4674. AND b.cpMainID = @cpMainID
  4675. )
  4676. RETURN 1
  4677. ELSE
  4678. RETURN 0
  4679. END
  4680. GO
  4681. /****** Object: StoredProcedure [dbo].[ccCaActiveLogInsertNew] Script Date: 2018/12/13 19:05:44 ******/
  4682. SET ANSI_NULLS ON
  4683. GO
  4684. SET QUOTED_IDENTIFIER ON
  4685. GO
  4686. --###################################################3
  4687. --###################################################3
  4688. --创建: sean
  4689. --时间: 2010-11-15
  4690. --查看简历消耗简历下载
  4691. --修改harry 增加简历下载配额 2017-12-12
  4692. --修改harry 2018-5-24 下载记录增加 人名
  4693. --###################################################3
  4694. CREATE PROCEDURE [dbo].[ccCaActiveLogInsertNew]
  4695. (
  4696. @cpMainID INT,
  4697. @caMainID INT,
  4698. @cvMainID INT,
  4699. @IP VARCHAR(31),
  4700. @First TINYINT --first 1, else 2
  4701. )
  4702. AS
  4703. SET NOCOUNT ON
  4704. BEGIN TRAN
  4705. BEGIN TRY
  4706. IF NOT EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK), caMain WITH(NOLOCK) WHERE cpMain.Id = @cpMainID AND caMain.cpMainID = @cpMainID AND cpMain.Valid=1 AND caMain.IsDelete=0 AND caMain.IsPause = 0)
  4707. GOTO Err1
  4708. IF NOT(ISNULL(@cvMainID, 0) < 0 AND @IP = '每月扣除')
  4709. IF NOT EXISTS(SELECT 'x' FROM paMain a WITH(NOLOCK), cvMain b WITH(NOLOCK) WHERE a.ID = b.paMainID AND b.Id = @cvMainID AND (ISNULL(b.Attachment, '')<>'' OR ISNULL(a.Mobile, '')<>''))
  4710. GOTO Err2
  4711. ----取订单信息,计算sun(activequota), SUM(remainquota)
  4712. DECLARE @RemainQuota AS INT
  4713. DECLARE @RemainQuotaALL AS INT
  4714. DECLARE @OrderID AS INT
  4715. DECLARE @MainOrderID AS INT --harry
  4716. DECLARE @IsAllocate AS BIT --harry
  4717. SELECT @RemainQuotaALL = SUM(RemainQuota) FROM caOrder WITH(NOLOCK)
  4718. WHERE cpMainID=@cpMainID AND OpenDate IS NOT NULL
  4719. AND BeginDate < GETDATE() AND EndDate > GETDATE()
  4720. AND RemainQuota > 0
  4721. IF ISNULL(@RemainQuotaALL, 0) < 1
  4722. GOTO Err3
  4723. SELECT TOP 1 @OrderID = ID, @RemainQuota = RemainQuota FROM caOrder WITH(NOLOCK)
  4724. WHERE cpMainID=@cpMainID AND OpenDate IS NOT NULL
  4725. AND BeginDate < GETDATE() AND EndDate > GETDATE()
  4726. AND RemainQuota > 0
  4727. ORDER BY ID
  4728. IF ISNULL(@OrderID, 0) = 0
  4729. GOTO Err4
  4730. --harry begin2017-12-12 简历配额
  4731. SELECT TOP 1 @MainOrderID = ID,@IsAllocate = isCvAllocate FROM caOrder WITH(NOLOCK)
  4732. WHERE cpMainID=@cpMainID AND OpenDate IS NOT NULL
  4733. AND orderType = 8
  4734. AND BeginDate < GETDATE() AND EndDate > GETDATE()
  4735. IF ISNULL(@IsAllocate,0)!=0--分配了配额
  4736. BEGIN
  4737. IF NOT EXISTS(SELECT 'x' FROM quotaLog WHERE CaOrderId = @MainOrderID AND CaMainId=@caMainID AND cpMainID=@cpMainID AND RemainQuota>0)
  4738. BEGIN
  4739. GOTO Err3
  4740. END
  4741. END
  4742. --harry end2017-12-12 简历配额
  4743. DECLARE @Num AS INT
  4744. EXEC @Num = ccActiveDownExist @cpMainID, @cvMainID
  4745. IF @Num = 0
  4746. BEGIN
  4747. DECLARE @paMainID INT, @CaActiveLogID INT, @wxFansId INT, @Mobile VARCHAR(20)
  4748. SELECT @paMainId = paMainId FROM cvMain WITH(NOLOCK) WHERE Id = @cvMainID
  4749. IF @First = 1
  4750. BEGIN
  4751. SELECT @mobile = Mobile FROM paMain WITH(NOLOCK) WHERE Id = @paMainId
  4752. IF @Mobile > ''
  4753. BEGIN
  4754. IF EXISTS(SELECT 'x' FROM CaActiveLog a WITH(NOLOCK), cvMain b WITH(NOLOCK), paMain c WITH(NOLOCK)
  4755. WHERE a.cpMainId = @cpMainId
  4756. AND a.cvMainId = b.Id
  4757. AND b.paMAinId = c.Id
  4758. AND c.Mobile = @Mobile
  4759. AND c.Id <> @paMainId)
  4760. GOTO Err6
  4761. END
  4762. END
  4763. SET @RemainQuota = @RemainQuota - 1
  4764. SET @RemainQuotaALL = @RemainQuotaALL - 1
  4765. DECLARE @name VARCHAR(20)
  4766. select @name=name from pamain where id=(select paMainID from cvmain where id=@cvMainID)
  4767. INSERT INTO CaActiveLog(cpMainID, caMainID, cvMainID, caOrderID, IP, RemainQuota,paName)
  4768. VALUES(@cpMainID, @caMainID, @cvMainID, @OrderID, @IP, @RemainQuota,@name)
  4769. --harry begin2017-12-12 简历配额
  4770. IF ISNULL(@IsAllocate,0)!=0--分配了配额
  4771. BEGIN
  4772. UPDATE quotalog SET RemainQuota = RemainQuota -1 WHERE CaOrderId = @MainOrderID AND CaMainId=@caMainID AND cpMainID=@cpMainID AND RemainQuota>0
  4773. END
  4774. --harry end2017-12-12 简历配额
  4775. --Harry Begin
  4776. SELECT @CaActiveLogID = @@IDENTITY
  4777. UPDATE caOrder SET RemainQuota = RemainQuota - 1 WHERE ID = @OrderID
  4778. SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainId AND [Status] = 2
  4779. IF @wxFansId > 0
  4780. BEGIN
  4781. --插入到wxMessageSend表中
  4782. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, CaMainId, AddDate)
  4783. SELECT 6, @wxFansId, @paMainId, @CaActiveLogID, @cpMainId, @cvMainID, @caMainID, GETDATE()
  4784. END
  4785. --Harry End
  4786. END
  4787. END TRY
  4788. BEGIN CATCH
  4789. PRINT error_message()
  4790. GOTO Err5
  4791. END CATCH
  4792. COMMIT
  4793. RETURN @RemainQuotaALL
  4794. Err:
  4795. BEGIN
  4796. ROLLBACK TRAN
  4797. RETURN 0
  4798. END
  4799. ----企业账号信息不正确
  4800. Err1:
  4801. BEGIN
  4802. ROLLBACK TRAN
  4803. RETURN -1
  4804. END
  4805. ----简历id是无效简历id
  4806. Err2:
  4807. BEGIN
  4808. ROLLBACK TRAN
  4809. RETURN -2
  4810. END
  4811. ----剩余点数RemainQuota 不足1
  4812. Err3:
  4813. BEGIN
  4814. ROLLBACK TRAN
  4815. RETURN -3
  4816. END
  4817. ----无订单号
  4818. Err4:
  4819. BEGIN
  4820. ROLLBACK TRAN
  4821. RETURN -4
  4822. END
  4823. ----其他错误
  4824. Err5:
  4825. BEGIN
  4826. ROLLBACK TRAN
  4827. RETURN -5
  4828. END
  4829. ----有手机号重复 提醒是否下载
  4830. Err6:
  4831. BEGIN
  4832. ROLLBACK TRAN
  4833. RETURN -6
  4834. END
  4835. GO
  4836. /****** Object: StoredProcedure [dbo].[cccaActiveLogSelect] Script Date: 2018/12/13 19:05:44 ******/
  4837. SET ANSI_NULLS ON
  4838. GO
  4839. SET QUOTED_IDENTIFIER ON
  4840. GO
  4841. --修改harry 2018-5-24
  4842. --增加cv secondid
  4843. CREATE PROCEDURE [dbo].[cccaActiveLogSelect]
  4844. (
  4845. @cpMainID INT,
  4846. @WHERE VARCHAR(1000),
  4847. @ORDER VARCHAR(100)
  4848. )
  4849. AS
  4850. BEGIN
  4851. SET @Where = dbo.SafeSql(@Where)
  4852. SET @ORDER = dbo.SafeSQLBack(@ORDER)
  4853. DECLARE @SQL AS VARCHAR(2000)
  4854. SET @SQL = 'SELECT a.*, b.Name, c.paMainID, c.SecondId
  4855. FROM caActiveLog a WITH(NOLOCK)
  4856. LEFT JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  4857. LEFT JOIN cvMain c WITH(NOLOCK) ON a.cvMainId = c.Id
  4858. WHERE a.caOrderID IN(SELECT ID FROM caOrder WHERE cpMainID=' + RTRIM(STR(@cpMainID)) + 'AND IsDeleted=0) AND a.cpMainID=' + RTRIM(STR(@cpMainID))
  4859. IF LEN(@WHERE) > 0
  4860. SET @SQL = @SQL + ' ' + @WHERE
  4861. IF LEN(@ORDER) > 0
  4862. SET @SQL = @SQL + '
  4863. ORDER BY ' + @ORDER
  4864. ELSE
  4865. SET @SQL = @SQL + '
  4866. ORDER BY a.caOrderID DESC,a.RemainQuota'
  4867. EXEC(@SQL)
  4868. END
  4869. GO
  4870. /****** Object: StoredProcedure [dbo].[cccaAssessCpInviteSelect] Script Date: 2018/12/13 19:05:44 ******/
  4871. SET ANSI_NULLS ON
  4872. GO
  4873. SET QUOTED_IDENTIFIER ON
  4874. GO
  4875. --#####################################################
  4876. --创建时间:20181022
  4877. --创建人:Peter
  4878. --查询企业邀请个人测评记录
  4879. --#####################################################
  4880. CREATE PROCEDURE [dbo].[cccaAssessCpInviteSelect]
  4881. (
  4882. @WHERE VARCHAR(1000),
  4883. @Order VARCHAR(100),
  4884. @Page SMALLINT,
  4885. @cpMainID INT,
  4886. @caMainID INT
  4887. )
  4888. AS
  4889. SET NOCOUNT ON
  4890. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE Id = @caMainId AND cpMainId = @cpMainId)
  4891. RETURN
  4892. BEGIN
  4893. SELECT @Where = dbo.SafeSql(@Where), @ORDER = dbo.SafeSql(@Order)
  4894. DECLARE @SQL AS VARCHAR(2000)
  4895. CREATE TABLE #T(
  4896. TitleID BIGINT,
  4897. ID INT,
  4898. cvMainID INT,
  4899. Degree TINYINT,
  4900. RelatedWorkYears TINYINT,
  4901. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  4902. IsNameHidden BIT,
  4903. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
  4904. Gender BIT,
  4905. paName NVARCHAR(20),
  4906. BirthDay INT,
  4907. HasPhoto TINYINT,
  4908. adddate SMALLDATETIME,
  4909. Valid TINYINT,
  4910. IsViewed BIT,
  4911. cvEducationID INT,
  4912. College NVARCHAR(50),
  4913. EduType TINYINT,
  4914. MajorName NVARCHAR(20),
  4915. Graduation INT,
  4916. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  4917. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  4918. MobileVerifyDate SMALLDATETIME,
  4919. IsOnline BIT,
  4920. HasWeiXin BIT,
  4921. paMainId INT,
  4922. SecondId VARCHAR(10),
  4923. Mobile VARCHAR(15),
  4924. Email VARCHAR(100),
  4925. ContactPrivi BIT,
  4926. AssessTypeID INT,
  4927. AssessTypeName NVARCHAR(50),
  4928. AssessEndDate SMALLDATETIME,
  4929. AssessAddDate SMALLDATETIME,
  4930. AssessStatus TINYINT,
  4931. AssessTestLogID INT,
  4932. IsOutSite BIT
  4933. )
  4934. --ca的类型: 1 管理员 2 普通用户
  4935. DECLARE @AccountType AS TINYINT
  4936. SELECT @AccountType = AccountType FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  4937. SET @SQL='
  4938. INSERT INTO #T(
  4939. TitleID, ID, cvMainID, Degree, RelatedWorkYears,
  4940. Attachment, IsNameHidden, LivePlace, Gender, paName, BirthDay, HasPhoto, adddate,
  4941. Valid, MobileVerifyDate, IsOnline, paMainId, SecondId,AssessTypeID,
  4942. AssessTypeName,AssessAddDate,AssessEndDate,AssessStatus,AssessTestLogID,IsOutSite
  4943. )
  4944. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
  4945. a.ID, a.cvMainID,
  4946. b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden,
  4947. c.LivePlace, c.Gender, c.Name AS paName, c.BirthDay, c.HasPhoto,
  4948. a.adddate, b.Valid, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID),
  4949. b.paMainId, b.SecondId,
  4950. a.AssessTypeID,e.Name,a.AddDate,a.EndDate,f.status,f.id,0
  4951. FROM AssessCpInvite a WITH(NOLOCK)
  4952. LEFT JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  4953. LEFT JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  4954. LEFT JOIN AssessType e WITH(NOLOCK) ON e.id = a.AssessTypeID
  4955. LEFT JOIN AssessTestLog f WITH(NOLOCK) ON f.AssessCpInviteID = a.ID
  4956. WHERE 1 = 1'
  4957. --add by mice 123 ca中的管理员可以查看子账号收藏的简历
  4958. IF @AccountType = 1
  4959. BEGIN
  4960. SET @SQL = @SQL + ' AND a.caMainID IN ( SELECT ID FROM caMain WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + ' AND IsDelete = 0 AND IsPause = 0 ) '
  4961. END
  4962. ELSE
  4963. BEGIN
  4964. SET @SQL = @SQL + ' AND a.caMainID = ' + LTRIM(STR(@caMainID)) + ''
  4965. END
  4966. IF LEN(@WHERE) > 0
  4967. SET @SQL = @SQL + @WHERE
  4968. --PRINT @sql
  4969. EXEC(@SQL)
  4970. IF(@Page < 1)
  4971. SET @Page = 1
  4972. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  4973. SET @Page = 1
  4974. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20),
  4975. IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID)
  4976. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  4977. UPDATE #T SET Speciality = (
  4978. SELECT Speciality FROM cvMain WITH(NOLOCK)
  4979. WHERE cvMain.ID = #T.cvMainID)
  4980. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  4981. UPDATE #T SET Experience = (
  4982. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  4983. WHERE cvExperience.cvMainID = #T.cvMainID
  4984. ORDER BY BeginDate DESC)
  4985. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  4986. UPDATE #T SET cvEducationID = (
  4987. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  4988. WHERE cvEducation.cvMainID = #T.cvMainID
  4989. AND #T.Degree = cvEducation.Degree
  4990. ORDER BY Graduation DESC)
  4991. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  4992. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  4993. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  4994. FROM #T a, cvEducation b WITH(NOLOCK)
  4995. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  4996. UPDATE a SET Email = b.Email,Mobile = b.Mobile,ContactPrivi = dbo.CheckCvPrivi(a.cvMainID,@cpMainID)
  4997. FROM #T a,PaMain b WITH(NOLOCK)
  4998. WHERE b.id = a.paMainID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  4999. UPDATE a SET a.Email = b.Email,a.paName=b.PaName,a.Mobile = b.Mobile ,IsOutSite = 1
  5000. FROM #T a,AssessCpInvite b WITH(NOLOCK)
  5001. WHERE b.id = a.ID
  5002. AND a.TitleID > (@Page-1)*20
  5003. AND a. TitleID <= @Page*20
  5004. AND LEN(b.PaName) > 0
  5005. --修改是否绑定微信
  5006. UPDATE a SET HasWeiXin = 1
  5007. FROM #T a, WxFans b WITH(NOLOCK), CvMain c WITH(NOLOCK)
  5008. WHERE a.CvMainID = c.ID
  5009. AND c.PaMainID = b.PaMainID
  5010. AND b.Status = 2
  5011. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5012. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  5013. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5014. DROP TABLE #T
  5015. END
  5016. GO
  5017. /****** Object: StoredProcedure [dbo].[ccCaBalanceLogByCvMainIDSelect] Script Date: 2018/12/13 19:05:45 ******/
  5018. SET ANSI_NULLS ON
  5019. GO
  5020. SET QUOTED_IDENTIFIER ON
  5021. GO
  5022. CREATE PROCEDURE [dbo].[ccCaBalanceLogByCvMainIDSelect]
  5023. (
  5024. @cpMainID INT,
  5025. @cvMainID INT
  5026. )
  5027. AS
  5028. BEGIN
  5029. IF EXISTS(
  5030. SELECT 'x' FROM caBalanceLog WITH(NOLOCK)
  5031. WHERE cpMainID = @cpMainID
  5032. AND cvMainID = @cvMainID
  5033. AND CONVERT(VARCHAR(10), AddDate, 120) = CONVERT(VARCHAR(10), GETDATE(), 120)
  5034. )
  5035. RETURN 1
  5036. ELSE
  5037. RETURN 0
  5038. END
  5039. GO
  5040. /****** Object: StoredProcedure [dbo].[ccCaBalanceLogInsert] Script Date: 2018/12/13 19:05:45 ******/
  5041. SET ANSI_NULLS ON
  5042. GO
  5043. SET QUOTED_IDENTIFIER ON
  5044. GO
  5045. CREATE PROCEDURE [dbo].[ccCaBalanceLogInsert]
  5046. (
  5047. @cpMainID INT,
  5048. @caMainID INT,
  5049. @cvMainID INT=NULL,
  5050. @IsAgent BIT,
  5051. @ReduceMoney INT,
  5052. @IP VARCHAR(30),
  5053. @BalanceType TINYINT
  5054. )
  5055. AS
  5056. BEGIN TRAN
  5057. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID)
  5058. GOTO Err
  5059. BEGIN TRY
  5060. DECLARE @Balance AS INT
  5061. DECLARE @IsPaid AS INT
  5062. EXEC @IsPaid = ccCaBalanceLogByCvMainIDSELECT @cpMainID, @cvMainID
  5063. IF @IsPaid != 1
  5064. BEGIN
  5065. SELECT @Balance=Balance FROM cpMain WHERE ID = @cpMainID
  5066. IF @Balance >0 --@ReduceMoney
  5067. BEGIN
  5068. SET @Balance = @Balance - @ReduceMoney
  5069. INSERT INTO caBalanceLog(cpMainID,caMainID,cvMainID,IsAgent,ReduceMoney,Balance,IP,BalanceType)
  5070. VALUES(@cpMainID,@caMainID,@cvMainID,@IsAgent,@ReduceMoney,@Balance,@IP,@BalanceType)
  5071. UPDATE cpMain SET balance = @balance WHERE ID = @cpMainID
  5072. IF @Balance<1
  5073. BEGIN
  5074. SET @Balance = 0
  5075. UPDATE cpMain SET balance = 0 WHERE ID = @cpMainID
  5076. END
  5077. END
  5078. ELSE
  5079. GOTO ERR1
  5080. END
  5081. END TRY
  5082. BEGIN CATCH
  5083. GOTO ERR
  5084. END CATCH
  5085. COMMIT
  5086. RETURN @Balance
  5087. ERR:
  5088. BEGIN
  5089. ROLLBACK TRAN
  5090. RETURN -10
  5091. END
  5092. ERR1:
  5093. BEGIN
  5094. ROLLBACK TRAN
  5095. RETURN -11
  5096. END
  5097. ----简历id是无效简历id
  5098. ERR2:
  5099. BEGIN
  5100. ROLLBACK TRAN
  5101. RETURN -2
  5102. END
  5103. GO
  5104. /****** Object: StoredProcedure [dbo].[cccaBalanceLogSelect] Script Date: 2018/12/13 19:05:45 ******/
  5105. SET ANSI_NULLS ON
  5106. GO
  5107. SET QUOTED_IDENTIFIER ON
  5108. GO
  5109. --修改人 Lucifer
  5110. --修改时间 2013-11-7
  5111. --修改原因 添加手机认证时间
  5112. CREATE PROCEDURE [dbo].[cccaBalanceLogSelect]
  5113. (
  5114. @cpMainID INT,
  5115. @WHERE VARCHAR(1000),
  5116. @ORDER VARCHAR(100),
  5117. @Page SMALLINT,
  5118. @caMainID INT
  5119. )
  5120. AS
  5121. BEGIN
  5122. BEGIN TRY
  5123. SET @Where = dbo.SafeSql(@Where)
  5124. SET @ORDER = dbo.SafeSql(@Order)
  5125. DECLARE @SQL VARCHAR(2000)
  5126. CREATE TABLE #T(
  5127. TitleID BIGINT,
  5128. cvMainID INT,
  5129. ReduceMoney INT,
  5130. Balance INT,
  5131. BalanceType TINYINT,
  5132. IP VARCHAR(39) COLLATE Chinese_PRC_CI_AS NOT NULL,
  5133. Degree TINYINT,
  5134. RelatedWorkYears TINYINT,
  5135. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS ,
  5136. IsNameHidden BIT,
  5137. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS ,
  5138. Gender BIT,
  5139. paName NVARCHAR(12),
  5140. BirthDay INT,
  5141. HasPhoto TINYINT,
  5142. AddDate SMALLDATETIME,
  5143. Valid TINYINT,
  5144. HasJobApply BIT,
  5145. HasInterview BIT,
  5146. HasRemark BIT,
  5147. HasFavorate BIT,
  5148. MobileVerifyDate SMALLDATETIME
  5149. )
  5150. SET @SQL='
  5151. INSERT INTO #T(TitleID,cvMainID,ReduceMoney,Balance,BalanceType,IP,AddDate,Degree,RelatedWorkYears,
  5152. Attachment,IsNameHidden,LivePlace,Gender,paName,BirthDay,HasPhoto,Valid,MobileVerifyDate)
  5153. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
  5154. a.cvMainID,a.ReduceMoney,Balance,BalanceType,IP,a.AddDate,
  5155. b.Degree,b.RelatedWorkYears,b.Attachment,b.IsNameHidden,
  5156. c.LivePlace,c.Gender,c.Name AS paName,c.BirthDay,c.HasPhoto,b.Valid,c.MobileVerifyDate
  5157. FROM caBalanceLog a WITH(NOLOCK)
  5158. LEFT JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  5159. LEFT JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID'
  5160. IF LEN(@WHERE) > 0
  5161. SET @SQL = @SQL + ' WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + @WHERE
  5162. --PRINT @SQL
  5163. EXEC(@SQL)
  5164. UPDATE #T SET paName = dbo.JobApplyName(IsNameHidden, paName, Gender),
  5165. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  5166. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  5167. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  5168. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  5169. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5170. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  5171. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5172. DROP TABLE #T
  5173. END TRY
  5174. BEGIN CATCH
  5175. DROP TABLE #T
  5176. END CATCH
  5177. END
  5178. GO
  5179. /****** Object: StoredProcedure [dbo].[ccCaContactByCaMainIDSelect] Script Date: 2018/12/13 19:05:46 ******/
  5180. SET ANSI_NULLS ON
  5181. GO
  5182. SET QUOTED_IDENTIFIER ON
  5183. GO
  5184. --#####################################################
  5185. --创建时间:2014.11.7
  5186. --创建人:John
  5187. --说明:根据参数从caContact表中查询20minutes内有没有提交过
  5188. --修改: Mice 123 2015-3-11 修改联系时间为20分钟
  5189. --#####################################################
  5190. CREATE PROCEDURE [dbo].[ccCaContactByCaMainIDSelect]
  5191. (
  5192. @caMainID INT
  5193. )
  5194. AS
  5195. BEGIN
  5196. SELECT TOP 1 'x' FROM CaContact WITH(NOLOCK) WHERE camainid = @caMainID AND adddate > DATEADD(mi,-20,GETDATE())
  5197. END
  5198. GO
  5199. /****** Object: StoredProcedure [dbo].[ccCaContactInsert] Script Date: 2018/12/13 19:05:46 ******/
  5200. SET ANSI_NULLS ON
  5201. GO
  5202. SET QUOTED_IDENTIFIER ON
  5203. GO
  5204. --#####################################################
  5205. --创建时间:2014.10.30
  5206. --创建人:Nick
  5207. --说明://保存客户要求回电记录
  5208. --#####################################################
  5209. CREATE PROCEDURE [dbo].[ccCaContactInsert]
  5210. (
  5211. @caMainID INT,
  5212. @cpMainid INT,
  5213. @telephone VARCHAR(20),
  5214. @name VARCHAR(20)
  5215. )
  5216. AS
  5217. SET NOCOUNT ON
  5218. BEGIN
  5219. IF EXISTS(SELECT 'x' FROM CaContact WITH(NOLOCK) WHERE caMainId = @caMainId AND AddDate > DATEADD(MINUTE, -2, GETDATE()))
  5220. RETURN 0
  5221. INSERT INTO CaContact(camainid, cpmainid, telephone, name)
  5222. VALUES(@caMainID, @cpMainid, @telephone, @name)
  5223. RETURN 1
  5224. END
  5225. GO
  5226. /****** Object: StoredProcedure [dbo].[cccaCvActionsSelect] Script Date: 2018/12/13 19:05:46 ******/
  5227. SET ANSI_NULLS ON
  5228. GO
  5229. SET QUOTED_IDENTIFIER ON
  5230. GO
  5231. --########################333
  5232. --该存储过程的安全验证在asp文件中进行
  5233. --########################333
  5234. CREATE PROCEDURE [dbo].[cccaCvActionsSelect]
  5235. (
  5236. @cvMainID INT,
  5237. @caMainID INT,
  5238. @HasJobApply INT OUT,
  5239. @HasInterview INT OUT,
  5240. @HasRemark INT OUT,
  5241. @HasFavorate INT OUT
  5242. )
  5243. AS
  5244. BEGIN
  5245. IF EXISTS(SELECT a.ID FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE b.caMainID=@caMainID AND cvMainID=@cvMainID)
  5246. SET @HasJobApply = 1
  5247. ELSE
  5248. SET @HasJobApply = 0
  5249. IF EXISTS(SELECT a.ID FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE b.caMainID=@caMainID AND cvMainID=@cvMainID)
  5250. SET @HasInterview = 1
  5251. ELSE
  5252. SET @HasInterview = 0
  5253. IF EXISTS(SELECT ID FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=@cvMainID)
  5254. SET @HasRemark = 1
  5255. ELSE
  5256. SET @HasRemark = 0
  5257. IF EXISTS(SELECT a.ID FROM caFavorate a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE b.caMainID=@caMainID AND cvMainID=@cvMainID)
  5258. SET @HasFavorate = 1
  5259. ELSE
  5260. SET @HasFavorate = 0
  5261. END
  5262. GO
  5263. /****** Object: StoredProcedure [dbo].[ccCaCvApplyDeletedSelect] Script Date: 2018/12/13 19:05:46 ******/
  5264. SET ANSI_NULLS ON
  5265. GO
  5266. SET QUOTED_IDENTIFIER ON
  5267. GO
  5268. --lambo 20140428
  5269. --查询企业删除的应聘的简历
  5270. --修改:Andy 2015-01-13 添加职位的regionid
  5271. CREATE PROCEDURE [dbo].[ccCaCvApplyDeletedSelect] --'', 'a.adddate', 1, 234434
  5272. (
  5273. @WHERE VARCHAR(1000),
  5274. @Order VARCHAR(100),
  5275. @Page SMALLINT,
  5276. @caMainID INT
  5277. )
  5278. AS
  5279. SET NOCOUNT ON
  5280. BEGIN
  5281. SET @Where = dbo.SafeSql(@Where)
  5282. SET @ORDER = dbo.SafeSql(@Order)
  5283. DECLARE @SQL AS VARCHAR(2000)
  5284. CREATE TABLE #T(
  5285. TitleID BIGINT,
  5286. ID INT,
  5287. JobID INT,
  5288. jobRegionID INT,
  5289. JobName NVARCHAR(50),
  5290. paMainID INT,
  5291. cvMainID INT,
  5292. AddDate SMALLDATETIME,
  5293. ApplyDate SMALLDATETIME,
  5294. Reply TINYINT,
  5295. Degree TINYINT,
  5296. RelatedWorkYears TINYINT,
  5297. LivePlace NVARCHAR(50),
  5298. Gender BIT,
  5299. paName NVARCHAR(20),
  5300. BirthDay INT,
  5301. HasPhoto TINYINT,
  5302. Attachment VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  5303. IsNameHidden BIT,
  5304. Valid TINYINT,
  5305. IsViewed BIT,
  5306. HasInterview BIT,
  5307. HasRemark BIT,
  5308. HasFavorate BIT,
  5309. cvEducationID INT,
  5310. College NVARCHAR(100),
  5311. EduType TINYINT,
  5312. MajorName NVARCHAR(50),
  5313. Graduation INT,
  5314. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  5315. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  5316. MobileVerifyDate SMALLDATETIME,
  5317. HasWeiXin BIT,
  5318. cvDeleted BIT,
  5319. JobDeleted BIT,
  5320. SecondId VARCHAR(10)
  5321. )
  5322. SET @SQL='
  5323. INSERT INTO #T
  5324. (TitleID, ID, JobID, jobRegionID, JobName, paMainID, cvMainID, AddDate, ApplyDate , Reply,
  5325. Degree, RelatedWorkYears, Attachment, IsNameHidden, LivePlace, Gender,
  5326. BirthDay, HasPhoto, Valid, MobileVerifyDate, cvDeleted, JobDeleted, SecondId)
  5327. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.ID, a.JobID, d.dcRegionID,
  5328. a.JobName, c.ID, a.cvMainID, a.AddDate, ApplyDate, a.Reply,
  5329. b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden, c.LivePlace,
  5330. c.Gender, c.BirthDay, c.HasPhoto, b.Valid, c.MobileVerifyDate, cvDeleted, JobDeleted, b.SecondId
  5331. FROM CaCvApplyDeleted a WITH(NOLOCK)
  5332. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  5333. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  5334. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  5335. WHERE 1=1 '
  5336. IF LEN(@WHERE) > 0
  5337. SET @SQL = @SQL + ' AND '+@WHERE
  5338. --PRINT @SQL
  5339. EXEC(@SQL)
  5340. IF(@Page < 1)
  5341. SET @Page = 1
  5342. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  5343. SET @Page = 1
  5344. DECLARE @cpMainID AS INT
  5345. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  5346. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20), IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  5347. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  5348. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  5349. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  5350. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5351. UPDATE #T SET Speciality = (
  5352. SELECT Speciality FROM cvMain WITH(NOLOCK)
  5353. WHERE cvMain.ID = #T.cvMainID)
  5354. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5355. UPDATE #T SET Experience = (
  5356. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  5357. WHERE cvExperience.cvMainID = #T.cvMainID
  5358. ORDER BY BeginDate DESC)
  5359. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5360. UPDATE #T SET cvEducationID = (
  5361. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  5362. WHERE cvEducation.cvMainID = #T.cvMainID
  5363. AND #T.Degree = cvEducation.Degree
  5364. ORDER BY Graduation DESC)
  5365. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5366. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  5367. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  5368. FROM #T a, cvEducation b WITH(NOLOCK)
  5369. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  5370. --修改是否绑定微信
  5371. UPDATE a SET HasWeiXin = 1
  5372. FROM #T a, WxFans b WITH(NOLOCK)
  5373. WHERE a.paMainID = b.PaMainID
  5374. AND b.Status = 2
  5375. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5376. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  5377. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5378. DROP TABLE #T
  5379. END
  5380. GO
  5381. /****** Object: StoredProcedure [dbo].[ccCaCvContackLogByCvViewSelect] Script Date: 2018/12/13 19:05:46 ******/
  5382. SET ANSI_NULLS ON
  5383. GO
  5384. SET QUOTED_IDENTIFIER ON
  5385. GO
  5386. --######################333
  5387. --@caMainID取自Session,caMainID = ca.caMainID cvview.asp line 202
  5388. --######################333
  5389. CREATE PROCEDURE [dbo].[ccCaCvContackLogByCvViewSelect]
  5390. (
  5391. @caMainID INT,
  5392. @cvMainID INT
  5393. )
  5394. AS
  5395. BEGIN
  5396. --查询最近2个月的申请记录
  5397. SELECT TOP 1 a.ID,a.AddDate,a.Reply,b.ID JobID,b.Name
  5398. FROM exJobApply a WITH(NOLOCK)
  5399. INNER JOIN Job b WITH(NOLOCK)
  5400. ON a.JobId = b.Id
  5401. WHERE a.cvMainId =@cvMainID
  5402. AND b.caMainID = @caMainID
  5403. --AND a.AddDate > DATEADD(MONTH, -2, GETDATE())
  5404. ORDER BY a.ID DESC
  5405. --查询最近3个月的发送面试通知记录
  5406. SELECT TOP 1 a.AddDate,b.ID,b.Name
  5407. FROM ExInterview a WITH(NOLOCK)
  5408. INNER JOIN Job b WITH(NOLOCK)
  5409. ON a.JobId = b.Id
  5410. WHERE a.cvMainId =@cvMainID
  5411. AND b.caMainID = @caMainID
  5412. AND a.AddDate > DATEADD(MONTH, -3, GETDATE())
  5413. ORDER BY a.ID DESC
  5414. --查询收藏记录
  5415. SELECT TOP 1 a.AddDate,b.ID,b.Name
  5416. FROM caFavorate a WITH(NOLOCK)
  5417. INNER JOIN Job b WITH(NOLOCK)
  5418. ON a.JobId = b.Id
  5419. WHERE a.cvMainId =@cvMainID
  5420. AND b.caMainID = @caMainID
  5421. ORDER BY a.ID DESC
  5422. --查询2周内浏览简历记录
  5423. SELECT TOP 1 AddDate
  5424. FROM CaCvViewLog a WITH(NOLOCK)
  5425. WHERE caMainID = @caMainID
  5426. AND cvMainID = @cvMainID
  5427. AND AddDate>DATEADD(DAY,-14,GETDATE())
  5428. END
  5429. GO
  5430. /****** Object: StoredProcedure [dbo].[cccaCvFinderBycaMainIDSelect] Script Date: 2018/12/13 19:05:46 ******/
  5431. SET ANSI_NULLS ON
  5432. GO
  5433. SET QUOTED_IDENTIFIER ON
  5434. GO
  5435. --#########################33333
  5436. --@caMainID 取自Session caCvFinder.GetList(ca.caMainID)
  5437. --#########################33333
  5438. CREATE PROCEDURE [dbo].[cccaCvFinderBycaMainIDSelect]
  5439. (
  5440. @caMainID INT
  5441. )
  5442. AS
  5443. BEGIN
  5444. SELECT * FROM caCvFinder WHERE caMainID = @caMainID
  5445. END
  5446. GO
  5447. /****** Object: StoredProcedure [dbo].[cccaCvFinderDelete] Script Date: 2018/12/13 19:05:47 ******/
  5448. SET ANSI_NULLS ON
  5449. GO
  5450. SET QUOTED_IDENTIFIER ON
  5451. GO
  5452. ----##########################################
  5453. ----@caMainID 取自Session
  5454. ----caCvFinder.ID = co.reqS("ID", 0)
  5455. ----caCvFinder.caMainID = ca.caMainID
  5456. ----##########################################
  5457. CREATE PROCEDURE [dbo].[cccaCvFinderDelete]
  5458. (
  5459. @ID INT,
  5460. @caMainID INT
  5461. )
  5462. AS
  5463. BEGIN
  5464. DELETE FROM caCvFinder WHERE ID = @ID AND caMainID = @caMainID
  5465. END
  5466. GO
  5467. /****** Object: StoredProcedure [dbo].[cccaCvFinderSave] Script Date: 2018/12/13 19:05:47 ******/
  5468. SET ANSI_NULLS ON
  5469. GO
  5470. SET QUOTED_IDENTIFIER ON
  5471. GO
  5472. CREATE PROCEDURE [dbo].[cccaCvFinderSave]
  5473. (
  5474. @ID INT,
  5475. @caMainID INT,
  5476. @Name VARCHAR(50),
  5477. @dcJobTypeID VARCHAR(50),
  5478. @dcRegionID VARCHAR(50),
  5479. @dcIndustryID VARCHAR(50),
  5480. @dcSalaryID INT,
  5481. @dcJobTypeIDOld VARCHAR(50),
  5482. @dcIndustryIDOld VARCHAR(50),
  5483. @MinExperience TINYINT,
  5484. @KeyWord VARCHAR(50),
  5485. @SubNodeNum TINYINT,
  5486. @Education VARCHAR(50),
  5487. @Standard BIT,
  5488. @EducationName VARCHAR(200),
  5489. @dcMajorID VARCHAR(50),
  5490. @Graduation VARCHAR(50),
  5491. @LanguageType VARCHAR(50),
  5492. @Gender TINYINT,
  5493. @MinAge TINYINT,
  5494. @MaxAge TINYINT,
  5495. @MinHeight TINYINT,
  5496. @MaxHeight TINYINT,
  5497. @LivePlace VARCHAR(50),
  5498. @AccountPlace VARCHAR(50),
  5499. @MobilePlace VARCHAR(50),
  5500. @cvMainID INT,
  5501. @IsNegotiable BIT,
  5502. @IncludeOld BIT,
  5503. @IsExpand BIT,
  5504. @SortType TINYINT,
  5505. @EmployType TINYINT
  5506. )
  5507. AS
  5508. DECLARE @MaxId AS INT
  5509. BEGIN TRY
  5510. IF @ID=0
  5511. SELECT @ID=ID FROM caCvFinder WITH(NOLOCK) WHERE NAME = @Name AND caMainID = @caMainID
  5512. IF @ID>0
  5513. BEGIN
  5514. UPDATE caCvFinder SET
  5515. Name=@Name,
  5516. dcJobTypeID=@dcJobTypeID,
  5517. dcRegionID=@dcRegionID,
  5518. dcIndustryID=@dcIndustryID,
  5519. dcSalaryID=@dcSalaryID,
  5520. dcJobTypeIDOld=@dcJobTypeIDOld,
  5521. dcIndustryIDOld=@dcIndustryIDOld,
  5522. MinExperience=@MinExperience,
  5523. KeyWord=@KeyWord,
  5524. SubNodeNum=@SubNodeNum,
  5525. Education=@Education,
  5526. Standard=@Standard,
  5527. EducationName=@EducationName,
  5528. dcMajorID=@dcMajorID,
  5529. Graduation=@Graduation,
  5530. LanguageType=@LanguageType,
  5531. Gender=@Gender,
  5532. MinAge=@MinAge,
  5533. MaxAge=@MaxAge,
  5534. MinHeight=@MinHeight,
  5535. MaxHeight=@MaxHeight,
  5536. LivePlace=@LivePlace,
  5537. AccountPlace=@AccountPlace,
  5538. MobilePlace = @MobilePlace,
  5539. cvMainID=@cvMainID,
  5540. IsNegotiable=@IsNegotiable,
  5541. IncludeOld=@IncludeOld,
  5542. IsExpand=@IsExpand,
  5543. SortType=@SortType,
  5544. EmployType=@EmployType
  5545. WHERE ID=@ID
  5546. SET @MaxID=@ID
  5547. END
  5548. ELSE
  5549. BEGIN
  5550. DECLARE @FinderCount AS TINYINT
  5551. SELECT @FinderCount=COUNT(ID) FROM caCvFinder WITH(NOLOCK) WHERE caMainID=@caMainID
  5552. IF @FinderCount < 20
  5553. BEGIN
  5554. INSERT INTO caCvFinder
  5555. (caMainID,Name,dcJobTypeID,dcRegionID,dcIndustryID,dcSalaryID,dcJobTypeIDOld,dcIndustryIDOld,MinExperience,
  5556. KeyWord,SubNodeNum,Education,Standard,EducationName,dcMajorID,Graduation,SortType,
  5557. LanguageType,Gender,MinAge,MaxAge,MinHeight,MaxHeight,LivePlace,AccountPlace,MobilePlace,cvMainID,IsNegotiable,IncludeOld,IsExpand,EmployType)
  5558. VALUES
  5559. (@caMainID,@Name,@dcJobTypeID,@dcRegionID,@dcIndustryID,@dcSalaryID,@dcJobTypeIDOld,@dcIndustryIDOld,@MinExperience,
  5560. @KeyWord,@SubNodeNum,@Education,@Standard,@EducationName,@dcMajorID,@Graduation,@SortType,
  5561. @LanguageType,@Gender,@MinAge,@MaxAge,@MinHeight,@MaxHeight,@LivePlace,@AccountPlace,@MobilePlace,@cvMainID,@IsNegotiable,@IncludeOld,@IsExpand,@EmployType)
  5562. SET @MaxID = @@IDENTITY
  5563. END
  5564. ELSE
  5565. GOTO ERR
  5566. END
  5567. END TRY
  5568. BEGIN CATCH
  5569. GOTO ERR
  5570. END CATCH
  5571. RETURN @MaxID
  5572. ERR:
  5573. BEGIN
  5574. RETURN 0
  5575. END
  5576. GO
  5577. /****** Object: StoredProcedure [dbo].[cccaCvFinderSelect] Script Date: 2018/12/13 19:05:47 ******/
  5578. SET ANSI_NULLS ON
  5579. GO
  5580. SET QUOTED_IDENTIFIER ON
  5581. GO
  5582. ----##########################################
  5583. ----@caMainID 取自Session
  5584. ---- Return = caCvFinder.GetData(ca.caMainID, co.reqS("ID", 0))
  5585. ----##########################################
  5586. CREATE PROCEDURE [dbo].[cccaCvFinderSelect]
  5587. (
  5588. @caMainID INT,
  5589. @ID INT
  5590. )
  5591. AS
  5592. BEGIN
  5593. SELECT *, 0 IsOnline FROM caCvFinder WITH(NOLOCK) WHERE ID = @ID AND caMainID = @caMainID
  5594. END
  5595. GO
  5596. /****** Object: StoredProcedure [dbo].[cccaCvIntentionBatchDelete] Script Date: 2018/12/13 19:05:47 ******/
  5597. SET ANSI_NULLS ON
  5598. GO
  5599. SET QUOTED_IDENTIFIER ON
  5600. GO
  5601. CREATE PROCEDURE [dbo].[cccaCvIntentionBatchDelete]
  5602. (
  5603. @AllID VARCHAR(1000),
  5604. @cpMainID INT
  5605. )
  5606. AS
  5607. BEGIN TRAN
  5608. BEGIN TRY
  5609. SET @AllID = dbo.FormatIDS(@AllID)
  5610. DECLARE @T AS TABLE(ID INT)
  5611. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  5612. DELETE FROM caCvIntention WHERE PersonDeleted=1 AND ID IN(SELECT ID FROM @T)
  5613. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  5614. UPDATE caCvIntention SET CompanyDeleted = 1
  5615. WHERE ID IN(SELECT ID FROM @T)
  5616. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  5617. END TRY
  5618. BEGIN CATCH
  5619. GOTO ERR
  5620. END CATCH
  5621. COMMIT TRAN
  5622. RETURN 1
  5623. ERR:
  5624. BEGIN
  5625. ROLLBACK TRAN
  5626. RETURN 0
  5627. END
  5628. GO
  5629. /****** Object: StoredProcedure [dbo].[cccacvIntentionCountByCaMainIDSelect] Script Date: 2018/12/13 19:05:48 ******/
  5630. SET ANSI_NULLS ON
  5631. GO
  5632. SET QUOTED_IDENTIFIER ON
  5633. GO
  5634. --#####################################################
  5635. --创建时间:2014.10.31
  5636. --创建人:Nick
  5637. --说明:获取今天发送的应聘邀请数量
  5638. --#####################################################
  5639. CREATE PROCEDURE [dbo].[cccacvIntentionCountByCaMainIDSelect]
  5640. (
  5641. @CaMainID INT
  5642. )
  5643. AS
  5644. BEGIN TRY
  5645. SELECT COUNT(1) cnt
  5646. FROM cacvIntention
  5647. WHERE caMainID=@CaMainID
  5648. AND AddDate>CONVERT(VARCHAR(10),GETDATE())
  5649. AND AddDate<CONVERT(VARCHAR(10),GETDATE())+' 23:59'
  5650. END TRY
  5651. BEGIN CATCH
  5652. RETURN 0
  5653. END CATCH
  5654. GO
  5655. /****** Object: StoredProcedure [dbo].[ccCacvIntentionInsert] Script Date: 2018/12/13 19:05:48 ******/
  5656. SET ANSI_NULLS ON
  5657. GO
  5658. SET QUOTED_IDENTIFIER ON
  5659. GO
  5660. --2015-8-27Harry
  5661. --将绑定关注微信的,插入到wxsendmessage表中
  5662. ---20160216 Lucifer 添加推送
  5663. CREATE PROCEDURE [dbo].[ccCacvIntentionInsert]
  5664. (
  5665. @caMainID INT,
  5666. @JobId INT,
  5667. @cvMainID INT
  5668. )
  5669. AS
  5670. SET NOCOUNT ON
  5671. BEGIN
  5672. DECLARE @IntertionPoint INT
  5673. SET @IntertionPoint = 5
  5674. DECLARE @CurrentPoint INT
  5675. SELECT @CurrentPoint = RemainPoint
  5676. FROM cpMain WITH(NOLOCK)
  5677. WHERE ID = (SELECT CpMainID FROM CaMain WITH(NOLOCK) WHERE ID = @caMainID)
  5678. IF @CurrentPoint < @IntertionPoint
  5679. BEGIN
  5680. RETURN -1
  5681. END
  5682. IF EXISTS(SELECT 'x' FROM Job WITH(NOLOCK) WHERE ID = @JobID AND caMainID = @caMainID)
  5683. BEGIN
  5684. IF EXISTS(SELECT ID FROM cacvIntention WHERE JobId = @JobId AND caMainID = @caMainID AND cvMainID = @cvMainID AND AddDate>GETDATE()-30)
  5685. RETURN 2
  5686. ELSE
  5687. BEGIN
  5688. IF (SELECT COUNT(1) FROM cacvIntention WHERE caMainID=@caMainID AND AddDate>CONVERT(VARCHAR(10),GETDATE()) AND AddDate<CONVERT(VARCHAR(10),GETDATE())+' 23:59') < 200
  5689. BEGIN
  5690. DECLARE @paMainId INT, @cacvIntentionID INT, @wxFansId INT, @cpMainId INT
  5691. INSERT INTO cacvIntention(caMainID, JobId, cvMainID) VALUES(@caMainID, @JobId, @cvMainID)
  5692. SELECT @cacvIntentionID=@@IDENTITY
  5693. SELECT @paMainId = a.paMainId, @wxFansId = b.id
  5694. FROM cvMain a, wxFans b
  5695. WHERE a.ID = @cvMainID
  5696. AND b.paMainId = a.paMainId
  5697. AND b.[Status] = 2
  5698. SELECT TOP 1 @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  5699. SELECT @paMainId = paMainId
  5700. FROM cvMain
  5701. WHERE ID = @cvMainID
  5702. IF @wxFansId IS NOT NULL --0已取消关注 1 正在关注 2 已绑定账号
  5703. BEGIN
  5704. --插入到wxMessageSend表中
  5705. INSERT INTO WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, CaMainId, AddDate)
  5706. SELECT 2, @wxFansId, @paMainId, @cacvIntentionID, @cpMainId, @cvMainID, @JobId, @caMainID, GETDATE()
  5707. END
  5708. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  5709. SELECT @paMainId, '亲,收到一份应聘邀请!', 3 WHERE EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = @paMainId)
  5710. --插入积分记录 Peter 2014-08-25
  5711. DECLARE @TodayPoint AS INT
  5712. DECLARE @TodayID AS INT
  5713. SET @TodayPoint = 0
  5714. SET @TodayID = 0
  5715. --SELECT TOP 1 @TodayPoint = ISNULL(Point,0),@TodayID = ISNULL(ID,0) FROM cpPoint WITH(NOLOCK) WHERE changeID = 5 AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120) AND cpMainID = @cpMainID
  5716. --SET @TodayPoint = @TodayPoint + 1
  5717. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,5,-(@IntertionPoint),GETDATE())
  5718. --IF @TodayPoint <= 50
  5719. --BEGIN
  5720. -- IF @TodayID = 0
  5721. -- BEGIN
  5722. -- INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,5,1,GETDATE())
  5723. -- END
  5724. -- ELSE
  5725. -- BEGIN
  5726. -- UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
  5727. -- END
  5728. --END
  5729. RETURN 1
  5730. END
  5731. ELSE
  5732. RETURN 3
  5733. END
  5734. END
  5735. ELSE
  5736. RETURN 0
  5737. END
  5738. GO
  5739. /****** Object: StoredProcedure [dbo].[ccCaCvIntentionSelect] Script Date: 2018/12/13 19:05:48 ******/
  5740. SET ANSI_NULLS ON
  5741. GO
  5742. SET QUOTED_IDENTIFIER ON
  5743. GO
  5744. CREATE PROCEDURE [dbo].[ccCaCvIntentionSelect]
  5745. (
  5746. @WHERE VARCHAR(1000),
  5747. @Order VARCHAR(100),
  5748. @Page SMALLINT,
  5749. @cpMainID INT,
  5750. @caMainID INT
  5751. )
  5752. AS
  5753. SET NOCOUNT ON
  5754. BEGIN
  5755. SET @Where = dbo.SafeSql(@Where)
  5756. SET @ORDER = dbo.SafeSql(@Order)
  5757. DECLARE @SQL AS VARCHAR(2000)
  5758. CREATE TABLE #T(
  5759. TitleID BIGINT,
  5760. ID INT,
  5761. Reply TINYINT,
  5762. ReplyDate SMALLDATETIME,
  5763. JobID INT,
  5764. JobName NVARCHAR(50) COLLATE Chinese_PRC_CI_AS NULL,
  5765. JobRegion VARCHAR(6) NULL,
  5766. IsJobDelete BIT NULL,
  5767. cvMainID INT,
  5768. Degree TINYINT,
  5769. RelatedWorkYears TINYINT,
  5770. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  5771. IsNameHidden BIT,
  5772. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
  5773. Gender BIT,
  5774. paName NVARCHAR(20),
  5775. BirthDay INT,
  5776. HasPhoto TINYINT,
  5777. adddate SMALLDATETIME,
  5778. Valid TINYINT,
  5779. IsViewed BIT,
  5780. HasJobApply BIT,
  5781. HasInterview BIT,
  5782. HasRemark BIT,
  5783. cvEducationID INT,
  5784. College NVARCHAR(50),
  5785. EduType TINYINT,
  5786. MajorName NVARCHAR(20),
  5787. Graduation INT,
  5788. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  5789. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  5790. cvMatch INT,
  5791. MobileVerifyDate SMALLDATETIME,
  5792. IsOnline BIT,
  5793. paMainId INT,
  5794. SecondId VARCHAR(10)
  5795. )
  5796. SET @SQL='
  5797. INSERT INTO #T(
  5798. TitleID, ID, Reply, ReplyDate, JobID, cvMainID, Degree, RelatedWorkYears,
  5799. Attachment, IsNameHidden, LivePlace, Gender, paName, BirthDay, HasPhoto, adddate,
  5800. Valid, MobileVerifyDate, IsOnline, paMainId, SecondId
  5801. )
  5802. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
  5803. a.ID, Reply, ReplyDate, a.JobID, a.cvMainID,
  5804. b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden,
  5805. c.LivePlace, c.Gender, c.Name AS paName, c.BirthDay, c.HasPhoto,
  5806. a.adddate, b.Valid, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID), b.paMainId, b.SecondId
  5807. FROM caCvIntention a WITH(NOLOCK)
  5808. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  5809. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  5810. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  5811. WHERE d.IsDelete = 0 AND CompanyDeleted = 0 '
  5812. DECLARE @AccountType TINYINT
  5813. SELECT @AccountType = AccountType FROM caMain WITH(NOLOCK) WHERE id = @caMainId AND cpMainId = @cpMainId
  5814. IF @AccountType = 1
  5815. SET @SQL = @SQL + ' AND d.cpMainID = ' + LTRIM(STR(@cpMainID))
  5816. ELSE IF @AccountType = 2
  5817. SET @SQL = @SQL + ' AND a.caMainID = ' + LTRIM(STR(@caMainID))
  5818. ELSE IF @AccountType IS NULL
  5819. RETURN
  5820. IF LEN(@WHERE) > 0
  5821. SET @SQL = @SQL + @WHERE
  5822. PRINT @SQL
  5823. EXEC(@SQL)
  5824. IF(@Page < 1)
  5825. SET @Page = 1
  5826. UPDATE #T
  5827. SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20),
  5828. IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  5829. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  5830. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  5831. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  5832. WHERE TitleID > (@Page-1) * 20
  5833. AND TitleID <= @Page*20
  5834. UPDATE #T SET Speciality = (
  5835. SELECT Speciality FROM cvMain WITH(NOLOCK)
  5836. WHERE cvMain.ID = #T.cvMainID)
  5837. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5838. UPDATE #T SET Experience = (
  5839. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  5840. WHERE cvExperience.cvMainID = #T.cvMainID
  5841. ORDER BY BeginDate DESC)
  5842. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5843. UPDATE #T SET cvEducationID = (
  5844. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  5845. WHERE cvEducation.cvMainID = #T.cvMainID
  5846. AND #T.Degree = cvEducation.Degree
  5847. ORDER BY Graduation DESC)
  5848. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5849. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  5850. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  5851. FROM #T a, cvEducation b WITH(NOLOCK)
  5852. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  5853. UPDATE #T SET cvMatch = dbo.GetCvMatch(cvMainID, JobID) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5854. UPDATE #T SET JobName = a.Name, JobRegion= a.dcRegionID, IsJobDelete = IsDelete
  5855. FROM Job a WITH(NOLOCK)
  5856. WHERE #T.JobID = a.ID
  5857. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  5858. SELECT a.*,b.Description DegreeName,c.MapBarName LivePlaceName,d.Description JobRegionName, dbo.BirthToAge(a.BirthDay) Age
  5859. FROM #T a WITH(NOLOCK)
  5860. LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  5861. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  5862. LEFT JOIN dcRegion d WITH(NOLOCK) ON d.ID = a.JobRegion
  5863. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  5864. DROP TABLE #T
  5865. END
  5866. GO
  5867. /****** Object: StoredProcedure [dbo].[ccCaCvQuotaLogByCvMainIDSelect] Script Date: 2018/12/13 19:05:49 ******/
  5868. SET ANSI_NULLS ON
  5869. GO
  5870. SET QUOTED_IDENTIFIER ON
  5871. GO
  5872. --######################################3
  5873. --创建:Lambo,修改Sean
  5874. --检查企业账号是否消耗日配额看过简历联系方式
  5875. --企业有多账号的情况,一个企业内部的查看情况共享,Copper建议
  5876. --######################################3
  5877. CREATE PROCEDURE [dbo].[ccCaCvQuotaLogByCvMainIDSelect]
  5878. (
  5879. @cpMainID INT,
  5880. @cvMainID INT
  5881. )
  5882. AS
  5883. BEGIN
  5884. IF EXISTS(
  5885. SELECT 'x' FROM CaCvQuotaLog WITH(NOLOCK)
  5886. WHERE cpMainID = @cpMainID
  5887. AND cvMainID = @cvMainID
  5888. )
  5889. RETURN 1
  5890. ELSE
  5891. RETURN 0
  5892. END
  5893. GO
  5894. /****** Object: StoredProcedure [dbo].[ccCaCvQuotaLogCount] Script Date: 2018/12/13 19:05:49 ******/
  5895. SET ANSI_NULLS ON
  5896. GO
  5897. SET QUOTED_IDENTIFIER ON
  5898. GO
  5899. --######################################3
  5900. --创建:Sean
  5901. --检查企业账号今天所有的配额消耗数量,用于CompanyAccount
  5902. --######################################3
  5903. CREATE PROCEDURE [dbo].[ccCaCvQuotaLogCount]
  5904. (
  5905. @cpMainID INT
  5906. )
  5907. AS
  5908. BEGIN
  5909. DECLARE @CNT AS INT
  5910. SELECT @CNT = COUNT(1) FROM CaCvQuotaLog WITH(NOLOCK)
  5911. WHERE cpMainID = @cpMainID
  5912. RETURN @CNT
  5913. END
  5914. GO
  5915. /****** Object: StoredProcedure [dbo].[cccaCvQuotaLogInsert] Script Date: 2018/12/13 19:05:49 ******/
  5916. SET ANSI_NULLS ON
  5917. GO
  5918. SET QUOTED_IDENTIFIER ON
  5919. GO
  5920. --###################################################3
  5921. --创建: sean
  5922. --时间: 2010-11-15
  5923. --兼容老版,查看一份简历消耗配额
  5924. --###################################################3
  5925. CREATE PROCEDURE [dbo].[cccaCvQuotaLogInsert]
  5926. (
  5927. @cpMainID INT,
  5928. @caMainID INT,
  5929. @cvMainID INT
  5930. )
  5931. AS
  5932. BEGIN TRAN
  5933. BEGIN TRY
  5934. IF NOT EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK), caMain WITH(NOLOCK) WHERE cpMain.Id = @cpMainID AND caMain.cpMainID = @cpMainID AND cpMain.Valid=1 AND caMain.IsPause = 0 AND caMain.IsDelete = 0)
  5935. GOTO Err1
  5936. IF NOT EXISTS(SELECT 'x' FROM paMain a WITH(NOLOCK), cvMain b WITH(NOLOCK) WHERE a.ID = b.paMainID AND b.Id = @cvMainID AND (ISNULL(b.Attachment,'')<>'' OR ISNULL(a.Mobile,'')<>''))
  5937. GOTO Err2
  5938. DECLARE @ResumeQuota AS INT
  5939. DECLARE @ResumeConsume AS INT
  5940. SELECT @ResumeQuota = ResumeQuota FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  5941. SELECT @ResumeConsume = COUNT(*) FROM caCvQuotaLog WITH(NOLOCK) WHERE cpMainID = @cpMainID
  5942. IF ISNULL(@ResumeQuota, 0) = 0
  5943. GOTO Err3
  5944. IF @ResumeQuota > @ResumeConsume
  5945. BEGIN
  5946. DECLARE @Num AS INT
  5947. EXEC @Num = ccCaCvQuotaLogByCvMainIDSELECT @cpMainID, @cvMainID
  5948. IF @Num = 0
  5949. BEGIN
  5950. INSERT INTO caCvQuotalog(cpMainID,caMainID,cvMainID) VALUES(@cpMainID,@caMainID,@cvMainID)
  5951. SET @ResumeConsume = @ResumeConsume + 1
  5952. END
  5953. END
  5954. ELSE
  5955. GOTO Err4
  5956. END TRY
  5957. BEGIN CATCH
  5958. GOTO ERR
  5959. END CATCH
  5960. COMMIT
  5961. RETURN @ResumeConsume
  5962. ERR:
  5963. BEGIN
  5964. ROLLBACK TRAN
  5965. RETURN 0
  5966. END
  5967. ----企业账号信息不正确
  5968. ERR1:
  5969. BEGIN
  5970. ROLLBACK TRAN
  5971. RETURN -1
  5972. END
  5973. ----简历id是无效简历id
  5974. ERR2:
  5975. BEGIN
  5976. ROLLBACK TRAN
  5977. RETURN -2
  5978. END
  5979. ----本日配额为0,不允许使用配额
  5980. ERR3:
  5981. BEGIN
  5982. ROLLBACK TRAN
  5983. RETURN -3
  5984. END
  5985. ----本日配额已经消耗完毕
  5986. ERR4:
  5987. BEGIN
  5988. ROLLBACK TRAN
  5989. RETURN -4
  5990. END
  5991. GO
  5992. /****** Object: StoredProcedure [dbo].[cccaCvRemarkByCvMainIDSelect] Script Date: 2018/12/13 19:05:49 ******/
  5993. SET ANSI_NULLS ON
  5994. GO
  5995. SET QUOTED_IDENTIFIER ON
  5996. GO
  5997. CREATE PROCEDURE [dbo].[cccaCvRemarkByCvMainIDSelect]
  5998. (
  5999. @caMainID INT,
  6000. @cvMainID INT,
  6001. @cpMainID INT
  6002. )
  6003. AS
  6004. BEGIN
  6005. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID)
  6006. RETURN 0
  6007. BEGIN TRY
  6008. SELECT ID, Remark, AddDate, caMainID FROM caCvRemark WITH(NOLOCK)
  6009. WHERE cvMainID=@cvMainID AND caMainID=@caMainID
  6010. ORDER BY ID DESc
  6011. END TRY
  6012. BEGIN CATCH
  6013. END CATCH
  6014. END
  6015. GO
  6016. /****** Object: StoredProcedure [dbo].[cccaCvRemarkDelete] Script Date: 2018/12/13 19:05:49 ******/
  6017. SET ANSI_NULLS ON
  6018. GO
  6019. SET QUOTED_IDENTIFIER ON
  6020. GO
  6021. --Lambo 20101130 修改
  6022. --增加cpMainID参数,判断是否是该企业的
  6023. CREATE PROCEDURE [dbo].[cccaCvRemarkDelete]
  6024. (
  6025. @ID INT ,
  6026. @cpMainID INT
  6027. )
  6028. AS
  6029. BEGIN
  6030. DELETE FROM caCvRemark WHERE ID = @ID AND caMainID IN (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  6031. END
  6032. GO
  6033. /****** Object: StoredProcedure [dbo].[cccaCvRemarkInsert] Script Date: 2018/12/13 19:05:50 ******/
  6034. SET ANSI_NULLS ON
  6035. GO
  6036. SET QUOTED_IDENTIFIER ON
  6037. GO
  6038. ----##########################################
  6039. ----@caMainID 取自Session
  6040. ----caMainID = ca.caMainID
  6041. ----caCvRemark.caMainID = caMainID
  6042. ----##########################################
  6043. CREATE PROCEDURE [dbo].[cccaCvRemarkInsert]
  6044. (
  6045. @caMainID INT,
  6046. @cvMainID INT,
  6047. @Remark VARCHAR(200)
  6048. )
  6049. AS
  6050. BEGIN
  6051. INSERT INTO caCvRemark(caMainID, Remark, cvMainID) VALUES(@caMainID, @Remark, @cvMainID)
  6052. END
  6053. GO
  6054. /****** Object: StoredProcedure [dbo].[ccCaCvViewLogBatchSave] Script Date: 2018/12/13 19:05:50 ******/
  6055. SET ANSI_NULLS ON
  6056. GO
  6057. SET QUOTED_IDENTIFIER ON
  6058. GO
  6059. CREATE PROCEDURE [dbo].[ccCaCvViewLogBatchSave]
  6060. (
  6061. @cvIDs VARCHAR(500),
  6062. @caMainID INT
  6063. )
  6064. AS
  6065. BEGIN
  6066. SET @cvIDs = dbo.FormatIDS(@cvIDs)
  6067. IF @caMainID <> 0
  6068. BEGIN
  6069. UPDATE CaCvViewLog SET AddDate=GETDATE()
  6070. WHERE caMainID = @caMainID AND cvMainID IN (SELECT * FROM dbo.fnSplit(@cvIDs, ','))
  6071. INSERT CaCvViewLog(caMainID,cvMainID)
  6072. SELECT @caMainID,a FROM dbo.fnSplit(@cvIDs, ',')
  6073. WHERE a NOT IN (SELECT cvMainID FROM CaCvViewLog WITH(NOLOCK) WHERE caMainID = @caMainID)
  6074. END
  6075. UPDATE cvMain SET ViewNumber = ViewNumber + 1 WHERE ID IN (SELECT * FROM dbo.fnSplit(@cvIDs, ','))
  6076. UPDATE ExJobApply SET ViewDate = GETDATE()
  6077. WHERE JobId IN(SELECT Id FROM Job WHERE caMainId = @caMainId)
  6078. AND cvMainID IN (SELECT * FROM dbo.fnSplit(@cvIDs, ','))
  6079. AND ViewDate IS NULL
  6080. END
  6081. GO
  6082. /****** Object: StoredProcedure [dbo].[ccCaCvViewLogBycaMainIDSelect] Script Date: 2018/12/13 19:05:50 ******/
  6083. SET ANSI_NULLS ON
  6084. GO
  6085. SET QUOTED_IDENTIFIER ON
  6086. GO
  6087. CREATE PROCEDURE [dbo].[ccCaCvViewLogBycaMainIDSelect]
  6088. (
  6089. @caMainID INT,
  6090. @WHERE VARCHAR(1000),
  6091. @ORDER VARCHAR(1000),
  6092. @Page SMALLINT,
  6093. @cpMainID INT
  6094. )
  6095. AS
  6096. SET NOCOUNT ON
  6097. BEGIN
  6098. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID)
  6099. RETURN 0
  6100. SET @Where = dbo.SafeSql(@Where)
  6101. SET @ORDER = dbo.SafeSql(@Order)
  6102. CREATE TABLE #t(
  6103. TitleID BIGINT,
  6104. caMainId INT,
  6105. cvMainId INT,
  6106. AddDate SMALLDATETIME,
  6107. Degree TINYINT,
  6108. RelatedWorkYears TINYINT,
  6109. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
  6110. Gender BIT,
  6111. paName NVARCHAR(20),
  6112. BirthDay INT,
  6113. HasPhoto TINYINT,
  6114. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  6115. IsNameHidden BIT,
  6116. Valid TINYINT,
  6117. HasJobApply BIT,
  6118. HasInterview BIT,
  6119. HasRemark BIT,
  6120. HasFavorate BIT,
  6121. cvEducationID INT,
  6122. College NVARCHAR(50),
  6123. EduType TINYINT,
  6124. MajorName NVARCHAR(20),
  6125. Graduation INT,
  6126. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  6127. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  6128. MobileVerifyDate SMALLDATETIME,
  6129. IsOnline BIT,
  6130. HasWeiXin BIT,
  6131. paMainId INT,
  6132. SecondId VARCHAR(10)
  6133. )
  6134. DECLARE @SQL AS VARCHAR(2000)
  6135. SET @SQL='INSERT INTO #t(TitleID, caMainID, cvMainID, AddDate, IsOnline, paMainId, SecondId)
  6136. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
  6137. a.caMainID, a.cvMainID, a.AddDate, dbo.GetPaOnlineStatus(c.ID), b.paMainId, b.SecondId
  6138. From CaCvViewLog a WITH(NOLOCK)
  6139. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  6140. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID'
  6141. SET @SQL=@SQL + '
  6142. WHERE 1=1'
  6143. IF LEN(@WHERE) > 0
  6144. SET @SQL = @SQL + @WHERE
  6145. --PRINT @SQL
  6146. EXEC(@SQL)
  6147. IF(@Page < 1)
  6148. SET @Page = 1
  6149. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  6150. SET @Page = 1
  6151. UPDATE #t SET Degree = a.Degree, RelatedWorkYears = a.RelatedWorkYears, Attachment = a.Attachment,
  6152. IsNameHidden = a.IsNameHidden, LivePlace = b.LivePlace, Gender = b.Gender, paName = b.Name,
  6153. BirthDay = b.BirthDay, HasPhoto = b.HasPhoto, Valid = a.Valid, MobileVerifyDate = b.MobileVerifyDate
  6154. FROM cvMain a WITH(NOLOCK) INNER JOIN paMain b WITH(NOLOCK) ON a.paMainID = b.ID
  6155. WHERE a.ID = #t.cvMainID AND TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6156. UPDATE #t SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20),
  6157. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#t.cvMainID),
  6158. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#t.cvMainID),
  6159. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#t.cvMainID),
  6160. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#t.cvMainID)
  6161. WHERE TitleID > (@Page - 1)*20 AND TitleID <= @Page*20
  6162. UPDATE #T SET Speciality = (
  6163. SELECT Speciality FROM cvMain WITH(NOLOCK)
  6164. WHERE cvMain.ID = #T.cvMainID)
  6165. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6166. UPDATE #T SET Experience = (
  6167. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  6168. WHERE cvExperience.cvMainID = #T.cvMainID
  6169. ORDER BY BeginDate DESC)
  6170. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6171. UPDATE #T SET cvEducationID = (
  6172. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  6173. WHERE cvEducation.cvMainID = #T.cvMainID
  6174. AND #T.Degree = cvEducation.Degree
  6175. ORDER BY Graduation DESC)
  6176. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6177. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  6178. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  6179. FROM #T a, cvEducation b WITH(NOLOCK)
  6180. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  6181. --修改是否绑定微信
  6182. UPDATE a SET HasWeiXin = 1
  6183. FROM #T a, WxFans b WITH(NOLOCK), CvMain c WITH(NOLOCK)
  6184. WHERE a.CvMainID = c.ID
  6185. AND c.PaMainID = b.PaMainID
  6186. AND b.Status = 2
  6187. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6188. SELECT COUNT(*) FROM #t WITH(NOLOCK)
  6189. SELECT * FROM #t WITH(NOLOCK) WHERE TitleID > (@Page - 1)*20 AND TitleID <= @Page*20
  6190. DROP TABLE #t
  6191. END
  6192. GO
  6193. /****** Object: StoredProcedure [dbo].[ccCaCvViewLogBycpMainIDSelect] Script Date: 2018/12/13 19:05:51 ******/
  6194. SET ANSI_NULLS ON
  6195. GO
  6196. SET QUOTED_IDENTIFIER ON
  6197. GO
  6198. CREATE PROCEDURE [dbo].[ccCaCvViewLogBycpMainIDSelect]
  6199. (
  6200. @cpMainID INT
  6201. )
  6202. AS
  6203. SET NOCOUNT ON
  6204. BEGIN
  6205. SELECT a.caMainID, a.cvmainid, a.AddDate, b.dcMajorID, b.IsOpen, c.LivePlace, c.Name AS paName,
  6206. e.FullName Region,b.Degree, 0 isApply
  6207. INTO #t
  6208. FROM CaCvViewLog a WITH(NOLOCK)
  6209. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  6210. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  6211. INNER JOIN caMain d WITH(NOLOCK) ON a.caMainID = d.ID
  6212. INNER JOIN dcRegion e WITH(NOLOCK) ON e.ID = c.LivePlace
  6213. WHERE d.cpMainId=@cpMainID
  6214. ORDER BY a.AddDate DESC
  6215. UPDATE #t SET IsApply=1
  6216. FROM #t a,exjobapply b, job c,caMain d
  6217. WHERE b.jobid=c.id and a.caMainid = d.id and c.cpMainID=d.cpMainID AND b.cvMainid = a.cvMainId
  6218. SELECT * FROM #t ORDER BY AddDate DESC
  6219. DROP TABLE #t
  6220. END
  6221. SET NOCOUNT OFF
  6222. GO
  6223. /****** Object: StoredProcedure [dbo].[ccCaCvViewLogByCpViewCountSelect] Script Date: 2018/12/13 19:05:51 ******/
  6224. SET ANSI_NULLS ON
  6225. GO
  6226. SET QUOTED_IDENTIFIER ON
  6227. GO
  6228. CREATE PROCEDURE [dbo].[ccCaCvViewLogByCpViewCountSelect]
  6229. (
  6230. @cvMainID INT,
  6231. @cpMainID INT
  6232. )
  6233. AS
  6234. BEGIN
  6235. DECLARE @Cnt AS INT
  6236. SELECT @Cnt = COUNT(1)
  6237. FROM caCvViewLog a WITH(NOLOCK)
  6238. INNER JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  6239. WHERE b.cpMainID = @cpMainID
  6240. --AND a.cvMainID = @cvMainID
  6241. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  6242. RETURN @Cnt
  6243. END
  6244. GO
  6245. /****** Object: StoredProcedure [dbo].[cccaCvViewLogInsert] Script Date: 2018/12/13 19:05:51 ******/
  6246. SET ANSI_NULLS ON
  6247. GO
  6248. SET QUOTED_IDENTIFIER ON
  6249. GO
  6250. ----##########################################
  6251. ----@caMainID 取自Session
  6252. ----caCvViewLog.caMainID = ca.caMainID
  6253. ----##########################################
  6254. ---20160216 Lucifer 添加推送
  6255. CREATE PROCEDURE [dbo].[cccaCvViewLogInsert]
  6256. (
  6257. @caMainID INT,
  6258. @cvMainID INT
  6259. )
  6260. AS
  6261. BEGIN
  6262. IF @caMainID > 0
  6263. BEGIN
  6264. IF EXISTS(SELECT 'x' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID = @cvMainID AND caMainID = @caMainID)
  6265. UPDATE caCvViewLog SET ADDDATE = GETDATE() WHERE cvMainID = @cvMainID AND caMainID = @caMainID
  6266. ELSE
  6267. BEGIN
  6268. INSERT INTO caCvViewLog(cvMainID, caMainID) VALUES(@cvMainID, @caMainID)
  6269. --HarryBegin
  6270. DECLARE @wxFansId INT, @paMainId INT, @cpMainID INT--harry
  6271. SELECT @paMainId = b.paMainId FROM cvMain b WITH(NOLOCK) WHERE id = @cvMainID
  6272. SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainId AND [Status] = 2
  6273. IF @wxFansId IS NOT NULL
  6274. BEGIN
  6275. SELECT @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE id = @caMainID
  6276. --插入到wxMessageSend表中
  6277. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, CpMainID, CvMainID, CaMainId, AddDate)
  6278. SELECT 5, @wxFansId, @paMainId, @cpMainId, @cvMainID, @caMainID, GETDATE()
  6279. END
  6280. --HarryEnd
  6281. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  6282. SELECT @paMainId, '亲,有企业查看了您的简历!', 4 WHERE EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = @paMainId)
  6283. END
  6284. END
  6285. UPDATE cvMain SET ViewNumber = ViewNumber + 1 WHERE ID = @cvMainID
  6286. UPDATE ExJobApply SET ViewDate = GETDATE()
  6287. WHERE JobId IN(SELECT Id FROM Job WHERE caMainId = @caMainId)
  6288. AND cvMainID = @cvMainId
  6289. AND ViewDate IS NULL
  6290. END
  6291. GO
  6292. /****** Object: StoredProcedure [dbo].[ccCaCvViewLogSelect] Script Date: 2018/12/13 19:05:51 ******/
  6293. SET ANSI_NULLS ON
  6294. GO
  6295. SET QUOTED_IDENTIFIER ON
  6296. GO
  6297. ----##########################################
  6298. ----@caMainID 取自Session
  6299. ----caMainID = ca.caMainID
  6300. ----##########################################
  6301. CREATE PROCEDURE [dbo].[ccCaCvViewLogSelect]
  6302. (
  6303. @caMainID INT,
  6304. @AllcvMainID VARCHAR(1000)
  6305. )
  6306. AS
  6307. SET NOCOUNT ON
  6308. BEGIN
  6309. SET @AllcvMainID = dbo.FormatIDS(@AllcvMainID)
  6310. SELECT a.caMainid, a.cvMainid, a.AddDate --, b.paMainId, b.SecondId
  6311. FROM CaCvViewLog a WITH(NOLOCK) --, cvMain b WITH(NOLOCK)
  6312. WHERE 1=1 --a.cvMainId = b.Id
  6313. AND a.cvMainId IN(SELECT * FROM dbo.fnSplit(@AllCvMainID, ','))
  6314. AND a.caMainID = @caMainID
  6315. ORDER BY a.AddDate DESC
  6316. END
  6317. GO
  6318. /****** Object: StoredProcedure [dbo].[ccCadailyGiftlogAddDateSelect] Script Date: 2018/12/13 19:05:51 ******/
  6319. SET ANSI_NULLS ON
  6320. GO
  6321. SET QUOTED_IDENTIFIER ON
  6322. GO
  6323. --#####################################################
  6324. --创建时间:2014.10.31
  6325. --创建人:Nick
  6326. --说明:获取下次能下载的时间
  6327. --#####################################################
  6328. CREATE PROCEDURE [dbo].[ccCadailyGiftlogAddDateSelect]
  6329. (
  6330. @CpMainID VARCHAR(20)
  6331. )
  6332. AS
  6333. BEGIN TRY
  6334. SELECT MIN(AddDate) AddDate,MIN(AddDate) + 30 enddate
  6335. FROM (
  6336. SELECT TOP 12 AddDate
  6337. FROM cadailygiftlog WITH(NOLOCK)
  6338. WHERE camainid IN(
  6339. SELECT id FROM caMain WITH(NOLOCK)
  6340. WHERE cpMainID=@CpMainID
  6341. ) ORDER BY adddate DEsc
  6342. ) a
  6343. END TRY
  6344. BEGIN CATCH
  6345. RETURN 0
  6346. END CATCH
  6347. GO
  6348. /****** Object: StoredProcedure [dbo].[ccCaDailyGiftLogByCpMainIDSelect] Script Date: 2018/12/13 19:05:51 ******/
  6349. SET ANSI_NULLS ON
  6350. GO
  6351. SET QUOTED_IDENTIFIER ON
  6352. GO
  6353. --#####################################################
  6354. --创建时间:2014.10.31
  6355. --创建人:Nick
  6356. --说明:判断一个月内免费下载的简历是否超过30
  6357. --#####################################################
  6358. CREATE PROCEDURE [dbo].[ccCaDailyGiftLogByCpMainIDSelect]
  6359. (
  6360. @CpMainID VARCHAR(20)
  6361. )
  6362. AS
  6363. BEGIN TRY
  6364. SELECT COUNT(1) cnt
  6365. FROM caDailyGiftLog
  6366. WHERE cpmainid =@CpMainID
  6367. AND adddate>GETDATE()-30
  6368. END TRY
  6369. BEGIN CATCH
  6370. RETURN 0
  6371. END CATCH
  6372. GO
  6373. /****** Object: StoredProcedure [dbo].[ccCaDailyGiftLogByNeedPointInsert] Script Date: 2018/12/13 19:05:52 ******/
  6374. SET ANSI_NULLS ON
  6375. GO
  6376. SET QUOTED_IDENTIFIER ON
  6377. GO
  6378. --###################################################3
  6379. --创建: Lambo
  6380. --时间: 2014-8-19
  6381. --查看简历消耗积分
  6382. --增加Err5 sunshine2018-8-30
  6383. --###################################################3
  6384. CREATE PROCEDURE [dbo].[ccCaDailyGiftLogByNeedPointInsert]
  6385. (
  6386. @cpMainID INT,
  6387. @caMainID INT,
  6388. @cvMainID INT,
  6389. @IP VARCHAR(30)
  6390. )
  6391. AS
  6392. BEGIN TRAN
  6393. BEGIN TRY
  6394. --判断企业帐户状态是否正常
  6395. IF NOT EXISTS(
  6396. SELECT 'x' FROM cpMain WITH(NOLOCK), caMain WITH(NOLOCK)
  6397. WHERE cpMain.Id = @cpMainID
  6398. AND caMain.cpMainID = @cpMainID
  6399. AND cpMain.Address IS NOT NULL
  6400. AND cpMain.IsLimitLogin < 9
  6401. AND cpMain.VerifyResult = 1
  6402. AND caMain.IsDelete = 0
  6403. AND caMain.IsPause = 0)
  6404. GOTO Err1
  6405. --判断该简历是否是否有联系方式 或者是附件简历
  6406. IF NOT EXISTS(
  6407. SELECT 'x' FROM paMain a WITH(NOLOCK), cvMain b WITH(NOLOCK)
  6408. WHERE a.ID = b.paMainID
  6409. AND b.Id = @cvMainID
  6410. AND (ISNULL(b.Attachment,'')<>'' OR ISNULL(a.Mobile,'')<>''))
  6411. GOTO Err2
  6412. DECLARE @RemainPoint AS INT --企业剩余积分
  6413. DECLARE @PointConsume AS INT --下载一份简历所需积分
  6414. DECLARE @dcProvinceID AS INT
  6415. SELECT @RemainPoint = RemainPoint, @dcProvinceID = dcProvinceID FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  6416. SELECT @PointConsume = NeedPoint FROM dcFeeStandard WITH(NOLOCK) WHERE dcProvinceID = @dcProvinceID
  6417. DECLARE @MonthCount AS INT, @CpRealNameStatus AS INT, @MemberType AS INT
  6418. SELECT @CpRealNameStatus =RealName,@MemberType=memberType from CpMain WITH(NOLOCK) where ID=@CpMainID
  6419. SELECT @MonthCount=COUNT(1)
  6420. FROM caDailyGiftLog
  6421. WHERE cpmainid =@CpMainID
  6422. AND adddate>GETDATE()-30
  6423. IF @MemberType!=3
  6424. BEGIN
  6425. IF ((@CpRealNameStatus =1 AND @MonthCount>=24)OR(@CpRealNameStatus !=1 AND @MonthCount>=12))
  6426. GOTO Err5
  6427. END
  6428. IF ISNULL(@RemainPoint, 0) = 0 --没有积分
  6429. GOTO Err3
  6430. IF @RemainPoint >= @PointConsume --判断企业剩余积分是否够消耗
  6431. BEGIN
  6432. DECLARE @Num AS INT
  6433. EXEC @Num = ccActiveDownExist @cpMainID, @cvMainID --判断这份简历是否下载过
  6434. IF @Num = 0
  6435. BEGIN
  6436. --插入简历下载记录 type=1 为积分下载
  6437. INSERT INTO CaDailyGiftLog(cpMainID,caMainID,cvMainID,IP,Type) VALUES(@cpMainID,@caMainID,@cvMainID,@IP,1)
  6438. --Harry Begin
  6439. DECLARE @paMainID INT, @CaDailyGiftLogID INT, @wxFansId INT
  6440. SELECT @CaDailyGiftLogID = @@IDENTITY
  6441. SELECT @paMainId = paMainId FROM cvMain WITH(NOLOCK) WHERE Id = @cvMainID
  6442. SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainId AND [Status] = 2
  6443. IF @wxFansId>0
  6444. BEGIN
  6445. --插入到wxMessageSend表中
  6446. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, CaMainId, AddDate)
  6447. SELECT 6, @wxFansId, @paMainId, @CaDailyGiftLogID, @cpMainId, @cvMainID, @caMainID, GETDATE()
  6448. END
  6449. --Harry End
  6450. --插入积分使用记录,Point是负数表示消耗积分。企业的剩余积分在cppoint的触发器中更新
  6451. INSERT INTO cpPoint (cpMainID, ChangeID, Point, RelativeID, LastModifyDate)
  6452. VALUES(@cpMainID, 17, 0 - @PointConsume, @cvMainID, GETDATE())
  6453. END
  6454. END
  6455. ELSE
  6456. GOTO Err4
  6457. END TRY
  6458. BEGIN CATCH
  6459. GOTO Err
  6460. END CATCH
  6461. COMMIT
  6462. RETURN 1
  6463. Err:
  6464. BEGIN
  6465. ROLLBACK TRAN
  6466. RETURN 0
  6467. END
  6468. ----企业账号信息不正确
  6469. Err1:
  6470. BEGIN
  6471. ROLLBACK TRAN
  6472. RETURN -1
  6473. END
  6474. ----简历id是无效简历id
  6475. Err2:
  6476. BEGIN
  6477. ROLLBACK TRAN
  6478. RETURN -2
  6479. END
  6480. ----无积分
  6481. Err3:
  6482. BEGIN
  6483. ROLLBACK TRAN
  6484. RETURN -3
  6485. END
  6486. ----积分不足
  6487. Err4:
  6488. BEGIN
  6489. ROLLBACK TRAN
  6490. RETURN -4
  6491. END
  6492. ----本月的赠送简历数已经用完了
  6493. Err5:
  6494. BEGIN
  6495. ROLLBACK TRAN
  6496. RETURN -5
  6497. END
  6498. GO
  6499. /****** Object: StoredProcedure [dbo].[ccCaDailyGiftLogCount] Script Date: 2018/12/13 19:05:52 ******/
  6500. SET ANSI_NULLS ON
  6501. GO
  6502. SET QUOTED_IDENTIFIER ON
  6503. GO
  6504. --####################################
  6505. --创建: Sean 2010-11-12
  6506. --根据企业账号查看该企业的所有日赠送消费数量
  6507. --####################################
  6508. CREATE PROCEDURE [dbo].[ccCaDailyGiftLogCount]
  6509. (
  6510. @cpMainID INT
  6511. )
  6512. AS
  6513. BEGIN
  6514. DECLARE @Count AS INT
  6515. SELECT @Count = ISNULL(COUNT(*), 0)
  6516. FROM caDailyGiftLog WITH(NOLOCK)
  6517. WHERE cpMainID = @cpMainID
  6518. AND ConsumeDate = CONVERT(VARCHAR(8), GETDATE(), 112)
  6519. RETURN @Count
  6520. END
  6521. GO
  6522. /****** Object: StoredProcedure [dbo].[ccCaDailyGiftLogInsert] Script Date: 2018/12/13 19:05:52 ******/
  6523. SET ANSI_NULLS ON
  6524. GO
  6525. SET QUOTED_IDENTIFIER ON
  6526. GO
  6527. --###################################################3
  6528. --创建: sean
  6529. --时间: 2010-11-15
  6530. --查看简历消耗日赠送配额
  6531. --增加Err5 sunshine2018-30
  6532. --###################################################3
  6533. CREATE PROCEDURE [dbo].[ccCaDailyGiftLogInsert]
  6534. (
  6535. @cpMainID INT,
  6536. @caMainID INT,
  6537. @cvMainID INT,
  6538. @IP VARCHAR(30)
  6539. )
  6540. AS
  6541. BEGIN TRAN
  6542. BEGIN TRY
  6543. IF NOT EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK), caMain WITH(NOLOCK)
  6544. WHERE cpMain.Id = @cpMainID AND caMain.cpMainID = @cpMainID
  6545. AND cpMain.Address IS NOT NULL AND cpMain.IsLimitLogin < 9 AND cpMain.VerifyResult = 1
  6546. AND caMain.IsDelete = 0 AND caMain.IsPause = 0)
  6547. GOTO Err1
  6548. IF NOT EXISTS(SELECT 'x' FROM paMain a WITH(NOLOCK), cvMain b WITH(NOLOCK) WHERE a.ID = b.paMainID AND b.Id = @cvMainID AND (ISNULL(b.Attachment,'')<>'' OR ISNULL(a.Mobile,'')<>''))
  6549. GOTO Err2
  6550. DECLARE @MonthCount AS INT, @CpRealNameStatus AS INT, @MemberType AS INT
  6551. SELECT @CpRealNameStatus =RealName,@MemberType=memberType from CpMain WITH(NOLOCK) where ID=@CpMainID
  6552. SELECT @MonthCount=COUNT(1)
  6553. FROM caDailyGiftLog
  6554. WHERE cpmainid =@CpMainID
  6555. AND adddate>GETDATE()-30
  6556. IF @MemberType!=3
  6557. BEGIN
  6558. IF ((@CpRealNameStatus =1 AND @MonthCount>=24)OR(@CpRealNameStatus !=1 AND @MonthCount>=12))
  6559. GOTO Err5
  6560. END
  6561. DECLARE @DailyGiftQuota AS INT
  6562. DECLARE @DailyGiftConsume AS INT
  6563. SELECT @DailyGiftQuota = DailyGiftQuota FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  6564. EXEC @DailyGiftConsume = ccCaDailyGiftLogCount @cpMainID
  6565. IF ISNULL(@DailyGiftQuota, 0) = 0
  6566. GOTO Err3
  6567. IF @DailyGiftQuota > @DailyGiftConsume
  6568. BEGIN
  6569. DECLARE @Num AS INT
  6570. EXEC @Num = ccActiveDownExist @cpMainID,@cvMainID
  6571. IF @Num = 0
  6572. BEGIN
  6573. --Harry Begin
  6574. DECLARE @paMainID INT, @CaDailyGiftLogID INT, @wxFansId INT
  6575. INSERT INTO CaDailyGiftLog(cpMainID,caMainID,cvMainID,IP) VALUES(@cpMainID,@caMainID,@cvMainID,@IP)
  6576. SELECT @CaDailyGiftLogID = @@IDENTITY
  6577. SELECT @paMainId = paMainId FROM cvMain WITH(NOLOCK) WHERE Id = @cvMainID
  6578. SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainId AND [Status] = 2
  6579. IF @wxFansId>0
  6580. BEGIN
  6581. --插入到wxMessageSend表中
  6582. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, CaMainId, AddDate)
  6583. SELECT 6, @wxFansId, @paMainId, @CaDailyGiftLogID, @cpMainId, @cvMainID, @caMainID, GETDATE()
  6584. END
  6585. --Harry End
  6586. SET @DailyGiftConsume = @DailyGiftConsume + 1
  6587. END
  6588. END
  6589. ELSE
  6590. GOTO Err4
  6591. END TRY
  6592. BEGIN CATCH
  6593. GOTO Err
  6594. END CATCH
  6595. COMMIT
  6596. RETURN @DailyGiftConsume
  6597. Err:
  6598. BEGIN
  6599. ROLLBACK TRAN
  6600. RETURN 0
  6601. END
  6602. ----企业账号信息不正确
  6603. Err1:
  6604. BEGIN
  6605. ROLLBACK TRAN
  6606. RETURN -1
  6607. END
  6608. ----简历id是无效简历id
  6609. Err2:
  6610. BEGIN
  6611. ROLLBACK TRAN
  6612. RETURN -2
  6613. END
  6614. ----本日赠送为0或空
  6615. Err3:
  6616. BEGIN
  6617. ROLLBACK TRAN
  6618. RETURN -3
  6619. END
  6620. ----本日赠送已经消耗完毕
  6621. Err4:
  6622. BEGIN
  6623. ROLLBACK TRAN
  6624. RETURN -4
  6625. END
  6626. ----本月的赠送简历数已经用完了
  6627. Err5:
  6628. BEGIN
  6629. ROLLBACK TRAN
  6630. RETURN -5
  6631. END
  6632. GO
  6633. /****** Object: StoredProcedure [dbo].[cccaDownloadLogByExcelSelect] Script Date: 2018/12/13 19:05:53 ******/
  6634. SET ANSI_NULLS ON
  6635. GO
  6636. SET QUOTED_IDENTIFIER ON
  6637. GO
  6638. --20180227 Carl 修改 隐藏的姓名导出时也隐藏
  6639. CREATE PROCEDURE [dbo].[cccaDownloadLogByExcelSelect]
  6640. (
  6641. @cpMainID INT,
  6642. @WHERE VARCHAR(1000),
  6643. @ORDER VARCHAR(100),
  6644. @caMainID INT
  6645. )
  6646. AS
  6647. SET NOCOUNT ON
  6648. BEGIN
  6649. SET @Where = dbo.SafeSql(@Where)
  6650. SET @ORDER = dbo.SafeSql(@Order)
  6651. DECLARE @SQL VARCHAR(2000)
  6652. CREATE TABLE #T(
  6653. cvMainID INT,
  6654. Degree TINYINT,
  6655. RelatedWorkYears TINYINT,
  6656. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS ,
  6657. IsNameHidden BIT,
  6658. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS ,
  6659. Gender BIT,
  6660. paName NVARCHAR(20),
  6661. BirthDay INT,
  6662. HasPhoto TINYINT,
  6663. Valid TINYINT,
  6664. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  6665. Email VARCHAR(50),
  6666. Mobile VARCHAR(13),
  6667. Adddate SMALLDATETIME,
  6668. paMainId INT,
  6669. SecondId VARCHAR(10)
  6670. )
  6671. SET @SQL = '
  6672. INSERT INTO #T(cvMainID, Degree, RelatedWorkYears, Attachment, IsNameHidden,
  6673. LivePlace, Gender, paName, BirthDay, HasPhoto, Valid, Speciality, Email,
  6674. Mobile, Adddate, paMainId, SecondId)
  6675. SELECT b.* FROM (
  6676. SELECT
  6677. a.cvMainID, b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden,
  6678. c.LivePlace, c.Gender, LEFT(dbo.GetPaName(b.Id, '+CONVERT(VARCHAR,@cpMainID)+'), 20) name, c.BirthDay, c.HasPhoto, b.Valid, b.Speciality,
  6679. c.Email, c.Mobile, a.Adddate, b.paMainId, b.SecondId
  6680. FROM caDailyGiftLog a WITH(NOLOCK)
  6681. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  6682. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  6683. WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + ' ' + REPLACE(@WHERE, 'a.caOrderID', '1') + '
  6684. UNION
  6685. SELECT
  6686. a.cvMainID, b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden,
  6687. c.LivePlace, c.Gender, LEFT(dbo.GetPaName(b.Id, '+CONVERT(VARCHAR,@cpMainID)+'), 20) name, c.BirthDay, c.HasPhoto, b.Valid, b.Speciality,
  6688. c.Email, c.Mobile, a.Adddate, b.paMainId, b.SecondId
  6689. FROM caActiveLog a WITH(NOLOCK)
  6690. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  6691. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  6692. WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + ' ' + @WHERE +
  6693. ') b'
  6694. --PRINT @SQL
  6695. EXEC(@SQL)
  6696. SELECT * FROM #T WITH(NOLOCK) ORDER BY AddDate DESC
  6697. DROP TABLE #T
  6698. END
  6699. GO
  6700. /****** Object: StoredProcedure [dbo].[cccaDownloadLogSelect] Script Date: 2018/12/13 19:05:53 ******/
  6701. SET ANSI_NULLS ON
  6702. GO
  6703. SET QUOTED_IDENTIFIER ON
  6704. GO
  6705. --20160108 nick 加入是否绑定微信
  6706. --20181016 Peter加入联系方式显示
  6707. CREATE PROCEDURE [dbo].[cccaDownloadLogSelect]
  6708. (
  6709. @cpMainID INT,
  6710. @WHERE VARCHAR(1000),
  6711. @ORDER VARCHAR(100),
  6712. @Page SMALLINT,
  6713. @caMainID INT
  6714. )
  6715. AS
  6716. SET NOCOUNT ON
  6717. BEGIN
  6718. SET @Where = dbo.SafeSql(@Where)
  6719. SET @ORDER = dbo.SafeSql(@Order)
  6720. DECLARE @SQL VARCHAR(2000)
  6721. CREATE TABLE #T(
  6722. TitleID BIGINT,
  6723. cvMainID INT,
  6724. caOrderID INT NULL,
  6725. IP VARCHAR(39) COLLATE Chinese_PRC_CI_AS NOT NULL,
  6726. RemainQuota SMALLINT NULL,
  6727. AddDate SMALLDATETIME,
  6728. Degree TINYINT,
  6729. RelatedWorkYears TINYINT,
  6730. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS ,
  6731. IsNameHidden BIT,
  6732. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS ,
  6733. Gender BIT,
  6734. paName NVARCHAR(20),
  6735. BirthDay INT,
  6736. HasPhoto TINYINT,
  6737. Valid TINYINT,
  6738. HasJobApply BIT,
  6739. HasInterview BIT,
  6740. HasRemark BIT,
  6741. HasFavorate BIT,
  6742. cvEducationID INT,
  6743. College NVARCHAR(50),
  6744. EduType TINYINT,
  6745. MajorName NVARCHAR(20),
  6746. Graduation INT,
  6747. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  6748. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  6749. MobileVerifyDate SMALLDATETIME,
  6750. IsOnline BIT,
  6751. HasWeiXin BIT,
  6752. paMainID INT,
  6753. SecondId VARCHAR(10),
  6754. Mobile VARCHAR(15),
  6755. Email VARCHAR(100),
  6756. ContactPrivi BIT
  6757. )
  6758. SET @SQL = '
  6759. INSERT INTO #T(TitleID, cvMainID, caOrderID, RemainQuota, IP, AddDate, Degree, RelatedWorkYears,
  6760. Attachment, IsNameHidden, LivePlace, Gender, BirthDay, HasPhoto, Valid, MobileVerifyDate, IsOnline, paMainId, SecondId)
  6761. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID, a.* FROM (
  6762. SELECT
  6763. a.cvMainID, NULL caOrderID, NULL RemainQuota, a.IP, a.AddDate,
  6764. b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden,
  6765. c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto, b.Valid, c.MobileVerifyDate,
  6766. dbo.GetPaOnlineStatus(c.ID) IsOnline, b.paMainId, b.SecondId
  6767. FROM caDailyGiftLog a WITH(NOLOCK)
  6768. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  6769. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  6770. WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + ' ' + REPLACE(@WHERE, 'a.caOrderID', '1') + '
  6771. AND a.AddDate > DATEADD(YEAR, -2, GETDATE())
  6772. UNION
  6773. SELECT
  6774. a.cvMainID, a.caOrderID, a.RemainQuota, a.IP, a.AddDate,
  6775. b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden,
  6776. c.LivePlace, c.Gender, c.BirthDay, c.HasPhoto, b.Valid, c.MobileVerifyDate,
  6777. dbo.GetPaOnlineStatus(c.ID) IsOnline, b.paMainId, b.SecondId
  6778. FROM caActiveLog a WITH(NOLOCK)
  6779. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  6780. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  6781. WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + '
  6782. AND a.AddDate > DATEADD(YEAR, -2, GETDATE()) ' + @WHERE + ') a'
  6783. --PRINT @SQL
  6784. EXEC(@SQL)
  6785. IF(@Page < 1)
  6786. SET @Page = 1
  6787. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  6788. SET @Page = 1
  6789. UPDATE #T SET paName = LEFT(dbo.GetPaName(cvMainID, @cpMainID), 20),
  6790. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  6791. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  6792. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID),
  6793. HasFavorate = (SELECT TOP 1 '1' FROM caFavorate WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  6794. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6795. UPDATE #T SET Speciality = (
  6796. SELECT Speciality FROM cvMain WITH(NOLOCK)
  6797. WHERE cvMain.ID = #T.cvMainID)
  6798. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6799. UPDATE #T SET Experience = (
  6800. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  6801. WHERE cvExperience.cvMainID = #T.cvMainID
  6802. ORDER BY BeginDate DESC)
  6803. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6804. UPDATE #T SET cvEducationID = (
  6805. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  6806. WHERE cvEducation.cvMainID = #T.cvMainID
  6807. AND #T.Degree = cvEducation.Degree
  6808. ORDER BY Graduation DESC)
  6809. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6810. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  6811. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  6812. FROM #T a, cvEducation b WITH(NOLOCK)
  6813. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  6814. UPDATE a SET Email = b.Email,Mobile = b.Mobile,ContactPrivi = dbo.CheckCvPrivi(a.cvMainID,@cpMainID)
  6815. FROM #T a,PaMain b WITH(NOLOCK)
  6816. WHERE b.id = a.paMainID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  6817. --修改是否绑定微信
  6818. UPDATE a SET HasWeiXin = 1
  6819. FROM #T a, WxFans b WITH(NOLOCK), CvMain c WITH(NOLOCK)
  6820. WHERE a.CvMainID = c.ID
  6821. AND c.PaMainID = b.PaMainID
  6822. AND b.Status = 2
  6823. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6824. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  6825. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  6826. DROP TABLE #T
  6827. END
  6828. GO
  6829. /****** Object: StoredProcedure [dbo].[cccaFavorateBatchDelete] Script Date: 2018/12/13 19:05:53 ******/
  6830. SET ANSI_NULLS ON
  6831. GO
  6832. SET QUOTED_IDENTIFIER ON
  6833. GO
  6834. CREATE PROCEDURE [dbo].[cccaFavorateBatchDelete]
  6835. (
  6836. @AllID VARCHAR(1000),
  6837. @cpMainID INT
  6838. )
  6839. AS
  6840. BEGIN TRY
  6841. SET @AllID = dbo.FormatIDS(@AllID)
  6842. DECLARE @T AS TABLE(ID INT)
  6843. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  6844. DELETE FROM caFavorate
  6845. WHERE ID IN(SELECT ID FROM @T)
  6846. AND caMainID IN (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  6847. END TRY
  6848. BEGIN CATCH
  6849. GOTO ERR
  6850. END CATCH
  6851. RETURN 1
  6852. ERR:
  6853. BEGIN
  6854. RETURN 0
  6855. END
  6856. GO
  6857. /****** Object: StoredProcedure [dbo].[cccaFavorateByCvMainIDSelect] Script Date: 2018/12/13 19:05:53 ******/
  6858. SET ANSI_NULLS ON
  6859. GO
  6860. SET QUOTED_IDENTIFIER ON
  6861. GO
  6862. --修改:Andy 2015-01-13 添加职位的regionid
  6863. CREATE PROCEDURE [dbo].[cccaFavorateByCvMainIDSelect]
  6864. (
  6865. @caMainID INT, --=0时是全部
  6866. @cvMainID INT,
  6867. @cpMainID INT
  6868. )
  6869. AS
  6870. BEGIN
  6871. BEGIN TRY
  6872. IF @caMainID = 0
  6873. SELECT a.caMainID,c.dcRegionID,a.AddDate, b.Name AS caName, a.JobID, c.Name AS JobName
  6874. FROM caFavorate a WITH(NOLOCK)
  6875. INNER JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  6876. INNER JOIN Job c WITH(NOLOCK) ON a.JobID = c.ID
  6877. WHERE cvMainID = @cvMainID AND b.cpMainID = @cpMainID
  6878. IF @caMainID > 0
  6879. SELECT a.AddDate, c.dcRegionID,b.Name AS caName, a.JobID, c.Name AS JobName
  6880. FROM caFavorate a WITH(NOLOCK)
  6881. INNER JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  6882. INNER JOIN Job c WITH(NOLOCK) ON a.JobID = c.ID
  6883. WHERE cvMainID = @cvMainID
  6884. AND b.cpMainID = @cpMainID
  6885. AND b.ID = @caMainID
  6886. END TRY
  6887. BEGIN CATCH
  6888. END CATCH
  6889. END
  6890. GO
  6891. /****** Object: StoredProcedure [dbo].[ccCaFavorateByExcelSelect] Script Date: 2018/12/13 19:05:53 ******/
  6892. SET ANSI_NULLS ON
  6893. GO
  6894. SET QUOTED_IDENTIFIER ON
  6895. GO
  6896. --Add by andy 2014-12-18
  6897. --查询收藏的职位(用于网站前台导出excel)
  6898. --alen 2018-3-28
  6899. CREATE PROCEDURE [dbo].[ccCaFavorateByExcelSelect]
  6900. (
  6901. @WHERE VARCHAR(1000),
  6902. @cpMainID INT,
  6903. @caMainID INT
  6904. )
  6905. AS
  6906. SET NOCOUNT ON
  6907. IF NOT EXISTS(SELECT 'x' FROM caMain WHERE id = @caMainId AND cpMainId = @cpMainId)
  6908. RETURN
  6909. BEGIN
  6910. SET @WHERE = dbo.SafeSQL(@WHERE)
  6911. DECLARE @SQL AS VARCHAR(2000)
  6912. CREATE TABLE #T(
  6913. ID INT,
  6914. JobID INT,
  6915. cvMainID INT,
  6916. caFavorateMarkID INT,
  6917. Degree TINYINT,
  6918. RelatedWorkYears TINYINT,
  6919. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  6920. IsNameHidden BIT,
  6921. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
  6922. Gender BIT,
  6923. paName NVARCHAR(20),
  6924. BirthDay INT,
  6925. HasPhoto TINYINT,
  6926. adddate SMALLDATETIME,
  6927. Valid TINYINT,
  6928. IsViewed BIT,
  6929. HasJobApply BIT,
  6930. HasInterview BIT,
  6931. HasRemark BIT,
  6932. cvEducationID INT,
  6933. College NVARCHAR(50),
  6934. EduType TINYINT,
  6935. MajorName NVARCHAR(20),
  6936. Graduation INT,
  6937. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  6938. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  6939. MobileVerifyDate SMALLDATETIME,
  6940. IsOnline BIT,
  6941. IsShowContact INT
  6942. )
  6943. SET @SQL = '
  6944. INSERT INTO #T(
  6945. ID, JobID, cvMainID, caFavorateMarkID, Degree, RelatedWorkYears,
  6946. Attachment, IsNameHidden, LivePlace, Gender, paName, BirthDay, HasPhoto, adddate,
  6947. Valid, MobileVerifyDate, IsOnline, IsShowContact)
  6948. SELECT a.ID, a.JobID, a.cvMainID, a.caFavorateMarkID,
  6949. b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden,
  6950. c.LivePlace, c.Gender, dbo.GetPaName(a.cvMainID, ' + LTRIM(STR(@cpMainID)) + ') AS paName, c.BirthDay, c.HasPhoto,
  6951. a.adddate, b.Valid, c.MobileVerifyDate, 0, 0
  6952. FROM caFavorate a WITH(NOLOCK)
  6953. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  6954. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  6955. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  6956. WHERE d.IsDelete = 0 AND a.caMainID = ' +LTRIM(STR(@caMainID))
  6957. IF LEN(@WHERE) > 0
  6958. SET @SQL = @SQL + @WHERE
  6959. SET @SQL = @SQL + ' ORDER BY a.Id DESC'
  6960. --print @sql
  6961. EXEC(@SQL)
  6962. UPDATE #T
  6963. SET Speciality = (
  6964. SELECT Speciality
  6965. FROM cvMain WITH(NOLOCK)
  6966. WHERE cvMain.ID = #T.cvMainID)
  6967. UPDATE #T
  6968. SET Experience = (
  6969. SELECT TOP 1 ISNULL(Description, DescriptionEng)
  6970. FROM cvExperience WITH(NOLOCK)
  6971. WHERE cvExperience.cvMainID = #T.cvMainID
  6972. ORDER BY BeginDate DESC)
  6973. UPDATE #T SET cvEducationID = (
  6974. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  6975. WHERE cvEducation.cvMainID = #T.cvMainID AND #T.Degree = cvEducation.Degree
  6976. ORDER BY Graduation DESC)
  6977. UPDATE a
  6978. SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  6979. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  6980. FROM #T a, cvEducation b WITH(NOLOCK)
  6981. WHERE b.ID = a.cvEducationID
  6982. UPDATE #t SET IsShowContact = 1 WHERE cvMainId IN(SELECT cvMainId FROM caActiveLog WITH(NOLOCK) WHERE cpMainId = @cpMainId)
  6983. UPDATE #t SET IsShowContact = 1 WHERE cvMainId IN(SELECT cvMainId FROM caDailyGiftLog WITH(NOLOCK) WHERE cpMainId = @cpMainId)
  6984. UPDATE #t SET IsShowContact = 1 WHERE cvMainId IN(SELECT cvMainId FROM exJobApply WITH(NOLOCK) WHERE JobId IN(SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainId = @cpMainId) AND IsPassed = 1)
  6985. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  6986. SELECT * FROM #T WITH(NOLOCK)
  6987. DROP TABLE #T
  6988. END
  6989. GO
  6990. /****** Object: StoredProcedure [dbo].[cccaFavorateInsert] Script Date: 2018/12/13 19:05:54 ******/
  6991. SET ANSI_NULLS ON
  6992. GO
  6993. SET QUOTED_IDENTIFIER ON
  6994. GO
  6995. ----##########################################
  6996. ----@caMainID 取自Session
  6997. ----caMainID = ca.caMainID
  6998. ----caFavorate.caMainID = caMainID
  6999. ----2012.1.10增加return,1新增;2:修改
  7000. ----因为有求职者反映,会收到很多邮件,估计是企业查询收藏再查询收藏,而发邮件没有判断是否以前收藏过造成重复发送邮件
  7001. ----2015-8-27Harry
  7002. ----收藏简历时,判断是否关注插入到wxsendmessage表
  7003. ----##########################################
  7004. CREATE PROCEDURE [dbo].[cccaFavorateInsert]
  7005. (
  7006. @caMainID INT,
  7007. @JobId INT,
  7008. @cvMainID INT
  7009. )
  7010. AS
  7011. BEGIN
  7012. IF NOT EXISTS(
  7013. SELECT 'x' FROM Job WITH(NOLOCK)
  7014. WHERE Id = @JobId
  7015. AND caMainID IN (
  7016. SELECT ID FROM CaMain
  7017. WHERE CpMainID = (
  7018. SELECT CpMainID FROM CaMain WHERE id = @caMainId
  7019. )
  7020. )
  7021. )
  7022. RETURN 0
  7023. IF EXISTS(
  7024. SELECT ID FROM caFavorate
  7025. WHERE JobId = @JobId
  7026. AND caMainID IN (
  7027. SELECT ID FROM CaMain
  7028. WHERE CpMainID = (
  7029. SELECT CpMainID FROM CaMain WHERE id = @caMainId
  7030. )
  7031. )
  7032. AND cvMainID = @cvMainID
  7033. )
  7034. BEGIN
  7035. UPDATE caFavorate SET AddDate = GETDATE() WHERE JobId = @JobId AND caMainID = @caMainID AND cvMainID = @cvMainID
  7036. RETURN 2
  7037. END
  7038. ELSE
  7039. BEGIN
  7040. --about weixin send
  7041. DECLARE @paMainId INT, @caFavorateID INT, @wxFansId INT,@wxStatus INT, @openId VARCHAR(50), @cpMainId INT
  7042. INSERT INTO caFavorate(caMainID, JobId, cvMainID) VALUES(@caMainID, @JobId, @cvMainID)
  7043. SELECT @caFavorateID = @@IDENTITY
  7044. SELECT @paMainId=a.pamainId, @wxFansId = b.id
  7045. FROM cvMain a WITH(NOLOCK), wxFans b WITH(NOLOCK)
  7046. WHERE a.Id = @cvMainID
  7047. AND a.paMainId = b.paMainId
  7048. AND b.[Status] = 2
  7049. IF @wxFansId IS NOT NULL --0已取消关注 1 正在关注 2 已绑定账号
  7050. BEGIN
  7051. SELECT @cpMainId = cpMainId FROM caMain WITH(NOLOCK) WHERE Id = @caMainID
  7052. --插入到wxMessageSend表中
  7053. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, CaMainId, AddDate)
  7054. SELECT 3, @wxFansId, @paMainId, @caFavorateID, @cpMainId, @cvMainID, @JobId, @caMainID, GETDATE()
  7055. END
  7056. RETURN 1
  7057. END
  7058. END
  7059. GO
  7060. /****** Object: StoredProcedure [dbo].[cccaFavorateMarkBycaMainIDSelect] Script Date: 2018/12/13 19:05:54 ******/
  7061. SET ANSI_NULLS ON
  7062. GO
  7063. SET QUOTED_IDENTIFIER ON
  7064. GO
  7065. CREATE PROCEDURE [dbo].[cccaFavorateMarkBycaMainIDSelect]
  7066. (
  7067. @caMainID INT
  7068. )
  7069. AS
  7070. BEGIN
  7071. SELECT ID, Mark, AddDate FROM caFavorateMark WHERE caMainID = @caMainID
  7072. END
  7073. GO
  7074. /****** Object: StoredProcedure [dbo].[cccaFavorateMarkDelete] Script Date: 2018/12/13 19:05:54 ******/
  7075. SET ANSI_NULLS ON
  7076. GO
  7077. SET QUOTED_IDENTIFIER ON
  7078. GO
  7079. --Lambo 20101130 修改
  7080. --增加cpMainID 参数,判断是否是本企业的
  7081. CREATE PROCEDURE [dbo].[cccaFavorateMarkDelete]
  7082. (
  7083. @ID INT,
  7084. @cpMainID INT
  7085. )
  7086. AS
  7087. BEGIN
  7088. DELETE FROM caFavorateMark
  7089. WHERE ID = @ID
  7090. AND caMainID IN(
  7091. SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID
  7092. )
  7093. UPDATE caFavorate SET caFavorateMarkID = NULL
  7094. WHERE caFavorateMarkID = @ID
  7095. AND caMainID IN(
  7096. SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID
  7097. )
  7098. END
  7099. GO
  7100. /****** Object: StoredProcedure [dbo].[cccaFavorateMarkSave] Script Date: 2018/12/13 19:05:54 ******/
  7101. SET ANSI_NULLS ON
  7102. GO
  7103. SET QUOTED_IDENTIFIER ON
  7104. GO
  7105. --Lambo 20101130 修改
  7106. --update语句后面加上增加本账户的条件
  7107. --caFavorateMark.caMainID = ca.caMainID
  7108. CREATE PROCEDURE [dbo].[cccaFavorateMarkSave]
  7109. (
  7110. @ID INT,
  7111. @caMainID INT,
  7112. @Mark VARCHAR(20)
  7113. )
  7114. AS
  7115. BEGIN
  7116. IF @ID > 0
  7117. BEGIN
  7118. UPDATE caFavorateMark SET Mark = @Mark
  7119. WHERE ID = @ID
  7120. AND caMainID IN (
  7121. SELECT caMainID FROM caMain WITH(NOLOCK)
  7122. WHERE cpMainID = (SELECT cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID)
  7123. )
  7124. RETURN @ID
  7125. END
  7126. ELSE
  7127. BEGIN
  7128. INSERT INTO caFavorateMark(caMainID, Mark) VALUES(@caMainID, @Mark)
  7129. RETURN @@IDENTITY
  7130. END
  7131. END
  7132. GO
  7133. /****** Object: StoredProcedure [dbo].[cccaFavorateMarkSelect] Script Date: 2018/12/13 19:05:55 ******/
  7134. SET ANSI_NULLS ON
  7135. GO
  7136. SET QUOTED_IDENTIFIER ON
  7137. GO
  7138. CREATE PROCEDURE [dbo].[cccaFavorateMarkSelect]
  7139. (
  7140. @ID INT
  7141. )
  7142. AS
  7143. BEGIN
  7144. SELECT ID, caMainID, Mark, AddDate
  7145. FROM caFavorateMark
  7146. WHERE ID = @ID
  7147. END
  7148. GO
  7149. /****** Object: StoredProcedure [dbo].[cccaFavorateSelect] Script Date: 2018/12/13 19:05:55 ******/
  7150. SET ANSI_NULLS ON
  7151. GO
  7152. SET QUOTED_IDENTIFIER ON
  7153. GO
  7154. --#####################################################
  7155. --修改:
  7156. -- 2015-6-3 mice 123 修改管理员类型的ca可以查看子账号收藏的简历
  7157. -- 2016-01-08 nick 加入是否绑定微信
  7158. --#####################################################
  7159. CREATE PROCEDURE [dbo].[cccaFavorateSelect]
  7160. (
  7161. @WHERE VARCHAR(1000),
  7162. @Order VARCHAR(100),
  7163. @Page SMALLINT,
  7164. @cpMainID INT,
  7165. @caMainID INT
  7166. )
  7167. AS
  7168. SET NOCOUNT ON
  7169. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE Id = @caMainId AND cpMainId = @cpMainId)
  7170. RETURN
  7171. BEGIN
  7172. SELECT @Where = dbo.SafeSql(@Where), @ORDER = dbo.SafeSql(@Order)
  7173. DECLARE @SQL AS VARCHAR(2000)
  7174. CREATE TABLE #T(
  7175. TitleID BIGINT,
  7176. ID INT,
  7177. JobID INT,
  7178. cvMainID INT,
  7179. caFavorateMarkID INT,
  7180. Degree TINYINT,
  7181. RelatedWorkYears TINYINT,
  7182. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  7183. IsNameHidden BIT,
  7184. LivePlace VARCHAR(6) COLLATE Chinese_PRC_CI_AS,
  7185. Gender BIT,
  7186. paName NVARCHAR(20),
  7187. BirthDay INT,
  7188. HasPhoto TINYINT,
  7189. adddate SMALLDATETIME,
  7190. Valid TINYINT,
  7191. IsViewed BIT,
  7192. HasJobApply BIT,
  7193. HasInterview BIT,
  7194. HasRemark BIT,
  7195. cvEducationID INT,
  7196. College NVARCHAR(50),
  7197. EduType TINYINT,
  7198. MajorName NVARCHAR(20),
  7199. Graduation INT,
  7200. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  7201. Experience VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  7202. MobileVerifyDate SMALLDATETIME,
  7203. IsOnline BIT,
  7204. HasWeiXin BIT,
  7205. paMainId INT,
  7206. SecondId VARCHAR(10),
  7207. Mobile VARCHAR(15),
  7208. Email VARCHAR(100),
  7209. ContactPrivi BIT
  7210. )
  7211. --ca的类型: 1 管理员 2 普通用户
  7212. DECLARE @AccountType AS TINYINT
  7213. SELECT @AccountType = AccountType FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  7214. SET @SQL='
  7215. INSERT INTO #T(
  7216. TitleID, ID, JobID, cvMainID, caFavorateMarkID, Degree, RelatedWorkYears,
  7217. Attachment, IsNameHidden, LivePlace, Gender, paName, BirthDay, HasPhoto, adddate,
  7218. Valid, MobileVerifyDate, IsOnline, paMainId, SecondId
  7219. )
  7220. SELECT ROW_NUMBER() OVER (ORDER BY ' + @ORDER + ') AS TitleID,
  7221. a.ID, a.JobID, a.cvMainID, a.caFavorateMarkID,
  7222. b.Degree, b.RelatedWorkYears, b.Attachment, b.IsNameHidden,
  7223. c.LivePlace, c.Gender, c.Name AS paName, c.BirthDay, c.HasPhoto,
  7224. a.adddate, b.Valid, c.MobileVerifyDate, dbo.GetPaOnlineStatus(c.ID),
  7225. b.paMainId, b.SecondId
  7226. FROM caFavorate a WITH(NOLOCK)
  7227. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  7228. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  7229. INNER JOIN Job d WITH(NOLOCK) ON d.ID = a.JobID
  7230. WHERE d.IsDelete = 0 '
  7231. --add by mice 123 ca中的管理员可以查看子账号收藏的简历
  7232. IF @AccountType = 1
  7233. BEGIN
  7234. SET @SQL = @SQL + ' AND a.caMainID IN ( SELECT ID FROM caMain WHERE cpMainID = ' + LTRIM(STR(@cpMainID)) + ' AND IsDelete = 0 AND IsPause = 0 ) '
  7235. END
  7236. ELSE
  7237. BEGIN
  7238. SET @SQL = @SQL + ' AND a.JobId IN(SELECT Id FROM Job WITH(NOLOCK) WHERE caMainID = ' + LTRIM(STR(@caMainID)) + ')'
  7239. END
  7240. IF LEN(@WHERE) > 0
  7241. SET @SQL = @SQL + @WHERE
  7242. --PRINT @sql
  7243. EXEC(@SQL)
  7244. IF(@Page < 1)
  7245. SET @Page = 1
  7246. IF NOT EXISTS(SELECT 'x' FROM #t WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20)
  7247. SET @Page = 1
  7248. UPDATE #T SET paName = LEFT(dbo.GetPersonName(cvMainID, @cpMainID), 20),
  7249. IsViewed = (SELECT TOP 1 '1' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID=#T.cvMainID AND caMainID=@caMainID),
  7250. HasJobApply = (SELECT TOP 1 '1' FROM exJobApply a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  7251. HasInterview = (SELECT TOP 1 '1' FROM exInterview a WITH(NOLOCK) INNER JOIN Job b WITH(NOLOCK) ON a.JobID=b.ID WHERE a.CompanyDeleted=0 AND b.caMainID=@caMainID AND cvMainID=#T.cvMainID),
  7252. HasRemark = (SELECT TOP 1 '1' FROM caCvRemark WITH(NOLOCK) WHERE caMainID=@caMainID AND cvMainID=#T.cvMainID)
  7253. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7254. UPDATE #T SET Speciality = (
  7255. SELECT Speciality FROM cvMain WITH(NOLOCK)
  7256. WHERE cvMain.ID = #T.cvMainID)
  7257. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7258. UPDATE #T SET Experience = (
  7259. SELECT TOP 1 ISNULL(Description, DescriptionEng) FROM cvExperience WITH(NOLOCK)
  7260. WHERE cvExperience.cvMainID = #T.cvMainID
  7261. ORDER BY BeginDate DESC)
  7262. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7263. UPDATE #T SET cvEducationID = (
  7264. SELECT TOP 1 ID FROM cvEducation WITH(NOLOCK)
  7265. WHERE cvEducation.cvMainID = #T.cvMainID
  7266. AND #T.Degree = cvEducation.Degree
  7267. ORDER BY Graduation DESC)
  7268. WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7269. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  7270. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  7271. FROM #T a, cvEducation b WITH(NOLOCK)
  7272. WHERE b.ID = a.cvEducationID AND a.TitleID > (@Page-1)*20 AND a.TitleID <= @Page*20
  7273. UPDATE a SET Email = b.Email,Mobile = b.Mobile,ContactPrivi = dbo.CheckCvPrivi(a.cvMainID,@cpMainID)
  7274. FROM #T a,PaMain b WITH(NOLOCK)
  7275. WHERE b.id = a.paMainID AND a.TitleID > (@Page-1)*20 AND a. TitleID <= @Page*20
  7276. --修改是否绑定微信
  7277. UPDATE a SET HasWeiXin = 1
  7278. FROM #T a, WxFans b WITH(NOLOCK), CvMain c WITH(NOLOCK)
  7279. WHERE a.CvMainID = c.ID
  7280. AND c.PaMainID = b.PaMainID
  7281. AND b.Status = 2
  7282. AND a.TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7283. SELECT COUNT(*) FROM #T WITH(NOLOCK)
  7284. SELECT * FROM #T WITH(NOLOCK) WHERE TitleID > (@Page-1)*20 AND TitleID <= @Page*20
  7285. DROP TABLE #T
  7286. END
  7287. GO
  7288. /****** Object: StoredProcedure [dbo].[cccaFavorateUpdate] Script Date: 2018/12/13 19:05:55 ******/
  7289. SET ANSI_NULLS ON
  7290. GO
  7291. SET QUOTED_IDENTIFIER ON
  7292. GO
  7293. CREATE PROCEDURE [dbo].[cccaFavorateUpdate]
  7294. (
  7295. @AllID VARCHAR(1000),
  7296. @MarkID INT,
  7297. @cpMainId INT
  7298. )
  7299. AS
  7300. BEGIN
  7301. SET @AllID = dbo.FormatIDS(@AllID)
  7302. DECLARE @NewMarkID AS VARCHAR(2000)
  7303. IF @MarkID > 0
  7304. SET @NewMarkID = LTRIM(STR(@MarkID))
  7305. ELSE
  7306. SET @NewMarkID = NULL
  7307. DECLARE @T AS TABLE(ID INT)
  7308. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  7309. UPDATE caFavorate SET caFavorateMarkID = @NewMarkID
  7310. WHERE ID IN(SELECT ID FROM @T)
  7311. AND caMainID IN(SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  7312. END
  7313. GO
  7314. /****** Object: StoredProcedure [dbo].[ccCaFeedBackByCaMainIDSelect] Script Date: 2018/12/13 19:05:56 ******/
  7315. SET ANSI_NULLS ON
  7316. GO
  7317. SET QUOTED_IDENTIFIER ON
  7318. GO
  7319. CREATE PROCEDURE [dbo].[ccCaFeedBackByCaMainIDSelect]
  7320. @CaMainID INT
  7321. AS
  7322. BEGIN
  7323. SELECT
  7324. *
  7325. FROM CaFeedBack WITH(NOLOCK)
  7326. WHERE caMainID = @caMainID
  7327. ORDER BY ID DESC
  7328. END
  7329. GO
  7330. /****** Object: StoredProcedure [dbo].[ccCaFeedBackByCpMainIDSelect] Script Date: 2018/12/13 19:05:56 ******/
  7331. SET ANSI_NULLS ON
  7332. GO
  7333. SET QUOTED_IDENTIFIER ON
  7334. GO
  7335. CREATE PROCEDURE [dbo].[ccCaFeedBackByCpMainIDSelect]
  7336. @CpMainID INT
  7337. AS
  7338. BEGIN
  7339. SELECT
  7340. a.*,b.Name caNAme
  7341. FROM CaFeedBack a WITH(NOLOCK) , caMain b WITH(NOLOCK)
  7342. WHERE a.caMainID = b.ID
  7343. AND b.cpMainID = @cpMainID
  7344. AND b.isDelete = 0
  7345. ORDER BY a.ID DESC
  7346. END
  7347. GO
  7348. /****** Object: StoredProcedure [dbo].[ccCaFeedBackInsert] Script Date: 2018/12/13 19:05:57 ******/
  7349. SET ANSI_NULLS ON
  7350. GO
  7351. SET QUOTED_IDENTIFIER ON
  7352. GO
  7353. CREATE PROCEDURE [dbo].[ccCaFeedBackInsert]
  7354. (
  7355. @caMainID INT,
  7356. @dcProvinceID INT,
  7357. @IP VARCHAR(31),
  7358. @Name VARCHAR(100),
  7359. @Telephone VARCHAR(50),
  7360. @Email VARCHAR(100),
  7361. @Message VARCHAR(4000)
  7362. )
  7363. AS
  7364. BEGIN TRY
  7365. SET @Telephone = dbo.TrimNull(@Telephone)
  7366. INSERT INTO CaFeedBack
  7367. (caMainID,dcProvinceID,IP,Name,Telephone,Email,Message,AddDate)
  7368. VALUES
  7369. (@caMainID,@dcProvinceID,@IP,@Name,@Telephone,@Email,@Message,GETDATE())
  7370. END TRY
  7371. BEGIN CATCH
  7372. GOTO ERR
  7373. END CATCH
  7374. RETURN 1
  7375. ERR:
  7376. BEGIN
  7377. RETURN 0
  7378. END
  7379. GO
  7380. /****** Object: StoredProcedure [dbo].[ccCaFeedBackNoViewSelect] Script Date: 2018/12/13 19:05:58 ******/
  7381. SET ANSI_NULLS ON
  7382. GO
  7383. SET QUOTED_IDENTIFIER ON
  7384. GO
  7385. CREATE PROCEDURE [dbo].[ccCaFeedBackNoViewSelect]
  7386. @CaMainID INT
  7387. AS
  7388. BEGIN
  7389. SELECT
  7390. *
  7391. FROM CaFeedBack WITH(NOLOCK)
  7392. WHERE caMainID = @caMainID
  7393. AND IsReply = 1
  7394. AND ViewDate IS NULL
  7395. ORDER BY ID DESC
  7396. END
  7397. GO
  7398. /****** Object: StoredProcedure [dbo].[ccCaFeedBackViewDateUpdate] Script Date: 2018/12/13 19:05:58 ******/
  7399. SET ANSI_NULLS ON
  7400. GO
  7401. SET QUOTED_IDENTIFIER ON
  7402. GO
  7403. --asp中取所有viewDate is null的id
  7404. CREATE PROCEDURE [dbo].[ccCaFeedBackViewDateUpdate]
  7405. (
  7406. @Ids VARCHAR(200),
  7407. @caMainID INT
  7408. )
  7409. AS
  7410. BEGIN TRY
  7411. SET @Ids = dbo.FormatIDS(@Ids)
  7412. DECLARE @T AS TABLE(ID INT)
  7413. INSERT INTO @T SELECT * FROM dbo.fnSplit(@Ids, ',')
  7414. UPDATE CaFeedBack SET ViewDate=GETDATE() WHERE ID IN(SELECT ID FROM @T) AND caMainID = @caMainID
  7415. RETURN 1
  7416. END TRY
  7417. BEGIN CATCH
  7418. RETURN 0
  7419. END CATCH
  7420. GO
  7421. /****** Object: StoredProcedure [dbo].[ccCaFeePageViewLogInsert] Script Date: 2018/12/13 19:05:59 ******/
  7422. SET ANSI_NULLS ON
  7423. GO
  7424. SET QUOTED_IDENTIFIER ON
  7425. GO
  7426. --##########################################
  7427. --间隔1小时,记录一次点击事件
  7428. --##########################################
  7429. CREATE PROCEDURE [dbo].[ccCaFeePageViewLogInsert]
  7430. (
  7431. @caMainID INT,
  7432. @PageID INT
  7433. )
  7434. AS
  7435. BEGIN
  7436. IF NOT EXISTS(
  7437. SELECT 'x'
  7438. FROM caFeePageViewLog WITH(NOLOCK)
  7439. WHERE caMainID = @caMainID
  7440. AND FeePageID = @PageID
  7441. AND AddDate > DATEADD(HOUR, -1, GETDATE()))
  7442. INSERT INTO caFeePageViewLog(caMainID, FeePageId)
  7443. VALUES(@caMainID, @PageID)
  7444. RETURN 1
  7445. END
  7446. GO
  7447. /****** Object: StoredProcedure [dbo].[ccCaGetPasswordLogByMailSelect] Script Date: 2018/12/13 19:05:59 ******/
  7448. SET ANSI_NULLS ON
  7449. GO
  7450. SET QUOTED_IDENTIFIER ON
  7451. GO
  7452. --======================================
  7453. --一天之内一个账号不能查询超过5次
  7454. --一天之内一个ip不能超过20次
  7455. --======================================
  7456. CREATE PROCEDURE [dbo].[ccCaGetPasswordLogByMailSelect]
  7457. @caMainID INT,
  7458. @IP VARCHAR(31)
  7459. AS
  7460. BEGIN
  7461. DECLARE @d AS DATETIME
  7462. DECLARE @C AS INT
  7463. SET @d = CONVERT(DATETIME,(FLOOR(CONVERT(FLOAT,GETDATE()))))
  7464. SELECT @C = COUNT(1) FROM caGetPasswordLog WITH(NOLOCK) WHERE caMainID = @caMainID AND AddDate>=@d
  7465. IF @c >4
  7466. GOTO Err1
  7467. SELECT @C = COUNT(1) FROM caGetPasswordLog WITH(NOLOCK) WHERE IP = @IP AND AddDate>=@d
  7468. IF @c > 20
  7469. GOTO Err2
  7470. RETURN 1
  7471. END
  7472. Err1:
  7473. BEGIN
  7474. RETURN -1
  7475. END
  7476. Err2:
  7477. BEGIN
  7478. RETURN -2
  7479. END
  7480. GO
  7481. /****** Object: StoredProcedure [dbo].[cccaGetPasswordLogByUniqueIDUpdate] Script Date: 2018/12/13 19:05:59 ******/
  7482. SET ANSI_NULLS ON
  7483. GO
  7484. SET QUOTED_IDENTIFIER ON
  7485. GO
  7486. --#####################################################
  7487. --创建时间:2014.10.30
  7488. --创建人:Nick
  7489. --说明:修改取回密碼的状态 重置密码成功后就修改一下状态(IsReset)
  7490. --#####################################################
  7491. CREATE PROCEDURE [dbo].[cccaGetPasswordLogByUniqueIDUpdate]
  7492. (
  7493. @UniqueId VARCHAR(50)
  7494. )
  7495. AS
  7496. BEGIN TRY
  7497. UPDATE caGetPasswordLog SET IsReset=1
  7498. WHERE AskNo=(SELECT TOP 1 AskNo FROM caGetPasswordLog WITH(NOLOCK) WHERE UniqueID = @UniqueId )
  7499. RETURN 1
  7500. END TRY
  7501. BEGIN CATCH
  7502. RETURN 0
  7503. END CATCH
  7504. GO
  7505. /****** Object: StoredProcedure [dbo].[cccaGetPasswordLogSelect] Script Date: 2018/12/13 19:05:59 ******/
  7506. SET ANSI_NULLS ON
  7507. GO
  7508. SET QUOTED_IDENTIFIER ON
  7509. GO
  7510. --#####################################################
  7511. --创建时间:2014.10.30
  7512. --创建人:Nick
  7513. --说明:获取企业取回密码记录
  7514. --#####################################################
  7515. CREATE PROCEDURE [dbo].[cccaGetPasswordLogSelect]
  7516. (
  7517. @UniqueType VARCHAR(10),
  7518. @UniqueId VARCHAR(50)
  7519. )
  7520. AS
  7521. BEGIN TRY
  7522. IF @UniqueType = '1'
  7523. BEGIN
  7524. SELECT * FROM caGetPasswordLog WITH(NOLOCK)
  7525. WHERE UniqueID = @UniqueId AND AddDate > DATEADD(MINUTE, -60, GETDATE()) AND IsReset IS NULL
  7526. END
  7527. ELSE
  7528. BEGIN
  7529. SELECT * FROM caGetPasswordLog WITH(NOLOCK)
  7530. WHERE askNo = @UniqueId AND AddDate > DATEADD(MINUTE, -60, GETDATE()) AND IsReset IS NULL
  7531. END
  7532. END TRY
  7533. BEGIN CATCH
  7534. RETURN 0
  7535. END CATCH
  7536. GO
  7537. /****** Object: StoredProcedure [dbo].[cccaGetsecondPasswordLogSelect] Script Date: 2018/12/13 19:05:59 ******/
  7538. SET ANSI_NULLS ON
  7539. GO
  7540. SET QUOTED_IDENTIFIER ON
  7541. GO
  7542. --#####################################################
  7543. --创建时间:2014.10.30
  7544. --创建人:Nick
  7545. --说明:验证激活码
  7546. --#####################################################
  7547. CREATE PROCEDURE [dbo].[cccaGetsecondPasswordLogSelect]
  7548. (
  7549. @caSafePasswordUniqueId VARCHAR(50)
  7550. )
  7551. AS
  7552. BEGIN TRY
  7553. SELECT TOP 10 *
  7554. FROM caGetsecondPasswordLog WITH(NOLOCK)
  7555. WHERE UniqueId = @caSafePasswordUniqueId
  7556. AND IsReset is null
  7557. END TRY
  7558. BEGIN CATCH
  7559. RETURN 0
  7560. END CATCH
  7561. GO
  7562. /****** Object: StoredProcedure [dbo].[ccCaInterviewTemplateByCaMainIDSelect] Script Date: 2018/12/13 19:05:59 ******/
  7563. SET ANSI_NULLS ON
  7564. GO
  7565. SET QUOTED_IDENTIFIER ON
  7566. GO
  7567. CREATE PROCEDURE [dbo].[ccCaInterviewTemplateByCaMainIDSelect]
  7568. @caMainID INT
  7569. AS
  7570. BEGIN
  7571. SELECT
  7572. ID,
  7573. Title,
  7574. InterviewDate,
  7575. InterViewPlace,
  7576. LinkMan,
  7577. Telephone,
  7578. Remark,
  7579. AddDate
  7580. FROM CaInterviewTemplate WITH(NOLOCK)
  7581. WHERE caMainID = @caMainID
  7582. END
  7583. GO
  7584. /****** Object: StoredProcedure [dbo].[ccCaInterviewTemplateDelete] Script Date: 2018/12/13 19:06:00 ******/
  7585. SET ANSI_NULLS ON
  7586. GO
  7587. SET QUOTED_IDENTIFIER ON
  7588. GO
  7589. --Lambo 20101130 修改
  7590. --增加cpMainID参数,判断是否是本企业的
  7591. CREATE PROCEDURE [dbo].[ccCaInterviewTemplateDelete]
  7592. @ID INT,
  7593. @cpMainID INT
  7594. AS
  7595. BEGIN
  7596. DELETE FROM CaInterviewTemplate
  7597. WHERE ID=@ID
  7598. AND caMainID IN
  7599. (SELECT ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  7600. END
  7601. GO
  7602. /****** Object: StoredProcedure [dbo].[ccCaInterviewTemplateSave] Script Date: 2018/12/13 19:06:00 ******/
  7603. SET ANSI_NULLS ON
  7604. GO
  7605. SET QUOTED_IDENTIFIER ON
  7606. GO
  7607. --Lambo 20101130 修改
  7608. --update语句后面增加本账户的条件
  7609. CREATE PROCEDURE [dbo].[ccCaInterviewTemplateSave]
  7610. @ID INT,
  7611. @caMainID INT,
  7612. @Title VARCHAR(20),
  7613. @InterviewDate VARCHAR(100),
  7614. @InterViewPlace VARCHAR(200),
  7615. @LinkMan VARCHAR(12),
  7616. @Telephone VARCHAR(20),
  7617. @Remark VARCHAR(1000)
  7618. AS
  7619. DECLARE @MaxID AS INT
  7620. BEGIN TRY
  7621. IF @ID > 0
  7622. BEGIN
  7623. UPDATE CaInterviewTemplate SET
  7624. Title=@Title,
  7625. InterviewDate = @InterviewDate,
  7626. InterViewPlace = @InterViewPlace,
  7627. LinkMan = @LinkMan,
  7628. Telephone = @Telephone,
  7629. Remark = @Remark,
  7630. AddDate = GETDATE()
  7631. WHERE ID=@ID
  7632. AND caMainID IN (SELECT caMainID FROM caMain WITH(NOLOCK) WHERE cpMainID = (SELECT cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID))
  7633. SET @MaxID = @ID
  7634. END
  7635. ELSE
  7636. BEGIN
  7637. INSERT INTO CaInterviewTemplate
  7638. (caMainID,Title,InterviewDate,InterViewPlace,LinkMan,Telephone,Remark)
  7639. VALUES(@caMainID,@Title,@InterviewDate,@InterViewPlace,@LinkMan,@Telephone,@Remark)
  7640. SET @MaxID=@@IDENTITY
  7641. END
  7642. END TRY
  7643. BEGIN CATCH
  7644. GOTO ERR
  7645. END CATCH
  7646. RETURN @MaxID
  7647. ERR:
  7648. BEGIN
  7649. RETURN 0
  7650. END
  7651. GO
  7652. /****** Object: StoredProcedure [dbo].[ccCaInterviewTemplateSelect] Script Date: 2018/12/13 19:06:00 ******/
  7653. SET ANSI_NULLS ON
  7654. GO
  7655. SET QUOTED_IDENTIFIER ON
  7656. GO
  7657. CREATE PROCEDURE [dbo].[ccCaInterviewTemplateSelect]
  7658. @ID INT
  7659. AS
  7660. BEGIN
  7661. SELECT
  7662. Title,
  7663. caMainID,
  7664. InterviewDate,
  7665. InterViewPlace,
  7666. LinkMan,
  7667. Telephone,
  7668. Remark,
  7669. AddDate
  7670. FROM CaInterviewTemplate WITH(NOLOCK)
  7671. WHERE ID = @ID
  7672. END
  7673. GO
  7674. /****** Object: StoredProcedure [dbo].[cccaJobCvMatchSelect] Script Date: 2018/12/13 19:06:00 ******/
  7675. SET ANSI_NULLS ON
  7676. GO
  7677. SET QUOTED_IDENTIFIER ON
  7678. GO
  7679. ---------------
  7680. --创建人Peter
  7681. --时间 2016-10-17
  7682. --根据职位ID获取推荐简历
  7683. CREATE PROCEDURE [dbo].[cccaJobCvMatchSelect]
  7684. (
  7685. @JobID INT,
  7686. @caMainId INT
  7687. )
  7688. AS
  7689. SET NOCOUNT ON
  7690. INSERT INTO ProcLog SELECT 'cccaJobCvMatchSelect', @JobId, GETDATE()
  7691. BEGIN
  7692. DECLARE @T_CvList AS TABLE(
  7693. ID INT,
  7694. cvEducationID INT,
  7695. dcMajorID INT,
  7696. Degree TINYINT,
  7697. RelatedWorkYears INT,
  7698. dcSalaryID TINYINT,
  7699. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  7700. RefreshDate SMALLDATETIME,
  7701. LastLoginDate SMALLDATETIME,
  7702. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  7703. Gender BIT,
  7704. BirthDay INT,
  7705. LivePlace INT,
  7706. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  7707. HasPhoto TINYINT,
  7708. College NVARCHAR(50),
  7709. EduType TINYINT,
  7710. MajorName NVARCHAR(20),
  7711. Graduation INT,
  7712. HasViewed BIT,
  7713. ViewDate SMALLDATETIME,
  7714. HasRemarked BIT,
  7715. LastJobTypeID INT,
  7716. Valid TINYINT,
  7717. IsOnline BIT,
  7718. HasWeiXin BIT,
  7719. JobRecommendDate SMALLDATETIME,
  7720. JobId INT,
  7721. BelongJobName NVARCHAR(50),
  7722. paMainId INT,
  7723. SecondId VARCHAR(10)
  7724. )
  7725. IF(@caMainId > 0)
  7726. BEGIN
  7727. INSERT INTO @T_CvList(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, Speciality,
  7728. RefreshDate, LastLoginDate, JobName, Gender, BirthDay, LivePlace, LastJobTypeID, Attachment,
  7729. HasPhoto, HasViewed, HasRemarked, Valid, IsOnline, JobRecommendDate, JobId, paMainId, SecondId)
  7730. SELECT a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, ISNULL(a.Speciality, a.SpecialityEng) Speciality,
  7731. a.RefreshDate, j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, j.Gender, j.BirthDay, j.LivePlace, a.LastJobTypeID, a.Attachment,
  7732. j.HasPhoto, 0, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), b.AddDate, b.JobId, a.paMainId, a.SecondId
  7733. FROM cvMainPublish a WITH(NOLOCK)
  7734. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID = j.ID
  7735. INNER JOIN caJobCvMatch b ON a.id = b.MatchcvMainID
  7736. WHERE b.JobID IN(SELECT Id FROM JobPublish WITH(NOLOCK) WHERE caMainId = @caMainId AND Valid = 1)
  7737. ORDER BY b.ID DESC
  7738. END
  7739. ELSE
  7740. BEGIN
  7741. INSERT INTO @T_CvList(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, Speciality,
  7742. RefreshDate, LastLoginDate, JobName, Gender, BirthDay, LivePlace, LastJobTypeID,
  7743. Attachment, HasPhoto, HasViewed, HasRemarked, Valid, IsOnline, JobRecommendDate, JobId, paMainId, SecondId)
  7744. SELECT a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, ISNULL(a.Speciality, a.SpecialityEng) Speciality,
  7745. a.RefreshDate, j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, j.Gender, j.BirthDay, j.LivePlace, a.LastJobTypeID,
  7746. a.Attachment, j.HasPhoto, 0, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), b.AddDate, b.JobId, a.paMainId, a.SecondId
  7747. FROM cvMainPublish a WITH(NOLOCK)
  7748. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID = j.ID
  7749. INNER JOIN caJobCvMatch b ON a.id = b.MatchcvMainID
  7750. WHERE b.JobID = @JobID
  7751. ORDER BY b.ID DESC
  7752. END
  7753. UPDATE a SET a.cvEducationID = (
  7754. SELECT TOP 1 ID FROM cvEducationPublish WITH(NOLOCK)
  7755. WHERE cvEducationPublish.cvMainID = a.ID
  7756. AND a.Degree = cvEducationPublish.Degree
  7757. ORDER BY Graduation DESC)
  7758. FROM @T_CvList a
  7759. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  7760. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  7761. FROM @T_CvList a, cvEducationPublish b WITH(NOLOCK)
  7762. WHERE b.ID = a.cvEducationID
  7763. --修改是否绑定微信
  7764. UPDATE a SET HasWeiXin = 1
  7765. FROM @T_CvList a, WxFans b WITH(NOLOCK), cvMainPublish c WITH(NOLOCK)
  7766. WHERE a.ID = c.ID
  7767. AND c.PaMainID = b.PaMainID
  7768. AND b.Status = 2
  7769. IF(ISNULL(@caMainId, 0) = 0)
  7770. SELECT @caMainID = caMainID FROM JobPublish WITH(NOLOCK) WHERE ID = @JobID
  7771. UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
  7772. FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
  7773. WHERE b.cvMainID = a.ID AND caMainID = @caMainID
  7774. UPDATE @T_CvList SET BelongJobName = (SELECT Name FROM Job WHERE Id = JobId)
  7775. SELECT * FROM @T_CvList ORDER BY JobRecommendDate DESC
  7776. END
  7777. GO
  7778. /****** Object: StoredProcedure [dbo].[cccaJobCvMatchSelect2] Script Date: 2018/12/13 19:06:00 ******/
  7779. SET ANSI_NULLS ON
  7780. GO
  7781. SET QUOTED_IDENTIFIER ON
  7782. GO
  7783. ---------------
  7784. --创建人Peter
  7785. --时间 2016-10-17
  7786. --根据职位ID获取推荐简历
  7787. CREATE PROCEDURE [dbo].[cccaJobCvMatchSelect2]
  7788. (
  7789. @JobID INT,
  7790. @caMainId INT
  7791. )
  7792. AS
  7793. SET NOCOUNT ON
  7794. INSERT INTO ProcLog SELECT 'cccaJobCvMatchSelect2', @JobId, GETDATE()
  7795. BEGIN
  7796. DECLARE @T_CvList AS TABLE(
  7797. ID INT,
  7798. cvEducationID INT,
  7799. dcMajorID INT,
  7800. Degree TINYINT,
  7801. RelatedWorkYears INT,
  7802. dcSalaryID TINYINT,
  7803. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  7804. RefreshDate SMALLDATETIME,
  7805. LastLoginDate SMALLDATETIME,
  7806. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  7807. Gender BIT,
  7808. BirthDay INT,
  7809. LivePlace INT,
  7810. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  7811. HasPhoto TINYINT,
  7812. College NVARCHAR(50),
  7813. EduType TINYINT,
  7814. MajorName NVARCHAR(20),
  7815. Graduation INT,
  7816. HasViewed BIT,
  7817. ViewDate SMALLDATETIME,
  7818. HasRemarked BIT,
  7819. LastJobTypeID INT,
  7820. Valid TINYINT,
  7821. IsOnline BIT,
  7822. HasWeiXin BIT,
  7823. JobRecommendDate SMALLDATETIME,
  7824. JobId INT,
  7825. BelongJobName NVARCHAR(50),
  7826. paMainId INT,
  7827. SecondId VARCHAR(10)
  7828. )
  7829. IF(@caMainId > 0)
  7830. BEGIN
  7831. INSERT INTO @T_CvList(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, Speciality,
  7832. RefreshDate, LastLoginDate, JobName, Gender, BirthDay, LivePlace, LastJobTypeID, Attachment,
  7833. HasPhoto, HasViewed, HasRemarked, Valid, IsOnline, JobRecommendDate, JobId, paMainId, SecondId)
  7834. SELECT a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, ISNULL(a.Speciality, a.SpecialityEng) Speciality,
  7835. a.RefreshDate, j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, j.Gender, j.BirthDay, j.LivePlace, a.LastJobTypeID, a.Attachment,
  7836. j.HasPhoto, 0, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), b.AddDate, b.JobId, a.paMainId, a.SecondId
  7837. FROM cvMainPublish a WITH(NOLOCK)
  7838. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID = j.ID
  7839. INNER JOIN caJobCvMatch b ON a.id = b.MatchcvMainID
  7840. WHERE b.JobID IN(SELECT Id FROM JobPublish WITH(NOLOCK) WHERE caMainId = @caMainId AND Valid = 1)
  7841. ORDER BY b.ID DESC
  7842. END
  7843. ELSE
  7844. BEGIN
  7845. INSERT INTO @T_CvList(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, Speciality,
  7846. RefreshDate, LastLoginDate, JobName, Gender, BirthDay, LivePlace, LastJobTypeID,
  7847. Attachment, HasPhoto, HasViewed, HasRemarked, Valid, IsOnline, JobRecommendDate, JobId, paMainId, SecondId)
  7848. SELECT a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, ISNULL(a.Speciality, a.SpecialityEng) Speciality,
  7849. a.RefreshDate, j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, j.Gender, j.BirthDay, j.LivePlace, a.LastJobTypeID,
  7850. a.Attachment, j.HasPhoto, 0, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), b.AddDate, b.JobId, a.paMainId, a.SecondId
  7851. FROM cvMainPublish a WITH(NOLOCK)
  7852. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID = j.ID
  7853. INNER JOIN caJobCvMatch b ON a.id = b.MatchcvMainID
  7854. WHERE b.JobID = @JobID
  7855. ORDER BY b.ID DESC
  7856. END
  7857. UPDATE a SET a.cvEducationID = (
  7858. SELECT TOP 1 ID FROM cvEducationPublish WITH(NOLOCK)
  7859. WHERE cvEducationPublish.cvMainID = a.ID
  7860. AND a.Degree = cvEducationPublish.Degree
  7861. ORDER BY Graduation DESC)
  7862. FROM @T_CvList a
  7863. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  7864. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  7865. FROM @T_CvList a, cvEducationPublish b WITH(NOLOCK)
  7866. WHERE b.ID = a.cvEducationID
  7867. --修改是否绑定微信
  7868. UPDATE a SET HasWeiXin = 1
  7869. FROM @T_CvList a, WxFans b WITH(NOLOCK), cvMainPublish c WITH(NOLOCK)
  7870. WHERE a.ID = c.ID
  7871. AND c.PaMainID = b.PaMainID
  7872. AND b.Status = 2
  7873. IF(ISNULL(@caMainId, 0) = 0)
  7874. SELECT @caMainID = caMainID FROM JobPublish WITH(NOLOCK) WHERE ID = @JobID
  7875. UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
  7876. FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
  7877. WHERE b.cvMainID = a.ID AND caMainID = @caMainID
  7878. UPDATE @T_CvList SET BelongJobName = (SELECT Name FROM Job WHERE Id = JobId)
  7879. SELECT * FROM @T_CvList
  7880. END
  7881. GO
  7882. /****** Object: StoredProcedure [dbo].[ccCaJobRefreshLogSelect] Script Date: 2018/12/13 19:06:00 ******/
  7883. SET ANSI_NULLS ON
  7884. GO
  7885. SET QUOTED_IDENTIFIER ON
  7886. GO
  7887. --创建人harry
  7888. --2017-11-7
  7889. --获取职位刷新数记录
  7890. CREATE PROCEDURE [dbo].[ccCaJobRefreshLogSelect]
  7891. (
  7892. @cpMainID INT,
  7893. @orderID INT
  7894. )
  7895. AS
  7896. SET NOCOUNT ON
  7897. BEGIN
  7898. IF @orderID > 0
  7899. BEGIN
  7900. SELECT a.*, b.Name
  7901. FROM jobRefreshLog a WITH(NOLOCK)
  7902. LEFT JOIN caMain b WITH(NOLOCK) ON a.operateMan = b.Id
  7903. WHERE a.orderId = @orderID
  7904. AND a.runDateTime is NOT NULL
  7905. ORDER BY a.runDateTime DESC
  7906. END
  7907. ELSE
  7908. BEGIN
  7909. SELECT a.*, b.Name
  7910. FROM jobRefreshLog a WITH(NOLOCK)
  7911. LEFT JOIN caMain b WITH(NOLOCK) ON a.operateMan = b.Id
  7912. WHERE a.orderId IN(SELECT ID FROM caOrder WHERE cpMainID = @cpMainID AND orderType IN(8,15))
  7913. AND a.runDateTime is NOT NULL
  7914. ORDER by a.runDateTime DESC
  7915. END
  7916. END
  7917. SET NOCOUNT OFF
  7918. GO
  7919. /****** Object: StoredProcedure [dbo].[ccCaLoginLogByAutoInsert] Script Date: 2018/12/13 19:06:01 ******/
  7920. SET ANSI_NULLS ON
  7921. GO
  7922. SET QUOTED_IDENTIFIER ON
  7923. GO
  7924. CREATE PROCEDURE [dbo].[ccCaLoginLogByAutoInsert]
  7925. (
  7926. @caMainID INT,
  7927. @cpMainName NVARCHAR(60),
  7928. @caMainName NVARCHAR(12),
  7929. @LoginIP VARCHAR(15),
  7930. @Browser VARCHAR(500)
  7931. )
  7932. AS
  7933. --insert proclog select 'ccCaLoginLogByAutoInsert', @caMainID, getdate()
  7934. BEGIN
  7935. DECLARE @ID AS INT
  7936. IF NOT EXISTS(SELECT 'X' FROM caLoginLog WITH(NOLOCK)
  7937. WHERE caMainID = @caMainID
  7938. AND ADDDATE > CONVERT(VARCHAR(10), GETDATE(), 120))
  7939. BEGIN
  7940. INSERT INTO caLoginLog(caMainID, cpMainName, caMainName, LoginIP, AddDate, Browser, LoginFrom, LoginCookies)
  7941. VALUES(@caMainID, @cpMainName, @caMainName, @LoginIP, GETDATE(), @Browser, 0, 'mblAutoLogin')
  7942. SET @ID = @@IDENTITY
  7943. END
  7944. ELSE
  7945. SET @ID = 0
  7946. RETURN @ID
  7947. END
  7948. GO
  7949. /****** Object: StoredProcedure [dbo].[ccCaLoginLogByCaLastLoginDateSelect] Script Date: 2018/12/13 19:06:01 ******/
  7950. SET ANSI_NULLS ON
  7951. GO
  7952. SET QUOTED_IDENTIFIER ON
  7953. GO
  7954. --Lambo 20110211
  7955. --查询企业用户的上次登陆时间
  7956. CREATE PROCEDURE [dbo].[ccCaLoginLogByCaLastLoginDateSelect]
  7957. (
  7958. @caMainID INT
  7959. )
  7960. AS
  7961. BEGIN
  7962. -- DECLARE @AddDate AS SMALLDATETIME
  7963. -- SELECT TOP 1 @AddDate = AddDate
  7964. -- FROM caLoginLog WITH(NOLOCK) WHERE caMainID = @caMainID
  7965. -- ORDER BY ID DESC
  7966. --
  7967. -- IF @AddDate IS NULL
  7968. -- SELECT @AddDate = RegDate FROM caMain WITH(NOLOCK) WHERE Id = @caMainId
  7969. --
  7970. -- SELECT @AddDate AddDate
  7971. DECLARE @t AS TABLE(Id INT, AddDate SMALLDATETIME)
  7972. INSERT INTO @t
  7973. SELECT TOP 2 Id, AddDate
  7974. FROM caLoginLog WITH(NOLOCK)
  7975. WHERE caMainID = @caMainID
  7976. AND AddDate > DATEADD(MINUTE, -240, GETDATE())
  7977. ORDER BY ID DESC
  7978. IF @@ROWCOUNT = 0
  7979. INSERT @t SELECT 1, GETDATE()
  7980. SELECT * FROM @t ORDER BY ID DESC
  7981. END
  7982. GO
  7983. /****** Object: StoredProcedure [dbo].[ccCaLoginLogByCpMainIDSelect] Script Date: 2018/12/13 19:06:01 ******/
  7984. SET ANSI_NULLS ON
  7985. GO
  7986. SET QUOTED_IDENTIFIER ON
  7987. GO
  7988. -----------------------
  7989. --修改人:Lucifer
  7990. --修改时间:2010-9-27
  7991. --修改内容:增加了LoginCookies字段,后台的CompanyLoginLog中用到
  7992. -----------------------
  7993. CREATE PROCEDURE [dbo].[ccCaLoginLogByCpMainIDSelect]
  7994. (
  7995. @cpMainID INT
  7996. )
  7997. AS
  7998. BEGIN
  7999. SELECT TOP 200
  8000. a.ID,
  8001. a.caMainID,
  8002. a.cpMainName,
  8003. a.caMainName,
  8004. a.LoginIP,
  8005. a.browser,
  8006. a.AddDate,
  8007. b.cpMainID,
  8008. a.LoginCookies
  8009. FROM caLoginLog a WITH(NOLOCK), caMain b WITH(NOLOCK)
  8010. WHERE a.caMainID = b.ID
  8011. AND b.cpMainID = @cpMainID
  8012. AND b.IsDelete=0
  8013. ORDER BY a.ID DESC
  8014. END
  8015. GO
  8016. /****** Object: StoredProcedure [dbo].[ccCaLoginLogByIndexSelect] Script Date: 2018/12/13 19:06:02 ******/
  8017. SET ANSI_NULLS ON
  8018. GO
  8019. SET QUOTED_IDENTIFIER ON
  8020. GO
  8021. --创建:sean 用于用户登陆信息,index.asp页面显示
  8022. --本日登陆次数和上次登录信息
  8023. --修改:显示上次登录信息错误harry2017-4-19
  8024. --#########################333
  8025. CREATE PROCEDURE [dbo].[ccCaLoginLogByIndexSelect]
  8026. (
  8027. @caMainID INT
  8028. )
  8029. AS
  8030. SET NOCOUNT ON
  8031. BEGIN
  8032. DECLARE @TodayLoginNumber AS TINYINT
  8033. DECLARE @LoginIP AS VARCHAR(31)
  8034. DECLARE @AddDate AS SMALLDATETIME
  8035. SELECT @TodayLoginNumber = COUNT(1) FROM CaLoginLog WITH(NOLOCK)
  8036. WHERE caMainID = @caMainID
  8037. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  8038. SELECT TOP 1 @LoginIP = LoginIP, @AddDate = AddDate
  8039. FROM (
  8040. SELECT TOP 2 LoginIP, AddDate, ROW_NUMBER() OVER (ORDER BY ID DESC) AS RowNumber FROM caLoginLog WITH(NOLOCK)
  8041. WHERE caMainId = @caMainID
  8042. ORDER BY ID DESC) a
  8043. WHERE RowNumber = 1
  8044. IF ISNULL(@LoginIP, '') = ''
  8045. SELECT TOP 1 @LoginIP = LoginIP, @AddDate = AddDate FROM caLoginLog WITH(NOLOCK) WHERE caMainID = @caMainID ORDER BY ID DESC
  8046. SELECT @TodayLoginNumber AS TodayLoginNumber, @LoginIP AS LoginIP, @AddDate AS AddDate
  8047. END
  8048. GO
  8049. /****** Object: StoredProcedure [dbo].[ccCaLoginLogInsert] Script Date: 2018/12/13 19:06:02 ******/
  8050. SET ANSI_NULLS ON
  8051. GO
  8052. SET QUOTED_IDENTIFIER ON
  8053. GO
  8054. CREATE PROCEDURE [dbo].[ccCaLoginLogInsert]
  8055. (
  8056. @caMainID INT,
  8057. @cpMainName NVARCHAR(60),
  8058. @caMainName NVARCHAR(12),
  8059. @LoginIP VARCHAR(31)
  8060. )
  8061. AS
  8062. insert proclog select 'ccCaLoginLogInsert', @caMainID, getdate()
  8063. BEGIN
  8064. DECLARE @ID AS INT
  8065. INSERT INTO caLoginLog(caMainID, cpMainName, caMainName, LoginIP, AddDate, Browser)
  8066. VALUES(@caMainID, @cpMainName, @caMainName, @LoginIP, GETDATE(), '1:')
  8067. SET @ID = @@IDENTITY
  8068. RETURN @ID
  8069. END
  8070. GO
  8071. /****** Object: StoredProcedure [dbo].[ccCaLoginLogSelect] Script Date: 2018/12/13 19:06:02 ******/
  8072. SET ANSI_NULLS ON
  8073. GO
  8074. SET QUOTED_IDENTIFIER ON
  8075. GO
  8076. CREATE PROCEDURE [dbo].[ccCaLoginLogSelect]
  8077. (
  8078. @caMainID INT
  8079. )
  8080. AS
  8081. BEGIN
  8082. SELECT TOP 100
  8083. ID,
  8084. caMainID,
  8085. cpMainName,
  8086. caMainName,
  8087. LoginIP,
  8088. AddDate
  8089. FROM caLoginLog WITH(NOLOCK)
  8090. WHERE caMainID = @caMainID
  8091. ORDER BY ADDDATE DESC
  8092. END
  8093. GO
  8094. /****** Object: StoredProcedure [dbo].[ccCaMainByBackLoginUpdate] Script Date: 2018/12/13 19:06:02 ******/
  8095. SET ANSI_NULLS ON
  8096. GO
  8097. SET QUOTED_IDENTIFIER ON
  8098. GO
  8099. --***********************************************************
  8100. --返回值:
  8101. -- 0:未定义错误
  8102. -- -1:用户名、密码不正确
  8103. -- -2:验证码不正确
  8104. -- 正整数:正确的ID
  8105. --后台登陆用
  8106. --Lambo 20101113修改
  8107. --后台需要查看用户浏览单位记录,所以将删除过期数据的sql注释掉了
  8108. --***********************************************************
  8109. CREATE PROCEDURE [dbo].[ccCaMainByBackLoginUpdate]
  8110. (
  8111. @UID VARCHAR(20),
  8112. @caMainID INT,
  8113. @ProvinceID INT,
  8114. @SessionID INT
  8115. )
  8116. AS
  8117. BEGIN TRY
  8118. DECLARE @ID AS INT
  8119. SELECT TOP 1 @ID = ID
  8120. FROM BsCpBackLogin WITH(NOLOCK)
  8121. WHERE UnqueID=@UID
  8122. AND HasLogin = 0
  8123. AND caMainID=@caMainID
  8124. SELECT @ProvinceID = LEFT(@ProvinceID, 2)
  8125. IF @ID IS NOT NULL
  8126. BEGIN
  8127. UPDATE BsCpBackLogin SET HasLogin = 1 WHERE ID = @ID
  8128. DELETE FROM BsCpBackLogin WHERE AddDate < GETDATE()- 2
  8129. IF EXISTS(SELECT 'X' FROM caMain a WITH(NOLOCK),cpMain b
  8130. WHERE a.cpMainID = b.ID
  8131. AND a.IsDelete = 0
  8132. AND b.IsDelete=0
  8133. AND a.ID=@caMainID
  8134. AND LEFT(b.dcProvinceID, 2) = @ProvinceID
  8135. )
  8136. BEGIN
  8137. ----单点登录,后台不考虑单点登录
  8138. --DELETE FROM cpSession WHERE caMainID = @caMainID
  8139. --INSERT INTO cpSession(SessionID, caMainID, IP) VALUES(@SessionID, @caMainID, '后台登陆')
  8140. RETURN 1
  8141. END
  8142. ELSE
  8143. RETURN 0
  8144. END
  8145. END TRY
  8146. BEGIN CATCH
  8147. RETURN -1
  8148. END CATCH
  8149. GO
  8150. /****** Object: StoredProcedure [dbo].[ccCaMainByCpMainIDSelect] Script Date: 2018/12/13 19:06:02 ******/
  8151. SET ANSI_NULLS ON
  8152. GO
  8153. SET QUOTED_IDENTIFIER ON
  8154. GO
  8155. CREATE PROCEDURE [dbo].[ccCaMainByCpMainIDSelect]
  8156. @cpMainID INT
  8157. AS
  8158. BEGIN
  8159. SELECT *, (SELECT TOP 1 ID FROM paLoginContact WHERE paMainID = caMain.ID AND ContactType = 101) IsWeixinBind
  8160. FROM caMain WITH(NOLOCK)
  8161. WHERE cpMainID = @cpMainID AND IsDelete=0
  8162. ORDER BY AccountType,IsPause
  8163. END
  8164. GO
  8165. /****** Object: StoredProcedure [dbo].[ccCaMainByEMailExist] Script Date: 2018/12/13 19:06:02 ******/
  8166. SET ANSI_NULLS ON
  8167. GO
  8168. SET QUOTED_IDENTIFIER ON
  8169. GO
  8170. --==================================
  8171. --企业邮箱是否重复
  8172. --检查: sean 2010-10-22
  8173. --==================================
  8174. CREATE PROCEDURE [dbo].[ccCaMainByEMailExist]
  8175. (
  8176. @EMail VARCHAR(50)
  8177. )
  8178. AS
  8179. SET NOCOUNT ON
  8180. BEGIN
  8181. SET @EMail = LTRIM(RTRIM(@EMail))
  8182. IF EXISTS(SELECT 'X' FROM Company_Black WITH(NOLOCK) WHERE Email = @Email AND LEN(@Email) > 6)
  8183. BEGIN
  8184. UPDATE Company_Black SET RefuseCount = RefuseCount + 1
  8185. WHERE Email = @Email
  8186. RETURN 2 --邮件在黑名单
  8187. END
  8188. IF EXISTS(SELECT 'x' FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  8189. WHERE (b.RegisterMode = 0 Or b.RegisterMode = 11)
  8190. AND a.cpMainID = b.ID AND a.Email = @Email
  8191. AND b.Isdelete = 0 AND a.IsDelete = 0 AND a.AccountType = 1)
  8192. RETURN 1
  8193. RETURN 0
  8194. END
  8195. GO
  8196. /****** Object: StoredProcedure [dbo].[ccCaMainByGetPasswordSelect] Script Date: 2018/12/13 19:06:03 ******/
  8197. SET ANSI_NULLS ON
  8198. GO
  8199. SET QUOTED_IDENTIFIER ON
  8200. GO
  8201. ---- =============================================
  8202. ---- Author: Sean
  8203. ---- Create date: 2010-12-20
  8204. ---- Description: 取回密码 先检查用户名是否在camain,Company_Xixni。如果没有结果则检查是否有邮箱
  8205. ---- Update date: 2012-3-7
  8206. ---- Description: 增加取回前检查取回纪录,取回后增加纪录;增加手机查询
  8207. ---- =============================================
  8208. CREATE PROCEDURE [dbo].[ccCaMainByGetPasswordSelect]
  8209. (
  8210. @Username VARCHAR(50),
  8211. @Email VARCHAR(50),
  8212. @Mobile VARCHAR(11),
  8213. @IP VARCHAR(15),
  8214. @VerifyCode VARCHAR(10),
  8215. @SubSiteName VARCHAR(30)
  8216. )
  8217. AS
  8218. BEGIN
  8219. DECLARE @Cnt AS INT, @Type AS VARCHAR(10), @ToDay AS DATETIME, @QueryMobile AS INT
  8220. ----如果用户名、油箱、手机号都为空则返回
  8221. IF LEN(ISNULL(@Username, '')) = 0 AND LEN(ISNULL(@Email, '')) = 0 AND LEN(ISNULL(@Mobile, '')) = 0
  8222. GOTO Err3
  8223. --SET @Mobile = ''
  8224. DECLARE @t AS TABLE(
  8225. ID INT,
  8226. cpMainID INT,
  8227. Name NVARCHAR(50) NOT NULL,
  8228. UserName VARCHAR(50) NOT NULL,
  8229. Email VARCHAR(50) NOT NULL,
  8230. Gender NVARCHAR(10),
  8231. ConsultantID SMALLINT,
  8232. ConsultantName NVARCHAR(10),
  8233. ConsultantEmail VARCHAR(50),
  8234. Mobile VARCHAR(13),
  8235. ReturnType VARCHAR(10),
  8236. UniqueId VARCHAR(40),
  8237. ActivateCode VARCHAR(6),
  8238. AskNo VARCHAR(40)
  8239. )
  8240. SELECT @Type = 'Email', @QueryMobile = 0
  8241. IF dbo.IsMobile(@Mobile) = 1 ----手机号是否合法
  8242. BEGIN
  8243. SET @QueryMobile = 1 ----手机号合法,则优先使用手机查询
  8244. ----一周内手机取回密码次数
  8245. SELECT @Cnt = COUNT(DISTINCT AskNo) FROM caGetPasswordLog WITH(NOLOCK) WHERE Mobile = @Mobile AND AddDate > GETDATE() - 1
  8246. IF @Cnt >= 3 ----总数=0,按手机号取回
  8247. GOTO Err4
  8248. SET @Type = 'Mobile'
  8249. END
  8250. IF @Type = 'Email' ----按油箱、用户名取回
  8251. BEGIN
  8252. SET @ToDay = CONVERT(DATETIME, CONVERT(VARCHAR(8), GETDATE(), 112))
  8253. IF @QueryMobile = 1
  8254. BEGIN
  8255. ----一天之内手机号至多查询5次
  8256. SELECT @Cnt = COUNT(1) FROM caGetPasswordLog WITH(NOLOCK) WHERE Mobile = @Mobile AND AddDate > @Today
  8257. IF @Cnt > 4 ----一天之内一个手机号最多取回5次
  8258. GOTO Err1
  8259. END
  8260. ELSE
  8261. BEGIN
  8262. IF LEN(ISNULL(@Username, '')) > 0 ----用户名优先
  8263. BEGIN
  8264. SELECT @Cnt = COUNT(1) FROM caGetPasswordLog WITH(NOLOCK) WHERE Username = @Username AND AddDate > @Today
  8265. SET @Type = 'Username'
  8266. END
  8267. ELSE ----其次Email
  8268. SELECT @Cnt = COUNT(1) FROM caGetPasswordLog WITH(NOLOCK) WHERE Email = @Email AND AddDate > @Today
  8269. IF @Cnt > 4 ----一天之内一个账号最多取回5次
  8270. GOTO Err1
  8271. END
  8272. SELECT @Cnt = COUNT(1) FROM caGetPasswordLog WITH(NOLOCK) WHERE IP = @IP AND AddDate >= @Today
  8273. IF @Cnt > 20 ----一天之内一个ip不能超过20次
  8274. GOTO Err2
  8275. END
  8276. SELECT @Cnt = 0
  8277. IF @QueryMobile = 1 ----按照手机号查询
  8278. BEGIN
  8279. INSERT INTO @t(ID, cpMainId, Name, UserName, Email, Gender, Mobile)
  8280. SELECT TOP 10 ID, cpMainId, ISNULL(Name, ''), Username, Email, Gender, Mobile
  8281. FROM caMain WITH(NOLOCK INDEX(IX_caMain_Mobile))
  8282. WHERE Mobile = @Mobile
  8283. ORDER BY (SELECT MAX(AddDate) FROM caLoginLog WITH(NOLOCK) WHERE caMainID = caMain.ID) DESC
  8284. IF (SELECT COUNT(*) FROM @t) = 0 ----有值则返回
  8285. GOTO Err3
  8286. END
  8287. ELSE IF LEN(ISNULL(@Username, '')) > 0 ----如果有用户名则以用户名为主
  8288. BEGIN
  8289. SET @Type = 'Username'
  8290. ----caMain.UserName = @UserName 区分大小写
  8291. INSERT INTO @t(ID, cpMainId, Name, UserName, Email, Gender, Mobile)
  8292. SELECT ID, cpMainId, ISNULL(Name, ''), Username, Email, Gender, Mobile
  8293. FROM caMain WITH(NOLOCK INDEX(IX_caMain_UserName))
  8294. WHERE Username = @UserName
  8295. IF (SELECT COUNT(*) FROM @t) = 1 ----有值则返回
  8296. GOTO Retu
  8297. ----无值,不区分大小写
  8298. ----caMain.UserNameLower = @UserName
  8299. INSERT INTO @t(ID, cpMainId, Name, UserName, Email, Gender, Mobile)
  8300. SELECT ID, cpMainId, ISNULL(Name, ''), Username, Email, Gender, Mobile
  8301. FROM caMain WITH(NOLOCK INDEX(IX_caMain_UserNameLower))
  8302. WHERE UsernameLower = @UserName
  8303. IF (SELECT COUNT(*) FROM @t) > 0 ----有值则返回
  8304. GOTO Retu
  8305. ----无值,再查询Company_Xinxi 区分大小写
  8306. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  8307. SELECT 0 ID, Username, Username, Email,NULL, NULL
  8308. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_UserName))
  8309. WHERE UserName = @Username
  8310. IF (SELECT COUNT(*) FROM @t) = 1 ----有一个则返回
  8311. GOTO Retu
  8312. ----不区分大小写
  8313. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  8314. SELECT 0 ID, Username, Username, Email, NULL, NULL
  8315. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_UserNameLower))
  8316. WHERE UserNameLower = @Username
  8317. IF (SELECT COUNT(*) FROM @t) > 0
  8318. GOTO Retu ----有值返回结果
  8319. ELSE
  8320. GOTO Err3 ----无值返回而Error
  8321. END
  8322. ELSE IF LEN(ISNULL(@Email, '')) > 0 ----查询caMain.Email
  8323. BEGIN
  8324. INSERT INTO @t(ID, cpMainId, Name, UserName, Email, Gender, Mobile)
  8325. SELECT TOP 10 ID, cpMainId, ISNULL(Name, ''), Username, Email, Gender, Mobile
  8326. FROM caMain WITH(NOLOCK INDEX(IX_caMain_Email))
  8327. WHERE Email = @Email
  8328. ORDER BY (SELECT MAX(AddDate) FROM caLoginLog WITH(NOLOCK) WHERE caMainID = caMain.ID) DESC
  8329. /*
  8330. IF (SELECT COUNT(*) FROM @t) > 0 ----有值则返回
  8331. GOTO Retu
  8332. */
  8333. INSERT INTO @t(ID, Name, UserName, Email)
  8334. SELECT TOP 10 0 ID, Username Name, Username, Email
  8335. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_Email))
  8336. WHERE Email = @Email
  8337. ORDER BY ID DESC
  8338. IF (SELECT COUNT(*) FROM @t) > 0
  8339. GOTO Retu ----有值返回结果
  8340. ELSE
  8341. GOTO Err3 ----无值返回而Error
  8342. END
  8343. END
  8344. Retu: ----正确返回,有数据
  8345. BEGIN
  8346. --获取随机数,激活码
  8347. DECLARE @Rnd AS INT,@AskNo AS VARCHAR(60)
  8348. SELECT @Rnd = RAND() * 899999 + 100000,@AskNo=REPLACE(NEWID(), '-', '')
  8349. UPDATE @t SET ReturnType = @Type, AskNo=@AskNo, ActivateCode = RAND() * 899999 + 100000,UniqueId=REPLACE(NEWID(), '-', '') ----修改返回类型,用于前台显示结果
  8350. ----记录取回纪录
  8351. INSERT INTO caGetPasswordLog(caMainID, UserNameIn, EmailIn, VerifyCode, IP, UserName, Email, Mobile, UniqueId, ActivateCode, AskNo )
  8352. SELECT ID, @UserName, @Email, @VerifyCode, @IP, UserName, Email, @Mobile, UniqueId,ActivateCode ,AskNo FROM @t
  8353. UPDATE a SET a.ConsultantName = (SELECT Name FROM ManagerUser WITH(NOLOCK) WHERE ManagerUser.ID = b.consultantID),
  8354. a.ConsultantEmail = (SELECT EMail FROM ManagerUser WITH(NOLOCK) WHERE ManagerUser.ID = b.consultantID)
  8355. FROM @t a, cpMain b WITH(NOLOCK)
  8356. WHERE a.cpMainId = b.Id
  8357. IF @Type = 'Mobile'
  8358. BEGIN
  8359. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  8360. SELECT TOP 1 0, NULL, NULL, a.ID, a.Mobile, 9, 0,
  8361. '您好,您在' + @SubSiteName + '的激活码是:' + d.ActivateCode
  8362. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK), (SELECT TOP 1 ID, ActivateCode FROM @t ORDER BY ID DESC) d
  8363. WHERE a.cpMainID = b.ID
  8364. AND a.ID = d.Id
  8365. AND a.Mobile > ''
  8366. ORDER BY ID DESC
  8367. END
  8368. SELECT * FROM @t ORDER BY ID DESC
  8369. RETURN
  8370. END
  8371. Err1: ----一个账号一天取回超过5次
  8372. BEGIN
  8373. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 1 ReturnType
  8374. RETURN
  8375. END
  8376. Err2: ----一个ip一天取回超过20次
  8377. BEGIN
  8378. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 2 ReturnType
  8379. RETURN
  8380. END
  8381. Err3: ----没有取回数据
  8382. BEGIN
  8383. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 3 ReturnType
  8384. RETURN
  8385. END
  8386. Err4: ----手机号一天取回超过3次
  8387. BEGIN
  8388. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 4 ReturnType
  8389. RETURN
  8390. END
  8391. GO
  8392. /****** Object: StoredProcedure [dbo].[ccCaMainByGetPasswordSelect1] Script Date: 2018/12/13 19:06:03 ******/
  8393. SET ANSI_NULLS ON
  8394. GO
  8395. SET QUOTED_IDENTIFIER ON
  8396. GO
  8397. ---- =============================================
  8398. ---- Author: Sean
  8399. ---- Create date: 2010-12-20
  8400. ---- Description: 取回密码 先检查用户名是否在camain,Company_Xixni。如果没有结果则检查是否有邮箱
  8401. ---- Update date: 2012-3-7
  8402. ---- Description: 增加取回前检查取回纪录,取回后增加纪录;增加手机查询
  8403. ---- 修改harry 2018-4-27
  8404. ---- 修改短信为实时发送
  8405. ---- 修改alen 2018-9-18
  8406. ---- 用户名为手机号的先检查手机号,没有在检查用户名。
  8407. ---- =============================================
  8408. CREATE PROCEDURE [dbo].[ccCaMainByGetPasswordSelect1]
  8409. (
  8410. @Username VARCHAR(50),
  8411. @Email VARCHAR(50),
  8412. @Mobile VARCHAR(11),
  8413. @IP VARCHAR(15),
  8414. @VerifyCode VARCHAR(10),
  8415. @SubSiteName VARCHAR(30)
  8416. )
  8417. AS
  8418. BEGIN
  8419. DECLARE @Cnt AS INT, @Type AS VARCHAR(10), @ToDay AS DATETIME, @QueryMobile AS INT
  8420. ----如果用户名、油箱、手机号都为空则返回
  8421. IF LEN(ISNULL(@Username, '')) = 0 AND LEN(ISNULL(@Email, '')) = 0 AND LEN(ISNULL(@Mobile, '')) = 0
  8422. GOTO Err3
  8423. --SET @Mobile = ''
  8424. DECLARE @t AS TABLE(
  8425. ID INT,
  8426. cpMainID INT,
  8427. Name NVARCHAR(50) NOT NULL,
  8428. UserName VARCHAR(50) NOT NULL,
  8429. Email VARCHAR(50) NOT NULL,
  8430. Gender NVARCHAR(10),
  8431. ConsultantID SMALLINT,
  8432. ConsultantName NVARCHAR(10),
  8433. ConsultantEmail VARCHAR(50),
  8434. Mobile VARCHAR(13),
  8435. ReturnType VARCHAR(10),
  8436. UniqueId VARCHAR(40),
  8437. ActivateCode VARCHAR(6),
  8438. AskNo VARCHAR(40)
  8439. )
  8440. SELECT @Type = 'Email', @QueryMobile = 0
  8441. IF dbo.IsMobile(@Mobile) = 1 ----手机号是否合法
  8442. BEGIN
  8443. SET @QueryMobile = 1 ----手机号合法,则优先使用手机查询
  8444. ----一周内手机取回密码次数
  8445. SELECT @Cnt = COUNT(DISTINCT AskNo) FROM caGetPasswordLog WITH(NOLOCK) WHERE Mobile = @Mobile AND AddDate > GETDATE() - 1
  8446. IF @Cnt >= 3 ----总数=0,按手机号取回
  8447. GOTO Err4
  8448. SET @Type = 'Mobile'
  8449. END
  8450. IF @Type = 'Email' ----按油箱、用户名取回
  8451. BEGIN
  8452. SET @ToDay = CONVERT(DATETIME, CONVERT(VARCHAR(8), GETDATE(), 112))
  8453. IF @QueryMobile = 1
  8454. BEGIN
  8455. ----一天之内手机号至多查询5次
  8456. SELECT @Cnt = COUNT(1) FROM caGetPasswordLog WITH(NOLOCK) WHERE Mobile = @Mobile AND AddDate > @Today
  8457. IF @Cnt > 4 ----一天之内一个手机号最多取回5次
  8458. GOTO Err1
  8459. END
  8460. ELSE
  8461. BEGIN
  8462. IF LEN(ISNULL(@Username, '')) > 0 ----用户名优先
  8463. BEGIN
  8464. SELECT @Cnt = COUNT(1) FROM caGetPasswordLog WITH(NOLOCK) WHERE Username = @Username AND AddDate > @Today
  8465. SET @Type = 'Username'
  8466. END
  8467. ELSE ----其次Email
  8468. SELECT @Cnt = COUNT(1) FROM caGetPasswordLog WITH(NOLOCK) WHERE Email = @Email AND AddDate > @Today
  8469. IF @Cnt > 4 ----一天之内一个账号最多取回5次
  8470. GOTO Err1
  8471. END
  8472. SELECT @Cnt = COUNT(1) FROM caGetPasswordLog WITH(NOLOCK) WHERE IP = @IP AND AddDate >= @Today
  8473. IF @Cnt > 20 ----一天之内一个ip不能超过20次
  8474. GOTO Err2
  8475. END
  8476. SELECT @Cnt = 0
  8477. IF @QueryMobile = 1 ----按照手机号查询
  8478. BEGIN
  8479. INSERT INTO @t(ID, cpMainId, Name, UserName, Email, Gender, Mobile)
  8480. SELECT TOP 10 ID, cpMainId, ISNULL(Name, ''), Username, Email, Gender, Mobile
  8481. FROM caMain WITH(NOLOCK INDEX(IX_caMain_Mobile))
  8482. WHERE Mobile = @Mobile
  8483. ORDER BY (SELECT MAX(AddDate) FROM caLoginLog WITH(NOLOCK) WHERE caMainID = caMain.ID) DESC
  8484. IF (SELECT COUNT(*) FROM @t) > 0 ----有值则返回
  8485. GOTO Retu
  8486. ELSE ----手机号查询不到按照用户名查询
  8487. BEGIN
  8488. INSERT INTO @t(ID, cpMainId, Name, UserName, Email, Gender, Mobile)
  8489. SELECT ID, cpMainId, ISNULL(Name, ''), Username, Email, Gender, Mobile
  8490. FROM caMain WITH(NOLOCK INDEX(IX_caMain_UserName))
  8491. WHERE Username = @Mobile
  8492. IF (SELECT COUNT(*) FROM @t) > 0 ----有值则返回
  8493. BEGIN
  8494. SET @Mobile = (SELECT TOP 1 Mobile FROM @t)
  8495. GOTO Retu
  8496. END
  8497. ELSE
  8498. GOTO Err3 ----无值返回而Error
  8499. END
  8500. END
  8501. ELSE IF LEN(ISNULL(@Username, '')) > 0 ----如果有用户名则以用户名为主
  8502. BEGIN
  8503. SET @Type = 'Username'
  8504. ----caMain.UserName = @UserName 区分大小写
  8505. INSERT INTO @t(ID, cpMainId, Name, UserName, Email, Gender, Mobile)
  8506. SELECT ID, cpMainId, ISNULL(Name, ''), Username, Email, Gender, Mobile
  8507. FROM caMain WITH(NOLOCK INDEX(IX_caMain_UserName))
  8508. WHERE Username = @UserName
  8509. IF (SELECT COUNT(*) FROM @t) = 1 ----有值则返回
  8510. GOTO Retu
  8511. ----无值,不区分大小写
  8512. ----caMain.UserNameLower = @UserName
  8513. INSERT INTO @t(ID, cpMainId, Name, UserName, Email, Gender, Mobile)
  8514. SELECT ID, cpMainId, ISNULL(Name, ''), Username, Email, Gender, Mobile
  8515. FROM caMain WITH(NOLOCK INDEX(IX_caMain_UserNameLower))
  8516. WHERE UsernameLower = @UserName
  8517. IF (SELECT COUNT(*) FROM @t) > 0 ----有值则返回
  8518. GOTO Retu
  8519. ----无值,再查询Company_Xinxi 区分大小写
  8520. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  8521. SELECT 0 ID, Username, Username, Email,NULL, NULL
  8522. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_UserName))
  8523. WHERE UserName = @Username
  8524. IF (SELECT COUNT(*) FROM @t) = 1 ----有一个则返回
  8525. GOTO Retu
  8526. ----不区分大小写
  8527. INSERT INTO @t(ID, Name, UserName, Email, Gender, Mobile)
  8528. SELECT 0 ID, Username, Username, Email, NULL, NULL
  8529. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_UserNameLower))
  8530. WHERE UserNameLower = @Username
  8531. IF (SELECT COUNT(*) FROM @t) > 0
  8532. GOTO Retu ----有值返回结果
  8533. ELSE
  8534. GOTO Err3 ----无值返回而Error
  8535. END
  8536. ELSE IF LEN(ISNULL(@Email, '')) > 0 ----查询caMain.Email
  8537. BEGIN
  8538. INSERT INTO @t(ID, cpMainId, Name, UserName, Email, Gender, Mobile)
  8539. SELECT TOP 10 ID, cpMainId, ISNULL(Name, ''), Username, Email, Gender, Mobile
  8540. FROM caMain WITH(NOLOCK INDEX(IX_caMain_Email))
  8541. WHERE Email = @Email
  8542. ORDER BY (SELECT MAX(AddDate) FROM caLoginLog WITH(NOLOCK) WHERE caMainID = caMain.ID) DESC
  8543. /*
  8544. IF (SELECT COUNT(*) FROM @t) > 0 ----有值则返回
  8545. GOTO Retu
  8546. */
  8547. INSERT INTO @t(ID, Name, UserName, Email)
  8548. SELECT TOP 10 0 ID, Username Name, Username, Email
  8549. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_Email))
  8550. WHERE Email = @Email
  8551. ORDER BY ID DESC
  8552. IF (SELECT COUNT(*) FROM @t) > 0
  8553. GOTO Retu ----有值返回结果
  8554. ELSE
  8555. GOTO Err3 ----无值返回而Error
  8556. END
  8557. END
  8558. Retu: ----正确返回,有数据
  8559. BEGIN
  8560. --获取随机数,激活码
  8561. DECLARE @Rnd AS INT,@AskNo AS VARCHAR(60)
  8562. SELECT @Rnd = RAND() * 899999 + 100000,@AskNo=REPLACE(NEWID(), '-', '')
  8563. UPDATE @t SET ReturnType = @Type, AskNo=@AskNo, ActivateCode = RAND() * 899999 + 100000,UniqueId=REPLACE(NEWID(), '-', '') ----修改返回类型,用于前台显示结果
  8564. ----记录取回纪录
  8565. INSERT INTO caGetPasswordLog(caMainID, UserNameIn, EmailIn, VerifyCode, IP, UserName, Email, Mobile, UniqueId, ActivateCode, AskNo )
  8566. SELECT ID, @UserName, @Email, @VerifyCode, @IP, UserName, Email, @Mobile, UniqueId,ActivateCode ,AskNo FROM @t
  8567. UPDATE a SET a.ConsultantName = (SELECT Name FROM ManagerUser WITH(NOLOCK) WHERE ManagerUser.ID = b.consultantID),
  8568. a.ConsultantEmail = (SELECT EMail FROM ManagerUser WITH(NOLOCK) WHERE ManagerUser.ID = b.consultantID)
  8569. FROM @t a, cpMain b WITH(NOLOCK)
  8570. WHERE a.cpMainId = b.Id
  8571. SELECT * FROM @t ORDER BY ID DESC
  8572. IF @Type = 'Mobile'
  8573. BEGIN
  8574. SELECT TOP 1 a.ID AS caMainId, a.Mobile, 9 AS MsgType,
  8575. '您好,您在' + @SubSiteName + '的激活码是:' + d.ActivateCode AS Msg
  8576. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK), (SELECT TOP 1 ID, ActivateCode FROM @t ORDER BY ID DESC) d
  8577. WHERE a.cpMainID = b.ID
  8578. AND a.ID = d.Id
  8579. AND a.Mobile > ''
  8580. ORDER BY a.ID DESC
  8581. END
  8582. RETURN
  8583. END
  8584. Err1: ----一个账号一天取回超过5次
  8585. BEGIN
  8586. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 1 ReturnType
  8587. RETURN
  8588. END
  8589. Err2: ----一个ip一天取回超过20次
  8590. BEGIN
  8591. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 2 ReturnType
  8592. RETURN
  8593. END
  8594. Err3: ----没有取回数据
  8595. BEGIN
  8596. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 3 ReturnType
  8597. RETURN
  8598. END
  8599. Err4: ----手机号一天取回超过3次
  8600. BEGIN
  8601. SELECT null ID, NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, 4 ReturnType
  8602. RETURN
  8603. END
  8604. GO
  8605. /****** Object: StoredProcedure [dbo].[ccCaMainByGetSecondPasswordSelect] Script Date: 2018/12/13 19:06:04 ******/
  8606. SET ANSI_NULLS ON
  8607. GO
  8608. SET QUOTED_IDENTIFIER ON
  8609. GO
  8610. ---- =============================================
  8611. ---- 创建人: Lambo
  8612. ---- 创建时间: 2014-12-20
  8613. ---- 功能: 企业重置二次密码
  8614. --[ccCaMainByGetSecondPasswordSelect] 9836390,'192.168.1.1','山东'
  8615. ---- =============================================
  8616. CREATE PROCEDURE [dbo].[ccCaMainByGetSecondPasswordSelect]
  8617. (
  8618. @CaMainID INT,
  8619. @IP VARCHAR(15),
  8620. @SubSiteName VARCHAR(30)
  8621. )
  8622. AS
  8623. BEGIN
  8624. DECLARE @Cnt AS INT, @Type AS VARCHAR(10), @ToDay AS DATETIME, @QueryMobile AS INT
  8625. ----如果用户名、油箱、手机号都为空则返回
  8626. DECLARE @t AS TABLE(
  8627. ID INT,
  8628. cpMainID INT,
  8629. Name NVARCHAR(50) NOT NULL,
  8630. UserName VARCHAR(50) NOT NULL,
  8631. Email VARCHAR(50) NOT NULL,
  8632. Gender NVARCHAR(10),
  8633. ConsultantID SMALLINT,
  8634. ConsultantName NVARCHAR(10),
  8635. ConsultantEmail VARCHAR(50),
  8636. Mobile VARCHAR(13),
  8637. UniqueId VARCHAR(40),
  8638. ActivateCode VARCHAR(6)
  8639. )
  8640. SET @ToDay = CONVERT(DATETIME, CONVERT(VARCHAR(8), GETDATE(), 112))
  8641. SELECT @Cnt = COUNT(1) FROM caGetSecondPasswordLog WITH(NOLOCK) WHERE caMainID=@CaMainID AND AddDate > @Today
  8642. IF @Cnt > 2 ----一天之内一个账号最多取回3次
  8643. GOTO Err1
  8644. SELECT @Cnt = COUNT(1) FROM caGetSecondPasswordLog WITH(NOLOCK) WHERE IP = @IP AND AddDate >= @Today
  8645. IF @Cnt > 20 ----一天之内一个ip不能超过20次
  8646. GOTO Err2
  8647. --获取随机数,激活码
  8648. DECLARE @Rnd AS INT,@UniqueId AS VARCHAR(60)
  8649. SELECT @Rnd = RAND() * 899999 + 100000,@UniqueId=REPLACE(NEWID(), '-', '')
  8650. INSERT INTO @t(ID, cpMainId, Name, UserName, Email, Gender, Mobile,UniqueId,ActivateCode)
  8651. SELECT ID, cpMainId, ISNULL(Name, ''), Username, Email, Gender, Mobile,@UniqueId,@Rnd
  8652. FROM caMain WITH(NOLOCK)
  8653. WHERE id=@caMainID
  8654. ----记录取回纪录
  8655. INSERT INTO caGetSecondPasswordLog(caMainID, ActivateCode, IP, UniqueId)
  8656. SELECT ID, ActivateCode, @IP, UniqueId FROM @t
  8657. UPDATE a SET a.ConsultantName = (SELECT Name FROM ManagerUser WITH(NOLOCK) WHERE ManagerUser.ID = b.consultantID),
  8658. a.ConsultantEmail = (SELECT EMail FROM ManagerUser WITH(NOLOCK) WHERE ManagerUser.ID = b.consultantID)
  8659. FROM @t a, cpMain b WITH(NOLOCK)
  8660. WHERE a.cpMainId = b.Id
  8661. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  8662. SELECT TOP 1 0, NULL, NULL, a.ID, a.Mobile, 9, 0,
  8663. '您好,您在' + @SubSiteName + '的激活码是:' + d.ActivateCode
  8664. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK), (SELECT TOP 1 ID, ActivateCode FROM @t ORDER BY ID DESC) d
  8665. WHERE a.cpMainID = b.ID
  8666. AND a.ID = d.Id
  8667. AND a.Mobile > ''
  8668. AND a.ID = @caMainID
  8669. ORDER BY ID DESC
  8670. SELECT TOP 1 * FROM @t
  8671. RETURN
  8672. END
  8673. Err1: ----一个账号一天取回超过3次
  8674. BEGIN
  8675. SELECT null ID, 1 cpMainID,NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, '' UniqueId
  8676. RETURN
  8677. END
  8678. Err2: ----一个ip一天取回超过20次
  8679. BEGIN
  8680. SELECT null ID, 2 cpMainID,NULL Name, NULL Username, NULL Email, NULL Gender, NULL Mobile, '' UniqueId
  8681. RETURN
  8682. END
  8683. GO
  8684. /****** Object: StoredProcedure [dbo].[ccCaMainByIsPauseUpdate] Script Date: 2018/12/13 19:06:04 ******/
  8685. SET ANSI_NULLS ON
  8686. GO
  8687. SET QUOTED_IDENTIFIER ON
  8688. GO
  8689. --##################################################
  8690. --检查: sean 2010-11-1
  8691. --暂停企业账号
  8692. --##################################################
  8693. CREATE PROCEDURE [dbo].[ccCaMainByIsPauseUpdate]
  8694. (
  8695. @ManagerID INT,
  8696. @ID INT
  8697. )
  8698. AS
  8699. SET NOCOUNT ON
  8700. BEGIN TRAN
  8701. IF @ManagerID = @ID
  8702. RETURN 0
  8703. BEGIN TRY
  8704. IF EXISTS(
  8705. SELECT a.ID FROM
  8706. caMain a WITH(NOLOCK),
  8707. caMain b WITH(NOLOCK)
  8708. WHERE a.cpMainID=b.cpMainID
  8709. AND a.AccountType=1
  8710. AND b.AccountType>1
  8711. AND a.ID=@ManagerID
  8712. AND b.ID=@ID
  8713. AND a.IsDelete = 0
  8714. )
  8715. BEGIN
  8716. DECLARE @IsPause AS BIT
  8717. DECLARE @cpMainID AS INT
  8718. DECLARE @Cnt AS INT
  8719. DECLARE @MaxUserNumber AS INT
  8720. DECLARE @DESC AS NVARCHAR(100)
  8721. SELECT @IsPause = IsPause, @cpMainID = cpMainID FROM caMain WHERE ID = @ID
  8722. IF @IsPause = 1
  8723. BEGIN
  8724. SELECT @Cnt = COUNT(1) FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID AND IsPause = 0
  8725. SELECT @MaxUserNumber = MaxUserNumber FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  8726. --PRINT @MaxUserNumber
  8727. IF @Cnt > @MaxUserNumber -1
  8728. GOTO Err
  8729. UPDATE Job
  8730. SET IssueEnd = GETDATE(),
  8731. IssueDate = CASE WHEN IssueDate > GETDATE() THEN CONVERT(VARCHAR(10), GETDATE(), 23) ELSE IssueDate END,
  8732. Valid = 0
  8733. WHERE caMainID = @ID
  8734. AND Valid = 1
  8735. END
  8736. UPDATE caMain SET IsPause = IsPause - 1 WHERE ID = @ID
  8737. END
  8738. END TRY
  8739. BEGIN CATCH
  8740. GOTO ERR
  8741. END CATCH
  8742. COMMIT TRAN
  8743. RETURN 1
  8744. ERR:
  8745. BEGIN
  8746. ROLLBACK TRAN
  8747. RETURN 0
  8748. END
  8749. GO
  8750. /****** Object: StoredProcedure [dbo].[ccCaMainByLoginUpdate] Script Date: 2018/12/13 19:06:04 ******/
  8751. SET ANSI_NULLS ON
  8752. GO
  8753. SET QUOTED_IDENTIFIER ON
  8754. GO
  8755. --========================
  8756. --创建: sean
  8757. --检查: sean 2010-10-15
  8758. --企业用户登录 ,增加Company_xinxi表中数据的检索、处理
  8759. --检查caMain表
  8760. --2010-12-27 sean 企业第一次登录时 注册时间改为信息员推广时间
  8761. --2012-09-05 NICK 加密后的登录过程
  8762. --2017-10-11 harry 限制实名的,不记录登录时间
  8763. --2018-8-7 harry 修改职位登录刷新,今天未刷新的刷新
  8764. --========================
  8765. CREATE PROCEDURE [dbo].[ccCaMainByLoginUpdate]
  8766. (
  8767. @UserName VARCHAR(70),
  8768. @Password VARCHAR(60),
  8769. @PlainPassword VARCHAR(50),
  8770. @IP VARCHAR(31),
  8771. @dcSubSiteID SMALLINT,
  8772. @LoginCookies VARCHAR(16),
  8773. @SessionID VARCHAR(30),
  8774. @browser VARCHAR(500),
  8775. @caMainID AS INT,
  8776. @loginFrom AS INT,
  8777. @CaType INT OUTPUT--camain数据是否从company_xinxi 表中导入
  8778. )
  8779. AS
  8780. SET NOCOUNT ON
  8781. IF @UserName LIKE '% %'
  8782. SET @UserName = REPLACE(@UserName, ' ', '')
  8783. IF @caMainID > 0
  8784. BEGIN
  8785. IF NOT EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE ID IN(SELECT cpMainId FROM caMain WITH(NOLOCK) WHERE Id= @caMainID))
  8786. BEGIN
  8787. IF EXISTS(SELECT 'x' FROM dcLimitIp WHERE LoginIp = @Ip)
  8788. RETURN -1
  8789. IF EXISTS(SELECT 'x' FROM dcLimitCookies WHERE LoginCookies = @LoginCookies)
  8790. RETURN -1
  8791. END
  8792. END
  8793. BEGIN TRAN
  8794. DECLARE
  8795. @cpMainID AS INT,
  8796. @SecondID VARCHAR(10),
  8797. @IsPause AS BIT,
  8798. @Name AS NVARCHAR(20),
  8799. @cpName AS NVARCHAR(50),
  8800. @DayLoginNumber AS INT,
  8801. @RefreshDate AS SMALLDATETIME,
  8802. @IsLimitLogin AS TINYINT,
  8803. @IsLock AS INT,
  8804. @thisDcProvinceID AS TINYINT,
  8805. @CountDate AS INT,
  8806. @dcProvinceID AS TINYINT,
  8807. @MemberType AS TINYINT,
  8808. @JobNumber AS INT,
  8809. @JobID AS VARCHAR(300),
  8810. @JobName AS VARCHAR(1000),
  8811. @LastJobIssueDate AS SMALLDATETIME,
  8812. @LastJobId AS VARCHAR(12),
  8813. @Cnt AS INT,
  8814. @dcREgionID VARCHAR(6),
  8815. @IsAgent BIT,
  8816. @RealNameLimit INT --harry2017-10-11
  8817. SELECT @dcProvinceID = LEFT(@dcSubSiteID, 2),
  8818. @CaType=0,
  8819. @CountDate = YEAR(GETDATE())*10000 + MONTH(GETDATE())*100 + DAY(GETDATE()),
  8820. @UserName = LTRIM(RTRIM(@UserName))
  8821. --caMain中存在账号
  8822. BEGIN TRY
  8823. IF @caMainID <>0
  8824. BEGIN
  8825. SELECT @caMainID = a.ID, @cpMainID = a.cpMainID, @Name = a.Name, @SecondId = SecondID,
  8826. @IsPause = a.IsPause, @dcRegionID = b.dcRegionId, @JobNumber = b.JobNumber,
  8827. @IsLimitLogin = b.IsLimitLogin, @RefreshDate = b.RefreshDate,
  8828. @cpName = b.Name, @IsAgent = b.IsAgent,
  8829. @IsLock = b.IsLock, @MemberType =MemberType, @thisDcProvinceID = dcProvinceID
  8830. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  8831. WHERE a.ID=@caMainID AND a.cpmainID = b.ID
  8832. END
  8833. IF @caMainID = 0 --在caMain表中没有记录
  8834. BEGIN
  8835. DECLARE @Company_XinxiID AS INT
  8836. DECLARE @AddMan AS SMALLINT
  8837. DECLARE @RegDate AS SMALLDATETIME
  8838. DECLARE @EMail AS VARCHAR(50)
  8839. SELECT @Cnt = COUNT(1)
  8840. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_UserNameLower))
  8841. WHERE UserNameLower = @UserName AND Password = @PlainPassword
  8842. IF @Cnt = 1
  8843. SELECT @cpName = CompanyName, @EMail = Email, @Company_XinxiID = ID, @AddMan = AddMan, @RegDate = RegDate
  8844. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_UserNameLower))
  8845. WHERE UserNameLower = @UserName
  8846. AND Password = @PlainPassword
  8847. ELSE IF @Cnt > 1
  8848. SELECT @cpName = CompanyName, @EMail = Email, @Company_XinxiID = ID, @AddMan = AddMan, @RegDate = RegDate
  8849. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_UserName))
  8850. WHERE UserName = @UserName
  8851. AND Password = @PlainPassword
  8852. IF @Company_XinxiID IS NOT NULL --如果在Company_xinxi中, 将其转移到cpmain中,并删除Company_xinxi中的记录
  8853. BEGIN
  8854. SET @CaType=1
  8855. ----企业表
  8856. INSERT INTO cpMain(dcProvinceID, dcRegionID, dcSubSiteID, RegisterIP, Name, RegDate, RegisterMode, AddMan, IsDefaultPassword)
  8857. VALUES(@dcProvinceID, @dcSubSiteID, @dcSubSiteID, @IP, @cpName, @RegDate, 1, @AddMan, 1)
  8858. SELECT @cpMainID = @@IDENTITY
  8859. ----账号表
  8860. INSERT INTO caMain(cpMainID, EMail, AccountType, UserName, Password)
  8861. VALUES(@cpMainID, @EMail, 1, @UserName, @Password)
  8862. SELECT TOP 1 @caMainID = ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID ORDER BY ID DESC
  8863. --INSERT INTO caPlainPassword(caMainId, PlainPassWord) SELECT @caMainID, @PlainPassword
  8864. ----顾问分配
  8865. EXEC ccCpMainByConsultantAssignUpdate @cpMainID, @dcProvinceID
  8866. SET @RefreshDate = GETDATE() - 10 --刷新时间和企业名称等变量
  8867. SET @thisDcProvinceID = @dcProvinceID
  8868. IF @cpName IS NULL
  8869. SET @cpName = '未命名企业'
  8870. ----日报表, 信息员推广过的个人注册,160天内作为推广ValIDCompany, 不判断省份
  8871. UPDATE DateReport
  8872. SET ValIDCompany = ValIDCompany +1
  8873. WHERE CountDate = @CountDate
  8874. AND Province_ID = @dcSubSiteID
  8875. --INSERT INTO pamainDatereport SELECT @cpMainID, 8, GETDATE() -- SEAN 20130911
  8876. ------判断是否有该行记录,没有则增加
  8877. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK) WHERE CountDate = @CountDate AND Province_ID = @dcProvinceID AND InfoManager_ID = @AddMan)
  8878. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, CountDate)
  8879. VALUES(@dcProvinceID, @AddMan, @CountDate)
  8880. ------记录数据,信息员工作量 + 1
  8881. UPDATE Info_DateReport
  8882. SET ValIDCompany = ValIDCompany + 1
  8883. WHERE CountDate = @CountDate
  8884. AND Province_ID = @dcProvinceID
  8885. AND InfoManager_ID = @AddMan
  8886. END
  8887. ELSE
  8888. GOTO ERR1 --用户名、密码不正确, cpMain、Company_xinxi中都没有
  8889. END
  8890. IF @IsPause = 1
  8891. GOTO ERR3 --企业账户被暂停
  8892. IF @IsLimitLogin = 9
  8893. GOTO Err4 --企业已经被限制登录
  8894. IF @thisDcProvinceID <> @dcProvinceID
  8895. GOTO Err5 --企业登陆网站不是注册网站
  8896. --Added By mice 123 判断是否为死客户,如果为死客户,则激活
  8897. IF EXISTS(SELECT 'X' FROM MainDb..bsDeadCompany x WITH(NOLOCK) WHERE x.cpMainID = @cpMainID AND x.ActiveDate IS NULL)
  8898. BEGIN
  8899. UPDATE MAINDB..bsDeadCompany SET ActiveDate = GETDATE() WHERE cpMainID = @cpMainID AND ActiveDate IS NULL
  8900. END
  8901. --根据企业购买的服务,确定每天最大登陆次数
  8902. IF @MemberType >= 3
  8903. SELECT @DayLoginNumber = 30
  8904. ELSE
  8905. SET @DayLoginNumber = 15
  8906. DECLARE @TodayLoginNumber AS INT, @IsOldRefresh BIT, @UnRefreshNumber INT
  8907. SELECT @TodayLoginNumber = COUNT(1)
  8908. FROM CaLoginLog WITH(NOLOCK)
  8909. WHERE caMainID = @caMainID
  8910. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  8911. --今天还未刷新的职位数 harry 2018-8-7
  8912. SELECT @UnRefreshNumber = COUNT(1)
  8913. FROM Job
  8914. WHERE caMainID = @caMainID AND RefreshDate < CONVERT(VARCHAR(10), GETDATE(), 120) AND Valid = 1
  8915. IF @TodayLoginNumber >= @DayLoginNumber
  8916. GOTO ERR2 --超过登陆次数, 每天限制登录次数
  8917. --登陆次数--harry 20171011 实名限制登录时间不更新
  8918. SELECT @RealNameLimit = ISNULL(RealName, 0), @IsOldRefresh = 0 FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  8919. IF @RealNameLimit < 2 -----harry 20171011 实名限制登录时间不更新
  8920. BEGIN
  8921. IF EXISTS(SELECT 'x' FROM jobRefreshOldCompany WHERE cpMainId = @cpMainId)
  8922. SET @IsOldRefresh = 1
  8923. UPDATE cpMain SET LoginCount = LoginCount + 1, LastLoginDate = GETDATE(), LastLoginIp = @IP WHERE ID = @cpMainID
  8924. IF @IsOldRefresh = 1 OR @TodayLoginNumber = 0 OR @UnRefreshNumber>0
  8925. UPDATE Job SET RefreshDate = GETDATE()
  8926. WHERE caMainID = @caMainID AND RefreshDate < CONVERT(VARCHAR(10), GETDATE(), 120) AND Valid = 1
  8927. --检查该企业数据是否已经在SearchDB..cpMainHomepageSnapshot
  8928. IF (@MemberType >= 2) OR (@dcProvinceID NOT IN(32, 30, 31, 35, 10, 11, 12, 40) AND @MemberType = 1)
  8929. IF NOT EXISTS(SELECT 'x' FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK) WHERE RealCpMainID = @cpMainID)
  8930. SET @RefreshDate = GETDATE() - 1
  8931. --IF DATEDIFF(MINUTE, @RefreshDate, GETDATE()) > 59 --刷新时间如果超过1个小时,更新为当前时间
  8932. -- UPDATE cpMain SET RefreshDate = GETDATE() WHERE ID = @cpMainID
  8933. --更新企业刷新时间, 更新职位刷新时间, 间隔时间1小时
  8934. IF DATEDIFF(MINUTE, @RefreshDate, GETDATE()) > 59 --刷新时间如果超过1个小时,更新为当前时间
  8935. BEGIN TRY
  8936. UPDATE cpMain SET RefreshDate = GETDATE() WHERE ID = @cpMainID
  8937. IF (@MemberType > 2)
  8938. BEGIN
  8939. IF EXISTS(SELECT 'x' FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK) WHERE RealCpMainID = @cpMainID)
  8940. DELETE FROM SearchDB..cpMainHomepageSnapshot WHERE RealCpMainID = @cpMainID
  8941. SELECT @JobID = dbo.GetJobSecondIds(@cpMainID), @JobName = dbo.GetJobNames(@cpMainID)
  8942. SELECT TOP 1 @LastJobIssueDate = IssueDate, @LastJobId = SecondId FROM Job WITH(NOLOCK)
  8943. WHERE cpMainID = @cpMainID AND Valid = 1 AND CHARINDEX(SecondId, LEFT(@JobId, 22)) > 0
  8944. ORDER BY IssueDate DESC
  8945. INSERT SearchDB..cpMainHomepageSnapshot(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, MemberType, RealCpMainId, RefreshDate)
  8946. VALUES(@dcSubSiteID, LEFT(@dcRegionID, 4), @SecondID, @cpName, @IsAgent, @JobNumber, @JobID, @JobName, @LastJobIssueDate, @LastJobId, @MemberType, @cpMainId, GETDATE())
  8947. END
  8948. IF (@MemberType = 2) OR (@dcProvinceID NOT IN(32, 30, 31, 35, 10, 11, 12, 40) AND @MemberType = 1)
  8949. BEGIN
  8950. IF EXISTS(SELECT 'x' FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK) WHERE RealCpMainID = @cpMainID)
  8951. DELETE FROM SearchDB..cpMainHomepageSnapshot WHERE RealCpMainID = @cpMainID
  8952. DECLARE @cpLicenceDate AS SMALLDATETIME
  8953. SELECT @cpLicenceDate = AddDate FROM cpLicence WITH(NOLOCK) WHERE cpMainID = @cpMainID
  8954. SELECT @JobID = dbo.GetJobSecondIds(@cpMainID), @JobName = dbo.GetJobNames(@cpMainID)
  8955. SELECT TOP 1 @LastJobIssueDate = IssueDate, @LastJobId = SecondId FROM Job WITH(NOLOCK)
  8956. WHERE cpMainID = @cpMainID AND Valid = 1 ORDER BY IssueDate DESC
  8957. INSERT SearchDB..cpMainHomepageSnapshot(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, MemberType, cpLicenceDate, RealCpMainId, RefreshDate)
  8958. VALUES(@dcSubSiteID, LEFT(@dcRegionID, 4), @SecondID, @cpName, @IsAgent, @JobNumber, @JobID, @JobName, @LastJobIssueDate, @LastJobId, @MemberType, @cpLicenceDate, @cpMainId, GETDATE())
  8959. END
  8960. END TRY
  8961. BEGIN CATCH
  8962. --print 'Error '
  8963. INSERT INTO PaMainDateReport SELECT @cpMainID, 99, GETDATE() --20130709 lambo
  8964. END CATCH
  8965. IF ISNULL(@Name, '') = ''
  8966. SET @Name = @UserName
  8967. --记录每日登录数据
  8968. IF NOT EXISTS(SELECT 'x' FROM caloginlog a WITH(NOLOCK), caMain b WITH(NOLOCK)
  8969. WHERE a.caMainID = b.ID
  8970. AND b.cpMainID = @cpMainID
  8971. AND a.AddDate >= CONVERT(VARCHAR(10), GETDATE(), 120))
  8972. AND @Company_XinxiID IS NULL
  8973. BEGIN
  8974. UPDATE DateReport
  8975. SET CompanyLoginNum_Net = CompanyLoginNum_Net + 1
  8976. WHERE Province_ID = @dcSubSiteID
  8977. AND CountDate = @CountDate
  8978. --INSERT INTO PaMainDateReport SELECT @cpMainID, 10, GETDATE() --20130709 lambo
  8979. END
  8980. --登陆日志, 记录Cookies
  8981. IF ISNULL(@LoginCookies, '') = ''
  8982. SET @LoginCookies = RTRIM(CONVERT(VARCHAR(16), @SessionID))
  8983. INSERT INTO caLoginLog(caMainID, cpMainName, caMainName, LoginIP, LoginCookies, browser, loginFrom)
  8984. VALUES(@caMainID, @cpName, @Name, @IP, @LoginCookies, '2:' + ISNULL(@browser, 'Null'), @loginFrom )
  8985. -- IF @MemberType = 3 AND GETDATE()<'2014-11-1'
  8986. -- BEGIN
  8987. -- IF NOT EXISTS(SELECT TOP 1 'x' FROM LotteryCompanyLoginLog WITH(NOLOCK)
  8988. -- WHERE cpMainID = @cpMainID
  8989. -- AND LoginDate > CONVERT(VARCHAR(10), GETDATE(), 120))
  8990. -- BEGIN
  8991. -- --取昨天是第几天登陆
  8992. -- DECLARE @LastLoginNo INT
  8993. -- SELECT @LastLoginNo = LoginNo FROM LotteryCompanyLoginLog
  8994. -- WHERE cpMainID=@cpMainID
  8995. -- AND CONVERT(VARCHAR(8), LoginDate, 112) = CONVERT(VARCHAR(8), GETDATE() - 1, 112)
  8996. --
  8997. -- SET @LastLoginNo = ISNULL(@LastLoginNo, 0)
  8998. --
  8999. -- IF @LastLoginNo = 5
  9000. -- SET @LastLoginNo = 1
  9001. -- ELSE
  9002. -- BEGIN
  9003. -- SET @LastLoginNo = @LastLoginNo + 1
  9004. -- IF @LastLoginNo = 5
  9005. -- INSERT INTO lotteryCompany(CpMainID, CaOrderID, LoginDate, Used, AddDate)
  9006. -- SELECT @cpMainID, NULL, GETDATE(), 0, GETDATE()
  9007. -- END
  9008. -- INSERT INTO LotteryCompanyLoginLog(cpMainID, LoginDate, LoginNo)
  9009. -- SELECT @cpMainID, GETDATE(), @LastLoginNo
  9010. -- END
  9011. -- END
  9012. END
  9013. END TRY
  9014. BEGIN CATCH
  9015. GOTO ERR
  9016. END CATCH
  9017. COMMIT TRAN
  9018. RETURN @caMainID
  9019. ERR:
  9020. BEGIN
  9021. ROLLBACK TRAN
  9022. print 0
  9023. RETURN 0
  9024. END
  9025. ERR1:
  9026. BEGIN
  9027. ROLLBACK TRAN
  9028. print -1
  9029. RETURN -1
  9030. END
  9031. ERR2:
  9032. BEGIN
  9033. ROLLBACK TRAN
  9034. IF @DayLoginNumber = 15
  9035. BEGIN
  9036. print -2
  9037. RETURN -2
  9038. END
  9039. IF @DayLoginNumber = 30
  9040. BEGIN
  9041. print -3
  9042. RETURN -3
  9043. END
  9044. END
  9045. ERR3:
  9046. BEGIN
  9047. ROLLBACK TRAN
  9048. print -4
  9049. RETURN -4
  9050. END
  9051. ERR4:
  9052. BEGIN
  9053. ROLLBACK TRAN
  9054. print 0
  9055. RETURN -9
  9056. END
  9057. ERR5:
  9058. BEGIN
  9059. ROLLBACK TRAN
  9060. print @cpMainID * -1
  9061. RETURN @cpMainID * -1
  9062. END
  9063. GO
  9064. /****** Object: StoredProcedure [dbo].[ccCaMainByLoginUpdate2] Script Date: 2018/12/13 19:06:04 ******/
  9065. SET ANSI_NULLS ON
  9066. GO
  9067. SET QUOTED_IDENTIFIER ON
  9068. GO
  9069. --========================
  9070. --创建: sean
  9071. --检查: sean 2010-10-15
  9072. --企业用户登录 ,增加Company_xinxi表中数据的检索、处理
  9073. --检查caMain表
  9074. --2010-12-27 sean 企业第一次登录时 注册时间改为信息员推广时间
  9075. --2012-09-05 NICK 加密后的登录过程
  9076. --========================
  9077. CREATE PROCEDURE [dbo].[ccCaMainByLoginUpdate2]
  9078. (
  9079. @UserName VARCHAR(70),
  9080. @Password VARCHAR(60),
  9081. @PlainPassword VARCHAR(50),
  9082. @IP VARCHAR(31),
  9083. @dcSubSiteID SMALLINT,
  9084. @LoginCookies VARCHAR(16),
  9085. @SessionID VARCHAR(30),
  9086. @browser VARCHAR(500),
  9087. @caMainID AS INT,
  9088. @loginFrom AS INT,
  9089. @CaType INT OUTPUT--camain数据是否从company_xinxi 表中导入
  9090. )
  9091. AS
  9092. SET NOCOUNT ON
  9093. IF @caMainID > 0
  9094. BEGIN
  9095. IF NOT EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE ID IN(SELECT cpMainId FROM caMain WITH(NOLOCK) WHERE Id= @caMainID))
  9096. BEGIN
  9097. IF EXISTS(SELECT 'x' FROM dcLimitIp WHERE LoginIp = @Ip)
  9098. RETURN -1
  9099. IF EXISTS(SELECT 'x' FROM dcLimitCookies WHERE LoginCookies = @LoginCookies)
  9100. RETURN -1
  9101. END
  9102. END
  9103. BEGIN TRAN
  9104. DECLARE
  9105. @cpMainID AS INT,
  9106. @SecondID VARCHAR(10),
  9107. @IsPause AS BIT,
  9108. @Name AS NVARCHAR(20),
  9109. @cpName AS NVARCHAR(50),
  9110. @DayLoginNumber AS INT,
  9111. @RefreshDate AS SMALLDATETIME,
  9112. @IsLimitLogin AS TINYINT,
  9113. @IsLock AS INT,
  9114. @thisDcProvinceID AS TINYINT,
  9115. @CountDate AS INT,
  9116. @dcProvinceID AS TINYINT,
  9117. @MemberType AS TINYINT,
  9118. @JobNumber AS INT,
  9119. @JobID AS VARCHAR(300),
  9120. @JobName AS VARCHAR(1000),
  9121. @LastJobIssueDate AS SMALLDATETIME,
  9122. @LastJobId AS INT,
  9123. @Cnt AS INT,
  9124. @dcREgionID VARCHAR(6),
  9125. @IsAgent BIT
  9126. SELECT @dcProvinceID = LEFT(@dcSubSiteID, 2),
  9127. @CaType=0,
  9128. @CountDate = YEAR(GETDATE())*10000 + MONTH(GETDATE())*100 + DAY(GETDATE()),
  9129. @UserName = LTRIM(RTRIM(@UserName))
  9130. --caMain中存在账号
  9131. BEGIN TRY
  9132. IF @caMainID <>0
  9133. BEGIN
  9134. SELECT @caMainID = a.ID, @cpMainID = a.cpMainID, @Name = a.Name, @SecondId = SecondID,
  9135. @IsPause = a.IsPause, @dcRegionID = b.dcRegionId, @JobNumber = b.JobNumber,
  9136. @IsLimitLogin = b.IsLimitLogin, @RefreshDate = b.RefreshDate,
  9137. @cpName = b.Name, @IsAgent = b.IsAgent,
  9138. @IsLock = b.IsLock, @MemberType =MemberType, @thisDcProvinceID = dcProvinceID
  9139. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  9140. WHERE a.ID=@caMainID AND a.cpmainID = b.ID
  9141. END
  9142. IF @caMainID = 0 --在caMain表中没有记录
  9143. BEGIN
  9144. DECLARE @Company_XinxiID AS INT
  9145. DECLARE @AddMan AS SMALLINT
  9146. DECLARE @RegDate AS SMALLDATETIME
  9147. DECLARE @EMail AS VARCHAR(50)
  9148. SELECT @Cnt = COUNT(1)
  9149. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_UserNameLower))
  9150. WHERE UserNameLower = @UserName AND Password = @PlainPassword
  9151. IF @Cnt = 1
  9152. SELECT @cpName = CompanyName, @EMail = Email, @Company_XinxiID = ID, @AddMan = AddMan, @RegDate = RegDate
  9153. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_UserNameLower))
  9154. WHERE UserNameLower = @UserName
  9155. AND Password = @PlainPassword
  9156. ELSE IF @Cnt > 1
  9157. SELECT @cpName = CompanyName, @EMail = Email, @Company_XinxiID = ID, @AddMan = AddMan, @RegDate = RegDate
  9158. FROM Company_Xinxi WITH(NOLOCK INDEX(IX_Company_Xinxi_UserName))
  9159. WHERE UserName = @UserName
  9160. AND Password = @PlainPassword
  9161. IF @Company_XinxiID IS NOT NULL --如果在Company_xinxi中, 将其转移到cpmain中,并删除Company_xinxi中的记录
  9162. BEGIN
  9163. SET @CaType=1
  9164. ----企业表
  9165. INSERT INTO cpMain(dcProvinceID, dcRegionID, dcSubSiteID, RegisterIP, Name, RegDate, RegisterMode, AddMan, IsDefaultPassword)
  9166. VALUES(@dcProvinceID, @dcSubSiteID, @dcSubSiteID, @IP, @cpName, @RegDate, 1, @AddMan, 1)
  9167. SELECT @cpMainID = @@IDENTITY
  9168. ----账号表
  9169. INSERT INTO caMain(cpMainID, EMail, AccountType, UserName, Password)
  9170. VALUES(@cpMainID, @EMail, 1, @UserName, @Password)
  9171. SELECT TOP 1 @caMainID = ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID ORDER BY ID DESC
  9172. --INSERT INTO caPlainPassword(caMainId, PlainPassWord) SELECT @caMainID, @PlainPassword
  9173. ----顾问分配
  9174. EXEC ccCpMainByConsultantAssignUpdate @cpMainID, @dcProvinceID
  9175. SET @RefreshDate = GETDATE() - 10 --刷新时间和企业名称等变量
  9176. SET @thisDcProvinceID = @dcProvinceID
  9177. IF @cpName IS NULL
  9178. SET @cpName = '未命名企业'
  9179. ----日报表, 信息员推广过的个人注册,160天内作为推广ValIDCompany, 不判断省份
  9180. UPDATE DateReport
  9181. SET ValIDCompany = ValIDCompany +1
  9182. WHERE CountDate = @CountDate
  9183. AND Province_ID = @dcSubSiteID
  9184. --INSERT INTO pamainDatereport SELECT @cpMainID, 8, GETDATE() -- SEAN 20130911
  9185. ------判断是否有该行记录,没有则增加
  9186. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK) WHERE CountDate = @CountDate AND Province_ID = @dcProvinceID AND InfoManager_ID = @AddMan)
  9187. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, CountDate)
  9188. VALUES(@dcProvinceID, @AddMan, @CountDate)
  9189. ------记录数据,信息员工作量 + 1
  9190. UPDATE Info_DateReport
  9191. SET ValIDCompany = ValIDCompany + 1
  9192. WHERE CountDate = @CountDate
  9193. AND Province_ID = @dcProvinceID
  9194. AND InfoManager_ID = @AddMan
  9195. END
  9196. ELSE
  9197. GOTO ERR1 --用户名、密码不正确, cpMain、Company_xinxi中都没有
  9198. END
  9199. IF @IsPause = 1
  9200. GOTO ERR3 --企业账户被暂停
  9201. IF @IsLimitLogin = 9
  9202. GOTO Err4 --企业已经被限制登录
  9203. IF @thisDcProvinceID <> @dcProvinceID
  9204. GOTO Err5 --企业登陆网站不是注册网站
  9205. --Added By mice 123 判断是否为死客户,如果为死客户,则激活
  9206. IF EXISTS(SELECT 'X' FROM MainDb..bsDeadCompany x WITH(NOLOCK) WHERE x.cpMainID = @cpMainID AND x.ActiveDate IS NULL)
  9207. BEGIN
  9208. UPDATE MAINDB..bsDeadCompany SET ActiveDate = GETDATE() WHERE cpMainID = @cpMainID AND ActiveDate IS NULL
  9209. END
  9210. --根据企业购买的服务,确定每天最大登陆次数
  9211. IF @MemberType >= 3
  9212. SELECT @DayLoginNumber = 30
  9213. ELSE
  9214. SET @DayLoginNumber = 15
  9215. DECLARE @TodayLoginNumber AS TINYINT
  9216. SELECT @TodayLoginNumber = COUNT(1)
  9217. FROM CaLoginLog WITH(NOLOCK)
  9218. WHERE caMainID = @caMainID
  9219. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  9220. IF @TodayLoginNumber >= @DayLoginNumber
  9221. GOTO ERR2 --超过登陆次数, 每天限制登录次数
  9222. --登陆次数
  9223. UPDATE cpMain SET LoginCount = LoginCount + 1, LastLoginDate = GETDATE(), LastLoginIp = @IP WHERE ID = @cpMainID
  9224. UPDATE Job SET RefreshDate = GETDATE()
  9225. WHERE caMainID = @caMainID AND DATEDIFF(MINUTE, RefreshDate, GETDATE()) > 60 AND Valid = 1
  9226. --检查该企业数据是否已经在SearchDB..cpMainHomepageSnapshot
  9227. IF (@MemberType >= 2) OR (@dcProvinceID NOT IN(32, 30, 31, 35, 10, 11, 12, 40) AND @MemberType = 1)
  9228. IF NOT EXISTS(SELECT 'x' FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK) WHERE RealCpMainID = @cpMainID)
  9229. SET @RefreshDate = GETDATE() - 1
  9230. --IF DATEDIFF(MINUTE, @RefreshDate, GETDATE()) > 59 --刷新时间如果超过1个小时,更新为当前时间
  9231. -- UPDATE cpMain SET RefreshDate = GETDATE() WHERE ID = @cpMainID
  9232. --更新企业刷新时间, 更新职位刷新时间, 间隔时间1小时
  9233. IF DATEDIFF(MINUTE, @RefreshDate, GETDATE()) > 59 --刷新时间如果超过1个小时,更新为当前时间
  9234. BEGIN TRY
  9235. UPDATE cpMain SET RefreshDate = GETDATE() WHERE ID = @cpMainID
  9236. IF (@MemberType > 2)
  9237. BEGIN
  9238. IF EXISTS(SELECT 'x' FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK) WHERE RealCpMainID = @cpMainID)
  9239. DELETE FROM SearchDB..cpMainHomepageSnapshot WHERE RealCpMainID = @cpMainID
  9240. SELECT @JobID = dbo.GetJobSecondIds(@cpMainID), @JobName = dbo.GetJobNames(@cpMainID)
  9241. SELECT TOP 1 @LastJobIssueDate = IssueDate, @LastJobId = Id FROM Job WITH(NOLOCK)
  9242. WHERE cpMainID = @cpMainID AND Valid = 1 ORDER BY IssueDate DESC
  9243. INSERT SearchDB..cpMainHomepageSnapshot(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, MemberType, RealCpMainId, RefreshDate)
  9244. VALUES(@dcSubSiteID, LEFT(@dcRegionID, 4), @SecondID, @cpName, @IsAgent, @JobNumber, @JobID, @JobName, @LastJobIssueDate, @LastJobId, @MemberType, @cpMainId, GETDATE())
  9245. END
  9246. IF (@MemberType = 2) OR (@dcProvinceID NOT IN(32, 30, 31, 35, 10, 11, 12, 40) AND @MemberType = 1)
  9247. BEGIN
  9248. IF EXISTS(SELECT 'x' FROM SearchDB..cpMainHomepageSnapshot WITH(NOLOCK) WHERE RealCpMainID = @cpMainID)
  9249. DELETE FROM SearchDB..cpMainHomepageSnapshot WHERE RealCpMainID = @cpMainID
  9250. DECLARE @cpLicenceDate AS SMALLDATETIME
  9251. SELECT @cpLicenceDate = AddDate FROM cpLicence WITH(NOLOCK) WHERE cpMainID = @cpMainID
  9252. SELECT @JobID = dbo.GetJobSecondIds(@cpMainID), @JobName = dbo.GetJobNames(@cpMainID)
  9253. SELECT TOP 1 @LastJobIssueDate = IssueDate, @LastJobId = Id FROM Job WITH(NOLOCK)
  9254. WHERE cpMainID = @cpMainID AND Valid = 1 ORDER BY IssueDate DESC
  9255. INSERT SearchDB..cpMainHomepageSnapshot(dcSubsiteID, dcRegionID, cpMainID, Name, IsAgent, JobNumber, JobID, JobName, LastJobIssueDate, LastJobId, MemberType, cpLicenceDate, RealCpMainId, RefreshDate)
  9256. VALUES(@dcSubSiteID, LEFT(@dcRegionID, 4), @SecondID, @cpName, @IsAgent, @JobNumber, @JobID, @JobName, @LastJobIssueDate, @LastJobId, @MemberType, @cpLicenceDate, @cpMainId, GETDATE())
  9257. END
  9258. END TRY
  9259. BEGIN CATCH
  9260. --print 'Error '
  9261. INSERT INTO PaMainDateReport SELECT @cpMainID, 99, GETDATE() --20130709 lambo
  9262. END CATCH
  9263. IF ISNULL(@Name, '') = ''
  9264. SET @Name = @UserName
  9265. --记录每日登录数据
  9266. IF NOT EXISTS(SELECT 'x' FROM caloginlog a WITH(NOLOCK), caMain b WITH(NOLOCK)
  9267. WHERE a.caMainID = b.ID
  9268. AND b.cpMainID = @cpMainID
  9269. AND a.AddDate >= CONVERT(VARCHAR(10), GETDATE(), 120)
  9270. ) AND @Company_XinxiID IS NULL
  9271. BEGIN
  9272. UPDATE DateReport
  9273. SET CompanyLoginNum_Net = CompanyLoginNum_Net + 1
  9274. WHERE Province_ID = @dcSubSiteID
  9275. AND CountDate = @CountDate
  9276. --INSERT INTO PaMainDateReport SELECT @cpMainID, 10, GETDATE() --20130709 lambo
  9277. END
  9278. --登陆日志, 记录Cookies
  9279. IF ISNULL(@LoginCookies, '') = ''
  9280. SET @LoginCookies = RTRIM(CONVERT(VARCHAR(16), @SessionID))
  9281. INSERT INTO caLoginLog(caMainID, cpMainName, caMainName, LoginIP, LoginCookies, browser, loginFrom)
  9282. VALUES(@caMainID, @cpName, @Name, @IP, @LoginCookies, '2:' + ISNULL(@browser, 'Null'), @loginFrom )
  9283. IF @MemberType = 3 AND GETDATE()<'2014-11-1'
  9284. IF NOT EXISTS(SELECT TOP 1 'x' FROM LotteryCompanyLoginLog WITH(NOLOCK)
  9285. WHERE cpMainID = @cpMainID
  9286. AND LoginDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  9287. )
  9288. BEGIN
  9289. --取昨天是第几天登陆
  9290. DECLARE @LastLoginNo INT
  9291. SELECT @LastLoginNo = LoginNo FROM LotteryCompanyLoginLog
  9292. WHERE cpMainID=@cpMainID
  9293. AND CONVERT(VARCHAR(8), LoginDate, 112) = CONVERT(VARCHAR(8), GETDATE() - 1, 112)
  9294. SET @LastLoginNo = ISNULL(@LastLoginNo, 0)
  9295. IF @LastLoginNo = 5
  9296. SET @LastLoginNo = 1
  9297. ELSE
  9298. BEGIN
  9299. SET @LastLoginNo = @LastLoginNo + 1
  9300. IF @LastLoginNo = 5
  9301. INSERT INTO lotteryCompany(CpMainID, CaOrderID, LoginDate, Used, AddDate)
  9302. SELECT @cpMainID, NULL, GETDATE(), 0, GETDATE()
  9303. END
  9304. INSERT INTO LotteryCompanyLoginLog(cpMainID, LoginDate, LoginNo)
  9305. SELECT @cpMainID, GETDATE(), @LastLoginNo
  9306. END
  9307. END TRY
  9308. BEGIN CATCH
  9309. GOTO ERR
  9310. END CATCH
  9311. COMMIT TRAN
  9312. RETURN @caMainID
  9313. ERR:
  9314. BEGIN
  9315. ROLLBACK TRAN
  9316. print 0
  9317. RETURN 0
  9318. END
  9319. ERR1:
  9320. BEGIN
  9321. ROLLBACK TRAN
  9322. print -1
  9323. RETURN -1
  9324. END
  9325. ERR2:
  9326. BEGIN
  9327. ROLLBACK TRAN
  9328. IF @DayLoginNumber = 15
  9329. BEGIN
  9330. print -2
  9331. RETURN -2
  9332. END
  9333. IF @DayLoginNumber = 30
  9334. BEGIN
  9335. print -3
  9336. RETURN -3
  9337. END
  9338. END
  9339. ERR3:
  9340. BEGIN
  9341. ROLLBACK TRAN
  9342. print -4
  9343. RETURN -4
  9344. END
  9345. ERR4:
  9346. BEGIN
  9347. ROLLBACK TRAN
  9348. print 0
  9349. RETURN -9
  9350. END
  9351. ERR5:
  9352. BEGIN
  9353. ROLLBACK TRAN
  9354. print @cpMainID * -1
  9355. RETURN @cpMainID * -1
  9356. END
  9357. GO
  9358. /****** Object: StoredProcedure [dbo].[cccaMainByMobileVerifyDateUpdate] Script Date: 2018/12/13 19:06:04 ******/
  9359. SET ANSI_NULLS ON
  9360. GO
  9361. SET QUOTED_IDENTIFIER ON
  9362. GO
  9363. CREATE PROCEDURE [dbo].[cccaMainByMobileVerifyDateUpdate]
  9364. (
  9365. @caMainID INT,
  9366. @cpMainID INT,
  9367. @Mobile VARCHAR(11),
  9368. @Code VARCHAR(6),
  9369. @IsMobileHide BIT,
  9370. @IP VARCHAR(30)
  9371. )
  9372. AS
  9373. SET NOCOUNT ON
  9374. BEGIN
  9375. IF NOT EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID)
  9376. RETURN 0
  9377. DECLARE @VerifyCode VARCHAR(6), @VerifyLogID INT
  9378. SELECT TOP 1 @VerifyCode = VerifyCode, @VerifyLogID = ID FROM CaVerifyLog WITH(NOLOCK)
  9379. WHERE Mobile = @Mobile
  9380. AND AddDate > DATEADD(HOUR, -1, GETDATE())
  9381. AND IP = @IP
  9382. AND VerifyDate IS NULL
  9383. ORDER BY ID DESC
  9384. IF @VerifyCode IS NULL
  9385. RETURN -1
  9386. IF NOT @VerifyCode = @Code
  9387. RETURN -1
  9388. UPDATE CaVerifyLog SET VerifyDate = GETDATE() WHERE ID = @VerifyLogID
  9389. UPDATE caMain SET IsMobileHide = @IsMobileHide, Mobile = @Mobile, MobileVerifyDate = GETDATE() WHERE ID = @caMainID
  9390. RETURN 1
  9391. END
  9392. GO
  9393. /****** Object: StoredProcedure [dbo].[ccCaMainByPasswordUpdate] Script Date: 2018/12/13 19:06:05 ******/
  9394. SET ANSI_NULLS ON
  9395. GO
  9396. SET QUOTED_IDENTIFIER ON
  9397. GO
  9398. CREATE PROCEDURE [dbo].[ccCaMainByPasswordUpdate]
  9399. (
  9400. @ID INT,
  9401. @Password VARCHAR(60),
  9402. @PlainPassword VARCHAR(20)
  9403. )
  9404. AS
  9405. BEGIN TRAN
  9406. --IF dbo.IsAccount(@PlainPassword) = 0
  9407. --BEGIN
  9408. -- GOTO Err
  9409. --END
  9410. IF dbo.IsPassword(@Password) = 0
  9411. BEGIN
  9412. GOTO Err
  9413. END
  9414. BEGIN TRY
  9415. UPDATE caMain SET Password = @Password WHERE ID = @ID
  9416. INSERT INTO caPlainPassword(caMainId, PlainPassWord) SELECT @ID, @PlainPassword
  9417. END TRY
  9418. BEGIN CATCH
  9419. GOTO ERR
  9420. END CATCH
  9421. COMMIT TRAN
  9422. RETURN 1
  9423. ERR:
  9424. BEGIN
  9425. ROLLBACK TRAN
  9426. RETURN 0
  9427. END
  9428. GO
  9429. /****** Object: StoredProcedure [dbo].[ccCaMainByResetPasswordUpdate] Script Date: 2018/12/13 19:06:05 ******/
  9430. SET ANSI_NULLS ON
  9431. GO
  9432. SET QUOTED_IDENTIFIER ON
  9433. GO
  9434. /*
  9435. sean 重置密码,2012-10-1 增加密码加密
  9436. */
  9437. CREATE PROCEDURE [dbo].[ccCaMainByResetPasswordUpdate]
  9438. (
  9439. @ID INT,
  9440. @Password VARCHAR(60),
  9441. @PlainPassword VARCHAR(20),
  9442. @ManagerID INT
  9443. )
  9444. AS
  9445. BEGIN TRAN
  9446. BEGIN TRY
  9447. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK)
  9448. WHERE AccountType = 1 AND ID = @ManagerID
  9449. AND cpMainID = (SELECT cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @ID)
  9450. )
  9451. GOTO ERR1
  9452. UPDATE caMain SET Password = @Password WHERE ID = @ID
  9453. INSERT INTO caPlainPassword(caMainId, PlainPassWord) SELECT @ID, @PlainPassword
  9454. END TRY
  9455. BEGIN CATCH
  9456. GOTO ERR
  9457. END CATCH
  9458. COMMIT TRAN
  9459. RETURN 1
  9460. ERR:
  9461. BEGIN
  9462. ROLLBACK TRAN
  9463. RETURN 0
  9464. END
  9465. ERR1:
  9466. BEGIN
  9467. ROLLBACK TRAN
  9468. RETURN -1
  9469. END
  9470. GO
  9471. /****** Object: StoredProcedure [dbo].[ccCaMainByResetUsernameUpdate] Script Date: 2018/12/13 19:06:05 ******/
  9472. SET ANSI_NULLS ON
  9473. GO
  9474. SET QUOTED_IDENTIFIER ON
  9475. GO
  9476. CREATE PROCEDURE [dbo].[ccCaMainByResetUsernameUpdate]
  9477. (
  9478. @ID INT,
  9479. @Username VARCHAR(60),
  9480. @ManagerID INT
  9481. )
  9482. AS
  9483. BEGIN TRAN
  9484. BEGIN TRY
  9485. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK)
  9486. WHERE AccountType = 1 AND ID = @ManagerID
  9487. AND cpMainID = (SELECT cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @ID)
  9488. )
  9489. GOTO ERR1
  9490. UPDATE caMain SET Username = @Username WHERE ID = @ID
  9491. END TRY
  9492. BEGIN CATCH
  9493. GOTO ERR
  9494. END CATCH
  9495. COMMIT TRAN
  9496. RETURN 1
  9497. ERR:
  9498. BEGIN
  9499. ROLLBACK TRAN
  9500. RETURN 0
  9501. END
  9502. ERR1:
  9503. BEGIN
  9504. ROLLBACK TRAN
  9505. RETURN -1
  9506. END
  9507. GO
  9508. /****** Object: StoredProcedure [dbo].[ccCaMainBySelfPasswordUpdate] Script Date: 2018/12/13 19:06:05 ******/
  9509. SET ANSI_NULLS ON
  9510. GO
  9511. SET QUOTED_IDENTIFIER ON
  9512. GO
  9513. /*
  9514. sean 重置密码,2012-10-1 增加密码加密
  9515. */
  9516. CREATE PROCEDURE [dbo].[ccCaMainBySelfPasswordUpdate]
  9517. (
  9518. @ID INT,
  9519. @Password VARCHAR(60),
  9520. @PlainPassword VARCHAR(20)
  9521. )
  9522. AS
  9523. BEGIN TRY
  9524. UPDATE caMain SET Password = @Password WHERE ID = @ID
  9525. INSERT caplainpassword(caMainId, PlainPassword) SELECT @ID, @PlainPassword
  9526. RETURN 1
  9527. END TRY
  9528. BEGIN CATCH
  9529. RETURN 0
  9530. END CATCH
  9531. GO
  9532. /****** Object: StoredProcedure [dbo].[ccCaMainByUserCountSelect] Script Date: 2018/12/13 19:06:05 ******/
  9533. SET ANSI_NULLS ON
  9534. GO
  9535. SET QUOTED_IDENTIFIER ON
  9536. GO
  9537. --========================================
  9538. --检查sean 2010-10-29
  9539. --企业用户数量
  9540. --========================================
  9541. CREATE PROCEDURE [dbo].[ccCaMainByUserCountSelect]
  9542. (
  9543. @cpMainID INT
  9544. )
  9545. AS
  9546. BEGIN
  9547. DECLARE @UserCount AS INT
  9548. SELECT @UserCount=COUNT(*)
  9549. FROM caMain WITH(NOLOCK)
  9550. WHERE cpMainID = @cpMainID AND IsDelete=0
  9551. RETURN @UserCount
  9552. END
  9553. GO
  9554. /****** Object: StoredProcedure [dbo].[ccCaMainByUserNameLowerSelect] Script Date: 2018/12/13 19:06:06 ******/
  9555. SET ANSI_NULLS ON
  9556. GO
  9557. SET QUOTED_IDENTIFIER ON
  9558. GO
  9559. --#####################################################
  9560. --创建时间:2014.10.30
  9561. --创建人:Nick
  9562. --说明:根据输入用户名得到企业信息
  9563. --修改harry:2018-1-8 增加dcregionid
  9564. --#####################################################
  9565. CREATE PROCEDURE [dbo].[ccCaMainByUserNameLowerSelect]
  9566. (
  9567. @UserName VARCHAR(50)
  9568. )
  9569. AS
  9570. BEGIN TRY
  9571. SELECT a.ID,a.Password,a.UserName,a.UserNameLower,b.dcProvinceID, b.dcregionid, b.dcregionid
  9572. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  9573. WHERE a.UserNameLower = @UserName
  9574. AND a.cpMainID = b.ID
  9575. AND a.IsDelete = 0
  9576. AND b.IsDelete = 0
  9577. END TRY
  9578. BEGIN CATCH
  9579. RETURN 0
  9580. END CATCH
  9581. GO
  9582. /****** Object: StoredProcedure [dbo].[ccCaMainByUsernameUpdate] Script Date: 2018/12/13 19:06:06 ******/
  9583. SET ANSI_NULLS ON
  9584. GO
  9585. SET QUOTED_IDENTIFIER ON
  9586. GO
  9587. CREATE PROCEDURE [dbo].[ccCaMainByUsernameUpdate]
  9588. (
  9589. @ID INT,
  9590. @NewUsername VARCHAR(20)
  9591. )
  9592. AS
  9593. BEGIN TRAN
  9594. BEGIN TRY
  9595. --用户名不能重复
  9596. IF EXISTS(SELECT ID FROM caMain WITH(NOLOCK) WHERE UserNameLower = @NewUserName)
  9597. GOTO ERR1
  9598. IF EXISTS(SELECT 'x' FROM Company_Xinxi WITH(NOLOCK) WHERE UserNameLower = @NewUSerName)
  9599. GOTO ERR1
  9600. IF dbo.IsAccount(@NewUsername) = 0
  9601. BEGIN
  9602. GOTO Err
  9603. END
  9604. UPDATE caMain SET Username = @NewUsername WHERE ID = @ID
  9605. END TRY
  9606. BEGIN CATCH
  9607. GOTO ERR
  9608. END CATCH
  9609. COMMIT
  9610. RETURN 1
  9611. ERR:
  9612. BEGIN
  9613. ROLLBACK TRAN
  9614. RETURN 0
  9615. END
  9616. ERR1:
  9617. BEGIN
  9618. ROLLBACK TRAN
  9619. RETURN -10
  9620. END
  9621. GO
  9622. /****** Object: StoredProcedure [dbo].[ccCaMainDelete] Script Date: 2018/12/13 19:06:06 ******/
  9623. SET ANSI_NULLS ON
  9624. GO
  9625. SET QUOTED_IDENTIFIER ON
  9626. GO
  9627. CREATE PROCEDURE [dbo].[ccCaMainDelete]
  9628. @OperatorID INT,
  9629. @ID INT
  9630. AS
  9631. BEGIN TRAN
  9632. IF @OperatorID=@ID
  9633. RETURN 0
  9634. BEGIN TRY
  9635. IF EXISTS(
  9636. SELECT a.ID FROM
  9637. caMain a WITH(NOLOCK),
  9638. caMain b WITH(NOLOCK)
  9639. WHERE a.cpMainID=b.cpMainID
  9640. AND a.AccountType=1
  9641. AND b.AccountType>1
  9642. AND a.ID=@OperatorID
  9643. AND b.ID=@ID
  9644. )
  9645. BEGIN
  9646. UPDATE Job SET IsDelete=1 WHERE caMainID = @ID
  9647. DELETE FROM bsCpModify WHERE caMainID = @ID
  9648. UPDATE caMain SET IsDelete=1 WHERE ID=@ID
  9649. DECLARE @desc AS VARCHAR(200)
  9650. SET @desc = '删除用户:用户ID:' + CONVERT(CHAR(10),@ID)
  9651. EXEC ccCaOperationLogInsert @ID, 17, @desc
  9652. END
  9653. END TRY
  9654. BEGIN CATCH
  9655. GOTO ERR
  9656. END CATCH
  9657. COMMIT TRAN
  9658. RETURN 1
  9659. ERR:
  9660. BEGIN
  9661. ROLLBACK TRAN
  9662. RETURN 0
  9663. END
  9664. GO
  9665. /****** Object: StoredProcedure [dbo].[ccCaMainGenderSelect] Script Date: 2018/12/13 19:06:06 ******/
  9666. SET ANSI_NULLS ON
  9667. GO
  9668. SET QUOTED_IDENTIFIER ON
  9669. GO
  9670. --#####################################################
  9671. --创建时间:2014.10.30
  9672. --创建人:Nick
  9673. --说明:获取性别
  9674. --#####################################################
  9675. CREATE PROCEDURE [dbo].[ccCaMainGenderSelect]
  9676. (
  9677. @ID INT
  9678. )
  9679. AS
  9680. BEGIN TRY
  9681. SELECT Gender FROM CaMain WITH(NOLOCK) WHERE ID = @ID
  9682. END TRY
  9683. BEGIN CATCH
  9684. RETURN 0
  9685. END CATCH
  9686. GO
  9687. /****** Object: StoredProcedure [dbo].[ccCaMainIsDeleteUpdate] Script Date: 2018/12/13 19:06:06 ******/
  9688. SET ANSI_NULLS ON
  9689. GO
  9690. SET QUOTED_IDENTIFIER ON
  9691. GO
  9692. CREATE PROCEDURE [dbo].[ccCaMainIsDeleteUpdate]
  9693. @OperatorID INT,
  9694. @ID INT
  9695. AS
  9696. BEGIN TRAN
  9697. IF @OperatorID=@ID
  9698. RETURN 0
  9699. BEGIN TRY
  9700. IF EXISTS(
  9701. SELECT a.ID FROM
  9702. caMain a WITH(NOLOCK),
  9703. caMain b WITH(NOLOCK)
  9704. WHERE a.cpMainID=b.cpMainID
  9705. AND a.AccountType=1
  9706. AND b.AccountType>1
  9707. AND a.ID=@OperatorID
  9708. AND b.ID=@ID
  9709. )
  9710. BEGIN
  9711. UPDATE caMain SET IsDelete=1 WHERE ID=@ID
  9712. END
  9713. END TRY
  9714. BEGIN CATCH
  9715. GOTO ERR
  9716. END CATCH
  9717. COMMIT TRAN
  9718. RETURN 1
  9719. ERR:
  9720. BEGIN
  9721. ROLLBACK TRAN
  9722. RETURN 0
  9723. END
  9724. GO
  9725. /****** Object: StoredProcedure [dbo].[ccCaMainSave] Script Date: 2018/12/13 19:06:06 ******/
  9726. SET ANSI_NULLS ON
  9727. GO
  9728. SET QUOTED_IDENTIFIER ON
  9729. GO
  9730. --====================================
  9731. --检查: sean 2010-11-1
  9732. --修改harry 2018-1-23
  9733. --修改Carl 2018-02-11
  9734. --====================================
  9735. CREATE PROCEDURE [dbo].[ccCaMainSave]
  9736. (
  9737. @caMainID INT,
  9738. @ID INT,
  9739. @cpMainID INT,
  9740. @AccountType INT,
  9741. @UserName VARCHAR(20),
  9742. @Password VARCHAR(60),
  9743. @PlainPassword VARCHAR(40),
  9744. @Name VARCHAR(12),
  9745. @Gender BIT,
  9746. @Title VARCHAR(40),
  9747. @Dept VARCHAR(40),
  9748. @Telephone VARCHAR(20),
  9749. @Mobile VARCHAR(11),
  9750. @Fax VARCHAR(20),
  9751. @EMail VARCHAR(50),
  9752. @QQ VARCHAR(13),
  9753. @IsPhoneHide BIT,
  9754. @IsNameHide BIT,
  9755. @IsMobileHide BIT,
  9756. @EmailSentType INT,
  9757. @IsReceiveSMS BIT,
  9758. @WeChat VARCHAR(20)
  9759. )
  9760. AS
  9761. SET NOCOUNT ON
  9762. IF @Telephone LIKE '00%'
  9763. RETURN 0
  9764. BEGIN TRAN
  9765. DECLARE @MaxID AS INT
  9766. SET @Dept = dbo.TrimNULL(@Dept)
  9767. SET @Title = dbo.TrimNULL(@Title)
  9768. SET @Email = dbo.TrimNULL(@Email)
  9769. SET @Telephone = dbo.TrimNULL(@Telephone)
  9770. SET @Mobile = dbo.TrimNULL(@Mobile)
  9771. SET @Fax = dbo.TrimNULL(@Fax)
  9772. SET @QQ = dbo.TrimNULL(@QQ)
  9773. IF @Telephone IS NULL
  9774. SET @IsPhoneHide = 1
  9775. IF @Mobile IS NULL
  9776. SET @IsMobileHide = 1
  9777. BEGIN TRY
  9778. SET @MaxID = 0
  9779. IF @ID>0
  9780. BEGIN
  9781. DECLARE @MID AS INT
  9782. SELECT TOP 1 @MID=ID FROM caMain WITH(NOLOCK) WHERE cpMainID=@cpMainID AND AccountType=1
  9783. IF @caMainID=@ID OR @caMainID=@MID
  9784. BEGIN
  9785. DECLARE @NameOld AS NVARCHAR(60)
  9786. DECLARE @TitleOld AS VARCHAR(MAX)
  9787. DECLARE @DeptOld AS VARCHAR(MAX)
  9788. SELECT @NameOld=RTRIM(ISNULL(Name, '')), @TitleOld=RTRIM(ISNULL(Title, '')), @DeptOld=RTRIM(ISNULL(Dept, ''))
  9789. FROM caMain WITH(NOLOCK)
  9790. WHERE ID=@ID
  9791. --新增
  9792. UPDATE caMain SET QQAddMan=0 WHERE ID=@ID AND QQ<>@QQ
  9793. UPDATE caMain SET WeChatAddMan=0 WHERE ID=@ID AND WeChat<>@WeChat
  9794. UPDATE caMain SET
  9795. Name = @Name,
  9796. Gender = @Gender,
  9797. Title = @Title,
  9798. Dept = @Dept,
  9799. Telephone = @Telephone,
  9800. Mobile = @Mobile,
  9801. Fax = @Fax,
  9802. EMail = @EMail,
  9803. QQ = @QQ,
  9804. IsPhoneHide = @IsPhoneHide,
  9805. IsNameHide = @IsNameHide,
  9806. IsMobileHide = @IsMobileHide,
  9807. EmailSentType = @EmailSentType,
  9808. IsReceiveSMS = @IsReceiveSMS,
  9809. WeChat = @WeChat,
  9810. LastModifyDate = GETDATE()
  9811. WHERE ID=@ID
  9812. SET @MaxID = @ID
  9813. IF @NameOld <> RTRIM(@Name)
  9814. BEGIN
  9815. DELETE FROM bsCpModify WHERE caMainID=@ID AND Location='b1'
  9816. INSERT INTO bsCpModify (cpMainID,caMainID,Location,ColValue) VALUES(@cpMainID, @ID,'b1', @Name)
  9817. END
  9818. IF RTRIM(@TitleOld) <> RTRIM(@Title)
  9819. BEGIN
  9820. DELETE FROM bsCpModify WHERE caMainID=@ID AND Location='b2'
  9821. INSERT INTO bsCpModify (cpMainID,caMainID,Location,ColValue) VALUES(@cpMainID, @ID,'b2', @Title)
  9822. END
  9823. IF @DeptOld <> RTRIM(@Dept)
  9824. BEGIN
  9825. DELETE FROM bsCpModify WHERE caMainID=@ID AND Location='b3'
  9826. INSERT INTO bsCpModify (cpMainID,caMainID,Location,ColValue) VALUES(@cpMainID, @ID,'b3', @Dept)
  9827. END
  9828. EXEC ccCaOperationLogInsert @ID, 18, '更新用户信息'
  9829. --更新企业信息,maxjobnumber=1
  9830. -- IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID AND ISNULL(MaxJobNumber, 0) = 0)
  9831. -- UPDATE cpMain SET MaxJobNumber = 1 WHERE ID = @cpMainID
  9832. END
  9833. ELSE
  9834. SET @MaxID = 0
  9835. END
  9836. ELSE
  9837. BEGIN
  9838. INSERT INTO caMain(
  9839. RegDate, cpMainID, AccountType, UserName,Password,
  9840. Name, Gender, Title, Dept, Telephone, Mobile,
  9841. Fax, QQ, EMail, IsPhoneHide, IsNameHide, IsMobileHide,
  9842. EmailSentType, IsReceiveSMS, LastModifyDate, WeChat
  9843. )
  9844. VALUES(
  9845. GETDATE(), @cpMainID, @AccountType, @UserName, @Password,
  9846. @Name, @Gender, @Title, @Dept, @Telephone, @Mobile,
  9847. @Fax, @QQ, @EMail, @IsPhoneHide, @IsNameHide, @IsMobileHide,
  9848. @EmailSentType, @IsReceiveSMS, GETDATE(), @WeChat
  9849. )
  9850. SET @MaxID = (SELECT TOP 1 ID FROM caMain WITH(NOLOCK) WHERE cpMAinID = @cpMainID ORDER BY ID DESC)
  9851. INSERT INTO caPlainPassword(caMainID,PlainPassword) VALUES(@MaxID,@PlainPassword)
  9852. INSERT INTO bsCpModify(cpMainID, caMainID, Location, ColValue) VALUES(@cpMainID, @MaxID, 'b1', @Name)
  9853. IF @Title IS NOT NULL
  9854. INSERT INTO bsCpModify (cpMainID,caMainID,Location,ColValue) VALUES(@cpMainID, @MaxID,'b2', @Title)
  9855. IF @Dept IS NOT NULL
  9856. INSERT INTO bsCpModify (cpMainID,caMainID,Location,ColValue) VALUES(@cpMainID, @MaxID,'b3', @Dept)
  9857. END
  9858. IF EXISTS(SELECT TOP 1 'X' FROM caVerifyLog WHERE VerifyDate > DATEAdd(n, -1, GETDATE()) AND Mobile = @Mobile)
  9859. UPDATE caMain SET MobileVerifyDate = GETDATE() WHERE ID = @MaxID
  9860. --ELSE--harry 2018-1-23 C#代码已处理,修改操作也都是认证了的,在不修改手机号的保存用户的情况下会重复认证
  9861. -- UPDATE caMain SET MobileVerifyDate = NULL WHERE ID = @MaxID
  9862. END TRY
  9863. BEGIN CATCH
  9864. GOTO ERR
  9865. END CATCH
  9866. COMMIT TRAN
  9867. RETURN @MaxID
  9868. ERR:
  9869. BEGIN
  9870. ROLLBACK TRAN
  9871. RETURN 0
  9872. END
  9873. GO
  9874. /****** Object: StoredProcedure [dbo].[ccCaMainSecondPasswordByIDSelect] Script Date: 2018/12/13 19:06:07 ******/
  9875. SET ANSI_NULLS ON
  9876. GO
  9877. SET QUOTED_IDENTIFIER ON
  9878. GO
  9879. --#####################################################
  9880. --创建时间:2014.10.30
  9881. --创建人:Nick
  9882. --说明:获取用户的保护密码
  9883. --#####################################################
  9884. CREATE PROCEDURE [dbo].[ccCaMainSecondPasswordByIDSelect]
  9885. (
  9886. @ID INT
  9887. )
  9888. AS
  9889. BEGIN TRY
  9890. SELECT SecondPassword FROM caMain WHERE id=@ID
  9891. END TRY
  9892. BEGIN CATCH
  9893. RETURN 0
  9894. END CATCH
  9895. GO
  9896. /****** Object: StoredProcedure [dbo].[ccCaMainSecondPasswordByIDUpdate] Script Date: 2018/12/13 19:06:07 ******/
  9897. SET ANSI_NULLS ON
  9898. GO
  9899. SET QUOTED_IDENTIFIER ON
  9900. GO
  9901. --#####################################################
  9902. --创建时间:2014.10.30
  9903. --创建人:Nick
  9904. --说明:修改用户的保护密码
  9905. --#####################################################
  9906. CREATE PROCEDURE [dbo].[ccCaMainSecondPasswordByIDUpdate]
  9907. (
  9908. @ID INT,
  9909. @Password VARCHAR(60)
  9910. )
  9911. AS
  9912. BEGIN TRY
  9913. UPDATE caMain SET SecondPassword = @Password WHERE ID=@ID
  9914. UPDATE cpMain SET IsProtect=1 WHERE ID=(SELECT cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @ID)
  9915. RETURN 1
  9916. END TRY
  9917. BEGIN CATCH
  9918. RETURN 0
  9919. END CATCH
  9920. GO
  9921. /****** Object: StoredProcedure [dbo].[ccCaMainSelect] Script Date: 2018/12/13 19:06:07 ******/
  9922. SET ANSI_NULLS ON
  9923. GO
  9924. SET QUOTED_IDENTIFIER ON
  9925. GO
  9926. --##################################
  9927. --检查: sean 201011-19
  9928. --##################################
  9929. CREATE PROCEDURE [dbo].[ccCaMainSelect]
  9930. (
  9931. @ID INT
  9932. )
  9933. AS
  9934. BEGIN
  9935. SELECT *,
  9936. (SELECT TOP 1 ID
  9937. FROM paLoginContact WITH(NOLOCK)
  9938. WHERE paMainID = @ID AND ContactType = 101) IsWeixinBind
  9939. FROM caMain WITH(NOLOCK)
  9940. WHERE ID = @ID
  9941. AND IsDelete = 0
  9942. END
  9943. GO
  9944. /****** Object: StoredProcedure [dbo].[ccCaMainUserNameExist] Script Date: 2018/12/13 19:06:08 ******/
  9945. SET ANSI_NULLS ON
  9946. GO
  9947. SET QUOTED_IDENTIFIER ON
  9948. GO
  9949. --==================================
  9950. --UserName已经存在
  9951. --检查: sean 2010-10-22
  9952. --==================================
  9953. CREATE PROCEDURE [dbo].[ccCaMainUserNameExist]
  9954. (
  9955. @UserName VARCHAR(20)
  9956. )
  9957. AS
  9958. BEGIN
  9959. BEGIN TRY
  9960. SET @UserName = LTRIM(RTRIM(@UserName))
  9961. IF EXISTS(SELECT ID FROM caMain WITH(NOLOCK) WHERE UserNameLower = @UserName)
  9962. RETURN 1
  9963. ELSE IF EXISTS(SELECT ID FROM Company_xinxi WITH(NOLOCK) WHERE UserNameLower = @UserName)
  9964. RETURN 1
  9965. RETURN 0
  9966. END TRY
  9967. BEGIN CATCH
  9968. RETURN 0
  9969. END CATCH
  9970. END
  9971. GO
  9972. /****** Object: StoredProcedure [dbo].[ccCaOperationLogByCaMainIDSelect] Script Date: 2018/12/13 19:06:08 ******/
  9973. SET ANSI_NULLS ON
  9974. GO
  9975. SET QUOTED_IDENTIFIER ON
  9976. GO
  9977. --lambo 20110114
  9978. --用于企业模块,查询用户自己的操作记录
  9979. CREATE PROCEDURE [dbo].[ccCaOperationLogByCaMainIDSelect]
  9980. (
  9981. @caMainID INT
  9982. )
  9983. AS
  9984. BEGIN
  9985. SELECT * FROM caOperationLog WITH(NOLOCK)
  9986. WHERE caMainID=@caMainID
  9987. ORDER BY ID DESC
  9988. END
  9989. GO
  9990. /****** Object: StoredProcedure [dbo].[ccCaOperationLogByCpMainIDSelect] Script Date: 2018/12/13 19:06:08 ******/
  9991. SET ANSI_NULLS ON
  9992. GO
  9993. SET QUOTED_IDENTIFIER ON
  9994. GO
  9995. --lambo 20110114
  9996. --用于企业部分,管理员查询所有用户的操作记录
  9997. CREATE PROCEDURE [dbo].[ccCaOperationLogByCpMainIDSelect]
  9998. (
  9999. @cpMainID INT
  10000. )
  10001. AS
  10002. BEGIN
  10003. SELECT a.*,b.Name,b.Telephone FROM caOperationLog a WITH(NOLOCK),caMain b WITH(NOLOCK)
  10004. WHERE a.caMainID = b.ID
  10005. AND b.cpMainID=@cpMainID
  10006. ORDER BY a.ID DESC
  10007. END
  10008. GO
  10009. /****** Object: StoredProcedure [dbo].[ccCaOperationLogByIpInsert] Script Date: 2018/12/13 19:06:08 ******/
  10010. SET ANSI_NULLS ON
  10011. GO
  10012. SET QUOTED_IDENTIFIER ON
  10013. GO
  10014. CREATE PROCEDURE [dbo].[ccCaOperationLogByIpInsert]
  10015. (
  10016. @caMainID AS INT,
  10017. @Operation AS INT,
  10018. @Details AS NVARCHAR(200),
  10019. @IP AS VARCHAR(31)
  10020. )
  10021. AS
  10022. SET NOCOUNT ON
  10023. BEGIN
  10024. INSERT INTO CaOperationLog(caMainID, Operation, Details, IP)
  10025. VALUES(@caMainID, @Operation, @Details, @IP)
  10026. END
  10027. GO
  10028. /****** Object: StoredProcedure [dbo].[ccCaOperationLogInsert] Script Date: 2018/12/13 19:06:08 ******/
  10029. SET ANSI_NULLS ON
  10030. GO
  10031. SET QUOTED_IDENTIFIER ON
  10032. GO
  10033. CREATE PROCEDURE [dbo].[ccCaOperationLogInsert]
  10034. (
  10035. @caMainID AS INT,
  10036. @Operation AS INT,
  10037. @Details AS NVARCHAR(200)
  10038. )
  10039. AS
  10040. BEGIN
  10041. DECLARE @IP AS VARCHAR(31)
  10042. SELECT TOP 1 @IP = LoginIP FROM caLoginLog WITH(NOLOCK) WHERE caMainID = @caMainID ORDER BY ID DESC
  10043. IF @IP IS NULL
  10044. BEGIN
  10045. DECLARE @cpMainID AS INT, @ManagerID AS INT, @RegIP AS VARCHAR(31)
  10046. SELECT @cpMainID = a.ID, @RegIP = a.RegisterIP
  10047. FROM cpMain a WITH(NOLOCK)
  10048. INNER JOIN caMain b WITH(NOLOCK) ON a.ID = b.cpMainID
  10049. WHERE b.ID = @caMainID
  10050. SELECT @ManagerID = ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainId AND AccountType = 1
  10051. SELECT TOP 1 @IP = LoginIP FROM caLoginLog WITH(NOLOCK) WHERE caMainID = @ManagerID ORDER BY ID DESC
  10052. IF @IP IS NULL
  10053. SET @IP = @RegIP
  10054. END
  10055. IF @IP IS NULL
  10056. SET @IP= ''
  10057. INSERT INTO CaOperationLog(caMainID, Operation, Details, IP)
  10058. VALUES(@caMainID, @Operation, @Details, @IP)
  10059. END
  10060. GO
  10061. /****** Object: StoredProcedure [dbo].[cccaOrderByAllUsedSelect] Script Date: 2018/12/13 19:06:08 ******/
  10062. SET ANSI_NULLS ON
  10063. GO
  10064. SET QUOTED_IDENTIFIER ON
  10065. GO
  10066. CREATE PROCEDURE [dbo].[cccaOrderByAllUsedSelect]
  10067. (
  10068. @cpMainID INT
  10069. )
  10070. AS
  10071. BEGIN
  10072. SELECT ID, OrderType, jobRefreshQuota FROM caOrder a
  10073. WHERE a.cpMainID = @cpMainID
  10074. AND (a.OrderType = 8 Or a.OrderType = 9 Or a.OrderType = 14 Or a.OrderType = 15)
  10075. AND a.BeginDate < GETDATE() AND IsDeleted=0
  10076. ORDER BY a.endDate
  10077. END
  10078. GO
  10079. /****** Object: StoredProcedure [dbo].[cccaOrderByAllValidSelect] Script Date: 2018/12/13 19:06:09 ******/
  10080. SET ANSI_NULLS ON
  10081. GO
  10082. SET QUOTED_IDENTIFIER ON
  10083. GO
  10084. --20110309 lambo
  10085. --查询该企业所有有效的VIP套餐订单
  10086. --修改:harry,只显示订单OrderStatus=4的2016-4-7
  10087. --修改:harry 增加短信数显示2017-6-5
  10088. CREATE PROCEDURE [dbo].[cccaOrderByAllValidSelect]
  10089. (
  10090. @cpMainID INT
  10091. )
  10092. AS
  10093. SET NOCOUNT ON
  10094. BEGIN
  10095. SELECT a.ID, a.beginDate, a.endDate,
  10096. (SELECT ISNULL(SUM(ActiveQuota),0) FROM caOrder WITH(NOLOCK) WHERE MainOrderID=a.ID AND EndDate >GETDATE())+ActiveQuota caActiveQuota,
  10097. (SELECT ISNULL(SUM(RemainQuota),0) FROM caOrder WITH(NOLOCK) WHERE MainOrderID=a.ID AND EndDate >GETDATE())+RemainQuota caRemainQuota,
  10098. (SELECT ISNULL(SUM(UserNumber),0) FROM caOrder WITH(NOLOCK) WHERE MainOrderID=a.ID AND EndDate >GETDATE())+UserNumber caUserNumber,
  10099. (SELECT ISNULL(SUM(JobNumber),0) FROM caOrder WITH(NOLOCK) WHERE MainOrderID=a.ID AND EndDate >GETDATE())+JobNumber caJobNumber,
  10100. (SELECT ISNULL(SUM(RemainSmsQuota),0) FROM caOrder WITH(NOLOCK) WHERE MainOrderID=a.ID AND EndDate >GETDATE())+RemainSmsQuota caSmsNumber
  10101. FROM caOrder a
  10102. WHERE a.cpMainID = @cpMainID
  10103. AND a.OrderType = 8
  10104. AND a.IsDeleted = 0
  10105. AND a.EndDate > GETDATE()
  10106. END
  10107. SET NOCOUNT OFF
  10108. GO
  10109. /****** Object: StoredProcedure [dbo].[ccCaOrderByIDSelect] Script Date: 2018/12/13 19:06:09 ******/
  10110. SET ANSI_NULLS ON
  10111. GO
  10112. SET QUOTED_IDENTIFIER ON
  10113. GO
  10114. -------------------------------------------------------------------------------------------------------------------
  10115. --lambo 20110309 修改
  10116. --将INNER JOIN 改为LEFT JOIN, 原因是考虑上门付款的
  10117. --[ccCaOrderByIDSelect] 265475
  10118. --mice 2014-8-21 修改, 添加返回值: a.PaidCoin, a.PaidPoint
  10119. --修改harry 2017-6-6 增加短信订单a.SmsQuota,RemainSmsQuota
  10120. --修改harry 2017-10-24 增加职位刷新remainJobRefreshQuota
  10121. --修改harry 2018-9-21 增加人才测评
  10122. CREATE PROCEDURE [dbo].[ccCaOrderByIDSelect]
  10123. (
  10124. @ID INT
  10125. )
  10126. AS
  10127. SET NOCOUNT ON
  10128. BEGIN
  10129. DECLARE @InvoiceCompany INT, @cpMainId INT
  10130. SELECT @InvoiceCompany = InvoiceCompany, @cpMainId = cpMainId FROM caOrder WITH(NOLOCK) WHERE Id = @Id
  10131. IF @InvoiceCompany IS NULL
  10132. BEGIN
  10133. DECLARE @regionId VARCHAR(6)
  10134. SELECT @RegionId = dcRegionId FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId
  10135. IF LEFT(@RegionId, 2) NOT IN(30, 32)
  10136. SET @InvoiceCompany = 2
  10137. ELSE IF LEFT(@RegionId, 4) IN ('3214', '3217')
  10138. SET @InvoiceCompany = 2
  10139. ELSE IF LEFT(@RegionId, 4) IN ('3201', '3205')
  10140. SET @InvoiceCompany = 5
  10141. ELSE
  10142. SET @InvoiceCompany = 4
  10143. END
  10144. SELECT a.ID, a.cpMainId, a.ProvinceID, a.dcFeeDetailID, a.ServiceType, a.PlaceWeek, a.PayMethod,
  10145. a.OrderType, a.Accounts, a.Paid, a.Balance, a.LinkMan,
  10146. a.Telephone, a.LinkRemark, a.MailAddress, a.Recipient, a.Zip, a.FaxFile,
  10147. a.CompanyName, a.RemittanceFile, a.RemittanceDate, a.SmsMobileNumber,
  10148. a.PostTelephone, a.ReceiveDate, a.NeedInvoice, a.InvoiceTitle,
  10149. a.InvoiceMonth, a.InvoiceCompany, a.InvoiceConfirmDate, a.ReceiveMan,
  10150. a.InvoiceConfirmMan, a.InvoiceAskDate, a.ContractFile, a.Manageruserid, a.IsDeleted,
  10151. a.DeletedMan, a.DeletedDate, a.OpenMan, a.OpenDate, a.BeginDate,
  10152. a.EndDate, a.AddDate, a.ActiveQuota, a.RemainQuota, a.JobNumber, a.UserNumber, a.MainOrderID, a.jobRefreshQuota, a.remainJobRefreshQuota, a.AssessReportQuota, a.RemainAssessReportQuota,
  10153. a.Tariff, a.RegisterAddress, a.RegisterTel, a.BankName, a.BankAccount,
  10154. a.PaidCoin, a.PaidPoint, a.SmsQuota, a.RemainSmsQuota, b.JointNo,
  10155. b.PayMethodID, c.Name as PayMethodName, b.Receiver, b.Account, b.BankName BankNamePre, a.OrderStatus, c.Homepage
  10156. FROM caOrder a WITH(NOLOCK)
  10157. LEFT JOIN dcPayMethodProvince b WITH(NOLOCK) ON a.PayMethod = b.PayMethodID
  10158. --AND b.dcProvinceID = CASE WHEN LEFT(a.ProvinceID, 2) = 32 AND InvoiceCompany = 2 THEN 10 ELSE LEFT(a.ProvinceID, 2) END
  10159. AND b.dcProvinceID = CASE @InvoiceCompany WHEN 4 THEN 30 WHEN 5 THEN 3201 ELSE 10 END
  10160. LEFT JOIN dcPayMethod c WITH(NOLOCK) ON a.PayMethod = c.PayMethodID
  10161. WHERE a.ID = @ID
  10162. END
  10163. SET NOCOUNT OFF
  10164. GO
  10165. /****** Object: StoredProcedure [dbo].[ccCaOrderByJobIDSelect] Script Date: 2018/12/13 19:06:09 ******/
  10166. SET ANSI_NULLS ON
  10167. GO
  10168. SET QUOTED_IDENTIFIER ON
  10169. GO
  10170. --#####################################################
  10171. --创建时间:2014.11.04
  10172. --创建人:Nick
  10173. --说明:获取职位置顶状态
  10174. --#####################################################
  10175. CREATE PROCEDURE [dbo].[ccCaOrderByJobIDSelect]
  10176. (
  10177. @JobID VARCHAR(20)
  10178. )
  10179. AS
  10180. BEGIN TRY
  10181. SELECT TOP 1 *
  10182. FROM caorder WITH(NOLOCK)
  10183. WHERE Balance = @JobID
  10184. AND OrderType=12
  10185. AND EndDate > GETDATE()
  10186. AND BeginDate < GETDATE()
  10187. END TRY
  10188. BEGIN CATCH
  10189. RETURN 0
  10190. END CATCH
  10191. GO
  10192. /****** Object: StoredProcedure [dbo].[ccCaorderByremainJobRefreshQuotaSelect] Script Date: 2018/12/13 19:06:09 ******/
  10193. SET ANSI_NULLS ON
  10194. GO
  10195. SET QUOTED_IDENTIFIER ON
  10196. GO
  10197. --创建:harry
  10198. --时间:2017-10-19
  10199. --说明:获取企业可用的职位刷新数(手动刷新)
  10200. CREATE PROCEDURE [dbo].[ccCaorderByremainJobRefreshQuotaSelect]
  10201. (
  10202. @cpMainId INT,
  10203. @caMainId INT,
  10204. @jobIds VARCHAR(200)
  10205. )
  10206. AS
  10207. BEGIN
  10208. SET NOCOUNT ON
  10209. --删除2分钟以上同一家企业的数据
  10210. DELETE FROM JobRefreshLog_temp WHERE AddDate < DATEADD(MINUTE, -2, GETDATE()) AND cpMainId = @cpMainId
  10211. DECLARE @sumRemain INT,@jobId INT, @jobinfo NVARCHAR(200),@InsertRow INT
  10212. SELECT @sumRemain = sum(remainJobRefreshQuota)
  10213. FROM caOrder WITH(NOLOCK)
  10214. WHERE cpMainID = @cpMainId
  10215. AND openDate IS NOT NULL
  10216. AND endDate > GETDATE()
  10217. AND BeginDate < GETDATE()
  10218. AND IsDeleted = 0
  10219. AND OrderType IN(8, 15)
  10220. IF @sumRemain != 0
  10221. BEGIN
  10222. DELETE FROM JobRefreshLog_temp WHERE cpMainId = @cpMainId AND operateMan = @caMainId--清空数据,只能清除自己添加的
  10223. --职位id
  10224. DECLARE @TjobId AS TABLE(jobId INT, jobInfo NVARCHAR(200))
  10225. INSERT INTO @TjobId (jobId)
  10226. SELECT * FROM dbo.fnSplit(@jobIds, ',')
  10227. --更新职位信息
  10228. UPDATE @TjobId
  10229. SET jobInfo= (SELECT name+','+ b.FullName FROM job a WITH(NOLOCK), dcregion b WITH(NOLOCK) WHERE a.id = jobId AND a.dcregionid = b.id)
  10230. --插入此次手动刷新的
  10231. INSERT INTO JobRefreshLog_temp(jobid, jobInfo, refreshType, preRefreshDateTime, operateMan, cpMainId, AddDate)
  10232. SELECT a.jobId, a.jobinfo, 1, getDate(), @caMainId, @cpMainId, GETDATE()
  10233. FROM @TjobId a
  10234. SELECT @InsertRow = @@ROWCOUNT
  10235. DECLARE @NeedQuota INT, @remainJobRefreshQuota INT, @AllInsertRow INT
  10236. SELECT @AllInsertRow =count(*) from jobrefreshlog_temp where cpmainid = @cpmainid and runDateTime is null
  10237. SELECT @NeedQuota = count(*) from jobrefreshlog where cpmainid = @cpmainid and runDateTime is null
  10238. SELECT @remainJobRefreshQuota = sum(remainJobRefreshQuota)
  10239. FROM caorder WITH(NOLOCK)
  10240. WHERE cpmainid = @cpmainid
  10241. AND ordertype in(8, 15) AND isdeleted=0 AND opendate > '' AND getdate() BETWEEN begindate AND enddate
  10242. --计算可用数量
  10243. IF (@NeedQuota +@AllInsertRow)> @remainJobRefreshQuota
  10244. BEGIN
  10245. SELECT (@remainJobRefreshQuota-(@NeedQuota+@AllInsertRow-@InsertRow)) AS availableNumber
  10246. END
  10247. ELSE
  10248. BEGIN
  10249. SELECT (@remainJobRefreshQuota-@NeedQuota) AS availableNumber
  10250. END
  10251. END
  10252. ELSE
  10253. BEGIN
  10254. SELECT 0 AS availableNumber
  10255. END
  10256. SET NOCOUNT OFF
  10257. END
  10258. GO
  10259. /****** Object: StoredProcedure [dbo].[ccCaOrderDelete] Script Date: 2018/12/13 19:06:09 ******/
  10260. SET ANSI_NULLS ON
  10261. GO
  10262. SET QUOTED_IDENTIFIER ON
  10263. GO
  10264. -- =============================================
  10265. -- Author: Peter
  10266. -- Create date: 2014-08-20 09:55
  10267. -- Description: 取消订单 -- Mice 2014-10-8 修改: 增加订单取消的原因
  10268. -- 修改:harry 修改积分和金币能够同时返还ELSE IF @UseCoin > 0---改为->IF @UseCoin > 0 2015-7-7
  10269. -- =============================================
  10270. CREATE PROCEDURE [dbo].[ccCaOrderDelete]
  10271. (
  10272. @caOrderID INT,
  10273. @cpMainID INT,
  10274. @cancelReason NVARCHAR(70) = ''
  10275. )
  10276. AS
  10277. SET NOCOUNT ON
  10278. BEGIN TRAN
  10279. BEGIN TRY
  10280. IF NOT EXISTS(SELECT 'x' FROM caOrder WITH(NOLOCK)
  10281. WHERE cpMainID = @cpMainID AND ID = @caOrderID AND OrderStatus = 0 AND IsDeleted = 0 AND FaxFile IS NULL)
  10282. GOTO ERR --检查该订单的有效性
  10283. DECLARE @UsePoint AS INT, @UseCoin AS INT, @GivePoint INT
  10284. --是否是积分订单
  10285. SELECT @UsePoint = PaidPoint, @GivePoint = GivePoint, @UseCoin = PaidCoin FROM caOrder WITH(NOLOCK) WHERE ID = @caOrderID
  10286. IF @UsePoint > 0 --积分订单
  10287. BEGIN
  10288. --插入积分记录
  10289. INSERT INTO cpPoint (cpMainID, changeID, point, relativeID, lastModifyDate)
  10290. VALUES(@cpMainID, 16, @UsePoint, @caOrderID, GETDATE())
  10291. END
  10292. IF @GivePoint > 0 --积分订单
  10293. BEGIN
  10294. --插入积分记录
  10295. INSERT INTO cpPoint (cpMainID, changeID, point, relativeID, lastModifyDate)
  10296. VALUES(@cpMainID, 24, @GivePoint * -1, @caOrderID, GETDATE())
  10297. END
  10298. --Harry
  10299. IF @UseCoin > 0
  10300. --插入金币记录
  10301. BEGIN
  10302. IF (SELECT COUNT(*) FROM cpCoin WITH(NOLOCK) WHERE caOrderId = @caOrderID) = 1
  10303. BEGIN
  10304. DECLARE @RemainCoin INT
  10305. SELECT @RemainCoin = ISNULL(RemainCoin, 0) FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainID
  10306. INSERT INTO cpCoin(cpMainId, caOrderId, Coin, IsCancel, Balance, AddDate)
  10307. SELECT @cpMainId, @caOrderID, @UseCoin, 1, @UseCoin + @RemainCoin, GETDATE()
  10308. END
  10309. END
  10310. --删除订单
  10311. UPDATE caOrder SET IsDeleted = 1 , CancelReason = @cancelReason WHERE ID = @caOrderID
  10312. END TRY
  10313. BEGIN CATCH
  10314. GOTO ERR
  10315. END CATCH
  10316. COMMIT TRAN
  10317. RETURN 1
  10318. ERR:
  10319. BEGIN
  10320. ROLLBACK TRAN
  10321. RETURN 0
  10322. END
  10323. GO
  10324. /****** Object: StoredProcedure [dbo].[ccCaOrderEndDateByCpMainIDSelect] Script Date: 2018/12/13 19:06:09 ******/
  10325. SET ANSI_NULLS ON
  10326. GO
  10327. SET QUOTED_IDENTIFIER ON
  10328. GO
  10329. --#####################################################
  10330. --创建时间:2014.11.6
  10331. --创建人:John
  10332. --说明:获取会员订单的到期时间
  10333. --#####################################################
  10334. CREATE PROCEDURE [dbo].[ccCaOrderEndDateByCpMainIDSelect]
  10335. (
  10336. @cpMainID INT
  10337. )
  10338. AS
  10339. BEGIN
  10340. SELECT EndDate FROM caOrder
  10341. WHERE cpMainID = @cpMainID
  10342. AND OrderType IN (1,2,8)
  10343. AND EndDate >= GETDATE() - 62
  10344. AND OpenDate IS NOT NULL
  10345. AND IsDeleted = 0
  10346. END
  10347. GO
  10348. /****** Object: StoredProcedure [dbo].[ccCaOrderFaxFileUpdate] Script Date: 2018/12/13 19:06:09 ******/
  10349. SET ANSI_NULLS ON
  10350. GO
  10351. SET QUOTED_IDENTIFIER ON
  10352. GO
  10353. CREATE PROCEDURE [dbo].[ccCaOrderFaxFileUpdate]
  10354. (
  10355. @ID INT,
  10356. @FaxFile VARCHAR(50)
  10357. )
  10358. AS
  10359. BEGIN
  10360. UPDATE caOrder SET FaxFile=@FaxFile WHERE ID=@ID
  10361. END
  10362. GO
  10363. /****** Object: StoredProcedure [dbo].[ccCaOrderInsert] Script Date: 2018/12/13 19:06:10 ******/
  10364. SET ANSI_NULLS ON
  10365. GO
  10366. SET QUOTED_IDENTIFIER ON
  10367. GO
  10368. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  10369. -- Author: Peter
  10370. -- Create date: 2014-08-20 09:55
  10371. -- Description:
  10372. -- Modify: Harry 2015-7-10
  10373. -- Description:修改needpoint为从dcfeedetail中取出(282行)
  10374. -- Modify: Harry 修改一年内最大积分数不能超过qlrc @MaxPoint=20000
  10375. -- Other Site @MaxPoint=10000
  10376. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  10377. CREATE PROCEDURE [dbo].[ccCaOrderInsert]
  10378. (
  10379. @cpMainID INT,
  10380. @IsAgent BIT,
  10381. @ProvinceID INT,
  10382. @ServiceType INT = NULL,
  10383. @PlaceWeek TINYINT = NULL,
  10384. @PayMethod TINYINT,
  10385. @OrderType TINYINT,
  10386. @Accounts NUMERIC(18, 2),
  10387. @Paid NUMERIC(18, 2),
  10388. @Balance NUMERIC(18, 2) = NULL,
  10389. @LinkMan NVARCHAR(50),
  10390. @Telephone VARCHAR(50),
  10391. @LinkRemark NVARCHAR(1000),
  10392. @Manageruserid SMALLINT,
  10393. @ActiveQuota SMALLINT = NULL,
  10394. @JobNumber SMALLINT = NULL,
  10395. @CompanyName VARCHAR(100),
  10396. @MainOrderID INT = NULL,
  10397. @InvoiceCompany SMALLINT,
  10398. @UserNumber SMALLINT = NULL,
  10399. @dcFeeDetailsID INT = NULL,
  10400. @UseCoin INT = NULL,
  10401. @UsePoint INT = NULL
  10402. )
  10403. AS
  10404. SET NOCOUNT ON
  10405. BEGIN TRAN
  10406. DECLARE @MaxId AS INT, @MaxPoint AS INT, @Type INT
  10407. IF LEFT(@ProvinceID, 2) = 32
  10408. SELECT @MaxPoint = 20000--设置1年内最大积分兑换额度
  10409. ELSE
  10410. SELECT @MaxPoint = 10000--设置1年内最大积分兑换额度
  10411. BEGIN TRY
  10412. IF @OrderType = 8
  10413. BEGIN
  10414. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK), dcVipDetail b WITH(NOLOCK)
  10415. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID, 2)
  10416. AND b.ID = @dcFeeDetailsID AND a.startDate<GETDATE() AND a.endDate > GETDATE())
  10417. GOTO ERR --检查是否套餐已过期
  10418. SELECT @Accounts = (b.PriceMonth * a.[Month]+a.ResumeNumber*b.PriceResume+JobNumber*b.PriceJob+UserNumber*b.PriceUser),
  10419. @Paid = a.Price, @ActiveQuota = a.ResumeNumber, @JobNumber = a.JobNumber, @UserNumber = a.UserNumber
  10420. FROM dcVipDetail a WITH(NOLOCK), dcVip b WITH(NOLOCK)
  10421. WHERE a.ID = @dcFeeDetailsID
  10422. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10423. AND a.dcVipID = b.ID
  10424. END
  10425. ELSE IF @OrderType = 4 AND @ServiceType = 6 ----根据周数查询1/6广告的资费信息
  10426. BEGIN
  10427. SET @Type = 4
  10428. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10429. @Paid = a.Price * @PlaceWeek,
  10430. @dcFeeDetailsID = a.ID
  10431. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10432. WHERE a.dcFeeID = b.ID
  10433. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10434. AND b.Type = @Type
  10435. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10436. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10437. IF @dcFeeDetailsID IS NULL
  10438. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10439. FROM dcFee WITH(NOLOCK)
  10440. WHERE Type = @Type
  10441. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10442. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10443. END
  10444. ELSE IF @OrderType = 4 AND @ServiceType = 7 ----根据周数查询2/6广告的资费信息
  10445. BEGIN
  10446. SET @Type = 5
  10447. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10448. @Paid = a.Price * @PlaceWeek,
  10449. @dcFeeDetailsID = a.ID
  10450. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10451. WHERE b.Type = @Type
  10452. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10453. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10454. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10455. AND a.dcFeeID = b.ID
  10456. IF @dcFeeDetailsID IS NULL
  10457. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10458. FROM dcFee WITH(NOLOCK)
  10459. WHERE Type = @Type
  10460. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10461. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10462. END
  10463. ELSE IF @OrderType = 4 AND @ServiceType = 8 ----根据周数查询3/6广告的资费信息
  10464. BEGIN
  10465. SET @Type = 20
  10466. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10467. @Paid = a.Price * @PlaceWeek,
  10468. @dcFeeDetailsID = a.ID
  10469. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10470. WHERE b.Type = @Type
  10471. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10472. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10473. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10474. AND a.dcFeeID = b.ID
  10475. IF @dcFeeDetailsID IS NULL
  10476. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10477. FROM dcFee WITH(NOLOCK)
  10478. WHERE Type = @Type
  10479. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10480. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10481. END
  10482. ELSE IF @OrderType = 4 AND @ServiceType = 9 ----根据周数查询6/6广告的资费信息
  10483. BEGIN
  10484. SET @Type = 21
  10485. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10486. @Paid = a.Price * @PlaceWeek,
  10487. @dcFeeDetailsID = a.ID
  10488. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10489. WHERE b.Type = @Type
  10490. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10491. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10492. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10493. AND a.dcFeeID = b.ID
  10494. IF @dcFeeDetailsID IS NULL
  10495. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10496. FROM dcFee WITH(NOLOCK)
  10497. WHERE Type = @Type
  10498. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10499. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10500. END
  10501. ELSE IF @OrderType = 4 AND @ServiceType = 10 ----根据周数查询6/6广告的资费信息
  10502. BEGIN
  10503. SET @Type = 23
  10504. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10505. @Paid = a.Price * @PlaceWeek,
  10506. @dcFeeDetailsID = a.ID
  10507. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10508. WHERE b.Type = @Type
  10509. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10510. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10511. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10512. AND a.dcFeeID = b.ID
  10513. IF @dcFeeDetailsID IS NULL
  10514. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10515. FROM dcFee WITH(NOLOCK)
  10516. WHERE Type = @Type
  10517. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10518. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10519. END
  10520. ELSE IF @OrderType = 7 ----根据周数查询固定位置的资费信息
  10521. BEGIN
  10522. SET @Type = 7
  10523. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10524. @Paid = a.Price * @PlaceWeek,
  10525. @dcFeeDetailsID = a.ID
  10526. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10527. WHERE b.Type = @Type
  10528. AND a.dcFeeID = b.ID
  10529. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10530. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10531. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10532. IF @dcFeeDetailsID IS NULL
  10533. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10534. FROM dcFee WITH(NOLOCK)
  10535. WHERE Type = @Type
  10536. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10537. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10538. END
  10539. ELSE IF @OrderType = 9 ----简历下载
  10540. BEGIN
  10541. SET @Type = 9
  10542. SELECT TOP 1 @Accounts = b.Price * @ActiveQuota,
  10543. @Paid = a.Price * @ActiveQuota,
  10544. @dcFeeDetailsID = a.ID
  10545. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10546. WHERE b.Type = @Type
  10547. AND a.dcFeeID = b.ID
  10548. AND ((MinValue< = @ActiveQuota AND MaxValue> = @ActiveQuota) OR (MinValue< = @ActiveQuota AND MaxValue = 0))
  10549. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10550. IF @dcFeeDetailsID IS NULL
  10551. SELECT TOP 1 @Accounts = Price, @Paid = Price * @ActiveQuota
  10552. FROM dcFee WITH(NOLOCK)
  10553. WHERE Type = @Type
  10554. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10555. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10556. END
  10557. ELSE IF @OrderType = 10 ----职位数
  10558. BEGIN
  10559. SET @Type = 10
  10560. SELECT TOP 1 @Accounts = b.Price * @JobNumber,
  10561. @Paid = a.Price * @JobNumber,
  10562. @dcFeeDetailsID = a.ID
  10563. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10564. WHERE b.Type = @Type
  10565. AND a.dcFeeID = b.ID
  10566. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10567. AND ((MinValue< = @JobNumber AND MaxValue> = @JobNumber) OR (MinValue< = @JobNumber AND MaxValue = 0))
  10568. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10569. IF @dcFeeDetailsID IS NULL
  10570. SELECT TOP 1 @Accounts = Price, @Paid = Price * @JobNumber
  10571. FROM dcFee WITH(NOLOCK)
  10572. WHERE Type = @Type
  10573. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10574. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10575. END
  10576. ELSE IF @OrderType = 11 ----用户数
  10577. BEGIN
  10578. SET @Type = 11
  10579. SELECT TOP 1 @Accounts = b.Price * @UserNumber,
  10580. @Paid = a.Price * @UserNumber,
  10581. @dcFeeDetailsID = a.ID
  10582. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10583. WHERE b.Type = @Type
  10584. AND a.dcFeeID = b.ID
  10585. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10586. AND ((MinValue< = @UserNumber AND MaxValue> = @UserNumber) OR (MinValue< = @UserNumber AND MaxValue = 0))
  10587. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10588. IF @dcFeeDetailsID IS NULL
  10589. SELECT TOP 1 @Accounts = Price, @Paid = Price * @UserNumber
  10590. FROM dcFee WITH(NOLOCK)
  10591. WHERE Type = @Type
  10592. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10593. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10594. END
  10595. ELSE IF @OrderType = 12 ----根据周数职位置顶资费信息
  10596. BEGIN
  10597. SET @Type = 22
  10598. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10599. @Paid = a.Price * @PlaceWeek,
  10600. @dcFeeDetailsID = a.ID
  10601. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10602. WHERE b.Type = @Type
  10603. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10604. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10605. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10606. AND a.dcFeeID = b.ID
  10607. IF @dcFeeDetailsID IS NULL
  10608. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10609. FROM dcFee WITH(NOLOCK)
  10610. WHERE Type = @Type
  10611. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10612. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10613. END
  10614. ELSE IF @OrderType = 13 ----根据周数职位置顶资费信息
  10615. BEGIN
  10616. SET @Type = 24
  10617. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10618. @Paid = a.Price * @PlaceWeek,
  10619. @dcFeeDetailsID = a.ID
  10620. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10621. WHERE b.Type = @Type
  10622. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10623. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10624. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10625. AND a.dcFeeID = b.ID
  10626. IF @dcFeeDetailsID IS NULL
  10627. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10628. FROM dcFee WITH(NOLOCK)
  10629. WHERE Type = @Type
  10630. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10631. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10632. END
  10633. IF @MainOrderID IS NOT NULL
  10634. IF NOT EXISTS(SELECT 'x' FROM caOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND ID = @MainOrderID AND OrderType = 8 AND EndDate >GETDATE())
  10635. AND @OrderType in (9, 10, 11)
  10636. GOTO ERR --检查是否是自己有效的主订单号
  10637. DECLARE @CoinBalance AS INT
  10638. DECLARE @PointBalance AS INT
  10639. IF @UseCoin IS NOT NULL
  10640. BEGIN
  10641. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainCoin > = @UseCoin)
  10642. GOTO ERR --检查剩余金币数量是否足够支付
  10643. SET @Paid = @Paid - @UseCoin
  10644. END
  10645. IF @UsePoint IS NOT NULL --积分支付
  10646. BEGIN
  10647. DECLARE @NeedPoint INT, @dcFeeDetailsID2 INT, @SumPoint AS INT
  10648. SELECT @NeedPoint = NeedPoint FROM dcfeedetail WHERE Id = @dcFeeDetailsID
  10649. IF @NeedPoint IS NULL
  10650. BEGIN
  10651. SELECT TOP 1 @dcFeeDetailsID2 = a.ID
  10652. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10653. WHERE b.Type = @Type
  10654. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10655. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10656. AND a.NeedPoint > 0
  10657. AND a.dcFeeID = b.ID
  10658. SELECT @NeedPoint = NeedPoint FROM dcfeedetail WHERE id = @dcFeeDetailsID2
  10659. END
  10660. IF @OrderType IN(4, 7, 12, 13)
  10661. BEGIN
  10662. SET @UsePoint = @NeedPoint * @PlaceWeek
  10663. END
  10664. ELSE
  10665. BEGIN
  10666. SET @UsePoint = @NeedPoint
  10667. END
  10668. --积分兑换的积分数是否超过最大数值
  10669. SELECT @SumPoint = SUM(PaidPoint)
  10670. FROM caOrder
  10671. WHERE cpMainid = @cpMainID
  10672. AND IsDeleted = 0 --未删除
  10673. AND ISNULL(Paid, 0) = 0 --付款为0
  10674. AND ISNULL(PaidCoin, 0) = 0 --金币支付为0
  10675. AND ISNULL(PaidPoint, 0) > 0 --积分不为0
  10676. AND Adddate > DATEADD(YEAR, -1, GETDATE())
  10677. IF(@SumPoint + @UsePoint) > @MaxPoint
  10678. BEGIN
  10679. GOTO ERR --超过最大积分数量
  10680. END
  10681. --HarryEND
  10682. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainPoint > = @UsePoint)
  10683. BEGIN
  10684. GOTO ERR --检查剩余积分数量是否足够支付
  10685. END
  10686. SET @Paid = 0
  10687. END
  10688. IF @Paid < 0
  10689. SET @Paid = 0
  10690. INSERT INTO caOrder (cpMainID, ProvinceID, ServiceType, PlaceWeek, PayMethod, UserNumber,
  10691. OrderType, Accounts, Paid, Balance, LinkMan, Telephone, LinkRemark, Manageruserid,
  10692. ActiveQuota, RemainQuota, JobNumber, CompanyName, MainOrderID, InvoiceCompany,
  10693. dcFeeDetailID, PaidCoin, PaidPoint)
  10694. VALUES(@cpMainID, @ProvinceID, @ServiceType, @PlaceWeek, @PayMethod, @UserNumber,
  10695. @OrderType, @Accounts, @Paid, @Balance, @LinkMan, @Telephone, @LinkRemark, @Manageruserid,
  10696. @ActiveQuota, @ActiveQuota, @JobNumber, @CompanyName, @MainOrderID, @InvoiceCompany,
  10697. @dcFeeDetailsID, @UseCoin, @UsePoint)
  10698. SET @MaxID = @@IDENTITY
  10699. DECLARE @Temp AS NUMERIC(18, 2)
  10700. IF @IsAgent = 1 AND @PayMethod <> 103
  10701. SET @Paid = @Accounts ----SET @Paid = @Paid * 5 Old Rule
  10702. SET @Temp = @Paid -- 1 + CONVERT(NUMERIC(18, 2), '0.' + RIGHT(STR(@cpMainID), 2))
  10703. --金币或订单全额支付
  10704. IF @Temp < 0
  10705. SET @Temp = 0
  10706. UPDATE caOrder SET Paid = @Temp WHERE ID = @MaxID
  10707. IF @UseCoin IS NOT NULL
  10708. BEGIN
  10709. --插入金币记录
  10710. INSERT INTO cpCoin (cpMainID, caOrderID, Coin, Balance, AddDate)
  10711. VALUES(@cpMainID, @MaxID, 0-@UseCoin, 0, GETDATE())
  10712. END
  10713. IF @UsePoint IS NOT NULL
  10714. BEGIN
  10715. --插入积分记录
  10716. INSERT INTO cpPoint (cpMainID, ChangeID, Point, relativeID, LastModifyDate)
  10717. VALUES(@cpMainID, 15, 0 - @UsePoint, @MaxID, GETDATE())
  10718. UPDATE caOrder SET NeedInvoice = 0 WHERE ID = @MaxID
  10719. DECLARE @BeginDate SMALLDATETIME
  10720. SET @BeginDate = GETDATE()
  10721. IF @Balance > 0
  10722. SELECT TOP 1 @BeginDate = EndDate FROM caOrder WITH(NOLOCK)
  10723. WHERE cpMainID = @cpMainID AND OrderType = @OrderType AND Balance = @Balance
  10724. AND EndDate > GETDATE() AND OpenDate IS NOT NULL AND IsDeleted = 0 ORDER BY EndDate DESC
  10725. ELSE
  10726. SELECT TOP 1 @BeginDate = EndDate FROM caOrder WITH(NOLOCK)
  10727. WHERE cpMainID = @cpMainID AND OrderType = @OrderType
  10728. AND EndDate > GETDATE() AND OpenDate IS NOT NULL AND IsDeleted = 0 ORDER BY EndDate DESC
  10729. IF @OrderType > 4
  10730. BEGIN -- 立即开通积分订单
  10731. UPDATE caOrder SET BeginDate = @BeginDate,
  10732. EndDate = DATEADD(DAY, PlaceWeek * 7, @BeginDate),
  10733. OpenDate = GETDATE(),
  10734. NeedInvoice = 0
  10735. WHERE PayMethod = 103
  10736. AND PlaceWeek > 0
  10737. AND Id = @MaxID
  10738. UPDATE caOrder
  10739. SET NeedInvoice = 0, ReceiveMan = 112, ReceiveDate = GETDATE()
  10740. WHERE PayMethod = 103
  10741. AND PlaceWeek > 0
  10742. AND Id = @MaxID
  10743. END
  10744. END
  10745. END TRY
  10746. BEGIN CATCH
  10747. GOTO ERR
  10748. END CATCH
  10749. COMMIT
  10750. RETURN @MaxID
  10751. ERR:
  10752. BEGIN
  10753. ROLLBACK TRAN
  10754. RETURN 0
  10755. END
  10756. GO
  10757. /****** Object: StoredProcedure [dbo].[ccCaOrderInsert1] Script Date: 2018/12/13 19:06:10 ******/
  10758. SET ANSI_NULLS ON
  10759. GO
  10760. SET QUOTED_IDENTIFIER ON
  10761. GO
  10762. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  10763. -- Create date: 2017-06-06 Harry
  10764. -- Description: harry 在ccCaOrderInsert基础上 增加短信订单14
  10765. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  10766. CREATE PROCEDURE [dbo].[ccCaOrderInsert1]
  10767. (
  10768. @cpMainID INT,
  10769. @IsAgent BIT,
  10770. @ProvinceID INT,
  10771. @ServiceType INT = NULL,
  10772. @PlaceWeek TINYINT = NULL,
  10773. @PayMethod TINYINT,
  10774. @OrderType TINYINT,
  10775. @Accounts NUMERIC(18, 2),
  10776. @Paid NUMERIC(18, 2),
  10777. @Balance NUMERIC(18, 2) = NULL,
  10778. @LinkMan NVARCHAR(50),
  10779. @Telephone VARCHAR(50),
  10780. @LinkRemark NVARCHAR(1000),
  10781. @Manageruserid SMALLINT,
  10782. @ActiveQuota SMALLINT = NULL,
  10783. @JobNumber SMALLINT = NULL,
  10784. @CompanyName VARCHAR(100),
  10785. @MainOrderID INT = NULL,
  10786. @InvoiceCompany SMALLINT,
  10787. @UserNumber SMALLINT = NULL,
  10788. @dcFeeDetailsID INT = NULL,
  10789. @smsNumber SMALLINT =NULL,
  10790. @UseCoin INT = NULL,
  10791. @UsePoint INT = NULL
  10792. )
  10793. AS
  10794. SET NOCOUNT ON
  10795. BEGIN TRAN
  10796. DECLARE @MaxId AS INT, @MaxPoint AS INT, @Type INT
  10797. IF LEFT(@ProvinceID, 2) = 32
  10798. SELECT @MaxPoint = 20000--设置1年内最大积分兑换额度
  10799. ELSE
  10800. SELECT @MaxPoint = 10000--设置1年内最大积分兑换额度
  10801. BEGIN TRY
  10802. IF @OrderType = 8
  10803. BEGIN
  10804. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK), dcVipDetail b WITH(NOLOCK)
  10805. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID, 2)
  10806. AND b.ID = @dcFeeDetailsID AND a.startDate<GETDATE() AND a.endDate > GETDATE())
  10807. GOTO ERR --检查是否套餐已过期
  10808. SELECT @Accounts = (b.PriceMonth * a.[Month]+a.ResumeNumber*b.PriceResume+JobNumber*b.PriceJob+UserNumber*b.PriceUser+ISNULL(a.SmsNumber,0)*ISNULL(b.PriceSms,0)),
  10809. @Paid = a.Price, @ActiveQuota = a.ResumeNumber, @JobNumber = a.JobNumber, @UserNumber = a.UserNumber, @smsNumber=ISNULL(a.SmsNumber,0)
  10810. FROM dcVipDetail a WITH(NOLOCK), dcVip b WITH(NOLOCK)
  10811. WHERE a.ID = @dcFeeDetailsID
  10812. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10813. AND a.dcVipID = b.ID
  10814. END
  10815. ELSE IF @OrderType = 4 AND @ServiceType = 6 ----根据周数查询1/6广告的资费信息
  10816. BEGIN
  10817. SET @Type = 4
  10818. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10819. @Paid = a.Price * @PlaceWeek,
  10820. @dcFeeDetailsID = a.ID
  10821. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10822. WHERE a.dcFeeID = b.ID
  10823. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10824. AND b.Type = @Type
  10825. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10826. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10827. IF @dcFeeDetailsID IS NULL
  10828. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10829. FROM dcFee WITH(NOLOCK)
  10830. WHERE Type = @Type
  10831. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10832. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10833. END
  10834. ELSE IF @OrderType = 4 AND @ServiceType = 7 ----根据周数查询2/6广告的资费信息
  10835. BEGIN
  10836. SET @Type = 5
  10837. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10838. @Paid = a.Price * @PlaceWeek,
  10839. @dcFeeDetailsID = a.ID
  10840. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10841. WHERE b.Type = @Type
  10842. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10843. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10844. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10845. AND a.dcFeeID = b.ID
  10846. IF @dcFeeDetailsID IS NULL
  10847. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10848. FROM dcFee WITH(NOLOCK)
  10849. WHERE Type = @Type
  10850. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10851. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10852. END
  10853. ELSE IF @OrderType = 4 AND @ServiceType = 8 ----根据周数查询3/6广告的资费信息
  10854. BEGIN
  10855. SET @Type = 20
  10856. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10857. @Paid = a.Price * @PlaceWeek,
  10858. @dcFeeDetailsID = a.ID
  10859. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10860. WHERE b.Type = @Type
  10861. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10862. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10863. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10864. AND a.dcFeeID = b.ID
  10865. IF @dcFeeDetailsID IS NULL
  10866. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10867. FROM dcFee WITH(NOLOCK)
  10868. WHERE Type = @Type
  10869. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10870. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10871. END
  10872. ELSE IF @OrderType = 4 AND @ServiceType = 9 ----根据周数查询6/6广告的资费信息
  10873. BEGIN
  10874. SET @Type = 21
  10875. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10876. @Paid = a.Price * @PlaceWeek,
  10877. @dcFeeDetailsID = a.ID
  10878. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10879. WHERE b.Type = @Type
  10880. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10881. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10882. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10883. AND a.dcFeeID = b.ID
  10884. IF @dcFeeDetailsID IS NULL
  10885. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10886. FROM dcFee WITH(NOLOCK)
  10887. WHERE Type = @Type
  10888. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10889. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10890. END
  10891. ELSE IF @OrderType = 4 AND @ServiceType = 10 ----根据周数查询6/6广告的资费信息
  10892. BEGIN
  10893. SET @Type = 23
  10894. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10895. @Paid = a.Price * @PlaceWeek,
  10896. @dcFeeDetailsID = a.ID
  10897. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10898. WHERE b.Type = @Type
  10899. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10900. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10901. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10902. AND a.dcFeeID = b.ID
  10903. IF @dcFeeDetailsID IS NULL
  10904. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10905. FROM dcFee WITH(NOLOCK)
  10906. WHERE Type = @Type
  10907. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10908. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10909. END
  10910. ELSE IF @OrderType = 7 ----根据周数查询固定位置的资费信息
  10911. BEGIN
  10912. SET @Type = 7
  10913. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10914. @Paid = a.Price * @PlaceWeek,
  10915. @dcFeeDetailsID = a.ID
  10916. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10917. WHERE b.Type = @Type
  10918. AND a.dcFeeID = b.ID
  10919. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10920. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10921. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10922. IF @dcFeeDetailsID IS NULL
  10923. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10924. FROM dcFee WITH(NOLOCK)
  10925. WHERE Type = @Type
  10926. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10927. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10928. END
  10929. ELSE IF @OrderType = 9 ----简历下载
  10930. BEGIN
  10931. SET @Type = 9
  10932. SELECT TOP 1 @Accounts = b.Price * @ActiveQuota,
  10933. @Paid = a.Price * @ActiveQuota,
  10934. @dcFeeDetailsID = a.ID
  10935. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10936. WHERE b.Type = @Type
  10937. AND a.dcFeeID = b.ID
  10938. AND ((MinValue< = @ActiveQuota AND MaxValue> = @ActiveQuota) OR (MinValue< = @ActiveQuota AND MaxValue = 0))
  10939. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10940. IF @dcFeeDetailsID IS NULL
  10941. SELECT TOP 1 @Accounts = Price, @Paid = Price * @ActiveQuota
  10942. FROM dcFee WITH(NOLOCK)
  10943. WHERE Type = @Type
  10944. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10945. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10946. END
  10947. ELSE IF @OrderType = 10 ----职位数
  10948. BEGIN
  10949. SET @Type = 10
  10950. SELECT TOP 1 @Accounts = b.Price * @JobNumber,
  10951. @Paid = a.Price * @JobNumber,
  10952. @dcFeeDetailsID = a.ID
  10953. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10954. WHERE b.Type = @Type
  10955. AND a.dcFeeID = b.ID
  10956. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10957. AND ((MinValue< = @JobNumber AND MaxValue> = @JobNumber) OR (MinValue< = @JobNumber AND MaxValue = 0))
  10958. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10959. IF @dcFeeDetailsID IS NULL
  10960. SELECT TOP 1 @Accounts = Price, @Paid = Price * @JobNumber
  10961. FROM dcFee WITH(NOLOCK)
  10962. WHERE Type = @Type
  10963. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10964. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10965. END
  10966. ELSE IF @OrderType = 11 ----用户数
  10967. BEGIN
  10968. SET @Type = 11
  10969. SELECT TOP 1 @Accounts = b.Price * @UserNumber,
  10970. @Paid = a.Price * @UserNumber,
  10971. @dcFeeDetailsID = a.ID
  10972. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10973. WHERE b.Type = @Type
  10974. AND a.dcFeeID = b.ID
  10975. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10976. AND ((MinValue< = @UserNumber AND MaxValue> = @UserNumber) OR (MinValue< = @UserNumber AND MaxValue = 0))
  10977. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10978. IF @dcFeeDetailsID IS NULL
  10979. SELECT TOP 1 @Accounts = Price, @Paid = Price * @UserNumber
  10980. FROM dcFee WITH(NOLOCK)
  10981. WHERE Type = @Type
  10982. AND dcProvinceID = LEFT(@ProvinceID, 2)
  10983. AND StartDate < GETDATE() AND EndDate > GETDATE()
  10984. END
  10985. ELSE IF @OrderType = 12 ----根据周数职位置顶资费信息
  10986. BEGIN
  10987. SET @Type = 22
  10988. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  10989. @Paid = a.Price * @PlaceWeek,
  10990. @dcFeeDetailsID = a.ID
  10991. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  10992. WHERE b.Type = @Type
  10993. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  10994. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  10995. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  10996. AND a.dcFeeID = b.ID
  10997. IF @dcFeeDetailsID IS NULL
  10998. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  10999. FROM dcFee WITH(NOLOCK)
  11000. WHERE Type = @Type
  11001. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11002. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11003. END
  11004. ELSE IF @OrderType = 13 ----根据周数职位置顶资费信息
  11005. BEGIN
  11006. SET @Type = 24
  11007. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11008. @Paid = a.Price * @PlaceWeek,
  11009. @dcFeeDetailsID = a.ID
  11010. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11011. WHERE b.Type = @Type
  11012. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11013. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11014. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11015. AND a.dcFeeID = b.ID
  11016. IF @dcFeeDetailsID IS NULL
  11017. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11018. FROM dcFee WITH(NOLOCK)
  11019. WHERE Type = @Type
  11020. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11021. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11022. END
  11023. ELSE IF @OrderType = 14 ----短信订单
  11024. BEGIN
  11025. SET @Type = 14
  11026. SELECT TOP 1 @Accounts = b.Price * @smsNumber,
  11027. @Paid = a.Price * @smsNumber,
  11028. @dcFeeDetailsID = a.ID
  11029. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11030. WHERE b.Type = @Type
  11031. AND a.dcFeeID = b.ID
  11032. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11033. AND ((MinValue< = @smsNumber AND MaxValue> = @smsNumber) OR (MinValue< = @smsNumber AND MaxValue = 0))
  11034. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11035. IF @dcFeeDetailsID IS NULL
  11036. SELECT TOP 1 @Accounts = Price, @Paid = Price * @smsNumber
  11037. FROM dcFee WITH(NOLOCK)
  11038. WHERE Type = @Type
  11039. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11040. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11041. END
  11042. IF @MainOrderID IS NOT NULL
  11043. IF NOT EXISTS(SELECT 'x' FROM caOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND ID = @MainOrderID AND OrderType = 8 AND EndDate >GETDATE())
  11044. AND @OrderType in (9, 10, 11,14)
  11045. GOTO ERR --检查是否是自己有效的主订单号
  11046. DECLARE @CoinBalance AS INT
  11047. DECLARE @PointBalance AS INT
  11048. IF @UseCoin IS NOT NULL
  11049. BEGIN
  11050. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainCoin > = @UseCoin)
  11051. GOTO ERR --检查剩余金币数量是否足够支付
  11052. SET @Paid = @Paid - @UseCoin
  11053. END
  11054. IF @UsePoint IS NOT NULL --积分支付
  11055. BEGIN
  11056. DECLARE @NeedPoint INT, @dcFeeDetailsID2 INT, @SumPoint AS INT
  11057. SELECT @NeedPoint = NeedPoint FROM dcfeedetail WHERE Id = @dcFeeDetailsID
  11058. IF @NeedPoint IS NULL
  11059. BEGIN
  11060. SELECT TOP 1 @dcFeeDetailsID2 = a.ID
  11061. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11062. WHERE b.Type = @Type
  11063. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11064. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11065. AND a.NeedPoint > 0
  11066. AND a.dcFeeID = b.ID
  11067. SELECT @NeedPoint = NeedPoint FROM dcfeedetail WHERE id = @dcFeeDetailsID2
  11068. END
  11069. IF @OrderType IN(4, 7, 12, 13)
  11070. BEGIN
  11071. SET @UsePoint = @NeedPoint * @PlaceWeek
  11072. END
  11073. ELSE
  11074. BEGIN
  11075. SET @UsePoint = @NeedPoint
  11076. END
  11077. --积分兑换的积分数是否超过最大数值
  11078. SELECT @SumPoint = SUM(PaidPoint)
  11079. FROM caOrder
  11080. WHERE cpMainid = @cpMainID
  11081. AND IsDeleted = 0 --未删除
  11082. AND ISNULL(Paid, 0) = 0 --付款为0
  11083. AND ISNULL(PaidCoin, 0) = 0 --金币支付为0
  11084. AND ISNULL(PaidPoint, 0) > 0 --积分不为0
  11085. AND Adddate > DATEADD(YEAR, -1, GETDATE())
  11086. IF(@SumPoint + @UsePoint) > @MaxPoint
  11087. BEGIN
  11088. GOTO ERR --超过最大积分数量
  11089. END
  11090. --HarryEND
  11091. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainPoint > = @UsePoint)
  11092. BEGIN
  11093. GOTO ERR --检查剩余积分数量是否足够支付
  11094. END
  11095. SET @Paid = 0
  11096. END
  11097. IF @Paid < 0
  11098. SET @Paid = 0
  11099. INSERT INTO caOrder (cpMainID, ProvinceID, ServiceType, PlaceWeek, PayMethod, UserNumber,
  11100. OrderType, Accounts, Paid, Balance, LinkMan, Telephone, LinkRemark, Manageruserid,
  11101. ActiveQuota, RemainQuota, JobNumber, CompanyName, MainOrderID, InvoiceCompany,
  11102. dcFeeDetailID, PaidCoin, PaidPoint, SmsQuota, RemainSmsQuota)
  11103. VALUES(@cpMainID, @ProvinceID, @ServiceType, @PlaceWeek, @PayMethod, @UserNumber,
  11104. @OrderType, @Accounts, @Paid, @Balance, @LinkMan, @Telephone, @LinkRemark, @Manageruserid,
  11105. @ActiveQuota, @ActiveQuota, @JobNumber, @CompanyName, @MainOrderID, @InvoiceCompany,
  11106. @dcFeeDetailsID, @UseCoin, @UsePoint, @smsNumber, @smsNumber)
  11107. SET @MaxID = @@IDENTITY
  11108. DECLARE @Temp AS NUMERIC(18, 2)
  11109. IF @IsAgent = 1 AND @PayMethod <> 103
  11110. SET @Paid = @Accounts ----SET @Paid = @Paid * 5 Old Rule
  11111. SET @Temp = @Paid -- 1 + CONVERT(NUMERIC(18, 2), '0.' + RIGHT(STR(@cpMainID), 2))
  11112. --金币或订单全额支付
  11113. IF @Temp < 0
  11114. SET @Temp = 0
  11115. UPDATE caOrder SET Paid = @Temp WHERE ID = @MaxID
  11116. IF @UseCoin IS NOT NULL
  11117. BEGIN
  11118. --插入金币记录
  11119. INSERT INTO cpCoin (cpMainID, caOrderID, Coin, Balance, AddDate)
  11120. VALUES(@cpMainID, @MaxID, 0-@UseCoin, 0, GETDATE())
  11121. END
  11122. IF @UsePoint IS NOT NULL
  11123. BEGIN
  11124. --插入积分记录
  11125. INSERT INTO cpPoint (cpMainID, ChangeID, Point, relativeID, LastModifyDate)
  11126. VALUES(@cpMainID, 15, 0 - @UsePoint, @MaxID, GETDATE())
  11127. UPDATE caOrder SET NeedInvoice = 0 WHERE ID = @MaxID
  11128. DECLARE @BeginDate SMALLDATETIME
  11129. SET @BeginDate = GETDATE()
  11130. IF @Balance > 0
  11131. SELECT TOP 1 @BeginDate = EndDate FROM caOrder WITH(NOLOCK)
  11132. WHERE cpMainID = @cpMainID AND OrderType = @OrderType AND Balance = @Balance
  11133. AND EndDate > GETDATE() AND OpenDate IS NOT NULL AND IsDeleted = 0 ORDER BY EndDate DESC
  11134. ELSE
  11135. SELECT TOP 1 @BeginDate = EndDate FROM caOrder WITH(NOLOCK)
  11136. WHERE cpMainID = @cpMainID AND OrderType = @OrderType
  11137. AND EndDate > GETDATE() AND OpenDate IS NOT NULL AND IsDeleted = 0 ORDER BY EndDate DESC
  11138. IF @OrderType > 4
  11139. BEGIN -- 立即开通积分订单
  11140. UPDATE caOrder SET BeginDate = @BeginDate,
  11141. EndDate = DATEADD(DAY, PlaceWeek * 7, @BeginDate),
  11142. OpenDate = GETDATE(),
  11143. NeedInvoice = 0
  11144. WHERE PayMethod = 103
  11145. AND PlaceWeek > 0
  11146. AND Id = @MaxID
  11147. UPDATE caOrder
  11148. SET NeedInvoice = 0, ReceiveMan = 112, ReceiveDate = GETDATE()
  11149. WHERE PayMethod = 103
  11150. AND PlaceWeek > 0
  11151. AND Id = @MaxID
  11152. END
  11153. END
  11154. END TRY
  11155. BEGIN CATCH
  11156. GOTO ERR
  11157. END CATCH
  11158. COMMIT
  11159. RETURN @MaxID
  11160. ERR:
  11161. BEGIN
  11162. ROLLBACK TRAN
  11163. RETURN 0
  11164. END
  11165. SET NOCOUNT OFF
  11166. GO
  11167. /****** Object: StoredProcedure [dbo].[ccCaOrderInsert2] Script Date: 2018/12/13 19:06:11 ******/
  11168. SET ANSI_NULLS ON
  11169. GO
  11170. SET QUOTED_IDENTIFIER ON
  11171. GO
  11172. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  11173. -- Author: Peter
  11174. -- Create date: 2014-08-20 09:55
  11175. -- Description:
  11176. -- Modify: Harry 2015-7-10
  11177. -- Description:修改needpoint为从dcfeedetail中取出(282行)
  11178. -- Modify: Harry 修改一年内最大积分数不能超过qlrc @MaxPoint=20000
  11179. -- Other Site @MaxPoint=10000
  11180. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  11181. CREATE PROCEDURE [dbo].[ccCaOrderInsert2]
  11182. (
  11183. @cpMainID INT,
  11184. @IsAgent BIT,
  11185. @ProvinceID INT,
  11186. @ServiceType INT = NULL,
  11187. @PlaceWeek TINYINT = NULL,
  11188. @PayMethod TINYINT,
  11189. @OrderType TINYINT,
  11190. @Accounts NUMERIC(18, 2),
  11191. @Paid NUMERIC(18, 2),
  11192. @Balance NUMERIC(18, 2) = NULL,
  11193. @LinkMan NVARCHAR(50),
  11194. @Telephone VARCHAR(50),
  11195. @LinkRemark NVARCHAR(1000),
  11196. @Manageruserid SMALLINT,
  11197. @ActiveQuota SMALLINT = NULL,
  11198. @JobNumber SMALLINT = NULL,
  11199. @CompanyName VARCHAR(100),
  11200. @MainOrderID INT = NULL,
  11201. @InvoiceCompany SMALLINT,
  11202. @UserNumber SMALLINT = NULL,
  11203. @dcFeeDetailsID INT = NULL,
  11204. @UseCoin INT = NULL,
  11205. @UsePoint INT = NULL
  11206. )
  11207. AS
  11208. SET NOCOUNT ON
  11209. BEGIN
  11210. DECLARE @MaxId AS INT, @MaxPoint AS INT, @Type INT
  11211. IF LEFT(@ProvinceID, 2) = 32
  11212. SELECT @MaxPoint = 20000--设置1年内最大积分兑换额度
  11213. ELSE
  11214. SELECT @MaxPoint = 10000--设置1年内最大积分兑换额度
  11215. BEGIN
  11216. IF @OrderType = 8
  11217. BEGIN
  11218. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK), dcVipDetail b WITH(NOLOCK)
  11219. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID, 2)
  11220. AND b.ID = @dcFeeDetailsID AND a.startDate<GETDATE() AND a.endDate > GETDATE())
  11221. begin
  11222. select 111
  11223. GOTO ERR --检查是否套餐已过期
  11224. end
  11225. SELECT @Accounts = (b.PriceMonth * a.[Month]+a.ResumeNumber*b.PriceResume+JobNumber*b.PriceJob+UserNumber*b.PriceUser),
  11226. @Paid = a.Price, @ActiveQuota = a.ResumeNumber, @JobNumber = a.JobNumber, @UserNumber = a.UserNumber
  11227. FROM dcVipDetail a WITH(NOLOCK), dcVip b WITH(NOLOCK)
  11228. WHERE a.ID = @dcFeeDetailsID
  11229. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11230. AND a.dcVipID = b.ID
  11231. END
  11232. ELSE IF @OrderType = 4 AND @ServiceType = 6 ----根据周数查询1/6广告的资费信息
  11233. BEGIN
  11234. SET @Type = 4
  11235. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11236. @Paid = a.Price * @PlaceWeek,
  11237. @dcFeeDetailsID = a.ID
  11238. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11239. WHERE a.dcFeeID = b.ID
  11240. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11241. AND b.Type = @Type
  11242. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11243. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11244. IF @dcFeeDetailsID IS NULL
  11245. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11246. FROM dcFee WITH(NOLOCK)
  11247. WHERE Type = @Type
  11248. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11249. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11250. END
  11251. ELSE IF @OrderType = 4 AND @ServiceType = 7 ----根据周数查询2/6广告的资费信息
  11252. BEGIN
  11253. SET @Type = 5
  11254. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11255. @Paid = a.Price * @PlaceWeek,
  11256. @dcFeeDetailsID = a.ID
  11257. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11258. WHERE b.Type = @Type
  11259. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11260. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11261. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11262. AND a.dcFeeID = b.ID
  11263. IF @dcFeeDetailsID IS NULL
  11264. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11265. FROM dcFee WITH(NOLOCK)
  11266. WHERE Type = @Type
  11267. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11268. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11269. END
  11270. ELSE IF @OrderType = 4 AND @ServiceType = 8 ----根据周数查询3/6广告的资费信息
  11271. BEGIN
  11272. SET @Type = 20
  11273. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11274. @Paid = a.Price * @PlaceWeek,
  11275. @dcFeeDetailsID = a.ID
  11276. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11277. WHERE b.Type = @Type
  11278. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11279. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11280. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11281. AND a.dcFeeID = b.ID
  11282. IF @dcFeeDetailsID IS NULL
  11283. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11284. FROM dcFee WITH(NOLOCK)
  11285. WHERE Type = @Type
  11286. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11287. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11288. END
  11289. ELSE IF @OrderType = 4 AND @ServiceType = 9 ----根据周数查询6/6广告的资费信息
  11290. BEGIN
  11291. SET @Type = 21
  11292. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11293. @Paid = a.Price * @PlaceWeek,
  11294. @dcFeeDetailsID = a.ID
  11295. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11296. WHERE b.Type = @Type
  11297. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11298. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11299. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11300. AND a.dcFeeID = b.ID
  11301. IF @dcFeeDetailsID IS NULL
  11302. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11303. FROM dcFee WITH(NOLOCK)
  11304. WHERE Type = @Type
  11305. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11306. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11307. END
  11308. ELSE IF @OrderType = 4 AND @ServiceType = 10 ----根据周数查询6/6广告的资费信息
  11309. BEGIN
  11310. SET @Type = 23
  11311. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11312. @Paid = a.Price * @PlaceWeek,
  11313. @dcFeeDetailsID = a.ID
  11314. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11315. WHERE b.Type = @Type
  11316. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11317. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11318. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11319. AND a.dcFeeID = b.ID
  11320. IF @dcFeeDetailsID IS NULL
  11321. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11322. FROM dcFee WITH(NOLOCK)
  11323. WHERE Type = @Type
  11324. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11325. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11326. END
  11327. ELSE IF @OrderType = 7 ----根据周数查询固定位置的资费信息
  11328. BEGIN
  11329. SET @Type = 7
  11330. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11331. @Paid = a.Price * @PlaceWeek,
  11332. @dcFeeDetailsID = a.ID
  11333. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11334. WHERE b.Type = @Type
  11335. AND a.dcFeeID = b.ID
  11336. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11337. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11338. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11339. IF @dcFeeDetailsID IS NULL
  11340. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11341. FROM dcFee WITH(NOLOCK)
  11342. WHERE Type = @Type
  11343. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11344. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11345. END
  11346. ELSE IF @OrderType = 9 ----简历下载
  11347. BEGIN
  11348. SET @Type = 9
  11349. SELECT TOP 1 @Accounts = b.Price * @ActiveQuota,
  11350. @Paid = a.Price * @ActiveQuota,
  11351. @dcFeeDetailsID = a.ID
  11352. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11353. WHERE b.Type = @Type
  11354. AND a.dcFeeID = b.ID
  11355. AND ((MinValue< = @ActiveQuota AND MaxValue> = @ActiveQuota) OR (MinValue< = @ActiveQuota AND MaxValue = 0))
  11356. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11357. IF @dcFeeDetailsID IS NULL
  11358. SELECT TOP 1 @Accounts = Price, @Paid = Price * @ActiveQuota
  11359. FROM dcFee WITH(NOLOCK)
  11360. WHERE Type = @Type
  11361. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11362. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11363. END
  11364. ELSE IF @OrderType = 10 ----职位数
  11365. BEGIN
  11366. SET @Type = 10
  11367. SELECT TOP 1 @Accounts = b.Price * @JobNumber,
  11368. @Paid = a.Price * @JobNumber,
  11369. @dcFeeDetailsID = a.ID
  11370. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11371. WHERE b.Type = @Type
  11372. AND a.dcFeeID = b.ID
  11373. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11374. AND ((MinValue< = @JobNumber AND MaxValue> = @JobNumber) OR (MinValue< = @JobNumber AND MaxValue = 0))
  11375. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11376. IF @dcFeeDetailsID IS NULL
  11377. SELECT TOP 1 @Accounts = Price, @Paid = Price * @JobNumber
  11378. FROM dcFee WITH(NOLOCK)
  11379. WHERE Type = @Type
  11380. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11381. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11382. END
  11383. ELSE IF @OrderType = 11 ----用户数
  11384. BEGIN
  11385. SET @Type = 11
  11386. SELECT TOP 1 @Accounts = b.Price * @UserNumber,
  11387. @Paid = a.Price * @UserNumber,
  11388. @dcFeeDetailsID = a.ID
  11389. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11390. WHERE b.Type = @Type
  11391. AND a.dcFeeID = b.ID
  11392. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11393. AND ((MinValue< = @UserNumber AND MaxValue> = @UserNumber) OR (MinValue< = @UserNumber AND MaxValue = 0))
  11394. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11395. IF @dcFeeDetailsID IS NULL
  11396. SELECT TOP 1 @Accounts = Price, @Paid = Price * @UserNumber
  11397. FROM dcFee WITH(NOLOCK)
  11398. WHERE Type = @Type
  11399. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11400. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11401. END
  11402. ELSE IF @OrderType = 12 ----根据周数职位置顶资费信息
  11403. BEGIN
  11404. SET @Type = 22
  11405. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11406. @Paid = a.Price * @PlaceWeek,
  11407. @dcFeeDetailsID = a.ID
  11408. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11409. WHERE b.Type = @Type
  11410. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11411. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11412. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11413. AND a.dcFeeID = b.ID
  11414. IF @dcFeeDetailsID IS NULL
  11415. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11416. FROM dcFee WITH(NOLOCK)
  11417. WHERE Type = @Type
  11418. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11419. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11420. END
  11421. ELSE IF @OrderType = 13 ----根据周数职位置顶资费信息
  11422. BEGIN
  11423. SET @Type = 24
  11424. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11425. @Paid = a.Price * @PlaceWeek,
  11426. @dcFeeDetailsID = a.ID
  11427. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11428. WHERE b.Type = @Type
  11429. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11430. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11431. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11432. AND a.dcFeeID = b.ID
  11433. IF @dcFeeDetailsID IS NULL
  11434. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11435. FROM dcFee WITH(NOLOCK)
  11436. WHERE Type = @Type
  11437. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11438. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11439. END
  11440. IF @MainOrderID IS NOT NULL
  11441. IF NOT EXISTS(SELECT 'x' FROM caOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND ID = @MainOrderID AND OrderType = 8 AND EndDate >GETDATE())
  11442. AND @OrderType in (9, 10, 11)
  11443. begin
  11444. select 222
  11445. GOTO ERR --检查是否是自己有效的主订单号
  11446. end
  11447. DECLARE @CoinBalance AS INT
  11448. DECLARE @PointBalance AS INT
  11449. IF @UseCoin IS NOT NULL
  11450. BEGIN
  11451. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainCoin > = @UseCoin)
  11452. begin
  11453. select 333
  11454. GOTO ERR --检查剩余金币数量是否足够支付
  11455. end
  11456. SET @Paid = @Paid - @UseCoin
  11457. END
  11458. IF @UsePoint IS NOT NULL --积分支付
  11459. BEGIN
  11460. DECLARE @NeedPoint INT, @dcFeeDetailsID2 INT, @SumPoint AS INT
  11461. SELECT @NeedPoint = NeedPoint FROM dcfeedetail WHERE Id = @dcFeeDetailsID
  11462. IF @NeedPoint IS NULL
  11463. BEGIN
  11464. SELECT TOP 1 @dcFeeDetailsID2 = a.ID
  11465. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11466. WHERE b.Type = @Type
  11467. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11468. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11469. AND a.NeedPoint > 0
  11470. AND a.dcFeeID = b.ID
  11471. SELECT @NeedPoint = NeedPoint FROM dcfeedetail WHERE id = @dcFeeDetailsID2
  11472. END
  11473. IF @OrderType IN(4, 7, 12, 13)
  11474. BEGIN
  11475. SET @UsePoint = @NeedPoint * @PlaceWeek
  11476. END
  11477. ELSE
  11478. BEGIN
  11479. SET @UsePoint = @NeedPoint
  11480. END
  11481. --积分兑换的积分数是否超过最大数值
  11482. SELECT @SumPoint = SUM(PaidPoint)
  11483. FROM caOrder
  11484. WHERE cpMainid = @cpMainID
  11485. AND IsDeleted = 0 --未删除
  11486. AND ISNULL(Paid, 0) = 0 --付款为0
  11487. AND ISNULL(PaidCoin, 0) = 0 --金币支付为0
  11488. AND ISNULL(PaidPoint, 0) > 0 --积分不为0
  11489. AND Adddate > DATEADD(YEAR, -1, GETDATE())
  11490. IF(@SumPoint + @UsePoint) > @MaxPoint
  11491. BEGIN
  11492. select @SumPoint + @UsePoint, @SumPoint , @UsePoint, @MaxPoint
  11493. GOTO ERR --超过最大积分数量
  11494. END
  11495. --HarryEND
  11496. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainPoint > = @UsePoint)
  11497. BEGIN
  11498. select 555
  11499. GOTO ERR --检查剩余积分数量是否足够支付
  11500. END
  11501. SET @Paid = 0
  11502. END
  11503. IF @Paid < 0
  11504. SET @Paid = 0
  11505. INSERT INTO caOrder (cpMainID, ProvinceID, ServiceType, PlaceWeek, PayMethod, UserNumber,
  11506. OrderType, Accounts, Paid, Balance, LinkMan, Telephone, LinkRemark, Manageruserid,
  11507. ActiveQuota, RemainQuota, JobNumber, CompanyName, MainOrderID, InvoiceCompany,
  11508. dcFeeDetailID, PaidCoin, PaidPoint)
  11509. VALUES(@cpMainID, @ProvinceID, @ServiceType, @PlaceWeek, @PayMethod, @UserNumber,
  11510. @OrderType, @Accounts, @Paid, @Balance, @LinkMan, @Telephone, @LinkRemark, @Manageruserid,
  11511. @ActiveQuota, @ActiveQuota, @JobNumber, @CompanyName, @MainOrderID, @InvoiceCompany,
  11512. @dcFeeDetailsID, @UseCoin, @UsePoint)
  11513. SET @MaxID = @@IDENTITY
  11514. DECLARE @Temp AS NUMERIC(18, 2)
  11515. IF @IsAgent = 1 AND @PayMethod <> 103
  11516. SET @Paid = @Accounts ----SET @Paid = @Paid * 5 Old Rule
  11517. SET @Temp = @Paid - 1 + CONVERT(NUMERIC(18, 2), '0.' + RIGHT(STR(@cpMainID), 2))
  11518. --金币或订单全额支付
  11519. IF @Temp < 0
  11520. SET @Temp = 0
  11521. UPDATE caOrder SET Paid = @Temp WHERE ID = @MaxID
  11522. IF @UseCoin IS NOT NULL
  11523. BEGIN
  11524. --插入金币记录
  11525. INSERT INTO cpCoin (cpMainID, caOrderID, Coin, Balance, AddDate)
  11526. VALUES(@cpMainID, @MaxID, 0-@UseCoin, 0, GETDATE())
  11527. END
  11528. IF @UsePoint IS NOT NULL
  11529. BEGIN
  11530. --插入积分记录
  11531. INSERT INTO cpPoint (cpMainID, ChangeID, Point, relativeID, LastModifyDate)
  11532. VALUES(@cpMainID, 15, 0 - @UsePoint, @MaxID, GETDATE())
  11533. UPDATE caOrder SET NeedInvoice = 0 WHERE ID = @MaxID
  11534. DECLARE @BeginDate SMALLDATETIME
  11535. SET @BeginDate = GETDATE()
  11536. IF @Balance > 0
  11537. SELECT TOP 1 @BeginDate = EndDate FROM caOrder WITH(NOLOCK)
  11538. WHERE cpMainID = @cpMainID AND OrderType = @OrderType AND Balance = @Balance
  11539. AND EndDate > GETDATE() AND OpenDate IS NOT NULL AND IsDeleted = 0 ORDER BY EndDate DESC
  11540. ELSE
  11541. SELECT TOP 1 @BeginDate = EndDate FROM caOrder WITH(NOLOCK)
  11542. WHERE cpMainID = @cpMainID AND OrderType = @OrderType
  11543. AND EndDate > GETDATE() AND OpenDate IS NOT NULL AND IsDeleted = 0 ORDER BY EndDate DESC
  11544. IF @OrderType > 4
  11545. BEGIN -- 立即开通积分订单
  11546. UPDATE caOrder SET BeginDate = @BeginDate,
  11547. EndDate = DATEADD(DAY, PlaceWeek * 7, @BeginDate),
  11548. OpenDate = GETDATE(),
  11549. NeedInvoice = 0
  11550. WHERE PayMethod = 103
  11551. AND PlaceWeek > 0
  11552. AND Id = @MaxID
  11553. UPDATE caOrder
  11554. SET NeedInvoice = 0, ReceiveMan = 112, ReceiveDate = GETDATE()
  11555. WHERE PayMethod = 103
  11556. AND PlaceWeek > 0
  11557. AND Id = @MaxID
  11558. END
  11559. END
  11560. END
  11561. END
  11562. RETURN @MaxID
  11563. select @MaxID
  11564. ERR:
  11565. BEGIN
  11566. select 'aaa'
  11567. RETURN 0
  11568. END
  11569. GO
  11570. /****** Object: StoredProcedure [dbo].[ccCaOrderInsert3] Script Date: 2018/12/13 19:06:12 ******/
  11571. SET ANSI_NULLS ON
  11572. GO
  11573. SET QUOTED_IDENTIFIER ON
  11574. GO
  11575. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  11576. -- Create date: 2017-06-06 Harry
  11577. -- Description: harry 在ccCaOrderInsert1基础上 增加职位刷新数订单15
  11578. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  11579. CREATE PROCEDURE [dbo].[ccCaOrderInsert3]
  11580. (
  11581. @cpMainID INT,
  11582. @IsAgent BIT,
  11583. @ProvinceID INT,
  11584. @ServiceType INT = NULL,
  11585. @PlaceWeek TINYINT = NULL,
  11586. @PayMethod TINYINT,
  11587. @OrderType TINYINT,
  11588. @Accounts NUMERIC(18, 2),
  11589. @Paid NUMERIC(18, 2),
  11590. @Balance NUMERIC(18, 2) = NULL,
  11591. @LinkMan NVARCHAR(50),
  11592. @Telephone VARCHAR(50),
  11593. @LinkRemark NVARCHAR(1000),
  11594. @Manageruserid SMALLINT,
  11595. @ActiveQuota SMALLINT = NULL,
  11596. @JobNumber SMALLINT = NULL,
  11597. @CompanyName VARCHAR(100),
  11598. @MainOrderID INT = NULL,
  11599. @InvoiceCompany SMALLINT,
  11600. @UserNumber SMALLINT = NULL,
  11601. @dcFeeDetailsID INT = NULL,
  11602. @smsNumber SMALLINT =NULL,
  11603. @JobRefreshNumber INT =NULL,
  11604. @UseCoin INT = NULL,
  11605. @UsePoint INT = NULL
  11606. )
  11607. AS
  11608. SET NOCOUNT ON
  11609. BEGIN TRAN
  11610. DECLARE @MaxId AS INT, @MaxPoint AS INT, @Type INT
  11611. IF LEFT(@ProvinceID, 2) = 32
  11612. SELECT @MaxPoint = 20000--设置1年内最大积分兑换额度
  11613. ELSE
  11614. SELECT @MaxPoint = 10000--设置1年内最大积分兑换额度
  11615. BEGIN TRY
  11616. IF @OrderType = 8
  11617. BEGIN
  11618. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK), dcVipDetail b WITH(NOLOCK)
  11619. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID, 2)
  11620. AND b.ID = @dcFeeDetailsID AND a.startDate<GETDATE() AND a.endDate > GETDATE())
  11621. GOTO ERR --检查是否套餐已过期
  11622. SELECT @Accounts = (b.PriceMonth * a.[Month]+a.ResumeNumber*b.PriceResume+JobNumber*b.PriceJob+UserNumber*b.PriceUser+ISNULL(a.SmsNumber,0)*ISNULL(b.PriceSms,0)+ISNULL(a.JobRefreshNumber,0)*ISNULL(b.priceJobrefreshNumber,0)),
  11623. @Paid = a.Price, @ActiveQuota = a.ResumeNumber, @JobNumber = a.JobNumber, @UserNumber = a.UserNumber, @smsNumber=ISNULL(a.SmsNumber,0), @JobRefreshNumber= ISNULL(a.JobRefreshNumber,0)
  11624. FROM dcVipDetail a WITH(NOLOCK), dcVip b WITH(NOLOCK)
  11625. WHERE a.ID = @dcFeeDetailsID
  11626. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11627. AND a.dcVipID = b.ID
  11628. END
  11629. ELSE IF @OrderType = 4 AND @ServiceType = 6 ----根据周数查询1/6广告的资费信息
  11630. BEGIN
  11631. SET @Type = 4
  11632. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11633. @Paid = a.Price * @PlaceWeek,
  11634. @dcFeeDetailsID = a.ID
  11635. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11636. WHERE a.dcFeeID = b.ID
  11637. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11638. AND b.Type = @Type
  11639. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11640. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11641. IF @dcFeeDetailsID IS NULL
  11642. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11643. FROM dcFee WITH(NOLOCK)
  11644. WHERE Type = @Type
  11645. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11646. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11647. END
  11648. ELSE IF @OrderType = 4 AND @ServiceType = 7 ----根据周数查询2/6广告的资费信息
  11649. BEGIN
  11650. SET @Type = 5
  11651. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11652. @Paid = a.Price * @PlaceWeek,
  11653. @dcFeeDetailsID = a.ID
  11654. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11655. WHERE b.Type = @Type
  11656. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11657. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11658. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11659. AND a.dcFeeID = b.ID
  11660. IF @dcFeeDetailsID IS NULL
  11661. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11662. FROM dcFee WITH(NOLOCK)
  11663. WHERE Type = @Type
  11664. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11665. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11666. END
  11667. ELSE IF @OrderType = 4 AND @ServiceType = 8 ----根据周数查询3/6广告的资费信息
  11668. BEGIN
  11669. SET @Type = 20
  11670. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11671. @Paid = a.Price * @PlaceWeek,
  11672. @dcFeeDetailsID = a.ID
  11673. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11674. WHERE b.Type = @Type
  11675. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11676. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11677. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11678. AND a.dcFeeID = b.ID
  11679. IF @dcFeeDetailsID IS NULL
  11680. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11681. FROM dcFee WITH(NOLOCK)
  11682. WHERE Type = @Type
  11683. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11684. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11685. END
  11686. ELSE IF @OrderType = 4 AND @ServiceType = 9 ----根据周数查询6/6广告的资费信息
  11687. BEGIN
  11688. SET @Type = 21
  11689. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11690. @Paid = a.Price * @PlaceWeek,
  11691. @dcFeeDetailsID = a.ID
  11692. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11693. WHERE b.Type = @Type
  11694. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11695. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11696. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11697. AND a.dcFeeID = b.ID
  11698. IF @dcFeeDetailsID IS NULL
  11699. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11700. FROM dcFee WITH(NOLOCK)
  11701. WHERE Type = @Type
  11702. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11703. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11704. END
  11705. ELSE IF @OrderType = 4 AND @ServiceType = 10 ----根据周数查询6/6广告的资费信息
  11706. BEGIN
  11707. SET @Type = 23
  11708. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11709. @Paid = a.Price * @PlaceWeek,
  11710. @dcFeeDetailsID = a.ID
  11711. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11712. WHERE b.Type = @Type
  11713. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11714. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11715. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11716. AND a.dcFeeID = b.ID
  11717. IF @dcFeeDetailsID IS NULL
  11718. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11719. FROM dcFee WITH(NOLOCK)
  11720. WHERE Type = @Type
  11721. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11722. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11723. END
  11724. ELSE IF @OrderType = 7 ----根据周数查询固定位置的资费信息
  11725. BEGIN
  11726. SET @Type = 7
  11727. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11728. @Paid = a.Price * @PlaceWeek,
  11729. @dcFeeDetailsID = a.ID
  11730. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11731. WHERE b.Type = @Type
  11732. AND a.dcFeeID = b.ID
  11733. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11734. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11735. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11736. IF @dcFeeDetailsID IS NULL
  11737. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11738. FROM dcFee WITH(NOLOCK)
  11739. WHERE Type = @Type
  11740. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11741. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11742. END
  11743. ELSE IF @OrderType = 9 ----简历下载
  11744. BEGIN
  11745. SET @Type = 9
  11746. SELECT TOP 1 @Accounts = b.Price * @ActiveQuota,
  11747. @Paid = a.Price * @ActiveQuota,
  11748. @dcFeeDetailsID = a.ID
  11749. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11750. WHERE b.Type = @Type
  11751. AND a.dcFeeID = b.ID
  11752. AND ((MinValue< = @ActiveQuota AND MaxValue> = @ActiveQuota) OR (MinValue< = @ActiveQuota AND MaxValue = 0))
  11753. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11754. IF @dcFeeDetailsID IS NULL
  11755. SELECT TOP 1 @Accounts = Price, @Paid = Price * @ActiveQuota
  11756. FROM dcFee WITH(NOLOCK)
  11757. WHERE Type = @Type
  11758. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11759. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11760. END
  11761. ELSE IF @OrderType = 10 ----职位数
  11762. BEGIN
  11763. SET @Type = 10
  11764. SELECT TOP 1 @Accounts = b.Price * @JobNumber,
  11765. @Paid = a.Price * @JobNumber,
  11766. @dcFeeDetailsID = a.ID
  11767. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11768. WHERE b.Type = @Type
  11769. AND a.dcFeeID = b.ID
  11770. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11771. AND ((MinValue< = @JobNumber AND MaxValue> = @JobNumber) OR (MinValue< = @JobNumber AND MaxValue = 0))
  11772. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11773. IF @dcFeeDetailsID IS NULL
  11774. SELECT TOP 1 @Accounts = Price, @Paid = Price * @JobNumber
  11775. FROM dcFee WITH(NOLOCK)
  11776. WHERE Type = @Type
  11777. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11778. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11779. END
  11780. ELSE IF @OrderType = 11 ----用户数
  11781. BEGIN
  11782. SET @Type = 11
  11783. SELECT TOP 1 @Accounts = b.Price * @UserNumber,
  11784. @Paid = a.Price * @UserNumber,
  11785. @dcFeeDetailsID = a.ID
  11786. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11787. WHERE b.Type = @Type
  11788. AND a.dcFeeID = b.ID
  11789. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11790. AND ((MinValue< = @UserNumber AND MaxValue> = @UserNumber) OR (MinValue< = @UserNumber AND MaxValue = 0))
  11791. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11792. IF @dcFeeDetailsID IS NULL
  11793. SELECT TOP 1 @Accounts = Price, @Paid = Price * @UserNumber
  11794. FROM dcFee WITH(NOLOCK)
  11795. WHERE Type = @Type
  11796. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11797. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11798. END
  11799. ELSE IF @OrderType = 12 ----根据周数职位置顶资费信息
  11800. BEGIN
  11801. SET @Type = 22
  11802. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11803. @Paid = a.Price * @PlaceWeek,
  11804. @dcFeeDetailsID = a.ID
  11805. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11806. WHERE b.Type = @Type
  11807. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11808. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11809. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11810. AND a.dcFeeID = b.ID
  11811. IF @dcFeeDetailsID IS NULL
  11812. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11813. FROM dcFee WITH(NOLOCK)
  11814. WHERE Type = @Type
  11815. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11816. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11817. END
  11818. ELSE IF @OrderType = 13 ----根据周数职位置顶资费信息
  11819. BEGIN
  11820. SET @Type = 24
  11821. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  11822. @Paid = a.Price * @PlaceWeek,
  11823. @dcFeeDetailsID = a.ID
  11824. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11825. WHERE b.Type = @Type
  11826. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11827. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11828. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  11829. AND a.dcFeeID = b.ID
  11830. IF @dcFeeDetailsID IS NULL
  11831. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  11832. FROM dcFee WITH(NOLOCK)
  11833. WHERE Type = @Type
  11834. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11835. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11836. END
  11837. ELSE IF @OrderType = 14 ----短信订单
  11838. BEGIN
  11839. SET @Type = 14
  11840. SELECT TOP 1 @Accounts = b.Price * @smsNumber,
  11841. @Paid = a.Price * @smsNumber,
  11842. @dcFeeDetailsID = a.ID
  11843. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11844. WHERE b.Type = @Type
  11845. AND a.dcFeeID = b.ID
  11846. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11847. AND ((MinValue< = @smsNumber AND MaxValue> = @smsNumber) OR (MinValue< = @smsNumber AND MaxValue = 0))
  11848. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11849. IF @dcFeeDetailsID IS NULL
  11850. SELECT TOP 1 @Accounts = Price, @Paid = Price * @smsNumber
  11851. FROM dcFee WITH(NOLOCK)
  11852. WHERE Type = @Type
  11853. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11854. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11855. END
  11856. ELSE IF @OrderType = 15 ----刷新数订单
  11857. BEGIN
  11858. SET @Type = 15
  11859. SELECT TOP 1 @Accounts = b.Price * @JobRefreshNumber,
  11860. @Paid = a.Price * @JobRefreshNumber,
  11861. @dcFeeDetailsID = a.ID
  11862. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11863. WHERE b.Type = @Type
  11864. AND a.dcFeeID = b.ID
  11865. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11866. AND ((MinValue< = @JobRefreshNumber AND MaxValue> = @JobRefreshNumber) OR (MinValue< = @JobRefreshNumber AND MaxValue = 0))
  11867. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11868. IF @dcFeeDetailsID IS NULL
  11869. SELECT TOP 1 @Accounts = Price, @Paid = Price * @JobRefreshNumber
  11870. FROM dcFee WITH(NOLOCK)
  11871. WHERE Type = @Type
  11872. AND dcProvinceID = LEFT(@ProvinceID, 2)
  11873. AND StartDate < GETDATE() AND EndDate > GETDATE()
  11874. END
  11875. IF @MainOrderID IS NOT NULL
  11876. IF NOT EXISTS(SELECT 'x' FROM caOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND ID = @MainOrderID AND OrderType = 8 AND EndDate >GETDATE())
  11877. AND @OrderType in (9, 10, 11,14)
  11878. GOTO ERR --检查是否是自己有效的主订单号
  11879. DECLARE @CoinBalance AS INT
  11880. DECLARE @PointBalance AS INT
  11881. IF @UseCoin IS NOT NULL
  11882. BEGIN
  11883. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainCoin > = @UseCoin)
  11884. GOTO ERR --检查剩余金币数量是否足够支付
  11885. SET @Paid = @Paid - @UseCoin
  11886. END
  11887. IF @UsePoint IS NOT NULL --积分支付
  11888. BEGIN
  11889. DECLARE @NeedPoint INT, @dcFeeDetailsID2 INT, @SumPoint AS INT
  11890. SELECT @NeedPoint = NeedPoint FROM dcfeedetail WHERE Id = @dcFeeDetailsID
  11891. IF @NeedPoint IS NULL
  11892. BEGIN
  11893. SELECT TOP 1 @dcFeeDetailsID2 = a.ID
  11894. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  11895. WHERE b.Type = @Type
  11896. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  11897. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  11898. AND a.NeedPoint > 0
  11899. AND a.dcFeeID = b.ID
  11900. SELECT @NeedPoint = NeedPoint FROM dcfeedetail WHERE id = @dcFeeDetailsID2
  11901. END
  11902. IF @OrderType IN(4, 7, 12, 13)
  11903. BEGIN
  11904. SET @UsePoint = @NeedPoint * @PlaceWeek
  11905. END
  11906. ELSE
  11907. BEGIN
  11908. SET @UsePoint = @NeedPoint
  11909. END
  11910. --积分兑换的积分数是否超过最大数值
  11911. SELECT @SumPoint = SUM(PaidPoint)
  11912. FROM caOrder
  11913. WHERE cpMainid = @cpMainID
  11914. AND IsDeleted = 0 --未删除
  11915. AND ISNULL(Paid, 0) = 0 --付款为0
  11916. AND ISNULL(PaidCoin, 0) = 0 --金币支付为0
  11917. AND ISNULL(PaidPoint, 0) > 0 --积分不为0
  11918. AND Adddate > DATEADD(YEAR, -1, GETDATE())
  11919. IF(@SumPoint + @UsePoint) > @MaxPoint
  11920. BEGIN
  11921. GOTO ERR --超过最大积分数量
  11922. END
  11923. --HarryEND
  11924. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainPoint > = @UsePoint)
  11925. BEGIN
  11926. GOTO ERR --检查剩余积分数量是否足够支付
  11927. END
  11928. SET @Paid = 0
  11929. END
  11930. IF @Paid < 0
  11931. SET @Paid = 0
  11932. INSERT INTO caOrder (cpMainID, ProvinceID, ServiceType, PlaceWeek, PayMethod, UserNumber,
  11933. OrderType, Accounts, Paid, Balance, LinkMan, Telephone, LinkRemark, Manageruserid,
  11934. ActiveQuota, RemainQuota, JobNumber, CompanyName, MainOrderID, InvoiceCompany,
  11935. dcFeeDetailID, PaidCoin, PaidPoint, SmsQuota, RemainSmsQuota, jobRefreshQuota, remainJobRefreshQuota)
  11936. VALUES(@cpMainID, @ProvinceID, @ServiceType, @PlaceWeek, @PayMethod, @UserNumber,
  11937. @OrderType, @Accounts, @Paid, @Balance, @LinkMan, @Telephone, @LinkRemark, @Manageruserid,
  11938. @ActiveQuota, @ActiveQuota, @JobNumber, @CompanyName, @MainOrderID, @InvoiceCompany,
  11939. @dcFeeDetailsID, @UseCoin, @UsePoint, @smsNumber, @smsNumber, @JobRefreshNumber, @JobRefreshNumber)
  11940. SET @MaxID = @@IDENTITY
  11941. DECLARE @Temp AS NUMERIC(18, 2)
  11942. IF @IsAgent = 1 AND @PayMethod <> 103
  11943. SET @Paid = @Accounts ----SET @Paid = @Paid * 5 Old Rule
  11944. SET @Temp = @Paid -- 1 + CONVERT(NUMERIC(18, 2), '0.' + RIGHT(STR(@cpMainID), 2))
  11945. --金币或订单全额支付
  11946. IF @Temp < 0
  11947. SET @Temp = 0
  11948. UPDATE caOrder SET Paid = @Temp WHERE ID = @MaxID
  11949. IF @UseCoin IS NOT NULL
  11950. BEGIN
  11951. --插入金币记录
  11952. INSERT INTO cpCoin (cpMainID, caOrderID, Coin, Balance, AddDate)
  11953. VALUES(@cpMainID, @MaxID, 0-@UseCoin, 0, GETDATE())
  11954. END
  11955. IF @UsePoint IS NOT NULL
  11956. BEGIN
  11957. --插入积分记录
  11958. INSERT INTO cpPoint (cpMainID, ChangeID, Point, relativeID, LastModifyDate)
  11959. VALUES(@cpMainID, 15, 0 - @UsePoint, @MaxID, GETDATE())
  11960. UPDATE caOrder SET NeedInvoice = 0 WHERE ID = @MaxID
  11961. DECLARE @BeginDate SMALLDATETIME
  11962. SET @BeginDate = GETDATE()
  11963. IF @Balance > 0
  11964. SELECT TOP 1 @BeginDate = EndDate FROM caOrder WITH(NOLOCK)
  11965. WHERE cpMainID = @cpMainID AND OrderType = @OrderType AND Balance = @Balance
  11966. AND EndDate > GETDATE() AND OpenDate IS NOT NULL AND IsDeleted = 0 ORDER BY EndDate DESC
  11967. ELSE
  11968. SELECT TOP 1 @BeginDate = EndDate FROM caOrder WITH(NOLOCK)
  11969. WHERE cpMainID = @cpMainID AND OrderType = @OrderType
  11970. AND EndDate > GETDATE() AND OpenDate IS NOT NULL AND IsDeleted = 0 ORDER BY EndDate DESC
  11971. IF @OrderType > 4
  11972. BEGIN -- 立即开通积分订单
  11973. UPDATE caOrder SET BeginDate = @BeginDate,
  11974. EndDate = DATEADD(DAY, PlaceWeek * 7, @BeginDate),
  11975. OpenDate = GETDATE(),
  11976. NeedInvoice = 0
  11977. WHERE PayMethod = 103
  11978. AND PlaceWeek > 0
  11979. AND Id = @MaxID
  11980. UPDATE caOrder
  11981. SET NeedInvoice = 0, ReceiveMan = 112, ReceiveDate = GETDATE()
  11982. WHERE PayMethod = 103
  11983. AND PlaceWeek > 0
  11984. AND Id = @MaxID
  11985. END
  11986. END
  11987. END TRY
  11988. BEGIN CATCH
  11989. GOTO ERR
  11990. END CATCH
  11991. COMMIT
  11992. RETURN @MaxID
  11993. ERR:
  11994. BEGIN
  11995. ROLLBACK TRAN
  11996. RETURN 0
  11997. END
  11998. SET NOCOUNT OFF
  11999. GO
  12000. /****** Object: StoredProcedure [dbo].[ccCaOrderInsert4] Script Date: 2018/12/13 19:06:12 ******/
  12001. SET ANSI_NULLS ON
  12002. GO
  12003. SET QUOTED_IDENTIFIER ON
  12004. GO
  12005. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  12006. -- Create date: 2017-06-06 Harry
  12007. -- Description: harry 在ccCaOrderInsert1基础上 增加职位刷新数订单15
  12008. -- Modify Date :2018-09-21 Peter
  12009. -- Description: 添加新的订单类型 评测订单为25
  12010. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  12011. CREATE PROCEDURE [dbo].[ccCaOrderInsert4]
  12012. (
  12013. @cpMainID INT,
  12014. @IsAgent BIT,
  12015. @ProvinceID INT,
  12016. @ServiceType INT = NULL,
  12017. @PlaceWeek TINYINT = NULL,
  12018. @PayMethod TINYINT,
  12019. @OrderType TINYINT,
  12020. @Accounts NUMERIC(18, 2),
  12021. @Paid NUMERIC(18, 2),
  12022. @Balance NUMERIC(18, 2) = NULL,
  12023. @LinkMan NVARCHAR(50),
  12024. @Telephone VARCHAR(50),
  12025. @LinkRemark NVARCHAR(1000),
  12026. @Manageruserid SMALLINT,
  12027. @ActiveQuota SMALLINT = NULL,
  12028. @JobNumber SMALLINT = NULL,
  12029. @CompanyName VARCHAR(100),
  12030. @MainOrderID INT = NULL,
  12031. @InvoiceCompany SMALLINT,
  12032. @UserNumber SMALLINT = NULL,
  12033. @dcFeeDetailsID INT = NULL,
  12034. @smsNumber SMALLINT =NULL,
  12035. @JobRefreshNumber INT =NULL,
  12036. @UseCoin INT = NULL,
  12037. @UsePoint INT = NULL,
  12038. @AssessNumber INT = NULL
  12039. )
  12040. AS
  12041. SET NOCOUNT ON
  12042. BEGIN TRAN
  12043. DECLARE @MaxId AS INT, @MaxPoint AS INT, @Type INT
  12044. IF LEFT(@ProvinceID, 2) = 32
  12045. SELECT @MaxPoint = 20000--设置1年内最大积分兑换额度
  12046. ELSE
  12047. SELECT @MaxPoint = 10000--设置1年内最大积分兑换额度
  12048. BEGIN TRY
  12049. IF @OrderType = 8
  12050. BEGIN
  12051. IF NOT EXISTS(SELECT 'x' FROM dcVip a WITH(NOLOCK), dcVipDetail b WITH(NOLOCK)
  12052. WHERE a.ID = b.dcVipID AND a.dcProvinceID = LEFT(@ProvinceID, 2)
  12053. AND b.ID = @dcFeeDetailsID AND a.startDate<GETDATE() AND a.endDate > GETDATE())
  12054. GOTO ERR --检查是否套餐已过期
  12055. SELECT @Accounts = (b.PriceMonth * a.[Month]+a.ResumeNumber*b.PriceResume+JobNumber*b.PriceJob+UserNumber*b.PriceUser+ISNULL(a.SmsNumber,0)*ISNULL(b.PriceSms,0)+ISNULL(a.JobRefreshNumber,0)*ISNULL(b.priceJobrefreshNumber,0)+ISNULL(a.AssessReportNumber,0)*ISNULL(b.PriceAssessReport,0)),
  12056. @Paid = a.Price, @ActiveQuota = a.ResumeNumber, @JobNumber = a.JobNumber, @UserNumber = a.UserNumber, @smsNumber=ISNULL(a.SmsNumber,0), @JobRefreshNumber= ISNULL(a.JobRefreshNumber,0)
  12057. FROM dcVipDetail a WITH(NOLOCK), dcVip b WITH(NOLOCK)
  12058. WHERE a.ID = @dcFeeDetailsID
  12059. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12060. AND a.dcVipID = b.ID
  12061. END
  12062. ELSE IF @OrderType = 4 AND @ServiceType = 6 ----根据周数查询1/6广告的资费信息
  12063. BEGIN
  12064. SET @Type = 4
  12065. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  12066. @Paid = a.Price * @PlaceWeek,
  12067. @dcFeeDetailsID = a.ID
  12068. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12069. WHERE a.dcFeeID = b.ID
  12070. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12071. AND b.Type = @Type
  12072. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12073. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  12074. IF @dcFeeDetailsID IS NULL
  12075. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  12076. FROM dcFee WITH(NOLOCK)
  12077. WHERE Type = @Type
  12078. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12079. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12080. END
  12081. ELSE IF @OrderType = 4 AND @ServiceType = 7 ----根据周数查询2/6广告的资费信息
  12082. BEGIN
  12083. SET @Type = 5
  12084. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  12085. @Paid = a.Price * @PlaceWeek,
  12086. @dcFeeDetailsID = a.ID
  12087. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12088. WHERE b.Type = @Type
  12089. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12090. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12091. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  12092. AND a.dcFeeID = b.ID
  12093. IF @dcFeeDetailsID IS NULL
  12094. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  12095. FROM dcFee WITH(NOLOCK)
  12096. WHERE Type = @Type
  12097. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12098. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12099. END
  12100. ELSE IF @OrderType = 4 AND @ServiceType = 8 ----根据周数查询3/6广告的资费信息
  12101. BEGIN
  12102. SET @Type = 20
  12103. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  12104. @Paid = a.Price * @PlaceWeek,
  12105. @dcFeeDetailsID = a.ID
  12106. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12107. WHERE b.Type = @Type
  12108. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12109. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12110. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  12111. AND a.dcFeeID = b.ID
  12112. IF @dcFeeDetailsID IS NULL
  12113. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  12114. FROM dcFee WITH(NOLOCK)
  12115. WHERE Type = @Type
  12116. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12117. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12118. END
  12119. ELSE IF @OrderType = 4 AND @ServiceType = 9 ----根据周数查询6/6广告的资费信息
  12120. BEGIN
  12121. SET @Type = 21
  12122. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  12123. @Paid = a.Price * @PlaceWeek,
  12124. @dcFeeDetailsID = a.ID
  12125. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12126. WHERE b.Type = @Type
  12127. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12128. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12129. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  12130. AND a.dcFeeID = b.ID
  12131. IF @dcFeeDetailsID IS NULL
  12132. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  12133. FROM dcFee WITH(NOLOCK)
  12134. WHERE Type = @Type
  12135. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12136. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12137. END
  12138. ELSE IF @OrderType = 4 AND @ServiceType = 10 ----根据周数查询6/6广告的资费信息
  12139. BEGIN
  12140. SET @Type = 23
  12141. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  12142. @Paid = a.Price * @PlaceWeek,
  12143. @dcFeeDetailsID = a.ID
  12144. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12145. WHERE b.Type = @Type
  12146. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12147. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12148. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  12149. AND a.dcFeeID = b.ID
  12150. IF @dcFeeDetailsID IS NULL
  12151. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  12152. FROM dcFee WITH(NOLOCK)
  12153. WHERE Type = @Type
  12154. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12155. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12156. END
  12157. ELSE IF @OrderType = 7 ----根据周数查询固定位置的资费信息
  12158. BEGIN
  12159. SET @Type = 7
  12160. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  12161. @Paid = a.Price * @PlaceWeek,
  12162. @dcFeeDetailsID = a.ID
  12163. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12164. WHERE b.Type = @Type
  12165. AND a.dcFeeID = b.ID
  12166. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12167. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  12168. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12169. IF @dcFeeDetailsID IS NULL
  12170. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  12171. FROM dcFee WITH(NOLOCK)
  12172. WHERE Type = @Type
  12173. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12174. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12175. END
  12176. ELSE IF @OrderType = 9 ----简历下载
  12177. BEGIN
  12178. SET @Type = 9
  12179. SELECT TOP 1 @Accounts = b.Price * @ActiveQuota,
  12180. @Paid = a.Price * @ActiveQuota,
  12181. @dcFeeDetailsID = a.ID
  12182. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12183. WHERE b.Type = @Type
  12184. AND a.dcFeeID = b.ID
  12185. AND ((MinValue< = @ActiveQuota AND MaxValue> = @ActiveQuota) OR (MinValue< = @ActiveQuota AND MaxValue = 0))
  12186. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12187. IF @dcFeeDetailsID IS NULL
  12188. SELECT TOP 1 @Accounts = Price, @Paid = Price * @ActiveQuota
  12189. FROM dcFee WITH(NOLOCK)
  12190. WHERE Type = @Type
  12191. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12192. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12193. END
  12194. ELSE IF @OrderType = 10 ----职位数
  12195. BEGIN
  12196. SET @Type = 10
  12197. SELECT TOP 1 @Accounts = b.Price * @JobNumber,
  12198. @Paid = a.Price * @JobNumber,
  12199. @dcFeeDetailsID = a.ID
  12200. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12201. WHERE b.Type = @Type
  12202. AND a.dcFeeID = b.ID
  12203. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12204. AND ((MinValue< = @JobNumber AND MaxValue> = @JobNumber) OR (MinValue< = @JobNumber AND MaxValue = 0))
  12205. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12206. IF @dcFeeDetailsID IS NULL
  12207. SELECT TOP 1 @Accounts = Price, @Paid = Price * @JobNumber
  12208. FROM dcFee WITH(NOLOCK)
  12209. WHERE Type = @Type
  12210. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12211. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12212. END
  12213. ELSE IF @OrderType = 11 ----用户数
  12214. BEGIN
  12215. SET @Type = 11
  12216. SELECT TOP 1 @Accounts = b.Price * @UserNumber,
  12217. @Paid = a.Price * @UserNumber,
  12218. @dcFeeDetailsID = a.ID
  12219. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12220. WHERE b.Type = @Type
  12221. AND a.dcFeeID = b.ID
  12222. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12223. AND ((MinValue< = @UserNumber AND MaxValue> = @UserNumber) OR (MinValue< = @UserNumber AND MaxValue = 0))
  12224. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12225. IF @dcFeeDetailsID IS NULL
  12226. SELECT TOP 1 @Accounts = Price, @Paid = Price * @UserNumber
  12227. FROM dcFee WITH(NOLOCK)
  12228. WHERE Type = @Type
  12229. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12230. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12231. END
  12232. ELSE IF @OrderType = 12 ----根据周数职位置顶资费信息
  12233. BEGIN
  12234. SET @Type = 22
  12235. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  12236. @Paid = a.Price * @PlaceWeek,
  12237. @dcFeeDetailsID = a.ID
  12238. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12239. WHERE b.Type = @Type
  12240. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12241. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12242. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  12243. AND a.dcFeeID = b.ID
  12244. IF @dcFeeDetailsID IS NULL
  12245. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  12246. FROM dcFee WITH(NOLOCK)
  12247. WHERE Type = @Type
  12248. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12249. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12250. END
  12251. ELSE IF @OrderType = 13 ----根据周数职位置顶资费信息
  12252. BEGIN
  12253. SET @Type = 24
  12254. SELECT TOP 1 @Accounts = b.Price * @PlaceWeek,
  12255. @Paid = a.Price * @PlaceWeek,
  12256. @dcFeeDetailsID = a.ID
  12257. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12258. WHERE b.Type = @Type
  12259. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12260. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12261. AND ((MinValue< = @PlaceWeek AND MaxValue> = @PlaceWeek) OR (MinValue< = @PlaceWeek AND MaxValue = 0))
  12262. AND a.dcFeeID = b.ID
  12263. IF @dcFeeDetailsID IS NULL
  12264. SELECT TOP 1 @Accounts = Price, @Paid = Price * @PlaceWeek
  12265. FROM dcFee WITH(NOLOCK)
  12266. WHERE Type = @Type
  12267. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12268. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12269. END
  12270. ELSE IF @OrderType = 14 ----短信订单
  12271. BEGIN
  12272. SET @Type = 14
  12273. SELECT TOP 1 @Accounts = b.Price * @smsNumber,
  12274. @Paid = a.Price * @smsNumber,
  12275. @dcFeeDetailsID = a.ID
  12276. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12277. WHERE b.Type = @Type
  12278. AND a.dcFeeID = b.ID
  12279. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12280. AND ((MinValue< = @smsNumber AND MaxValue> = @smsNumber) OR (MinValue< = @smsNumber AND MaxValue = 0))
  12281. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12282. IF @dcFeeDetailsID IS NULL
  12283. SELECT TOP 1 @Accounts = Price, @Paid = Price * @smsNumber
  12284. FROM dcFee WITH(NOLOCK)
  12285. WHERE Type = @Type
  12286. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12287. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12288. END
  12289. ELSE IF @OrderType = 15 ----刷新数订单
  12290. BEGIN
  12291. SET @Type = 15
  12292. SELECT TOP 1 @Accounts = b.Price * @JobRefreshNumber,
  12293. @Paid = a.Price * @JobRefreshNumber,
  12294. @dcFeeDetailsID = a.ID
  12295. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12296. WHERE b.Type = @Type
  12297. AND a.dcFeeID = b.ID
  12298. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12299. AND ((MinValue< = @JobRefreshNumber AND MaxValue> = @JobRefreshNumber) OR (MinValue< = @JobRefreshNumber AND MaxValue = 0))
  12300. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12301. IF @dcFeeDetailsID IS NULL
  12302. SELECT TOP 1 @Accounts = Price, @Paid = Price * @JobRefreshNumber
  12303. FROM dcFee WITH(NOLOCK)
  12304. WHERE Type = @Type
  12305. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12306. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12307. END
  12308. ELSE IF @OrderType = 25 ----刷新数订单
  12309. BEGIN
  12310. SET @Type = 25
  12311. SELECT TOP 1 @Accounts = b.Price * @AssessNumber,
  12312. @Paid = a.Price * @AssessNumber,
  12313. @dcFeeDetailsID = a.ID
  12314. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12315. WHERE b.Type = @Type
  12316. AND a.dcFeeID = b.ID
  12317. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12318. AND ((MinValue< = @AssessNumber AND MaxValue> = @AssessNumber) OR (MinValue< = @AssessNumber AND MaxValue = 0))
  12319. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12320. IF @dcFeeDetailsID IS NULL
  12321. SELECT TOP 1 @Accounts = Price,@Paid = Price * @AssessNumber
  12322. FROM dcFee WITH(NOLOCK)
  12323. WHERE Type = @Type
  12324. AND dcProvinceID = LEFT(@ProvinceID, 2)
  12325. AND StartDate < GETDATE() AND EndDate > GETDATE()
  12326. END
  12327. IF @MainOrderID IS NOT NULL
  12328. IF NOT EXISTS(SELECT 'x' FROM caOrder WITH(NOLOCK) WHERE cpMainID = @cpMainID AND ID = @MainOrderID AND OrderType = 8 AND EndDate >GETDATE())
  12329. AND @OrderType in (9, 10, 11,14)
  12330. GOTO ERR --检查是否是自己有效的主订单号
  12331. DECLARE @CoinBalance AS INT
  12332. DECLARE @PointBalance AS INT
  12333. IF @UseCoin IS NOT NULL
  12334. BEGIN
  12335. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainCoin > = @UseCoin)
  12336. GOTO ERR --检查剩余金币数量是否足够支付
  12337. SET @Paid = @Paid - @UseCoin
  12338. END
  12339. IF @UsePoint IS NOT NULL --积分支付
  12340. BEGIN
  12341. DECLARE @NeedPoint INT, @dcFeeDetailsID2 INT, @SumPoint AS INT
  12342. SELECT @NeedPoint = NeedPoint FROM dcfeedetail WHERE Id = @dcFeeDetailsID
  12343. IF @NeedPoint IS NULL
  12344. BEGIN
  12345. SELECT TOP 1 @dcFeeDetailsID2 = a.ID
  12346. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  12347. WHERE b.Type = @Type
  12348. AND b.dcProvinceID = LEFT(@ProvinceID, 2)
  12349. AND StartDate < GETDATE() AND EndDate > = GETDATE()
  12350. AND a.NeedPoint > 0
  12351. AND a.dcFeeID = b.ID
  12352. SELECT @NeedPoint = NeedPoint FROM dcfeedetail WHERE id = @dcFeeDetailsID2
  12353. END
  12354. IF @OrderType IN(4, 7, 12, 13)
  12355. BEGIN
  12356. SET @UsePoint = @NeedPoint * @PlaceWeek
  12357. END
  12358. ELSE
  12359. BEGIN
  12360. SET @UsePoint = @NeedPoint
  12361. END
  12362. --积分兑换的积分数是否超过最大数值
  12363. SELECT @SumPoint = SUM(PaidPoint)
  12364. FROM caOrder
  12365. WHERE cpMainid = @cpMainID
  12366. AND IsDeleted = 0 --未删除
  12367. AND ISNULL(Paid, 0) = 0 --付款为0
  12368. AND ISNULL(PaidCoin, 0) = 0 --金币支付为0
  12369. AND ISNULL(PaidPoint, 0) > 0 --积分不为0
  12370. AND Adddate > DATEADD(YEAR, -1, GETDATE())
  12371. IF(@SumPoint + @UsePoint) > @MaxPoint
  12372. BEGIN
  12373. GOTO ERR --超过最大积分数量
  12374. END
  12375. --HarryEND
  12376. IF NOT EXISTS(SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND RemainPoint > = @UsePoint)
  12377. BEGIN
  12378. GOTO ERR --检查剩余积分数量是否足够支付
  12379. END
  12380. SET @Paid = 0
  12381. END
  12382. IF @Paid < 0
  12383. SET @Paid = 0
  12384. INSERT INTO caOrder (cpMainID, ProvinceID, ServiceType, PlaceWeek, PayMethod, UserNumber,
  12385. OrderType, Accounts, Paid, Balance, LinkMan, Telephone, LinkRemark, Manageruserid,
  12386. ActiveQuota, RemainQuota, JobNumber, CompanyName, MainOrderID, InvoiceCompany,
  12387. dcFeeDetailID, PaidCoin, PaidPoint, SmsQuota, RemainSmsQuota, jobRefreshQuota,
  12388. remainJobRefreshQuota,AssessReportQuota,RemainAssessReportQuota)
  12389. VALUES(@cpMainID, @ProvinceID, @ServiceType, @PlaceWeek, @PayMethod, @UserNumber,
  12390. @OrderType, @Accounts, @Paid, @Balance, @LinkMan, @Telephone, @LinkRemark, @Manageruserid,
  12391. @ActiveQuota, @ActiveQuota, @JobNumber, @CompanyName, @MainOrderID, @InvoiceCompany,
  12392. @dcFeeDetailsID, @UseCoin, @UsePoint, @smsNumber, @smsNumber, @JobRefreshNumber,
  12393. @JobRefreshNumber,@AssessNumber,@AssessNumber)
  12394. SET @MaxID = @@IDENTITY
  12395. DECLARE @Temp AS NUMERIC(18, 2)
  12396. IF @IsAgent = 1 AND @PayMethod <> 103
  12397. SET @Paid = @Accounts ----SET @Paid = @Paid * 5 Old Rule
  12398. SET @Temp = @Paid -- 1 + CONVERT(NUMERIC(18, 2), '0.' + RIGHT(STR(@cpMainID), 2))
  12399. --金币或订单全额支付
  12400. IF @Temp < 0
  12401. SET @Temp = 0
  12402. UPDATE caOrder SET Paid = @Temp WHERE ID = @MaxID
  12403. IF @UseCoin IS NOT NULL
  12404. BEGIN
  12405. --插入金币记录
  12406. INSERT INTO cpCoin (cpMainID, caOrderID, Coin, Balance, AddDate)
  12407. VALUES(@cpMainID, @MaxID, 0-@UseCoin, 0, GETDATE())
  12408. END
  12409. IF @UsePoint IS NOT NULL
  12410. BEGIN
  12411. --插入积分记录
  12412. INSERT INTO cpPoint (cpMainID, ChangeID, Point, relativeID, LastModifyDate)
  12413. VALUES(@cpMainID, 15, 0 - @UsePoint, @MaxID, GETDATE())
  12414. UPDATE caOrder SET NeedInvoice = 0 WHERE ID = @MaxID
  12415. DECLARE @BeginDate SMALLDATETIME
  12416. SET @BeginDate = GETDATE()
  12417. IF @Balance > 0
  12418. SELECT TOP 1 @BeginDate = EndDate FROM caOrder WITH(NOLOCK)
  12419. WHERE cpMainID = @cpMainID AND OrderType = @OrderType AND Balance = @Balance
  12420. AND EndDate > GETDATE() AND OpenDate IS NOT NULL AND IsDeleted = 0 ORDER BY EndDate DESC
  12421. ELSE
  12422. SELECT TOP 1 @BeginDate = EndDate FROM caOrder WITH(NOLOCK)
  12423. WHERE cpMainID = @cpMainID AND OrderType = @OrderType
  12424. AND EndDate > GETDATE() AND OpenDate IS NOT NULL AND IsDeleted = 0 ORDER BY EndDate DESC
  12425. IF @OrderType > 4
  12426. BEGIN -- 立即开通积分订单
  12427. UPDATE caOrder SET BeginDate = @BeginDate,
  12428. EndDate = DATEADD(DAY, PlaceWeek * 7, @BeginDate),
  12429. OpenDate = GETDATE(),
  12430. NeedInvoice = 0
  12431. WHERE PayMethod = 103
  12432. AND PlaceWeek > 0
  12433. AND Id = @MaxID
  12434. UPDATE caOrder
  12435. SET NeedInvoice = 0, ReceiveMan = 112, ReceiveDate = GETDATE()
  12436. WHERE PayMethod = 103
  12437. AND PlaceWeek > 0
  12438. AND Id = @MaxID
  12439. END
  12440. END
  12441. END TRY
  12442. BEGIN CATCH
  12443. GOTO ERR
  12444. END CATCH
  12445. COMMIT
  12446. RETURN @MaxID
  12447. ERR:
  12448. BEGIN
  12449. ROLLBACK TRAN
  12450. RETURN 0
  12451. END
  12452. SET NOCOUNT OFF
  12453. GO
  12454. /****** Object: StoredProcedure [dbo].[ccCaOrderInvoiceNullUpdate] Script Date: 2018/12/13 19:06:13 ******/
  12455. SET ANSI_NULLS ON
  12456. GO
  12457. SET QUOTED_IDENTIFIER ON
  12458. GO
  12459. --#####################################################
  12460. --创建时间:2014.11.6
  12461. --创建人:John
  12462. --说明:更新会员订单的发票信息为空
  12463. --#####################################################
  12464. CREATE PROCEDURE [dbo].[ccCaOrderInvoiceNullUpdate]
  12465. (
  12466. @caOrderID INT,
  12467. @cpMainID INT
  12468. )
  12469. AS
  12470. BEGIN
  12471. UPDATE caOrder SET InvoiceAskDate = NULL,NeedInvoice = 0,InvoiceConfirmDate = NULL,InvoiceConfirmMan = NULL
  12472. WHERE ID = @caOrderID AND cpMainID = @cpMainID
  12473. END
  12474. GO
  12475. /****** Object: StoredProcedure [dbo].[ccCaOrderInvoiceUpdate] Script Date: 2018/12/13 19:06:14 ******/
  12476. SET ANSI_NULLS ON
  12477. GO
  12478. SET QUOTED_IDENTIFIER ON
  12479. GO
  12480. CREATE PROCEDURE [dbo].[ccCaOrderInvoiceUpdate]
  12481. (
  12482. @ID INT,
  12483. @caMainID INT,
  12484. @InvoiceTitle NVARCHAR(50),
  12485. @PostTelephone VARCHAR(50),
  12486. @Recipient NVARCHAR(100),
  12487. @Zip char(6),
  12488. @MailAddress NVARCHAR(100)
  12489. )
  12490. AS
  12491. BEGIN
  12492. IF EXISTS(SELECT 'X' FROM caOrder WHERE ID=@ID AND cpMainID = (SELECT cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID))
  12493. BEGIN
  12494. UPDATE caOrder SET InvoiceAskDate=GETDATE(),NeedInvoice=1,InvoiceTitle=@InvoiceTitle,PostTelephone=@PostTelephone,
  12495. Zip=@Zip,MailAddress=@MailAddress,Recipient=@Recipient WHERE ID=@ID
  12496. RETURN 1
  12497. END
  12498. ELSE
  12499. RETURN 0
  12500. END
  12501. GO
  12502. /****** Object: StoredProcedure [dbo].[ccCaOrderInvoiceUpdateNew] Script Date: 2018/12/13 19:06:14 ******/
  12503. SET ANSI_NULLS ON
  12504. GO
  12505. SET QUOTED_IDENTIFIER ON
  12506. GO
  12507. CREATE PROCEDURE [dbo].[ccCaOrderInvoiceUpdateNew]
  12508. (
  12509. @ID INT,
  12510. @caMainID INT,
  12511. @InvoiceTitle NVARCHAR(50),
  12512. @PostTelephone VARCHAR(50),
  12513. @Recipient NVARCHAR(100),
  12514. @Zip char(6),
  12515. @MailAddress NVARCHAR(100),
  12516. @Tariff VARCHAR(30),
  12517. @RegisterAddress NVARCHAR(100),
  12518. @RegisterTel VARCHAR(50),
  12519. @BankName VARCHAR(50),
  12520. @BankAccount VARCHAR(50)
  12521. )
  12522. AS
  12523. BEGIN
  12524. IF EXISTS(SELECT 'X' FROM caOrder WHERE ID=@ID AND cpMainID = (SELECT cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID))
  12525. BEGIN
  12526. UPDATE caOrder SET
  12527. InvoiceAskDate=GETDATE(),NeedInvoice=1,
  12528. InvoiceTitle=@InvoiceTitle,PostTelephone=@PostTelephone,
  12529. Zip=@Zip,MailAddress=@MailAddress,Recipient=@Recipient,
  12530. Tariff = @Tariff,RegisterAddress = @RegisterAddress,
  12531. RegisterTel = @RegisterTel,BankName = @BankName,
  12532. BankAccount = @BankAccount
  12533. WHERE ID=@ID
  12534. RETURN 1
  12535. END
  12536. ELSE
  12537. RETURN 0
  12538. END
  12539. GO
  12540. /****** Object: StoredProcedure [dbo].[ccCaOrderPointByCpMainIDSelect] Script Date: 2018/12/13 19:06:14 ******/
  12541. SET ANSI_NULLS ON
  12542. GO
  12543. SET QUOTED_IDENTIFIER ON
  12544. GO
  12545. -- =============================================
  12546. -- Author: Harry
  12547. -- Create date: 2015-7-9
  12548. -- Description: 获取企业一年内积分免费兑换的总积分数量
  12549. -- =============================================
  12550. CREATE PROCEDURE [dbo].[ccCaOrderPointByCpMainIDSelect]
  12551. (
  12552. @cpMainID INT
  12553. )
  12554. AS
  12555. BEGIN
  12556. SELECT SUM(PaidPoint)cnt
  12557. FROM caOrder
  12558. WHERE cpMainID=@cpMainID
  12559. AND IsDeleted=0--未删除
  12560. AND ISNULL(Paid,0)=0--付款为0
  12561. AND ISNULL(PaidCoin,0)=0--金币支付为0
  12562. AND ISNULL(PaidPoint,0)>0--积分不为0
  12563. AND Adddate > DATEADD(YEAR, -1, GETDATE())
  12564. END
  12565. GO
  12566. /****** Object: StoredProcedure [dbo].[ccCaOrderSelect] Script Date: 2018/12/13 19:06:14 ******/
  12567. SET ANSI_NULLS ON
  12568. GO
  12569. SET QUOTED_IDENTIFIER ON
  12570. GO
  12571. ---------------------------------------------------------------------------------------------------------------------
  12572. --cccaorderSELECT 8796242,'OpenDate IS NULL'
  12573. --mice 2014-8-21 修改, 添加返回值: a.PaidCoin, a.PaidPoint
  12574. --harry 2017-7-8 修改 a.SmsQuota, a.RemainSmsQuota
  12575. CREATE PROCEDURE [dbo].[ccCaOrderSelect]
  12576. (
  12577. @cpMainID INT,
  12578. @WHERE VARCHAR(200)
  12579. )
  12580. AS
  12581. BEGIN
  12582. SET @Where = REPLACE(dbo.SafeSql(@Where), '''', '''''')
  12583. DECLARE @SQL AS VARCHAR(2000)
  12584. SET @SQL='SELECT a.ID,a.cpMainID,a.ProvinceID,a.ServiceType,a.PlaceWeek,a.PayMethod,a.jobRefreshQuota,a.remainJobRefreshQuota,
  12585. a.OrderType,a.Accounts,a.Paid,a.Balance,a.LinkMan,a.Telephone AS LinkTelephone,
  12586. a.LinkRemark,a.MailAddress,a.Recipient,a.Zip,a.FaxFile,a.CompanyName,
  12587. a.RemittanceFile,a.RemittanceDate,a.PostTelephone,a.ReceiveDate,
  12588. a.NeedInvoice,a.InvoiceTitle,a.InvoiceCompany,
  12589. a.InvoiceConfirmDate,a.InvoiceConfirmMan,a.InvoiceAskDate,
  12590. a.ContractFile,a.Manageruserid,a.IsDeleted,a.DeletedMan,a.DeletedDate,
  12591. a.OpenMan,a.OpenDate,a.BeginDate,a.EndDate,a.AddDate,a.ActiveQuota,
  12592. a.PaidCoin, a.PaidPoint, a.dcFeeDetailID,
  12593. a.RemainQuota,a.JobNumber,a.MainOrderID, a.SmsQuota, a.RemainSmsQuota, a.AssessReportQuota, a.RemainAssessReportQuota, b.PayMethodID,c.Name as PayMethodName,b.Receiver,
  12594. b.Account,b.BankName
  12595. FROM caOrder a WITH(NOLOCK)
  12596. INNER JOIN dcPayMethod c WITH(NOLOCK) ON a.PayMethod = c.PayMethodID
  12597. LEFT JOIN dcPayMethodProvince b WITH(NOLOCK) ON a.PayMethod = b.PayMethodID
  12598. AND b.dcProvinceID = CASE WHEN a.InvoiceCompany = 4 THEN 30 WHEN a.InvoiceCompany = 2 THEN 10 END
  12599. WHERE (a.IsDeleted=0 OR a.IsDeleted IS NULL)
  12600. AND a.cpMainID = ' + CONVERT(VARCHAR(10), @cpMainID)
  12601. IF @cpMainId = 8399005
  12602. SET @SQL = @SQL + ' AND a.Id NOT IN(282110,282108,281450,205880)'
  12603. IF LEN(@WHERE)> 0
  12604. SET @SQL = @SQL + ' AND ' + @WHERE
  12605. SET @SQL = @SQL + ' ORDER BY a.ID DESC'
  12606. print @SQL
  12607. EXEC(@SQL)
  12608. END
  12609. GO
  12610. /****** Object: StoredProcedure [dbo].[ccCaorderSelectByOrdertype] Script Date: 2018/12/13 19:06:14 ******/
  12611. SET ANSI_NULLS ON
  12612. GO
  12613. SET QUOTED_IDENTIFIER ON
  12614. GO
  12615. --根据类型获取订单信息
  12616. --Harry
  12617. --说明:1:简历下载数只取主订单,从属的简历订单不显示
  12618. --2017-12-5
  12619. CREATE PROCEDURE [dbo].[ccCaorderSelectByOrdertype]
  12620. (
  12621. @orderType INT,--1简历
  12622. @cpMainId INT
  12623. )
  12624. AS
  12625. SET NOCOUNT ON
  12626. BEGIN
  12627. IF @orderType=1
  12628. BEGIN
  12629. SELECT * FROM caOrder WITH(NOLOCK)
  12630. WHERE cpMainId = @cpMainId
  12631. AND orderType = 8
  12632. AND OpenDate IS NOT NULl
  12633. AND endDate>GETDATE()
  12634. AND IsDeleted = 0
  12635. ORDER BY endDate
  12636. END
  12637. END
  12638. SET NOCOUNT OFF
  12639. GO
  12640. /****** Object: StoredProcedure [dbo].[ccCaOrderTryOutSelect] Script Date: 2018/12/13 19:06:14 ******/
  12641. SET ANSI_NULLS ON
  12642. GO
  12643. SET QUOTED_IDENTIFIER ON
  12644. GO
  12645. CREATE PROCEDURE [dbo].[ccCaOrderTryOutSelect]
  12646. (
  12647. @cpMainID INT
  12648. )
  12649. AS
  12650. IF EXISTS
  12651. (
  12652. SELECT 'x' FROM caOrder WITH(NOLOCK)
  12653. WHERE cpMainID = @cpMainID
  12654. AND BeginDate<GETDATE()
  12655. AND EndDate>GETDATE()
  12656. AND OrderType = 8
  12657. AND ServiceType = 101
  12658. )
  12659. RETURN 1
  12660. ELSE
  12661. RETURN 0
  12662. GO
  12663. /****** Object: StoredProcedure [dbo].[ccCaPlaintByCaMainIDSelect] Script Date: 2018/12/13 19:06:15 ******/
  12664. SET ANSI_NULLS ON
  12665. GO
  12666. SET QUOTED_IDENTIFIER ON
  12667. GO
  12668. CREATE PROCEDURE [dbo].[ccCaPlaintByCaMainIDSelect]
  12669. (
  12670. @caMainID INT
  12671. )
  12672. AS
  12673. BEGIN
  12674. SELECT dbo.GetPaName(a.cvMainID,b.cpMainID) paName, c.Name CompanyName, c.ID CompanyID, a.*, d.SecondID, d.paMainID
  12675. FROM CaPlaint a WITH(NOLOCK)
  12676. INNER JOIN caMain b WITH(NOLOCK) ON a.caMainID = b.ID
  12677. LEFT JOIN cpMain c WITH(NOLOCK) ON b.cpMainID = c.ID
  12678. INNER JOIN cvMain d WITH(NOLOCK) ON a.cvMainID = d.ID
  12679. WHERE a.caMainID = @caMainID
  12680. ORDER BY ID DESC
  12681. END
  12682. GO
  12683. /****** Object: StoredProcedure [dbo].[ccCaPlaintByCpMainIDSelect] Script Date: 2018/12/13 19:06:15 ******/
  12684. SET ANSI_NULLS ON
  12685. GO
  12686. SET QUOTED_IDENTIFIER ON
  12687. GO
  12688. CREATE PROCEDURE [dbo].[ccCaPlaintByCpMainIDSelect]
  12689. (
  12690. @cpMainID INT
  12691. )
  12692. AS
  12693. BEGIN
  12694. SELECT dbo.GetPaName(a.cvMainID,@cpMainID) paName,a.*,b.Name caName, c.SecondId, c.paMainID, b.cpMainID CompanyID
  12695. FROM CaPlaint a WITH(NOLOCK), caMain b WITH(NOLOCK), cvMain c WITH(NOLOCK) WHERE a.caMainID = b.ID AND a.cvMainID = c.ID AND b.cpMainID = @cpMainID AND b.isDelete = 0 ORDER BY a.ID DESC
  12696. END
  12697. GO
  12698. /****** Object: StoredProcedure [dbo].[ccCaPlaintInsert] Script Date: 2018/12/13 19:06:15 ******/
  12699. SET ANSI_NULLS ON
  12700. GO
  12701. SET QUOTED_IDENTIFIER ON
  12702. GO
  12703. --============
  12704. --检查 sean,2010-10-9
  12705. --查看简历时,对个人进行投诉
  12706. --============
  12707. CREATE PROCEDURE [dbo].[ccCaPlaintInsert]
  12708. (
  12709. @caMainID INT,
  12710. @cvMainID INT,
  12711. @Plaint VARCHAR(1000),
  12712. @LinkMan VARCHAR(50),
  12713. @Telephone VARCHAR(20)
  12714. )
  12715. AS
  12716. BEGIN TRY
  12717. INSERT INTO caPlaint(caMainID,cvMainID,PlaINT,LinkMan,Telephone)
  12718. VALUES(@caMainID,@cvMainID,@PlaINT,@LinkMan,@Telephone)
  12719. RETURN 1
  12720. END TRY
  12721. BEGIN CATCH
  12722. RETURN 0
  12723. END CATCH
  12724. GO
  12725. /****** Object: StoredProcedure [dbo].[cccaPushSetSelectByCaMainID] Script Date: 2018/12/13 19:06:15 ******/
  12726. SET ANSI_NULLS ON
  12727. GO
  12728. SET QUOTED_IDENTIFIER ON
  12729. GO
  12730. --------------------
  12731. --创建人 Peter
  12732. --创建时间:2016-10-17
  12733. --获取企业推送的相关数据
  12734. CREATE PROCEDURE [dbo].[cccaPushSetSelectByCaMainID]
  12735. (
  12736. @CaMainID INT
  12737. )
  12738. AS
  12739. SET NOCOUNT ON
  12740. BEGIN
  12741. SELECT * FROM caPushSet WHERE caMainID = @CaMainID
  12742. END
  12743. GO
  12744. /****** Object: StoredProcedure [dbo].[cccaPushSetUpdateByCaMainID] Script Date: 2018/12/13 19:06:15 ******/
  12745. SET ANSI_NULLS ON
  12746. GO
  12747. SET QUOTED_IDENTIFIER ON
  12748. GO
  12749. -------------------
  12750. --创建人 Peter
  12751. --创建时间:2016-10-17
  12752. --企业修改推送频率
  12753. CREATE PROCEDURE [dbo].[cccaPushSetUpdateByCaMainID]
  12754. (
  12755. @CaMainID INT,
  12756. @PushFrequency TINYINT
  12757. )
  12758. AS
  12759. SET NOCOUNT ON
  12760. BEGIN
  12761. IF EXISTS(SELECT 'x' FROM caPushSet WITH(NOLOCK) WHERE caMainID = @caMainID)
  12762. BEGIN
  12763. UPDATE caPushSet
  12764. SET PushFrequency = @PushFrequency,PushNo = 0
  12765. WHERE caMainID = @CaMainID
  12766. END
  12767. ELSE
  12768. BEGIN
  12769. INSERT INTO caPushSet(caMainID,PushFrequency,PushNo)
  12770. VALUES (@CaMainID,@PushFrequency,0)
  12771. END
  12772. END
  12773. GO
  12774. /****** Object: StoredProcedure [dbo].[ccCaSmsLogSelect] Script Date: 2018/12/13 19:06:16 ******/
  12775. SET ANSI_NULLS ON
  12776. GO
  12777. SET QUOTED_IDENTIFIER ON
  12778. GO
  12779. --创建人harry
  12780. --2017-6-7
  12781. --获取短信发送记录
  12782. CREATE PROCEDURE [dbo].[ccCaSmsLogSelect]
  12783. (
  12784. @cpMainID INT,
  12785. @orderID INT
  12786. )
  12787. AS
  12788. SET NOCOUNT ON
  12789. BEGIN
  12790. IF @orderID > 0
  12791. BEGIN
  12792. SELECT a.*, b.Name
  12793. FROM caSmsLog a WITH(NOLOCK)
  12794. LEFT JOIN caMain b WITH(NOLOCK) ON a.caMainid = b.Id
  12795. WHERE a.caOrderID = @orderID
  12796. ORDER BY a.id
  12797. END
  12798. ELSE
  12799. BEGIN
  12800. SELECT a.*, b.Name
  12801. FROM caSmsLog a WITH(NOLOCK)
  12802. LEFT JOIN caMain b WITH(NOLOCK) ON a.caMainid = b.Id
  12803. WHERE a.caOrderID IN(SELECT ID FROM caOrder WHERE cpMainID = @cpMainID)
  12804. ORDER by a.id
  12805. END
  12806. END
  12807. SET NOCOUNT OFF
  12808. GO
  12809. /****** Object: StoredProcedure [dbo].[ccCaVerifyLogByMobileIpSelect] Script Date: 2018/12/13 19:06:16 ******/
  12810. SET ANSI_NULLS ON
  12811. GO
  12812. SET QUOTED_IDENTIFIER ON
  12813. GO
  12814. --#####################################################
  12815. --创建时间:2017-7-11
  12816. --创建人:sean
  12817. --说明:获取cpmpany手机验证日志
  12818. --#####################################################
  12819. CREATE PROCEDURE [dbo].[ccCaVerifyLogByMobileIpSelect]
  12820. (
  12821. @Mobile VARCHAR(11),
  12822. @ip VARCHAR(31)
  12823. )
  12824. AS
  12825. BEGIN
  12826. SELECT TOP 1 * FROM CaVerifyLog WITH(NOLOCK)
  12827. WHERE Mobile = @Mobile
  12828. AND AddDate > DATEADD(HOUR, -1, GETDATE())
  12829. AND ip = @ip
  12830. AND VerifyDate IS NULL
  12831. ORDER BY id DESC
  12832. END
  12833. GO
  12834. /****** Object: StoredProcedure [dbo].[ccCaVerifyLogInsert] Script Date: 2018/12/13 19:06:16 ******/
  12835. SET ANSI_NULLS ON
  12836. GO
  12837. SET QUOTED_IDENTIFIER ON
  12838. GO
  12839. --sean 20170711
  12840. --手机号注册,前台发送验证码 cmpany
  12841. --harry2018-7-20黑名单手机号不发送
  12842. CREATE PROCEDURE [dbo].[ccCaVerifyLogInsert]
  12843. (
  12844. @Mobile VARCHAR(11),
  12845. @IP VARCHAR(31)
  12846. )
  12847. AS
  12848. SET NOCOUNT ON
  12849. BEGIN
  12850. IF EXISTS(SELECT 'x' FROM tmp_limitmobile WITH(NOLOCK) WHERE Mobile = @Mobile)
  12851. RETURN -1
  12852. IF EXISTS(SELECT 'x' FROM Company_Black WITH(NOLOCK) WHERE Mobile = @Mobile)
  12853. RETURN -1
  12854. --IF DATEPART(HOUR, GETDATE()) > 22 OR DATEPART(HOUR, GETDATE()) < 7
  12855. -- RETURN -1
  12856. --IF CHARINDEX(', ', @Ip) > 0
  12857. -- RETURN -1
  12858. IF CHARINDEX(', ', @Ip) > 0
  12859. SET @Ip = RIGHT(@ip, LEN(@ip) - CHARINDEX(', ', @ip))
  12860. DECLARE @VerifyCount SMALLINT
  12861. IF(SELECT COUNT(*) FROM Ip_WHite WHERE CHARINDEX(ip, @Ip) > 0 AND Kind = 2) = 0
  12862. SELECT @VerifyCount = COUNT(1) FROM caVerifyLog WITH(NOLOCK)
  12863. WHERE IP = @IP
  12864. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  12865. ELSE
  12866. SET @VerifyCount = 0
  12867. IF @VerifyCount > 3
  12868. RETURN -1
  12869. SELECT @VerifyCount = COUNT(1) FROM caVerifyLog WITH(NOLOCK)
  12870. WHERE Mobile = @Mobile
  12871. AND AddDate > CONVERT(VARCHAR(10), GETDATE(), 120)
  12872. IF @VerifyCount > 2
  12873. RETURN 0
  12874. SELECT @VerifyCount = COUNT(1) FROM caVerifyLog WITH(NOLOCK)
  12875. WHERE Mobile = @Mobile
  12876. AND AddDate > DATEADD(MINUTE, -5, GETDATE())
  12877. IF @VerifyCount > 3
  12878. RETURN 0
  12879. DECLARE @VerifyCode AS VARCHAR(6)
  12880. SELECT @VerifyCode = RAND() * 899999 + 100000
  12881. INSERT INTO caVerifyLog(caMainID, Mobile, VerifyCode, VerifyDate, AddDate, ip)
  12882. VALUES(0, @Mobile, @VerifyCode, NULL, GETDATE(), @IP)
  12883. RETURN @VerifyCode
  12884. END
  12885. GO
  12886. /****** Object: StoredProcedure [dbo].[ccCaVerifyLogUpdate] Script Date: 2018/12/13 19:06:17 ******/
  12887. SET ANSI_NULLS ON
  12888. GO
  12889. SET QUOTED_IDENTIFIER ON
  12890. GO
  12891. --#####################################################
  12892. --创建时间:2017-7-19
  12893. --创建人:sean
  12894. --说明:UPDATE cpmpany手机验证日志
  12895. --#####################################################
  12896. CREATE PROCEDURE [dbo].[ccCaVerifyLogUpdate]
  12897. (
  12898. @Id INT
  12899. )
  12900. AS
  12901. BEGIN
  12902. UPDATE CaVerifyLog SET VerifyDate = GETDATE() WHERE Id = @Id
  12903. END
  12904. GO
  12905. /****** Object: StoredProcedure [dbo].[ccChatOnLineByCaMainIDSelectNew] Script Date: 2018/12/13 19:06:17 ******/
  12906. SET ANSI_NULLS ON
  12907. GO
  12908. SET QUOTED_IDENTIFIER ON
  12909. GO
  12910. CREATE PROCEDURE [dbo].[ccChatOnLineByCaMainIDSelectNew]
  12911. (
  12912. @CaMainID INT, --企业用户的ID
  12913. @GetType INT
  12914. )
  12915. AS
  12916. SET NOCOUNT ON
  12917. --INSERT INTO procLog SELECT 'ccChatOnLineByCaMainIDSelectNew', LTRIM(STR(@CaMainID)) + ' ' + LTRIM(STR(@GetType)), GETDATE()
  12918. BEGIN
  12919. DECLARE @AddDate AS DATETIME, @CpMainID INT
  12920. IF @GetType = 0
  12921. BEGIN
  12922. IF NOT EXISTS(SELECT 'x' FROM SearchDb..ChatOnlineListLog WITH(NOLOCK)
  12923. WHERE caMainId = @caMainId
  12924. AND AddDate > DATEADD(MINUTE, -10, GETDATE())
  12925. )
  12926. SET @GetType = 1
  12927. END
  12928. IF @GetType = 1
  12929. BEGIN
  12930. SELECT @CpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @CaMainID
  12931. CREATE TABLE #UserList
  12932. (
  12933. ChatOnlineID INT,
  12934. CaMainID INT,
  12935. CvMainID INT,
  12936. EndDate SMALLDATETIME,
  12937. LastChatDate SMALLDATETIME,
  12938. SumUnRead INT,
  12939. IsHidden BIT
  12940. )
  12941. UPDATE ChatOnline
  12942. SET caUnViewed = 0
  12943. WHERE caUnViewed > 0
  12944. AND caMainId = @CaMainID
  12945. UPDATE a
  12946. SET a.caUnViewed = b.Cnt
  12947. FROM ChatOnline a WITH(NOLOCK), (
  12948. SELECT MAX(a.ID) Id, COUNT(*) Cnt
  12949. FROM ChatOnline a WITH(NOLOCK), ChatOnlineLog b WITH(NOLOCK)
  12950. WHERE a.id = b.ChatOnlineID
  12951. AND b.IsViewed = 0
  12952. AND b.SenderType <> 1 --不是企业发送的
  12953. AND a.caMainID = @CaMainID
  12954. GROUP BY a.CaMainID, a.CvMainID
  12955. ) b
  12956. WHERE a.Id = b.Id
  12957. --企业的联系人列表,有留言的
  12958. INSERT INTO #UserList
  12959. SELECT MAX(ID), @CaMainID, CvMainID, MAX(EndDate), MAX(StartDate), SUM(caUnViewed), 0
  12960. FROM ChatOnline WITH(NOLOCK)
  12961. WHERE caMainId = @CaMainID --当前企业用户
  12962. AND (caUnViewed > 0
  12963. OR StartDate > GETDATE() - 15)
  12964. GROUP BY CvMainID
  12965. --企业联系列表,15之外曾有联系的,隐藏不显示
  12966. INSERT INTO #UserList
  12967. SELECT MAX(ID), @CaMainID, CvMainID, MAX(EndDate), MAX(StartDate), 0, 1
  12968. FROM ChatOnline WITH(NOLOCK)
  12969. WHERE caMainId = @CaMainID --当前企业用户
  12970. AND CvMainID NOT IN(SELECT CvMainID FROM #UserList)
  12971. GROUP BY CvMainID
  12972. --最终结果
  12973. DELETE FROM SearchDb..ChatOnlineListLog WHERE caMainId = @CaMainId
  12974. DELETE FROM SearchDb..ChatOnlineList WHERE caMainId = @CaMainId
  12975. INSERT INTO SearchDb..ChatOnlineListLog SELECT @caMainId, GETDATE()
  12976. INSERT INTO SearchDb..ChatOnlineList
  12977. SELECT TOP 20
  12978. a.*,
  12979. dbo.GetPaName(b.ID, @CpMainID) PaName,
  12980. b.PaMainID,
  12981. b.JobName UserName,
  12982. ISNULL(c.IsOnline, 0) IsOnline
  12983. FROM #UserList a
  12984. INNER JOIN cvMain b ON a.cvMainID = b.ID
  12985. LEFT JOIN paOnline c ON b.paMainId = c.paMainId
  12986. ORDER BY a.LastChatDate DESC
  12987. DROP TABLE #UserList
  12988. END
  12989. SELECT * FROM SearchDb..ChatOnlineList WITH(NOLOCK)
  12990. WHERE caMainId = @CaMainId
  12991. ORDER BY SumUnRead Desc, LastChatDate DESC
  12992. END
  12993. GO
  12994. /****** Object: StoredProcedure [dbo].[ccChatOnlineByIsRecentlyContactSelect] Script Date: 2018/12/13 19:06:17 ******/
  12995. SET ANSI_NULLS ON
  12996. GO
  12997. SET QUOTED_IDENTIFIER ON
  12998. GO
  12999. CREATE PROCEDURE [dbo].[ccChatOnlineByIsRecentlyContactSelect]
  13000. (
  13001. @caMainID INT
  13002. )
  13003. AS
  13004. BEGIN TRY
  13005. IF EXISTS(SELECT 'X' FROM ChatOnlineLog WHERE ChatOnlineID IN(
  13006. SELECT ID FROM ChatOnline WHERE caMainID = @caMainID) HAVING MAX(AddDate) > DATEADD(mi, -5, GETDATE()))
  13007. RETURN 1
  13008. IF EXISTS(SELECT 'X' FROM ChatOnlineLog WHERE ChatOnlineID IN(
  13009. SELECT ID FROM ChatOnline WHERE caMainID = @caMainID) AND SenderType=2 AND IsViewed=0)
  13010. RETURN 1
  13011. RETURN 0
  13012. END TRY
  13013. BEGIN CATCH
  13014. RETURN 0
  13015. END CATCH
  13016. GO
  13017. /****** Object: StoredProcedure [dbo].[ccChatOnLineLogByCaMainIDSelect] Script Date: 2018/12/13 19:06:18 ******/
  13018. SET ANSI_NULLS ON
  13019. GO
  13020. SET QUOTED_IDENTIFIER ON
  13021. GO
  13022. CREATE PROCEDURE [dbo].[ccChatOnLineLogByCaMainIDSelect]
  13023. (
  13024. @CaMainID INT --企业用户的ID
  13025. )
  13026. AS
  13027. SET NOCOUNT ON
  13028. BEGIN
  13029. CREATE TABLE #ChatLog(
  13030. CaMainID INT,
  13031. CvMainID INT,
  13032. LastMessage VARCHAR(MAX),
  13033. LastReceiverDate SMALLDATETIME,
  13034. Initiative TINYINT)
  13035. INSERT INTO #ChatLog
  13036. SELECT a.CaMainID, a.CvMainID,
  13037. (SELECT TOP 1 Message FROM ChatOnlineLog WHERE ChatOnlineID = MAX(a.ID) ORDER BY AddDate DESC),
  13038. MAX(b.Adddate),
  13039. (SELECT Initiative FROM ChatOnline WHERE ID = MIN(a.ID))
  13040. FROM ChatOnline a, ChatOnlineLog b
  13041. WHERE a.id = b.ChatOnlineID
  13042. --AND b.IsViewed = 0
  13043. AND a.caMainId = @CaMainID --当前个人用户
  13044. GROUP BY a.CaMainID,a.CvMainID
  13045. SELECT a.*,
  13046. c.Name PaName,
  13047. b.Name CvName,
  13048. b.ID CvID,
  13049. d.Description Education,
  13050. e.FullName LivePlace,
  13051. Initiative,
  13052. b.paMainId,
  13053. b.SecondId
  13054. FROM #ChatLog a, cvMain b, paMain c, dcEducation d, dcRegion e
  13055. WHERE a.cvMainID = b.id
  13056. AND b.paMainID = c.ID
  13057. AND c.livePlace = e.ID
  13058. AND b.Degree=d.ID
  13059. END
  13060. GO
  13061. /****** Object: StoredProcedure [dbo].[ccChatServiceSelect] Script Date: 2018/12/13 19:06:18 ******/
  13062. SET ANSI_NULLS ON
  13063. GO
  13064. SET QUOTED_IDENTIFIER ON
  13065. GO
  13066. CREATE PROCEDURE [dbo].[ccChatServiceSelect]
  13067. AS
  13068. BEGIN
  13069. SELECT TOP 1 *
  13070. FROM ChatService a
  13071. LEFT JOIN ManagerUser b ON a.ManageruserID = b.id
  13072. WHERE a.IsOnline = 1
  13073. AND b.SOLStatus = 1
  13074. ORDER BY a.ChatCount
  13075. END
  13076. GO
  13077. /****** Object: StoredProcedure [dbo].[ccCheckReccomendCvSelect] Script Date: 2018/12/13 19:06:18 ******/
  13078. SET ANSI_NULLS ON
  13079. GO
  13080. SET QUOTED_IDENTIFIER ON
  13081. GO
  13082. --#####################################################
  13083. --创建时间:2014.10.31
  13084. --创建人:Nick
  13085. --说明:
  13086. --修改:harry
  13087. --区分主办方:校园,社会,校园主办方只能看本校的学生
  13088. --2018-3-15
  13089. --harry 18-4-8
  13090. --#####################################################
  13091. CREATE PROCEDURE [dbo].[ccCheckReccomendCvSelect]
  13092. (
  13093. @rmDeptID INT,
  13094. @cvID INT
  13095. )
  13096. AS
  13097. BEGIN
  13098. DECLARE @CNT INT
  13099. SET @CNT = 0
  13100. IF EXISTS(SELECT 'x' FROM marketdb..rmdept where id=@rmDeptID and isSchool =1)
  13101. BEGIN
  13102. --学号必须一致
  13103. SELECT @CNT = COUNT(*) FROM cvMain a WITH(NOLOCK)
  13104. INNER JOIN paMain b WITH(NOLOCK) ON a.paMainID=b.ID
  13105. INNER JOIN marketdb..RmPerson c WITH(NOLOCK) ON c.paMainID=b.Id
  13106. INNER JOIN wutongguodb..RecruitmentSchool d WITH(NOLOCK) ON c.RecruitmentID=d.ID*-1
  13107. LEFT JOIN marketdb..RmStudentIds f ON c.studentId= f.rmStudentId
  13108. WHERE a.ID=@cvID
  13109. AND d.RecruitmentDeptId=@rmDeptID
  13110. AND c.studentId IS NOT NULL
  13111. AND f.rmdeptId= @rmDeptID
  13112. IF @CNT = 0
  13113. BEGIN
  13114. RETURN 0
  13115. END
  13116. ELSE
  13117. BEGIN
  13118. RETURN 1
  13119. END
  13120. END
  13121. ELSE
  13122. BEGIN
  13123. SELECT @CNT = COUNT(*) FROM cvMain a WITH(NOLOCK)
  13124. INNER JOIN paMain d WITH(NOLOCK) ON a.paMainID=d.ID
  13125. INNER JOIN marketdb..ptCvInvitation b WITH(NOLOCK) ON a.paMainID=b.paMainID
  13126. INNER JOIN marketdb..ptWorkAppoint c WITH(NOLOCK) ON b.PtWorkAppointID1=c.ID
  13127. INNER JOIN Recruitment e WITH(NOLOCK) ON c.RecruitmentID=e.ID
  13128. INNER JOIN RecruitmentDept f WITH(NOLOCK) ON e.RecruitmentDeptId=f.ID
  13129. WHERE a.ID=@cvID AND a.Valid=1 AND f.ID=@rmDeptID
  13130. IF @CNT = 0
  13131. BEGIN
  13132. SELECT @CNT = COUNT(*) FROM cvMain a WITH(NOLOCK)
  13133. INNER JOIN paMain d WITH(NOLOCK) ON a.paMainID=d.ID
  13134. INNER JOIN marketdb..RmInvitationCode b WITH(NOLOCK) ON a.paMainID=b.paMainID AND b.Valid=1
  13135. INNER JOIN marketdb..RmProject c WITH(NOLOCK) ON b.RmProjectID=c.ID
  13136. INNER JOIN marketdb..Recruitment e WITH(NOLOCK) ON c.RecruitmentID=e.ID
  13137. INNER JOIN marketdb..RmDept f WITH(NOLOCK) ON e.RecruitmentDeptId=f.ID
  13138. WHERE a.ID=@cvID AND a.Valid=1 AND f.ID=@rmDeptID
  13139. IF @CNT = 0
  13140. BEGIN
  13141. RETURN 0
  13142. END
  13143. ELSE
  13144. BEGIN
  13145. RETURN 1
  13146. END
  13147. END
  13148. ELSE
  13149. BEGIN
  13150. RETURN 1
  13151. END
  13152. END
  13153. END
  13154. GO
  13155. /****** Object: StoredProcedure [dbo].[ccColdCustomerByCpRegisterUpdate] Script Date: 2018/12/13 19:06:18 ******/
  13156. SET ANSI_NULLS ON
  13157. GO
  13158. SET QUOTED_IDENTIFIER ON
  13159. GO
  13160. --alen 2018-4-8
  13161. CREATE PROCEDURE [dbo].[ccColdCustomerByCpRegisterUpdate]
  13162. (
  13163. @cpMainID INT,
  13164. @cpName NVARCHAR(50),
  13165. @provinceID TINYINT
  13166. )
  13167. AS
  13168. BEGIN
  13169. DECLARE @ColdCustomerID AS INT,@IsTure AS BIT
  13170. SET @ColdCustomerID =0
  13171. IF NOT EXISTS(SELECT 'X' FROM cpMain WITH(NOLOCK) WHERE ID<>@cpMainID AND Name =@cpName AND dcProvinceID=@provinceID)
  13172. BEGIN
  13173. SET @IsTure=1
  13174. END
  13175. IF EXISTS(SELECT 'X' FROM cpMain WITH(NOLOCK) WHERE ID<>@cpMainID AND Name =@cpName AND dcProvinceID=@provinceID AND MemberType<2 AND LastLoginDate<DATEADD(month, -1, GETDATE()))
  13176. BEGIN
  13177. SET @IsTure=1
  13178. END
  13179. IF @IsTure =1
  13180. BEGIN
  13181. SELECT @ColdCustomerID = ID
  13182. FROM MainDB..ColdCustomer WITH(NOLOCK)
  13183. WHERE companyName = @cpName
  13184. AND isValid=1
  13185. AND ProvinceID in (
  13186. SELECT ID
  13187. FROM Maindb..dcprovince
  13188. WHERE SouthNorth = (
  13189. SELECT SouthNorth
  13190. FROM Maindb..dcprovince
  13191. WHERE id = @provinceID
  13192. )
  13193. )
  13194. AND AddDate>DATEADD(day, -14, GETDATE())
  13195. IF @ColdCustomerID > 0
  13196. BEGIN
  13197. UPDATE MainDB..ColdCustomer SET CpMainID = @cpMainID,RegisterDate=GETDATE(),Status=2 WHERE ID=@ColdCustomerID
  13198. END
  13199. END
  13200. END
  13201. GO
  13202. /****** Object: StoredProcedure [dbo].[ccColdCustomerByIDSelect] Script Date: 2018/12/13 19:06:18 ******/
  13203. SET ANSI_NULLS ON
  13204. GO
  13205. SET QUOTED_IDENTIFIER ON
  13206. GO
  13207. --#####################################################
  13208. --创建时间:2014.10.30
  13209. --创建人:Nick
  13210. --说明:判断是否是冷客户
  13211. --#####################################################
  13212. CREATE PROCEDURE [dbo].[ccColdCustomerByIDSelect]
  13213. (
  13214. @CpmainID INT
  13215. )
  13216. AS
  13217. BEGIN TRY
  13218. SELECT TOP 1 * FROM maindb..ColdCustomer WHERE CpmainID = @CpmainID
  13219. END TRY
  13220. BEGIN CATCH
  13221. RETURN 0
  13222. END CATCH
  13223. GO
  13224. /****** Object: StoredProcedure [dbo].[ccCompany_xinxiPasswordByEmailUpdate] Script Date: 2018/12/13 19:06:18 ******/
  13225. SET ANSI_NULLS ON
  13226. GO
  13227. SET QUOTED_IDENTIFIER ON
  13228. GO
  13229. --#####################################################
  13230. --创建时间:2014.10.30
  13231. --创建人:Nick
  13232. --说明:重置Company_xinxi里的密碼
  13233. --#####################################################
  13234. CREATE PROCEDURE [dbo].[ccCompany_xinxiPasswordByEmailUpdate]
  13235. (
  13236. @Password VARCHAR(50),
  13237. @UserName VARCHAR(50),
  13238. @Email VARCHAR(50)
  13239. )
  13240. AS
  13241. BEGIN TRY
  13242. UPDATE Company_xinxi SET password=@Password WHERE username=@UserName AND email=@Email
  13243. RETURN 1
  13244. END TRY
  13245. BEGIN CATCH
  13246. RETURN 0
  13247. END CATCH
  13248. GO
  13249. /****** Object: StoredProcedure [dbo].[ccCompanyInformSelect] Script Date: 2018/12/13 19:06:18 ******/
  13250. SET ANSI_NULLS ON
  13251. GO
  13252. SET QUOTED_IDENTIFIER ON
  13253. GO
  13254. CREATE PROCEDURE [dbo].[ccCompanyInformSelect]
  13255. (
  13256. @Object VARCHAR(50),
  13257. @Province_ID VARCHAR(2)
  13258. )
  13259. AS
  13260. BEGIN
  13261. SELECT ID,TITLE,Type,Link,Content,At1
  13262. FROM CompanyInform WITH(NOLOCK)
  13263. WHERE Status=1
  13264. AND Object LIKE '%'+@Object+'%'
  13265. AND Province LIKE '%'+@Province_ID+'%'
  13266. AND EndDate > GETDATE()
  13267. ORDER BY AddDate DESC
  13268. END
  13269. GO
  13270. /****** Object: StoredProcedure [dbo].[ccCompanyLuckDrawByCpMainIDSelect] Script Date: 2018/12/13 19:06:19 ******/
  13271. SET ANSI_NULLS ON
  13272. GO
  13273. SET QUOTED_IDENTIFIER ON
  13274. GO
  13275. --#####################################################
  13276. --创建时间:2016.01.19
  13277. --创建人:NICK
  13278. --说明:获取企业抽奖记录
  13279. --#####################################################
  13280. CREATE PROCEDURE [dbo].[ccCompanyLuckDrawByCpMainIDSelect]
  13281. (
  13282. @CpMainID INT
  13283. )
  13284. AS
  13285. BEGIN
  13286. SELECT TOP 100 *
  13287. FROM CompanyLuckDraw WITH(NOLOCK)
  13288. WHERE CpMainID = @CpMainID
  13289. ORDER BY LotteryDate DESC
  13290. END
  13291. GO
  13292. /****** Object: StoredProcedure [dbo].[ccCompanyNotifyByCompanyIDSelect] Script Date: 2018/12/13 19:06:19 ******/
  13293. SET ANSI_NULLS ON
  13294. GO
  13295. SET QUOTED_IDENTIFIER ON
  13296. GO
  13297. CREATE PROCEDURE [dbo].[ccCompanyNotifyByCompanyIDSelect]
  13298. (
  13299. @CompanyID INT
  13300. )
  13301. AS
  13302. BEGIN
  13303. SET NOCOUNT ON
  13304. SELECT *
  13305. FROM CompanyNotify WITH(NOLOCK)
  13306. WHERE CompanyID=@CompanyID
  13307. AND ((Type=1 AND Received=0) Or (Type=2 AND EndDate>GETDATE()))
  13308. ORDER BY AddDate DESC
  13309. END
  13310. GO
  13311. /****** Object: StoredProcedure [dbo].[ccCompanyNotifyByReceivedUpdate] Script Date: 2018/12/13 19:06:20 ******/
  13312. SET ANSI_NULLS ON
  13313. GO
  13314. SET QUOTED_IDENTIFIER ON
  13315. GO
  13316. CREATE PROCEDURE [dbo].[ccCompanyNotifyByReceivedUpdate]
  13317. (
  13318. @ID INT,
  13319. @CompanyID INT
  13320. )
  13321. AS
  13322. BEGIN
  13323. SET NOCOUNT ON
  13324. UPDATE CompanyNotify SET Received = 1 WHERE ID = @ID AND CompanyID = @CompanyID AND Received = 0
  13325. END
  13326. GO
  13327. /****** Object: StoredProcedure [dbo].[ccCpCertificationDelete] Script Date: 2018/12/13 19:06:20 ******/
  13328. SET ANSI_NULLS ON
  13329. GO
  13330. SET QUOTED_IDENTIFIER ON
  13331. GO
  13332. CREATE PROCEDURE [dbo].[ccCpCertificationDelete]
  13333. (
  13334. @cpMainID INT
  13335. )
  13336. AS
  13337. SET NOCOUNT ON
  13338. BEGIN
  13339. DECLARE @cpCertificationID INT, @MemberType TINYINT, @CerType TINYINT
  13340. SELECT @cpCertificationID = ID, @MemberType = MemberType, @CerType = CerType FROM cpCertification WITH(NOLOCK) WHERE cpMainID = @cpMainID AND CerStatus IS NULL
  13341. IF @cpCertificationID IS NULL
  13342. RETURN 0
  13343. DELETE FROM cpCertification WHERE ID = @cpCertificationID
  13344. DELETE FROM cpLicence WHERE cpCertificationID = @cpCertificationID
  13345. DECLARE @Desc NVARCHAR(50)
  13346. IF @MemberType = 1 AND @CerType = 1
  13347. BEGIN
  13348. INSERT INTO LogDB..UserActionDetail(ActionType, ActionID, dcProvinceID)
  13349. SELECT TOP 1 206, @CpMainID, dcProvinceID FROM cpMain WITH(NOLOCK) WHERE ID = @CpMainID
  13350. SET @Desc = '实名认证(对公)'
  13351. END
  13352. ELSE IF @MemberType = 1 AND @CerType = 2
  13353. BEGIN
  13354. INSERT INTO LogDB..UserActionDetail(ActionType, ActionID, dcProvinceID)
  13355. SELECT TOP 1 207, @CpMainID, dcProvinceID FROM cpMain WITH(NOLOCK) WHERE ID = @CpMainID
  13356. SET @Desc = '实名认证(法人)'
  13357. END
  13358. ELSE IF @MemberType = 2 AND @CerType = 2
  13359. BEGIN
  13360. INSERT INTO LogDB..UserActionDetail(ActionType, ActionID, dcProvinceID)
  13361. SELECT TOP 1 204, @CpMainID, dcProvinceID FROM cpMain WITH(NOLOCK) WHERE ID = @CpMainID
  13362. SET @Desc = '普通认证(营业执照+个人)'
  13363. END
  13364. ELSE IF @MemberType = 2 AND @CerType = 3
  13365. BEGIN
  13366. INSERT INTO LogDB..UserActionDetail(ActionType, ActionID, dcProvinceID)
  13367. SELECT TOP 1 205, @CpMainID, dcProvinceID FROM cpMain WITH(NOLOCK) WHERE ID = @CpMainID
  13368. SET @Desc = '普通认证(邮箱)'
  13369. END
  13370. INSERT INTO RtxNotifyLog(Receiver, RtxTitle, RtxMessage, SendType, DelayTime, ShowType)
  13371. SELECT ConsultantId, '企业认证取消通知', Name + '(' + LTRIM(STR(ID)) + ')取消了企业认证[' + @Desc + ']。http://sysback.51rc.com/newoa/company/cp/cpMainInfo?id=' + LTRIM(STR(ID)) + '&code=' + LTRIM(STR(DATEPART(HOUR, RegDate) * 100 + DATEPART(MINUTE, RegDate))), 0, 0, 1
  13372. FROM cpMain WHERE ConsultantId > 0 AND ID = @CpMainID
  13373. RETURN 1
  13374. END
  13375. SET NOCOUNT OFF
  13376. GO
  13377. /****** Object: StoredProcedure [dbo].[cccpCertificationInsert] Script Date: 2018/12/13 19:06:20 ******/
  13378. SET ANSI_NULLS ON
  13379. GO
  13380. SET QUOTED_IDENTIFIER ON
  13381. GO
  13382. CREATE PROCEDURE [dbo].[cccpCertificationInsert]
  13383. (
  13384. @cpMainID INT,
  13385. @CerType TINYINT,
  13386. @CompanyName VARCHAR(100),
  13387. @Mobile VARCHAR(11)
  13388. )
  13389. AS
  13390. SET NOCOUNT ON
  13391. BEGIN
  13392. DELETE FROM cpCertification WHERE cpMainID = @cpMainID AND CerStatus IS NULL
  13393. IF @CerType = 0
  13394. SET @CerType = NULL
  13395. IF CHARINDEX('公司', @CompanyName) > 0
  13396. SET @CerType = 1
  13397. INSERT INTO cpCertification(cpMainID, CompanyName, Mobile, MemberType, CerType)
  13398. VALUES(@cpMainID, @CompanyName, @Mobile, 1, @CerType)
  13399. END
  13400. SET NOCOUNT OFF
  13401. GO
  13402. /****** Object: StoredProcedure [dbo].[cccpCertificationUpdate] Script Date: 2018/12/13 19:06:20 ******/
  13403. SET ANSI_NULLS ON
  13404. GO
  13405. SET QUOTED_IDENTIFIER ON
  13406. GO
  13407. CREATE PROCEDURE [dbo].[cccpCertificationUpdate]
  13408. (
  13409. @cpMainID INT,
  13410. @cpCertificationID INT,
  13411. @CerType TINYINT
  13412. )
  13413. AS
  13414. SET NOCOUNT ON
  13415. BEGIN
  13416. IF NOT EXISTS(SELECT 'X' FROM cpCertification WITH(NOLOCK) WHERE ID = @cpCertificationID AND cpMainID = @cpMainID AND CerStatus IS NULL)
  13417. RETURN 0
  13418. UPDATE cpCertification SET CerType = @CerType WHERE ID = @cpCertificationID
  13419. RETURN 1
  13420. END
  13421. SET NOCOUNT OFF
  13422. GO
  13423. /****** Object: StoredProcedure [dbo].[ccCpCoinByCpMainIDSelect] Script Date: 2018/12/13 19:06:20 ******/
  13424. SET ANSI_NULLS ON
  13425. GO
  13426. SET QUOTED_IDENTIFIER ON
  13427. GO
  13428. -- =============================================
  13429. -- Author: mice
  13430. -- Create date: 2014-8-12
  13431. -- Description: 返回企业的金币详情
  13432. -- Modify: Lucifer 2016-9-29 抽奖赠送orderid=0
  13433. -- =============================================
  13434. CREATE PROCEDURE [dbo].[ccCpCoinByCpMainIDSelect]
  13435. (
  13436. @cpMainID INT
  13437. )
  13438. AS
  13439. BEGIN
  13440. SELECT TOP 200 a.*, b.OrderType , b.ServiceType
  13441. FROM MainDb..cpCoin a LEFT JOIN caOrder b ON a.caOrderID = b.id
  13442. WHERE a.cpMainID = @cpMainID
  13443. ORDER BY a.AddDate DESC
  13444. END
  13445. GO
  13446. /****** Object: StoredProcedure [dbo].[ccCpCompanyEmailInsert] Script Date: 2018/12/13 19:06:20 ******/
  13447. SET ANSI_NULLS ON
  13448. GO
  13449. SET QUOTED_IDENTIFIER ON
  13450. GO
  13451. CREATE PROCEDURE [dbo].[ccCpCompanyEmailInsert]
  13452. (
  13453. @CompanyName VARCHAR(100),
  13454. @Mobile VARCHAR(11),
  13455. @Email VARCHAR(50),
  13456. @cpMainID INT
  13457. )
  13458. AS
  13459. SET NOCOUNT ON
  13460. BEGIN
  13461. DELETE FROM cpCertification WHERE cpMainID = @cpMainID AND CerStatus IS NULL
  13462. DECLARE @cpCertificationID INT
  13463. INSERT INTO cpCertification(cpMainID, CompanyName, Mobile, MemberType, CerType)
  13464. VALUES(@cpMainID, @CompanyName, @Mobile, 2, 3)
  13465. SET @cpCertificationID = @@IDENTITY
  13466. DECLARE @VerifyCode AS VARCHAR(6)
  13467. SELECT @VerifyCode = RAND() * 899999 + 100000
  13468. INSERT INTO cpCompanyEmail(cpCertificationID, Email, VerifyCode)
  13469. VALUES(@cpCertificationID, @Email, @VerifyCode)
  13470. RETURN 1
  13471. END
  13472. SET NOCOUNT OFF
  13473. GO
  13474. /****** Object: StoredProcedure [dbo].[ccCpCompanyEmailUpdate] Script Date: 2018/12/13 19:06:20 ******/
  13475. SET ANSI_NULLS ON
  13476. GO
  13477. SET QUOTED_IDENTIFIER ON
  13478. GO
  13479. CREATE PROCEDURE [dbo].[ccCpCompanyEmailUpdate]
  13480. (
  13481. @VerifyCode VARCHAR(6),
  13482. @cpCertificationID INT,
  13483. @cpMainID INT
  13484. )
  13485. AS
  13486. SET NOCOUNT ON
  13487. BEGIN
  13488. IF NOT EXISTS(SELECT 'X' FROM cpCertification WITH(NOLOCK) WHERE ID = @cpCertificationID AND cpMainID = @cpMainID AND CerStatus IS NULL)
  13489. RETURN -1
  13490. IF EXISTS(SELECT 'X' FROM cpCompanyEmail WITH(NOLOCK) WHERE cpCertificationID = @cpCertificationID AND CheckResult IS NOT NULL)
  13491. RETURN -1
  13492. IF EXISTS(SELECT 'X' FROM cpCompanyEmail WITH(NOLOCK) WHERE cpCertificationID = @cpCertificationID AND VerifyCode = @VerifyCode)
  13493. BEGIN
  13494. UPDATE cpCompanyEmail SET CheckResult = 2 WHERE cpCertificationID = @cpCertificationID
  13495. RETURN 1
  13496. END
  13497. ELSE
  13498. RETURN 0
  13499. END
  13500. SET NOCOUNT OFF
  13501. GO
  13502. /****** Object: StoredProcedure [dbo].[cccpCvShieldByCpMainIDSelect] Script Date: 2018/12/13 19:06:21 ******/
  13503. SET ANSI_NULLS ON
  13504. GO
  13505. SET QUOTED_IDENTIFIER ON
  13506. GO
  13507. --#####################################################
  13508. --创建时间:2014.10.31
  13509. --创建人:Nick
  13510. --说明:根据企业编号,获取屏蔽的简历 编号
  13511. --#####################################################
  13512. CREATE PROCEDURE [dbo].[cccpCvShieldByCpMainIDSelect]
  13513. (
  13514. @CpMainID INT
  13515. )
  13516. AS
  13517. BEGIN TRY
  13518. SELECT * FROM cpCvShield WITH(NOLOCK) WHERE cpMainID = @CpMainID
  13519. END TRY
  13520. BEGIN CATCH
  13521. RETURN 0
  13522. END CATCH
  13523. GO
  13524. /****** Object: StoredProcedure [dbo].[cccpCvShieldByCvMainIDSelect] Script Date: 2018/12/13 19:06:21 ******/
  13525. SET ANSI_NULLS ON
  13526. GO
  13527. SET QUOTED_IDENTIFIER ON
  13528. GO
  13529. --#####################################################
  13530. --创建时间:2014.10.31
  13531. --创建人:Nick
  13532. --说明:根据企业编号、简历编号 获取 屏蔽的简历
  13533. --#####################################################
  13534. CREATE PROCEDURE [dbo].[cccpCvShieldByCvMainIDSelect]
  13535. (
  13536. @CpMainID INT,
  13537. @CvMainID INT
  13538. )
  13539. AS
  13540. BEGIN TRY
  13541. SELECT * FROM cpCvShield WITH(NOLOCK) WHERE cpMainID = @CpMainID AND CvMainID = @CvMainID
  13542. END TRY
  13543. BEGIN CATCH
  13544. RETURN 0
  13545. END CATCH
  13546. GO
  13547. /****** Object: StoredProcedure [dbo].[cccpCvShieldDelete] Script Date: 2018/12/13 19:06:21 ******/
  13548. SET ANSI_NULLS ON
  13549. GO
  13550. SET QUOTED_IDENTIFIER ON
  13551. GO
  13552. --#####################################################
  13553. --创建时间:2014.10.31
  13554. --创建人:Nick
  13555. --说明:将简历编号 从 cpCvShield表中删除
  13556. --#####################################################
  13557. CREATE PROCEDURE [dbo].[cccpCvShieldDelete]
  13558. (
  13559. @cpMainID INT,
  13560. @cvMainID INT
  13561. )
  13562. AS
  13563. BEGIN TRY
  13564. DELETE FROM cpCvShield Where CpMainID=@cpMainID AND CvMainID=@cvMainID
  13565. RETURN 1
  13566. END TRY
  13567. BEGIN CATCH
  13568. RETURN 0
  13569. END CATCH
  13570. GO
  13571. /****** Object: StoredProcedure [dbo].[cccpCvShieldInsert] Script Date: 2018/12/13 19:06:22 ******/
  13572. SET ANSI_NULLS ON
  13573. GO
  13574. SET QUOTED_IDENTIFIER ON
  13575. GO
  13576. --#####################################################
  13577. --创建时间:2014.10.31
  13578. --创建人:Nick
  13579. --说明:将建立编号 加入cpCvShield 表
  13580. --#####################################################
  13581. CREATE PROCEDURE [dbo].[cccpCvShieldInsert]
  13582. (
  13583. @cpMainID INT,
  13584. @cvMainID INT
  13585. )
  13586. AS
  13587. BEGIN TRY
  13588. INSERT INTO cpCvShield(cpMainID,cvMainID) VALUES(@cpMainID,@cvMainID)
  13589. RETURN 1
  13590. END TRY
  13591. BEGIN CATCH
  13592. RETURN 0
  13593. END CATCH
  13594. GO
  13595. /****** Object: StoredProcedure [dbo].[cccpImage_beforeInsert] Script Date: 2018/12/13 19:06:22 ******/
  13596. SET ANSI_NULLS ON
  13597. GO
  13598. SET QUOTED_IDENTIFIER ON
  13599. GO
  13600. -- 将上传logo的信息先放在cpimage_before中
  13601. -- harry
  13602. --2016-10-19
  13603. CREATE PROCEDURE [dbo].[cccpImage_beforeInsert]
  13604. @cpMainID INT,
  13605. @Photo VARCHAR(50)
  13606. AS
  13607. SET NOCOUNT ON
  13608. BEGIN
  13609. DECLARE @MaxId AS INT
  13610. INSERT INTO cpimage_before (cpMainID,FileUrl,addDate)
  13611. VALUES(@cpMainID,dbo.SafeSQL(@Photo),getdate())
  13612. SET @MaxID = @@IDENTITY
  13613. RETURN @MaxID
  13614. END
  13615. SET NOCOUNT OFF
  13616. GO
  13617. /****** Object: StoredProcedure [dbo].[ccCpImageByDescriptionUpdate] Script Date: 2018/12/13 19:06:22 ******/
  13618. SET ANSI_NULLS ON
  13619. GO
  13620. SET QUOTED_IDENTIFIER ON
  13621. GO
  13622. -- =============================================
  13623. -- Author:
  13624. -- Create date: <2015-1-20>
  13625. -- Description: <修改图片备注>
  13626. -- =============================================
  13627. CREATE PROCEDURE [dbo].[ccCpImageByDescriptionUpdate]
  13628. (
  13629. @ID VARCHAR(20),
  13630. @description NVARCHAR(50)
  13631. )
  13632. AS
  13633. BEGIN
  13634. UPDATE maindb..cpImage
  13635. SET Description = @description,
  13636. HasPassed = NULL,
  13637. CheckMan = NULL,
  13638. CheckDate = NULL,
  13639. CheckMessage = NULL,
  13640. AddDate=GETDATE()
  13641. WHERE id= @ID
  13642. END
  13643. GO
  13644. /****** Object: StoredProcedure [dbo].[ccCpImageByHasPassedUpdate] Script Date: 2018/12/13 19:06:22 ******/
  13645. SET ANSI_NULLS ON
  13646. GO
  13647. SET QUOTED_IDENTIFIER ON
  13648. GO
  13649. --###########################
  13650. --创建时间:2014.11.27
  13651. --创建人:Nick
  13652. --说明:后台形象图上传
  13653. --###########################
  13654. CREATE PROCEDURE [dbo].[ccCpImageByHasPassedUpdate]
  13655. @ID INT,
  13656. @HasPassed INT
  13657. AS
  13658. BEGIN
  13659. UPDATE cpImage SET HasPassed=@HasPassed WHERE ID=@ID
  13660. END
  13661. GO
  13662. /****** Object: StoredProcedure [dbo].[ccCpImageByIDDelete] Script Date: 2018/12/13 19:06:22 ******/
  13663. SET ANSI_NULLS ON
  13664. GO
  13665. SET QUOTED_IDENTIFIER ON
  13666. GO
  13667. -----------------------------
  13668. --Peter 2014-08-26修改
  13669. --添加积分扣减
  13670. --Peter 2014-9-1 修改
  13671. --判断企业之前没有上传过
  13672. -- [ccCpImageByIDDelete] 112,371108,1, 1
  13673. -------------------------
  13674. CREATE PROCEDURE [dbo].[ccCpImageByIDDelete]
  13675. (
  13676. @OperatorID INT,
  13677. @cpMainID INT,
  13678. @ImgType TINYINT,
  13679. @ID INT
  13680. )
  13681. AS
  13682. SET NOCOUNT ON
  13683. BEGIN
  13684. DECLARE @caMainId INT
  13685. --LOGO图
  13686. IF @ImgType = 1
  13687. BEGIN
  13688. DELETE FROM cpImage WHERE cpMainID=@cpMainID AND ImgType=@ImgType
  13689. IF EXISTS (SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND HasLogo = 1)
  13690. BEGIN
  13691. DECLARE @Point INT
  13692. SELECT TOP 1 @Point = Point * -1 FROM cpPoint WHERE cpMainId = @cpMainId AND ChangeId IN(7, 8) ORDER BY ID DESC
  13693. IF @Point < 0
  13694. INSERT INTO cpPoint(cpMainID, ChangeID, Point, LastModifyDate) VALUES(@cpMainID, 8, @Point, GETDATE())
  13695. ELSE
  13696. INSERT INTO cpPoint(cpMainID, ChangeID, Point, LastModifyDate) VALUES(@cpMainID, 8, -10, GETDATE())
  13697. END
  13698. UPDATE cpMain SET HasLogo=0 WHERE ID=@cpMainID
  13699. SELECT TOP 1 @caMainId = Id FROM caMAin WHERE cpMainId = @cpMainId ORDER BY ID
  13700. EXEC ccCaOperationLogInsert @caMainId, 21, '删除企业LOGO图'
  13701. END
  13702. --形象图
  13703. IF @ImgType = 2
  13704. BEGIN
  13705. DELETE FROM cpImage WHERE cpMainID=@cpMainID AND ImgType=@ImgType AND ID=@ID
  13706. IF NOT EXISTS(SELECT 'X' FROM cpImage WITH(NOLOCK) WHERE cpMainID=@cpMainID AND ImgType=2 AND HasPassed=1)
  13707. BEGIN
  13708. IF EXISTS (SELECT 'x' FROM cpMain WHERE ID = @cpMainID AND HasVisual = 1)
  13709. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,10,-10,GETDATE())
  13710. UPDATE cpMain SET HasVisual=0 WHERE ID=@cpMainID
  13711. END
  13712. SELECT TOP 1 @caMainId = Id FROM caMAin WHERE cpMainId = @cpMainId ORDER BY ID
  13713. EXEC ccCaOperationLogInsert @caMainId, 23, '删除企业形象图'
  13714. END
  13715. --环境图
  13716. IF @ImgType = 3
  13717. BEGIN
  13718. IF EXISTS(SELECT 'X' FROM cpImage WITH(NOLOCK) WHERE cpMainID=@cpMainID AND ImgType=@ImgType AND ID=@ID AND HasPassed=1)
  13719. BEGIN
  13720. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,25,-10,GETDATE())
  13721. END
  13722. DELETE FROM cpImage WHERE cpMainID=@cpMainID AND ImgType=@ImgType AND ID=@ID
  13723. SELECT TOP 1 @caMainId = Id FROM caMain WHERE cpMainId = @cpMainId ORDER BY ID
  13724. EXEC ccCaOperationLogInsert @caMainId, 46, '删除企业环境图'
  13725. END
  13726. END
  13727. GO
  13728. /****** Object: StoredProcedure [dbo].[ccCpImageByIDSelect] Script Date: 2018/12/13 19:06:22 ******/
  13729. SET ANSI_NULLS ON
  13730. GO
  13731. SET QUOTED_IDENTIFIER ON
  13732. GO
  13733. --###########################
  13734. --创建时间:2014.11.27
  13735. --创建人:Nick
  13736. --说明:获取后台审核形象图
  13737. --###########################
  13738. CREATE PROCEDURE [dbo].[ccCpImageByIDSelect]
  13739. @cpMainID INT,
  13740. @ID INT
  13741. AS
  13742. BEGIN
  13743. SELECT * FROM cpImage WITH(NOLOCK)
  13744. WHERE ID = @ID AND CpMainID = @cpMainID
  13745. END
  13746. GO
  13747. /****** Object: StoredProcedure [dbo].[ccCpImageByVideoInsert] Script Date: 2018/12/13 19:06:23 ******/
  13748. SET ANSI_NULLS ON
  13749. GO
  13750. SET QUOTED_IDENTIFIER ON
  13751. GO
  13752. CREATE PROCEDURE [dbo].[ccCpImageByVideoInsert]
  13753. (
  13754. @OperatorID INT,
  13755. @cpMainID INT,
  13756. @ImgType TINYINT,
  13757. @ImgFile VARCHAR(500),
  13758. @videoId varchar(100),
  13759. @description nvarchar(200)
  13760. )
  13761. AS
  13762. SET NOCOUNT ON
  13763. BEGIN
  13764. INSERT INTO cpImage (cpMainID,ImgType,ImgFile,videoId,Description)
  13765. VALUES(@cpMainID,@ImgType,@ImgFile,@videoId,@description)
  13766. EXEC ccCaOperationLogInsert @OperatorID, 43, '上传企业宣传视频'
  13767. RETURN 1
  13768. END
  13769. SET NOCOUNT OFF
  13770. GO
  13771. /****** Object: StoredProcedure [dbo].[ccCpImageClickNumberUpdate] Script Date: 2018/12/13 19:06:23 ******/
  13772. SET ANSI_NULLS ON
  13773. GO
  13774. SET QUOTED_IDENTIFIER ON
  13775. GO
  13776. -- =============================================
  13777. -- Description: <企业环境照片点击有用数量更新>;
  13778. -- Creater : mice 2015-1-7
  13779. -- =============================================
  13780. CREATE PROCEDURE [dbo].[ccCpImageClickNumberUpdate]
  13781. (
  13782. @ID INT
  13783. )
  13784. AS
  13785. BEGIN
  13786. UPDATE Maindb..cpImage
  13787. SET ClickNumber = ISNULL(ClickNumber, 0) + 1
  13788. WHERE ID = @ID
  13789. END
  13790. GO
  13791. /****** Object: StoredProcedure [dbo].[ccCpImageDelete] Script Date: 2018/12/13 19:06:23 ******/
  13792. SET ANSI_NULLS ON
  13793. GO
  13794. SET QUOTED_IDENTIFIER ON
  13795. GO
  13796. CREATE PROCEDURE [dbo].[ccCpImageDelete]
  13797. @OperatorID INT,
  13798. @cpMainID INT,
  13799. @ImgType TINYINT
  13800. AS
  13801. BEGIN TRAN
  13802. BEGIN TRY
  13803. DELETE FROM cpImage WHERE cpMainID=@cpMainID AND ImgType=@ImgType
  13804. --LOGO图
  13805. IF @ImgType = 1
  13806. BEGIN
  13807. UPDATE cpMain SET HasLOGO=0 WHERE ID=@cpMainID
  13808. EXEC ccCaOperationLogInsert @OperatorID, 21, '删除企业LOGO图'
  13809. END
  13810. --形象图
  13811. IF @ImgType = 2
  13812. BEGIN
  13813. UPDATE cpMain SET HasVisual=0 WHERE ID=@cpMainID
  13814. EXEC ccCaOperationLogInsert @OperatorID, 23, '删除企业形象图'
  13815. END
  13816. END TRY
  13817. BEGIN CATCH
  13818. GOTO ERR
  13819. END CATCH
  13820. COMMIT TRAN
  13821. RETURN 1
  13822. ERR:
  13823. BEGIN
  13824. ROLLBACK TRAN
  13825. RETURN 0
  13826. END
  13827. GO
  13828. /****** Object: StoredProcedure [dbo].[ccCpImageInsert] Script Date: 2018/12/13 19:06:23 ******/
  13829. SET ANSI_NULLS ON
  13830. GO
  13831. SET QUOTED_IDENTIFIER ON
  13832. GO
  13833. CREATE PROCEDURE [dbo].[ccCpImageInsert]
  13834. (
  13835. @OperatorID INT,
  13836. @cpMainID INT,
  13837. @ImgType TINYINT,
  13838. @ImgFile VARCHAR(50)
  13839. )
  13840. AS
  13841. SET NOCOUNT ON
  13842. BEGIN
  13843. DECLARE @MaxId AS INT, @Desc AS VARCHAR(200)
  13844. DELETE FROM cpImage WHERE cpMainID=@cpMainID AND ImgType=@ImgType
  13845. INSERT INTO cpImage (cpMainID,ImgType,ImgFile)
  13846. VALUES(@cpMainID,@ImgType,@ImgFile)
  13847. SET @MaxID = @@IDENTITY
  13848. --LOGO图
  13849. IF @ImgType = 1
  13850. BEGIN
  13851. SET @Desc = '上传LOGO图,文件名:' + @ImgFile
  13852. UPDATE cpMain SET HasLOGO=0 WHERE ID=@cpMainID
  13853. IF @OperatorID > 0
  13854. EXEC ccCaOperationLogInsert @OperatorID, 20, @Desc
  13855. INSERT INTO bsCpStatus(cpMainID, StatusID) VALUES(@cpMainID, 2)
  13856. END
  13857. --形象图
  13858. IF @ImgType = 2
  13859. BEGIN
  13860. SET @Desc = '上传形象图,文件名:' + @ImgFile
  13861. UPDATE cpMain SET HasVisual=0 WHERE ID=@cpMainID
  13862. IF @OperatorID > 0
  13863. EXEC ccCaOperationLogInsert @OperatorID, 22, @Desc
  13864. INSERT INTO bsCpStatus(cpMainID,StatusID) VALUES(@cpMainID,3)
  13865. END
  13866. RETURN @MaxID
  13867. END
  13868. GO
  13869. /****** Object: StoredProcedure [dbo].[ccCpImageInsertByOperatorID] Script Date: 2018/12/13 19:06:23 ******/
  13870. SET ANSI_NULLS ON
  13871. GO
  13872. SET QUOTED_IDENTIFIER ON
  13873. GO
  13874. --=============================================
  13875. -- 创建: Harry
  13876. -- 检查: 2016-10-19
  13877. -- 说明: 企业logo上传
  13878. --=============================================
  13879. CREATE PROCEDURE [dbo].[ccCpImageInsertByOperatorID]
  13880. @OperatorID INT,
  13881. @cpMainID INT
  13882. AS
  13883. BEGIN TRAN
  13884. DECLARE @MaxId AS INT, @Desc AS VARCHAR(200),@ImgFile VARCHAR(50)
  13885. BEGIN TRY
  13886. DELETE FROM cpImage WHERE cpMainID=@cpMainID AND ImgType=1
  13887. SELECT TOP 1 @ImgFile=FileUrl FROM cpImage_before WHERE cpMainID = @cpMainID ORDER BY ID DESC
  13888. INSERT INTO cpImage (cpMainID,ImgType,ImgFile)
  13889. SELECT @cpMainID, 1, @ImgFile
  13890. SET @MaxID = @@IDENTITY
  13891. SET @Desc = '上传LOGO图,文件名:' + @ImgFile
  13892. UPDATE cpMain SET HasLOGO=0 WHERE ID=@cpMainID
  13893. IF @OperatorID > 0
  13894. EXEC ccCaOperationLogInsert @OperatorID, 20, @Desc
  13895. INSERT INTO bsCpStatus(cpMainID, StatusID) VALUES(@cpMainID, 2)
  13896. END TRY
  13897. BEGIN CATCH
  13898. GOTO ERR
  13899. END CATCH
  13900. COMMIT TRAN
  13901. RETURN @MaxID
  13902. ERR:
  13903. BEGIN
  13904. ROLLBACK TRAN
  13905. RETURN 0
  13906. END
  13907. GO
  13908. /****** Object: StoredProcedure [dbo].[ccCpImageOrderNoUpdate] Script Date: 2018/12/13 19:06:23 ******/
  13909. SET ANSI_NULLS ON
  13910. GO
  13911. SET QUOTED_IDENTIFIER ON
  13912. GO
  13913. -- =============================================
  13914. -- Author: <Mice, 123 >
  13915. -- Create date: <2015-01-08>
  13916. -- Description: <企业环境照片排序>
  13917. -- =============================================
  13918. CREATE PROCEDURE [dbo].[ccCpImageOrderNoUpdate]
  13919. (
  13920. @ImgID VARCHAR(200),
  13921. @ImgOrderNo VARCHAR(50)
  13922. )
  13923. AS
  13924. BEGIN
  13925. DECLARE @t1 AS TABLE(ID INT IDENTITY(1, 1), ImgId INT, OrderNo INT)
  13926. DECLARE @t2 AS TABLE (ID INT IDENTITY(1, 1), OrderNo INT)
  13927. INSERT INTO @t1(ImgId) SELECT a FROM dbo.fnsplit(@ImgID,',')
  13928. INSERT INTO @t2(OrderNo) SELECT a FROM dbo.fnsplit(@ImgOrderNo,',')
  13929. UPDATE a SET a.OrderNo = b.OrderNo
  13930. FROM @t1 a, @t2 b
  13931. WHERE a.Id = b.ID
  13932. UPDATE a SET a.OrderNo = b.OrderNo
  13933. FROM Maindb..cpImage a, @t1 b
  13934. WHERE a.Id = b.ImgId
  13935. END
  13936. GO
  13937. /****** Object: StoredProcedure [dbo].[ccCpImageSelect] Script Date: 2018/12/13 19:06:24 ******/
  13938. SET ANSI_NULLS ON
  13939. GO
  13940. SET QUOTED_IDENTIFIER ON
  13941. GO
  13942. CREATE PROCEDURE [dbo].[ccCpImageSelect]
  13943. (
  13944. @cpMainID INT,
  13945. @ImgType INT
  13946. )
  13947. AS
  13948. BEGIN
  13949. IF @ImgType = 4
  13950. SELECT *
  13951. FROM cpImage WITH(NOLOCK)
  13952. WHERE cpMainID = @cpMainID AND ImgType IN(4, 5,6)
  13953. ELSE
  13954. SELECT *
  13955. FROM cpImage WITH(NOLOCK)
  13956. WHERE cpMainID = @cpMainID AND ImgType = @ImgType
  13957. END
  13958. GO
  13959. /****** Object: StoredProcedure [dbo].[ccCpIndexLinkByCaMainIDSelect] Script Date: 2018/12/13 19:06:24 ******/
  13960. SET ANSI_NULLS ON
  13961. GO
  13962. SET QUOTED_IDENTIFIER ON
  13963. GO
  13964. CREATE PROCEDURE [dbo].[ccCpIndexLinkByCaMainIDSelect]
  13965. (
  13966. @caMainID INT,
  13967. @IsManager INT,
  13968. @cpMainID INT
  13969. )
  13970. AS
  13971. BEGIN
  13972. DECLARE @JobCount AS INT --已发布职位数量
  13973. DECLARE @DownLoadCount AS INT --下载简历数量
  13974. DECLARE @FavorateCount AS INT --收藏简历数量
  13975. DECLARE @OneWeekApplyCount AS INT --一周内应聘简历数量
  13976. DECLARE @NoRepliedJobApply AS INT --未答复的应聘简历
  13977. DECLARE @NoViewedMessage AS INT --未查看的留言
  13978. --已发布职位数量
  13979. SELECT @JobCount = COUNT(*)
  13980. FROM Job a WITH(NOLOCK), caMain b WITH(NOLOCK)
  13981. WHERE a.cpMainId = b.cpMainId
  13982. AND b.ID = @caMainID
  13983. AND a.IsDelete=0
  13984. AND a.IssueDate IS NOT NULL
  13985. AND a.IssueEnd > GETDATE()
  13986. --下载简历数量
  13987. SELECT @DownLoadCount = SUM(a.cnt) FROM(
  13988. SELECT COUNT(*) cnt
  13989. FROM caDailyGiftLog a WITH(NOLOCK)
  13990. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  13991. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  13992. WHERE caMainID = @caMainID
  13993. AND a.AddDate > DATEADD(YEAR, -2, GETDATE())
  13994. UNION
  13995. SELECT COUNT(*) cnt
  13996. FROM caActiveLog a WITH(NOLOCK)
  13997. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  13998. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  13999. WHERE caMainID = @caMainID
  14000. AND a.AddDate > DATEADD(YEAR, -2, GETDATE())
  14001. )a
  14002. --收藏简历数量
  14003. SELECT @FavorateCount = COUNT(A.ID)
  14004. FROM caFavorate a,Job b
  14005. WHERE a.caMainID=@caMainID and a.JobID=b.ID AND b.IsDelete = 0
  14006. IF @IsManager = 1
  14007. BEGIN
  14008. --一Month内应聘简历数量
  14009. SELECT @OneWeekApplyCount = COUNT(1)
  14010. FROM exJobApply WITH(index(IX_exJobApply_JobId) NOLOCK)
  14011. WHERE CompanyDeleted = 0
  14012. AND JobID IN (
  14013. SELECT ID FROM Job WITH(NOLOCK)
  14014. WHERE cPMainID = @cpMainID AND IsDelete = 0
  14015. )
  14016. END
  14017. ELSE
  14018. BEGIN
  14019. --一Month内应聘简历数量
  14020. SELECT @OneWeekApplyCount = COUNT(1)
  14021. FROM exJobApply WITH(index(IX_exJobApply_JobId) NOLOCK)
  14022. WHERE CompanyDeleted = 0
  14023. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE caMainID = @caMainID AND IsDelete = 0)
  14024. END
  14025. --未答复的应聘简历
  14026. SELECT @NoRepliedJobApply = COUNT(1)
  14027. FROM exJobApply a WITH(NOLOCK),
  14028. Job b WITH(NOLOCK),
  14029. cvMain c WITH(NOLOCK),
  14030. paMain d WITH(NOLOCK)
  14031. WHERE a.Reply = 0
  14032. And a.CompanyDeleted = 0
  14033. AND a.JobID =b.ID
  14034. AND b.caMainID = @caMainID
  14035. AND b.IsDelete = 0
  14036. AND a.IsFilter = 0
  14037. AND C.ID = a.cvMainID
  14038. AND D.ID = C.PamainID
  14039. --未查看的留言
  14040. SELECT @NoViewedMessage = COUNT(1)
  14041. FROM exMessageP2C WITH(NOLOCK)
  14042. WHERE IsViewed = 0
  14043. AND CompanyDeleted = 0
  14044. AND caMainID = @caMainID
  14045. SELECT @JobCount AS JobCount,@DownLoadCount AS DownLoadCount,
  14046. @FavorateCount AS FavorateCount,@OneWeekApplyCount AS OneWeekApplyCount,
  14047. @NoRepliedJobApply AS NoRepliedJobApply, @NoViewedMessage AS NoViewedMessage
  14048. END
  14049. GO
  14050. /****** Object: StoredProcedure [dbo].[ccCpIndexLinkByCountSelect] Script Date: 2018/12/13 19:06:25 ******/
  14051. SET ANSI_NULLS ON
  14052. GO
  14053. SET QUOTED_IDENTIFIER ON
  14054. GO
  14055. CREATE PROCEDURE [dbo].[ccCpIndexLinkByCountSelect]
  14056. (
  14057. @caMainID INT
  14058. )
  14059. AS
  14060. BEGIN TRY
  14061. DECLARE @JobCount AS INT --已发布职位数量
  14062. DECLARE @DownLoadCount AS INT --下载简历数量
  14063. DECLARE @FavorateCount AS INT --收藏简历数量
  14064. DECLARE @OneWeekApplyCount AS INT --一周内应聘简历数量
  14065. DECLARE @NoRepliedJobApply AS INT --未答复的应聘简历
  14066. DECLARE @NoViewedMessage AS INT --未查看的留言
  14067. --已发布职位数量
  14068. SELECT @JobCount = COUNT(*)
  14069. FROM Job a WITH(NOLOCK), caMain b WITH(NOLOCK)
  14070. WHERE a.cpMainId = b.cpMainId
  14071. AND b.ID = @caMainID
  14072. AND a.IsDelete=0
  14073. AND a.IssueDate IS NOT NULL
  14074. AND a.IssueEnd > GETDATE()
  14075. --下载简历数量
  14076. SELECT @DownLoadCount = SUM(a.cnt) FROM(
  14077. -- SELECT COUNT(*) cnt FROM caDailyGiftLog WHERE caMainID = @caMainID UNION ALL
  14078. -- SELECT COUNT(*) cnt FROM caActiveLog WHERE caMainID = @caMainID
  14079. SELECT COUNT(*) cnt
  14080. FROM caDailyGiftLog a WITH(NOLOCK)
  14081. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  14082. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  14083. WHERE caMainID = @caMainID
  14084. UNION
  14085. SELECT COUNT(*) cnt
  14086. FROM caActiveLog a WITH(NOLOCK)
  14087. INNER JOIN cvMain b WITH(NOLOCK) ON b.ID = a.cvMainID
  14088. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = b.paMainID
  14089. WHERE caMainID = @caMainID
  14090. )a
  14091. --收藏简历数量
  14092. SELECT @FavorateCount = COUNT(A.ID)
  14093. FROM caFavorate a,Job b
  14094. WHERE a.caMainID=@caMainID and a.JobID=b.ID AND b.IsDelete = 0
  14095. --一Month内应聘简历数量
  14096. SELECT @OneWeekApplyCount = COUNT(1)
  14097. FROM exJobApply WITH(index(IX_exJobApply_JobId) NOLOCK)
  14098. WHERE AddDate > DATEADD(Month,-1,GETDATE()) AND CompanyDeleted = 0
  14099. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE caMainID = @caMainID AND IsDelete = 0)
  14100. --未答复的应聘简历
  14101. SELECT @NoRepliedJobApply = COUNT(1)
  14102. FROM exJobApply a WITH(NOLOCK), Job b WITH(NOLOCK),cvMain c,paMain d
  14103. WHERE a.Reply = 0
  14104. And a.CompanyDeleted = 0
  14105. AND a.JobID =b.ID
  14106. AND b.caMainID = @caMainID
  14107. AND b.IsDelete = 0
  14108. AND C.ID = a.cvMainID
  14109. AND D.ID = C.PamainID
  14110. --未查看的留言
  14111. SELECT @NoViewedMessage = COUNT(1)
  14112. FROM exMessageP2C WITH(NOLOCK)
  14113. WHERE IsViewed = 0
  14114. AND CompanyDeleted = 0
  14115. AND caMainID = @caMainID
  14116. SELECT @JobCount AS JobCount,@DownLoadCount AS DownLoadCount ,@FavorateCount AS FavorateCount,@OneWeekApplyCount AS OneWeekApplyCount,
  14117. @NoRepliedJobApply AS NoRepliedJobApply, @NoViewedMessage AS NoViewedMessage
  14118. END TRY
  14119. BEGIN CATCH
  14120. RETURN
  14121. END CATCH
  14122. GO
  14123. /****** Object: StoredProcedure [dbo].[ccCpIndexPageSelect] Script Date: 2018/12/13 19:06:25 ******/
  14124. SET ANSI_NULLS ON
  14125. GO
  14126. SET QUOTED_IDENTIFIER ON
  14127. GO
  14128. --peter 2017
  14129. --sean 2018-4-3
  14130. CREATE PROCEDURE [dbo].[ccCpIndexPageSelect]
  14131. (
  14132. @cpMainId INT,
  14133. @caMainId INT,
  14134. @ProvinceId INT,
  14135. @IsManager BIT,
  14136. @Object VARCHAR(10)
  14137. )
  14138. AS
  14139. SET NOCOUNT ON
  14140. BEGIN
  14141. IF NOT EXISTS(SELECT 'x' FROM cpIndexPage WITH(NOLOCK) WHERE caMainId = @caMainId AND AddDate > DATEADD(MINUTE, -10, GETDATE()))
  14142. BEGIN
  14143. DECLARE @t AS TABLE(
  14144. Id INT,
  14145. type INT,
  14146. ICount INT NULL,
  14147. Title NVARCHAR(100) NULL,
  14148. Link NVARCHAR(200) NULL,
  14149. ContentText NVARCHAR(MAX) NULL,
  14150. AddDate SMALLDATETIME NULL
  14151. )
  14152. --取未付款订单
  14153. INSERT INTO @T(Id, type, ICount)
  14154. SELECT @cpMainId, 0, COUNT(1) FROM caOrder WITH(NOLOCK)
  14155. WHERE IsDeleted = 0 AND cpMainId = @cpMainId AND OrderStatus = 0 AND AddDate > DATEADD(MONTH, -2, GETDATE())
  14156. --取未查看的网站消息
  14157. INSERT INTO @T(Id, type, ContentText, AddDate, ICount)
  14158. SELECT Id, 1, Content, AddDate, type FROM CompanyNotify WITH(NOLOCK)
  14159. WHERE CompanyId = @cpMainId AND ((Type=1 AND Received=0) OR (Type=2 AND EndDate>GETDATE()))
  14160. ORDER BY AddDate DESC
  14161. --取未查看的反馈
  14162. INSERT INTO @T(Id, type, ContentText, AddDate)
  14163. SELECT TOP 1 Id, 2, ReplyMessage, ReplyDate FROM caFeedBack WITH(NOLOCK)
  14164. WHERE caMainId = @caMainId AND IsReply = 1 AND ViewDate IS NULL
  14165. ORDER BY Id DESC
  14166. --取未查看的投诉
  14167. IF @IsManager = 1
  14168. INSERT INTO @T(Id, type, ContentText, AddDate)
  14169. SELECT TOP 1 a.Id, 3, a.Plaint, a.AddDate
  14170. FROM PaPlaint a WITH(NOLOCK INDEX(IX_paPlaint_caMainId)), caMain b WITH( NOLOCK INDEX(IX_caMain_cpMainId))
  14171. WHERE a.caMainId = b.Id AND b.cpMainId = @cpMainId AND IsViewed=0 AND ReplyType =1
  14172. ORDER BY a.caMainId, a.Id DESC
  14173. ELSE
  14174. INSERT INTO @T(Id, type, ContentText, AddDate)
  14175. SELECT TOP 1 Id, 3, Plaint, AddDate FROM PaPlaint WITH(NOLOCK INDEX(IX_paPlaint_caMainId))
  14176. WHERE caMainId = @caMainId AND IsViewed=0 AND ReplyType = 1
  14177. ORDER BY Id DESC
  14178. --取未查看的网站分类通知
  14179. INSERT INTO @T(Id, type, Title, ContentText, link, ICount)
  14180. SELECT TOP 1 Id, 4, Title, Content, link, Type
  14181. FROM CompanyInform WITH(NOLOCK)
  14182. WHERE Status = 1
  14183. AND Object LIKE '%' + @Object + '%'
  14184. AND Province LIKE '%' + LTRIM(STR(@ProvinceId)) + '%'
  14185. AND EndDate > GETDATE() ORDER BY AddDate DESC
  14186. --取当前调查
  14187. INSERT INTO @T(Id, type, ContentText)
  14188. SELECT TOP 1 Id, 5, Title FROM Ivgt_Investigation WITH(NOLOCK)
  14189. WHERE ENDdate > GETDATE()
  14190. AND province Like '%' + LTRIM(STR(@provinceId)) + '%'
  14191. AND type=1
  14192. ORDER BY adddate
  14193. --如果有1个月内到期的职位, 修改截止日期
  14194. IF EXISTS(SELECT 'x' FROM Job WITH(NOLOCK)
  14195. WHERE caMainId = @caMainId
  14196. AND IssueEnd < DATEADD(MONTH, 1, GETDATE())
  14197. AND ValId = 1)
  14198. BEGIN
  14199. UPDATE Job SET IssueEnd = DATEADD(MINUTE, -1, CONVERT(VARCHAR(10), DATEADD(MONTH, 2, GETDATE()) + 1, 120))
  14200. WHERE caMainId = @caMainId
  14201. AND IssueEnd < DATEADD(MONTH, 1, GETDATE())
  14202. AND ValId = 1
  14203. AND @cpMainId <> 10371941
  14204. IF @@ROWCOUNT > 0
  14205. BEGIN
  14206. INSERT INTO @T(Id, [Type], ContentText) VALUES(@caMainId, 6, '')
  14207. END
  14208. END
  14209. --面试通知
  14210. DECLARE @InterViewCnt INT
  14211. SELECT @InterViewCnt = COUNT(*)
  14212. FROM exInterview WITH(NOLOCK)
  14213. WHERE JobId IN (
  14214. SELECT Id FROM Job WITH(NOLOCK)
  14215. WHERE cpMainId = @cpMainId
  14216. AND caMainId = @caMainId
  14217. )
  14218. AND Replydate IS NOT NULL
  14219. AND cpResultViewDate IS NULL
  14220. IF @InterViewCnt > 0
  14221. INSERT INTO @T(Id, [Type], ContentText, AddDate) VALUES(@caMainId, 7, @InterViewCnt, GETDATE())
  14222. --求答复提醒
  14223. DECLARE @ReplyViewCnt INT
  14224. SELECT @ReplyViewCnt = COUNT(*)
  14225. FROM ExJobApply WITH(NOLOCK)
  14226. WHERE JobId IN (
  14227. SELECT Id FROM Job WITH(NOLOCK)
  14228. WHERE cpMainId = @cpMainId
  14229. AND caMainId = @caMainId
  14230. )
  14231. AND RemindDate IS NOT NULL
  14232. AND cpRemindViewDate IS NULL
  14233. IF @ReplyViewCnt > 0
  14234. INSERT INTO @T(Id, [Type], ContentText, AddDate) VALUES(@caMainId, 8, @ReplyViewCnt, GETDATE())
  14235. --取未填写发票的订单
  14236. INSERT INTO @T(Id, type, ICount)
  14237. SELECT TOP 1 @cpMainId, 9, Id FROM caOrder WITH(NOLOCK)
  14238. WHERE IsDeleted = 0 AND cpMainId = @cpMainId
  14239. AND OrderStatus = 6 AND AddDate > DATEADD(DAY, -15, GETDATE())
  14240. AND PaId > 0
  14241. ORDER BY Id DESC
  14242. UPDATE @t SET AddDate = GETDATE() WHERE AddDate IS NULL
  14243. DELETE FROM cpIndexPage WHERE caMainId = @caMainId
  14244. INSERT INTO cpIndexPage
  14245. SELECT @caMainId, * FROM @T ORDER BY Type, Id
  14246. END
  14247. SELECT * FROM cpIndexPage WITH(NOLOCK) WHERE caMainId = @caMainId ORDER BY Type, Id
  14248. END
  14249. GO
  14250. /****** Object: StoredProcedure [dbo].[ccCpIndexPageSelect2] Script Date: 2018/12/13 19:06:25 ******/
  14251. SET ANSI_NULLS ON
  14252. GO
  14253. SET QUOTED_IDENTIFIER ON
  14254. GO
  14255. CREATE PROCEDURE [dbo].[ccCpIndexPageSelect2]
  14256. (
  14257. @cpMainID INT,
  14258. @caMainID INT,
  14259. @ProvinceID INT,
  14260. @IsManager BIT,
  14261. @Object VARCHAR(10)
  14262. )
  14263. AS
  14264. SET NOCOUNT ON
  14265. BEGIN
  14266. IF NOT EXISTS(SELECT 'x' FROM cpIndexPage WITH(NOLOCK) WHERE caMainId = @caMainId AND AddDate > DATEADD(MINUTE, -10, GETDATE()))
  14267. BEGIN
  14268. DECLARE @t AS TABLE(
  14269. ID INT,
  14270. type INT,
  14271. ICount INT NULL,
  14272. Title NVARCHAR(100) NULL,
  14273. Link NVARCHAR(200) NULL,
  14274. ContentText NVARCHAR(MAX) NULL,
  14275. AddDate SMALLDATETIME NULL
  14276. )
  14277. --取未付款订单
  14278. INSERT INTO @T(ID, type, ICount)
  14279. SELECT @cpMainID, 0, COUNT(1) FROM caOrder WITH(NOLOCK)
  14280. WHERE IsDeleted = 0 AND cpMainID = @cpMainID AND OrderStatus = 0 AND AddDate > DATEADD(MONTH, -2, GETDATE())
  14281. --取未查看的网站消息
  14282. INSERT INTO @T(ID, type, ContentText, AddDate, ICount)
  14283. SELECT ID, 1, Content, AddDate, type FROM CompanyNotify WITH(NOLOCK)
  14284. WHERE CompanyID = @cpMainID AND ((Type=1 AND Received=0) OR (Type=2 AND EndDate>GETDATE()))
  14285. ORDER BY AddDate DESC
  14286. --取未查看的反馈
  14287. INSERT INTO @T(ID, type, ContentText, AddDate)
  14288. SELECT TOP 1 ID, 2, ReplyMessage, ReplyDate FROM CaFeedBack WITH(NOLOCK)
  14289. WHERE caMainID = @caMainID AND IsReply = 1 AND ViewDate IS NULL
  14290. ORDER BY ID DESC
  14291. --取未查看的投诉
  14292. IF @IsManager = 1
  14293. INSERT INTO @T(ID, type, ContentText, AddDate)
  14294. SELECT TOP 1 a.ID, 3, a.Plaint, a.AddDate
  14295. FROM PaPlaint a WITH(NOLOCK INDEX(IX_paPlaint_caMainID)), caMain b WITH( NOLOCK INDEX(IX_caMain_cpMainID))
  14296. WHERE a.caMainID = b.ID AND b.cpMainID = @cpMainID AND IsViewed=0 AND ReplyType =1
  14297. ORDER BY a.CaMainID, a.ID DESC
  14298. ELSE
  14299. INSERT INTO @T(ID, type, ContentText, AddDate)
  14300. SELECT TOP 1 ID, 3, Plaint, AddDate FROM PaPlaint WITH(NOLOCK INDEX(IX_paPlaint_caMainID))
  14301. WHERE caMainID = @caMainID AND IsViewed=0 AND ReplyType = 1
  14302. ORDER BY ID DESC
  14303. --取未查看的网站分类通知
  14304. INSERT INTO @T(ID, type, Title, ContentText, link, ICount)
  14305. SELECT TOP 1 ID, 4, Title, Content, link, Type
  14306. FROM CompanyInform WITH(NOLOCK)
  14307. WHERE Status = 1
  14308. AND Object LIKE '%' + @Object + '%'
  14309. AND Province LIKE '%' + LTRIM(STR(@ProvinceID)) + '%'
  14310. AND EndDate > GETDATE() ORDER BY AddDate DESC
  14311. --取当前调查
  14312. INSERT INTO @T(ID, type, ContentText)
  14313. SELECT TOP 1 ID, 5, Title FROM Ivgt_Investigation WITH(NOLOCK)
  14314. WHERE ENDdate > GETDATE()
  14315. AND province Like '%' + LTRIM(STR(@provinceid)) + '%'
  14316. AND type=1
  14317. ORDER BY adddate
  14318. --如果有1个月内到期的职位, 修改截止日期
  14319. UPDATE Job SET IssueEnd = DATEADD(MINUTE, -1, CONVERT(VARCHAR(10), DATEADD(MONTH, 2, GETDATE()) + 1, 120))
  14320. WHERE caMainId = @caMainID
  14321. AND IssueEnd < DATEADD(MONTH, 1, GETDATE())
  14322. AND Valid = 1
  14323. AND @cpMainID <> 10371941
  14324. IF @@ROWCOUNT > 0
  14325. BEGIN
  14326. INSERT INTO @T(ID, [Type], ContentText) VALUES(@caMainID, 6, '')
  14327. END
  14328. --面试通知
  14329. DECLARE @InterViewCnt INT
  14330. SELECT @InterViewCnt = COUNT(*)
  14331. FROM exInterview WITH(NOLOCK)
  14332. WHERE JOBID IN (
  14333. SELECT ID FROM JOB WITH(NOLOCK)
  14334. WHERE CpMainID = @cpMainID
  14335. AND CaMainID = @caMainID
  14336. )
  14337. AND Replydate IS NOT NULL
  14338. AND CpResultViewDate IS NULL
  14339. IF @InterViewCnt > 0
  14340. INSERT INTO @T(ID, [Type], ContentText, AddDate) VALUES(@caMainID, 7, @InterViewCnt, GETDATE())
  14341. --求答复提醒
  14342. DECLARE @ReplyViewCnt INT
  14343. SELECT @ReplyViewCnt = COUNT(*)
  14344. FROM ExJobApply WITH(NOLOCK)
  14345. WHERE JOBID IN (
  14346. SELECT ID FROM JOB WITH(NOLOCK)
  14347. WHERE CpMainID = @cpMainID
  14348. AND CaMainID = @caMainID
  14349. )
  14350. AND RemindDate IS NOT NULL
  14351. AND CpRemindViewDate IS NULL
  14352. IF @ReplyViewCnt > 0
  14353. INSERT INTO @T(ID, [Type], ContentText, AddDate) VALUES(@caMainID, 8, @ReplyViewCnt, GETDATE())
  14354. --取未填写发票的订单
  14355. INSERT INTO @T(ID, type, ICount)
  14356. SELECT TOP 1 @cpMainID, 9, Id FROM caOrder WITH(NOLOCK)
  14357. WHERE IsDeleted = 0 AND cpMainID = @cpMainID
  14358. AND OrderStatus = 6 AND AddDate > DATEADD(DAY, -15, GETDATE())
  14359. AND Paid > 0
  14360. ORDER BY ID DESC
  14361. UPDATE @t SET AddDate = GETDATE() WHERE AddDate IS NULL
  14362. DELETE FROM cpIndexPage WHERE caMainId = @caMainId
  14363. INSERT INTO cpIndexPage
  14364. SELECT @caMainId, * FROM @T ORDER BY Type, ID
  14365. END
  14366. SELECT * FROM cpIndexPage WITH(NOLOCK) WHERE caMainId = @caMainId ORDER BY Type, ID
  14367. END
  14368. GO
  14369. /****** Object: StoredProcedure [dbo].[ccCpIndustryByCpMainIDSelect] Script Date: 2018/12/13 19:06:26 ******/
  14370. SET ANSI_NULLS ON
  14371. GO
  14372. SET QUOTED_IDENTIFIER ON
  14373. GO
  14374. --#####################################################
  14375. --创建时间:2014.10.30
  14376. --创建人:Nick
  14377. --说明:根据cpmainid 获取industryid
  14378. --#####################################################
  14379. CREATE PROCEDURE [dbo].[ccCpIndustryByCpMainIDSelect]
  14380. (
  14381. @CpMainID INT
  14382. )
  14383. AS
  14384. BEGIN TRY
  14385. SELECT TOP 1 dcindustryid FROM cpindustry WHERE CpmainID=@CpMainID
  14386. END TRY
  14387. BEGIN CATCH
  14388. RETURN 0
  14389. END CATCH
  14390. GO
  14391. /****** Object: StoredProcedure [dbo].[ccCpIndustrySelect] Script Date: 2018/12/13 19:06:26 ******/
  14392. SET ANSI_NULLS ON
  14393. GO
  14394. SET QUOTED_IDENTIFIER ON
  14395. GO
  14396. CREATE PROCEDURE [dbo].[ccCpIndustrySelect]
  14397. @ID INT
  14398. AS
  14399. BEGIN
  14400. SELECT * FROM cpIndustry WITH(NOLOCK) WHERE cpMainID = @ID
  14401. END
  14402. GO
  14403. /****** Object: StoredProcedure [dbo].[ccCplicenceByCheckDateSelect] Script Date: 2018/12/13 19:06:26 ******/
  14404. SET ANSI_NULLS ON
  14405. GO
  14406. SET QUOTED_IDENTIFIER ON
  14407. GO
  14408. CREATE PROCEDURE [dbo].[ccCplicenceByCheckDateSelect]
  14409. (
  14410. @cpMainID INT,
  14411. @CheckDate VARCHAR(30) OUTPUT
  14412. )
  14413. AS
  14414. BEGIN
  14415. SELECT @CheckDate = CONVERT(VARCHAR(30), CheckDate, 120) FROM cpLicence WITH(NOLOCK)
  14416. WHERE cpMainId = @cpMainID
  14417. AND HasPassed = 1
  14418. --PRINT @CheckDate
  14419. END
  14420. GO
  14421. /****** Object: StoredProcedure [dbo].[cccpLicenceDelete] Script Date: 2018/12/13 19:06:26 ******/
  14422. SET ANSI_NULLS ON
  14423. GO
  14424. SET QUOTED_IDENTIFIER ON
  14425. GO
  14426. --==========================================
  14427. --检查sean 2010-10-28
  14428. --营业执照删除
  14429. --==========================================
  14430. CREATE PROCEDURE [dbo].[cccpLicenceDelete]
  14431. @caMainID INT,
  14432. @cpMainID INT
  14433. AS
  14434. BEGIN TRAN
  14435. BEGIN TRY
  14436. IF EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainId AND IsDelete = 0)
  14437. BEGIN
  14438. DELETE FROM cpLicence WHERE cpMainID=@cpMainID
  14439. UPDATE cpMain SET HasLicence=0 WHERE ID=@cpMainID
  14440. EXEC ccCaOperationLogInsert @caMainID, 25, '删除营业执照'
  14441. END
  14442. ELSE
  14443. GOTO Err
  14444. END TRY
  14445. BEGIN CATCH
  14446. GOTO ERR
  14447. END CATCH
  14448. COMMIT TRAN
  14449. RETURN 1
  14450. ERR:
  14451. BEGIN
  14452. ROLLBACK TRAN
  14453. RETURN 0
  14454. END
  14455. GO
  14456. /****** Object: StoredProcedure [dbo].[cccpLicenceInsert] Script Date: 2018/12/13 19:06:26 ******/
  14457. SET ANSI_NULLS ON
  14458. GO
  14459. SET QUOTED_IDENTIFIER ON
  14460. GO
  14461. --==========================================
  14462. --检查sean 2010-10-28
  14463. --营业执照上传
  14464. --==========================================
  14465. CREATE PROCEDURE [dbo].[cccpLicenceInsert]
  14466. @caMainID INT,
  14467. @cpMainID INT,
  14468. @ImgFile VARCHAR(50)
  14469. AS
  14470. BEGIN TRAN
  14471. DECLARE @MaxId AS INT, @Desc AS VARCHAR(200)
  14472. BEGIN TRY
  14473. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND AccountType = 1 AND cpMainID = @cpMainID)
  14474. GOTO ERR
  14475. DECLARE @IP AS VARCHAR(31)
  14476. SELECT TOP 1 @IP = LoginIP FROM caLoginLog WITH(NOLOCK) WHERE caMainId = @caMainID ORDER BY ID DESC
  14477. DELETE FROM cpLicence WHERE cpMainID=@cpMainID
  14478. UPDATE cpMain SET HasLicence=0 WHERE ID=@cpMainID
  14479. INSERT INTO cpLicence (cpMainID,ImgFile, FileSource, Ip) VALUES(@cpMainID,@ImgFile, 1, @IP)
  14480. SET @MaxID = @@IDENTITY
  14481. SET @Desc = '上传营业执照,文件名:' + @ImgFile
  14482. EXEC ccCaOperationLogInsert @caMainID, 24, @Desc
  14483. --INSERT INTO bsCpStatus(cpMainID,StatusID) VALUES(@cpMainID,1)
  14484. END TRY
  14485. BEGIN CATCH
  14486. GOTO ERR
  14487. END CATCH
  14488. COMMIT TRAN
  14489. RETURN @MaxID
  14490. ERR:
  14491. BEGIN
  14492. ROLLBACK TRAN
  14493. RETURN 0
  14494. END
  14495. GO
  14496. /****** Object: StoredProcedure [dbo].[cccpLicenceInsert20171019] Script Date: 2018/12/13 19:06:27 ******/
  14497. SET ANSI_NULLS ON
  14498. GO
  14499. SET QUOTED_IDENTIFIER ON
  14500. GO
  14501. CREATE PROCEDURE [dbo].[cccpLicenceInsert20171019]
  14502. @caMainID INT,
  14503. @cpMainID INT,
  14504. @ImgFile VARCHAR(50),
  14505. @CompanyName VARCHAR(100),
  14506. @Mobile VARCHAR(11)
  14507. AS
  14508. BEGIN TRAN
  14509. DECLARE @MaxId AS INT, @Desc AS VARCHAR(200)
  14510. BEGIN TRY
  14511. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND AccountType = 1 AND cpMainID = @cpMainID)
  14512. GOTO ERR
  14513. DECLARE @cpCertificationID INT
  14514. SELECT @cpCertificationID = ID FROM cpCertification WITH(NOLOCK) WHERE cpMainID = @cpMainID AND CerStatus IS NULL
  14515. IF @cpCertificationID IS NULL
  14516. BEGIN
  14517. INSERT INTO cpCertification(cpMainID, CompanyName, Mobile, MemberType, CerType)
  14518. VALUES(@cpMainID, @CompanyName, @Mobile, 2, 2)
  14519. SET @cpCertificationID = @@IDENTITY
  14520. END
  14521. ELSE
  14522. UPDATE cpCertification SET CompanyName = @CompanyName, Mobile = @Mobile WHERE ID = @cpCertificationID
  14523. DECLARE @IP AS VARCHAR(31)
  14524. SELECT TOP 1 @IP = LoginIP FROM caLoginLog WITH(NOLOCK) WHERE caMainId = @caMainID ORDER BY ID DESC
  14525. DELETE FROM cpLicence WHERE cpCertificationID = @cpCertificationID
  14526. --UPDATE cpMain SET HasLicence = 0 WHERE ID = @cpMainID
  14527. INSERT INTO cpLicence (cpMainID, cpCertificationID, ImgFile, FileSource, Ip) VALUES(@cpMainID, @cpCertificationID, @ImgFile, 1, @IP)
  14528. SET @MaxID = @@IDENTITY
  14529. SET @Desc = '上传营业执照,文件名:' + @ImgFile
  14530. EXEC ccCaOperationLogInsert @caMainID, 24, @Desc
  14531. END TRY
  14532. BEGIN CATCH
  14533. GOTO ERR
  14534. END CATCH
  14535. COMMIT TRAN
  14536. RETURN @MaxID
  14537. ERR:
  14538. BEGIN
  14539. ROLLBACK TRAN
  14540. RETURN 0
  14541. END
  14542. GO
  14543. /****** Object: StoredProcedure [dbo].[ccCpLicenceLogByCpMainIDSelect] Script Date: 2018/12/13 19:06:27 ******/
  14544. SET ANSI_NULLS ON
  14545. GO
  14546. SET QUOTED_IDENTIFIER ON
  14547. GO
  14548. --===================================
  14549. --创建: sean 2010-10-27
  14550. --获取最后一次一尼姑也执照审核错误记录
  14551. --===================================
  14552. CREATE PROCEDURE [dbo].[ccCpLicenceLogByCpMainIDSelect]
  14553. (
  14554. @cpMainID INT
  14555. )
  14556. AS
  14557. BEGIN
  14558. SELECT TOP 1 * FROM cpLicenceLog WITH(NOLOCK) WHERE cpMainID =@cpMainID ORDER BY ID DESC
  14559. END
  14560. GO
  14561. /****** Object: StoredProcedure [dbo].[cccpLicenceSelect] Script Date: 2018/12/13 19:06:27 ******/
  14562. SET ANSI_NULLS ON
  14563. GO
  14564. SET QUOTED_IDENTIFIER ON
  14565. GO
  14566. --==================================
  14567. --lambo 20101020 修改
  14568. --增加了FileSource,ip这两个字段
  14569. --审核: Sean 2010-10-26
  14570. --==================================
  14571. CREATE PROCEDURE [dbo].[cccpLicenceSelect]
  14572. (
  14573. @cpMainID INT
  14574. )
  14575. AS
  14576. BEGIN
  14577. IF EXISTS(SELECT TOP 1 'X' FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID AND HasLicence = 1)
  14578. SELECT a.*, b.AddDate RealNameDate
  14579. FROM cpLicence a WITH(NOLOCK)
  14580. LEFT JOIN CpRealNameLog b WITH(NOLOCK) ON b.cpMainID = a.cpMainID
  14581. WHERE a.cpMainID = @cpMainID AND a.HasPassed = 1
  14582. ORDER BY a.ID DESC
  14583. ELSE
  14584. SELECT a.*, b.AddDate RealNameDate
  14585. FROM cpLicence a WITH(NOLOCK)
  14586. LEFT JOIN CpRealNameLog b WITH(NOLOCK) ON b.cpMainID = a.cpMainID
  14587. WHERE a.cpMainID = @cpMainID
  14588. ORDER BY a.ID DESC
  14589. END
  14590. GO
  14591. /****** Object: StoredProcedure [dbo].[ccCpMainAutoReplyConfirmUpdate] Script Date: 2018/12/13 19:06:27 ******/
  14592. SET ANSI_NULLS ON
  14593. GO
  14594. SET QUOTED_IDENTIFIER ON
  14595. GO
  14596. --企业同意自动答复应聘的简历
  14597. --HARRY
  14598. --2017-5-17
  14599. CREATE PROCEDURE [dbo].[ccCpMainAutoReplyConfirmUpdate]
  14600. (
  14601. @cpMainId INT
  14602. )
  14603. AS
  14604. SET NOCOUNT ON
  14605. BEGIN
  14606. UPDATE cpMain SET AutoReplyConfirm = GETDATE(), ReplyRate = 1 WHERE id = @cpMainId
  14607. END
  14608. SET NOCOUNT OFF
  14609. GO
  14610. /****** Object: StoredProcedure [dbo].[ccCpMainBalanceUpdate] Script Date: 2018/12/13 19:06:28 ******/
  14611. SET ANSI_NULLS ON
  14612. GO
  14613. SET QUOTED_IDENTIFIER ON
  14614. GO
  14615. CREATE PROCEDURE [dbo].[ccCpMainBalanceUpdate]
  14616. (
  14617. @ID INT,
  14618. @BalanceDate VARCHAR(20),
  14619. @Balance INT
  14620. )
  14621. AS
  14622. UPDATE cpMain SET BalanceDate=@BalanceDate,Balance=@Balance WHERE ID=@ID
  14623. GO
  14624. /****** Object: StoredProcedure [dbo].[ccCpMainByBlackEmailExist] Script Date: 2018/12/13 19:06:28 ******/
  14625. SET ANSI_NULLS ON
  14626. GO
  14627. SET QUOTED_IDENTIFIER ON
  14628. GO
  14629. --==================================
  14630. --企业邮箱在黑名单
  14631. --检查: sean 2010-10-22
  14632. --==================================
  14633. CREATE PROCEDURE [dbo].[ccCpMainByBlackEmailExist]
  14634. (
  14635. @Email VARCHAR(50),
  14636. @ErrorMessage NVARCHAR(500) OUT
  14637. )
  14638. AS
  14639. BEGIN
  14640. SET @ErrorMessage = ''
  14641. BEGIN TRY
  14642. SET @Email=LTRIM(RTRIM(@Email))
  14643. IF EXISTS(SELECT ID FROM company_black WITH(NOLOCK) WHERE email LIKE '%'+@Email+'%')
  14644. SELECT TOP 1 @ErrorMessage=Reason FROM company_black WITH(NOLOCK) WHERE Email = @Email
  14645. END TRY
  14646. BEGIN CATCH
  14647. SET @ErrorMessage = '检查邮件是否被屏蔽时出现错误,请稍后继续提交!'
  14648. END CATCH
  14649. END
  14650. GO
  14651. /****** Object: StoredProcedure [dbo].[ccCpMainByBlackNameExist] Script Date: 2018/12/13 19:06:28 ******/
  14652. SET ANSI_NULLS ON
  14653. GO
  14654. SET QUOTED_IDENTIFIER ON
  14655. GO
  14656. --==================================
  14657. --企业名称在黑名单
  14658. --检查: sean 2010-10-22
  14659. --==================================
  14660. CREATE PROCEDURE [dbo].[ccCpMainByBlackNameExist]
  14661. (
  14662. @Name VARCHAR(100),
  14663. @ErrorMessage NVARCHAR(500) OUT
  14664. )
  14665. AS
  14666. BEGIN
  14667. SET @ErrorMessage = ''
  14668. BEGIN TRY
  14669. SET @Name=LTRIM(RTRIM(@Name))
  14670. IF EXISTS(SELECT ID FROM company_black WITH(NOLOCK) WHERE CHARINDEX(LTRIM(RTRIM(companyname)),@Name)>0)
  14671. BEGIN
  14672. UPDATE Company_Black SET RefuseCount = RefuseCount + 1
  14673. WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)),@Name)>0
  14674. SELECT TOP 1 @ErrorMessage=Reason
  14675. FROM company_black WITH(NOLOCK)
  14676. WHERE CHARINDEX(LTRIM(RTRIM(companyname)),@Name)>0
  14677. END
  14678. END TRY
  14679. BEGIN CATCH
  14680. SET @ErrorMessage = '检查单位名称是否被屏蔽时出现错误,请稍后继续提交!'
  14681. END CATCH
  14682. END
  14683. GO
  14684. /****** Object: StoredProcedure [dbo].[ccCpMainByBriefSelect] Script Date: 2018/12/13 19:06:28 ******/
  14685. SET ANSI_NULLS ON
  14686. GO
  14687. SET QUOTED_IDENTIFIER ON
  14688. GO
  14689. --sean 2014-8-13
  14690. CREATE PROCEDURE [dbo].[ccCpMainByBriefSelect]
  14691. (
  14692. @cpMainId INT
  14693. )
  14694. AS
  14695. BEGIN
  14696. SELECT Id, Name, SecondId, LEFT(Brief, 200) Brief FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId
  14697. END
  14698. GO
  14699. /****** Object: StoredProcedure [dbo].[ccCpMainByConsultantAssignUpdate] Script Date: 2018/12/13 19:06:28 ******/
  14700. SET ANSI_NULLS ON
  14701. GO
  14702. SET QUOTED_IDENTIFIER ON
  14703. GO
  14704. --==============================================
  14705. --创建: Sean
  14706. --时间: 2010-10-22
  14707. --说明: 分配招聘顾问
  14708. -- Richard 按组分配修改为按省分配 2012-04-23修改
  14709. -- Sean 2013-6-19 改为按区域分配,并且增加订单联动
  14710. -- harry 2018-5-23 更名时分配不分给推广
  14711. --==============================================
  14712. CREATE PROCEDURE [dbo].[ccCpMainByConsultantAssignUpdate]
  14713. (
  14714. @cpMainID INT,
  14715. @dcProvinceID TINYINT
  14716. )
  14717. AS
  14718. SET NOCOUNT ON
  14719. --RETURN 1
  14720. IF NOT EXISTS(SELECT 'x' FROM dcProvince WITH(NOLOCK) WHERE AssignConsultant = 1 AND ID = @dcProvinceID)
  14721. RETURN 1
  14722. IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE id = @cpMainId AND IsLimitLogin = 9)
  14723. RETURN 1
  14724. BEGIN TRAN
  14725. --用于暂停客户的分配
  14726. DECLARE @CompanyName AS VARCHAR(100),
  14727. @ManagerUserID AS SMALLINT,
  14728. @ThisManagerUserID AS SMALLINT,
  14729. @ThisManagerDate AS DATETIME,
  14730. @MemberType AS INT
  14731. SELECT @CompanyName = Name, @ThisManagerUserID = ConsultantId,
  14732. @ThisManagerDate = ConsultantDate, @MemberType = MemberType
  14733. FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID
  14734. IF @ThisManagerDate IS NULL
  14735. SET @ThisManagerDate = GETDATE()
  14736. --sean 2015-5-20 first judge is ColdCustomer
  14737. --企业的营业执照审核通过后,重新分配招聘顾问。
  14738. DECLARE @AddMan2 INT, @SouthNorth AS TINYINT
  14739. SELECT @SouthNorth = SouthNorth FROM dcProvince WITH(NOLOCK) WHERE Id = @dcProvinceId
  14740. SELECT TOP 1 @AddMan2 = AddMan FROM ColdCustomer WITH(NOLOCK)
  14741. WHERE ProvinceID IN (SELECT ID FROM dcProvince WITH(NOLOCK) WHERE SouthNorth = @SouthNorth)
  14742. --20160809 Lucifer修改,根据企业名称或关联的cpMainID
  14743. --20170206 Lucifer修改,付费的转给招聘顾问,不给冷客户顾问
  14744. AND (CompanyName = @CompanyName OR CpMainID = @cpMainID)
  14745. AND NOT EXISTS(SELECT TOP 1 'x' FROM cpMain WHERE ([Name] = @CompanyName OR ID = @cpMainID) AND MemberType = 3)
  14746. ORDER BY ID DESC
  14747. --SELECT TOP 1 @AddMan2 = AddMan FROM ColdCustomer WITH(NOLOCK) WHERE CompanyName = @CompanyName ORDER BY ID DESC
  14748. -- Richard 按组分配修改为按省分配 2012-04-23修改
  14749. -- Sean 2013-6-19 改为按区域分配,并且增加订单联动
  14750. -- Richard 保险、房地产公司不分给原来的顾问 2012-04-23修改
  14751. IF CHARINDEX('物业顾问',@CompanyName)=0 and CHARINDEX('某公司',@CompanyName)=0
  14752. and CHARINDEX('置业',@CompanyName)=0 and CHARINDEX('房地产',@CompanyName)=0
  14753. and CHARINDEX('不动产',@CompanyName)=0 and CHARINDEX('房产',@CompanyName)=0
  14754. and CHARINDEX('住房',@CompanyName)=0 and CHARINDEX('保险',@CompanyName)=0
  14755. BEGIN
  14756. SELECT TOP 1 @ManagerUserID = ConsultantId
  14757. FROM cpMain WITH(NOLOCK)
  14758. WHERE ConsultantId IS NOT NULL
  14759. -- Sean 2013-6-19 回复按区域分配
  14760. AND dcProvinceID IN(SELECT ID FROM dcProvince WITH(NOLOCK) WHERE SouthNorth = @SouthNorth)
  14761. -- Richard 按组分配修改为按省分配 2012-04-23修改
  14762. -- AND dcProvinceID = @dcProvinceID
  14763. AND Name = @CompanyName
  14764. AND ID <> @cpMainID --Richard 2011年12月6日增加
  14765. AND ConsultantDate < @ThisManagerDate --Richard 2011年12月11日增加
  14766. AND consultantId NOT IN(select id FROM manageruser where deptid=15)--harry 2018-5-23
  14767. ORDER BY ConsultantDate desc
  14768. IF @ManagerUserID IS NULL AND @MemberType < 2 --Sean 2011-12-14增加,如果是未审核的
  14769. SELECT TOP 1 @ManagerUserID = ConsultantId
  14770. FROM cpMain WITH(NOLOCK)
  14771. WHERE ConsultantId IS NOT NULL
  14772. -- Sean 2013-6-19 回复按区域分配
  14773. AND dcProvinceID IN(SELECT ID FROM dcProvince WITH(NOLOCK) WHERE SouthNorth = @SouthNorth)
  14774. -- Richard 按组分配修改为按省分配 2012-04-23修改
  14775. --AND dcProvinceID = @dcProvinceID
  14776. AND Name = @CompanyName
  14777. AND ID <> @cpMainID
  14778. AND MemberType > 1 --已经审核过的
  14779. AND consultantId NOT IN(select id FROM manageruser where deptid=15)--harry 2018-5-23
  14780. ORDER BY ConsultantDate desc
  14781. /*
  14782. 同一省组(山东、南方、北方)内,是否存在公司名称完全相同,有招聘顾问,
  14783. 而且分配时间比A账户的分配时间还早的账户(B)?
  14784. */
  14785. END
  14786. IF @ManagerUserID > 0 ----存在重名的企业,招聘顾问不重新分配
  14787. BEGIN
  14788. GOTO ASSIGN
  14789. END
  14790. ELSE IF @AddMan2 > 0
  14791. BEGIN
  14792. --企业是冷客户
  14793. SET @ManagerUserID = @AddMan2
  14794. GOTO ASSIGN
  14795. END
  14796. ELSE IF @ThisManagerUserID IS NULL --当前帐户无顾问
  14797. BEGIN
  14798. DECLARE @T AS TABLE(
  14799. ID INT,
  14800. ManagerUserID SMALLINT,
  14801. Power TINYINT,
  14802. Current_Power TINYINT
  14803. )
  14804. INSERT INTO @T
  14805. SELECT a.ID, a.ManageruserID, a.Power, a.Current_Power
  14806. FROM Consultant_Assign a WITH(NOLOCK), Manageruser b WITH(NOLOCK)
  14807. WHERE a.ManageruserID = b.ID
  14808. AND b.ConsultantNum < b.ConsultantNum_Up
  14809. AND b.ConsultantNum_New < b.ConsultantNum_Up_New
  14810. AND a.Province_ID = @dcProvinceID
  14811. AND a.Status = 1
  14812. ORDER BY a.ManageruserID
  14813. IF EXISTS(SELECT 'x' FROM @T)
  14814. BEGIN
  14815. DECLARE @ID AS INT
  14816. --如果全部Current_Power = Power,则清零
  14817. IF NOT EXISTS(SELECT 'x' FROM @T WHERE Current_Power < Power)
  14818. BEGIN
  14819. UPDATE @T SET Current_Power = 0
  14820. UPDATE Consultant_Assign SET Current_Power = 0 WHERE ID IN(SELECT ID FROM @T)
  14821. END
  14822. --提取第一个顾问
  14823. SELECT TOP 1 @ID = ID, @ManagerUserID = ManagerUserID FROM @T WHERE Current_Power < Power
  14824. IF @ManagerUserID IS NULL
  14825. GOTO Err1
  14826. --修改顾问分配表
  14827. UPDATE Consultant_Assign SET Current_Power = Current_Power + 1 WHERE ID = @ID
  14828. END
  14829. END
  14830. --分配顾问
  14831. ASSIGN:
  14832. IF (@ManagerUserID > 0) AND (ISNULL(@ThisManagerUserID, 0) <> @ManagerUserID) --Richard 2011年12月11日修改
  14833. BEGIN
  14834. UPDATE cpMain SET ConsultantId = @ManagerUserID, ConsultantDate = GETDATE() WHERE ID = @cpMainID
  14835. ----Sean 2012-2-16增加,记录每次修改情况 中间停止了 2013-6-19继续启用
  14836. DECLARE @Sql AS VARCHAR(200)
  14837. SET @Sql = '系统自动分配招聘顾问:从' + LTRIM(STR(ISNULL(@ThisManagerUserID, 0))) + '给'
  14838. SET @Sql =@Sql + LTRIM(STR(@ManagerUserID))
  14839. INSERT INTO bsManagerUserAction VALUES(@cpMainId, @Sql, '', 112, GETDATE())
  14840. --Sean 2013-7-1
  14841. DECLARE @AddMan INT
  14842. SELECT @AddMan = AddMan FROM ColdCustomer WITH(NOLOCK) WHERE cpMainId = @cpMainId
  14843. IF @AddMan > 0
  14844. BEGIN
  14845. IF EXISTS(SELECT 'x' FROM CaOrder WITH(NOLOCK) WHERE cpMainId = @cpMainId AND OpenDate > DATEADD(DAY, -28, GETDATE()) AND ManagerUSerID <> @ManagerUserID)
  14846. BEGIN
  14847. INSERT INTO bsManagerUserAction
  14848. SELECT @cpMainId, '冷客户订单28天内转移从' + LTRIM(STR(ISNULL(ManagerUserId, 0))) + '至空', '', 112, GETDATE()
  14849. FROM CaOrder WITH(NOLOCK) WHERE cpMainId = @cpMainId AND OpenDate > DATEADD(MONTH, -1, GETDATE()) AND ManagerUSerID <> @ManagerUserID
  14850. IF EXISTS(SELECT 'x' FROM CaOrder WHERE cpMainId = @cpMainId AND OpenDate > DATEADD(DAY, -28, GETDATE()) AND ManagerUSerID <> @ManagerUserID)
  14851. UPDATE CaOrder SET ManagerUserId = NULL
  14852. WHERE cpMainId = @cpMainId AND OpenDate > DATEADD(DAY, -28, GETDATE()) AND ManagerUSerID <> @ManagerUserID
  14853. END
  14854. END
  14855. END
  14856. COMMIT
  14857. RETURN 1
  14858. Err:
  14859. BEGIN
  14860. ROLLBACK TRAN
  14861. RETURN 0
  14862. END
  14863. Err1:
  14864. BEGIN
  14865. ROLLBACK TRAN
  14866. RETURN -1
  14867. END
  14868. GO
  14869. /****** Object: StoredProcedure [dbo].[ccCpMainByEncryptViewSelect] Script Date: 2018/12/13 19:06:29 ******/
  14870. SET ANSI_NULLS ON
  14871. GO
  14872. SET QUOTED_IDENTIFIER ON
  14873. GO
  14874. --根据加密ID查找职位 Lucifer 20131206
  14875. --修改harry 2017-4-11 强制实名认证的,限制的不显示
  14876. --lucofer 2018-3-2
  14877. CREATE PROCEDURE [dbo].[ccCpMainByEncryptViewSelect]
  14878. (
  14879. @ID VARCHAR(12)
  14880. )
  14881. AS
  14882. BEGIN
  14883. SELECT a.ID, a.dcProvinceID, a.RegDate, a.RegisterIP, a.RegisterMode, a.AddMan, a.IsDefaultPassword,
  14884. a.Name, a.ShortName, a.dcCompanyKindID, a.dcCompanySizeID, a.dcRegionID,
  14885. dbo.CleanAddress(a.Address, a.dcRegionId) Address,
  14886. --a.Address,
  14887. a.Zip, a.MapBarID, a.HomePage,a.RealName,
  14888. a.Brief, a.HasLicence, a.HasLogo, a.HasVisual, a.ConsultantID, a.ConsultantDate,
  14889. a.DailyGiftQuota, a.UnlimitedDate, a.BalanceDate, a.Balance, a.ResumeQuota, a.MaxUserNumber,
  14890. a.MaxJobNumber, a.Quality, a.SendFeeCount, a.IsAgent, a.IsLimitLogin, a.Islock, a.IsDelete,
  14891. a.MemberType, a.Description, a.VerifyResult, a.BlockCount, a.VerifyCount, a.LoginCount,
  14892. a.JobNumber, a.ViewNumber, a.RefreshDate, a.LastModifyDate, a.RegCapital, a.dcSubSiteID,
  14893. a.LastLoginDate, a.LastLoginIP, a.Valid, a.PerfectDate, a.Lng, a.Lat, a.SecondId,
  14894. dbo.GetCpIndustry(a.ID) Industry,
  14895. b.FullName Region,a.ReplyRate,
  14896. (SELECT COUNT(1) FROM caOnline c WITH(NOLOCK), caMain d WITH(NOLOCK) WHERE c.caMainID = d.ID AND d.cpMainID = a.ID AND IsOnline = 1) OnlineStatus
  14897. FROM cpMain a WITH(NOLOCK INDEX(IX_cpMain_SecondId))
  14898. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionId = b.Id
  14899. WHERE a.SecondID = @ID
  14900. AND ISNULL(a.RealName, 0) < 2
  14901. AND a.IsLimitLogin < 9
  14902. END
  14903. GO
  14904. /****** Object: StoredProcedure [dbo].[cccpMainByLimitedReasonBycaMainIDSelect] Script Date: 2018/12/13 19:06:29 ******/
  14905. SET ANSI_NULLS ON
  14906. GO
  14907. SET QUOTED_IDENTIFIER ON
  14908. GO
  14909. -- =============================================
  14910. -- Lucifer 根据caMainID获取限制登陆原因
  14911. -- =============================================
  14912. CREATE PROCEDURE [dbo].[cccpMainByLimitedReasonBycaMainIDSelect]
  14913. (
  14914. @caMainID INT,
  14915. @LimiteReason NVARCHAR(200) OUTPUT
  14916. )
  14917. AS
  14918. SET NOCOUNT ON
  14919. BEGIN
  14920. DECLARE @ConsultantID AS VARCHAR(20)
  14921. DECLARE @ConsultantPhone AS VARCHAR(20)
  14922. DECLARE @cpMainID AS VARCHAR(20)
  14923. SELECT TOP 1 @LimiteReason = VerifyInfo,@ConsultantID = b.ConsultantID,@cpMainID = b.ID FROM bscpStatus a,cpMain b
  14924. WHERE a.cpMainID = b.ID AND a.cpMainID =
  14925. (
  14926. SELECT a.cpMainID
  14927. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  14928. WHERE a.ID = @caMainID
  14929. AND a.cpMainID = b.ID
  14930. AND a.IsDelete = 0
  14931. AND b.IsDelete = 0
  14932. )
  14933. AND StatusID = 9
  14934. ORDER BY AddDate DESC
  14935. IF @ConsultantID IS NULL
  14936. SET @LimiteReason = @LimiteReason + '&lt;br /&gt;如有疑问可在工作时间[周一至周五8:30至17:30]拨打400-626-5151与客服人员取得联系,谢谢合作! 您的会员编号是:' + @cpMainID
  14937. ELSE
  14938. BEGIN
  14939. IF LEFT(@ConsultantID , 1) = '6'
  14940. BEGIN
  14941. SET @ConsultantPhone = '5' + @ConsultantID
  14942. END
  14943. ELSE
  14944. BEGIN
  14945. SET @ConsultantPhone = '6' + @ConsultantID
  14946. END
  14947. SET @LimiteReason = @LimiteReason + '&lt;br /&gt;如有疑问可在工作时间[周一至周五8:30至17:30]拨打400-626-5151转' + @ConsultantPhone +'分机与您的' + @ConsultantID + '号招聘顾问取得联系,谢谢合作! 您的会员编号是:' + @cpMainID
  14948. END
  14949. END
  14950. GO
  14951. /****** Object: StoredProcedure [dbo].[cccpMainByLimitedReasonSelect] Script Date: 2018/12/13 19:06:29 ******/
  14952. SET ANSI_NULLS ON
  14953. GO
  14954. SET QUOTED_IDENTIFIER ON
  14955. GO
  14956. -- =============================================
  14957. -- 修改: mice 2015-3-23 修改顾问的的分机号
  14958. -- 修改:Harry2017-4-21 修改rean长度为400
  14959. -- =============================================
  14960. CREATE PROCEDURE [dbo].[cccpMainByLimitedReasonSelect]
  14961. (
  14962. @UserName VARCHAR(50),
  14963. @Password VARCHAR(50),
  14964. @LimiteReason NVARCHAR(400) OUTPUT
  14965. )
  14966. AS
  14967. SET NOCOUNT ON
  14968. BEGIN
  14969. DECLARE @ConsultantID AS VARCHAR(20)
  14970. DECLARE @ConsultantPhone AS VARCHAR(20)
  14971. DECLARE @cpMainID AS VARCHAR(20)
  14972. SELECT TOP 1 @LimiteReason = VerifyInfo,@ConsultantID = b.ConsultantID,@cpMainID = b.ID FROM bscpStatus a,cpMain b
  14973. WHERE a.cpMainID = b.ID AND a.cpMainID =
  14974. (
  14975. SELECT a.cpMainID
  14976. FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  14977. WHERE a.UserName = @UserName
  14978. AND a.cpMainID = b.ID
  14979. AND a.IsDelete = 0
  14980. AND b.IsDelete = 0
  14981. )
  14982. AND StatusID = 9
  14983. ORDER BY AddDate DESC
  14984. IF @ConsultantID IS NULL
  14985. SET @LimiteReason = @LimiteReason + '<br />如有疑问可在工作时间[周一至周五8:30至17:30]拨打400-626-5151与客服人员取得联系,谢谢合作! 您的会员编号是:' + @cpMainID
  14986. ELSE
  14987. BEGIN
  14988. DECLARE @officeID AS TINYINT
  14989. SELECT @officeID = office FROM ManagerUser WITH(NOLOCK) WHERE ID = @ConsultantID
  14990. IF @officeID = 1
  14991. BEGIN
  14992. SET @ConsultantPhone = '5' + @ConsultantID
  14993. END
  14994. IF @officeID = 2
  14995. BEGIN
  14996. SET @ConsultantPhone = '6' + @ConsultantID
  14997. END
  14998. IF @officeID = 3
  14999. BEGIN
  15000. SET @ConsultantPhone = '7' + @ConsultantID
  15001. END
  15002. IF @officeID = 4
  15003. BEGIN
  15004. SET @ConsultantPhone = '8' + @ConsultantID
  15005. END
  15006. SET @LimiteReason = @LimiteReason + '<br />如有疑问可在工作时间[周一至周五8:30至17:30]拨打400-626-5151转' + @ConsultantPhone +'分机与您的' + @ConsultantID + '号招聘顾问取得联系,谢谢合作! 您的会员编号是:' + @cpMainID
  15007. END
  15008. END
  15009. GO
  15010. /****** Object: StoredProcedure [dbo].[ccCpMainByMapBarIDUpdate] Script Date: 2018/12/13 19:06:29 ******/
  15011. SET ANSI_NULLS ON
  15012. GO
  15013. SET QUOTED_IDENTIFIER ON
  15014. GO
  15015. -- =============================================
  15016. -- Author: Sean
  15017. -- Create date: 2010-10-28
  15018. -- Description: 修改mapBarID
  15019. -- =============================================
  15020. CREATE PROCEDURE [dbo].[ccCpMainByMapBarIDUpdate]
  15021. @ID INT,
  15022. @MapBarID VARCHAR(50)
  15023. AS
  15024. BEGIN
  15025. UPDATE cpMain SET MapBarID=@MapBarID WHERE ID=@ID
  15026. END
  15027. GO
  15028. /****** Object: StoredProcedure [dbo].[cccpMainByMapBarUpdate] Script Date: 2018/12/13 19:06:29 ******/
  15029. SET ANSI_NULLS ON
  15030. GO
  15031. SET QUOTED_IDENTIFIER ON
  15032. GO
  15033. CREATE PROCEDURE [dbo].[cccpMainByMapBarUpdate]
  15034. @Lng VARCHAR(20),
  15035. @Lat VARCHAR(20),
  15036. @cpMainID INT
  15037. AS
  15038. BEGIN
  15039. UPDATE cpMain SET Lng=@Lng,Lat=@Lat WHERE ID=@cpMainID
  15040. END
  15041. GO
  15042. /****** Object: StoredProcedure [dbo].[ccCpMainByNameExist] Script Date: 2018/12/13 19:06:29 ******/
  15043. SET ANSI_NULLS ON
  15044. GO
  15045. SET QUOTED_IDENTIFIER ON
  15046. GO
  15047. --==================================
  15048. --企业名称是否重复
  15049. --检查: sean 2010-10-22
  15050. --0 无企业,>0企业id
  15051. --sean 2011-1-30 一省之内 不能和营业执照审核通过的重名
  15052. --==================================
  15053. CREATE PROCEDURE [dbo].[ccCpMainByNameExist]
  15054. (
  15055. @Name VARCHAR(100),
  15056. @dcProvinceID TINYINT
  15057. )
  15058. AS
  15059. BEGIN TRY
  15060. SET @Name=LTRIM(RTRIM(@Name))
  15061. IF EXISTS(SELECT 'X' FROM Company_Black WITH(NOLOCK) WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)),@Name)>0)
  15062. BEGIN
  15063. UPDATE Company_Black SET RefuseCount = RefuseCount + 1
  15064. WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)),@Name)>0
  15065. RETURN -1 --企业名称在黑名单
  15066. END
  15067. /* DECLARE @cpMainID AS INT
  15068. SELECT @cpMainID = ID FROM cpMain WITH(NOLOCK)
  15069. WHERE Name=@Name
  15070. AND dcProvinceID=@dcProvinceID
  15071. AND IsDelete=0
  15072. AND HasLicence = 1
  15073. IF @cpMainID > 0
  15074. RETURN @cpMainID
  15075. */
  15076. RETURN 0
  15077. END TRY
  15078. BEGIN CATCH
  15079. RETURN 0
  15080. END CATCH
  15081. GO
  15082. /****** Object: StoredProcedure [dbo].[ccCpMainByNameUpdate] Script Date: 2018/12/13 19:06:29 ******/
  15083. SET ANSI_NULLS ON
  15084. GO
  15085. SET QUOTED_IDENTIFIER ON
  15086. GO
  15087. -- =============================================
  15088. -- Author: Sean
  15089. -- Create date: 2010-10-28
  15090. -- Description: 修改企业名称
  15091. -- =============================================
  15092. CREATE PROCEDURE [dbo].[ccCpMainByNameUpdate]
  15093. (
  15094. @caMainID INT,
  15095. @cpMainID INT,
  15096. @Name VARCHAR(100)
  15097. )
  15098. AS
  15099. IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE Id = @cpMainId AND MemberType > 1)
  15100. RETURN -1
  15101. BEGIN TRAN
  15102. BEGIN TRY
  15103. --验证是否是该企业的用户
  15104. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK) WHERE ID = @caMainID AND cpMainID = @cpMainID AND ISDelete = 0 AND AccountType =1)
  15105. GOTO Err1
  15106. --检查新企业名称是否和旧企业名称一致,一致则退出
  15107. DECLARE @NameOld AS VARCHAR(100), @Desc AS NVARCHAR(200)
  15108. SELECT @NameOld = Name FROM cpMain WITH(NOLOCK) WHERE ID=@cpMainID
  15109. IF LTRIM(RTRIM(@Name)) = '' OR LTRIM(RTRIM(@NameOld)) = LTRIM(RTRIM(@Name))
  15110. GOTO ERR2
  15111. IF EXISTS(SELECT 'X' FROM Company_Black WITH(NOLOCK) WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)),@Name)>0)
  15112. BEGIN
  15113. UPDATE Company_Black SET RefuseCount = RefuseCount + 1
  15114. WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)),@Name)>0
  15115. GOTO Err3 --企业名称在黑名单
  15116. END
  15117. IF LTRIM(RTRIM(@NameOld)) <> LTRIM(RTRIM(@Name))
  15118. BEGIN
  15119. UPDATE cpMain SET Name = @Name,LastModifyDate =GETDATE() WHERE ID=@cpMainID
  15120. DELETE FROM bsCpModify WHERE cpMainID=@cpMainID AND Location='a1'
  15121. INSERT INTO bsCpModify (cpMainID,caMainID,Location,ColValue) VALUES(@cpMainID, @caMainID, 'a1',@Name)
  15122. SET @Desc = '修改企业名称:原名称:' + @NameOld + ';新名称:' + @Name
  15123. EXEC ccCaOperationLogInsert @caMainID, 11, @Desc
  15124. END
  15125. END TRY
  15126. BEGIN CATCH
  15127. GOTO ERR
  15128. END CATCH
  15129. COMMIT TRAN
  15130. RETURN 1
  15131. ERR:
  15132. BEGIN
  15133. ROLLBACK TRAN
  15134. RETURN 0
  15135. END
  15136. ERR1:
  15137. BEGIN
  15138. ROLLBACK TRAN
  15139. RETURN -1
  15140. END
  15141. ERR2:
  15142. BEGIN
  15143. ROLLBACK TRAN
  15144. RETURN -2
  15145. END
  15146. ERR3:
  15147. BEGIN
  15148. ROLLBACK TRAN
  15149. RETURN -3
  15150. END
  15151. GO
  15152. /****** Object: StoredProcedure [dbo].[ccCpMainByRefreshDateUpdate] Script Date: 2018/12/13 19:06:30 ******/
  15153. SET ANSI_NULLS ON
  15154. GO
  15155. SET QUOTED_IDENTIFIER ON
  15156. GO
  15157. CREATE PROCEDURE [dbo].[ccCpMainByRefreshDateUpdate]
  15158. (
  15159. @cpMainId INT
  15160. )
  15161. AS
  15162. BEGIN
  15163. IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainId AND RefreshDate < DATEADD(MiNUTE, -60, GETDATE()))
  15164. BEGIN
  15165. UPDATE cpMain SET RefreshDate = GETDATE() WHERE ID = @cpMainId
  15166. UPDATE SearchDb..cpMainHomepageSnapshot SET RefreshDate = GETDATE() WHERE RealCpMainId= @cpMainId
  15167. END
  15168. IF EXISTS(SELECT 'x' FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainId AND Valid = 1 AND RefreshDate < DATEADD(MiNUTE, -60, GETDATE()))
  15169. UPDATE Job SET RefreshDate = GETDATE() WHERE cpMainID = @cpMainId AND Valid = 1
  15170. END
  15171. GO
  15172. /****** Object: StoredProcedure [dbo].[ccCpMainByViewSelect] Script Date: 2018/12/13 19:06:30 ******/
  15173. SET ANSI_NULLS ON
  15174. GO
  15175. SET QUOTED_IDENTIFIER ON
  15176. GO
  15177. CREATE PROCEDURE [dbo].[ccCpMainByViewSelect]
  15178. (
  15179. @ID INT
  15180. )
  15181. AS
  15182. BEGIN
  15183. SELECT a.ID, a.dcProvinceID, a.RegDate, a.RegisterIP, a.RegisterMode, a.AddMan, a.IsDefaultPassword,
  15184. a.Name, a.ShortName, a.dcCompanyKindID, a.dcCompanySizeID, a.dcRegionID,
  15185. dbo.CleanAddress(a.Address, a.dcRegionId) Address,
  15186. a.Zip, a.MapBarID, a.HomePage, a.RealName,
  15187. a.Brief, a.HasLicence, a.HasLogo, a.HasVisual, a.ConsultantID, a.ConsultantDate,
  15188. a.DailyGiftQuota, a.UnlimitedDate, a.BalanceDate, a.Balance, a.ResumeQuota, a.MaxUserNumber,
  15189. a.MaxJobNumber, a.Quality, a.SendFeeCount, a.IsAgent, a.IsLimitLogin, a.Islock, a.IsDelete,
  15190. a.MemberType, a.Description, a.VerifyResult, a.BlockCount, a.VerifyCount, a.LoginCount,
  15191. a.JobNumber, a.ViewNumber, a.RefreshDate, a.LastModifyDate, a.RegCapital, a.dcSubSiteID,
  15192. a.LastLoginDate, a.LastLoginIP, a.Valid, a.PerfectDate, a.Lng, a.Lat, a.SecondId,
  15193. dbo.GetCpIndustry(a.ID) Industry, b.FullName Region, a.ReplyRate, a.InterViewNumber, a.CommentNumber
  15194. FROM cpMain a WITH(NOLOCK INDEX(pk_cpMain))
  15195. LEFT JOIN dcRegion b WITH(NOLOCK) ON a.dcRegionId = b.Id
  15196. WHERE a.ID = @ID
  15197. --AND ID NOT IN(SELECT cpMainID FROM bsJobProblem)
  15198. END
  15199. GO
  15200. /****** Object: StoredProcedure [dbo].[ccCpMainColdInsert] Script Date: 2018/12/13 19:06:31 ******/
  15201. SET ANSI_NULLS ON
  15202. GO
  15203. SET QUOTED_IDENTIFIER ON
  15204. GO
  15205. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  15206. --创建: sean
  15207. --检查: 2010-10-21
  15208. --注册企业用户
  15209. --1、检查黑名单 企业名
  15210. --2、记录黑名单 返回
  15211. --3、检查黑名单 邮箱名
  15212. --4、记录黑名单 返回
  15213. --5、检查企业名重复
  15214. --6、检查email重复, RegisterMode<>!
  15215. --7、注册
  15216. --8、连接地址的来源注册的注册单位
  15217. --9、日报
  15218. --10、Company_Xinxi处理
  15219. --11、分配招聘顾问
  15220. --12、生成session asp处理
  15221. --13、发邮件 asp处理
  15222. --2011-2-10 取消企业名称重复检查,由审核时手工确认
  15223. --密码加密后注册 lambo
  15224. --2015-8-7 harry 增加冷客户id,根据冷客户id,查询到冷客户相关信息后更新到cpmain中
  15225. --2015-8-10 harry 将冷客户的来源地址加到cpmain的备注中
  15226. --2016-03-10 Peter 取消资料转移
  15227. --20181122Sunshine修改后台审核数据(推广注册的不审核)
  15228. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  15229. CREATE PROCEDURE [dbo].[ccCpMainColdInsert]
  15230. (
  15231. @Name VARCHAR(100),
  15232. @Email VARCHAR(50),
  15233. @Username VARCHAR(20),
  15234. @Password VARCHAR(60), --加密后的密码
  15235. @PlainPassword VARCHAR(20), --加密前的明文
  15236. @dcSubSiteID SMALLINT,
  15237. @RegisterIP VARCHAR(31),
  15238. @Url_ID INT,
  15239. @SessionID INT,
  15240. @Cookies VARCHAR(20),
  15241. @cpMainID INT OUTPUT,
  15242. @caMainID INT OUTPUT,
  15243. @Telephone VARCHAR(100),
  15244. @Mobile VARCHAR(20),
  15245. @QQ VARCHAR(13),
  15246. @ID INT
  15247. )
  15248. AS
  15249. SET NOCOUNT ON
  15250. BEGIN
  15251. SET @cpMainID = 0
  15252. SET @caMainID = 0
  15253. SET @Name = LTRIM(RTRIM(@Name))
  15254. DECLARE @dcProvinceID AS TINYINT
  15255. SET @dcProvinceID = LEFT(@dcSubSiteID, 2)
  15256. IF EXISTS(SELECT 'X' FROM Company_Black WITH(NOLOCK) WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)), @Name)>0)
  15257. BEGIN
  15258. UPDATE Company_Black SET RefuseCount = RefuseCount + 1
  15259. WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)), @Name)>0
  15260. GOTO Err1 --企业名称在黑名单
  15261. END
  15262. IF EXISTS(SELECT 'X' FROM Company_Black WITH(NOLOCK) WHERE Email = @Email)
  15263. BEGIN
  15264. UPDATE Company_Black SET RefuseCount = RefuseCount + 1
  15265. WHERE Email = @Email
  15266. GOTO Err2 --邮件在黑名单
  15267. END
  15268. IF dbo.IsEmail(@Email) =0
  15269. GOTO Err2
  15270. IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE UserNameLower = @UserName)
  15271. GOTO Err3 --用户名重复
  15272. IF EXISTS(SELECT 'X' FROM Company_Xinxi WITH(NOLOCK) WHERE UserNameLower = @UserName)
  15273. GOTO Err3 --用户名重复
  15274. --如果是非工作时间,则检查是否有重复注册
  15275. IF(DATEPART(HOUR, GETDATE()) > 17 OR DATEPART(HOUR, GETDATE()) < 8)
  15276. BEGIN
  15277. IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE RegDate > GETDATE()-0.0005 AND Name LIKE '%' + @Name + '%')
  15278. GOTO Err3 --非工作时间,1小时内企业名称重复,认为是恶意注册
  15279. IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE RegDate > GETDATE()-0.000005 AND LastLoginIp = @RegisterIP)
  15280. GOTO Err3 --非工作时间,1小时内注册Ip重复,认为是恶意注册
  15281. IF EXISTS(SELECT 'x' FROM caLoginLog WITH(NOLOCK) WHERE LoginCookies = @Cookies AND cpMainName LIKE '%' + @Name + '%' AND AddDate > GETDATE() - 0.0005)
  15282. GOTO Err3 --非工作时间,1小时内注册Cookies重复,认为是恶意注册
  15283. END
  15284. IF EXISTS(SELECT 'x' FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  15285. WHERE (b.RegisterMode = 0 Or b.RegisterMode = 11)
  15286. AND a.cpMainID = b.ID AND a.Email = @Email
  15287. AND b.Isdelete = 0 AND a.IsDelete = 0 AND a.AccountType = 1)
  15288. GOTO Err5 --Email重复,不是信息员推广的,或者已经审核的
  15289. --###############################3
  15290. --是否应该删除 DELETE cpMain FROM caMain WHERE caMain.cpMainID = cpMain.ID AND RegisterMode = 1 AND caMain.Email = @Email
  15291. --###############################3
  15292. ----检查通过,增加到企业表
  15293. --Harry Begin
  15294. --从冷客户表中获取填写的企业信息
  15295. DECLARE @dcCompanyKindID AS INT,
  15296. @dcCompanySizeID INT,
  15297. @dcIndustryID VARCHAR(50),
  15298. @dcRegionID VARCHAR(6),
  15299. @Address VARCHAR(120),
  15300. @SourceLink VARCHAR(1000),
  15301. @Brief VARCHAR(6000),
  15302. @Phone VARCHAR(50),
  15303. @AddDate DATETIME
  15304. SELECT @dcCompanyKindID = CASE dcCompanyKindID WHEN 0 THEN NULL ELSE dcCompanyKindID END,
  15305. @dcCompanySizeID = dcCompanySizeID, @dcIndustryID = cpIndustry, @dcRegionID = dcRegionID,
  15306. @Address = [Address], @Brief = Brief, @SourceLink = SourceLink, @Phone = Phone, @AddDate = AddDate
  15307. FROM ColdCustomer
  15308. WHERE ID = @ID
  15309. IF ISNULL(@Mobile, '') = '' AND ISNULL(@Telephone, '') = '' AND @Phone > ''
  15310. BEGIN
  15311. IF @Phone LIKE '%/%'
  15312. BEGIN
  15313. SELECT @Telephone = LEFT(@Phone, CHARINDEX('/', @Phone) - 1),
  15314. @Mobile = RIGHT(@Phone, LEN(@Phone) - CHARINDEX('/', @Phone))
  15315. END
  15316. ELSE IF @Phone LIKE '1%'
  15317. SET @Mobile = @Phone
  15318. ELSE IF @Phone LIKE '0%'
  15319. SET @Telephone = @Phone
  15320. END
  15321. SELECT @dcRegionID=ISNULL(@dcRegionID,@dcSubSiteID)
  15322. --Harry END
  15323. DECLARE @CountDate AS INT,
  15324. @IsHistory AS BIT
  15325. SET @CountDate = YEAR(GETDATE())*10000 + MONTH(GETDATE())*100 + DAY(GETDATE())
  15326. SET @Username = LTRIM(RTRIM(@Username))
  15327. BEGIN TRAN
  15328. ----企业表
  15329. INSERT INTO cpMain(dcProvinceID,dcSubSiteID, RegisterIP, Name, RegDate, RegisterMode, RefreshDate, LoginCount, LastLoginDate, LastLoginIP,dcRegionID)
  15330. VALUES(@dcProvinceID, @dcSubSiteID, @RegisterIP, @Name, GETDATE(), 0 , GETDATE(), 1, GETDATE(), @RegisterIP, @dcRegionID)
  15331. SELECT @cpMainID = @@IDENTITY
  15332. --保存所属行业
  15333. DELETE FROM cpIndustry WHERE cpMainID = @cpMainID
  15334. INSERT INTO cpIndustry
  15335. SELECT @cpMainID, a FROM dbo.fnSplit(@dcIndustryID, ' ')
  15336. ----Company_Xinxi处理, 160天内计算工作量,超过160天不计算工作量
  15337. DECLARE @Company_XinxiID AS INT, @AddMan AS SMALLINT, @RegDate AS SMALLDATETIME, @Resume_Xinxi_ProvinceID AS TINYINT
  15338. SELECT @Company_XinxiID = ID, @AddMan = AddMan, @RegDate = RegDate
  15339. FROM Company_Xinxi WITH(NOLOCK)
  15340. WHERE Email = @Email
  15341. AND Province_ID = @dcProvinceID
  15342. AND IsHistory = 0
  15343. ORDER BY RegDate DESC
  15344. ----日报表, 信息员推广过的个人注册,Ishistory=0的作为推广ValIDCompany
  15345. IF @AddMan > 200 AND @AddMan < 500 AND @RegDate > GETDATE() - 30
  15346. BEGIN
  15347. UPDATE cpMain SET AddMan = @AddMan, RegisterMode = 1 WHERE ID = @cpMainID
  15348. ----记录信息员工作量
  15349. ------判断是否有该行记录,没有则增加
  15350. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK) WHERE CountDate = @CountDate AND Province_ID = @dcProvinceID AND InfoManager_ID = @AddMan)
  15351. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, CountDate)
  15352. VALUES(@dcProvinceID, @AddMan, @CountDate)
  15353. ------记录数据,信息员工作量 + 1
  15354. UPDATE Info_DateReport
  15355. SET ValIDCompany = ValIDCompany + 1
  15356. WHERE CountDate = @CountDate
  15357. AND Province_ID = @dcProvinceID
  15358. AND InfoManager_ID = @AddMan
  15359. END
  15360. DELETE Company_Xinxi WHERE Email = @Email
  15361. ----账号表
  15362. INSERT INTO caMain(cpMainID, EMail, AccountType, UserName, Password, Telephone, Mobile, QQ)
  15363. VALUES(@cpMainID, @EMail, 1, @UserName, @Password, @Telephone, @Mobile, @QQ)
  15364. SELECT TOP 1 @caMainID = ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID
  15365. INSERT INTO caPlainPassword(caMainId, PlainPassWord) SELECT @caMainID, @PlainPassword
  15366. --企业注册数量+1
  15367. UPDATE DateReport
  15368. SET CompanyRegNum = CompanyRegNum + 1
  15369. WHERE CountDate = @CountDate
  15370. AND Province_ID = @dcSubSiteID
  15371. --INSERT INTO pamainDatereport SELECT @cpMainID, 1, GETDATE() -- SEAN 20130911
  15372. ----后台审核--20181122Sunshien修改
  15373. IF NOT EXISTS(SELECT TOP 1 'X' FROM ColdCustomer WITH(NOLOCK) WHERE CpMainID = @cpMainID AND AddMan IS NOT NULL)
  15374. BEGIN
  15375. INSERT INTO bsCpModify (cpMainID, caMainID, Location, ColValue) VALUES(@cpMainID, @caMainID, 'a1', @Name)
  15376. END
  15377. ----顾问分配
  15378. EXEC ccCpMainByConsultantAssignUpdate @cpMainID, @dcProvinceID
  15379. ----单点登录用
  15380. DELETE FROM cpSession WHERE caMainID = @caMainID
  15381. INSERT INTO cpSession(SessionID, caMainID, IP, Cookies) VALUES(@SessionID, @caMainID, @RegisterIP, @Cookies)
  15382. ----注册算一次登录
  15383. INSERT INTO caLoginLog(caMainID, cpMainName, caMainName, LoginIP, LoginCookies, Browser)
  15384. VALUES(@caMainID, @Name, LEFT(@Username, 20), @RegisterIP, '注册登录', '3:')
  15385. COMMIT TRAN
  15386. RETURN 1
  15387. END
  15388. ERR: --未知错误
  15389. BEGIN
  15390. RETURN 0
  15391. END
  15392. Err1: --企业名称在黑名单
  15393. BEGIN
  15394. RETURN -1
  15395. END
  15396. Err2: --邮件在黑名单
  15397. BEGIN
  15398. RETURN -2
  15399. END
  15400. Err3: --用户名重复
  15401. BEGIN
  15402. RETURN -3
  15403. END
  15404. Err4: --企业名称重复
  15405. BEGIN
  15406. RETURN -4
  15407. END
  15408. Err5: --Email重复,信息员推广的,并且没有审核的
  15409. BEGIN
  15410. RETURN -5
  15411. END
  15412. Err6: --注册时的错误
  15413. BEGIN
  15414. ROLLBACK TRAN
  15415. RETURN -6
  15416. END
  15417. GO
  15418. /****** Object: StoredProcedure [dbo].[ccCpMainColdInsert1009] Script Date: 2018/12/13 19:06:31 ******/
  15419. SET ANSI_NULLS ON
  15420. GO
  15421. SET QUOTED_IDENTIFIER ON
  15422. GO
  15423. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  15424. --创建: sean
  15425. --检查: 2010-10-21
  15426. --注册企业用户
  15427. --1、检查黑名单 企业名
  15428. --2、记录黑名单 返回
  15429. --3、检查黑名单 邮箱名
  15430. --4、记录黑名单 返回
  15431. --5、检查企业名重复
  15432. --6、检查email重复, RegisterMode<>!
  15433. --7、注册
  15434. --8、连接地址的来源注册的注册单位
  15435. --9、日报
  15436. --10、Company_Xinxi处理
  15437. --11、分配招聘顾问
  15438. --12、生成session asp处理
  15439. --13、发邮件 asp处理
  15440. --2011-2-10 取消企业名称重复检查,由审核时手工确认
  15441. --密码加密后注册 lambo
  15442. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  15443. CREATE PROCEDURE [dbo].[ccCpMainColdInsert1009]
  15444. (
  15445. @Name VARCHAR(100),
  15446. @Email VARCHAR(50),
  15447. @Username VARCHAR(20),
  15448. @Password VARCHAR(60), --加密后的密码
  15449. @PlainPassword VARCHAR(20), --加密前的明文
  15450. @dcSubSiteID SMALLINT,
  15451. @RegisterIP VARCHAR(31),
  15452. @Url_ID INT,
  15453. @SessionID INT,
  15454. @Cookies VARCHAR(20),
  15455. @cpMainID INT OUTPUT,
  15456. @caMainID INT OUTPUT,
  15457. @Telephone VARCHAR(100),
  15458. @Mobile VARCHAR(20)
  15459. )
  15460. AS
  15461. --BEGIN TRY
  15462. SET @cpMainID = 0
  15463. SET @caMainID = 0
  15464. SET @Name = LTRIM(RTRIM(@Name))
  15465. DECLARE @dcProvinceID AS TINYINT
  15466. SET @dcProvinceID = LEFT(@dcSubSiteID, 2)
  15467. IF EXISTS(SELECT 'X' FROM Company_Black WITH(NOLOCK) WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)), @Name)>0)
  15468. BEGIN
  15469. UPDATE Company_Black SET RefuseCount = RefuseCount + 1
  15470. WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)), @Name)>0
  15471. GOTO Err1 --企业名称在黑名单
  15472. END
  15473. IF EXISTS(SELECT 'X' FROM Company_Black WITH(NOLOCK) WHERE Email = @Email)
  15474. BEGIN
  15475. UPDATE Company_Black SET RefuseCount = RefuseCount + 1
  15476. WHERE Email = @Email
  15477. GOTO Err2 --邮件在黑名单
  15478. END
  15479. IF dbo.IsEmail(@Email) =0
  15480. GOTO Err2
  15481. IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE UserNameLower = @UserName)
  15482. GOTO Err3 --用户名重复
  15483. IF EXISTS(SELECT 'X' FROM Company_Xinxi WITH(NOLOCK) WHERE UserNameLower = @UserName)
  15484. GOTO Err3 --用户名重复
  15485. /* IF EXISTS(SELECT 'X' FROM cpMain WITH(NOLOCK) WHERE Name = @Name AND dcProvinceID = @dcProvinceID AND IsDelete = 0)
  15486. GOTO Err4 --企业名称重复
  15487. IF EXISTS(SELECT 'X' FROM cpMainLimited WITH(NOLOCK) WHERE CompanyName = @Name)
  15488. GOTO Err3 --近期删除的企业名称重复,属于类似黑名单
  15489. IF EXISTS(SELECT 'X' FROM cpMainLimited WITH(NOLOCK) WHERE LoginIp = @RegisterIp AND LoginCookies = @Cookies)
  15490. GOTO Err3 --近期删除的企业名称重复,属于类似黑名单
  15491. IF EXISTS(SELECT 'X' FROM cpMainLimited WITH(NOLOCK) WHERE (LoginIp = @RegisterIp OR LoginCookies = @Cookies) AND CHARINDEX(CompanyName, @Name) > 0)
  15492. GOTO Err3 --近期删除的企业名称重复,属于类似黑名单
  15493. */
  15494. --如果是非工作时间,则检查是否有重复注册
  15495. IF(DATEPART(HOUR, GETDATE()) > 17 OR DATEPART(HOUR, GETDATE()) < 8)
  15496. BEGIN
  15497. IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE RegDate > GETDATE()-0.0005 AND Name LIKE '%' + @Name + '%')
  15498. GOTO Err3 --非工作时间,1小时内企业名称重复,认为是恶意注册
  15499. IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE RegDate > GETDATE()-0.000005 AND LastLoginIp = @RegisterIP)
  15500. GOTO Err3 --非工作时间,1小时内注册Ip重复,认为是恶意注册
  15501. IF EXISTS(SELECT 'x' FROM caLoginLog WITH(NOLOCK) WHERE LoginCookies = @Cookies AND cpMainName LIKE '%' + @Name + '%' AND AddDate > GETDATE() - 0.0005)
  15502. GOTO Err3 --非工作时间,1小时内注册Cookies重复,认为是恶意注册
  15503. END
  15504. IF EXISTS(SELECT 'x' FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  15505. WHERE (b.RegisterMode = 0 Or b.RegisterMode = 11)
  15506. AND a.cpMainID = b.ID AND a.Email = @Email
  15507. AND b.Isdelete = 0 AND a.IsDelete = 0 AND a.AccountType = 1)
  15508. GOTO Err5 --Email重复,不是信息员推广的,或者已经审核的
  15509. --###############################3
  15510. --是否应该删除 DELETE cpMain FROM caMain WHERE caMain.cpMainID = cpMain.ID AND RegisterMode = 1 AND caMain.Email = @Email
  15511. --###############################3
  15512. ----检查通过,增加到企业表
  15513. DECLARE @CountDate AS INT,
  15514. @IsHistory AS BIT
  15515. SET @CountDate = YEAR(GETDATE())*10000 + MONTH(GETDATE())*100 + DAY(GETDATE())
  15516. SET @Username = LTRIM(RTRIM(@Username))
  15517. BEGIN TRAN
  15518. -- BEGIN TRY
  15519. ----企业表
  15520. INSERT INTO cpMain(dcProvinceID, dcRegionID, dcSubSiteID, RegisterIP, Name, RegDate, RegisterMode, RefreshDate, LoginCount, LastLoginDate, LastLoginIP)
  15521. VALUES(@dcProvinceID, @dcSubSiteID, @dcSubSiteID, @RegisterIP, @Name, GETDATE(), 0 , GETDATE(), 1, GETDATE(), @RegisterIP)
  15522. SELECT @cpMainID = @@IDENTITY
  15523. ----Company_Xinxi处理, 160天内计算工作量,超过160天不计算工作量
  15524. DECLARE @Company_XinxiID AS INT,
  15525. @AddMan AS SMALLINT,
  15526. @RegDate AS SMALLDATETIME,
  15527. @Resume_Xinxi_ProvinceID AS TINYINT
  15528. SELECT @Company_XinxiID = ID, @AddMan = AddMan, @RegDate = RegDate,
  15529. @IsHistory = IsHistory
  15530. FROM Company_Xinxi WITH(NOLOCK)
  15531. WHERE Email = @Email
  15532. AND Province_ID = @dcProvinceID
  15533. ORDER BY IsHistory, RegDate DESC
  15534. ----账号表
  15535. INSERT INTO caMain(cpMainID, EMail, AccountType, UserName, Password,Telephone,Mobile)
  15536. VALUES(@cpMainID, @EMail, 1, @UserName, @Password,@Telephone,@Mobile)
  15537. SELECT TOP 1 @caMainID = ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID
  15538. INSERT INTO caPlainPassword(caMainId, PlainPassWord) SELECT @caMainID, @PlainPassword
  15539. ----日报表, 信息员推广过的个人注册,Ishistory=0的作为推广ValIDCompany
  15540. IF @Company_XinxiID IS NOT NULL AND @AddMan > 1 AND @Ishistory = 0
  15541. BEGIN
  15542. UPDATE cpMain SET AddMan = @AddMan, RegisterMode = 1 WHERE ID = @cpMainID
  15543. ----记录信息员工作量
  15544. ------判断是否有该行记录,没有则增加
  15545. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK) WHERE CountDate = @CountDate AND Province_ID = @dcProvinceID AND InfoManager_ID = @AddMan)
  15546. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, CountDate)
  15547. VALUES(@dcProvinceID, @AddMan, @CountDate)
  15548. ------记录数据,信息员工作量 + 1
  15549. UPDATE Info_DateReport
  15550. SET ValIDCompany = ValIDCompany + 1
  15551. WHERE CountDate = @CountDate
  15552. AND Province_ID = @dcProvinceID
  15553. AND InfoManager_ID = @AddMan
  15554. -----推广的企业数量+1
  15555. UPDATE DateReport
  15556. SET ValidCompany = ValidCompany + 1
  15557. WHERE CountDate = @CountDate
  15558. AND Province_ID = @dcSubSiteID
  15559. --INSERT INTO pamainDatereport SELECT @cpMainID, 8, GETDATE() -- SEAN 20130911
  15560. END
  15561. ELSE
  15562. BEGIN
  15563. --企业注册数量+1
  15564. UPDATE DateReport
  15565. SET CompanyRegNum = CompanyRegNum + 1
  15566. WHERE CountDate = @CountDate
  15567. AND Province_ID = @dcSubSiteID
  15568. --INSERT INTO pamainDatereport SELECT @cpMainID, 1, GETDATE() -- SEAN 20130911
  15569. END
  15570. ----连接地址的来源注册的注册单位
  15571. IF @Url_ID > 0
  15572. UPDATE Url
  15573. SET AllCompany = AllCompany + 1, TodayCompany = TodayCompany + 1
  15574. WHERE ID = @Url_ID
  15575. ----后台审核
  15576. INSERT INTO bsCpModify (cpMainID, caMainID, Location, ColValue) VALUES(@cpMainID, @caMainID, 'a1', @Name)
  15577. ----顾问分配
  15578. EXEC ccCpMainByConsultantAssignUpdate @cpMainID, @dcProvinceID
  15579. ----单点登录用
  15580. DELETE FROM cpSession WHERE caMainID = @caMainID
  15581. INSERT INTO cpSession(SessionID, caMainID, IP, Cookies) VALUES(@SessionID, @caMainID, @RegisterIP, @Cookies)
  15582. ----注册算一次登录
  15583. INSERT INTO caLoginLog(caMainID, cpMainName, caMainName, LoginIP, LoginCookies, Browser)
  15584. VALUES(@caMainID, @Name, LEFT(@Username, 20), @RegisterIP, '注册登录', '3:')
  15585. -- END TRY
  15586. -- BEGIN CATCH
  15587. -- GOTO Err6
  15588. -- END CATCH
  15589. COMMIT TRAN
  15590. RETURN 1
  15591. --END TRY
  15592. --BEGIN CATCH
  15593. -- GOTO ERR
  15594. --END CATCH
  15595. ERR: --未知错误
  15596. BEGIN
  15597. RETURN 0
  15598. END
  15599. Err1: --企业名称在黑名单
  15600. BEGIN
  15601. RETURN -1
  15602. END
  15603. Err2: --邮件在黑名单
  15604. BEGIN
  15605. RETURN -2
  15606. END
  15607. Err3: --用户名重复
  15608. BEGIN
  15609. RETURN -3
  15610. END
  15611. Err4: --企业名称重复
  15612. BEGIN
  15613. RETURN -4
  15614. END
  15615. Err5: --Email重复,信息员推广的,并且没有审核的
  15616. BEGIN
  15617. RETURN -5
  15618. END
  15619. Err6: --注册时的错误
  15620. BEGIN
  15621. ROLLBACK TRAN
  15622. RETURN -6
  15623. END
  15624. GO
  15625. /****** Object: StoredProcedure [dbo].[ccCpMainInsert] Script Date: 2018/12/13 19:06:31 ******/
  15626. SET ANSI_NULLS ON
  15627. GO
  15628. SET QUOTED_IDENTIFIER ON
  15629. GO
  15630. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  15631. --创建: Lucifer
  15632. --检查: 2013-10-9
  15633. --注册企业用户
  15634. --1、检查黑名单 企业名
  15635. --2、记录黑名单 返回
  15636. --3、检查黑名单 邮箱名
  15637. --4、记录黑名单 返回
  15638. --5、检查企业名重复
  15639. --6、检查email重复, RegisterMode<>!
  15640. --7、注册
  15641. --8、连接地址的来源注册的注册单位
  15642. --9、日报
  15643. --10、Company_Xinxi处理
  15644. --11、分配招聘顾问
  15645. --12、生成session asp处理
  15646. --13、发邮件 asp处理
  15647. -- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  15648. CREATE PROCEDURE [dbo].[ccCpMainInsert]
  15649. (
  15650. @Name VARCHAR(100),
  15651. @Email VARCHAR(50),
  15652. @Username VARCHAR(20),
  15653. @Password VARCHAR(60), --加密后的密码
  15654. @PlainPassword VARCHAR(20), --加密前的明文
  15655. @CaName NVARCHAR(6),
  15656. @Mobile VARCHAR(11),
  15657. @Telephone VARCHAR(25),
  15658. @dcSubSiteID SMALLINT,
  15659. @RegisterIP VARCHAR(31),
  15660. @Url_ID INT,
  15661. @SessionID INT,
  15662. @Cookies VARCHAR(20),
  15663. @cpMainID INT OUTPUT,
  15664. @caMainID INT OUTPUT
  15665. )
  15666. AS
  15667. SET NOCOUNT ON
  15668. --IF CHARINDEX(',', @RegisterIP) > 0
  15669. --SET @RegisterIP = RIGHT(@RegisterIP, LEN(@RegisterIP)- CHARINDEX(',', @RegisterIP))
  15670. IF EXISTS(SELECT 'x' FROM Ip_Black WITH(NOLOCK) WHERE Ip = @RegisterIP)
  15671. RETURN 0
  15672. IF CHARINDEX(',113.248.157.168', @RegisterIP) > 0
  15673. RETURN 0
  15674. BEGIN
  15675. SET @cpMainID = 0
  15676. SET @caMainID = 0
  15677. DECLARE @dcProvinceID AS TINYINT
  15678. SET @dcProvinceID = LEFT(@dcSubSiteID, 2)
  15679. --IF @dcProvinceId = 42
  15680. -- SET @Name = REPLACE(REPLACE(@Name, ' ', ''), '', '')
  15681. --IF @dcProvinceId = 41 AND @CaName = '王林'
  15682. -- GOTO Err3
  15683. SET @Name = LTRIM(RTRIM(@Name))
  15684. --IF @dcProvinceID = 42 AND CHARINDEX('公司', @Name) = 0 AND LEN(@Name) > 4
  15685. -- GOTO Err3
  15686. --IF EXISTS(SELECT 'X' FROM Company_Black WITH(NOLOCK) WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)), @Name)>0)
  15687. IF EXISTS(SELECT 'X' FROM Company_Black WITH(NOLOCK) WHERE CompanyName > ' ' AND CHARINDEX(LTRIM(RTRIM(CompanyName)), @Name)>0)
  15688. BEGIN
  15689. UPDATE Company_Black SET RefuseCount = RefuseCount + 1
  15690. WHERE CHARINDEX(LTRIM(RTRIM(CompanyName)), @Name)>0
  15691. GOTO Err1 --企业名称在黑名单
  15692. END
  15693. IF EXISTS(SELECT 'X' FROM Company_Black WITH(NOLOCK) WHERE Email = @Email)
  15694. BEGIN
  15695. UPDATE Company_Black SET RefuseCount = RefuseCount + 1
  15696. WHERE Email = @Email
  15697. GOTO Err2 --邮件在黑名单
  15698. END
  15699. IF dbo.IsEmail(@Email) =0
  15700. GOTO Err2
  15701. IF EXISTS(SELECT 'X' FROM caMain WITH(NOLOCK) WHERE UserNameLower = @UserName)
  15702. GOTO Err3 --用户名重复
  15703. IF EXISTS(SELECT 'X' FROM Company_Xinxi WITH(NOLOCK) WHERE UserNameLower = @UserName)
  15704. GOTO Err3 --用户名重复
  15705. /* IF EXISTS(SELECT 'X' FROM cpMain WITH(NOLOCK) WHERE Name = @Name AND dcProvinceID = @dcProvinceID AND IsDelete = 0)
  15706. GOTO Err4 --企业名称重复
  15707. IF EXISTS(SELECT 'X' FROM cpMainLimited WITH(NOLOCK) WHERE CompanyName = @Name)
  15708. GOTO Err3 --近期删除的企业名称重复,属于类似黑名单
  15709. IF EXISTS(SELECT 'X' FROM cpMainLimited WITH(NOLOCK) WHERE LoginIp = @RegisterIp AND LoginCookies = @Cookies)
  15710. GOTO Err3 --近期删除的企业名称重复,属于类似黑名单
  15711. IF EXISTS(SELECT 'X' FROM cpMainLimited WITH(NOLOCK) WHERE (LoginIp = @RegisterIp OR LoginCookies = @Cookies) AND CHARINDEX(CompanyName, @Name) > 0)
  15712. GOTO Err3 --近期删除的企业名称重复,属于类似黑名单
  15713. */
  15714. --如果是非工作时间,则检查是否有重复注册
  15715. IF(DATEPART(HOUR, GETDATE()) > 17 OR DATEPART(HOUR, GETDATE()) < 8)
  15716. BEGIN
  15717. IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE RegDate > DATEADD(MINUTE, -10, GETDATE()) AND Name LIKE '%' + @Name + '%')
  15718. GOTO Err3 --非工作时间,1小时内企业名称重复,认为是恶意注册
  15719. IF EXISTS(SELECT 'x' FROM cpMain WITH(NOLOCK) WHERE RegDate > DATEADD(MINUTE, -3, GETDATE()) AND LastLoginIp = @RegisterIP)
  15720. GOTO Err3 --非工作时间,1小时内注册Ip重复,认为是恶意注册
  15721. IF EXISTS(SELECT 'x' FROM caLoginLog WITH(NOLOCK) WHERE LoginCookies = @Cookies AND cpMainName LIKE '%' + @Name + '%' AND AddDate > DATEADD(MINUTE, -20, GETDATE()))
  15722. GOTO Err3 --非工作时间,1小时内注册Cookies重复,认为是恶意注册
  15723. END
  15724. IF (SELECT COUNT(*) FROM cpMain WITH(NOLOCK) WHERE RegDate > DATEADD(MINUTE, -3, GETDATE()) AND LastLoginIp = @RegisterIP) > 3
  15725. GOTO Err3 --非工作时间,1小时内注册Ip重复,认为是恶意注册
  15726. IF EXISTS (SELECT 'x' FROM Tmp_limitip WITH(NOLOCK) WHERE LastLoginIp = @RegisterIP)
  15727. GOTO Err3 --非工作时间,1小时内注册Ip重复,认为是恶意注册
  15728. -- IF CHARINDEX('公司', @Name) = 0 AND @DcProvinceId = 42
  15729. -- BEGIN
  15730. -- DECLARE @NameLeft AS VARCHAR(10), @NameRight AS VARCHAR(10)
  15731. -- IF LEN(@Name) > 8
  15732. -- SELECT @NameRight = RIGHT(@Name, 4), @NameLeft = LEFT(@Name, 4)
  15733. -- ELSE
  15734. -- SELECT @NameRight = RIGHT(@Name, 3), @NameLeft = LEFT(@Name, 3)
  15735. -- IF (SELECT COUNT(*) FROM (SELECT TOP 10 Name FROM cpMain WITH(NOLOCK) WHERE dcProvinceId = @dcProvinceId ORDER BY Id DESC) a WHERE CHARINDEX(@NameRight, Name) > 0) > 1
  15736. -- GOTO Err3
  15737. -- IF (SELECT COUNT(*) FROM (SELECT TOP 10 Name FROM cpMain WITH(NOLOCK) WHERE dcProvinceId = @dcProvinceId ORDER BY Id DESC) a WHERE CHARINDEX(@NameLeft, Name) > 0) > 1
  15738. -- GOTO Err3
  15739. -- END
  15740. IF EXISTS(SELECT 'x' FROM caMain a WITH(NOLOCK), cpMain b WITH(NOLOCK)
  15741. WHERE (b.RegisterMode = 0 Or b.RegisterMode = 11)
  15742. AND a.cpMainID = b.ID AND a.Email = @Email
  15743. AND b.Isdelete = 0 AND a.IsDelete = 0 AND a.AccountType = 1)
  15744. GOTO Err5 --Email重复,不是信息员推广的,或者已经审核的
  15745. --###############################3
  15746. --是否应该删除 DELETE cpMain FROM caMain WHERE caMain.cpMainID = cpMain.ID AND RegisterMode = 1 AND caMain.Email = @Email
  15747. --###############################3
  15748. ----检查通过,增加到企业表
  15749. DECLARE @CountDate AS INT,
  15750. @IsHistory AS BIT
  15751. SET @CountDate = YEAR(GETDATE())*10000 + MONTH(GETDATE())*100 + DAY(GETDATE())
  15752. SET @Username = LTRIM(RTRIM(@Username))
  15753. BEGIN TRAN
  15754. -- BEGIN TRY
  15755. ----企业表
  15756. INSERT INTO cpMain(dcProvinceID, dcRegionID, dcSubSiteID, RegisterIP, Name, RegDate, RegisterMode, RefreshDate, LoginCount, LastLoginDate, LastLoginIP)
  15757. VALUES(@dcProvinceID, @dcSubSiteID, @dcSubSiteID, @RegisterIP, @Name, GETDATE(), 0 , GETDATE(), 1, GETDATE(), @RegisterIP)
  15758. SELECT @cpMainID = @@IDENTITY
  15759. ----Company_Xinxi处理, 160天内计算工作量,超过160天不计算工作量
  15760. DECLARE @Company_XinxiID AS INT,
  15761. @AddMan AS SMALLINT,
  15762. @RegDate AS SMALLDATETIME,
  15763. @Resume_Xinxi_ProvinceID AS TINYINT
  15764. SELECT @Company_XinxiID = ID, @AddMan = AddMan, @RegDate = RegDate,
  15765. @IsHistory = IsHistory
  15766. FROM Company_Xinxi WITH(NOLOCK)
  15767. WHERE Email = @Email
  15768. AND Province_ID = @dcProvinceID
  15769. ORDER BY IsHistory, RegDate DESC
  15770. ----账号表
  15771. INSERT INTO caMain(cpMainID, EMail, AccountType, UserName, Password, Name, Mobile, Telephone)
  15772. VALUES(@cpMainID, @EMail, 1, @UserName, @Password, @CaName, @Mobile, @Telephone)
  15773. SELECT TOP 1 @caMainID = ID FROM caMain WITH(NOLOCK) WHERE cpMainID = @cpMainID
  15774. INSERT INTO caPlainPassword(caMainId, PlainPassWord) SELECT @caMainID, @PlainPassword
  15775. IF EXISTS(SELECT TOP 1 'X' FROM caVerifyLog WHERE VerifyDate > DATEAdd(n, -1, GETDATE()) AND Mobile = @Mobile)
  15776. UPDATE caMain SET MobileVerifyDate = GETDATE() WHERE ID = @caMainID
  15777. ----日报表, 信息员推广过的个人注册,Ishistory=0的作为推广ValIDCompany
  15778. IF @Company_XinxiID IS NOT NULL AND @AddMan > 1 AND @Ishistory = 0
  15779. BEGIN
  15780. UPDATE cpMain SET AddMan = @AddMan, RegisterMode = 1 WHERE ID = @cpMainID
  15781. ----记录信息员工作量
  15782. ------判断是否有该行记录,没有则增加
  15783. IF NOT EXISTS(SELECT 'x' FROM Info_DateReport WITH(NOLOCK) WHERE CountDate = @CountDate AND Province_ID = @dcProvinceID AND InfoManager_ID = @AddMan)
  15784. INSERT INTO Info_DateReport(Province_ID, InfoManager_ID, CountDate)
  15785. VALUES(@dcProvinceID, @AddMan, @CountDate)
  15786. ------记录数据,信息员工作量 + 1
  15787. UPDATE Info_DateReport
  15788. SET ValIDCompany = ValIDCompany + 1
  15789. WHERE CountDate = @CountDate
  15790. AND Province_ID = @dcProvinceID
  15791. AND InfoManager_ID = @AddMan
  15792. -----推广的企业数量+1
  15793. UPDATE DateReport
  15794. SET ValidCompany = ValidCompany + 1
  15795. WHERE CountDate = @CountDate
  15796. AND Province_ID = @dcSubSiteID
  15797. --INSERT INTO pamainDatereport SELECT @cpMainID, 8, GETDATE() -- SEAN 20130911
  15798. END
  15799. ELSE
  15800. BEGIN
  15801. --企业注册数量+1
  15802. UPDATE DateReport
  15803. SET CompanyRegNum = CompanyRegNum + 1
  15804. WHERE CountDate = @CountDate
  15805. AND Province_ID = @dcSubSiteID
  15806. --INSERT INTO pamainDatereport SELECT @cpMainID, 1, GETDATE() -- SEAN 20130911
  15807. END
  15808. ----连接地址的来源注册的注册单位
  15809. IF @Url_ID > 0
  15810. BEGIN
  15811. UPDATE Url
  15812. SET AllCompany = AllCompany + 1, TodayCompany = TodayCompany + 1
  15813. WHERE ID = @Url_ID
  15814. UPDATE cpMain SET RegisterSourceId = @Url_Id WHERE ID = @cpMainID
  15815. END
  15816. INSERT INTO bsCpModify (cpMainID, caMainID, Location, ColValue) VALUES(@cpMainID, @caMainID, 'a1', @Name)
  15817. ----顾问分配
  15818. EXEC ccCpMainByConsultantAssignUpdate @cpMainID, @dcProvinceID
  15819. ----单点登录用
  15820. DELETE FROM cpSession WHERE caMainID = @caMainID
  15821. INSERT INTO cpSession(SessionID, caMainID, IP, Cookies) VALUES(@SessionID, @caMainID, @RegisterIP, @Cookies)
  15822. ----注册算一次登录
  15823. INSERT INTO caLoginLog(caMainID, cpMainName, caMainName, LoginIP, LoginCookies, Browser)
  15824. VALUES(@caMainID, @Name, @CaName, @RegisterIP, '注册登录', '3:')
  15825. -- END TRY
  15826. -- BEGIN CATCH
  15827. -- GOTO Err6
  15828. -- END CATCH
  15829. COMMIT TRAN
  15830. RETURN 1
  15831. END
  15832. ERR: --未知错误
  15833. BEGIN
  15834. RETURN 0
  15835. END
  15836. Err1: --企业名称在黑名单
  15837. BEGIN
  15838. RETURN -1
  15839. END
  15840. Err2: --邮件在黑名单
  15841. BEGIN
  15842. RETURN -2
  15843. END
  15844. Err3: --用户名重复
  15845. BEGIN
  15846. RETURN -3
  15847. END
  15848. Err4: --企业名称重复
  15849. BEGIN
  15850. RETURN -4
  15851. END
  15852. Err5: --Email重复,信息员推广的,并且没有审核的
  15853. BEGIN
  15854. RETURN -5
  15855. END
  15856. Err6: --注册时的错误
  15857. BEGIN
  15858. ROLLBACK TRAN
  15859. RETURN -6
  15860. END
  15861. GO
  15862. /****** Object: StoredProcedure [dbo].[ccCpMainMapBarIDUpdate] Script Date: 2018/12/13 19:06:32 ******/
  15863. SET ANSI_NULLS ON
  15864. GO
  15865. SET QUOTED_IDENTIFIER ON
  15866. GO
  15867. -- =============================================
  15868. -- Author: <Author,,Name>
  15869. -- Create date: <Create Date,,>
  15870. -- Description: <Description,,>
  15871. -- =============================================
  15872. CREATE PROCEDURE [dbo].[ccCpMainMapBarIDUpdate]
  15873. @ID INT,
  15874. @MapBarID VARCHAR(50)
  15875. AS
  15876. BEGIN
  15877. UPDATE cpMain SET MapBarID=@MapBarID WHERE ID=@ID
  15878. END
  15879. GO
  15880. /****** Object: StoredProcedure [dbo].[ccCpMainPublishSelect] Script Date: 2018/12/13 19:06:32 ******/
  15881. SET ANSI_NULLS ON
  15882. GO
  15883. SET QUOTED_IDENTIFIER ON
  15884. GO
  15885. --#####################################################
  15886. --ccCpMainPublishSelect
  15887. --创建时间:2014.10.30
  15888. --创建人:Nick
  15889. --说明:获取想同地区,同一行业的其他公司的名称
  15890. --#####################################################*/
  15891. CREATE PROCEDURE [dbo].[ccCpMainPublishSelect]
  15892. (
  15893. @dcRegionId INT,
  15894. @dcIndustryId INT,
  15895. @cpMainId INT
  15896. )
  15897. AS
  15898. SET NOCOUNT ON
  15899. BEGIN
  15900. IF @dcRegionId > 9999
  15901. SET @dcRegionId = LEFT(@dcRegionId, 4)
  15902. IF @dcRegionId LIKE '32%'
  15903. SELECT SecondId AS Id, Name, LogoFile LogoUrl
  15904. FROM SearchDb..CpMainSameIndustry32 WITH(NOLOCK)
  15905. WHERE --dcRegionId = @dcRegionId AND
  15906. dcIndustryId = @dcIndustryId
  15907. --AND RealId != @cpmainId
  15908. ORDER BY Row
  15909. ELSE
  15910. SELECT SecondId AS Id, Name, LogoFile LogoUrl
  15911. FROM SearchDb..CpMainSameIndustry WITH(NOLOCK)
  15912. WHERE dcRegionId = @dcRegionId
  15913. AND dcIndustryId = @dcIndustryId
  15914. --AND RealId != @cpmainId
  15915. ORDER BY Row
  15916. END
  15917. GO
  15918. /****** Object: StoredProcedure [dbo].[ccCpMainSelect] Script Date: 2018/12/13 19:06:32 ******/
  15919. SET ANSI_NULLS ON
  15920. GO
  15921. SET QUOTED_IDENTIFIER ON
  15922. GO
  15923. --修改harry 增加 是否为职位刷新数老用户2017-10-19
  15924. CREATE PROCEDURE [dbo].[ccCpMainSelect]
  15925. @ID INT
  15926. AS
  15927. BEGIN
  15928. SET NOCOUNT ON
  15929. SELECT a.*, dbo.GetCpIndustry(a.ID) Industry, dbo.GetCpIndustryId(a.ID) dcIndustryID, b.Mobile, CASE WHEN EXISTS(SELECT 'X' FROM JobRefreshOldCompany WITH(NOLOCK) WHERE cpMainId = @ID) THEN 1 ELSE 0 END AS IsJobRefreshOldCompany,
  15930. c.[Description] CompanyKind, d.[Description] CompanySize, e.FullName Region
  15931. FROM cpMain a WITH(NOLOCK)
  15932. LEFT JOIN Manageruser b WITH(NOLOCK) ON a.ConsultantId = b.ID
  15933. LEFT JOIN dcCompanyKind c WITH(NOLOCK) ON a.dcCompanyKindId = c.ID
  15934. LEFT JOIN dcCompanySize d WITH(NOLOCK) ON a.dcCompanySizeId = d.ID
  15935. LEFT JOIN dcRegion e WITH(NOLOCK) ON a.dcRegionId = e.ID
  15936. WHERE a.ID = @ID
  15937. SET NOCOUNT OFF
  15938. END
  15939. GO
  15940. /****** Object: StoredProcedure [dbo].[ccCpMainUnLimitedDateUpdate] Script Date: 2018/12/13 19:06:33 ******/
  15941. SET ANSI_NULLS ON
  15942. GO
  15943. SET QUOTED_IDENTIFIER ON
  15944. GO
  15945. CREATE PROCEDURE [dbo].[ccCpMainUnLimitedDateUpdate]
  15946. (
  15947. @ID INT,
  15948. @UnLimitedDate VARCHAR(20),
  15949. @ResumeQuota SMALLINT
  15950. )
  15951. AS
  15952. BEGIN
  15953. UPDATE cpMain SET UnLimitedDate=@UnLimitedDate,ResumeQuota=@ResumeQuota WHERE ID = @ID
  15954. END
  15955. GO
  15956. /****** Object: StoredProcedure [dbo].[ccCpMainUpdate] Script Date: 2018/12/13 19:06:33 ******/
  15957. SET ANSI_NULLS ON
  15958. GO
  15959. SET QUOTED_IDENTIFIER ON
  15960. GO
  15961. -- =============================================
  15962. -- Author: Sean
  15963. -- Create date: 2010-10-28
  15964. -- Description: 修改企业信息
  15965. -- 因为Name shortname 不在此处修改,所以去掉相关部分
  15966. -- mice 123 2015-6-8 添加修改企业简称(shortname)的修改
  15967. -- sean 2015-11-27 remove修改企业简称(shortname)的修改
  15968. -- =============================================
  15969. CREATE PROCEDURE [dbo].[ccCpMainUpdate]
  15970. (
  15971. @caMainID INT,
  15972. @cpMainID INT,
  15973. @Name VARCHAR(100),
  15974. @ShortName VARCHAR(40),
  15975. @dcCompanyKindID INT,
  15976. @dcCompanySizeID INT,
  15977. @dcIndustryID VARCHAR(50),
  15978. @dcRegionID VARCHAR(6),
  15979. @Address VARCHAR(120),
  15980. @Zip VARCHAR(6),
  15981. @MapBarID VARCHAR(50),
  15982. @HomePage VARCHAR(50),
  15983. @Brief VARCHAR(6000)
  15984. )
  15985. AS
  15986. SET NOCOUNT ON
  15987. SELECT @dcIndustryID = dbo.SafeSql(@dcIndustryID),
  15988. @Address = dbo.SafeSql(@Address),
  15989. @HomePage = dbo.SafeSql(@HomePage),
  15990. @MapBarID = dbo.SafeSql(@MapBarID),
  15991. @Brief = dbo.SafeSql(@Brief)
  15992. IF NOT EXISTS(SELECT 'x' FROM caMain WITH(NOLOCK)
  15993. INNER JOIN cpMain WITH(NOLOCK) ON caMain.cpMainID = cpMain.ID
  15994. WHERE cpMain.ID = @cpMainID
  15995. AND caMain.ID = @caMainID)
  15996. GOTO Err2
  15997. --SET @Brief = REPLACE(@Brief, CHAR(13) + CHAR(10) + '?', CHAR(13) + CHAR(10) + ' ')
  15998. --IF(LEFT(@Brief, 1) = '?')
  15999. -- SET @Brief = REPLACE(@Brief, '?', ' ')
  16000. --SET @Brief = REPLACE(@Brief, '&nbsp;', ' ')
  16001. IF @Brief LIKE '最少输入20字,最多输入3000字。%'
  16002. SET @Brief = REPLACE(@Brief, '最少输入20字,最多输入3000字。', '')
  16003. BEGIN TRAN
  16004. BEGIN TRY
  16005. DECLARE @AddressOld AS NVARCHAR(60),
  16006. @HomePageOld AS VARCHAR(100),
  16007. @BriefOld AS VARCHAR(6000),
  16008. --@ShortNameOld VARCHAR(40),
  16009. @IsVerify AS TINYINT
  16010. SET @IsVerify = 0
  16011. SELECT @MapBarID = dbo.TrimNull(@MapBarID),
  16012. @Zip = dbo.TrimNull(@Zip),
  16013. @Homepage = REPLACE(@Homepage, 'http://', ''),
  16014. @Homepage = dbo.TrimNull(@Homepage)
  16015. SELECT @AddressOld=RTRIM(ISNULL(Address, '')),@HomePageOld=RTRIM(ISNULL(HomePage, '')),
  16016. @BriefOld=RTRIM(ISNULL(Brief, ''))
  16017. --,@ShortNameOld = ISNULL(ShortName, '')
  16018. FROM cpMain WITH(NOLOCK)
  16019. WHERE ID=@cpMainID
  16020. --IF LEN(dbo.Trim(@ShortName)) = 0
  16021. -- SET @ShortName = NULL
  16022. UPDATE cpMain SET
  16023. --ShortName = @ShortName,
  16024. dcCompanyKindID = @dcCompanyKindID,
  16025. dcCompanySizeID = @dcCompanySizeID,
  16026. dcRegionID = @dcRegionID,
  16027. Address = @Address,
  16028. Zip = @Zip,
  16029. MapBarID = @MapBarID,
  16030. HomePage = @HomePage,
  16031. Brief = @Brief,
  16032. LastModifyDate =GETDATE()
  16033. WHERE ID=@cpMainID
  16034. --保存所属行业
  16035. DELETE FROM cpIndustry WHERE cpMainID = @cpMainID
  16036. INSERT INTO cpIndustry
  16037. SELECT @cpMainID, a FROM dbo.fnSplit(@dcIndustryID, ' ')
  16038. ----记录到bsCpModify审核记录
  16039. IF dbo.TextTrim(@Address) = ''
  16040. DELETE FROM bsCpModify WHERE cpMainID=@cpMainID AND Location='a3'
  16041. ELSE
  16042. IF @AddressOld <> RTRIM(@Address)
  16043. BEGIN
  16044. DELETE FROM bsCpModify WHERE cpMainID=@cpMainID AND Location='a3'
  16045. INSERT INTO bsCpModify (cpMainID,caMainID,Location,ColValue) VALUES(@cpMainID,@caMainID,'a3',@Address)
  16046. SET @IsVerify = 1
  16047. END
  16048. IF dbo.TextTrim(@HomePage) = ''
  16049. DELETE FROM bsCpModify WHERE cpMainID=@cpMainID AND Location='a4'
  16050. ELSE
  16051. IF @HomePageOld <> RTRIM(@HomePage)
  16052. BEGIN
  16053. DELETE FROM bsCpModify WHERE cpMainID=@cpMainID AND Location='a4'
  16054. INSERT INTO bsCpModify (cpMainID,caMainID,Location,ColValue) VALUES(@cpMainID,@caMainID,'a4',@HomePage)
  16055. SET @IsVerify = 1
  16056. END
  16057. IF dbo.TextTrim(@Brief) = ''
  16058. DELETE FROM bsCpModify WHERE cpMainID=@cpMainID AND Location='a5'
  16059. ELSE
  16060. IF @BriefOld <> RTRIM(@Brief)
  16061. BEGIN
  16062. DELETE FROM bsCpModify WHERE cpMainID=@cpMainID AND Location='a5'
  16063. INSERT INTO bsCpModify (cpMainID,caMainID,Location,ColValue) VALUES(@cpMainID,@caMainID,'a5',@Brief)
  16064. SET @IsVerify = 1
  16065. END
  16066. /*
  16067. IF dbo.TextTrim(@ShortName) = ''
  16068. DELETE FROM bsCpModify WHERE cpMainID=@cpMainID AND Location='a6'
  16069. ELSE
  16070. BEGIN
  16071. IF CHARINDEX(@ShortName, @Name) = 0
  16072. BEGIN
  16073. IF @ShortNameOld <> RTRIM(@ShortName)
  16074. BEGIN
  16075. DELETE FROM bsCpModify WHERE cpMainID=@cpMainID AND Location='a6'
  16076. INSERT INTO bsCpModify (cpMainID,caMainID,Location,ColValue) VALUES(@cpMainID,@caMainID,'a6',@ShortName)
  16077. SET @IsVerify = 1
  16078. END
  16079. END
  16080. ELSE
  16081. DELETE FROM bsCpModify WHERE cpMainID=@cpMainID AND Location='a6'
  16082. END
  16083. */
  16084. --EXEC ccCaOperationLogInsert @caMainID, 12, '更新企业信息'
  16085. END TRY
  16086. BEGIN CATCH
  16087. GOTO ERR
  16088. END CATCH
  16089. COMMIT TRAN
  16090. RETURN 1
  16091. ERR:
  16092. BEGIN
  16093. ROLLBACK TRAN
  16094. RETURN 0
  16095. END
  16096. ERR2:
  16097. BEGIN
  16098. RETURN -1
  16099. END
  16100. GO
  16101. /****** Object: StoredProcedure [dbo].[cccpMainViewNumberUpdate] Script Date: 2018/12/13 19:06:33 ******/
  16102. SET ANSI_NULLS ON
  16103. GO
  16104. SET QUOTED_IDENTIFIER ON
  16105. GO
  16106. --#####################################################
  16107. --创建时间:2014.10.30
  16108. --创建人:Nick
  16109. --说明:企业查看次数修改
  16110. --#####################################################
  16111. CREATE PROCEDURE [dbo].[cccpMainViewNumberUpdate]
  16112. (
  16113. @ID INT
  16114. )
  16115. AS
  16116. RETURN
  16117. BEGIN
  16118. UPDATE cpMain
  16119. SET ViewNumber = ViewNumber + 1
  16120. WHERE ID=@ID
  16121. END
  16122. GO
  16123. /****** Object: StoredProcedure [dbo].[ccCpMainVipBefore20170801Select] Script Date: 2018/12/13 19:06:34 ******/
  16124. SET ANSI_NULLS ON
  16125. GO
  16126. SET QUOTED_IDENTIFIER ON
  16127. GO
  16128. --Lambo 20101022
  16129. --查询该简历是否向本公司申请过
  16130. --用于简历显示页面
  16131. --sean 20170731
  16132. CREATE PROCEDURE [dbo].[ccCpMainVipBefore20170801Select]
  16133. (
  16134. @cpMainID INT
  16135. )
  16136. AS
  16137. SET NOCOUNT ON
  16138. BEGIN
  16139. SELECT * FROM cpMainVip WITH(NOLOCK) WHERE cpMainId = @cpMainId
  16140. --SELECT @cpMainId cpMainId
  16141. END
  16142. GO
  16143. /****** Object: StoredProcedure [dbo].[ccCpNoViewCountSelect] Script Date: 2018/12/13 19:06:34 ******/
  16144. SET ANSI_NULLS ON
  16145. GO
  16146. SET QUOTED_IDENTIFIER ON
  16147. GO
  16148. --#####################################################
  16149. --创建时间:2014.10.30
  16150. --创建人:John
  16151. --说明:获取企业未查看的预约数
  16152. --#####################################################
  16153. CREATE PROCEDURE [dbo].[ccCpNoViewCountSelect]
  16154. (
  16155. @caMainID INT
  16156. )
  16157. AS
  16158. BEGIN
  16159. SELECT COUNT(*) cnt
  16160. FROM viplaninvitelog a,viplan b
  16161. WHERE a.viplanid = b.id
  16162. AND addtype = 0
  16163. AND viewdate IS NULL
  16164. AND camainid = @caMainID
  16165. END
  16166. GO
  16167. /****** Object: StoredProcedure [dbo].[cccpPersonalAccountInsert] Script Date: 2018/12/13 19:06:34 ******/
  16168. SET ANSI_NULLS ON
  16169. GO
  16170. SET QUOTED_IDENTIFIER ON
  16171. GO
  16172. CREATE PROCEDURE [dbo].[cccpPersonalAccountInsert]
  16173. (
  16174. @cpCertificationID INT,
  16175. @cpMainID INT,
  16176. @Name VARCHAR(50),
  16177. @BankNo VARCHAR(50),
  16178. @IDCard VARCHAR(50)
  16179. )
  16180. AS
  16181. SET NOCOUNT ON
  16182. BEGIN
  16183. DECLARE @MemberType TINYINT
  16184. SELECT @MemberType = MemberType FROM cpCertification WITH(NOLOCK) WHERE ID = @cpCertificationID AND cpMainID = @cpMainID AND CerStatus IS NULL
  16185. IF @MemberType IS NULL
  16186. RETURN -1
  16187. IF LEFT(@Name, 4) = 'WYRC'
  16188. SELECT @BankNo = BankNo FROM cpPersonalAccount WHERE cpCertificationID = @cpCertificationID
  16189. DELETE FROM cpPersonalAccount WHERE cpCertificationID = @cpCertificationID
  16190. INSERT INTO cpPersonalAccount(cpCertificationID, [Name], IDCard, BankNo)
  16191. VALUES(@cpCertificationID, @Name, @IDCard, @BankNo)
  16192. IF LEFT(@Name, 4) = 'WYRC' --如果是普通认证并且是芝麻认证 人脸认证需要记录业务凭证
  16193. BEGIN
  16194. IF NOT EXISTS(SELECT 'X' FROM ZmxyTransaction WHERE ID = @Name)
  16195. INSERT INTO ZmxyTransaction(ID, cpMainID, cpCertificationID) VALUES(@Name, @cpMainID, @cpCertificationID)
  16196. END
  16197. RETURN 1
  16198. END
  16199. SET NOCOUNT OFF
  16200. GO
  16201. /****** Object: StoredProcedure [dbo].[cccpPersonalAccountUpdate] Script Date: 2018/12/13 19:06:34 ******/
  16202. SET ANSI_NULLS ON
  16203. GO
  16204. SET QUOTED_IDENTIFIER ON
  16205. GO
  16206. CREATE PROCEDURE [dbo].[cccpPersonalAccountUpdate]
  16207. @cpCertificationID INT,
  16208. @cpMainID INT,
  16209. @CheckResult TINYINT
  16210. AS
  16211. SET NOCOUNT ON
  16212. BEGIN
  16213. IF NOT EXISTS(SELECT 'X' FROM cpCertification WITH(NOLOCK) WHERE ID = @cpCertificationID AND cpMainID = @cpMainID AND CerStatus IS NULL)
  16214. RETURN -1
  16215. DECLARE @cpPersonalAccountID INT
  16216. SELECT TOP 1 @cpPersonalAccountID = ID FROM cpPersonalAccount WITH(NOLOCK) WHERE cpCertificationID = @cpCertificationID AND CheckResult IS NULL AND IDCard IS NOT NULL
  16217. IF @cpPersonalAccountID IS NULL
  16218. RETURN -1
  16219. IF @CheckResult = 0
  16220. BEGIN
  16221. DELETE FROM cpPersonalAccount WHERE ID = @cpPersonalAccountID
  16222. END
  16223. ELSE
  16224. BEGIN
  16225. DECLARE @MemberType TINYINT
  16226. SELECT TOP 1 @MemberType = MemberType FROM cpCertification WITH(NOLOCK) WHERE ID = @cpCertificationID AND cpMainID = @cpMainID AND CerStatus IS NULL
  16227. IF @MemberType = 1
  16228. UPDATE cpPersonalAccount SET CheckResult = 2 WHERE ID = @cpPersonalAccountID
  16229. ELSE
  16230. BEGIN
  16231. UPDATE cpPersonalAccount SET CheckResult = 1 WHERE ID = @cpPersonalAccountID
  16232. BEGIN TRY
  16233. UPDATE cpCertification SET CerStatus = 1 WHERE ID = @cpCertificationID AND cpMainID = @cpMainID AND CerStatus IS NULL
  16234. END TRY
  16235. BEGIN CATCH
  16236. END CATCH
  16237. END
  16238. END
  16239. RETURN 1
  16240. END
  16241. SET NOCOUNT OFF
  16242. GO
  16243. /****** Object: StoredProcedure [dbo].[ccCpPointByChatOnlineInsert] Script Date: 2018/12/13 19:06:34 ******/
  16244. SET ANSI_NULLS ON
  16245. GO
  16246. SET QUOTED_IDENTIFIER ON
  16247. GO
  16248. --Peter 2014-08-25修改
  16249. --首次在线沟通加分
  16250. --修改harry (10积分),每日最多可获得 (200积分)
  16251. CREATE PROCEDURE [dbo].[ccCpPointByChatOnlineInsert]
  16252. @caMainID INT
  16253. AS
  16254. BEGIN
  16255. BEGIN TRY
  16256. --插入积分记录 Peter 2014-08-25
  16257. DECLARE @TodayPoint AS INT
  16258. DECLARE @TodayID AS INT
  16259. DECLARE @cpMainID AS INT
  16260. SET @TodayPoint = 0
  16261. SET @TodayID = 0
  16262. SELECT TOP 1 @cpMainID = cpMainID FROM caMain WITH(NOLOCK) WHERE ID = @caMainID
  16263. SELECT TOP 1 @TodayPoint = ISNULL(Point,0),@TodayID = ISNULL(ID,0) FROM cpPoint WITH(NOLOCK) WHERE changeID = 14 AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120) AND cpMainID = @cpMainID
  16264. SET @TodayPoint = @TodayPoint + 10
  16265. IF @TodayPoint <= 200
  16266. BEGIN
  16267. IF @TodayID = 0
  16268. BEGIN
  16269. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,6,2,GETDATE())
  16270. END
  16271. ELSE
  16272. BEGIN
  16273. UPDATE cpPoint SET Point = @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
  16274. END
  16275. END
  16276. END TRY
  16277. BEGIN CATCH
  16278. END CATCH
  16279. END
  16280. GO
  16281. /****** Object: StoredProcedure [dbo].[ccCpPointByCpMainIDSelect] Script Date: 2018/12/13 19:06:35 ******/
  16282. SET ANSI_NULLS ON
  16283. GO
  16284. SET QUOTED_IDENTIFIER ON
  16285. GO
  16286. -- =============================================
  16287. -- Author: Mice
  16288. -- Create date: 2014-8-12
  16289. -- Description: 获取积分详情
  16290. -- Modify: Harry 增加选择每日的积分综合,取消top200
  16291. -- =============================================
  16292. CREATE PROCEDURE [dbo].[ccCpPointByCpMainIDSelect]
  16293. (
  16294. @cpMainId INT
  16295. )
  16296. AS
  16297. BEGIN
  16298. DECLARE @d DATETIME, @AllPoint INT
  16299. SET @d = convert(varchar(10), getdate(), 120)
  16300. DELETE cpPointCount WHERE countdate = @d AND cpMainId = @cpMainId
  16301. SELECT @AllPoint = remainpoint FROM cpMain WHERE id = @cpMainId
  16302. INSERT INTO cpPointCount
  16303. SELECT @d, @cpMainId, sum(point), @AllPoint
  16304. FROM cppoint
  16305. WHERE lastmodifydate > @d
  16306. AND cpMainId = @cpMainId
  16307. SELECT TOP 500 a.*, b.RemainPoint , c.ServiceType , c.OrderType
  16308. FROM cpPoint a
  16309. LEFT JOIN cpMain b ON a.cpMainId = b.id
  16310. LEFT JOIN caOrder c ON c.id = a.relativeID AND (a.ChangeID = 15 OR a.ChangeID = 16 )
  16311. WHERE a.cpMainId = @cpMainId
  16312. ORDER BY a.LastModifyDate DESC
  16313. SELECT TOP 30 *
  16314. FROM cpPointCount
  16315. WHERE cpMainId=@cpMainId
  16316. ORDER BY CountDate DESC
  16317. END
  16318. GO
  16319. /****** Object: StoredProcedure [dbo].[ccCpPointByCvSelectInsert] Script Date: 2018/12/13 19:06:35 ******/
  16320. SET ANSI_NULLS ON
  16321. GO
  16322. SET QUOTED_IDENTIFIER ON
  16323. GO
  16324. -- =============================================
  16325. -- Author: Peter
  16326. -- Create date: 2014-8-25
  16327. -- Description: 首次查询简历插入积分记录
  16328. -- =============================================
  16329. CREATE PROCEDURE [dbo].[ccCpPointByCvSelectInsert]
  16330. -- Add the parameters for the stored procedure here
  16331. @cpMainID INT
  16332. AS
  16333. BEGIN
  16334. --插入积分记录
  16335. IF NOT EXISTS (SELECT 'x' FROM cpPoint WITH(NOLOCK) WHERE ChangeID = 3 AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120) AND cpMainID = @cpMainID)
  16336. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,3,5,GETDATE())
  16337. END
  16338. GO
  16339. /****** Object: StoredProcedure [dbo].[ccCpPointByLastModifyDateInsert] Script Date: 2018/12/13 19:06:35 ******/
  16340. SET ANSI_NULLS ON
  16341. GO
  16342. SET QUOTED_IDENTIFIER ON
  16343. GO
  16344. --------------------------------------------------------------------------------------------------------
  16345. --Peter 20140825创建
  16346. --每天检查添加积分项 计划任务
  16347. --修改harry 积分改为5分
  16348. CREATE PROCEDURE [dbo].[ccCpPointByLastModifyDateInsert]
  16349. AS
  16350. BEGIN
  16351. --有有效职位+5分
  16352. INSERT INTO cpPoint (cpMainID, ChangeID, Point, LastModifyDate)
  16353. SELECT ID, 11, 5, GETDATE() FROM cpMain WITH(NOLOCK)
  16354. WHERE EXISTS (SELECT 'x' FROM JobPublish WITH(NOLOCK) WHERE cpMainID = cpMain.ID AND JobPublish.Valid =1)
  16355. UPDATE cpMain
  16356. SET RemainPoint = ISNULL(RemainPoint, 0) + 5
  16357. WHERE EXISTS(SELECT 'x' FROM JobPublish WITH(NOLOCK) WHERE JobPublish.Valid = 1 AND JobPublish.cpMainId = cpMain.Id)
  16358. --AND RemainPoint > 0
  16359. --检查视频面试记录
  16360. /*SELECT a.ID, 13 ChangeID, CASE WHEN COUNT(b.ID)*5 > 50 THEN 50 ELSE COUNT(b.ID)*5 END Point, GETDATE() LastModifyDate
  16361. INTO #t
  16362. FROM cpMain a WITH(NOLOCK), viInterviewRecord b WITH(NOLOCK), caMain c WITH(NOLOCK), viRoom d WITH(NOLOCK)
  16363. WHERE b.viRoomID = d.ID
  16364. AND d.caMainID = c.ID
  16365. AND c.cpMainID = a.ID
  16366. AND b.BeginDate > CONVERT(VARCHAR(10), GETDATE() - 1, 120)
  16367. AND b.BeginDate < CONVERT(VARCHAR(10), GETDATE(), 120)
  16368. AND DATEDIFF(MINUTE, b.BeginDate, b.EndDate) >= 5
  16369. GROUP BY a.ID
  16370. INSERT INTO cpPoint (cpMainID, ChangeID, Point, LastModifyDate)
  16371. SELECT * FROM #t
  16372. UPDATE a SET a.RemainPoint= a.RemainPoint + b.Point
  16373. FROM cpMain a, #t b
  16374. WHERE a.Id = b.Id
  16375. */
  16376. END
  16377. GO
  16378. /****** Object: StoredProcedure [dbo].[cccpPointByLastModifyDateSelect] Script Date: 2018/12/13 19:06:36 ******/
  16379. SET ANSI_NULLS ON
  16380. GO
  16381. SET QUOTED_IDENTIFIER ON
  16382. GO
  16383. -- =============================================-- Author: Peter
  16384. -- Create date: 2014-08-20 09:55
  16385. -- Description:
  16386. -- 修改Harry 修改为changeid=1 登录积分2017-4-19
  16387. -- =============================================
  16388. CREATE PROCEDURE [dbo].[cccpPointByLastModifyDateSelect]
  16389. (
  16390. @cpMainID INT,
  16391. @BeginDate DATETIME,
  16392. @EndDate DATETIME
  16393. )
  16394. AS
  16395. BEGIN
  16396. SELECT LastModifyDate
  16397. FROM cpPoint
  16398. WHERE cpMainID = @cpMainID
  16399. AND ChangeID= 1
  16400. AND LastModifyDate BETWEEN @BeginDate AND @EndDate
  16401. END
  16402. GO
  16403. /****** Object: StoredProcedure [dbo].[cccpPointByLoginInsert] Script Date: 2018/12/13 19:06:36 ******/
  16404. SET ANSI_NULLS ON
  16405. GO
  16406. SET QUOTED_IDENTIFIER ON
  16407. GO
  16408. -- =============================================
  16409. -- Author: Peter
  16410. -- Create date: 2014-08-20 09:55
  16411. -- Description:
  16412. -- =============================================
  16413. CREATE PROCEDURE [dbo].[cccpPointByLoginInsert]
  16414. (
  16415. @cpMainID INT
  16416. )
  16417. AS
  16418. BEGIN TRY
  16419. --查询是否是第一次登陆
  16420. IF EXISTS(SELECT 'x' FROM cpPoint WITH(NOLOCK)
  16421. WHERE cpMainID = @cpMainID
  16422. AND ChangeID = 1
  16423. AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120))
  16424. RETURN 0
  16425. --查询前一天获取的分值
  16426. DECLARE @LastLoginPoint AS INT
  16427. SET @LastLoginPoint = 0
  16428. SELECT @LastLoginPoint = Point
  16429. FROM cpPoint WITH(NOLOCK)
  16430. WHERE cpMainID = @cpMainID
  16431. AND ChangeID = 1
  16432. AND LastModifyDate BETWEEN (CONVERT(VARCHAR(10),GETDATE()-1,120) + ' 00:00:00') AND (CONVERT(VARCHAR(10),GETDATE()-1,120) + ' 23:59:59')
  16433. --在前一天的分值基础上+2 最大为10分
  16434. SET @LastLoginPoint = @LastLoginPoint + 2
  16435. IF @LastLoginPoint > 10
  16436. SET @LastLoginPoint = 10
  16437. --插入积分登陆记录
  16438. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,1,@LastLoginPoint,GETDATE())
  16439. RETURN 1
  16440. END TRY
  16441. BEGIN CATCH
  16442. END CATCH
  16443. GO
  16444. /****** Object: StoredProcedure [dbo].[cccpPointByPointSelect] Script Date: 2018/12/13 19:06:36 ******/
  16445. SET ANSI_NULLS ON
  16446. GO
  16447. SET QUOTED_IDENTIFIER ON
  16448. GO
  16449. -- =============================================
  16450. -- Author: Peter
  16451. -- Create date: 2014-08-20 09:55
  16452. -- Description:
  16453. -- Mice 2014-8-28 修改 : 当天获得的积分中不包括取消订单
  16454. -- =============================================
  16455. CREATE PROCEDURE [dbo].[cccpPointByPointSelect]
  16456. (
  16457. @cpMainID INT
  16458. )
  16459. AS
  16460. BEGIN
  16461. SELECT (SELECT TOP 1 RemainPoint FROM cpMain WITH(NOLOCK) WHERE ID = @cpMainID) RemainPoint,
  16462. ISNULL((SELECT SUM(Point) FROM cpPoint WITH(NOLOCK) WHERE cpMainID = @cpMainID AND ChangeID <> 16 AND Point > 0 AND LastModifyDate > CONVERT(VARCHAR(10),GETDATE(),120)),0) TodayPoint,
  16463. ISNULL((SELECT Point FROM cpPoint WITH(NOLOCK) WHERE cpMainID = @cpMainID AND ChangeID = 1 AND LastModifyDate > CONVERT(VARCHAR(10),GETDATE(),120)),0) LoginPoint
  16464. END
  16465. GO
  16466. /****** Object: StoredProcedure [dbo].[cccpRefreshlogDayByCpMainIDSelect] Script Date: 2018/12/13 19:06:36 ******/
  16467. SET ANSI_NULLS ON
  16468. GO
  16469. SET QUOTED_IDENTIFIER ON
  16470. GO
  16471. --#####################################################
  16472. --创建时间:2014.10.31
  16473. --创建人:Nick
  16474. --说明:返回企业的日刷新数量
  16475. --修改:harry 增加刷新数2017-12-21
  16476. --#####################################################
  16477. CREATE PROCEDURE [dbo].[cccpRefreshlogDayByCpMainIDSelect]
  16478. (
  16479. @dtStart DATETIME,
  16480. @dtEnd DATETIME,
  16481. @CpMainID INT
  16482. )
  16483. AS
  16484. SET NOCOUNT ON
  16485. BEGIN
  16486. DECLARE @Tabel AS TABLE(Refreshdate DATETIME)
  16487. --插入数据 刷新数刷新记录
  16488. INSERT INTO @Tabel
  16489. SELECT runDateTime
  16490. FROM jobRefreshLog WITH(NOLOCK)
  16491. WHERE cpMainId = @cpMainId
  16492. AND runDateTime> @dtStart
  16493. AND runDateTime< @dtEnd
  16494. --插入数据 登录刷新、老刷新
  16495. INSERT INTO @Tabel
  16496. SELECT RefreshDate
  16497. FROM Maindb..cpRefreshlog WITH(NOLOCK)
  16498. WHERE cpMainId = @cpMainId
  16499. AND RefreshDate > @dtStart
  16500. AND RefreshDate < @dtEnd
  16501. SELECT TOP 1000 *
  16502. FROM @Tabel
  16503. ORDER BY Refreshdate
  16504. END
  16505. GO
  16506. /****** Object: StoredProcedure [dbo].[cccpRefreshlogMonthByCpMainIDSelect] Script Date: 2018/12/13 19:06:36 ******/
  16507. SET ANSI_NULLS ON
  16508. GO
  16509. SET QUOTED_IDENTIFIER ON
  16510. GO
  16511. --#####################################################
  16512. --创建时间:2014.10.31
  16513. --创建人:Nick
  16514. --说明:返回企业的月刷新数量
  16515. --修改:harry 增加职位刷新数记录 2017-11-21
  16516. --#####################################################
  16517. CREATE PROCEDURE [dbo].[cccpRefreshlogMonthByCpMainIDSelect]
  16518. (
  16519. @dtStart DATETIME,
  16520. @dtEnd DATETIME,
  16521. @CpMainID INT
  16522. )
  16523. AS
  16524. SET NOCOUNT ON
  16525. BEGIN
  16526. DECLARE @Tabel AS TABLE(Refreshdate DATETIME)
  16527. --插入数据 刷新数刷新记录
  16528. INSERT INTO @Tabel
  16529. SELECT runDateTime
  16530. FROM jobRefreshLog WITH(NOLOCK)
  16531. WHERE cpMainId = @cpMainId
  16532. AND runDateTime> @dtStart
  16533. AND runDateTime< @dtEnd
  16534. --插入数据 登录刷新、老刷新
  16535. INSERT INTO @Tabel
  16536. SELECT RefreshDate
  16537. FROM Maindb..cpRefreshlog
  16538. WHERE cpMainId = @cpMainId
  16539. AND RefreshDate > @dtStart
  16540. AND RefreshDate < @dtEnd
  16541. SELECT TOP 1000 CONVERT(VARCHAR(10),RefreshDate, 121) AS sdate, COUNT(1) AS refreshNum
  16542. FROM @Tabel
  16543. GROUP BY CONVERT(varchar(10),RefreshDate, 121)
  16544. ORDER BY CONVERT(varchar(10),RefreshDate, 121)
  16545. END
  16546. GO
  16547. /****** Object: StoredProcedure [dbo].[ccCpSessionByCaMainIDDelete] Script Date: 2018/12/13 19:06:36 ******/
  16548. SET ANSI_NULLS ON
  16549. GO
  16550. SET QUOTED_IDENTIFIER ON
  16551. GO
  16552. --#####################################################
  16553. --创建时间:2014.10.30
  16554. --创建人:Nick
  16555. --说明:删除cpsession
  16556. --#####################################################
  16557. CREATE PROCEDURE [dbo].[ccCpSessionByCaMainIDDelete]
  16558. (
  16559. @CamainID INT,
  16560. @Cookies VARCHAR(100)
  16561. )
  16562. AS
  16563. BEGIN TRY
  16564. DELETE FROM cpSession
  16565. WHERE caMainID=@CamainID
  16566. AND (Cookies=@Cookies Or RefreshDate < DateAdd(mi, -10, GETDATE()))
  16567. RETURN 1
  16568. END TRY
  16569. BEGIN CATCH
  16570. RETURN 0
  16571. END CATCH
  16572. GO
  16573. /****** Object: StoredProcedure [dbo].[ccCpSessionByCaMainIDSelect] Script Date: 2018/12/13 19:06:37 ******/
  16574. SET ANSI_NULLS ON
  16575. GO
  16576. SET QUOTED_IDENTIFIER ON
  16577. GO
  16578. --#####################################################
  16579. --创建时间:2014.10.30
  16580. --创建人:Nick
  16581. --说明:获取cpsession
  16582. --#####################################################
  16583. CREATE PROCEDURE [dbo].[ccCpSessionByCaMainIDSelect]
  16584. (
  16585. @CamainID INT
  16586. )
  16587. AS
  16588. BEGIN TRY
  16589. SELECT TOP 1 * FROM cpSession WITH(NOLOCK) WHERE caMainID=@CamainID ORDER BY RefreshDate Desc
  16590. END TRY
  16591. BEGIN CATCH
  16592. RETURN 0
  16593. END CATCH
  16594. GO
  16595. /****** Object: StoredProcedure [dbo].[ccCpSessionByCaMainIDUpdate] Script Date: 2018/12/13 19:06:37 ******/
  16596. SET ANSI_NULLS ON
  16597. GO
  16598. SET QUOTED_IDENTIFIER ON
  16599. GO
  16600. --#####################################################
  16601. --创建时间:2014.10.30
  16602. --创建人:Nick
  16603. --说明:修改cpsession
  16604. --#####################################################
  16605. CREATE PROCEDURE [dbo].[ccCpSessionByCaMainIDUpdate]
  16606. (
  16607. @CamainID INT,
  16608. @Cookies VARCHAR(100)
  16609. )
  16610. AS
  16611. BEGIN TRY
  16612. UPDATE cpSession SET RefreshDate=GETDATE()
  16613. WHERE caMainID=@CamainID AND Cookies=@Cookies
  16614. RETURN 1
  16615. END TRY
  16616. BEGIN CATCH
  16617. RETURN 0
  16618. END CATCH
  16619. GO
  16620. /****** Object: StoredProcedure [dbo].[cccpSessionLogDelete] Script Date: 2018/12/13 19:06:37 ******/
  16621. SET ANSI_NULLS ON
  16622. GO
  16623. SET QUOTED_IDENTIFIER ON
  16624. GO
  16625. --#####################################################
  16626. --创建时间:2014.10.30
  16627. --创建人:Nick
  16628. --说明:企业退出后删除SessionLOg
  16629. --#####################################################
  16630. CREATE PROCEDURE [dbo].[cccpSessionLogDelete]
  16631. (
  16632. @caMainID INT,
  16633. @Cookie VARCHAR(50)
  16634. )
  16635. AS
  16636. BEGIN TRY
  16637. DELETE FROM cpSession
  16638. WHERE caMainID = @caMainID
  16639. AND (Cookies = @Cookie Or RefreshDate < DateAdd(mi, -10, GETDATE()))
  16640. RETURN 1
  16641. END TRY
  16642. BEGIN CATCH
  16643. RETURN 0
  16644. END CATCH
  16645. GO
  16646. /****** Object: StoredProcedure [dbo].[ccCpViInterviewSmsMessageLogInsert] Script Date: 2018/12/13 19:06:37 ******/
  16647. SET ANSI_NULLS ON
  16648. GO
  16649. SET QUOTED_IDENTIFIER ON
  16650. GO
  16651. --#####################################################
  16652. --创建时间:2014.10.29
  16653. --创建人:John
  16654. --说明:企业邀请个人进入面试室添加短信通知
  16655. --#####################################################
  16656. CREATE PROCEDURE [dbo].[ccCpViInterviewSmsMessageLogInsert]
  16657. (
  16658. @JobID INT,
  16659. @CvMainID INT
  16660. )
  16661. AS
  16662. BEGIN
  16663. DECLARE @cnt INT
  16664. SELECT @cnt = COUNT(1)
  16665. FROM SmsMessageLog
  16666. WHERE msgtype = 121
  16667. AND camainid =
  16668. (
  16669. SELECT camainid
  16670. FROM job
  16671. WHERE id = @JobID
  16672. )
  16673. AND adddate > CONVERT(VARCHAR(10), GETDATE(), 23)
  16674. IF @cnt < 10
  16675. BEGIN
  16676. INSERT SmsMessageLog(SendMan, ManagerUserId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  16677. SELECT top 1 0, NULL, a.ID, e.caMainID, b.Mobile, 121, 0, ISNULL(b.Name,'') +','+ d.Name +'在'+ c.SubSiteName + c.EmailSite +'上邀请您参加视频面试,请登录网站查看'
  16678. FROM cvMain a WITH(NOLOCK), paMain b WITH(NOLOCK), dcSubSite c WITH(NOLOCK),cpMain d WITH(NOLOCK),job e WITH(NOLOCK)
  16679. WHERE a.paMainID = b.ID
  16680. AND b.dcSubSiteID = c.ID
  16681. AND d.id = e.cpMainID
  16682. AND e.ID = @JobID
  16683. AND b.Mobile > ''
  16684. AND a.ID = @CvMainID
  16685. AND b.IsReceiveSms = 1
  16686. AND
  16687. (
  16688. SELECT COUNT(1)
  16689. FROM SmsMessageLog WITH(NOLOCK)
  16690. WHERE paMainid =
  16691. (
  16692. SELECT paMainID
  16693. FROM cvMain
  16694. WHERE id = @CvMainID
  16695. )
  16696. AND caMainID =
  16697. (
  16698. SELECT camainid
  16699. FROM job
  16700. WHERE id = @JobID
  16701. )
  16702. AND MsgType = 121
  16703. ) = 0
  16704. END
  16705. END
  16706. GO
  16707. /****** Object: StoredProcedure [dbo].[ccCvBySearchPublishSelect] Script Date: 2018/12/13 19:06:37 ******/
  16708. SET ANSI_NULLS ON
  16709. GO
  16710. SET QUOTED_IDENTIFIER ON
  16711. GO
  16712. /********************************************************
  16713. Update 2012-9-3 sean
  16714. object Add Height
  16715. ********************************************************/
  16716. CREATE PROCEDURE [dbo].[ccCvBySearchPublishSelect]
  16717. (
  16718. @dcJobTypeID VARCHAR(50), --职位类别
  16719. @dcRegionID VARCHAR(50), --求职地区
  16720. @dcIndustryID VARCHAR(50), --现从事行业
  16721. @IncludeOld BIT, --1包含曾从事职业
  16722. @dcJobTypeIDExpect VARCHAR(50),--期望职位类别
  16723. @dcIndustryIDExpect VARCHAR(50),--期望求职行业
  16724. @dcSalaryID TINYINT, --月薪
  16725. @IsNegotiable BIT, --1允许面议,不面议
  16726. @MinExperience TINYINT, --工作经验
  16727. @dcEducationID TINYINT, --最低学历
  16728. @LanguageType SMALLINT, --语种
  16729. @KeyWord NVARCHAR(20), --关键词
  16730. @College NVARCHAR(50), --学校名称
  16731. @Standard BIT, --是否统招
  16732. @SubNodeNum INT, --下属人数
  16733. @Major INT, --所学专业
  16734. @Graduation INT, --毕业时间 year
  16735. @Gender TINYINT, --性别,2不限
  16736. @MaxAge SMALLINT, --最大年龄
  16737. @MinAge SMALLINT, --最小年龄
  16738. @LivePlace VARCHAR(50), --现居住地
  16739. @AccountPlace INT, --户口所在地
  16740. @MobilePlace VARCHAR(50), --现居住地
  16741. @SortType TINYINT, --排序方式
  16742. @CvMainID INT, --简历ID
  16743. --@dcCareerStatus TINYINT, --简历状态
  16744. --sessionid,没有采用全部人员共享方式,因为10分钟内,搜索相同条件的可能性很大,
  16745. --而10分钟搜索的用户翻到第二页时内容可能会和第一页一样。这样让用户很难理解。
  16746. --使用SessionID,可以保证60分钟内查询结果一致。出现不一致的几率很小
  16747. @SessionID INT,
  16748. @PageNumber INT, --翻页页码
  16749. @IsExpand BIT, --是否扩大地区范围
  16750. @caMainID INT --企业用户ID,用来判断是否和建立联系
  16751. )
  16752. AS
  16753. --return
  16754. SET NOCOUNT ON
  16755. BEGIN TRY
  16756. DECLARE @MajorName AS NVARCHAR(20)
  16757. IF @dcJobTypeID IS NULL
  16758. SET @dcJobTypeID = ''
  16759. SET @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID)
  16760. IF @dcJobTypeIDExpect IS NULL
  16761. SET @dcJobTypeIDExpect = ''
  16762. SET @dcJobTypeIDExpect = dbo.FormatIDS(@dcJobTypeIDExpect)
  16763. IF @dcRegionID IS NULL
  16764. SET @dcRegionID = ''
  16765. SET @dcRegionID = dbo.FormatIDS(@dcRegionID)
  16766. IF @dcIndustryID IS NULL
  16767. Set @dcIndustryID = ''
  16768. SET @dcIndustryID = dbo.FormatIDS(@dcIndustryID)
  16769. IF @dcIndustryIDExpect IS NULL
  16770. SET @dcIndustryIDExpect = ''
  16771. SET @dcIndustryIDExpect = dbo.FormatIDS(@dcIndustryIDExpect)
  16772. IF @dcSalaryID IS NULL
  16773. SET @dcSalaryID = 0
  16774. IF @IsNegotiable IS NULL
  16775. SET @IsNegotiable = 0
  16776. IF @MinExperience IS NULL
  16777. SET @MinExperience = 99
  16778. IF @dcEducationID IS NULL
  16779. SET @dcEducationID = 0
  16780. IF @LanguageType IS NULL
  16781. SET @LanguageType = 0
  16782. IF @College IS NULL
  16783. SET @College = ''
  16784. IF LEN(@College) < 2
  16785. SET @College = ''
  16786. IF @KeyWord IS NULL OR LEN(@KeyWord) < 2
  16787. SET @KeyWord = ''
  16788. ELSE
  16789. IF LEFT(@KeyWord, 7) = 'major::'
  16790. SET @MajorName = REPLACE(@KeyWord, 'major::', '')
  16791. SET @KeyWord = LTRIM(RTRIM(dbo.SafeSQL(@KeyWord)))
  16792. SET @KeyWord = REPLACE(@KeyWord, ' ', ' near ')
  16793. SET @College = dbo.SafeSQL(@College)
  16794. IF @SubNodeNum IS NULL
  16795. SET @SubNodeNum = 0
  16796. IF @MaxAge IS NULL OR @MaxAge = 0
  16797. SET @MaxAge = 99
  16798. IF @MinAge IS NULL OR @MinAge = 0
  16799. SET @MinAge = 99
  16800. IF @LivePlace IS NULL
  16801. SET @LivePlace = ''
  16802. SET @LivePlace = dbo.FormatIDS(@LivePlace)
  16803. IF @MobilePlace IS NULL
  16804. SET @MobilePlace = ''
  16805. SET @MobilePlace = dbo.FormatIDS(@MobilePlace)
  16806. IF @AccountPlace IS NULL
  16807. SET @AccountPlace = 0
  16808. IF @Gender IS NULL
  16809. SET @Gender = 2
  16810. IF @IncludeOld IS NULL
  16811. SET @IncludeOld = 0
  16812. IF @Major IS NULL
  16813. SET @Major = 0
  16814. IF @Graduation IS NULL
  16815. SET @Graduation = 0
  16816. ELSE IF @Graduation > DATEPART(YEAR, GETDATE()) + 1 OR @Graduation < DATEPART(YEAR, GETDATE()) - 10
  16817. SET @Graduation = 0
  16818. IF @CvMainID IS NULL
  16819. SET @CvMainID = 0
  16820. IF @Standard IS NULL
  16821. SET @Standard = 0
  16822. IF @IsExpand IS NULL
  16823. SET @IsExpand = 0
  16824. IF @CvMainID = 0
  16825. BEGIN
  16826. ----给null值变量赋默认值
  16827. DECLARE @cpSearchConditionID AS INT
  16828. SELECT @cpSearchConditionID=0, @SessionID = 1
  16829. DECLARE @MinId AS INT
  16830. --sqlserver中计划任务自动删除60分钟前的数据
  16831. SELECT TOP 1 @cpSearchConditionID = ID FROM SearchDB..cpSearchCondition WITH(NOLOCK)
  16832. WHERE SessionID=@SessionID AND dcJobTypeID=@dcJobTypeID AND dcJobTypeIDExpect=@dcJobTypeIDExpect
  16833. AND dcRegionID=@dcRegionID AND dcIndustryID=@dcIndustryID AND dcIndustryIDExpect=@dcIndustryIDExpect
  16834. AND IncludeOld=@IncludeOld AND dcSalaryID=@dcSalaryID AND IsNegotiable=@IsNegotiable
  16835. AND MinExperience=@MinExperience AND dcEducationID=@dcEducationID AND LanguageType=@LanguageType
  16836. AND KeyWord=@KeyWord AND College=@College AND Standard=@Standard AND SortType=@SortType
  16837. AND SubNodeNum = @SubNodeNum AND Major = @Major AND Graduation = @Graduation AND Gender=@Gender AND MaxAge=@MaxAge
  16838. AND MinAge=@MinAge AND LivePlace=@LivePlace AND AccountPlace=@AccountPlace AND MobilePlace=@MobilePlace AND IsExpand=@IsExpand
  16839. AND LogTime > DATEADD(M, -60, GETDATE())
  16840. ORDER BY ID DESC
  16841. IF ISNULL(@cpSearchConditionID, 0) = 0
  16842. GOTO SelectReset --无数据,重新搜索
  16843. ELSE
  16844. GOTO GetRecordSet --从临时结果中提取数据
  16845. END
  16846. ELSE
  16847. BEGIN
  16848. ----如果有简历id,则直接显示,不再查询
  16849. SELECT COUNT(1) FROM cvMainPublish WITH(NOLOCK) WHERE ID = @CvMainID AND Valid > 0
  16850. DECLARE @T_Cv AS TABLE(
  16851. ID INT,
  16852. dcMajorID INT,
  16853. Degree TINYINT,
  16854. RelatedWorkYears INT,
  16855. dcSalaryID TINYINT,
  16856. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  16857. RefreshDate SMALLDATETIME,
  16858. LastLoginDate SMALLDATETIME,
  16859. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  16860. Gender BIT,
  16861. BirthDay INT,
  16862. LivePlace INT,
  16863. Attachment VARCHAR(50),
  16864. HasPhoto TINYINT,
  16865. College NVARCHAR(50),
  16866. EduType TINYINT,
  16867. MajorName NVARCHAR(20),
  16868. Graduation INT,
  16869. HasViewed BIT,
  16870. ViewDate SMALLDATETIME,
  16871. HasRemarked BIT,
  16872. LastJobTypeID INT,
  16873. Valid TINYINT
  16874. )
  16875. INSERT INTO @T_Cv(ID,dcMajorID,Degree,RelatedWorkYears,dcSalaryID,Speciality,RefreshDate,LastLoginDate,
  16876. JobName,Gender,BirthDay,LivePlace,LastJobTypeID,Attachment,HasPhoto,HasViewed,HasRemarked,Valid)
  16877. SELECT a.ID,a.dcMajorID,a.Degree,a.RelatedWorkYears,a.dcSalaryID,ISNULL(a.Speciality,a.SpecialityEng) Speciality,a.RefreshDate,
  16878. j.LastLoginDate,ISNULL(a.JobName, '应届毕业生') JobName,j.Gender,j.BirthDay,j.LivePlace,a.LastJobTypeID,
  16879. a.Attachment,j.HasPhoto,0,0,a.Valid FROM cvMainPublish a WITH(NOLOCK)
  16880. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
  16881. WHERE a.ID=@CvMainID AND a.Valid > 0
  16882. UPDATE a SET a.College = ISNULL(b.GraduateCollage,b.GraduateCollageEng), a.EduType = b.EduType,
  16883. a.MajorName = ISNULL(b.MajorName,b.MajorNameEng), a.Graduation = b.Graduation FROM @T_Cv a,
  16884. cvEducationPublish b WITH(NOLOCK) WHERE b.cvMainID = a.ID AND b.Degree = a.Degree
  16885. UPDATE a SET a.HasViewed = 1, a.ViewDate = (SELECT AddDate FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  16886. FROM @T_Cv a WHERE EXISTS(SELECT 'X' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  16887. UPDATE a SET a.HasRemarked = 1
  16888. FROM @T_Cv a WHERE EXISTS(SELECT 'X' FROM caCvRemark WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  16889. SELECT * FROM @T_Cv
  16890. RETURN
  16891. END
  16892. SelectReset: --从cv中搜索数据
  16893. BEGIN
  16894. DECLARE @SQL AS VARCHAR(8000)
  16895. DECLARE @WHERE AS VARCHAR(8000)
  16896. DECLARE @FROM AS VARCHAR(1000)
  16897. ----记录查询条件
  16898. INSERT INTO SearchDB..cpSearchCondition(SessionID,dcJobTypeID,dcJobTypeIDExpect,dcRegionID,dcIndustryID,
  16899. dcIndustryIDExpect,IncludeOld,dcSalaryID,IsNegotiable,SortType,
  16900. MinExperience,dcEducationID,LanguageType,KeyWord,College,Standard,SubNodeNum,
  16901. Major,Graduation,Gender,MaxAge,MinAge,LivePlace,AccountPlace,MobilePlace,IsExpand, ReuseNumber)
  16902. VALUES(@SessionID,@dcJobTypeID,@dcJobTypeIDExpect,@dcRegionID,@dcIndustryID,
  16903. @dcIndustryIDExpect,@IncludeOld,@dcSalaryID,@IsNegotiable,@SortType,
  16904. @MinExperience,@dcEducationID,@LanguageType,@KeyWord,@College,@Standard,@SubNodeNum,
  16905. @Major,@Graduation,@Gender,@MaxAge,@MinAge,@LivePlace,@AccountPlace,@MobilePlace,@IsExpand, 0)
  16906. SET @cpSearchConditionID = @@IDENTITY
  16907. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  16908. DECLARE @T_JobPlace AS TABLE(ID INT)
  16909. DECLARE @T_JobType AS TABLE(ID INT)
  16910. DECLARE @JobType AS VARCHAR(3000)
  16911. DECLARE @JobTypeExpect AS VARCHAR(3000)
  16912. DECLARE @JobPlace AS VARCHAR(2000)
  16913. DECLARE @tmpLivePlace AS VARCHAR(2000)
  16914. DECLARE @tmpMobilePlace AS VARCHAR(2000)
  16915. SET @JobPlace = ''
  16916. SET @tmpLivePlace = ''
  16917. SET @tmpMobilePlace = ''
  16918. SET @JobType=''
  16919. SET @JobTypeExpect = ''
  16920. SET @WHERE = ' WHERE a.Valid > 0'
  16921. ----生成工作地点的表变量
  16922. IF LEN(@dcRegionID) > 0
  16923. BEGIN
  16924. INSERT INTO @T_JobPlace
  16925. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  16926. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  16927. IF @IsExpand = 1
  16928. BEGIN
  16929. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID = ''' + LTRIM(STR(LEFT(ID,2)))+'''' )
  16930. FROM @T_JobPlace WHERE LEN(ID) > 2
  16931. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID = ''' + LTRIM(STR(LEFT(ID,4)))+'''' )
  16932. FROM @T_JobPlace WHERE LEN(ID) > 4
  16933. END
  16934. IF LEN(@JobPlace) > 0
  16935. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  16936. END
  16937. IF LEN(@LivePlace) > 0
  16938. BEGIN
  16939. DELETE FROM @T_JobPlace
  16940. INSERT INTO @T_JobPlace
  16941. SELECT * FROM dbo.fnSplit(@LivePlace, ',')
  16942. SELECT @tmpLivePlace = (@tmpLivePlace + ' OR j.LivePlace Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  16943. IF LEN(@tmpLivePlace) > 0
  16944. SET @tmpLivePlace = RIGHT(@tmpLivePlace, LEN(@tmpLivePlace) -4)
  16945. END
  16946. IF LEN(@MobilePlace) > 0
  16947. BEGIN
  16948. DELETE FROM @T_JobPlace
  16949. INSERT INTO @T_JobPlace
  16950. SELECT * FROM dbo.fnSplit(@MobilePlace, ',')
  16951. SELECT @tmpMobilePlace = (@tmpMobilePlace + ' OR j.MobileRegion Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  16952. IF LEN(@tmpMobilePlace) > 0
  16953. SET @tmpMobilePlace = RIGHT(@tmpMobilePlace, LEN(@tmpMobilePlace) -4)
  16954. END
  16955. ----生成求聘职位的表变量
  16956. IF LEN(@dcJobTypeID) > 0
  16957. BEGIN
  16958. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  16959. INSERT INTO @T_Temp
  16960. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  16961. INSERT INTO @T_JobType
  16962. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  16963. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  16964. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  16965. OR ID IN(SELECT ID FROM @T_TEMP)
  16966. ----生成in字符串
  16967. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  16968. IF RIGHT(@JobType, 1) = ','
  16969. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  16970. END
  16971. IF LEN(@dcJobTypeIDExpect) > 0
  16972. BEGIN
  16973. DECLARE @T_Temp1 AS TABLE(ID INT) --临时表,用于构建组合查询语句
  16974. INSERT INTO @T_Temp1
  16975. SELECT * FROM dbo.fnSplit(@dcJobTypeIDExpect, ',')
  16976. DELETE FROM @T_JobType
  16977. INSERT INTO @T_JobType
  16978. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  16979. WHERE ParentId IN(SELECT ID FROM @T_TEMP1)
  16980. OR ParentId2 in(SELECT ID FROM @T_TEMP1)
  16981. OR ID IN(SELECT ID FROM @T_TEMP1)
  16982. ----生成in字符串
  16983. SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType
  16984. IF RIGHT(@JobTypeExpect, 1) = ','
  16985. SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
  16986. END
  16987. ----建立关键字搜索的临时表
  16988. CREATE TABLE #FullText(
  16989. CvID INT NOT NULL
  16990. )
  16991. ----建立临时表
  16992. CREATE TABLE #Cv(
  16993. ID INT NOT NULL,
  16994. RefreshDate SMALLDATETIME NOT NULL
  16995. )
  16996. ----生成插入临时表的Sql语句
  16997. SET @SQL = '
  16998. INSERT INTO #Cv
  16999. SELECT DISTINCT TOP 2000 a.ID'
  17000. IF @SortType = 1
  17001. SET @SQL = @SQL + ', j.LastLoginDate'
  17002. ELSE
  17003. SET @SQL = @SQL + ', a.RefreshDate'
  17004. SET @FROM = '
  17005. FROM cvMainPublish a WITH(NOLOCK) INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID'
  17006. ----工作经验的职位类别
  17007. IF LEN(@dcJobTypeID) > 0
  17008. BEGIN
  17009. IF @IncludeOld = 0 ----最近从事和曾从事职位
  17010. SET @WHERE = @WHERE + '
  17011. AND (a.LastJobTypeID IN(' + @JobType +'))'
  17012. ELSE
  17013. SET @WHERE = @WHERE + '
  17014. AND (c.dcJobTypeID IN(' + @JobType +'))'
  17015. END
  17016. ----期望职位类别
  17017. IF LEN(@dcJobTypeIDExpect) > 0
  17018. BEGIN
  17019. SET @WHERE = @WHERE + '
  17020. AND (g.dcJobTypeID IN(' + @JobTypeExpect +'))'
  17021. END
  17022. ----工作地点
  17023. IF LEN(@JobPlace) > 0
  17024. SET @WHERE = @WHERE + '
  17025. AND (' + @JobPlace + ')'
  17026. ----现从事行业
  17027. IF LEN(@dcIndustryID) > 0
  17028. SET @WHERE = @WHERE + '
  17029. AND (a.LastIndustryID IN(' + @dcIndustryID + '))'
  17030. ----期望行业
  17031. IF LEN(@dcIndustryIDExpect) > 0
  17032. BEGIN
  17033. SET @WHERE = @WHERE + '
  17034. AND (i.dcIndustryID IN(' + @dcIndustryIDExpect + '))'
  17035. END
  17036. ----下属人数
  17037. IF @SubNodeNum > 0
  17038. BEGIN
  17039. SET @WHERE = @WHERE + '
  17040. AND a.SubNodeNum = ' + LTRIM(STR(@SubNodeNum))
  17041. END
  17042. ----当前所在地
  17043. IF LEN(@tmpLivePlace) > 0
  17044. BEGIN
  17045. SET @WHERE = @WHERE + '
  17046. AND (' + @tmpLivePlace + ')'
  17047. END
  17048. ----Mobile所在地
  17049. IF LEN(@tmpMobilePlace) > 0
  17050. BEGIN
  17051. SET @WHERE = @WHERE + '
  17052. AND (' + @tmpMobilePlace + ')'
  17053. END
  17054. ----户口所在地
  17055. IF @AccountPlace > 0
  17056. BEGIN
  17057. SET @WHERE = @WHERE + '
  17058. AND j.AccountPlace LIKE ''' + LTRIM(STR(@AccountPlace)) + '%'''
  17059. END
  17060. ----专业
  17061. IF @Major > 0
  17062. BEGIN
  17063. SET @WHERE = @WHERE + '
  17064. AND b.dcMajorID = ' + LTRIM(STR(@Major))
  17065. END
  17066. --Graduation
  17067. IF @Graduation = DATEPART(YEAR, GETDATE()) + 1
  17068. BEGIN
  17069. SET @WHERE = @WHERE + '
  17070. AND b.Graduation > ' + LTRIM(STR(@Graduation)) + '00'
  17071. END
  17072. ELSE IF @Graduation > DATEPART(YEAR, GETDATE()) - 10
  17073. BEGIN
  17074. SET @WHERE = @WHERE + '
  17075. AND b.Graduation BETWEEN ' + LTRIM(STR(@Graduation)) + '00 AND ' + LTRIM(STR(@Graduation)) + '99'
  17076. END
  17077. ELSE IF @Graduation = DATEPART(YEAR, GETDATE()) - 10
  17078. BEGIN
  17079. SET @WHERE = @WHERE + '
  17080. AND b.Graduation < ' + LTRIM(STR(@Graduation)) + '99'
  17081. END
  17082. ----性别
  17083. IF @Gender < 2
  17084. BEGIN
  17085. SET @WHERE = @WHERE + '
  17086. AND j.Gender=' + LTRIM(STR(@Gender))
  17087. END
  17088. ----年龄
  17089. IF @MinAge < 99
  17090. BEGIN
  17091. SET @WHERE = @WHERE + '
  17092. AND j.BirthDay <= ' + LTRIM(STR(dbo.AgeToBirth(@MinAge)))
  17093. END
  17094. IF @MaxAge < 99
  17095. BEGIN
  17096. SET @MaxAge = @MaxAge + 1
  17097. SET @WHERE = @WHERE + '
  17098. AND j.BirthDay > ' + LTRIM(STR(dbo.AgeToBirth(@MaxAge)))
  17099. END
  17100. ----薪水
  17101. IF @dcSalaryID > 0
  17102. BEGIN
  17103. SET @WHERE = @WHERE + '
  17104. AND((
  17105. a.dcSalaryID >=' + LTRIM(STR(@dcSalaryID-1)) + '
  17106. AND a.dcSalaryID <=' + LTRIM(STR(@dcSalaryID+1)) + '
  17107. )'
  17108. IF @IsNegotiable = 1 --包括面议
  17109. SET @WHERE = @WHERE + '
  17110. OR a.IsNegotiable=1'
  17111. SET @WHERE = @WHERE + ')'
  17112. END
  17113. ----工作经验要求
  17114. IF @MinExperience < 99
  17115. BEGIN
  17116. IF @MinExperience = 4
  17117. SET @WHERE = @WHERE + '
  17118. AND a.RelatedWorkYears=11'
  17119. ELSE IF @MinExperience = 1
  17120. SET @WHERE = @WHERE + '
  17121. AND a.RelatedWorkYears>=1 AND a.RelatedWorkYears<=2'
  17122. ELSE IF @MinExperience = 2
  17123. SET @WHERE = @WHERE + '
  17124. AND a.RelatedWorkYears>=3 AND a.RelatedWorkYears<=5'
  17125. ELSE IF @MinExperience = 3
  17126. SET @WHERE = @WHERE + '
  17127. AND a.RelatedWorkYears>=6 AND a.RelatedWorkYears<=10'
  17128. ELSE IF @MinExperience = 5
  17129. SET @WHERE = @WHERE + '
  17130. AND a.RelatedWorkYears>=2 AND a.RelatedWorkYears<=3'
  17131. ELSE
  17132. SET @WHERE = @WHERE + '
  17133. AND a.RelatedWorkYears=0'
  17134. END
  17135. ----学历要求
  17136. IF @dcEducationID > 0
  17137. BEGIN
  17138. IF @dcEducationID = 1
  17139. SET @WHERE = @WHERE + ' AND a.Degree IN(1,2,3,4) '
  17140. ELSE IF @dcEducationID = 2
  17141. SET @WHERE = @WHERE + ' AND a.Degree <= 5 '
  17142. ELSE IF @dcEducationID = 3
  17143. SET @WHERE = @WHERE + ' AND a.Degree = 5 '
  17144. ELSE IF @dcEducationID = 4
  17145. SET @WHERE = @WHERE + ' AND a.Degree IN(5,6) '
  17146. ELSE IF @dcEducationID = 5
  17147. SET @WHERE = @WHERE + ' AND a.Degree = 6 '
  17148. ELSE IF @dcEducationID = 6
  17149. SET @WHERE = @WHERE + ' AND a.Degree >= 6 '
  17150. ELSE IF @dcEducationID = 7
  17151. SET @WHERE = @WHERE + ' AND a.Degree = 7 '
  17152. ELSE IF @dcEducationID = 8
  17153. SET @WHERE = @WHERE + ' AND a.Degree = 8 '
  17154. IF @Major > 0 OR LEN(@College) > 0 OR @Standard = 1 OR @MajorName > ''
  17155. SET @WHERE = @WHERE + '
  17156. AND b.Degree = a.Degree'
  17157. IF @Standard = 1
  17158. SET @WHERE = @WHERE + '
  17159. AND b.EduType=1'
  17160. END
  17161. ----语种
  17162. IF @LanguageType > 0
  17163. SET @WHERE = @WHERE + '
  17164. AND d.LanguageType = ' + LTRIM(STR(@LanguageType))
  17165. ----关键词
  17166. IF LEN(@KeyWord) > 0 AND @MajorName IS NULL
  17167. BEGIN
  17168. DECLARE @S DATETIME, @SqlFt VARCHAR(MAX)
  17169. SELECT @S = GETDATE()
  17170. INSERT INTO #FullText
  17171. SELECT [key] FROM CONTAINSTABLE(CvMainPublish, *, @KeyWord, 20000) AS KeyCv
  17172. INSERT INTO #FullText
  17173. SELECT DISTINCT cvMainID FROM CvExperiencePublish WITH(NOLOCK) WHERE ID IN(
  17174. SELECT [key] FROM CONTAINSTABLE(CvExperiencePublish, *, @KeyWord, 20000) AS KeyCv)
  17175. INSERT INTO #FullText
  17176. SELECT DISTINCT cvMainID FROM CvEducationPublish WITH(NOLOCK) WHERE ID IN(
  17177. SELECT [key] FROM CONTAINSTABLE(CvEducationPublish, *, @KeyWord, 20000) AS KeyCv)
  17178. INSERT INTO #FullText
  17179. SELECT DISTINCT cvMainID FROM cvProjectPublish WITH(NOLOCK) WHERE ID IN(
  17180. SELECT [key] FROM CONTAINSTABLE(cvProjectPublish, *, @KeyWord, 20000) AS KeyCv)
  17181. INSERT INTO #FullText
  17182. SELECT DISTINCT cvMainID FROM CvTrainingPublish WITH(NOLOCK) WHERE ID IN(
  17183. SELECT [key] FROM CONTAINSTABLE(CvTrainingPublish, *, @KeyWord, 20000) AS KeyCv)
  17184. --Richard 2011.8.21增加
  17185. INSERT INTO #FullText
  17186. SELECT DISTINCT cvMainID FROM CvAppendixPublish WITH(NOLOCK) WHERE ID IN(
  17187. SELECT [key] FROM CONTAINSTABLE(CvAppendixPublish, *, @KeyWord, 20000) AS KeyCv)
  17188. --Richard 2011.8.24增加
  17189. SELECT @SqlFt = 'SELECT [key] FROM CONTAINSTABLE(CvMainPublish, *, ''' + @KeyWord + ''',20000) AS KeyCv ORDER BY [key] DESC 开始:' + CONVERT(varchar(8), @S, 8) + ' 结束:' + CONVERT(varchar(8), getdate(), 8)
  17190. UPDATE SearchDB..cpSearchCondition SET SqlFT = @SqlFt WHERE ID = @cpSearchConditionID
  17191. END
  17192. ----学校名称
  17193. IF LEN(@College) > 0
  17194. SET @WHERE = @WHERE + '
  17195. AND b.GraduateCollage LIKE ''%' + LTRIM((@College)) + '%'''
  17196. IF LEN(@MajorName) > 0
  17197. SET @WHERE = @WHERE + '
  17198. AND b.MajorName LIKE ''%' + LTRIM((@MajorName)) + '%'''
  17199. IF CHARINDEX('b.',@WHERE) > 0
  17200. SET @FROM = @FROM + ' INNER JOIN cvEducationPublish b WITH(NOLOCK) ON a.ID=b.cvMainID'
  17201. IF CHARINDEX('c.',@WHERE) > 0
  17202. SET @FROM = @FROM + ' INNER JOIN CvExperiencePublish c WITH(NOLOCK) ON a.ID=c.cvMainID'
  17203. IF CHARINDEX('d.',@WHERE) > 0
  17204. SET @FROM = @FROM + ' INNER JOIN cvLanguagePublish d WITH(NOLOCK) ON a.ID=d.cvMainID'
  17205. IF CHARINDEX('e.',@WHERE) > 0
  17206. SET @FROM = @FROM + ' INNER JOIN CvTrainingPublish e WITH(NOLOCK) ON a.ID=e.cvMainID'
  17207. IF CHARINDEX('f.',@WHERE) > 0
  17208. SET @FROM = @FROM + ' INNER JOIN cvProjectPublish f WITH(NOLOCK) ON a.ID=f.cvMainID'
  17209. IF CHARINDEX('g.',@WHERE) > 0
  17210. SET @FROM = @FROM + ' INNER JOIN cvJobTypePublish g WITH(NOLOCK) ON a.ID=g.cvMainID'
  17211. IF CHARINDEX('h.',@WHERE) > 0
  17212. SET @FROM = @FROM + ' INNER JOIN cvJobPlacePublish h WITH(NOLOCK) ON a.ID=h.cvMainID'
  17213. IF CHARINDEX('i.',@WHERE) > 0
  17214. SET @FROM = @FROM + ' INNER JOIN cvIndustryPublish i WITH(NOLOCK) ON a.ID=i.cvMainID'
  17215. IF LEN(@KeyWord) > 0 AND @MajorName IS NULL
  17216. SET @FROM = @FROM + ' INNER JOIN #FullText k WITH(NOLOCK) ON a.ID=k.cvID'
  17217. SET @SQL = @SQL + @FROM + @WHERE
  17218. IF @SortType = 1
  17219. SET @SQL = @SQL + '
  17220. ORDER BY j.LastLoginDate DESC, a.ID'
  17221. ELSE
  17222. SET @SQL = @SQL + '
  17223. ORDER BY a.RefreshDate DESC, a.ID'
  17224. --PRINT @SQL
  17225. ----把符合条件的职位全部列出
  17226. UPDATE SearchDB..cpSearchCondition SET Sql = REPLACE(@SQL, 'INSERT INTO #Cv', ''), StartDate = GETDATE() WHERE ID = @cpSearchConditionID
  17227. EXEC(@SQL)
  17228. ----记录查询结果总数
  17229. DECLARE @ValidCvNumber INT
  17230. SET @ValidCvNumber = @@ROWCOUNT
  17231. UPDATE SearchDB..cpSearchCondition SET ValidCvNumber = @ValidCvNumber WHERE ID = @cpSearchConditionID
  17232. --记录查询时间
  17233. UPDATE SearchDB..cpSearchCondition SET EndDate = GETDATE() WHERE ID = @cpSearchConditionID
  17234. INSERT INTO SearchDB..cpSearchCvID
  17235. SELECT TOP 2000 @cpSearchConditionID, ID FROM #Cv WITH(NOLOCK)
  17236. DROP TABLE #Cv
  17237. DROP TABLE #FullText
  17238. GOTO GetRecordSet
  17239. END
  17240. GetRecordSet:
  17241. BEGIN
  17242. DECLARE @PageSize AS TINYINT
  17243. SET @PageSize = 20 --每页的行数
  17244. ----返回查询数量
  17245. UPDATE SearchDB..cpSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@cpSearchConditionID
  17246. SELECT ValidCvNumber FROM SearchDB..cpSearchCondition WITH(NOLOCK) WHERE ID=@cpSearchConditionID
  17247. ----返回20行查询结果
  17248. IF @PageNumber > 0
  17249. BEGIN
  17250. DECLARE @T_CvList AS TABLE(
  17251. ID INT,
  17252. cvEducationID INT,
  17253. dcMajorID INT,
  17254. Degree TINYINT,
  17255. RelatedWorkYears INT,
  17256. dcSalaryID TINYINT,
  17257. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  17258. RefreshDate SMALLDATETIME,
  17259. LastLoginDate SMALLDATETIME,
  17260. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  17261. Gender BIT,
  17262. BirthDay INT,
  17263. LivePlace INT,
  17264. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  17265. HasPhoto TINYINT,
  17266. College NVARCHAR(50),
  17267. EduType TINYINT,
  17268. MajorName NVARCHAR(20),
  17269. Graduation INT,
  17270. HasViewed BIT,
  17271. ViewDate SMALLDATETIME,
  17272. HasRemarked BIT,
  17273. LastJobTypeID INT,
  17274. Valid TINYINT
  17275. )
  17276. SELECT @MinId = MIN(ID)FROM SearchDB..cpSearchCvID WITH(NOLOCK) WHERE cpSearchConditionID=@cpSearchConditionID
  17277. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  17278. INSERT INTO @T_CvList(ID,dcMajorID,Degree,RelatedWorkYears,dcSalaryID,Speciality,RefreshDate,LastLoginDate,
  17279. JobName,Gender,BirthDay,LivePlace,LastJobTypeID,Attachment,HasPhoto,HasViewed,HasRemarked,Valid)
  17280. SELECT top 20 a.ID,a.dcMajorID,a.Degree,a.RelatedWorkYears,a.dcSalaryID,ISNULL(a.Speciality,a.SpecialityEng) Speciality,a.RefreshDate,
  17281. j.LastLoginDate,ISNULL(a.JobName, '应届毕业生') JobName,j.Gender,j.BirthDay,j.LivePlace,a.LastJobTypeID,
  17282. a.Attachment,j.HasPhoto,0,0,a.Valid FROM cvMainPublish a WITH(NOLOCK)
  17283. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
  17284. INNER JOIN SearchDB..cpSearchCvID b ON a.id=b.CvID
  17285. WHERE b.cpSearchConditionID=@cpSearchConditionID AND b.ID>=@MinId
  17286. ORDER BY b.ID,a.ID DESC
  17287. --RICHARD 2011-7-23 16:51分修改
  17288. UPDATE a SET a.cvEducationID = (
  17289. SELECT TOP 1 ID FROM cvEducationPublish WITH(NOLOCK)
  17290. WHERE cvEducationPublish.cvMainID = a.ID
  17291. AND a.Degree = cvEducationPublish.Degree
  17292. ORDER BY Graduation DESC)
  17293. FROM @T_CvList a
  17294. UPDATE a SET a.College = ISNULL(b.GraduateCollage,b.GraduateCollageEng), a.EduType = b.EduType,
  17295. a.MajorName = ISNULL(b.MajorName,b.MajorNameEng), a.Graduation = b.Graduation
  17296. FROM @T_CvList a, cvEducationPublish b WITH(NOLOCK)
  17297. WHERE b.ID = a.cvEducationID
  17298. UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
  17299. FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
  17300. WHERE b.cvMainID = a.ID AND caMainID=@caMainID
  17301. UPDATE a SET a.HasRemarked = 1
  17302. FROM @T_CvList a WHERE EXISTS(SELECT 'X' FROM caCvRemark WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  17303. SELECT * FROM @T_CvList
  17304. END
  17305. RETURN
  17306. END
  17307. END TRY
  17308. BEGIN CATCH
  17309. ---检查是否已经建立临时表,已经建立则删除
  17310. BEGIN TRY
  17311. DROP TABLE #FullText
  17312. END TRY
  17313. BEGIN CATCH
  17314. END CATCH
  17315. BEGIN TRY
  17316. DROP TABLE #cv
  17317. END TRY
  17318. BEGIN CATCH
  17319. END CATCH
  17320. PRINT '查询时出现错误,请联系技术人员检查,错误信息:'
  17321. PRINT Error_Message()
  17322. PRINT Error_Number()
  17323. PRINT Error_Line()
  17324. END CATCH
  17325. GO
  17326. /****** Object: StoredProcedure [dbo].[ccCvBySearchSelect] Script Date: 2018/12/13 19:06:37 ******/
  17327. SET ANSI_NULLS ON
  17328. GO
  17329. SET QUOTED_IDENTIFIER ON
  17330. GO
  17331. --Peter 2014-08-25修改
  17332. --添加首次搜索简历积分记录
  17333. --Carl 2018-02-08 修改 最低学历添加大专及以上
  17334. CREATE PROCEDURE [dbo].[ccCvBySearchSelect]
  17335. (
  17336. @dcJobTypeID VARCHAR(50), --职位类别
  17337. @dcRegionID VARCHAR(50), --求职地区
  17338. @dcIndustryID VARCHAR(50), --现从事行业
  17339. @IncludeOld BIT, --1包含曾从事职业
  17340. @dcJobTypeIDExpect VARCHAR(50), --期望职位类别
  17341. @dcIndustryIDExpect VARCHAR(50), --期望求职行业
  17342. @dcSalaryID TINYINT, --月薪
  17343. @IsNegotiable BIT, --1允许面议,不面议
  17344. @MinExperience TINYINT, --工作经验
  17345. @dcEducationID TINYINT, --最低学历
  17346. @LanguageType SMALLINT, --语种
  17347. @KeyWord NVARCHAR(20), --关键词
  17348. @College NVARCHAR(50), --学校名称
  17349. @Standard BIT, --是否统招
  17350. @SubNodeNum INT, --下属人数
  17351. @Major INT, --所学专业
  17352. @Graduation INT, --毕业时间 year
  17353. @Gender TINYINT, --性别, 2不限
  17354. @MaxAge SMALLINT, --最大年龄
  17355. @MinAge SMALLINT, --最小年龄
  17356. @LivePlace VARCHAR(50), --现居住地
  17357. @AccountPlace INT, --户口所在地
  17358. @MobilePlace VARCHAR(50), --Mobile住地
  17359. @MinHeight TINYINT, --MinHeight
  17360. @MaxHeight TINYINT, --MaxHeight
  17361. @SortType TINYINT, --排序方式
  17362. @CvMainID INT, --简历ID
  17363. --@dcCareerStatus TINYINT, --简历状态
  17364. --sessionid,没有采用全部人员共享方式,因为10分钟内,搜索相同条件的可能性很大,
  17365. --而10分钟搜索的用户翻到第二页时内容可能会和第一页一样。这样让用户很难理解。
  17366. --使用SessionID, 可以保证60分钟内查询结果一致。出现不一致的几率很小
  17367. @SessionID INT,
  17368. @PageNumber INT, --翻页页码
  17369. @IsExpand BIT, --是否扩大地区范围
  17370. @caMainID INT, --企业用户ID,用来判断是否和建立联系
  17371. @cvEmployType INT --期望工作性质ID,用来限制期望工作性质选项
  17372. )
  17373. AS
  17374. --return
  17375. SET NOCOUNT ON
  17376. BEGIN TRY
  17377. DECLARE @MajorName AS NVARCHAR(20), @KeyTemp NVARCHAR(20)
  17378. IF @dcJobTypeID IS NULL
  17379. SET @dcJobTypeID = ''
  17380. SET @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID)
  17381. IF @dcJobTypeIDExpect IS NULL
  17382. SET @dcJobTypeIDExpect = ''
  17383. SET @dcJobTypeIDExpect = dbo.FormatIDS(@dcJobTypeIDExpect)
  17384. IF @dcRegionID IS NULL
  17385. SET @dcRegionID = ''
  17386. SET @dcRegionID = dbo.FormatIDS(@dcRegionID)
  17387. IF @dcIndustryID IS NULL
  17388. Set @dcIndustryID = ''
  17389. SET @dcIndustryID = dbo.FormatIDS(@dcIndustryID)
  17390. IF @dcIndustryIDExpect IS NULL
  17391. SET @dcIndustryIDExpect = ''
  17392. SET @dcIndustryIDExpect = dbo.FormatIDS(@dcIndustryIDExpect)
  17393. IF @dcSalaryID IS NULL
  17394. SELECT @dcSalaryID = 0, @IsNegotiable = 0
  17395. IF @IsNegotiable IS NULL
  17396. SET @IsNegotiable = 0
  17397. IF @MinExperience IS NULL
  17398. SET @MinExperience = 99
  17399. IF @dcEducationID IS NULL
  17400. SET @dcEducationID = 0
  17401. IF @LanguageType IS NULL
  17402. SET @LanguageType = 0
  17403. IF @College IS NULL
  17404. SET @College = ''
  17405. IF LEN(@College) < 2
  17406. SET @College = ''
  17407. IF @SortType IS NULL
  17408. SET @SortType = 0
  17409. WHILE @KeyWord LIKE '% %'
  17410. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  17411. SET @KeyWord = LTRIM(RTRIM(dbo.SafeSQL(@KeyWord)))
  17412. SET @KeyTemp = @KeyWord
  17413. IF @KeyWord IS NULL OR LEN(@KeyWord) < 2
  17414. SELECT @KeyWord = '', @KeyTemp = ''
  17415. ELSE
  17416. BEGIN
  17417. IF LEFT(@KeyWord, 7) = 'major::'
  17418. BEGIN
  17419. SELECT @MajorName = REPLACE(@KeyWord, 'major::', '')
  17420. SELECT @KeyWord = '', @KeyTemp = ''
  17421. END
  17422. ELSE
  17423. BEGIN
  17424. DECLARE @p INT
  17425. SET @p = CHARINDEX('@@', @KeyWord)
  17426. IF @p > 0
  17427. BEGIN
  17428. SELECT @MajorName = LTRIM(RTRIM(RIGHT(@KeyWord, LEN(@KeyWord) - @p - 1)))
  17429. SELECT @KeyTemp = LEFT(@KeyWord, @p - 1)
  17430. IF LEN(@KeyTemp) < 2
  17431. SET @KeyTemp = ''
  17432. END
  17433. END
  17434. END
  17435. SET @KeyTemp = REPLACE(@KeyTemp, ' ', ' near ')
  17436. SET @College = LTRIM(RTRIM(dbo.SafeSQL(@College)))
  17437. IF @SubNodeNum IS NULL
  17438. SET @SubNodeNum = 0
  17439. IF @MaxAge IS NULL OR @MaxAge = 0
  17440. SET @MaxAge = 99
  17441. IF @MinAge IS NULL OR @MinAge = 0
  17442. SET @MinAge = 99
  17443. IF @LivePlace IS NULL
  17444. SET @LivePlace = ''
  17445. SET @LivePlace = dbo.FormatIDS(@LivePlace)
  17446. IF @MobilePlace IS NULL
  17447. SET @MobilePlace = ''
  17448. SET @MobilePlace = dbo.FormatIDS(@MobilePlace)
  17449. IF @AccountPlace IS NULL
  17450. SET @AccountPlace = 0
  17451. IF @Gender IS NULL
  17452. SET @Gender = 2
  17453. IF @IncludeOld IS NULL
  17454. SET @IncludeOld = 0
  17455. IF @Major IS NULL
  17456. SET @Major = 0
  17457. IF @Graduation IS NULL
  17458. SET @Graduation = 0
  17459. ELSE IF @Graduation > DATEPART(YEAR, GETDATE()) + 1 OR @Graduation < DATEPART(YEAR, GETDATE()) -10
  17460. SET @Graduation = 0
  17461. IF @CvMainID IS NULL
  17462. SET @CvMainID = 0
  17463. IF @Standard IS NULL
  17464. SET @Standard = 0
  17465. IF @IsExpand IS NULL
  17466. SET @IsExpand = 0
  17467. SET @MinHeight = ISNULL(@MinHeight, 0)
  17468. SET @MaxHeight = ISNULL(@MaxHeight, 250)
  17469. IF @MinHeight < 140 OR @MinHeight > 200
  17470. SET @MinHeight = 0
  17471. IF @cvEmployType IS NULL
  17472. SET @cvEmployType = 0
  17473. IF @CvMainID = 0
  17474. BEGIN
  17475. ----给null值变量赋默认值
  17476. DECLARE @cpSearchConditionID AS INT, @MinId AS INT
  17477. SELECT @cpSearchConditionID = 0
  17478. IF @SessionID != -1
  17479. SELECT @SessionId = 1
  17480. --sqlserver中计划任务自动删除60分钟前的数据
  17481. SELECT TOP 1 @cpSearchConditionID = ID FROM SearchDB..cpSearchCondition WITH(NOLOCK)
  17482. WHERE SessionID=@SessionID AND dcJobTypeID=@dcJobTypeID AND dcJobTypeIDExpect=@dcJobTypeIDExpect
  17483. AND dcRegionID=@dcRegionID AND dcIndustryID=@dcIndustryID AND dcIndustryIDExpect=@dcIndustryIDExpect
  17484. AND IncludeOld=@IncludeOld AND dcSalaryID=@dcSalaryID AND IsNegotiable=@IsNegotiable
  17485. AND MinExperience=@MinExperience AND dcEducationID=@dcEducationID AND LanguageType=@LanguageType
  17486. AND KeyWord=@KeyWord AND College=@College AND Standard=@Standard AND SortType=@SortType
  17487. AND SubNodeNum = @SubNodeNum AND Major = @Major AND Graduation = @Graduation AND Gender=@Gender AND MaxAge=@MaxAge
  17488. AND MinAge=@MinAge AND LivePlace=@LivePlace AND AccountPlace=@AccountPlace AND MobilePlace=@MobilePlace
  17489. AND IsExpand=@IsExpand AND MinHeight = @MinHeight AND MaxHeight = @MaxHeight AND LogTime > DATEADD(M, -60, GETDATE())
  17490. AND EmployType=@cvEmployType
  17491. ORDER BY ID DESC
  17492. IF ISNULL(@cpSearchConditionID, 0) = 0
  17493. GOTO SelectReset --无数据,重新搜索
  17494. ELSE
  17495. GOTO GetRecordSet --从临时结果中提取数据
  17496. END
  17497. ELSE
  17498. BEGIN
  17499. ----如果有简历id,则直接显示,不再查询
  17500. SELECT COUNT(1) FROM cvmainPublish WITH(NOLOCK) WHERE ID = @CvMainID AND Valid > 0
  17501. DECLARE @T_Cv AS TABLE(
  17502. ID INT,
  17503. dcMajorID INT,
  17504. Degree TINYINT,
  17505. RelatedWorkYears INT,
  17506. dcSalaryID TINYINT,
  17507. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  17508. RefreshDate SMALLDATETIME,
  17509. LastLoginDate SMALLDATETIME,
  17510. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  17511. Gender BIT,
  17512. BirthDay INT,
  17513. LivePlace INT,
  17514. Attachment VARCHAR(50),
  17515. HasPhoto TINYINT,
  17516. College NVARCHAR(50),
  17517. EduType TINYINT,
  17518. MajorName NVARCHAR(20),
  17519. Graduation INT,
  17520. HasViewed BIT,
  17521. ViewDate SMALLDATETIME,
  17522. HasRemarked BIT,
  17523. LastJobTypeID INT,
  17524. Valid TINYINT,
  17525. IsOnline BIT,
  17526. HasWeiXin BIT,
  17527. paMainId INT,
  17528. SecondId VARCHAR(10)
  17529. )
  17530. INSERT INTO @T_Cv(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, Speciality, RefreshDate, LastLoginDate,
  17531. JobName, Gender, BirthDay, LivePlace, LastJobTypeID, Attachment, HasPhoto, HasViewed, HasRemarked, Valid, IsOnline, paMainId, secondId)
  17532. SELECT a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, ISNULL(a.Speciality, a.SpecialityEng) Speciality, a.RefreshDate,
  17533. j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, j.Gender, j.BirthDay, j.LivePlace, a.LastJobTypeID,
  17534. a.Attachment, j.HasPhoto, 0, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), a.paMainId, a.secondId
  17535. FROM cvmainPublish a WITH(NOLOCK)
  17536. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID = j.ID
  17537. WHERE a.ID = @CvMainID AND a.Valid > 0
  17538. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  17539. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  17540. FROM @T_Cv a, cvEducationPublish b WITH(NOLOCK)
  17541. WHERE b.cvMainID = a.ID
  17542. AND b.Degree = a.Degree
  17543. UPDATE a SET a.HasViewed = 1, a.ViewDate = (SELECT AddDate FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  17544. FROM @T_Cv a
  17545. WHERE EXISTS(SELECT 'X' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  17546. --修改是否绑定微信
  17547. UPDATE a SET HasWeiXin = 1
  17548. FROM @T_Cv a, WxFans b WITH(NOLOCK)
  17549. WHERE a.PaMainID = b.PaMainID
  17550. AND b.Status = 2
  17551. SELECT a.*,b.Description DegreeName,c.Description LivePlaceName, dbo.BirthToAge(a.BirthDay) Age,d.Description dcSalaryName
  17552. FROM @T_Cv a
  17553. LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  17554. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  17555. LEFT JOIN dcSalary d WITH(NOLOCK) ON d.ID = a.dcSalaryID
  17556. RETURN
  17557. END
  17558. SelectReset: --从cv中搜索数据
  17559. BEGIN
  17560. DECLARE @SQL AS VARCHAR(8000)
  17561. DECLARE @WHERE AS VARCHAR(8000)
  17562. DECLARE @FROM AS VARCHAR(1000)
  17563. ----记录查询条件
  17564. INSERT INTO SearchDB..cpSearchCondition(SessionID, dcJobTypeID, dcJobTypeIDExpect, dcRegionID, dcIndustryID,
  17565. dcIndustryIDExpect, IncludeOld, dcSalaryID, IsNegotiable, SortType,
  17566. MinExperience, dcEducationID, LanguageType, KeyWord, College, Standard, SubNodeNum,
  17567. Major, Graduation, Gender, MaxAge, MinAge, LivePlace, AccountPlace, MobilePlace, IsExpand, MinHeight, MaxHeight, ReuseNumber, EmployType)
  17568. VALUES(@SessionID, @dcJobTypeID, @dcJobTypeIDExpect, @dcRegionID, @dcIndustryID,
  17569. @dcIndustryIDExpect, @IncludeOld, @dcSalaryID, @IsNegotiable, @SortType,
  17570. @MinExperience, @dcEducationID, @LanguageType, @KeyWord, @College, @Standard, @SubNodeNum,
  17571. @Major, @Graduation, @Gender, @MaxAge, @MinAge, @LivePlace, @AccountPlace, @MobilePlace, @IsExpand, @MinHeight, @MaxHeight, 0, @cvEmployType)
  17572. SET @cpSearchConditionID = @@IDENTITY
  17573. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  17574. DECLARE @T_JobPlace AS TABLE(ID INT)
  17575. DECLARE @T_JobType AS TABLE(ID INT)
  17576. DECLARE @tmpMobilePlace AS VARCHAR(2000),
  17577. @JobType AS VARCHAR(3000), @JobTypeExpect AS VARCHAR(3000),
  17578. @JobPlace AS VARCHAR(2000), @tmpLivePlace AS VARCHAR(2000)
  17579. SELECT @JobPlace = '', @tmpLivePlace = '', @tmpMobilePlace = '', @JobType='', @JobTypeExpect = '', @WHERE = ' WHERE a.Valid > 0'
  17580. ----生成工作地点的表变量
  17581. IF LEN(@dcRegionID) > 0
  17582. BEGIN
  17583. INSERT INTO @T_JobPlace
  17584. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  17585. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  17586. IF @IsExpand = 1
  17587. BEGIN
  17588. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID = ''' + LTRIM(STR(LEFT(ID, 2)))+'''' )
  17589. FROM @T_JobPlace WHERE LEN(ID) > 2
  17590. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID = ''' + LTRIM(STR(LEFT(ID, 4)))+'''' )
  17591. FROM @T_JobPlace WHERE LEN(ID) > 4
  17592. END
  17593. IF LEN(@JobPlace) > 0
  17594. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  17595. END
  17596. IF LEN(@LivePlace) > 0
  17597. BEGIN
  17598. DELETE FROM @T_JobPlace
  17599. INSERT INTO @T_JobPlace
  17600. SELECT * FROM dbo.fnSplit(@LivePlace, ',')
  17601. SELECT @tmpLivePlace = (@tmpLivePlace + ' OR j.LivePlace Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  17602. IF LEN(@tmpLivePlace) > 0
  17603. SET @tmpLivePlace = RIGHT(@tmpLivePlace, LEN(@tmpLivePlace) -4)
  17604. END
  17605. IF LEN(@MobilePlace) > 0
  17606. BEGIN
  17607. DELETE FROM @T_JobPlace
  17608. INSERT INTO @T_JobPlace
  17609. SELECT * FROM dbo.fnSplit(@MobilePlace, ',')
  17610. SELECT @tmpMobilePlace = (@tmpMobilePlace + ' OR j.MobileRegion Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  17611. IF LEN(@tmpMobilePlace) > 0
  17612. SET @tmpMobilePlace = RIGHT(@tmpMobilePlace, LEN(@tmpMobilePlace) -4)
  17613. END
  17614. ----生成求聘职位的表变量
  17615. IF LEN(@dcJobTypeID) > 0
  17616. BEGIN
  17617. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  17618. INSERT INTO @T_Temp
  17619. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  17620. INSERT INTO @T_JobType
  17621. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  17622. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  17623. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  17624. OR ID IN(SELECT ID FROM @T_TEMP)
  17625. ----生成in字符串
  17626. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  17627. IF RIGHT(@JobType, 1) = ', '
  17628. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  17629. END
  17630. IF LEN(@dcJobTypeIDExpect) > 0
  17631. BEGIN
  17632. DECLARE @T_Temp1 AS TABLE(ID INT) --临时表,用于构建组合查询语句
  17633. INSERT INTO @T_Temp1
  17634. SELECT * FROM dbo.fnSplit(@dcJobTypeIDExpect, ',')
  17635. DELETE FROM @T_JobType
  17636. INSERT INTO @T_JobType
  17637. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  17638. WHERE ParentId IN(SELECT ID FROM @T_TEMP1)
  17639. OR ParentId2 in(SELECT ID FROM @T_TEMP1)
  17640. OR ID IN(SELECT ID FROM @T_TEMP1)
  17641. ----生成in字符串
  17642. SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType
  17643. IF RIGHT(@JobTypeExpect, 1) = ', '
  17644. SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
  17645. END
  17646. ----建立关键字搜索的临时表
  17647. CREATE TABLE #FullText(
  17648. CvID INT NOT NULL,
  17649. Rank INT
  17650. )
  17651. ----建立临时表
  17652. CREATE TABLE #Cv(
  17653. ID INT NOT NULL,
  17654. RefreshDate SMALLDATETIME NOT NULL,
  17655. RANK INT
  17656. )
  17657. ----生成插入临时表的Sql语句
  17658. SET @SQL = '
  17659. INSERT INTO #Cv
  17660. SELECT DISTINCT TOP 2000 a.ID, j.LastLoginDate'
  17661. IF LEN(@KeyTemp) > 0
  17662. SET @Sql = @Sql + ', k.Rank'
  17663. ELSE
  17664. SET @Sql = @Sql + ', 1'
  17665. SET @FROM = '
  17666. FROM cvmainPublish a WITH(NOLOCK) INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID = j.ID'
  17667. ----工作经验的职位类别
  17668. IF LEN(@dcJobTypeID) > 0
  17669. BEGIN
  17670. IF @IncludeOld = 0 ----最近从事和曾从事职位
  17671. SET @WHERE = @WHERE + '
  17672. AND (a.LastJobTypeID IN(' + @JobType +'))'
  17673. ELSE
  17674. SET @WHERE = @WHERE + '
  17675. AND (c.dcJobTypeID IN(' + @JobType +'))'
  17676. END
  17677. ----期望职位类别
  17678. IF LEN(@dcJobTypeIDExpect) > 0
  17679. BEGIN
  17680. SET @WHERE = @WHERE + '
  17681. AND (g.dcJobTypeID IN(' + @JobTypeExpect +'))'
  17682. END
  17683. ----工作地点
  17684. IF LEN(@JobPlace) > 0
  17685. SET @WHERE = @WHERE + '
  17686. AND (' + @JobPlace + ')'
  17687. ----现从事行业
  17688. IF LEN(@dcIndustryID) > 0
  17689. SET @WHERE = @WHERE + '
  17690. AND (a.LastIndustryID IN(' + @dcIndustryID + '))'
  17691. ----期望行业
  17692. IF LEN(@dcIndustryIDExpect) > 0
  17693. BEGIN
  17694. SET @WHERE = @WHERE + '
  17695. AND (i.dcIndustryID IN(' + @dcIndustryIDExpect + '))'
  17696. END
  17697. ----下属人数
  17698. IF @SubNodeNum > 0
  17699. BEGIN
  17700. SET @WHERE = @WHERE + '
  17701. AND a.SubNodeNum = ' + LTRIM(STR(@SubNodeNum))
  17702. END
  17703. ----当前所在地
  17704. IF LEN(@tmpLivePlace) > 0
  17705. BEGIN
  17706. SET @WHERE = @WHERE + '
  17707. AND (' + @tmpLivePlace + ')'
  17708. END
  17709. IF @SessionId = -1
  17710. BEGIN
  17711. SET @WHERE = @WHERE + '
  17712. AND j.Id IN(SELECT paMainId FROM paOnline)'
  17713. END
  17714. ----Mobile所在地
  17715. IF LEN(@tmpMobilePlace) > 0
  17716. BEGIN
  17717. SET @WHERE = @WHERE + '
  17718. AND (' + @tmpMobilePlace + ')'
  17719. END
  17720. ----户口所在地
  17721. IF @AccountPlace > 0
  17722. BEGIN
  17723. SET @WHERE = @WHERE + '
  17724. AND j.AccountPlace LIKE ''' + LTRIM(STR(@AccountPlace)) + '%'''
  17725. END
  17726. ----专业
  17727. IF @Major > 0
  17728. BEGIN
  17729. SET @WHERE = @WHERE + '
  17730. AND b.dcMajorID = ' + LTRIM(STR(@Major))
  17731. END
  17732. --Graduation
  17733. IF @Graduation = DATEPART(YEAR, GETDATE()) + 1
  17734. BEGIN
  17735. SET @WHERE = @WHERE + '
  17736. AND b.Graduation > ' + LTRIM(STR(@Graduation)) + '00'
  17737. END
  17738. ELSE IF @Graduation > DATEPART(YEAR, GETDATE()) - 10
  17739. BEGIN
  17740. SET @WHERE = @WHERE + '
  17741. AND b.Graduation BETWEEN ' + LTRIM(STR(@Graduation)) + '00 AND ' + LTRIM(STR(@Graduation)) + '99'
  17742. END
  17743. ELSE IF @Graduation = DATEPART(YEAR, GETDATE()) - 10
  17744. BEGIN
  17745. SET @WHERE = @WHERE + '
  17746. AND b.Graduation < ' + LTRIM(STR(@Graduation)) + '99'
  17747. END
  17748. ----性别
  17749. IF @Gender < 2
  17750. BEGIN
  17751. SET @WHERE = @WHERE + '
  17752. AND j.Gender = ' + LTRIM(STR(@Gender))
  17753. END
  17754. ----年龄
  17755. IF @MinAge < 99
  17756. BEGIN
  17757. SET @WHERE = @WHERE + '
  17758. AND j.BirthDay <= ' + LTRIM(STR(dbo.AgeToBirth(@MinAge)))
  17759. END
  17760. IF @MaxAge < 99
  17761. BEGIN
  17762. SET @MaxAge = @MaxAge + 1
  17763. SET @WHERE = @WHERE + '
  17764. AND j.BirthDay > ' + LTRIM(STR(dbo.AgeToBirth(@MaxAge)))
  17765. END
  17766. IF @MinHeight > 139
  17767. BEGIN
  17768. SET @WHERE = @WHERE + '
  17769. AND j.Height >= ' + LTRIM(STR(@MinHeight))
  17770. END
  17771. IF @MaxHeight < 231
  17772. BEGIN
  17773. SET @WHERE = @WHERE + '
  17774. AND j.Height <= ' + LTRIM(STR(@MaxHeight))
  17775. END
  17776. ----薪水
  17777. IF @dcSalaryID > 0
  17778. BEGIN
  17779. SET @WHERE = @WHERE + '
  17780. AND((
  17781. a.dcSalaryID >= ' + LTRIM(STR(@dcSalaryID-1)) + '
  17782. AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID+1)) + '
  17783. )'
  17784. IF @IsNegotiable = 1 --包括面议
  17785. SET @WHERE = @WHERE + '
  17786. OR a.IsNegotiable = 1'
  17787. SET @WHERE = @WHERE + ')'
  17788. END
  17789. ----工作经验要求
  17790. IF @MinExperience < 99
  17791. BEGIN
  17792. IF @MinExperience = 4
  17793. SET @WHERE = @WHERE + '
  17794. AND a.RelatedWorkYears = 11'
  17795. ELSE IF @MinExperience = 1
  17796. SET @WHERE = @WHERE + '
  17797. AND a.RelatedWorkYears >= 1 AND a.RelatedWorkYears <= 2'
  17798. ELSE IF @MinExperience = 2
  17799. SET @WHERE = @WHERE + '
  17800. AND a.RelatedWorkYears >= 3 AND a.RelatedWorkYears <= 5'
  17801. ELSE IF @MinExperience = 3
  17802. SET @WHERE = @WHERE + '
  17803. AND a.RelatedWorkYears >= 6 AND a.RelatedWorkYears <= 10'
  17804. ELSE IF @MinExperience = 5
  17805. SET @WHERE = @WHERE + '
  17806. AND a.RelatedWorkYears >= 2 AND a.RelatedWorkYears <= 3'
  17807. ELSE
  17808. SET @WHERE = @WHERE + '
  17809. AND a.RelatedWorkYears = 0'
  17810. END
  17811. ----学历要求
  17812. IF @dcEducationID > 0
  17813. BEGIN
  17814. IF @dcEducationID = 1
  17815. SET @WHERE = @WHERE + ' AND a.Degree IN(1, 2, 3, 4) '
  17816. ELSE IF @dcEducationID = 2
  17817. SET @WHERE = @WHERE + ' AND a.Degree <= 5 '
  17818. ELSE IF @dcEducationID = 3
  17819. SET @WHERE = @WHERE + ' AND a.Degree = 5 '
  17820. ELSE IF @dcEducationID = 4
  17821. SET @WHERE = @WHERE + ' AND a.Degree IN(5, 6) '
  17822. ELSE IF @dcEducationID = 5
  17823. SET @WHERE = @WHERE + ' AND a.Degree = 6 '
  17824. ELSE IF @dcEducationID = 6
  17825. SET @WHERE = @WHERE + ' AND a.Degree >= 6 '
  17826. ELSE IF @dcEducationID = 7
  17827. SET @WHERE = @WHERE + ' AND a.Degree = 7 '
  17828. ELSE IF @dcEducationID = 8
  17829. SET @WHERE = @WHERE + ' AND a.Degree = 8 '
  17830. ELSE IF @dcEducationID = 9
  17831. SET @WHERE = @WHERE + ' AND a.Degree IN(5, 6, 7, 8) '
  17832. IF @Major > 0 OR LEN(@College) > 0 OR @Standard = 1 OR @MajorName > ''
  17833. SET @WHERE = @WHERE + '
  17834. AND b.Degree = a.Degree'
  17835. IF @Standard = 1
  17836. SET @WHERE = @WHERE + '
  17837. AND b.EduType=1'
  17838. END
  17839. ----语种
  17840. IF @LanguageType > 0
  17841. SET @WHERE = @WHERE + '
  17842. AND d.LanguageType = ' + LTRIM(STR(@LanguageType))
  17843. ----关键词
  17844. IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
  17845. BEGIN
  17846. DECLARE @S DATETIME, @SqlFt VARCHAR(MAX)
  17847. SELECT @S = GETDATE()
  17848. --INSERT INTO #FullText
  17849. --SELECT cvMainID, 9999 FROM cvinfo WHERE JobName LIKE '%' + @KeyTemp + '%'
  17850. INSERT INTO #FullText
  17851. SELECT [Key], 100000 + [Rank] FROM CONTAINSTABLE(cvinfo, *, @KeyTemp, 100000) AS KeyCv
  17852. ORDER BY RANK DESC
  17853. INSERT INTO #FullText
  17854. SELECT [Key], [Rank] FROM FREETEXTTABLE(cvinfo, *, @KeyTemp, 100000) AS KeyCv
  17855. WHERE [Key] NOT IN(SELECT cvId FROM #FullText)
  17856. ORDER BY RANK DESC
  17857. --Richard 2011.8.24增加
  17858. SELECT @SqlFt = 'SELECT [key] FROM FREETEXTTABLE(cvinfo, *, ''' + @KeyTemp + ''', 100000) AS KeyCv ORDER BY RANK DESC 开始:' + convert(varchar(8), @S, 8) + ' 结束:' + convert(varchar(8), getdate(), 8)
  17859. UPDATE SearchDB..cpSearchCondition SET SqlFT = @SqlFt WHERE ID = @cpSearchConditionID
  17860. END
  17861. ----学校名称
  17862. IF LEN(@College) > 0
  17863. IF CHARINDEX(' ', @College)= 0
  17864. SET @WHERE = @WHERE + '
  17865. AND b.GraduateCollage LIKE ''%' + LTRIM((@College)) + '%'''
  17866. ELSE
  17867. BEGIN
  17868. WHILE CHARINDEX(' ', @College)> 0
  17869. SET @College = REPLACE(@College, ' ', ' ')
  17870. SET @WHERE = @WHERE + '
  17871. AND (b.GraduateCollage LIKE ''%' + REPLACE(@College, ' ', '%'' OR b.GraduateCollage LIKE ''%') + '%'')'
  17872. END
  17873. IF LEN(@MajorName) > 0
  17874. IF CHARINDEX(' ', @MajorName)= 0
  17875. SET @WHERE = @WHERE + '
  17876. AND b.MajorName LIKE ''%' + @MajorName + '%'''
  17877. ELSE
  17878. BEGIN
  17879. WHILE CHARINDEX(' ', @MajorName)> 0
  17880. SET @MajorName = REPLACE(@MajorName, ' ', ' ')
  17881. SET @WHERE = @WHERE + '
  17882. AND (b.MajorName LIKE ''%' + REPLACE(@MajorName, ' ', '%'' OR b.MajorName LIKE ''%') + '%'')'
  17883. END
  17884. --工作性质
  17885. IF @cvEmployType IN(2, 4)
  17886. SET @WHERE = @WHERE + '
  17887. AND a.EmployType = ' + LTRIM(STR(@cvEmployType))
  17888. ELSE IF @cvEmployType = 1
  17889. SET @WHERE = @WHERE + '
  17890. AND a.EmployType IN (1, 2) '
  17891. ELSE IF @cvEmployType = 3
  17892. SET @WHERE = @WHERE + '
  17893. AND a.EmployType IN (3, 2) '
  17894. DECLARE @Order AS VARCHAR(50)
  17895. SET @Order = ' ORDER BY j.LastLoginDate DESC, a.ID'
  17896. IF CHARINDEX('b.', @WHERE) > 0
  17897. SET @FROM = @FROM + ' INNER JOIN cvEducationPublish b WITH(NOLOCK) ON a.ID=b.cvMainID'
  17898. IF CHARINDEX('c.', @WHERE) > 0
  17899. SET @FROM = @FROM + ' INNER JOIN CvExperiencePublish c WITH(NOLOCK) ON a.ID=c.cvMainID'
  17900. IF CHARINDEX('d.', @WHERE) > 0
  17901. SET @FROM = @FROM + ' INNER JOIN cvLanguagePublish d WITH(NOLOCK) ON a.ID=d.cvMainID'
  17902. IF CHARINDEX('e.', @WHERE) > 0
  17903. SET @FROM = @FROM + ' INNER JOIN cvTrainingPublish e WITH(NOLOCK) ON a.ID=e.cvMainID'
  17904. IF CHARINDEX('f.', @WHERE) > 0
  17905. SET @FROM = @FROM + ' INNER JOIN cvProjectPublish f WITH(NOLOCK) ON a.ID=f.cvMainID'
  17906. IF CHARINDEX('g.', @WHERE) > 0
  17907. SET @FROM = @FROM + ' INNER JOIN cvJobTypePublish g WITH(NOLOCK) ON a.ID=g.cvMainID'
  17908. IF CHARINDEX('h.', @WHERE) > 0
  17909. SET @FROM = @FROM + ' INNER JOIN cvJobPlacePublish h WITH(NOLOCK) ON a.ID=h.cvMainID'
  17910. IF CHARINDEX('i.', @WHERE) > 0
  17911. SET @FROM = @FROM + ' INNER JOIN cvIndustryPublish i WITH(NOLOCK) ON a.ID=i.cvMainID'
  17912. IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
  17913. SELECT @FROM = @FROM + ' INNER JOIN #FullText k WITH(NOLOCK) ON a.ID=k.cvID',
  17914. @Order = ' ORDER BY j.LastLoginDate DESC, a.ID',
  17915. @Where = @Where + ' AND j.LastLoginDate > DATEADD(MONTH, -3, GETDATE())'
  17916. --@Order = ' ORDER BY k.Rank DESC, j.LastLoginDate DESC, a.ID'
  17917. SET @SQL = @SQL + @FROM + @WHERE + @Order
  17918. --PRINT @SQL
  17919. ----把符合条件的职位全部列出
  17920. UPDATE SearchDB..cpSearchCondition SET Sql = REPLACE(@SQL, 'INSERT INTO #Cv', ''), StartDate = GETDATE() WHERE ID = @cpSearchConditionID
  17921. EXEC(@SQL)
  17922. ----记录查询结果总数
  17923. DECLARE @ValidCvNumber INT
  17924. SET @ValidCvNumber = @@ROWCOUNT
  17925. UPDATE SearchDB..cpSearchCondition SET ValidCvNumber = @ValidCvNumber WHERE ID = @cpSearchConditionID
  17926. IF (SELECT COUNT(*) FROM #FullText) > 100
  17927. INSERT INTO SearchDB..cpSearchCvID
  17928. SELECT TOP 2000 @cpSearchConditionID, ID
  17929. FROM #Cv WITH(NOLOCK)
  17930. Order BY DATEADD(MINUTE, Rank, RefreshDate) DESC
  17931. ELSE
  17932. INSERT INTO SearchDB..cpSearchCvID
  17933. SELECT TOP 2000 @cpSearchConditionID, ID
  17934. FROM #Cv WITH(NOLOCK)
  17935. Order BY RefreshDate DESC
  17936. DROP TABLE #Cv
  17937. DROP TABLE #FullText
  17938. GOTO GetRecordSet
  17939. END
  17940. GetRecordSet:
  17941. BEGIN
  17942. DECLARE @PageSize AS TINYINT
  17943. SET @PageSize = 20 --每页的行数
  17944. ----返回查询数量
  17945. UPDATE SearchDB..cpSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@cpSearchConditionID
  17946. SELECT ValidCvNumber FROM SearchDB..cpSearchCondition WITH(NOLOCK) WHERE ID=@cpSearchConditionID
  17947. ----返回20行查询结果
  17948. IF @PageNumber > 0
  17949. BEGIN
  17950. DECLARE @T_CvList AS TABLE(
  17951. ID INT,
  17952. cvEducationID INT,
  17953. dcMajorID INT,
  17954. Degree TINYINT,
  17955. RelatedWorkYears INT,
  17956. dcSalaryID TINYINT,
  17957. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  17958. RefreshDate SMALLDATETIME,
  17959. LastLoginDate SMALLDATETIME,
  17960. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  17961. Gender BIT,
  17962. BirthDay INT,
  17963. LivePlace INT,
  17964. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  17965. HasPhoto TINYINT,
  17966. College NVARCHAR(50),
  17967. EduType TINYINT,
  17968. MajorName NVARCHAR(20),
  17969. Graduation INT,
  17970. HasViewed BIT,
  17971. ViewDate SMALLDATETIME,
  17972. HasRemarked BIT,
  17973. LastJobTypeID INT,
  17974. Valid TINYINT,
  17975. IsOnline BIT,
  17976. HasWeiXin BIT,
  17977. paMainId int,
  17978. SecondId VARCHAR(10),
  17979. Seq INT IDENTITY(1, 1)
  17980. )
  17981. SELECT @MinId = MIN(ID) FROM SearchDB..cpSearchCvID WITH(NOLOCK) WHERE cpSearchConditionID=@cpSearchConditionID
  17982. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  17983. INSERT INTO @T_CvList(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, Speciality, RefreshDate, LastLoginDate,
  17984. JobName, Gender, BirthDay, LivePlace, LastJobTypeID, Attachment, HasPhoto, HasViewed, HasRemarked, Valid, IsOnline, paMainId, SecondId)
  17985. SELECT TOP 20 a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, ISNULL(a.Speciality, a.SpecialityEng) Speciality, a.RefreshDate,
  17986. j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, j.Gender, j.BirthDay, j.LivePlace, a.LastJobTypeID,
  17987. a.Attachment, j.HasPhoto, 0, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), a.paMainId, a.SecondId
  17988. FROM cvmainPublish a WITH(NOLOCK)
  17989. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
  17990. INNER JOIN SearchDB..cpSearchCvID b ON a.id=b.CvID
  17991. WHERE b.cpSearchConditionID=@cpSearchConditionID AND b.ID>=@MinId
  17992. ORDER BY b.ID, a.ID DESC
  17993. --RICHARD 2011-7-23 16:51分修改
  17994. UPDATE a SET a.cvEducationID = (
  17995. SELECT TOP 1 ID FROM cvEducationPublish WITH(NOLOCK)
  17996. WHERE cvEducationPublish.cvMainID = a.ID
  17997. AND a.Degree = cvEducationPublish.Degree
  17998. ORDER BY Graduation DESC)
  17999. FROM @T_CvList a
  18000. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  18001. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  18002. FROM @T_CvList a, cvEducationPublish b WITH(NOLOCK)
  18003. WHERE b.ID = a.cvEducationID
  18004. --修改是否绑定微信
  18005. UPDATE a SET HasWeiXin = 1
  18006. FROM @T_CvList a, WxFans b WITH(NOLOCK), CvMainPublish c WITH(NOLOCK)
  18007. WHERE a.ID = c.ID
  18008. AND c.PaMainID = b.PaMainID
  18009. AND b.Status = 2
  18010. UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
  18011. FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
  18012. WHERE b.cvMainID = a.ID AND caMainID=@caMainID
  18013. SELECT a.*, b.Description DegreeName,c.Description LivePlaceName, dbo.BirthToAge(a.BirthDay) Age,d.Description dcSalaryName
  18014. FROM @T_CvList a
  18015. LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  18016. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  18017. LEFT JOIN dcSalary d WITH(NOLOCK) ON d.ID = a.dcSalaryID
  18018. ORDER BY a.Seq
  18019. END
  18020. --记录查询时间
  18021. UPDATE SearchDB..cpSearchCondition SET EndDate = GETDATE() WHERE ID = @cpSearchConditionID
  18022. RETURN
  18023. END
  18024. END TRY
  18025. BEGIN CATCH
  18026. ---检查是否已经建立临时表,已经建立则删除
  18027. BEGIN TRY
  18028. DROP TABLE #FullText
  18029. END TRY
  18030. BEGIN CATCH
  18031. END CATCH
  18032. BEGIN TRY
  18033. DROP TABLE #cv
  18034. END TRY
  18035. BEGIN CATCH
  18036. END CATCH
  18037. PRINT '查询时出现错误,请联系技术人员检查,错误信息:'
  18038. PRINT Error_Message()
  18039. PRINT Error_Number()
  18040. PRINT Error_Line()
  18041. END CATCH
  18042. GO
  18043. /****** Object: StoredProcedure [dbo].[ccCvBySearchSelect2] Script Date: 2018/12/13 19:06:38 ******/
  18044. SET ANSI_NULLS ON
  18045. GO
  18046. SET QUOTED_IDENTIFIER ON
  18047. GO
  18048. --Peter 2014-08-25修改
  18049. --添加首次搜索简历积分记录
  18050. --Carl 2018-02-08 修改 最低学历添加大专及以上
  18051. CREATE PROCEDURE [dbo].[ccCvBySearchSelect2]
  18052. (
  18053. @dcJobTypeID VARCHAR(50), --职位类别
  18054. @dcRegionID VARCHAR(50), --求职地区
  18055. @dcIndustryID VARCHAR(50), --现从事行业
  18056. @IncludeOld BIT, --1包含曾从事职业
  18057. @dcJobTypeIDExpect VARCHAR(50), --期望职位类别
  18058. @dcIndustryIDExpect VARCHAR(50), --期望求职行业
  18059. @dcSalaryID TINYINT, --月薪
  18060. @IsNegotiable BIT, --1允许面议,不面议
  18061. @MinExperience TINYINT, --工作经验
  18062. @dcEducationID TINYINT, --最低学历
  18063. @LanguageType SMALLINT, --语种
  18064. @KeyWord NVARCHAR(20), --关键词
  18065. @College NVARCHAR(50), --学校名称
  18066. @Standard BIT, --是否统招
  18067. @SubNodeNum INT, --下属人数
  18068. @Major INT, --所学专业
  18069. @Graduation INT, --毕业时间 year
  18070. @Gender TINYINT, --性别, 2不限
  18071. @MaxAge SMALLINT, --最大年龄
  18072. @MinAge SMALLINT, --最小年龄
  18073. @LivePlace VARCHAR(50), --现居住地
  18074. @AccountPlace INT, --户口所在地
  18075. @MobilePlace VARCHAR(50), --Mobile住地
  18076. @MinHeight TINYINT, --MinHeight
  18077. @MaxHeight TINYINT, --MaxHeight
  18078. @SortType TINYINT, --排序方式
  18079. @CvMainID INT, --简历ID
  18080. --@dcCareerStatus TINYINT, --简历状态
  18081. --sessionid,没有采用全部人员共享方式,因为10分钟内,搜索相同条件的可能性很大,
  18082. --而10分钟搜索的用户翻到第二页时内容可能会和第一页一样。这样让用户很难理解。
  18083. --使用SessionID, 可以保证60分钟内查询结果一致。出现不一致的几率很小
  18084. @SessionID INT,
  18085. @PageNumber INT, --翻页页码
  18086. @IsExpand BIT, --是否扩大地区范围
  18087. @caMainID INT, --企业用户ID,用来判断是否和建立联系
  18088. @cvEmployType INT, --期望工作性质ID,用来限制期望工作性质选项
  18089. @dcProvinceId INT
  18090. )
  18091. AS
  18092. SET NOCOUNT ON
  18093. BEGIN TRY
  18094. DECLARE @MajorName AS NVARCHAR(20), @KeyTemp NVARCHAR(20)
  18095. IF @dcJobTypeID IS NULL
  18096. SET @dcJobTypeID = ''
  18097. SET @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID)
  18098. IF @dcJobTypeIDExpect IS NULL
  18099. SET @dcJobTypeIDExpect = ''
  18100. SET @dcJobTypeIDExpect = dbo.FormatIDS(@dcJobTypeIDExpect)
  18101. IF @dcRegionID IS NULL
  18102. SET @dcRegionID = ''
  18103. SET @dcRegionID = dbo.FormatIDS(@dcRegionID)
  18104. IF @dcIndustryID IS NULL
  18105. Set @dcIndustryID = ''
  18106. SET @dcIndustryID = dbo.FormatIDS(@dcIndustryID)
  18107. IF @dcIndustryIDExpect IS NULL
  18108. SET @dcIndustryIDExpect = ''
  18109. SET @dcIndustryIDExpect = dbo.FormatIDS(@dcIndustryIDExpect)
  18110. IF @dcSalaryID IS NULL
  18111. SELECT @dcSalaryID = 0, @IsNegotiable = 0
  18112. IF @IsNegotiable IS NULL
  18113. SET @IsNegotiable = 0
  18114. IF @MinExperience IS NULL
  18115. SET @MinExperience = 99
  18116. IF @dcEducationID IS NULL
  18117. SET @dcEducationID = 0
  18118. IF @LanguageType IS NULL
  18119. SET @LanguageType = 0
  18120. IF @College IS NULL
  18121. SET @College = ''
  18122. IF LEN(@College) < 2
  18123. SET @College = ''
  18124. IF @SortType IS NULL
  18125. SET @SortType = 0
  18126. WHILE @KeyWord LIKE '% %'
  18127. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  18128. SET @KeyWord = LTRIM(RTRIM(dbo.SafeSQL(@KeyWord)))
  18129. SET @KeyTemp = @KeyWord
  18130. IF @KeyWord IS NULL OR LEN(@KeyWord) < 2
  18131. SELECT @KeyWord = '', @KeyTemp = ''
  18132. ELSE
  18133. BEGIN
  18134. IF LEFT(@KeyWord, 7) = 'major::'
  18135. BEGIN
  18136. SELECT @MajorName = REPLACE(@KeyWord, 'major::', '')
  18137. SELECT @KeyWord = '', @KeyTemp = ''
  18138. END
  18139. ELSE
  18140. BEGIN
  18141. DECLARE @p INT
  18142. SET @p = CHARINDEX('@@', @KeyWord)
  18143. IF @p > 0
  18144. BEGIN
  18145. SELECT @MajorName = LTRIM(RTRIM(RIGHT(@KeyWord, LEN(@KeyWord) - @p - 1)))
  18146. SELECT @KeyTemp = LEFT(@KeyWord, @p - 1)
  18147. IF LEN(@KeyTemp) < 2
  18148. SET @KeyTemp = ''
  18149. END
  18150. END
  18151. END
  18152. SET @KeyTemp = REPLACE(@KeyTemp, ' ', ' near ')
  18153. SET @College = LTRIM(RTRIM(dbo.SafeSQL(@College)))
  18154. IF @SubNodeNum IS NULL
  18155. SET @SubNodeNum = 0
  18156. IF @MaxAge IS NULL OR @MaxAge = 0
  18157. SET @MaxAge = 99
  18158. IF @MinAge IS NULL OR @MinAge = 0
  18159. SET @MinAge = 99
  18160. IF @LivePlace IS NULL
  18161. SET @LivePlace = ''
  18162. SET @LivePlace = dbo.FormatIDS(@LivePlace)
  18163. IF @MobilePlace IS NULL
  18164. SET @MobilePlace = ''
  18165. SET @MobilePlace = dbo.FormatIDS(@MobilePlace)
  18166. IF @AccountPlace IS NULL
  18167. SET @AccountPlace = 0
  18168. IF @Gender IS NULL
  18169. SET @Gender = 2
  18170. IF @IncludeOld IS NULL
  18171. SET @IncludeOld = 0
  18172. IF @Major IS NULL
  18173. SET @Major = 0
  18174. IF @Graduation IS NULL
  18175. SET @Graduation = 0
  18176. ELSE IF @Graduation > DATEPART(YEAR, GETDATE()) + 1 OR @Graduation < DATEPART(YEAR, GETDATE()) -10
  18177. SET @Graduation = 0
  18178. IF @CvMainID IS NULL
  18179. SET @CvMainID = 0
  18180. IF @Standard IS NULL
  18181. SET @Standard = 0
  18182. IF @IsExpand IS NULL
  18183. SET @IsExpand = 0
  18184. SET @MinHeight = ISNULL(@MinHeight, 0)
  18185. SET @MaxHeight = ISNULL(@MaxHeight, 250)
  18186. IF @MinHeight < 140 OR @MinHeight > 200
  18187. SET @MinHeight = 0
  18188. IF @cvEmployType IS NULL
  18189. SET @cvEmployType = 0
  18190. IF @CvMainID = 0
  18191. BEGIN
  18192. ----给null值变量赋默认值
  18193. DECLARE @cpSearchConditionID AS INT, @MinId AS INT
  18194. SELECT @cpSearchConditionID = 0
  18195. IF @SessionID != -1
  18196. SELECT @SessionId = 1
  18197. --sqlserver中计划任务自动删除60分钟前的数据
  18198. SELECT TOP 1 @cpSearchConditionID = ID FROM SearchDB..cpSearchCondition WITH(NOLOCK)
  18199. WHERE SessionID=@SessionID AND dcJobTypeID=@dcJobTypeID AND dcJobTypeIDExpect=@dcJobTypeIDExpect
  18200. AND dcRegionID=@dcRegionID AND dcIndustryID=@dcIndustryID AND dcIndustryIDExpect=@dcIndustryIDExpect
  18201. AND IncludeOld=@IncludeOld AND dcSalaryID=@dcSalaryID AND IsNegotiable=@IsNegotiable
  18202. AND MinExperience=@MinExperience AND dcEducationID=@dcEducationID AND LanguageType=@LanguageType
  18203. AND KeyWord=@KeyWord AND College=@College AND Standard=@Standard AND SortType=@SortType
  18204. AND SubNodeNum = @SubNodeNum AND Major = @Major AND Graduation = @Graduation AND Gender=@Gender AND MaxAge=@MaxAge
  18205. AND MinAge=@MinAge AND LivePlace=@LivePlace AND AccountPlace=@AccountPlace AND MobilePlace=@MobilePlace
  18206. AND IsExpand=@IsExpand AND MinHeight = @MinHeight AND MaxHeight = @MaxHeight AND LogTime > DATEADD(M, -60, GETDATE())
  18207. AND EmployType=@cvEmployType
  18208. ORDER BY ID DESC
  18209. IF ISNULL(@cpSearchConditionID, 0) = 0
  18210. GOTO SelectReset --无数据,重新搜索
  18211. ELSE
  18212. GOTO GetRecordSet --从临时结果中提取数据
  18213. END
  18214. ELSE
  18215. BEGIN
  18216. ----如果有简历id,则直接显示,不再查询
  18217. SELECT COUNT(1) FROM cvmainPublish WITH(NOLOCK) WHERE ID = @CvMainID AND Valid > 0
  18218. DECLARE @T_Cv AS TABLE(
  18219. ID INT,
  18220. dcMajorID INT,
  18221. Degree TINYINT,
  18222. RelatedWorkYears INT,
  18223. dcSalaryID TINYINT,
  18224. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  18225. RefreshDate SMALLDATETIME,
  18226. LastLoginDate SMALLDATETIME,
  18227. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  18228. Gender BIT,
  18229. BirthDay INT,
  18230. LivePlace INT,
  18231. Attachment VARCHAR(50),
  18232. HasPhoto TINYINT,
  18233. College NVARCHAR(50),
  18234. EduType TINYINT,
  18235. MajorName NVARCHAR(20),
  18236. Graduation INT,
  18237. HasViewed BIT,
  18238. ViewDate SMALLDATETIME,
  18239. HasRemarked BIT,
  18240. LastJobTypeID INT,
  18241. Valid TINYINT,
  18242. IsOnline BIT,
  18243. HasWeiXin BIT,
  18244. paMainId INT,
  18245. SecondId VARCHAR(10)
  18246. )
  18247. INSERT INTO @T_Cv(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, Speciality, RefreshDate, LastLoginDate,
  18248. JobName, Gender, BirthDay, LivePlace, LastJobTypeID, Attachment, HasPhoto, HasViewed, HasRemarked, Valid, IsOnline, paMainId, secondId)
  18249. SELECT a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, ISNULL(a.Speciality, a.SpecialityEng) Speciality, a.RefreshDate,
  18250. j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, j.Gender, j.BirthDay, j.LivePlace, a.LastJobTypeID,
  18251. a.Attachment, j.HasPhoto, 0, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), a.paMainId, a.secondId
  18252. FROM cvmainPublish a WITH(NOLOCK)
  18253. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID = j.ID
  18254. WHERE a.ID = @CvMainID AND a.Valid > 0
  18255. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  18256. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  18257. FROM @T_Cv a, cvEducationPublish b WITH(NOLOCK)
  18258. WHERE b.cvMainID = a.ID
  18259. AND b.Degree = a.Degree
  18260. UPDATE a SET a.HasViewed = 1, a.ViewDate = (SELECT AddDate FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  18261. FROM @T_Cv a
  18262. WHERE EXISTS(SELECT 'X' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  18263. --修改是否绑定微信
  18264. UPDATE a SET HasWeiXin = 1
  18265. FROM @T_Cv a, WxFans b WITH(NOLOCK)
  18266. WHERE a.PaMainID = b.PaMainID
  18267. AND b.Status = 2
  18268. SELECT a.*,b.Description DegreeName,c.Description LivePlaceName, dbo.BirthToAge(a.BirthDay) Age,d.Description dcSalaryName
  18269. FROM @T_Cv a
  18270. LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  18271. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  18272. LEFT JOIN dcSalary d WITH(NOLOCK) ON d.ID = a.dcSalaryID
  18273. RETURN
  18274. END
  18275. SelectReset: --从cv中搜索数据
  18276. BEGIN
  18277. DECLARE @SQL AS VARCHAR(8000)
  18278. DECLARE @WHERE AS VARCHAR(8000)
  18279. DECLARE @FROM AS VARCHAR(1000)
  18280. ----记录查询条件
  18281. INSERT INTO SearchDB..cpSearchCondition(SessionID, dcJobTypeID, dcJobTypeIDExpect, dcRegionID, dcIndustryID,
  18282. dcIndustryIDExpect, IncludeOld, dcSalaryID, IsNegotiable, SortType,
  18283. MinExperience, dcEducationID, LanguageType, KeyWord, College, Standard, SubNodeNum,
  18284. Major, Graduation, Gender, MaxAge, MinAge, LivePlace, AccountPlace, MobilePlace, IsExpand, MinHeight, MaxHeight, ReuseNumber, EmployType)
  18285. VALUES(@SessionID, @dcJobTypeID, @dcJobTypeIDExpect, @dcRegionID, @dcIndustryID,
  18286. @dcIndustryIDExpect, @IncludeOld, @dcSalaryID, @IsNegotiable, @SortType,
  18287. @MinExperience, @dcEducationID, @LanguageType, @KeyWord, @College, @Standard, @SubNodeNum,
  18288. @Major, @Graduation, @Gender, @MaxAge, @MinAge, @LivePlace, @AccountPlace, @MobilePlace, @IsExpand, @MinHeight, @MaxHeight, 0, @cvEmployType)
  18289. SET @cpSearchConditionID = @@IDENTITY
  18290. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  18291. DECLARE @T_JobPlace AS TABLE(ID INT)
  18292. DECLARE @T_JobType AS TABLE(ID INT)
  18293. DECLARE @tmpMobilePlace AS VARCHAR(2000),
  18294. @JobType AS VARCHAR(3000), @JobTypeExpect AS VARCHAR(3000),
  18295. @JobPlace AS VARCHAR(2000), @tmpLivePlace AS VARCHAR(2000)
  18296. SELECT @JobPlace = '', @tmpLivePlace = '', @tmpMobilePlace = '', @JobType='', @JobTypeExpect = '', @WHERE = ' WHERE a.Valid > 0'
  18297. ----生成工作地点的表变量
  18298. IF LEN(@dcRegionID) > 0
  18299. BEGIN
  18300. INSERT INTO @T_JobPlace
  18301. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  18302. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  18303. IF @IsExpand = 1
  18304. BEGIN
  18305. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID = ''' + LTRIM(STR(LEFT(ID, 2)))+'''' )
  18306. FROM @T_JobPlace WHERE LEN(ID) > 2
  18307. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID = ''' + LTRIM(STR(LEFT(ID, 4)))+'''' )
  18308. FROM @T_JobPlace WHERE LEN(ID) > 4
  18309. END
  18310. IF LEN(@JobPlace) > 0
  18311. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  18312. END
  18313. IF LEN(@LivePlace) > 0
  18314. BEGIN
  18315. DELETE FROM @T_JobPlace
  18316. INSERT INTO @T_JobPlace
  18317. SELECT * FROM dbo.fnSplit(@LivePlace, ',')
  18318. SELECT @tmpLivePlace = (@tmpLivePlace + ' OR j.LivePlace Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  18319. IF LEN(@tmpLivePlace) > 0
  18320. SET @tmpLivePlace = RIGHT(@tmpLivePlace, LEN(@tmpLivePlace) -4)
  18321. END
  18322. IF LEN(@MobilePlace) > 0
  18323. BEGIN
  18324. DELETE FROM @T_JobPlace
  18325. INSERT INTO @T_JobPlace
  18326. SELECT * FROM dbo.fnSplit(@MobilePlace, ',')
  18327. SELECT @tmpMobilePlace = (@tmpMobilePlace + ' OR j.MobileRegion Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  18328. IF LEN(@tmpMobilePlace) > 0
  18329. SET @tmpMobilePlace = RIGHT(@tmpMobilePlace, LEN(@tmpMobilePlace) -4)
  18330. END
  18331. ----生成求聘职位的表变量
  18332. IF LEN(@dcJobTypeID) > 0
  18333. BEGIN
  18334. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  18335. INSERT INTO @T_Temp
  18336. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  18337. INSERT INTO @T_JobType
  18338. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  18339. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  18340. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  18341. OR ID IN(SELECT ID FROM @T_TEMP)
  18342. ----生成in字符串
  18343. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  18344. IF RIGHT(@JobType, 1) = ', '
  18345. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  18346. END
  18347. IF LEN(@dcJobTypeIDExpect) > 0
  18348. BEGIN
  18349. DECLARE @T_Temp1 AS TABLE(ID INT) --临时表,用于构建组合查询语句
  18350. INSERT INTO @T_Temp1
  18351. SELECT * FROM dbo.fnSplit(@dcJobTypeIDExpect, ',')
  18352. DELETE FROM @T_JobType
  18353. INSERT INTO @T_JobType
  18354. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  18355. WHERE ParentId IN(SELECT ID FROM @T_TEMP1)
  18356. OR ParentId2 in(SELECT ID FROM @T_TEMP1)
  18357. OR ID IN(SELECT ID FROM @T_TEMP1)
  18358. ----生成in字符串
  18359. SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType
  18360. IF RIGHT(@JobTypeExpect, 1) = ', '
  18361. SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
  18362. END
  18363. ----建立关键字搜索的临时表
  18364. CREATE TABLE #FullText(
  18365. CvID INT NOT NULL,
  18366. Rank INT
  18367. )
  18368. ----建立临时表
  18369. CREATE TABLE #Cv(
  18370. ID INT NOT NULL,
  18371. RefreshDate SMALLDATETIME NOT NULL,
  18372. RANK INT
  18373. )
  18374. ----生成插入临时表的Sql语句
  18375. SET @SQL = '
  18376. INSERT INTO #Cv
  18377. SELECT DISTINCT TOP 2000 a.ID, j.LastLoginDate'
  18378. IF LEN(@KeyTemp) > 0
  18379. SET @Sql = @Sql + ', k.Rank'
  18380. ELSE
  18381. SET @Sql = @Sql + ', 1'
  18382. SET @FROM = '
  18383. FROM cvmainPublish a WITH(NOLOCK) INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID = j.ID'
  18384. IF @dcPRovinceId != 32
  18385. SET @FROM = @FROM + ' AND j.dcProvinceID != 32 '
  18386. ----工作经验的职位类别
  18387. IF LEN(@dcJobTypeID) > 0
  18388. BEGIN
  18389. IF @IncludeOld = 0 ----最近从事和曾从事职位
  18390. SET @WHERE = @WHERE + '
  18391. AND (a.LastJobTypeID IN(' + @JobType +'))'
  18392. ELSE
  18393. SET @WHERE = @WHERE + '
  18394. AND (c.dcJobTypeID IN(' + @JobType +'))'
  18395. END
  18396. ----期望职位类别
  18397. IF LEN(@dcJobTypeIDExpect) > 0
  18398. BEGIN
  18399. SET @WHERE = @WHERE + '
  18400. AND (g.dcJobTypeID IN(' + @JobTypeExpect +'))'
  18401. END
  18402. ----工作地点
  18403. IF LEN(@JobPlace) > 0
  18404. SET @WHERE = @WHERE + '
  18405. AND (' + @JobPlace + ')'
  18406. ----现从事行业
  18407. IF LEN(@dcIndustryID) > 0
  18408. SET @WHERE = @WHERE + '
  18409. AND (a.LastIndustryID IN(' + @dcIndustryID + '))'
  18410. ----期望行业
  18411. IF LEN(@dcIndustryIDExpect) > 0
  18412. BEGIN
  18413. SET @WHERE = @WHERE + '
  18414. AND (i.dcIndustryID IN(' + @dcIndustryIDExpect + '))'
  18415. END
  18416. ----下属人数
  18417. IF @SubNodeNum > 0
  18418. BEGIN
  18419. SET @WHERE = @WHERE + '
  18420. AND a.SubNodeNum = ' + LTRIM(STR(@SubNodeNum))
  18421. END
  18422. ----当前所在地
  18423. IF LEN(@tmpLivePlace) > 0
  18424. BEGIN
  18425. SET @WHERE = @WHERE + '
  18426. AND (' + @tmpLivePlace + ')'
  18427. END
  18428. IF @SessionId = -1
  18429. BEGIN
  18430. SET @WHERE = @WHERE + '
  18431. AND j.Id IN(SELECT paMainId FROM paOnline)'
  18432. END
  18433. ----Mobile所在地
  18434. IF LEN(@tmpMobilePlace) > 0
  18435. BEGIN
  18436. SET @WHERE = @WHERE + '
  18437. AND (' + @tmpMobilePlace + ')'
  18438. END
  18439. ----户口所在地
  18440. IF @AccountPlace > 0
  18441. BEGIN
  18442. SET @WHERE = @WHERE + '
  18443. AND j.AccountPlace LIKE ''' + LTRIM(STR(@AccountPlace)) + '%'''
  18444. END
  18445. ----专业
  18446. IF @Major > 0
  18447. BEGIN
  18448. SET @WHERE = @WHERE + '
  18449. AND b.dcMajorID = ' + LTRIM(STR(@Major))
  18450. END
  18451. --Graduation
  18452. IF @Graduation = DATEPART(YEAR, GETDATE()) + 1
  18453. BEGIN
  18454. SET @WHERE = @WHERE + '
  18455. AND b.Graduation > ' + LTRIM(STR(@Graduation)) + '00'
  18456. END
  18457. ELSE IF @Graduation > DATEPART(YEAR, GETDATE()) - 10
  18458. BEGIN
  18459. SET @WHERE = @WHERE + '
  18460. AND b.Graduation BETWEEN ' + LTRIM(STR(@Graduation)) + '00 AND ' + LTRIM(STR(@Graduation)) + '99'
  18461. END
  18462. ELSE IF @Graduation = DATEPART(YEAR, GETDATE()) - 10
  18463. BEGIN
  18464. SET @WHERE = @WHERE + '
  18465. AND b.Graduation < ' + LTRIM(STR(@Graduation)) + '99'
  18466. END
  18467. ----性别
  18468. IF @Gender < 2
  18469. BEGIN
  18470. SET @WHERE = @WHERE + '
  18471. AND j.Gender = ' + LTRIM(STR(@Gender))
  18472. END
  18473. ----年龄
  18474. IF @MinAge < 99
  18475. BEGIN
  18476. SET @WHERE = @WHERE + '
  18477. AND j.BirthDay <= ' + LTRIM(STR(dbo.AgeToBirth(@MinAge)))
  18478. END
  18479. IF @MaxAge < 99
  18480. BEGIN
  18481. SET @MaxAge = @MaxAge + 1
  18482. SET @WHERE = @WHERE + '
  18483. AND j.BirthDay > ' + LTRIM(STR(dbo.AgeToBirth(@MaxAge)))
  18484. END
  18485. IF @MinHeight > 139
  18486. BEGIN
  18487. SET @WHERE = @WHERE + '
  18488. AND j.Height >= ' + LTRIM(STR(@MinHeight))
  18489. END
  18490. IF @MaxHeight < 231
  18491. BEGIN
  18492. SET @WHERE = @WHERE + '
  18493. AND j.Height <= ' + LTRIM(STR(@MaxHeight))
  18494. END
  18495. ----薪水
  18496. IF @dcSalaryID > 0
  18497. BEGIN
  18498. SET @WHERE = @WHERE + '
  18499. AND((
  18500. a.dcSalaryID >= ' + LTRIM(STR(@dcSalaryID-1)) + '
  18501. AND a.dcSalaryID <= ' + LTRIM(STR(@dcSalaryID+1)) + '
  18502. )'
  18503. IF @IsNegotiable = 1 --包括面议
  18504. SET @WHERE = @WHERE + '
  18505. OR a.IsNegotiable = 1'
  18506. SET @WHERE = @WHERE + ')'
  18507. END
  18508. ----工作经验要求
  18509. IF @MinExperience < 99
  18510. BEGIN
  18511. IF @MinExperience = 4
  18512. SET @WHERE = @WHERE + '
  18513. AND a.RelatedWorkYears = 11'
  18514. ELSE IF @MinExperience = 1
  18515. SET @WHERE = @WHERE + '
  18516. AND a.RelatedWorkYears >= 1 AND a.RelatedWorkYears <= 2'
  18517. ELSE IF @MinExperience = 2
  18518. SET @WHERE = @WHERE + '
  18519. AND a.RelatedWorkYears >= 3 AND a.RelatedWorkYears <= 5'
  18520. ELSE IF @MinExperience = 3
  18521. SET @WHERE = @WHERE + '
  18522. AND a.RelatedWorkYears >= 6 AND a.RelatedWorkYears <= 10'
  18523. ELSE IF @MinExperience = 5
  18524. SET @WHERE = @WHERE + '
  18525. AND a.RelatedWorkYears >= 2 AND a.RelatedWorkYears <= 3'
  18526. ELSE
  18527. SET @WHERE = @WHERE + '
  18528. AND a.RelatedWorkYears = 0'
  18529. END
  18530. ----学历要求
  18531. IF @dcEducationID > 0
  18532. BEGIN
  18533. IF @dcEducationID = 1
  18534. SET @WHERE = @WHERE + ' AND a.Degree IN(1, 2, 3, 4) '
  18535. ELSE IF @dcEducationID = 2
  18536. SET @WHERE = @WHERE + ' AND a.Degree <= 5 '
  18537. ELSE IF @dcEducationID = 3
  18538. SET @WHERE = @WHERE + ' AND a.Degree = 5 '
  18539. ELSE IF @dcEducationID = 4
  18540. SET @WHERE = @WHERE + ' AND a.Degree IN(5, 6) '
  18541. ELSE IF @dcEducationID = 5
  18542. SET @WHERE = @WHERE + ' AND a.Degree = 6 '
  18543. ELSE IF @dcEducationID = 6
  18544. SET @WHERE = @WHERE + ' AND a.Degree >= 6 '
  18545. ELSE IF @dcEducationID = 7
  18546. SET @WHERE = @WHERE + ' AND a.Degree = 7 '
  18547. ELSE IF @dcEducationID = 8
  18548. SET @WHERE = @WHERE + ' AND a.Degree = 8 '
  18549. ELSE IF @dcEducationID = 9
  18550. SET @WHERE = @WHERE + ' AND a.Degree IN(5, 6, 7, 8) '
  18551. IF @Major > 0 OR LEN(@College) > 0 OR @Standard = 1 OR @MajorName > ''
  18552. SET @WHERE = @WHERE + '
  18553. AND b.Degree = a.Degree'
  18554. IF @Standard = 1
  18555. SET @WHERE = @WHERE + '
  18556. AND b.EduType=1'
  18557. END
  18558. ----语种
  18559. IF @LanguageType > 0
  18560. SET @WHERE = @WHERE + '
  18561. AND d.LanguageType = ' + LTRIM(STR(@LanguageType))
  18562. ----关键词
  18563. IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
  18564. BEGIN
  18565. DECLARE @S DATETIME, @SqlFt VARCHAR(MAX)
  18566. SELECT @S = GETDATE()
  18567. --INSERT INTO #FullText
  18568. --SELECT cvMainID, 9999 FROM cvinfo WHERE JobName LIKE '%' + @KeyTemp + '%'
  18569. INSERT INTO #FullText
  18570. SELECT [Key], 100000 + [Rank] FROM CONTAINSTABLE(cvinfo, *, @KeyTemp, 100000) AS KeyCv
  18571. ORDER BY RANK DESC
  18572. INSERT INTO #FullText
  18573. SELECT [Key], [Rank] FROM FREETEXTTABLE(cvinfo, *, @KeyTemp, 100000) AS KeyCv
  18574. WHERE [Key] NOT IN(SELECT cvId FROM #FullText)
  18575. ORDER BY RANK DESC
  18576. --Richard 2011.8.24增加
  18577. SELECT @SqlFt = 'SELECT [key] FROM FREETEXTTABLE(cvinfo, *, ''' + @KeyTemp + ''', 100000) AS KeyCv ORDER BY RANK DESC 开始:' + convert(varchar(8), @S, 8) + ' 结束:' + convert(varchar(8), getdate(), 8)
  18578. UPDATE SearchDB..cpSearchCondition SET SqlFT = @SqlFt WHERE ID = @cpSearchConditionID
  18579. END
  18580. ----学校名称
  18581. IF LEN(@College) > 0
  18582. IF CHARINDEX(' ', @College)= 0
  18583. SET @WHERE = @WHERE + '
  18584. AND b.GraduateCollage LIKE ''%' + LTRIM((@College)) + '%'''
  18585. ELSE
  18586. BEGIN
  18587. WHILE CHARINDEX(' ', @College)> 0
  18588. SET @College = REPLACE(@College, ' ', ' ')
  18589. SET @WHERE = @WHERE + '
  18590. AND (b.GraduateCollage LIKE ''%' + REPLACE(@College, ' ', '%'' OR b.GraduateCollage LIKE ''%') + '%'')'
  18591. END
  18592. IF LEN(@MajorName) > 0
  18593. IF CHARINDEX(' ', @MajorName)= 0
  18594. SET @WHERE = @WHERE + '
  18595. AND b.MajorName LIKE ''%' + @MajorName + '%'''
  18596. ELSE
  18597. BEGIN
  18598. WHILE CHARINDEX(' ', @MajorName)> 0
  18599. SET @MajorName = REPLACE(@MajorName, ' ', ' ')
  18600. SET @WHERE = @WHERE + '
  18601. AND (b.MajorName LIKE ''%' + REPLACE(@MajorName, ' ', '%'' OR b.MajorName LIKE ''%') + '%'')'
  18602. END
  18603. --工作性质
  18604. IF @cvEmployType IN(2, 4)
  18605. SET @WHERE = @WHERE + '
  18606. AND a.EmployType = ' + LTRIM(STR(@cvEmployType))
  18607. ELSE IF @cvEmployType = 1
  18608. SET @WHERE = @WHERE + '
  18609. AND a.EmployType IN (1, 2) '
  18610. ELSE IF @cvEmployType = 3
  18611. SET @WHERE = @WHERE + '
  18612. AND a.EmployType IN (3, 2) '
  18613. DECLARE @Order AS VARCHAR(50)
  18614. SET @Order = ' ORDER BY j.LastLoginDate DESC, a.ID'
  18615. IF CHARINDEX('b.', @WHERE) > 0
  18616. SET @FROM = @FROM + ' INNER JOIN cvEducationPublish b WITH(NOLOCK) ON a.ID=b.cvMainID'
  18617. IF CHARINDEX('c.', @WHERE) > 0
  18618. SET @FROM = @FROM + ' INNER JOIN CvExperiencePublish c WITH(NOLOCK) ON a.ID=c.cvMainID'
  18619. IF CHARINDEX('d.', @WHERE) > 0
  18620. SET @FROM = @FROM + ' INNER JOIN cvLanguagePublish d WITH(NOLOCK) ON a.ID=d.cvMainID'
  18621. IF CHARINDEX('e.', @WHERE) > 0
  18622. SET @FROM = @FROM + ' INNER JOIN cvTrainingPublish e WITH(NOLOCK) ON a.ID=e.cvMainID'
  18623. IF CHARINDEX('f.', @WHERE) > 0
  18624. SET @FROM = @FROM + ' INNER JOIN cvProjectPublish f WITH(NOLOCK) ON a.ID=f.cvMainID'
  18625. IF CHARINDEX('g.', @WHERE) > 0
  18626. SET @FROM = @FROM + ' INNER JOIN cvJobTypePublish g WITH(NOLOCK) ON a.ID=g.cvMainID'
  18627. IF CHARINDEX('h.', @WHERE) > 0
  18628. SET @FROM = @FROM + ' INNER JOIN cvJobPlacePublish h WITH(NOLOCK) ON a.ID=h.cvMainID'
  18629. IF CHARINDEX('i.', @WHERE) > 0
  18630. SET @FROM = @FROM + ' INNER JOIN cvIndustryPublish i WITH(NOLOCK) ON a.ID=i.cvMainID'
  18631. IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
  18632. SELECT @FROM = @FROM + ' INNER JOIN #FullText k WITH(NOLOCK) ON a.ID=k.cvID',
  18633. @Order = ' ORDER BY j.LastLoginDate DESC, a.ID',
  18634. @Where = @Where + ' AND j.LastLoginDate > DATEADD(MONTH, -3, GETDATE())'
  18635. --@Order = ' ORDER BY k.Rank DESC, j.LastLoginDate DESC, a.ID'
  18636. SET @SQL = @SQL + @FROM + @WHERE + @Order
  18637. --PRINT @SQL
  18638. ----把符合条件的职位全部列出
  18639. UPDATE SearchDB..cpSearchCondition SET Sql = REPLACE(@SQL, 'INSERT INTO #Cv', ''), StartDate = GETDATE() WHERE ID = @cpSearchConditionID
  18640. EXEC(@SQL)
  18641. ----记录查询结果总数
  18642. DECLARE @ValidCvNumber INT
  18643. SET @ValidCvNumber = @@ROWCOUNT
  18644. UPDATE SearchDB..cpSearchCondition SET ValidCvNumber = @ValidCvNumber WHERE ID = @cpSearchConditionID
  18645. IF (SELECT COUNT(*) FROM #FullText) > 100
  18646. INSERT INTO SearchDB..cpSearchCvID
  18647. SELECT TOP 2000 @cpSearchConditionID, ID
  18648. FROM #Cv WITH(NOLOCK)
  18649. Order BY DATEADD(MINUTE, Rank, RefreshDate) DESC
  18650. ELSE
  18651. INSERT INTO SearchDB..cpSearchCvID
  18652. SELECT TOP 2000 @cpSearchConditionID, ID
  18653. FROM #Cv WITH(NOLOCK)
  18654. Order BY RefreshDate DESC
  18655. DROP TABLE #Cv
  18656. DROP TABLE #FullText
  18657. GOTO GetRecordSet
  18658. END
  18659. GetRecordSet:
  18660. BEGIN
  18661. DECLARE @PageSize AS TINYINT
  18662. SET @PageSize = 20 --每页的行数
  18663. ----返回查询数量
  18664. UPDATE SearchDB..cpSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@cpSearchConditionID
  18665. SELECT ValidCvNumber FROM SearchDB..cpSearchCondition WITH(NOLOCK) WHERE ID=@cpSearchConditionID
  18666. ----返回20行查询结果
  18667. IF @PageNumber > 0
  18668. BEGIN
  18669. DECLARE @T_CvList AS TABLE(
  18670. ID INT,
  18671. cvEducationID INT,
  18672. dcMajorID INT,
  18673. Degree TINYINT,
  18674. RelatedWorkYears INT,
  18675. dcSalaryID TINYINT,
  18676. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  18677. RefreshDate SMALLDATETIME,
  18678. LastLoginDate SMALLDATETIME,
  18679. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  18680. Gender BIT,
  18681. BirthDay INT,
  18682. LivePlace INT,
  18683. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  18684. HasPhoto TINYINT,
  18685. College NVARCHAR(50),
  18686. EduType TINYINT,
  18687. MajorName NVARCHAR(20),
  18688. Graduation INT,
  18689. HasViewed BIT,
  18690. ViewDate SMALLDATETIME,
  18691. HasRemarked BIT,
  18692. LastJobTypeID INT,
  18693. Valid TINYINT,
  18694. IsOnline BIT,
  18695. HasWeiXin BIT,
  18696. paMainId int,
  18697. SecondId VARCHAR(10),
  18698. Seq INT IDENTITY(1, 1)
  18699. )
  18700. SELECT @MinId = MIN(ID) FROM SearchDB..cpSearchCvID WITH(NOLOCK) WHERE cpSearchConditionID=@cpSearchConditionID
  18701. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  18702. INSERT INTO @T_CvList(ID, dcMajorID, Degree, RelatedWorkYears, dcSalaryID, Speciality, RefreshDate, LastLoginDate,
  18703. JobName, Gender, BirthDay, LivePlace, LastJobTypeID, Attachment, HasPhoto, HasViewed, HasRemarked, Valid, IsOnline, paMainId, SecondId)
  18704. SELECT TOP 20 a.ID, a.dcMajorID, a.Degree, a.RelatedWorkYears, a.dcSalaryID, ISNULL(a.Speciality, a.SpecialityEng) Speciality, a.RefreshDate,
  18705. j.LastLoginDate, ISNULL(a.JobName, '应届毕业生') JobName, j.Gender, j.BirthDay, j.LivePlace, a.LastJobTypeID,
  18706. a.Attachment, j.HasPhoto, 0, 0, a.Valid, dbo.GetPaOnlineStatus(j.ID), a.paMainId, a.SecondId
  18707. FROM cvmainPublish a WITH(NOLOCK)
  18708. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
  18709. INNER JOIN SearchDB..cpSearchCvID b ON a.id=b.CvID
  18710. WHERE b.cpSearchConditionID=@cpSearchConditionID AND b.ID>=@MinId
  18711. ORDER BY b.ID, a.ID DESC
  18712. --RICHARD 2011-7-23 16:51分修改
  18713. UPDATE a SET a.cvEducationID = (
  18714. SELECT TOP 1 ID FROM cvEducationPublish WITH(NOLOCK)
  18715. WHERE cvEducationPublish.cvMainID = a.ID
  18716. AND a.Degree = cvEducationPublish.Degree
  18717. ORDER BY Graduation DESC)
  18718. FROM @T_CvList a
  18719. UPDATE a SET a.College = ISNULL(b.GraduateCollage, b.GraduateCollageEng), a.EduType = b.EduType,
  18720. a.MajorName = ISNULL(b.MajorName, b.MajorNameEng), a.Graduation = b.Graduation
  18721. FROM @T_CvList a, cvEducationPublish b WITH(NOLOCK)
  18722. WHERE b.ID = a.cvEducationID
  18723. --修改是否绑定微信
  18724. UPDATE a SET HasWeiXin = 1
  18725. FROM @T_CvList a, WxFans b WITH(NOLOCK), CvMainPublish c WITH(NOLOCK)
  18726. WHERE a.ID = c.ID
  18727. AND c.PaMainID = b.PaMainID
  18728. AND b.Status = 2
  18729. UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
  18730. FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
  18731. WHERE b.cvMainID = a.ID AND caMainID=@caMainID
  18732. SELECT a.*, b.Description DegreeName,c.Description LivePlaceName, dbo.BirthToAge(a.BirthDay) Age,d.Description dcSalaryName
  18733. FROM @T_CvList a
  18734. LEFT JOIN dcEducation b WITH(NOLOCK) ON b.ID = a.Degree
  18735. LEFT JOIN dcRegion c WITH(NOLOCK) ON c.ID = a.LivePlace
  18736. LEFT JOIN dcSalary d WITH(NOLOCK) ON d.ID = a.dcSalaryID
  18737. ORDER BY a.Seq
  18738. END
  18739. --记录查询时间
  18740. UPDATE SearchDB..cpSearchCondition SET EndDate = GETDATE() WHERE ID = @cpSearchConditionID
  18741. RETURN
  18742. END
  18743. END TRY
  18744. BEGIN CATCH
  18745. ---检查是否已经建立临时表,已经建立则删除
  18746. BEGIN TRY
  18747. DROP TABLE #FullText
  18748. END TRY
  18749. BEGIN CATCH
  18750. END CATCH
  18751. BEGIN TRY
  18752. DROP TABLE #cv
  18753. END TRY
  18754. BEGIN CATCH
  18755. END CATCH
  18756. PRINT '查询时出现错误,请联系技术人员检查,错误信息:'
  18757. PRINT Error_Message()
  18758. PRINT Error_Number()
  18759. PRINT Error_Line()
  18760. END CATCH
  18761. GO
  18762. /****** Object: StoredProcedure [dbo].[ccCvBySearchSelectTest] Script Date: 2018/12/13 19:06:39 ******/
  18763. SET ANSI_NULLS ON
  18764. GO
  18765. SET QUOTED_IDENTIFIER ON
  18766. GO
  18767. CREATE PROCEDURE [dbo].[ccCvBySearchSelectTest]
  18768. (
  18769. @dcJobTypeID VARCHAR(50), --职位类别
  18770. @dcRegionID VARCHAR(50), --求职地区
  18771. @dcIndustryID VARCHAR(50), --现从事行业
  18772. @IncludeOld BIT, --1包含曾从事职业
  18773. @dcJobTypeIDExpect VARCHAR(50),--期望职位类别
  18774. @dcIndustryIDExpect VARCHAR(50),--期望求职行业
  18775. @dcSalaryID TINYINT, --月薪
  18776. @IsNegotiable BIT, --1允许面议,不面议
  18777. @MinExperience TINYINT, --工作经验
  18778. @dcEducationID TINYINT, --最低学历
  18779. @LanguageType SMALLINT, --语种
  18780. @KeyWord NVARCHAR(20), --关键词
  18781. @College NVARCHAR(50), --学校名称
  18782. @Standard BIT, --是否统招
  18783. @SubNodeNum INT, --下属人数
  18784. @Major INT, --所学专业
  18785. @Graduation INT, --毕业时间 year
  18786. @Gender TINYINT, --性别,2不限
  18787. @MaxAge SMALLINT, --最大年龄
  18788. @MinAge SMALLINT, --最小年龄
  18789. @LivePlace VARCHAR(50), --现居住地
  18790. @AccountPlace INT, --户口所在地
  18791. @MobilePlace VARCHAR(50), --Mobile住地
  18792. @MinHeight TINYINT, --MinHeight
  18793. @MaxHeight TINYINT, --MaxHeight
  18794. @SortType TINYINT, --排序方式
  18795. @CvMainID INT, --简历ID
  18796. --@dcCareerStatus TINYINT, --简历状态
  18797. --sessionid,没有采用全部人员共享方式,因为10分钟内,搜索相同条件的可能性很大,
  18798. --而10分钟搜索的用户翻到第二页时内容可能会和第一页一样。这样让用户很难理解。
  18799. --使用SessionID,可以保证60分钟内查询结果一致。出现不一致的几率很小
  18800. @SessionID INT,
  18801. @PageNumber INT, --翻页页码
  18802. @IsExpand BIT, --是否扩大地区范围
  18803. @caMainID INT, --企业用户ID,用来判断是否和建立联系
  18804. @cvEmployType INT --期望工作性质ID,用来限制期望工作性质选项
  18805. )
  18806. AS
  18807. --return
  18808. SET NOCOUNT ON
  18809. BEGIN TRY
  18810. DECLARE @MajorName AS NVARCHAR(20), @KeyTemp NVARCHAR(20)
  18811. IF @dcJobTypeID IS NULL
  18812. SET @dcJobTypeID = ''
  18813. SET @dcJobTypeID = dbo.FormatIDS(@dcJobTypeID)
  18814. IF @dcJobTypeIDExpect IS NULL
  18815. SET @dcJobTypeIDExpect = ''
  18816. SET @dcJobTypeIDExpect = dbo.FormatIDS(@dcJobTypeIDExpect)
  18817. IF @dcRegionID IS NULL
  18818. SET @dcRegionID = ''
  18819. SET @dcRegionID = dbo.FormatIDS(@dcRegionID)
  18820. IF @dcIndustryID IS NULL
  18821. Set @dcIndustryID = ''
  18822. SET @dcIndustryID = dbo.FormatIDS(@dcIndustryID)
  18823. IF @dcIndustryIDExpect IS NULL
  18824. SET @dcIndustryIDExpect = ''
  18825. SET @dcIndustryIDExpect = dbo.FormatIDS(@dcIndustryIDExpect)
  18826. IF @dcSalaryID IS NULL
  18827. SET @dcSalaryID = 0
  18828. IF @IsNegotiable IS NULL
  18829. SET @IsNegotiable = 0
  18830. IF @MinExperience IS NULL
  18831. SET @MinExperience = 99
  18832. IF @dcEducationID IS NULL
  18833. SET @dcEducationID = 0
  18834. IF @LanguageType IS NULL
  18835. SET @LanguageType = 0
  18836. IF @College IS NULL
  18837. SET @College = ''
  18838. IF LEN(@College) < 2
  18839. SET @College = ''
  18840. WHILE @KeyWord LIKE '% %'
  18841. SET @KeyWord = REPLACE(@KeyWord, ' ', ' ')
  18842. SET @KeyWord = LTRIM(RTRIM(dbo.SafeSQL(@KeyWord)))
  18843. SET @KeyTemp = @KeyWord
  18844. IF @KeyWord IS NULL OR LEN(@KeyWord) < 2
  18845. SELECT @KeyWord = '', @KeyTemp = ''
  18846. ELSE
  18847. BEGIN
  18848. IF LEFT(@KeyWord, 7) = 'major::'
  18849. BEGIN
  18850. SELECT @MajorName = REPLACE(@KeyWord, 'major::', '')
  18851. SELECT @KeyWord = '', @KeyTemp = ''
  18852. END
  18853. ELSE
  18854. BEGIN
  18855. DECLARE @p INT
  18856. SET @p = CHARINDEX('@@', @KeyWord)
  18857. IF @p > 0
  18858. BEGIN
  18859. SELECT @MajorName = LTRIM(RTRIM(RIGHT(@KeyWord, LEN(@KeyWord) - @p - 1)))
  18860. SELECT @KeyTemp = LEFT(@KeyWord, @p - 1)
  18861. IF LEN(@KeyTemp) < 2
  18862. SET @KeyTemp = ''
  18863. END
  18864. END
  18865. END
  18866. SET @KeyTemp = REPLACE(@KeyTemp, ' ', ' near ')
  18867. SET @College = dbo.SafeSQL(@College)
  18868. IF @SubNodeNum IS NULL
  18869. SET @SubNodeNum = 0
  18870. IF @MaxAge IS NULL OR @MaxAge = 0
  18871. SET @MaxAge = 99
  18872. IF @MinAge IS NULL OR @MinAge = 0
  18873. SET @MinAge = 99
  18874. IF @LivePlace IS NULL
  18875. SET @LivePlace = ''
  18876. SET @LivePlace = dbo.FormatIDS(@LivePlace)
  18877. IF @MobilePlace IS NULL
  18878. SET @MobilePlace = ''
  18879. SET @MobilePlace = dbo.FormatIDS(@MobilePlace)
  18880. IF @AccountPlace IS NULL
  18881. SET @AccountPlace = 0
  18882. IF @Gender IS NULL
  18883. SET @Gender = 2
  18884. IF @IncludeOld IS NULL
  18885. SET @IncludeOld = 0
  18886. IF @Major IS NULL
  18887. SET @Major = 0
  18888. IF @Graduation IS NULL
  18889. SET @Graduation = 0
  18890. ELSE IF @Graduation > DATEPART(YEAR, GETDATE()) + 1 OR @Graduation < DATEPART(YEAR, GETDATE()) - 10
  18891. SET @Graduation = 0
  18892. IF @CvMainID IS NULL
  18893. SET @CvMainID = 0
  18894. IF @Standard IS NULL
  18895. SET @Standard = 0
  18896. IF @IsExpand IS NULL
  18897. SET @IsExpand = 0
  18898. SET @MinHeight = ISNULL(@MinHeight, 0)
  18899. SET @MaxHeight = ISNULL(@MaxHeight, 250)
  18900. IF @MinHeight < 140 OR @MinHeight > 200
  18901. SET @MinHeight = 0
  18902. IF @cvEmployType IS NULL
  18903. SET @cvEmployType = 0
  18904. IF @CvMainID = 0
  18905. BEGIN
  18906. ----给null值变量赋默认值
  18907. DECLARE @cpSearchConditionID AS INT
  18908. SELECT @cpSearchConditionID=0, @SessionID = 1
  18909. DECLARE @MinId AS INT
  18910. --sqlserver中计划任务自动删除60分钟前的数据
  18911. SELECT TOP 1 @cpSearchConditionID = ID FROM SearchDB..cpSearchCondition WITH(NOLOCK)
  18912. WHERE SessionID=@SessionID AND dcJobTypeID=@dcJobTypeID AND dcJobTypeIDExpect=@dcJobTypeIDExpect
  18913. AND dcRegionID=@dcRegionID AND dcIndustryID=@dcIndustryID AND dcIndustryIDExpect=@dcIndustryIDExpect
  18914. AND IncludeOld=@IncludeOld AND dcSalaryID=@dcSalaryID AND IsNegotiable=@IsNegotiable
  18915. AND MinExperience=@MinExperience AND dcEducationID=@dcEducationID AND LanguageType=@LanguageType
  18916. AND KeyWord=@KeyWord AND College=@College AND Standard=@Standard AND SortType=@SortType
  18917. AND SubNodeNum = @SubNodeNum AND Major = @Major AND Graduation = @Graduation AND Gender=@Gender AND MaxAge=@MaxAge
  18918. AND MinAge=@MinAge AND LivePlace=@LivePlace AND AccountPlace=@AccountPlace AND MobilePlace=@MobilePlace
  18919. AND IsExpand=@IsExpand AND MinHeight = @MinHeight AND MaxHeight = @MaxHeight AND LogTime > DATEADD(M, -60, GETDATE())
  18920. AND EmployType=@cvEmployType
  18921. ORDER BY ID DESC
  18922. IF ISNULL(@cpSearchConditionID, 0) = 0
  18923. GOTO SelectReset --无数据,重新搜索
  18924. ELSE
  18925. GOTO GetRecordSet --从临时结果中提取数据
  18926. END
  18927. ELSE
  18928. BEGIN
  18929. ----如果有简历id,则直接显示,不再查询
  18930. SELECT COUNT(1) FROM cvmainPublish WITH(NOLOCK) WHERE ID = @CvMainID AND Valid > 0
  18931. DECLARE @T_Cv AS TABLE(
  18932. ID INT,
  18933. dcMajorID INT,
  18934. Degree TINYINT,
  18935. RelatedWorkYears INT,
  18936. dcSalaryID TINYINT,
  18937. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  18938. RefreshDate SMALLDATETIME,
  18939. LastLoginDate SMALLDATETIME,
  18940. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  18941. Gender BIT,
  18942. BirthDay INT,
  18943. LivePlace INT,
  18944. Attachment VARCHAR(50),
  18945. HasPhoto TINYINT,
  18946. College NVARCHAR(50),
  18947. EduType TINYINT,
  18948. MajorName NVARCHAR(20),
  18949. Graduation INT,
  18950. HasViewed BIT,
  18951. ViewDate SMALLDATETIME,
  18952. HasRemarked BIT,
  18953. LastJobTypeID INT,
  18954. Valid TINYINT
  18955. )
  18956. INSERT INTO @T_Cv(ID,dcMajorID,Degree,RelatedWorkYears,dcSalaryID,Speciality,RefreshDate,LastLoginDate,
  18957. JobName,Gender,BirthDay,LivePlace,LastJobTypeID,Attachment,HasPhoto,HasViewed,HasRemarked,Valid)
  18958. SELECT a.ID,a.dcMajorID,a.Degree,a.RelatedWorkYears,a.dcSalaryID,ISNULL(a.Speciality,a.SpecialityEng) Speciality,a.RefreshDate,
  18959. j.LastLoginDate,ISNULL(a.JobName, '应届毕业生') JobName,j.Gender,j.BirthDay,j.LivePlace,a.LastJobTypeID,
  18960. a.Attachment,j.HasPhoto,0,0,a.Valid FROM cvmainPublish a WITH(NOLOCK)
  18961. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
  18962. WHERE a.ID=@CvMainID AND a.Valid > 0
  18963. UPDATE a SET a.College = ISNULL(b.GraduateCollage,b.GraduateCollageEng), a.EduType = b.EduType,
  18964. a.MajorName = ISNULL(b.MajorName,b.MajorNameEng), a.Graduation = b.Graduation FROM @T_Cv a,
  18965. cvEducationPublish b WITH(NOLOCK) WHERE b.cvMainID = a.ID AND b.Degree = a.Degree
  18966. UPDATE a SET a.HasViewed = 1, a.ViewDate = (SELECT AddDate FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  18967. FROM @T_Cv a WHERE EXISTS(SELECT 'X' FROM caCvViewLog WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  18968. -- UPDATE a SET a.HasRemarked = 1
  18969. -- FROM @T_Cv a WHERE EXISTS(SELECT 'X' FROM caCvRemark WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  18970. SELECT * FROM @T_Cv
  18971. RETURN
  18972. END
  18973. SelectReset: --从cv中搜索数据
  18974. BEGIN
  18975. DECLARE @SQL AS VARCHAR(8000)
  18976. DECLARE @WHERE AS VARCHAR(8000)
  18977. DECLARE @FROM AS VARCHAR(1000)
  18978. ----记录查询条件
  18979. INSERT INTO SearchDB..cpSearchCondition(SessionID,dcJobTypeID,dcJobTypeIDExpect,dcRegionID,dcIndustryID,
  18980. dcIndustryIDExpect,IncludeOld,dcSalaryID,IsNegotiable,SortType,
  18981. MinExperience,dcEducationID,LanguageType,KeyWord,College,Standard,SubNodeNum,
  18982. Major,Graduation,Gender,MaxAge,MinAge,LivePlace,AccountPlace,MobilePlace,IsExpand, MinHeight, MaxHeight, ReuseNumber, EmployType)
  18983. VALUES(@SessionID,@dcJobTypeID,@dcJobTypeIDExpect,@dcRegionID,@dcIndustryID,
  18984. @dcIndustryIDExpect,@IncludeOld,@dcSalaryID,@IsNegotiable,@SortType,
  18985. @MinExperience,@dcEducationID,@LanguageType,@KeyWord,@College,@Standard,@SubNodeNum,
  18986. @Major,@Graduation,@Gender,@MaxAge,@MinAge,@LivePlace,@AccountPlace,@MobilePlace,@IsExpand, @MinHeight, @MaxHeight, 0,@cvEmployType)
  18987. SET @cpSearchConditionID = @@IDENTITY
  18988. ------生成职位类别的表变量,因为职位类别有包含(父子)关系
  18989. DECLARE @T_JobPlace AS TABLE(ID INT)
  18990. DECLARE @T_JobType AS TABLE(ID INT)
  18991. DECLARE @JobType AS VARCHAR(3000)
  18992. DECLARE @JobTypeExpect AS VARCHAR(3000)
  18993. DECLARE @JobPlace AS VARCHAR(2000)
  18994. DECLARE @tmpLivePlace AS VARCHAR(2000)
  18995. DECLARE @tmpMobilePlace AS VARCHAR(2000)
  18996. SET @JobPlace = ''
  18997. SET @tmpLivePlace = ''
  18998. SET @tmpMobilePlace = ''
  18999. SET @JobType=''
  19000. SET @JobTypeExpect = ''
  19001. SET @WHERE = ' WHERE a.Valid > 0'
  19002. ----生成工作地点的表变量
  19003. IF LEN(@dcRegionID) > 0
  19004. BEGIN
  19005. INSERT INTO @T_JobPlace
  19006. SELECT * FROM dbo.fnSplit(@dcRegionID, ',')
  19007. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  19008. IF @IsExpand = 1
  19009. BEGIN
  19010. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID = ''' + LTRIM(STR(LEFT(ID,2)))+'''' )
  19011. FROM @T_JobPlace WHERE LEN(ID) > 2
  19012. SELECT @JobPlace = (@JobPlace + ' OR h.dcRegionID = ''' + LTRIM(STR(LEFT(ID,4)))+'''' )
  19013. FROM @T_JobPlace WHERE LEN(ID) > 4
  19014. END
  19015. IF LEN(@JobPlace) > 0
  19016. SET @JobPlace = RIGHT(@JobPlace, LEN(@JobPlace) -4)
  19017. END
  19018. IF LEN(@LivePlace) > 0
  19019. BEGIN
  19020. DELETE FROM @T_JobPlace
  19021. INSERT INTO @T_JobPlace
  19022. SELECT * FROM dbo.fnSplit(@LivePlace, ',')
  19023. SELECT @tmpLivePlace = (@tmpLivePlace + ' OR j.LivePlace Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  19024. IF LEN(@tmpLivePlace) > 0
  19025. SET @tmpLivePlace = RIGHT(@tmpLivePlace, LEN(@tmpLivePlace) -4)
  19026. END
  19027. IF LEN(@MobilePlace) > 0
  19028. BEGIN
  19029. DELETE FROM @T_JobPlace
  19030. INSERT INTO @T_JobPlace
  19031. SELECT * FROM dbo.fnSplit(@MobilePlace, ',')
  19032. SELECT @tmpMobilePlace = (@tmpMobilePlace + ' OR j.MobileRegion Like ''' + LTRIM(STR(ID) + '%''')) FROM @T_JobPlace
  19033. IF LEN(@tmpMobilePlace) > 0
  19034. SET @tmpMobilePlace = RIGHT(@tmpMobilePlace, LEN(@tmpMobilePlace) -4)
  19035. END
  19036. ----生成求聘职位的表变量
  19037. IF LEN(@dcJobTypeID) > 0
  19038. BEGIN
  19039. DECLARE @T_Temp AS TABLE(ID INT) --临时表,用于构建组合查询语句
  19040. INSERT INTO @T_Temp
  19041. SELECT * FROM dbo.fnSplit(@dcJobTypeID, ',')
  19042. INSERT INTO @T_JobType
  19043. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  19044. WHERE ParentId IN(SELECT ID FROM @T_TEMP)
  19045. OR ParentId2 in(SELECT ID FROM @T_TEMP)
  19046. OR ID IN(SELECT ID FROM @T_TEMP)
  19047. ----生成in字符串
  19048. SELECT @JobType = (@JobType + LTRIM(STR(ID) + ',')) FROM @T_JobType
  19049. IF RIGHT(@JobType, 1) = ','
  19050. SET @JobType = LEFT(@JobType, LEN(@JobType) - 1)
  19051. END
  19052. IF LEN(@dcJobTypeIDExpect) > 0
  19053. BEGIN
  19054. DECLARE @T_Temp1 AS TABLE(ID INT) --临时表,用于构建组合查询语句
  19055. INSERT INTO @T_Temp1
  19056. SELECT * FROM dbo.fnSplit(@dcJobTypeIDExpect, ',')
  19057. DELETE FROM @T_JobType
  19058. INSERT INTO @T_JobType
  19059. SELECT DISTINCT ID FROM dcJobType WITH(NOLOCK)
  19060. WHERE ParentId IN(SELECT ID FROM @T_TEMP1)
  19061. OR ParentId2 in(SELECT ID FROM @T_TEMP1)
  19062. OR ID IN(SELECT ID FROM @T_TEMP1)
  19063. ----生成in字符串
  19064. SELECT @JobTypeExpect = (@JobTypeExpect + LTRIM(STR(ID) + ',')) FROM @T_JobType
  19065. IF RIGHT(@JobTypeExpect, 1) = ','
  19066. SET @JobTypeExpect = LEFT(@JobTypeExpect, LEN(@JobTypeExpect) - 1)
  19067. END
  19068. ----建立关键字搜索的临时表
  19069. CREATE TABLE #FullText(
  19070. CvID INT NOT NULL
  19071. )
  19072. ----建立临时表
  19073. CREATE TABLE #Cv(
  19074. ID INT NOT NULL,
  19075. RefreshDate SMALLDATETIME NOT NULL
  19076. )
  19077. ----生成插入临时表的Sql语句
  19078. SET @SQL = '
  19079. INSERT INTO #Cv
  19080. SELECT DISTINCT TOP 2000 a.ID'
  19081. IF @SortType = 1
  19082. SET @SQL = @SQL + ', j.LastLoginDate'
  19083. ELSE
  19084. SET @SQL = @SQL + ', a.RefreshDate'
  19085. SET @FROM = '
  19086. FROM cvmainPublish a WITH(NOLOCK) INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID'
  19087. ----工作经验的职位类别
  19088. IF LEN(@dcJobTypeID) > 0
  19089. BEGIN
  19090. IF @IncludeOld = 0 ----最近从事和曾从事职位
  19091. SET @WHERE = @WHERE + '
  19092. AND (a.LastJobTypeID IN(' + @JobType +'))'
  19093. ELSE
  19094. SET @WHERE = @WHERE + '
  19095. AND (c.dcJobTypeID IN(' + @JobType +'))'
  19096. END
  19097. ----期望职位类别
  19098. IF LEN(@dcJobTypeIDExpect) > 0
  19099. BEGIN
  19100. SET @WHERE = @WHERE + '
  19101. AND (g.dcJobTypeID IN(' + @JobTypeExpect +'))'
  19102. END
  19103. ----工作地点
  19104. IF LEN(@JobPlace) > 0
  19105. SET @WHERE = @WHERE + '
  19106. AND (' + @JobPlace + ')'
  19107. ----现从事行业
  19108. IF LEN(@dcIndustryID) > 0
  19109. SET @WHERE = @WHERE + '
  19110. AND (a.LastIndustryID IN(' + @dcIndustryID + '))'
  19111. ----期望行业
  19112. IF LEN(@dcIndustryIDExpect) > 0
  19113. BEGIN
  19114. SET @WHERE = @WHERE + '
  19115. AND (i.dcIndustryID IN(' + @dcIndustryIDExpect + '))'
  19116. END
  19117. ----下属人数
  19118. IF @SubNodeNum > 0
  19119. BEGIN
  19120. SET @WHERE = @WHERE + '
  19121. AND a.SubNodeNum = ' + LTRIM(STR(@SubNodeNum))
  19122. END
  19123. ----当前所在地
  19124. IF LEN(@tmpLivePlace) > 0
  19125. BEGIN
  19126. SET @WHERE = @WHERE + '
  19127. AND (' + @tmpLivePlace + ')'
  19128. END
  19129. ----Mobile所在地
  19130. IF LEN(@tmpMobilePlace) > 0
  19131. BEGIN
  19132. SET @WHERE = @WHERE + '
  19133. AND (' + @tmpMobilePlace + ')'
  19134. END
  19135. ----户口所在地
  19136. IF @AccountPlace > 0
  19137. BEGIN
  19138. SET @WHERE = @WHERE + '
  19139. AND j.AccountPlace LIKE ''' + LTRIM(STR(@AccountPlace)) + '%'''
  19140. END
  19141. ----专业
  19142. IF @Major > 0
  19143. BEGIN
  19144. SET @WHERE = @WHERE + '
  19145. AND b.dcMajorID = ' + LTRIM(STR(@Major))
  19146. END
  19147. --Graduation
  19148. IF @Graduation = DATEPART(YEAR, GETDATE()) + 1
  19149. BEGIN
  19150. SET @WHERE = @WHERE + '
  19151. AND b.Graduation > ' + LTRIM(STR(@Graduation)) + '00'
  19152. END
  19153. ELSE IF @Graduation > DATEPART(YEAR, GETDATE()) - 10
  19154. BEGIN
  19155. SET @WHERE = @WHERE + '
  19156. AND b.Graduation BETWEEN ' + LTRIM(STR(@Graduation)) + '00 AND ' + LTRIM(STR(@Graduation)) + '99'
  19157. END
  19158. ELSE IF @Graduation = DATEPART(YEAR, GETDATE()) - 10
  19159. BEGIN
  19160. SET @WHERE = @WHERE + '
  19161. AND b.Graduation < ' + LTRIM(STR(@Graduation)) + '99'
  19162. END
  19163. ----性别
  19164. IF @Gender < 2
  19165. BEGIN
  19166. SET @WHERE = @WHERE + '
  19167. AND j.Gender=' + LTRIM(STR(@Gender))
  19168. END
  19169. ----年龄
  19170. IF @MinAge < 99
  19171. BEGIN
  19172. SET @WHERE = @WHERE + '
  19173. AND j.BirthDay <= ' + LTRIM(STR(dbo.AgeToBirth(@MinAge)))
  19174. END
  19175. IF @MaxAge < 99
  19176. BEGIN
  19177. SET @MaxAge = @MaxAge + 1
  19178. SET @WHERE = @WHERE + '
  19179. AND j.BirthDay > ' + LTRIM(STR(dbo.AgeToBirth(@MaxAge)))
  19180. END
  19181. IF @MinHeight > 139
  19182. BEGIN
  19183. SET @WHERE = @WHERE + '
  19184. AND j.Height >= ' + LTRIM(STR(@MinHeight))
  19185. END
  19186. IF @MaxHeight < 231
  19187. BEGIN
  19188. SET @WHERE = @WHERE + '
  19189. AND j.Height <= ' + LTRIM(STR(@MaxHeight))
  19190. END
  19191. ----薪水
  19192. IF @dcSalaryID > 0
  19193. BEGIN
  19194. SET @WHERE = @WHERE + '
  19195. AND((
  19196. a.dcSalaryID >=' + LTRIM(STR(@dcSalaryID-1)) + '
  19197. AND a.dcSalaryID <=' + LTRIM(STR(@dcSalaryID+1)) + '
  19198. )'
  19199. IF @IsNegotiable = 1 --包括面议
  19200. SET @WHERE = @WHERE + '
  19201. OR a.IsNegotiable=1'
  19202. SET @WHERE = @WHERE + ')'
  19203. END
  19204. ----工作经验要求
  19205. IF @MinExperience < 99
  19206. BEGIN
  19207. IF @MinExperience = 4
  19208. SET @WHERE = @WHERE + '
  19209. AND a.RelatedWorkYears=11'
  19210. ELSE IF @MinExperience = 1
  19211. SET @WHERE = @WHERE + '
  19212. AND a.RelatedWorkYears>=1 AND a.RelatedWorkYears<=2'
  19213. ELSE IF @MinExperience = 2
  19214. SET @WHERE = @WHERE + '
  19215. AND a.RelatedWorkYears>=3 AND a.RelatedWorkYears<=5'
  19216. ELSE IF @MinExperience = 3
  19217. SET @WHERE = @WHERE + '
  19218. AND a.RelatedWorkYears>=6 AND a.RelatedWorkYears<=10'
  19219. ELSE IF @MinExperience = 5
  19220. SET @WHERE = @WHERE + '
  19221. AND a.RelatedWorkYears>=2 AND a.RelatedWorkYears<=3'
  19222. ELSE
  19223. SET @WHERE = @WHERE + '
  19224. AND a.RelatedWorkYears=0'
  19225. END
  19226. ----学历要求
  19227. IF @dcEducationID > 0
  19228. BEGIN
  19229. IF @dcEducationID = 1
  19230. SET @WHERE = @WHERE + ' AND a.Degree IN(1,2,3,4) '
  19231. ELSE IF @dcEducationID = 2
  19232. SET @WHERE = @WHERE + ' AND a.Degree <= 5 '
  19233. ELSE IF @dcEducationID = 3
  19234. SET @WHERE = @WHERE + ' AND a.Degree = 5 '
  19235. ELSE IF @dcEducationID = 4
  19236. SET @WHERE = @WHERE + ' AND a.Degree IN(5,6) '
  19237. ELSE IF @dcEducationID = 5
  19238. SET @WHERE = @WHERE + ' AND a.Degree = 6 '
  19239. ELSE IF @dcEducationID = 6
  19240. SET @WHERE = @WHERE + ' AND a.Degree >= 6 '
  19241. ELSE IF @dcEducationID = 7
  19242. SET @WHERE = @WHERE + ' AND a.Degree = 7 '
  19243. ELSE IF @dcEducationID = 8
  19244. SET @WHERE = @WHERE + ' AND a.Degree = 8 '
  19245. IF @Major > 0 OR LEN(@College) > 0 OR @Standard = 1 OR @MajorName > ''
  19246. SET @WHERE = @WHERE + '
  19247. AND b.Degree = a.Degree'
  19248. IF @Standard = 1
  19249. SET @WHERE = @WHERE + '
  19250. AND b.EduType=1'
  19251. END
  19252. ----语种
  19253. IF @LanguageType > 0
  19254. SET @WHERE = @WHERE + '
  19255. AND d.LanguageType = ' + LTRIM(STR(@LanguageType))
  19256. ----关键词
  19257. IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
  19258. BEGIN
  19259. DECLARE @S DATETIME, @SqlFt VARCHAR(MAX)
  19260. SELECT @S = GETDATE()
  19261. INSERT INTO #FullText
  19262. SELECT [key] FROM CONTAINSTABLE(CvMainPublish, *, @KeyTemp, 100000) AS KeyCv
  19263. INSERT INTO #FullText
  19264. SELECT DISTINCT cvMainID FROM CvExperiencePublish WITH(NOLOCK) WHERE ID IN(
  19265. SELECT [key] FROM CONTAINSTABLE(CvExperiencePublish, *, @KeyTemp, 100000) AS KeyCv)
  19266. INSERT INTO #FullText
  19267. SELECT DISTINCT cvMainID FROM CvEducationPublish WITH(NOLOCK) WHERE ID IN(
  19268. SELECT [key] FROM CONTAINSTABLE(CvEducationPublish, *, @KeyTemp, 100000) AS KeyCv)
  19269. INSERT INTO #FullText
  19270. SELECT DISTINCT cvMainID FROM CvProjectPublish WITH(NOLOCK) WHERE ID IN(
  19271. SELECT [key] FROM CONTAINSTABLE(CvProjectPublish, *, @KeyTemp, 100000) AS KeyCv)
  19272. INSERT INTO #FullText
  19273. SELECT DISTINCT cvMainID FROM CvTrainingPublish WITH(NOLOCK) WHERE ID IN(
  19274. SELECT [key] FROM CONTAINSTABLE(CvTrainingPublish, *, @KeyTemp, 100000) AS KeyCv)
  19275. --Richard 2011.8.21增加
  19276. INSERT INTO #FullText
  19277. SELECT DISTINCT cvMainID FROM CvAppendixPublish WITH(NOLOCK) WHERE ID IN(
  19278. SELECT [key] FROM CONTAINSTABLE(CvAppendixPublish, *, @KeyTemp, 100000) AS KeyCv)
  19279. --Richard 2011.8.24增加
  19280. SELECT @SqlFt = 'SELECT [key] FROM CONTAINSTABLE(CvMainPublish, *, ''' + @KeyTemp + ''',100000) AS KeyCv ORDER BY [key] DESC 开始:' + CONVERT(varchar(8), @S, 8) + ' 结束:' + CONVERT(varchar(8), getdate(), 8)
  19281. UPDATE SearchDB..cpSearchCondition SET SqlFT = @SqlFt WHERE ID = @cpSearchConditionID
  19282. END
  19283. ----学校名称
  19284. IF LEN(@College) > 0
  19285. SET @WHERE = @WHERE + '
  19286. AND b.GraduateCollage LIKE ''%' + LTRIM((@College)) + '%'''
  19287. IF LEN(@MajorName) > 0
  19288. SET @WHERE = @WHERE + '
  19289. AND b.MajorName LIKE ''%' + LTRIM((@MajorName)) + '%'''
  19290. --工作性质
  19291. IF @cvEmployType IN(2, 4)
  19292. SET @WHERE = @WHERE + '
  19293. AND a.EmployType = ' + LTRIM(STR(@cvEmployType))
  19294. ELSE IF @cvEmployType = 1
  19295. SET @WHERE = @WHERE + '
  19296. AND a.EmployType IN (1, 2) '
  19297. ELSE IF @cvEmployType = 3
  19298. SET @WHERE = @WHERE + '
  19299. AND a.EmployType IN (3, 2) '
  19300. IF CHARINDEX('b.',@WHERE) > 0
  19301. SET @FROM = @FROM + ' INNER JOIN cvEducationPublish b WITH(NOLOCK) ON a.ID=b.cvMainID'
  19302. IF CHARINDEX('c.',@WHERE) > 0
  19303. SET @FROM = @FROM + ' INNER JOIN CvExperiencePublish c WITH(NOLOCK) ON a.ID=c.cvMainID'
  19304. IF CHARINDEX('d.',@WHERE) > 0
  19305. SET @FROM = @FROM + ' INNER JOIN cvLanguagePublish d WITH(NOLOCK) ON a.ID=d.cvMainID'
  19306. IF CHARINDEX('e.',@WHERE) > 0
  19307. SET @FROM = @FROM + ' INNER JOIN cvTrainingPublish e WITH(NOLOCK) ON a.ID=e.cvMainID'
  19308. IF CHARINDEX('f.',@WHERE) > 0
  19309. SET @FROM = @FROM + ' INNER JOIN cvProjectPublish f WITH(NOLOCK) ON a.ID=f.cvMainID'
  19310. IF CHARINDEX('g.',@WHERE) > 0
  19311. SET @FROM = @FROM + ' INNER JOIN cvJobTypePublish g WITH(NOLOCK) ON a.ID=g.cvMainID'
  19312. IF CHARINDEX('h.',@WHERE) > 0
  19313. SET @FROM = @FROM + ' INNER JOIN cvJobPlacePublish h WITH(NOLOCK) ON a.ID=h.cvMainID'
  19314. IF CHARINDEX('i.',@WHERE) > 0
  19315. SET @FROM = @FROM + ' INNER JOIN cvIndustryPublish i WITH(NOLOCK) ON a.ID=i.cvMainID'
  19316. IF LEN(@KeyTemp) > 0 --AND @MajorName IS NULL
  19317. SET @FROM = @FROM + ' INNER JOIN #FullText k WITH(NOLOCK) ON a.ID=k.cvID'
  19318. SET @SQL = @SQL + @FROM + @WHERE
  19319. IF @SortType = 1
  19320. SET @SQL = @SQL + '
  19321. ORDER BY j.LastLoginDate DESC, a.ID'
  19322. ELSE
  19323. SET @SQL = @SQL + '
  19324. ORDER BY a.RefreshDate DESC, a.ID'
  19325. --PRINT @SQL
  19326. ----把符合条件的职位全部列出
  19327. UPDATE SearchDB..cpSearchCondition SET Sql = REPLACE(@SQL, 'INSERT INTO #Cv', ''), StartDate = GETDATE() WHERE ID = @cpSearchConditionID
  19328. EXEC(@SQL)
  19329. ----记录查询结果总数
  19330. DECLARE @ValidCvNumber INT
  19331. SET @ValidCvNumber = @@ROWCOUNT
  19332. UPDATE SearchDB..cpSearchCondition SET ValidCvNumber = @ValidCvNumber WHERE ID = @cpSearchConditionID
  19333. --记录查询时间
  19334. UPDATE SearchDB..cpSearchCondition SET EndDate = GETDATE() WHERE ID = @cpSearchConditionID
  19335. INSERT INTO SearchDB..cpSearchCvID
  19336. SELECT TOP 2000 @cpSearchConditionID, ID FROM #Cv WITH(NOLOCK)
  19337. DROP TABLE #Cv
  19338. DROP TABLE #FullText
  19339. GOTO GetRecordSet
  19340. END
  19341. GetRecordSet:
  19342. BEGIN
  19343. DECLARE @PageSize AS TINYINT
  19344. SET @PageSize = 20 --每页的行数
  19345. ----返回查询数量
  19346. UPDATE SearchDB..cpSearchCondition SET ReuseNumber = ReuseNumber + 1 WHERE ID=@cpSearchConditionID
  19347. SELECT ValidCvNumber FROM SearchDB..cpSearchCondition WITH(NOLOCK) WHERE ID=@cpSearchConditionID
  19348. ----返回20行查询结果
  19349. IF @PageNumber > 0
  19350. BEGIN
  19351. DECLARE @T_CvList AS TABLE(
  19352. ID INT,
  19353. cvEducationID INT,
  19354. dcMajorID INT,
  19355. Degree TINYINT,
  19356. RelatedWorkYears INT,
  19357. dcSalaryID TINYINT,
  19358. Speciality VARCHAR(MAX) COLLATE Chinese_PRC_CI_AS,
  19359. RefreshDate SMALLDATETIME,
  19360. LastLoginDate SMALLDATETIME,
  19361. JobName VARCHAR(100) COLLATE Chinese_PRC_CI_AS,
  19362. Gender BIT,
  19363. BirthDay INT,
  19364. LivePlace INT,
  19365. Attachment VARCHAR(50) COLLATE Chinese_PRC_CI_AS,
  19366. HasPhoto TINYINT,
  19367. College NVARCHAR(50),
  19368. EduType TINYINT,
  19369. MajorName NVARCHAR(20),
  19370. Graduation INT,
  19371. HasViewed BIT,
  19372. ViewDate SMALLDATETIME,
  19373. HasRemarked BIT,
  19374. LastJobTypeID INT,
  19375. Valid TINYINT
  19376. )
  19377. SELECT @MinId = MIN(ID)FROM SearchDB..cpSearchCvID WITH(NOLOCK) WHERE cpSearchConditionID=@cpSearchConditionID
  19378. SET @MinId = @MinId+(@PageNumber-1)*@PageSize
  19379. INSERT INTO @T_CvList(ID,dcMajorID,Degree,RelatedWorkYears,dcSalaryID,Speciality,RefreshDate,LastLoginDate,
  19380. JobName,Gender,BirthDay,LivePlace,LastJobTypeID,Attachment,HasPhoto,HasViewed,HasRemarked,Valid)
  19381. SELECT top 20 a.ID,a.dcMajorID,a.Degree,a.RelatedWorkYears,a.dcSalaryID,ISNULL(a.Speciality,a.SpecialityEng) Speciality,a.RefreshDate,
  19382. j.LastLoginDate,ISNULL(a.JobName, '应届毕业生') JobName,j.Gender,j.BirthDay,j.LivePlace,a.LastJobTypeID,
  19383. a.Attachment,j.HasPhoto,0,0,a.Valid FROM cvmainPublish a WITH(NOLOCK)
  19384. INNER JOIN paMainPublish j WITH(NOLOCK) ON a.paMainID=j.ID
  19385. INNER JOIN SearchDB..cpSearchCvID b ON a.id=b.CvID
  19386. WHERE b.cpSearchConditionID=@cpSearchConditionID AND b.ID>=@MinId
  19387. ORDER BY b.ID,a.ID DESC
  19388. --RICHARD 2011-7-23 16:51分修改
  19389. UPDATE a SET a.cvEducationID = (
  19390. SELECT TOP 1 ID FROM cvEducationPublish WITH(NOLOCK)
  19391. WHERE cvEducationPublish.cvMainID = a.ID
  19392. AND a.Degree = cvEducationPublish.Degree
  19393. ORDER BY Graduation DESC)
  19394. FROM @T_CvList a
  19395. UPDATE a SET a.College = ISNULL(b.GraduateCollage,b.GraduateCollageEng), a.EduType = b.EduType,
  19396. a.MajorName = ISNULL(b.MajorName,b.MajorNameEng), a.Graduation = b.Graduation
  19397. FROM @T_CvList a, cvEducationPublish b WITH(NOLOCK)
  19398. WHERE b.ID = a.cvEducationID
  19399. UPDATE a SET a.HasViewed = 1, a.ViewDate = b.AddDate
  19400. FROM @T_CvList a, caCvViewLog b WITH(NOLOCK)
  19401. WHERE b.cvMainID = a.ID AND caMainID=@caMainID
  19402. -- UPDATE a SET a.HasRemarked = 1
  19403. -- FROM @T_CvList a WHERE EXISTS(SELECT 'X' FROM caCvRemark WITH(NOLOCK) WHERE cvMainID = a.ID AND caMainID=@caMainID)
  19404. SELECT * FROM @T_CvList
  19405. END
  19406. RETURN
  19407. END
  19408. END TRY
  19409. BEGIN CATCH
  19410. ---检查是否已经建立临时表,已经建立则删除
  19411. BEGIN TRY
  19412. DROP TABLE #FullText
  19413. END TRY
  19414. BEGIN CATCH
  19415. END CATCH
  19416. BEGIN TRY
  19417. DROP TABLE #cv
  19418. END TRY
  19419. BEGIN CATCH
  19420. END CATCH
  19421. PRINT '查询时出现错误,请联系技术人员检查,错误信息:'
  19422. PRINT Error_Message()
  19423. PRINT Error_Number()
  19424. PRINT Error_Line()
  19425. END CATCH
  19426. GO
  19427. /****** Object: StoredProcedure [dbo].[ccCvLinkByCountSelect] Script Date: 2018/12/13 19:06:41 ******/
  19428. SET ANSI_NULLS ON
  19429. GO
  19430. SET QUOTED_IDENTIFIER ON
  19431. GO
  19432. CREATE PROCEDURE [dbo].[ccCvLinkByCountSelect]
  19433. (
  19434. @caMainID INT
  19435. )
  19436. AS
  19437. SET NOCOUNT ON
  19438. BEGIN
  19439. DECLARE @JobApply AS INT
  19440. DECLARE @NoRepliedJobApply AS INT
  19441. DECLARE @Message AS INT
  19442. DECLARE @NoViewedMessage AS INT
  19443. DECLARE @JobView AS INT
  19444. DECLARE @IsManager INT
  19445. SELECT @IsManager = AccountType FROM camain WHERE ID = @caMainID
  19446. IF @IsManager = 1
  19447. BEGIN
  19448. SELECT @JobApply = COUNT(*)
  19449. FROM exJobApply a WITH(NOLOCK), Job b WITH(NOLOCK)
  19450. WHERE a.CompanyDeleted = 0
  19451. AND a.JobID = b.ID
  19452. AND b.cpMainID = (SELECT CpMainID FROM CaMain WITH(NOLOCK) WHERE ID = @caMainID)
  19453. AND b.IsDelete = 0
  19454. SELECT @JobView = COUNT(*)
  19455. FROM PaJobViewLog a
  19456. INNER JOIN Job b WITH(NOLOCK) ON a.JobId = b.ID
  19457. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = a.paMainID
  19458. INNER JOIN cvMain d WITH(NOLOCK) ON d.paMainID=c.ID AND d.Valid>0
  19459. WHERE b.cpMainID = (SELECT CpMainID FROM CaMain WITH(NOLOCK) WHERE ID = @caMainID)
  19460. END
  19461. ELSE
  19462. BEGIN
  19463. SELECT @JobApply = COUNT(*)
  19464. FROM exJobApply a WITH(NOLOCK), Job b WITH(NOLOCK)
  19465. WHERE a.CompanyDeleted = 0
  19466. AND a.JobID =b.ID
  19467. AND b.caMainID = @caMainID
  19468. AND b.IsDelete = 0
  19469. SELECT @JobView = COUNT(*)
  19470. FROM PaJobViewLog a
  19471. INNER JOIN Job b WITH(NOLOCK) ON a.JobId = b.ID
  19472. INNER JOIN paMain c WITH(NOLOCK) ON c.ID = a.paMainID
  19473. INNER JOIN cvMain d WITH(NOLOCK) ON d.paMainID=c.ID AND d.Valid>0
  19474. WHERE b.caMainID = @caMainID
  19475. END
  19476. SELECT @NoRepliedJobApply = COUNT(*)
  19477. FROM exJobApply a WITH(NOLOCK), Job b WITH(NOLOCK)
  19478. WHERE a.Reply = 0
  19479. And a.CompanyDeleted = 0
  19480. AND a.JobID =b.ID
  19481. AND b.caMainID = @caMainID
  19482. AND b.IsDelete = 0
  19483. SELECT @NoViewedMessage = 0
  19484. SELECT @Message = 0
  19485. SELECT @NoRepliedJobApply AS NoRepliedJobApply, @NoViewedMessage AS NoViewedMessage, @JobApply AS JobApply, @Message AS [Message],@JobView JobView
  19486. END
  19487. GO
  19488. /****** Object: StoredProcedure [dbo].[ccCvMainByExJobApplyIDSelect] Script Date: 2018/12/13 19:06:41 ******/
  19489. SET ANSI_NULLS ON
  19490. GO
  19491. SET QUOTED_IDENTIFIER ON
  19492. GO
  19493. --2016-1-6 nick
  19494. --根据申请ID查询简历ID、姓名
  19495. create PROCEDURE [dbo].[ccCvMainByExJobApplyIDSelect]
  19496. (
  19497. @ExJobApplyID INT
  19498. )
  19499. AS
  19500. BEGIN
  19501. SELECT b.ID,c.Name,d.Name AS JobName
  19502. FROM exjobapply a WITH(NOLOCK),CvMain b WITH(NOLOCK),PaMain c WITH(NOLOCK),Job d WITH(NOLOCK)
  19503. WHERE a.ID = @ExJobApplyID
  19504. AND a.CvMainID = b.ID
  19505. AND b.PaMainID = c.ID
  19506. AND a.JobID = d.ID
  19507. END
  19508. GO
  19509. /****** Object: StoredProcedure [dbo].[ccCvMainBySecondIdAllSelect] Script Date: 2018/12/13 19:06:41 ******/
  19510. SET ANSI_NULLS ON
  19511. GO
  19512. SET QUOTED_IDENTIFIER ON
  19513. GO
  19514. create PROCEDURE [dbo].[ccCvMainBySecondIdAllSelect]
  19515. (
  19516. @SecondID VARCHAR(10)
  19517. )
  19518. AS
  19519. BEGIN
  19520. SELECT *, dbo.GetPaOnlineStatus(paMainID) IsOnline
  19521. FROM cvMain WITH(NOLOCK INDEX(IX_CvMain_SecondId))
  19522. WHERE SecondID = @SecondID
  19523. END
  19524. GO
  19525. /****** Object: StoredProcedure [dbo].[ccCvMainBySecondIdSelect] Script Date: 2018/12/13 19:06:41 ******/
  19526. SET ANSI_NULLS ON
  19527. GO
  19528. SET QUOTED_IDENTIFIER ON
  19529. GO
  19530. create PROCEDURE [dbo].[ccCvMainBySecondIdSelect]
  19531. (
  19532. @SecondId VARCHAR(10)
  19533. )
  19534. AS
  19535. BEGIN
  19536. SELECT Id, paMainId FROM cvMain WITH(NOLOCK) WHERE SecondId = @SecondId
  19537. END
  19538. GO
  19539. /****** Object: StoredProcedure [dbo].[ccCvmainRelatedWorkYearsByIDUpdate] Script Date: 2018/12/13 19:06:41 ******/
  19540. SET ANSI_NULLS ON
  19541. GO
  19542. SET QUOTED_IDENTIFIER ON
  19543. GO
  19544. --#####################################################
  19545. --创建时间:2014.10.31
  19546. --创建人:Nick
  19547. --说明:修改工作时间
  19548. --#####################################################
  19549. CREATE PROCEDURE [dbo].[ccCvmainRelatedWorkYearsByIDUpdate]
  19550. (
  19551. @cvMainID INT,
  19552. @WorkYears INT
  19553. )
  19554. AS
  19555. BEGIN TRY
  19556. UPDATE cvMain
  19557. SET RelatedWorkYears=@WorkYears
  19558. WHERE ID=@cvMainID
  19559. END TRY
  19560. BEGIN CATCH
  19561. RETURN 0
  19562. END CATCH
  19563. GO
  19564. /****** Object: StoredProcedure [dbo].[ccCvMainSelect] Script Date: 2018/12/13 19:06:41 ******/
  19565. SET ANSI_NULLS ON
  19566. GO
  19567. SET QUOTED_IDENTIFIER ON
  19568. GO
  19569. CREATE PROCEDURE [dbo].[ccCvMainSelect]
  19570. @ID INT
  19571. AS
  19572. BEGIN
  19573. SELECT *
  19574. FROM cvMain a WITH(NOLOCK),paMain b WITH(NOLOCK)
  19575. WHERE a.paMainID=b.ID
  19576. AND a.ID=@ID
  19577. END
  19578. GO
  19579. /****** Object: StoredProcedure [dbo].[ccdcFeeByCoinRationSelect] Script Date: 2018/12/13 19:06:42 ******/
  19580. SET ANSI_NULLS ON
  19581. GO
  19582. SET QUOTED_IDENTIFIER ON
  19583. GO
  19584. -- =============================================-- Author: Peter
  19585. -- Create date: 2014-08-20 09:55
  19586. -- Description:
  19587. -- =============================================
  19588. CREATE PROCEDURE [dbo].[ccdcFeeByCoinRationSelect]
  19589. (
  19590. @cpMainID INT,
  19591. @dcFeeDetailID INT
  19592. )
  19593. AS
  19594. BEGIN
  19595. SELECT CoinRation,(SELECT ReMainCoin FROM cpMain WHERE id=@cpMainID) CoinBalance
  19596. FROM dcFee
  19597. WHERE ID=@dcFeeDetailID
  19598. END
  19599. GO
  19600. /****** Object: StoredProcedure [dbo].[ccDcFeeByOrderTypeSelect] Script Date: 2018/12/13 19:06:42 ******/
  19601. SET ANSI_NULLS ON
  19602. GO
  19603. SET QUOTED_IDENTIFIER ON
  19604. GO
  19605. -- =============================================
  19606. -- Author: mice
  19607. -- Create date: 2014-8-21
  19608. -- Description: 返回当前时间内的积分兑换订单
  19609. -- 修改:harry 2015-7-3
  19610. -- 修改: a.NeedPoint >0
  19611. -- =============================================
  19612. CREATE PROCEDURE [dbo].[ccDcFeeByOrderTypeSelect]
  19613. (
  19614. @dcProvinceID INT
  19615. )
  19616. AS
  19617. BEGIN
  19618. CREATE TABLE #PointOrderCount(
  19619. typeID INT,
  19620. typeCount INT )
  19621. DECLARE @VipOrderCount AS INT
  19622. SELECT @VipOrderCount = COUNT(a.id) FROM dcVipDetail a, dcVip b
  19623. WHERE b.id = a.dcVipID AND a.NeedPoint > 0
  19624. AND b.dcProvinceID = @dcProvinceID AND b.startDate < GETDATE()
  19625. AND endDate > GETDATE()
  19626. INSERT INTO #PointOrderCount VALUES(8, @VipOrderCount)
  19627. INSERT INTO #PointOrderCount
  19628. SELECT b.Type AS typeID, COUNT(a.id) AS typeCount
  19629. FROM dcFeeDetail a WITH(NOLOCK), dcFee b WITH(NOLOCK)
  19630. WHERE a.dcFeeID = b.id AND a.NeedPoint >0
  19631. AND b.dcProvinceID = @dcProvinceID AND b.startDate < GETDATE() AND endDate > GETDATE()
  19632. AND b.Type IN (10, 11, 22, 24, 21, 20, 23, 5, 4, 7)
  19633. GROUP BY b.Type
  19634. SELECT * FROM #PointOrderCount
  19635. DROP TABLE #PointOrderCount
  19636. END
  19637. GO
  19638. /****** Object: StoredProcedure [dbo].[ccDcFeeByProvinceIDSelect] Script Date: 2018/12/13 19:06:42 ******/
  19639. SET ANSI_NULLS ON
  19640. GO
  19641. SET QUOTED_IDENTIFIER ON
  19642. GO
  19643. --#####################################################
  19644. --创建时间:2014.11.6
  19645. --创建人:John
  19646. --说明:根据省份获取所有资费
  19647. --#####################################################
  19648. CREATE PROCEDURE [dbo].[ccDcFeeByProvinceIDSelect]
  19649. (
  19650. @ProvinceID INT,
  19651. @BackTestDate VARCHAR(50)
  19652. )
  19653. AS
  19654. set nocount on
  19655. if ISnull(@BackTestDate, '') > ''
  19656. insert proclog select 'ccDcFeeByProvinceIDSelect', @BackTestDate, getdate()
  19657. else
  19658. insert proclog select 'ccDcFeeByProvinceIDSelect2', '', getdate()
  19659. BEGIN
  19660. IF @BackTestDate <> ''
  19661. BEGIN
  19662. SELECT a.type,a.name allname,a.price allprice,a.enddate,a.remark allremark ,b.name,b.price,b.minvalue,b.remark
  19663. FROM DcFee a WITH(NOLOCK), dcFeeDetail b WITH(NOLOCK)
  19664. WHERE a.id = b.dcfeeid
  19665. AND a.dcprovinceid = @ProvinceID
  19666. AND a.StartDate <= @BackTestDate
  19667. AND a.EndDate >= @BackTestDate
  19668. ORDER BY a.type,b.minvalue
  19669. END
  19670. ELSE
  19671. BEGIN
  19672. SELECT a.type,a.name allname,a.price allprice,a.enddate,a.remark allremark ,b.name,b.price,b.minvalue,b.remark
  19673. FROM DcFee a WITH(NOLOCK), dcFeeDetail b WITH(NOLOCK)
  19674. WHERE a.id = b.dcfeeid
  19675. AND a.dcprovinceid = @ProvinceID
  19676. AND GETDATE() BETWEEN a.startdate AND a.enddate
  19677. ORDER BY a.type,b.minvalue
  19678. END
  19679. END
  19680. GO
  19681. /****** Object: StoredProcedure [dbo].[ccdcFeeByStartDateSelect] Script Date: 2018/12/13 19:06:42 ******/
  19682. SET ANSI_NULLS ON
  19683. GO
  19684. SET QUOTED_IDENTIFIER ON
  19685. GO
  19686. CREATE PROCEDURE [dbo].[ccdcFeeByStartDateSelect]
  19687. @dcProvinceID INT,
  19688. @type INT,
  19689. @BackTestDate VARCHAR(20)
  19690. AS
  19691. SET NOCOUNT ON
  19692. INSERT PROCLOG SELECT 'ccdcFeeByStartDateSelect', @BackTestDate, GETDATE()
  19693. BEGIN
  19694. SELECT TOP 1 *
  19695. FROM dcFee WITH(NOLOCK)
  19696. WHERE dcProvinceID = @dcProvinceID
  19697. AND type = @type
  19698. AND StartDate <= @BackTestDate AND EndDate >= @BackTestDate
  19699. END
  19700. GO
  19701. /****** Object: StoredProcedure [dbo].[ccdcFeeDetailByIDSelect] Script Date: 2018/12/13 19:06:43 ******/
  19702. SET ANSI_NULLS ON
  19703. GO
  19704. SET QUOTED_IDENTIFIER ON
  19705. GO
  19706. -- =============================================-- Author: Peter
  19707. -- Create date: 2014-08-20 09:55
  19708. -- Description:
  19709. -- =============================================
  19710. CREATE PROCEDURE [dbo].[ccdcFeeDetailByIDSelect]
  19711. @ID INT
  19712. AS
  19713. BEGIN
  19714. SELECT a.ID,a.dcFeeID,a.Name detailName,a.MinValue,a.MaxValue,a.Price,a.Remark,a.NeedPoint, b.Price PrePrice, b.Name
  19715. FROM dcFeeDetail a WITH(NOLOCK) ,dcFee b WITH(NOLOCK)
  19716. WHERE a.dcFeeID = b.ID AND a.ID = @ID
  19717. END
  19718. GO
  19719. /****** Object: StoredProcedure [dbo].[ccdcFeeDetailByMinValueSelect] Script Date: 2018/12/13 19:06:43 ******/
  19720. SET ANSI_NULLS ON
  19721. GO
  19722. SET QUOTED_IDENTIFIER ON
  19723. GO
  19724. CREATE PROCEDURE [dbo].[ccdcFeeDetailByMinValueSelect]
  19725. @dcProvinceID INT,
  19726. @Type INT
  19727. AS
  19728. BEGIN
  19729. DECLARE @MinValue INT
  19730. SELECT @MinValue = Min(MinValue) FROM dcFee a WITH(NOLOCK), dcFeeDetail b WITH(NOLOCK)
  19731. WHERE a.dcProvinceID = @dcProvinceID
  19732. AND a.Type = @Type
  19733. AND b.dcFeeID = a.ID
  19734. AND a.StartDate <= GETDATE() AND a.EndDate >= GETDATE()
  19735. RETURN @MinValue
  19736. END
  19737. GO
  19738. /****** Object: StoredProcedure [dbo].[ccdcFeeDetailSelect] Script Date: 2018/12/13 19:06:43 ******/
  19739. SET ANSI_NULLS ON
  19740. GO
  19741. SET QUOTED_IDENTIFIER ON
  19742. GO
  19743. CREATE PROCEDURE [dbo].[ccdcFeeDetailSelect]
  19744. @dcFeeID INT
  19745. AS
  19746. BEGIN
  19747. SELECT a.startDate, a.EndDate,a.Price PrePrice, b.*
  19748. FROM dcFee a WITH(NOLOCK), dcFeeDetail b WITH(NOLOCK)
  19749. WHERE b.dcFeeID = @dcFeeID
  19750. AND b.dcFeeID = a.ID
  19751. ORDER BY MinValue
  19752. END
  19753. GO
  19754. /****** Object: StoredProcedure [dbo].[ccdcFeeSelect] Script Date: 2018/12/13 19:06:43 ******/
  19755. SET ANSI_NULLS ON
  19756. GO
  19757. SET QUOTED_IDENTIFIER ON
  19758. GO
  19759. CREATE PROCEDURE [dbo].[ccdcFeeSelect]
  19760. (
  19761. @dcProvinceID INT,
  19762. @type INT
  19763. )
  19764. AS
  19765. SET NOCOUNT ON
  19766. --INSERT PROCLOG SELECT 'ccdcFeeSelect', @TYPE, GETDATE()
  19767. --this proc is valid
  19768. BEGIN
  19769. SELECT TOP 1 *
  19770. FROM dcFee WITH(NOLOCK)
  19771. WHERE dcProvinceID = @dcProvinceID
  19772. AND type = @type
  19773. AND StartDate <=GETDATE() AND EndDate >= GETDATE()
  19774. END
  19775. GO
  19776. /****** Object: StoredProcedure [dbo].[ccDcJobNameSelect] Script Date: 2018/12/13 19:06:43 ******/
  19777. SET ANSI_NULLS ON
  19778. GO
  19779. SET QUOTED_IDENTIFIER ON
  19780. GO
  19781. CREATE PROCEDURE [dbo].[ccDcJobNameSelect]
  19782. (
  19783. @Name NVARCHAR(50)
  19784. )
  19785. AS
  19786. SET NOCOUNT ON
  19787. BEGIN
  19788. IF(@Name = '微信运营')
  19789. BEGIN
  19790. SELECT Id, Description FROM dcJobType WHERE ID = 2313
  19791. RETURN
  19792. END
  19793. IF(@Name = '招标')
  19794. BEGIN
  19795. SELECT Id, Description FROM dcJobType WHERE ID = 1918
  19796. RETURN
  19797. END
  19798. DECLARE @t AS TABLE(ID INT IDENTITY(1, 1), Name NVARCHAR(100), dcJobTypeId VARCHAR(4))
  19799. INSERT @t
  19800. SELECT TOP 3 Name, dcJobTypeId
  19801. FROM dcJobName WITH(NOLOCK)
  19802. WHERE Name = @Name
  19803. AND dcJobTypeId IN(SELECT dcJobTypeID FROM dcJobTypetemplate)
  19804. ORDER BY Cnt DESC
  19805. IF(SELECT COUNT(*) FROM @t) > 0
  19806. BEGIN
  19807. SELECT Id, Description FROM dcJobType WHERE
  19808. ID IN(SELECT dcJobTypeId FROM @t)
  19809. AND ID IN(SELECT dcJobTypeID FROM dcJobTypetemplate WHERE LEN(Responsibility) > 0)
  19810. RETURN
  19811. END
  19812. ELSE
  19813. BEGIN
  19814. INSERT @t
  19815. SELECT TOP 3 Name, dcJobTypeId
  19816. FROM dcJobName WITH(NOLOCK)
  19817. WHERE CHARINDEX(@Name, Name) >0
  19818. AND dcJobTypeId IN(SELECT dcJobTypeID FROM dcJobTypetemplate)
  19819. ORDER BY Cnt DESC
  19820. IF(SELECT COUNT(*) FROM @t) > 0
  19821. BEGIN
  19822. SELECT Id, Description
  19823. FROM dcJobType
  19824. WHERE ID IN(SELECT dcJobTypeId FROM @t)
  19825. AND ID IN(SELECT dcJobTypeID FROM dcJobTypetemplate WHERE LEN(Responsibility) > 0)
  19826. RETURN
  19827. END
  19828. IF NOT EXISTS(SELECT 'X' FROM dcJobType WHERE Description = @Name)
  19829. BEGIN
  19830. INSERT @t
  19831. SELECT TOP 3 Name, dcJobTypeId
  19832. FROM dcJobName WITH(NOLOCK)
  19833. WHERE CHARINDEX(Name, @Name) > 0
  19834. AND dcJobTypeId IN(SELECT dcJobTypeID FROM dcJobTypetemplate)
  19835. ORDER BY Cnt DESC
  19836. SELECT Id, Description
  19837. FROM dcJobType
  19838. WHERE ID IN(SELECT dcJobTypeId FROM @t)
  19839. AND ID IN(SELECT dcJobTypeID FROM dcJobTypetemplate WHERE LEN(Responsibility) > 0)
  19840. END
  19841. ELSE
  19842. SELECT TOP 0 Id, Description FROM dcJobType WHERE ID IN(SELECT dcJobTypeId FROM @t)
  19843. END
  19844. END
  19845. GO
  19846. /****** Object: StoredProcedure [dbo].[ccDcJobNameSelect11] Script Date: 2018/12/13 19:06:44 ******/
  19847. SET ANSI_NULLS ON
  19848. GO
  19849. SET QUOTED_IDENTIFIER ON
  19850. GO
  19851. CREATE PROCEDURE [dbo].[ccDcJobNameSelect11]
  19852. (
  19853. @Name NVARCHAR(50)
  19854. )
  19855. AS
  19856. BEGIN
  19857. DECLARE @t AS TABLE(ID INT IDENTITY(1, 1), Name NVARCHAR(100), dcJobTypeId VARCHAR(4))
  19858. INSERT @t
  19859. SELECT TOP 1 DescrIption, Id FROM dcJobType WITH(NOLOCK) WHERE CHARINDEX(@Name, Description) >0 AND Description NOT LIKE '其他%' ORDER BY ID
  19860. IF(SELECT COUNT(*) FROM @t) > 0
  19861. BEGIN
  19862. SELECT a.Id, a.Description FROM dcJobType a, @t b
  19863. WHERE a.ID = b.dcJobTypeId
  19864. AND a.ID IN(SELECT dcJobTypeID FROM dcJobTypetemplate)
  19865. ORDER BY b.ID
  19866. RETURN
  19867. END
  19868. INSERT @t
  19869. SELECT TOP 3 Name, dcJobTypeId FROM dcJobName WITH(NOLOCK) WHERE Name = @Name AND dcJobTypeId IN(SELECT dcJobTypeID FROM dcJobTypetemplate)
  19870. ORDER BY Cnt DESC
  19871. IF(SELECT COUNT(*) FROM @t) > 0
  19872. BEGIN
  19873. SELECT a.Id, a.Description FROM dcJobType a, @t b
  19874. WHERE a.ID = b.dcJobTypeId
  19875. AND a.ID IN(SELECT dcJobTypeID FROM dcJobTypetemplate)
  19876. ORDER BY b.ID
  19877. RETURN
  19878. END
  19879. INSERT @t
  19880. SELECT TOP 3 Name, dcJobTypeId FROM dcJobName WITH(NOLOCK) WHERE CHARINDEX(@Name, Name) >0 AND dcJobTypeId IN(SELECT dcJobTypeID FROM dcJobTypetemplate)
  19881. ORDER BY Cnt DESC
  19882. IF(SELECT COUNT(*) FROM @t) > 0
  19883. BEGIN
  19884. SELECT a.Id, a.Description FROM dcJobType a, @t b
  19885. WHERE a.ID = b.dcJobTypeId
  19886. AND a.ID IN(SELECT dcJobTypeID FROM dcJobTypetemplate)
  19887. ORDER BY b.ID
  19888. RETURN
  19889. END
  19890. INSERT @t
  19891. SELECT TOP 3 Name, dcJobTypeId FROM dcJobName WITH(NOLOCK) WHERE CHARINDEX(Name, @Name) >0 AND dcJobTypeId IN(SELECT dcJobTypeID FROM dcJobTypetemplate)
  19892. ORDER BY Cnt DESC
  19893. SELECT a.Id, a.Description FROM dcJobType a, @t b
  19894. WHERE a.ID = b.dcJobTypeId
  19895. AND a.ID IN(SELECT dcJobTypeID FROM dcJobTypetemplate)
  19896. ORDER BY b.ID
  19897. END
  19898. GO
  19899. /****** Object: StoredProcedure [dbo].[ccdcPayMethodSelect] Script Date: 2018/12/13 19:06:44 ******/
  19900. SET ANSI_NULLS ON
  19901. GO
  19902. SET QUOTED_IDENTIFIER ON
  19903. GO
  19904. --3201,3204,3205,3206,3209,3212,3213,3215,3217
  19905. CREATE PROCEDURE [dbo].[ccdcPayMethodSelect]
  19906. (
  19907. @dcProvinceID INT
  19908. )
  19909. AS
  19910. BEGIN
  19911. IF @dcProvinceID IN (3201,3204,3205,3206,3209,3212,3213,3215,3217)
  19912. BEGIN
  19913. SELECT b.Name,a.PayMethodID,a.JointNo,
  19914. BankName,Account,Receiver,b.HomePage
  19915. FROM dcPayMethodProvince a WITH(NOLOCK),
  19916. dcPayMethod b WITH(NOLOCK)
  19917. WHERE a.PayMethodID = b.PayMethodID
  19918. AND a.dcProvinceID = @dcProvinceID AND b.FrontShow = 1
  19919. ORDER BY OrderBy
  19920. END
  19921. ELSE IF @dcProvinceID IN(30, 32)
  19922. BEGIN
  19923. SELECT b.Name,a.PayMethodID,a.JointNo,
  19924. BankName,Account,Receiver,b.HomePage
  19925. FROM dcPayMethodProvince a WITH(NOLOCK),
  19926. dcPayMethod b WITH(NOLOCK)
  19927. WHERE a.PayMethodID = b.PayMethodID
  19928. AND a.dcProvinceID = 30 AND b.FrontShow = 1
  19929. ORDER BY OrderBy
  19930. END
  19931. ELSE
  19932. BEGIN
  19933. SELECT b.Name,a.PayMethodID,a.JointNo,
  19934. BankName,Account,Receiver,b.HomePage
  19935. FROM dcPayMethodProvince a WITH(NOLOCK),
  19936. dcPayMethod b WITH(NOLOCK)
  19937. WHERE a.PayMethodID = b.PayMethodID
  19938. AND a.dcProvinceID = 10 AND b.FrontShow = 1
  19939. ORDER BY OrderBy
  19940. END
  19941. END
  19942. GO
  19943. /****** Object: StoredProcedure [dbo].[ccdcVipByCoinRationSelect] Script Date: 2018/12/13 19:06:44 ******/
  19944. SET ANSI_NULLS ON
  19945. GO
  19946. SET QUOTED_IDENTIFIER ON
  19947. GO
  19948. -- =============================================
  19949. -- Author: Peter
  19950. -- Create date: 2014-08-20 09:55
  19951. -- Description:
  19952. -- =============================================
  19953. CREATE PROCEDURE [dbo].[ccdcVipByCoinRationSelect]
  19954. (
  19955. @cpMainID INT,
  19956. @dcFeeDetailID INT
  19957. )
  19958. AS
  19959. BEGIN
  19960. SELECT a.CoinRation,(SELECT RemainCoin FROM cpMain WHERE id=@cpMainID) CoinBalance
  19961. FROM dcVip a, dcVipdetail b
  19962. WHERE b.dcVipID=a.ID AND b.ID=@dcFeeDetailID
  19963. END
  19964. GO
  19965. /****** Object: StoredProcedure [dbo].[ccdcVipByStartDateSelect] Script Date: 2018/12/13 19:06:44 ******/
  19966. SET ANSI_NULLS ON
  19967. GO
  19968. SET QUOTED_IDENTIFIER ON
  19969. GO
  19970. CREATE PROCEDURE [dbo].[ccdcVipByStartDateSelect]
  19971. (
  19972. @dcProvinceID INT,
  19973. @BackTestDate VARCHAR(20)
  19974. )
  19975. AS
  19976. SET NOCOUNT ON
  19977. INSERT ProcLog SELECT 'ccdcVipByStartDateSelect', @BackTestDate, GETDATE()
  19978. BEGIN
  19979. SELECT TOP 1 *
  19980. FROM dcVip WITH(NOLOCK)
  19981. WHERE dcProvinceID = @dcProvinceID
  19982. AND StartDate <= @BackTestDate AND EndDate >= @BackTestDate
  19983. END
  19984. GO
  19985. /****** Object: StoredProcedure [dbo].[ccdcVipDetailByIDSelect] Script Date: 2018/12/13 19:06:44 ******/
  19986. SET ANSI_NULLS ON
  19987. GO
  19988. SET QUOTED_IDENTIFIER ON
  19989. GO
  19990. --修改harry 2017-6-5 增加短信订单
  19991. --修改harry 2017-11-11 增加刷新数订单
  19992. CREATE PROCEDURE [dbo].[ccdcVipDetailByIDSelect]
  19993. (
  19994. @ID INT
  19995. )
  19996. AS
  19997. --INSERT INTO procLog SELECT 'ccDcVipDetailByIDSelect', '', GETDATE()
  19998. SET NOCOUNT ON
  19999. BEGIN
  20000. IF(@Id = 0)
  20001. SELECT * FROM dcVipTryOut
  20002. ELSE
  20003. SELECT a.*, b.PriceJOb, b.PriceUser, b.PriceResume, b.PriceMonth, b.PriceSms,b.priceJobrefreshNumber, b.Name
  20004. FROM dcVipDetail a WITH(NOLOCK), dcVip b WITH(NOLOCK)
  20005. WHERE a.dcVipID = b.ID AND a.ID = @ID
  20006. END
  20007. SET NOCOUNT OFF
  20008. GO
  20009. /****** Object: StoredProcedure [dbo].[ccdcVipDetailPointSelect] Script Date: 2018/12/13 19:06:44 ******/
  20010. SET ANSI_NULLS ON
  20011. GO
  20012. SET QUOTED_IDENTIFIER ON
  20013. GO
  20014. -- =============================================
  20015. -- Author: Mice
  20016. -- Create date: 2014-08-15
  20017. -- Description: 查询可用积分兑换Vip订单信息
  20018. -- =============================================
  20019. CREATE PROCEDURE [dbo].[ccdcVipDetailPointSelect]
  20020. (
  20021. @dcVipID INT
  20022. )
  20023. AS
  20024. BEGIN
  20025. SELECT a.startDate, a.EndDate, b.*
  20026. FROM dcVip a WITH(NOLOCK), dcVipDetail b WITH(NOLOCK)
  20027. WHERE b.dcVipID = @dcVipID
  20028. AND b.dcVipID = a.ID
  20029. AND b.IsShowFront = 1
  20030. AND b.NeedPoint IS NOT NULL
  20031. AND b.NeedPoint <> 0
  20032. ORDER BY [Month] DESC, Price DESC
  20033. END
  20034. GO
  20035. /****** Object: StoredProcedure [dbo].[ccdcVipDetailSelect] Script Date: 2018/12/13 19:06:45 ******/
  20036. SET ANSI_NULLS ON
  20037. GO
  20038. SET QUOTED_IDENTIFIER ON
  20039. GO
  20040. --创建人 lambo
  20041. --功能:前台根据资费计划取资费套餐
  20042. --修改:增加IsShowFront=0的条件,取前台显示的记录 lambo 20131125
  20043. CREATE PROCEDURE [dbo].[ccdcVipDetailSelect]
  20044. (
  20045. @dcVipID INT
  20046. )
  20047. AS
  20048. BEGIN
  20049. SELECT a.startDate, a.EndDate, b.*
  20050. FROM dcVip a WITH(NOLOCK), dcVipDetail b WITH(NOLOCK)
  20051. WHERE b.dcVipID = @dcVipID
  20052. AND b.dcVipID = a.ID
  20053. AND b.IsShowFront=1
  20054. ORDER BY [Month] DESC, Price DESC
  20055. END
  20056. GO
  20057. /****** Object: StoredProcedure [dbo].[ccdcVipSelect] Script Date: 2018/12/13 19:06:45 ******/
  20058. SET ANSI_NULLS ON
  20059. GO
  20060. SET QUOTED_IDENTIFIER ON
  20061. GO
  20062. CREATE PROCEDURE [dbo].[ccdcVipSelect]
  20063. (
  20064. @dcProvinceID INT
  20065. )
  20066. AS
  20067. SET NOCOUNT ON
  20068. --INSERT ProcLog SELECT 'ccdcVipSelect', @dcProvinceID, GETDATE()
  20069. --this proc is valid
  20070. BEGIN
  20071. SELECT TOP 1 *
  20072. FROM dcVip WITH(NOLOCK)
  20073. WHERE dcProvinceID = @dcProvinceID
  20074. AND StartDate <= GETDATE() AND EndDate >= GETDATE()
  20075. END
  20076. GO
  20077. /****** Object: StoredProcedure [dbo].[ccExInterviewBatchDelete] Script Date: 2018/12/13 19:06:45 ******/
  20078. SET ANSI_NULLS ON
  20079. GO
  20080. SET QUOTED_IDENTIFIER ON
  20081. GO
  20082. --Lambo 20101130 修改
  20083. --增加cpMainID参数,判断是否是本企业的
  20084. --Lambo 20110223修改
  20085. --增加时间、是否回复的判断,一个月内,未回复的不能删除
  20086. CREATE PROCEDURE [dbo].[ccExInterviewBatchDelete]
  20087. (
  20088. @AllID VARCHAR(1000),
  20089. @cpMainID INT
  20090. )
  20091. AS
  20092. BEGIN TRAN
  20093. BEGIN TRY
  20094. SET @AllID = dbo.FormatIDS(@AllID)
  20095. DECLARE @T AS TABLE(ID INT)
  20096. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  20097. DELETE FROM ExInterview
  20098. WHERE ID IN(SELECT ID FROM @T)
  20099. AND (Reply <> 0 Or AddDate < GETDATE()-30)
  20100. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  20101. AND PersonDeleted = 1
  20102. UPDATE ExInterview SET CompanyDeleted = 1, CompanyDeleteDate = GETDATE()
  20103. WHERE ID IN(SELECT ID FROM @T)
  20104. AND (Reply <> 0 Or AddDate < GETDATE()-30)
  20105. AND JobID IN (SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainID = @cpMainID)
  20106. END TRY
  20107. BEGIN CATCH
  20108. GOTO ERR
  20109. END CATCH
  20110. COMMIT TRAN
  20111. RETURN 1
  20112. ERR:
  20113. BEGIN
  20114. ROLLBACK TRAN
  20115. RETURN 0
  20116. END
  20117. GO
  20118. /****** Object: StoredProcedure [dbo].[ccExInterviewByCvMainID30DaysSelect] Script Date: 2018/12/13 19:06:45 ******/
  20119. SET ANSI_NULLS ON
  20120. GO
  20121. SET QUOTED_IDENTIFIER ON
  20122. GO
  20123. CREATE PROCEDURE [dbo].[ccExInterviewByCvMainID30DaysSelect]
  20124. @AllID VARCHAR(1000),
  20125. @JobID INT
  20126. AS
  20127. BEGIN
  20128. SET @AllID = dbo.FormatIDS(@AllID)
  20129. DECLARE @T AS TABLE(ID INT)
  20130. INSERT INTO @T SELECT * FROM dbo.fnSplit(@AllID, ',')
  20131. SELECT cvMainID,AddDate FROM exInterview WITH(NOLOCK)
  20132. WHERE JOBID = @JobID
  20133. AND GETDATE()-AddDate < 30
  20134. AND cvMainID IN(SELECT ID FROM @T)
  20135. END
  20136. GO
  20137. /****** Object: StoredProcedure [dbo].[ccExInterViewByCvMainIDSelect] Script Date: 2018/12/13 19:06:45 ******/
  20138. SET ANSI_NULLS ON
  20139. GO
  20140. SET QUOTED_IDENTIFIER ON
  20141. GO
  20142. --#####################################################
  20143. --说明:得到面试通知列表
  20144. --修改:2015-01-15 Andy
  20145. -- 1. 添加dcRegionID列
  20146. -- 2. 去掉try catch
  20147. --#####################################################
  20148. CREATE PROCEDURE [dbo].[ccExInterViewByCvMainIDSelect]
  20149. (
  20150. @caMainID INT,
  20151. @cvMainID INT,
  20152. @cpMainID INT
  20153. )
  20154. AS
  20155. BEGIN
  20156. IF @cpMainID > 0
  20157. BEGIN
  20158. SELECT a.ID, a.JobID, b.dcRegionID, a.cvMainID, a.InterviewDate, a.InterViewPlace, a.LinkMan, a.Telephone,
  20159. a.Remark, a.AddDate, a.Reply, a.ReplyMessage, a.Replydate, a.CompanyDeleted, a.CompanyDeleteDate,
  20160. a.PersonDeleted, a.PersonDeleteDate, a.ViewDate, b.Name AS JobName, b.caMainID
  20161. FROM exInterView a WITH(NOLOCK)
  20162. INNER JOIN Job b WITH(NOLOCK) ON b.ID = a.JobID
  20163. WHERE cvMainID = @cvMainID AND cpMainID = @cpMainID
  20164. END
  20165. IF @cpMainID = 0
  20166. BEGIN
  20167. SELECT a.ID, a.JobID, b.dcRegionID, a.cvMainID, a.InterviewDate, a.InterViewPlace, a.LinkMan, a.Telephone,
  20168. a.Remark, a.AddDate, a.Reply, a.ReplyMessage, a.Replydate, a.CompanyDeleted, a.CompanyDeleteDate,
  20169. a.PersonDeleted, a.PersonDeleteDate, a.ViewDate, b.Name AS JobName, b.caMainID
  20170. FROM exInterView a WITH(NOLOCK)
  20171. INNER JOIN Job b WITH(NOLOCK) ON b.ID = a.JobID
  20172. WHERE cvMainID = @cvMainID AND caMainID=@caMainID
  20173. END
  20174. END
  20175. GO
  20176. /****** Object: StoredProcedure [dbo].[ccExInterviewByIDSelect] Script Date: 2018/12/13 19:06:45 ******/
  20177. SET ANSI_NULLS ON
  20178. GO
  20179. SET QUOTED_IDENTIFIER ON
  20180. GO
  20181. --#####################################################
  20182. --创建时间:2014.10.30
  20183. --创建人:Nick
  20184. --说明://得到面试通知详情
  20185. --#####################################################
  20186. CREATE PROCEDURE [dbo].[ccExInterviewByIDSelect]
  20187. (
  20188. @ID INT
  20189. )
  20190. AS
  20191. BEGIN TRY
  20192. SELECT a.ID,a.Name ,a.Mobile,a.dcSubSiteID,a.IsReceiveSms,d.Name JobName
  20193. FROM paMain a WITH(NOLOCK) ,cvMain b WITH(NOLOCK) ,ExInterview c WITH(NOLOCK) ,Job d WITH(NOLOCK)
  20194. WHERE a.ID = b.paMainID AND b.ID = c.cvMainID AND c.JobID = d.ID AND c.ID =@ID
  20195. END TRY
  20196. BEGIN CATCH
  20197. RETURN 0
  20198. END CATCH
  20199. GO
  20200. /****** Object: StoredProcedure [dbo].[ccexInterviewByIDUpdate] Script Date: 2018/12/13 19:06:46 ******/
  20201. SET ANSI_NULLS ON
  20202. GO
  20203. SET QUOTED_IDENTIFIER ON
  20204. GO
  20205. --#####################################################
  20206. --创建时间:2014.10.30
  20207. --创建人:Nick
  20208. --说明:修改面试通知
  20209. --#####################################################
  20210. CREATE PROCEDURE [dbo].[ccexInterviewByIDUpdate]
  20211. (
  20212. @Result VARCHAR(50),
  20213. @CamainID INT,
  20214. @ID INT
  20215. )
  20216. AS
  20217. BEGIN TRY
  20218. DECLARE @IsManager INT,@CpMainID INT
  20219. SELECT @IsManager = AccountType,@CpMainID = CpMainID
  20220. FROM caMain WITH(NOLOCK)
  20221. WHERE ID = @CamainID
  20222. IF @IsManager = 1
  20223. BEGIN
  20224. UPDATE exInterview
  20225. SET Result=@Result,ResultDate=GETDATE()
  20226. WHERE ID = @ID And JobID IN (SELECT ID From Job WHERE cpMainID = @CpMainID)
  20227. END
  20228. ELSE
  20229. BEGIN
  20230. UPDATE exInterview
  20231. SET Result=@Result,ResultDate=GETDATE()
  20232. WHERE ID = @ID And JobID IN (SELECT ID From Job WHERE caMainID = @CaMainID)
  20233. END
  20234. RETURN 1
  20235. END TRY
  20236. BEGIN CATCH
  20237. RETURN 0
  20238. END CATCH
  20239. GO
  20240. /****** Object: StoredProcedure [dbo].[ccExInterViewByJobIDInsert] Script Date: 2018/12/13 19:06:46 ******/
  20241. SET ANSI_NULLS ON
  20242. GO
  20243. SET QUOTED_IDENTIFIER ON
  20244. GO
  20245. /*#######################################
  20246. ---面试通知
  20247. 2012-10-23 sean
  20248. update msgcount from smsmessagelog
  20249. 2014-08-25 Peter
  20250. 添加积分记录
  20251. ---2015-8-27 Harry
  20252. ---增加将绑定关注微信的,插入到wxsendmessage表中
  20253. ---20160216 Lucifer 添加推送
  20254. #######################################*/
  20255. CREATE PROCEDURE [dbo].[ccExInterViewByJobIDInsert]
  20256. (
  20257. @JobID INT,
  20258. @cpMainID INT,
  20259. @cvMainID INT,
  20260. @InterviewDate VARCHAR(100),
  20261. @InterViewPlace VARCHAR(200),
  20262. @LinkMan VARCHAR(12),
  20263. @Telephone VARCHAR(20),
  20264. @Remark VARCHAR(1000)
  20265. )
  20266. AS
  20267. SET NOCOUNT ON
  20268. BEGIN
  20269. SET NOCOUNT ON
  20270. DECLARE @InterviewPoint INT --直接发送面试通知 赠送积分
  20271. DECLARE @ReplyInterviewPoint INT --答复后 发送面试通知 赠送积分
  20272. SET @InterviewPoint =7
  20273. SET @ReplyInterviewPoint = 10
  20274. DECLARE @caMainID INT, @paMainId INT, @ExInterViewID INT, @wxFansId INT, @MsgCount INT
  20275. SELECT @caMainID = caMainId FROM Job WITH(NOLOCK) WHERE ID = @JobID AND cpMainID = @cpMainID
  20276. IF ISNULL(@caMainID, 0) = 0
  20277. RETURN -1
  20278. SELECT @Remark = dbo.TrimNull(@Remark),
  20279. @InterviewDate = dbo.Trim(@InterviewDate),
  20280. @InterViewPlace = dbo.Trim(@InterViewPlace),
  20281. @Telephone = dbo.Trim(@Telephone)
  20282. INSERT INTO ExInterView(JobID, cvMainID, InterviewDate, InterViewPlace, LinkMan, Telephone, Remark)
  20283. VALUES(@JobID, @cvMainID, @InterviewDate, @InterViewPlace, @LinkMan, @Telephone, @Remark)
  20284. SET @ExInterViewID = @@IDENTITY
  20285. --未答复的修改答复状态
  20286. UPDATE exJobApply SET Reply =1 WHERE JobID = @JobID AND CvMainID = @cvMainID
  20287. BEGIN TRY
  20288. SELECT @paMainId = paMainId FROM cvMain WITH(NOLOCK) WHERE Id = @cvMainId
  20289. SELECT @wxFansId = id FROM wxFans WITH(NOLOCK) WHERE paMainId = @paMainId AND [Status] = 2
  20290. IF @wxFansId IS NULL
  20291. BEGIN
  20292. SELECT @MsgCount = SUM(smsNumber) FROM ExInterView WITH(NOLOCK)
  20293. WHERE JobId IN(SELECT ID FROM Job WITH(NOLOCK) WHERE cpMainId = @cpMainID)
  20294. AND AddDate > CONVERT(VARCHAR(10), GETDATE() - 29, 120)
  20295. IF @MsgCount < 30
  20296. BEGIN
  20297. INSERT SmsMessageLog(SendMan, ManagerUSerId, paMainId, caMainId, Mobile, MsgType, IsCat, Msg)
  20298. SELECT 0, NULL, b.ID, @caMainID, b.Mobile, 101, 0,
  20299. ISNULL(b.Name,'') +','+ d.Name +'在'+ c.SubSiteName + c.EmailSite +'上邀请您面试,请登录网站查看'
  20300. FROM cvMain a WITH(NOLOCK), paMain b WITH(NOLOCK), dcSubSite c WITH(NOLOCK),cpMain d WITH(NOLOCK)
  20301. WHERE a.paMainID = b.ID
  20302. AND b.dcSubSiteID = c.ID
  20303. AND d.ID = @cpMainID
  20304. AND b.Mobile > ''
  20305. AND a.ID = @cvMainID
  20306. AND b.IsReceiveSms = 1
  20307. UPDATE ExInterView SET SmsNumber = ISNULL(SmsNumber, 0) + 1 WHERE ID = @ExInterViewID
  20308. END
  20309. END
  20310. ELSE --关注的用户发送微信消息提醒
  20311. BEGIN
  20312. --插入到wxMessageSend表中
  20313. INSERT WxMessageSend2(Templatetype, WxFansID, PaMainId, MainTableId, CpMainID, CvMainID, JobId, CaMainId, AddDate)
  20314. SELECT 1, @wxFansId, @paMainId, @ExInterViewID, @cpMainId, @cvMainID, @JobId, @caMainID, GETDATE()
  20315. END
  20316. INSERT INTO paPushLog(paMainID, PushMessage, PushType)
  20317. SELECT @paMainId, '亲,收到一份面试通知!', 2 WHERE EXISTS(SELECT 'X' FROM paIOSBind WHERE paMainID = @paMainId)
  20318. END TRY
  20319. BEGIN CATCH
  20320. END CATCH
  20321. --插入积分记录
  20322. BEGIN TRY
  20323. --插入积分记录
  20324. DECLARE @TodayPoint AS INT
  20325. DECLARE @TodayID AS INT
  20326. SET @TodayPoint = 0
  20327. SET @TodayID = 0
  20328. SELECT TOP 1 @TodayPoint = ISNULL(Point,0),
  20329. @TodayID = ISNULL(ID, 0)
  20330. FROM cpPoint WITH(NOLOCK)
  20331. WHERE changeID = 4 AND LastModifyDate > CONVERT(VARCHAR(10), GETDATE(),120)
  20332. AND cpMainID = @cpMainID
  20333. --判断是否是应聘的简历
  20334. -- DECLARE @JobApplyID INT,@Reply INT
  20335. --
  20336. -- SELECT @JobApplyID = 0,@Reply = 0
  20337. -- SELECT @JobApplyID = ID,@Reply = Reply
  20338. -- FROM ExJobApply WITH(NOLOCK)
  20339. -- WHERE JobID = @JobID
  20340. -- AND CvMainID = @cvMainID
  20341. --
  20342. -- IF @JobApplyID = 0 --未应聘
  20343. -- BEGIN
  20344. -- SET @TodayPoint = @ReplyInterviewPoint
  20345. -- END
  20346. -- ELSE
  20347. -- BEGIN
  20348. -- IF @Reply = 0
  20349. -- BEGIN
  20350. -- UPDATE ExJobApply
  20351. -- SET Reply = 1
  20352. -- WHERE ID = @JobApplyID
  20353. --
  20354. -- SET @TodayPoint = @InterviewPoint
  20355. -- END
  20356. -- ELSE
  20357. -- BEGIN
  20358. -- SET @TodayPoint = @ReplyInterviewPoint
  20359. -- END
  20360. -- END
  20361. SET @TodayPoint = @TodayPoint + @ReplyInterviewPoint
  20362. IF @TodayPoint <= 200
  20363. BEGIN
  20364. IF @TodayID = 0
  20365. BEGIN
  20366. INSERT INTO cpPoint (cpMainID,ChangeID,Point,LastModifyDate) VALUES(@cpMainID,4,@TodayPoint,GETDATE())
  20367. END
  20368. ELSE
  20369. BEGIN
  20370. UPDATE cpPoint SET Point = Point + @TodayPoint,LastModifyDate = GETDATE() WHERE ID = @TodayID
  20371. END
  20372. END
  20373. END TRY
  20374. BEGIN CATCH
  20375. END CATCH
  20376. -- RETURN @Return
  20377. RETURN ISNULL(@MsgCount, 0)
  20378. END
  20379. GO
  20380. /****** Object: StoredProcedure [dbo].[ccexInterviewByJobIDSelect] Script Date: 2018/12/13 19:06:46 ******/
  20381. SET ANSI_NULLS ON
  20382. GO
  20383. SET QUOTED_IDENTIFIER ON
  20384. GO
  20385. --#####################################################
  20386. --创建时间:20160104
  20387. --创建人:Nick
  20388. --说明:是否发送过面试通知
  20389. --#####################################################
  20390. create PROCEDURE [dbo].[ccexInterviewByJobIDSelect]
  20391. (
  20392. @JobID INT,
  20393. @CvMainID INT,
  20394. @CaMainID INT
  20395. )
  20396. AS
  20397. SET NOCOUNT ON
  20398. BEGIN
  20399. SELECT TOP 1 a.* FROM exInterview a,Job b
  20400. WHERE JobID = @JobID
  20401. AND CvMainID = @CvMainID
  20402. AND b.CaMainID = @CaMainID
  20403. AND a.JobID = b.ID
  20404. ORDER BY a.ID DESC
  20405. END
  20406. GO