12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071 |
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpMemberCardRechargeRecord') and name='Mcrr_OrderPerson')
- begin
- alter table dbo.tb_ErpMemberCardRechargeRecord add Mcrr_OrderPerson nvarchar(20) NULL
- end
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpMemberCardPayment') and name='Mcpt_PackagePrice')
- begin
- alter table dbo.tb_ErpMemberCardPayment add Mcpt_PackagePrice decimal(18,2) NULL
- end
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpMemberCardPayment') and name='Mcpt_Discount')
- begin
- alter table dbo.tb_ErpMemberCardPayment add Mcpt_Discount decimal(18,2) NULL
- end
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpMemberCardPayment') and name='Mcpt_OrderPerson')
- begin
- alter table dbo.tb_ErpMemberCardPayment add Mcpt_OrderPerson nvarchar(20) NULL
- end
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpMemberCardGradeSet') and name='Mcgs_OpenCardAoumnt')
- begin
- alter table tb_ErpMemberCardGradeSet add Mcgs_OpenCardAoumnt nvarchar(200) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpMemberCardGradeSet', N'COLUMN',N'Mcgs_OpenCardAoumnt'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'新摄会开卡金' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpMemberCardGradeSet', @level2type=N'COLUMN',@level2name=N'Mcgs_OpenCardAoumnt'
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpMemberCardGradeSet') and name='Mcgs_ReturnNeededPoints')
- begin
- alter table tb_ErpMemberCardGradeSet add Mcgs_ReturnNeededPoints nvarchar(200) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpMemberCardGradeSet', N'COLUMN',N'Mcgs_ReturnNeededPoints'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'新摄会返还所需积分' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpMemberCardGradeSet', @level2type=N'COLUMN',@level2name=N'Mcgs_ReturnNeededPoints'
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpMemberCardGradeSet') and name='Mcgs_ReturnAoumnt')
- begin
- alter table tb_ErpMemberCardGradeSet add Mcgs_ReturnAoumnt nvarchar(200) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpMemberCardGradeSet', N'COLUMN',N'Mcgs_ReturnAoumnt'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'新摄会返还金额' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpMemberCardGradeSet', @level2type=N'COLUMN',@level2name=N'Mcgs_ReturnAoumnt'
- GO
- --2015-06-28 更新---
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_DianQingDate')
- begin
- alter table tb_ErpCompanyInfo add Company_DianQingDate nvarchar(200) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpCompanyInfo', N'COLUMN',N'Company_DianQingDate'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'店庆日期' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCompanyInfo', @level2type=N'COLUMN',@level2name=N'Company_DianQingDate'
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpMemberCardPointsRuleSet') and name='Mcprs_Remark')
- begin
- alter table tb_ErpMemberCardPointsRuleSet add Mcprs_Remark nvarchar(200) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpMemberCardPointsRuleSet', N'COLUMN',N'Mcprs_Remark'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpMemberCardPointsRuleSet', @level2type=N'COLUMN',@level2name=N'Mcprs_Remark'
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='订单收款')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'订单收款', N'Jolimark FP-530K+', N'\\MICROSOF-CA157D\Jolimark FP-530K+', N'适用于(针式打印机)', N'0', CAST(N'2015-06-27 09:58:30.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='现金支出')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'现金支出', N'Jolimark FP-530K+', N'\\MICROSOF-CA157D\Jolimark FP-530K+', N'适用于(针式打印机)', N'0', CAST(N'2015-06-27 09:58:30.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='其它收入')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'其它收入', N'Jolimark FP-530K+', N'\\MICROSOF-CA157D\Jolimark FP-530K+', N'适用于(针式打印机)', N'0', CAST(N'2015-06-27 09:58:30.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='财务报表日')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES (N'SSN001', N'财务报表日', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'1', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='财务报表月')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES (N'SSN001', N'财务报表月', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'1', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='财务报表年')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES (N'SSN001', N'财务报表年', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'1', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='拍照明细表')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES (N'SSN001', N'拍照明细表', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='拍照派工单')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'拍照派工单', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='选片明细表')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES (N'SSN001', N'选片明细表', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='看设计明细表')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES (N'SSN001', N'看设计明细表', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='取件明细表')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'取件明细表', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='服务明细')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'服务明细', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='选片缩略图')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'选片缩略图', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'3', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='制作单明细')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'制作单明细', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'3', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='订单打印')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'订单打印', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'4', CAST(N'2015-05-11 15:18:52.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='摄控本总览')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'摄控本总览', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'5', CAST(N'2015-05-09 15:57:16.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='其它二销')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'其它二销', N'Jolimark FP-530K+', N'\\MICROSOF-CA157D\Jolimark FP-530K+', N'适用于(针式打印机)', N'0', CAST(N'2015-06-27 09:58:30.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='会员充值收款')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'会员充值收款', N'Jolimark FP-530K+', N'\\MICROSOF-CA157D\Jolimark FP-530K+', N'适用于(针式打印机)', N'0', CAST(N'2015-06-27 09:58:30.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='礼服出售清单')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'礼服出售清单', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-18 16:11:23.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='礼服出租清单')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'礼服出租清单', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-18 16:11:23.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='库存采购单')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'库存采购单', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-18 16:11:23.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='库存采购申请单')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'库存采购申请单', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-18 16:11:23.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='库存采购验收单')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'库存采购验收单', N'Brother DCP-7060D Printer', N'\\CW01\Brother DCP-7060D Printer', N'适用于(A4纸打印机)', N'2', CAST(N'2015-05-18 16:11:23.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='礼服出租收款')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'礼服出租收款', N'Jolimark FP-530K+', N'\\MICROSOF-CA157D\Jolimark FP-530K+', N'适用于(针式打印机)', N'0', CAST(N'2015-06-27 09:58:30.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='礼服出售收款')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES (N'SSN001', N'礼服出售收款', N'Jolimark FP-530K+', N'\\MICROSOF-CA157D\Jolimark FP-530K+', N'适用于(针式打印机)', N'0', CAST(N'2015-06-27 09:58:30.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='礼服出租退押金')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'礼服出租退押金', N'Jolimark FP-530K+', N'\\MICROSOF-CA157D\Jolimark FP-530K+', N'适用于(针式打印机)', N'0', CAST(N'2015-06-27 09:58:30.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='新摄会收款凭据')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'新摄会收款凭据', N'Jolimark FP-530K+', N'\\MICROSOF-CA157D\Jolimark FP-530K+', N'适用于(针式打印机)', N'0', CAST(N'2015-06-27 09:58:30.000' AS DateTime), N'20141125111443713')
- end
- GO
- if not exists
- (select * from [tb_ErpPrinterSet] where [ps_SingleName]='新摄会返还款凭据')
- begin
- INSERT [dbo].[tb_ErpPrinterSet] ( [ps_DividedShop], [ps_SingleName], [ps_PrinterName], [ps_PrinterPath], [ps_PrintAppliesType], [ps_SingleSort], [ps_UpdateDateTime], [ps_UpdateName]) VALUES ( N'SSN001', N'新摄会返还款凭据', N'Jolimark FP-530K+', N'\\MICROSOF-CA157D\Jolimark FP-530K+', N'适用于(针式打印机)', N'0', CAST(N'2015-06-27 09:58:30.000' AS DateTime), N'20141125111443713')
- end
- GO
- --2015-07-14-更新--
- if (select count(ID) from tb_ErpSystemCategory where Sc_ClassCode = 'AAAAAAI') <= 0
- begin
- insert into tb_ErpSystemCategory(Sc_ClassCode, Sc_ClassName, Sc_ClassParentID, Sc_IsDisable, Sc_IsReadOnly, Sc_URL, Sc_IsDelete, Sc_IsEnabledURL) values('AAAAAAI', '活动套系', '5', 'False', 'False', '', 'True', 'False')
- end
- GO
- if (select count(ID) from tb_ErpSystemCategory where Sc_ClassCode = 'AAAAAAI') >0
- begin
- UPDATE tb_ErpSystemCategory set Sc_ClassName='活动套系', Sc_ClassParentID='5', Sc_IsDisable='False', Sc_IsReadOnly='True', Sc_IsDelete='True' where Sc_ClassCode = 'AAAAAAI'
- end
- GO
- if (select count(ID) from tb_ErpSystemCategory where Sc_ClassCode = 'BFAFBCBADBDCABFDD') <= 0
- begin
- insert into tb_ErpSystemCategory(Sc_ClassCode, Sc_ClassName, Sc_ClassParentID, Sc_IsDisable, Sc_IsReadOnly, Sc_URL, Sc_IsDelete, Sc_IsEnabledURL) values('BFAFBCBADBDCABFDD', '朋友介绍', '25', 'False', 'True', '', 'True', 'False')
- end
- GO
- if (select count(ID) from tb_ErpSystemCategory where Sc_ClassCode = 'BFACBABGBGBJGDHIE') <= 0
- begin
- update tb_ErpSystemCategory set Sc_IsReadOnly = 'true',Sc_IsDelete = 'true' where Sc_ClassCode = 'BFACBABGBGBJGDHIE'
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCustomer') and name='Cus_Type')
- begin
- ALTER TABLE tb_ErpCustomer ALTER COLUMN Cus_Type nvarchar(20) NULL;
- end
- GO
- update tb_ErpPackages set Pak_IntoTheBook = 0 where Pak_IntoTheBook = -1
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_Customer_PaymentOrdersTwo')
- BEGIN
- DROP VIEW [dbo].View_Customer_PaymentOrdersTwo
- END
- GO
- create view View_Customer_PaymentOrdersTwo
- as
- select ID,
- Ord_Number,
- Ord_DividedShop,
- Ord_Type,
- Ord_SeriesName,
- Ord_SeriesPrice,
- Ord_Class,
- Ord_CustomerListID,
- Ord_MainContact,
- (select Cus_Name from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as Ord_CustomerName1,
- (select Cus_Sex from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as Ord_CustomerSex1,
- (select Cus_Telephone from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as Ord_CustomerTelephone1,
- (CASE Ord_Type
- WHEN '0' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- WHEN '1' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- ELSE '' END ) as Ord_CustomerListID2 ,
- (select Cus_Name from tb_ErpCustomer where (CASE Ord_Type
- WHEN '0' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- WHEN '1' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- ELSE '' END )=Cus_CustomerNumber) as Ord_CustomerName2,
- (select Cus_Telephone from tb_ErpCustomer where (CASE Ord_Type
- WHEN '0' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- WHEN '1' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- ELSE '' END )=Cus_CustomerNumber) as Ord_CustomerTelephone2,
- (select stuff((select ','+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('')),1,1,'')) as Ord_OrdersPerson,
- (select [Cus_NamePinyin] from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) AS name1,
- ((select [Cus_NamePinyin] from tb_ErpCustomer where (CASE Ord_Type
- WHEN '0' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- WHEN '1' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- ELSE '' END )=Cus_CustomerNumber)) AS name2,
- (select stuff((select ','+ OrdPe_OrdersPerson from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('')),1,1,'')) as Ord_OrdersPersonID,
- Ord_CreateDatetime
- ,( SELECT count(id) FROM tb_ErpOrderProductList where OPlist_OrderNumber=Ord_Number and OPlist_PickupStatus=0) as PickupStatusCount
- from tb_ErpOrder
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_ErpPieceCommissionRecords')
- BEGIN
- DROP VIEW [dbo].View_ErpPieceCommissionRecords
- END
- GO
- Create view [dbo].[View_ErpPieceCommissionRecords]
- as
- SELECT tb_ErpPieceCommissionRecords.ID
- ,Pcr_OrderNumber
- ,Pcr_DigitalDivision
- ,Pcr_Date
- ,Pcr_CompletionContents
- ,Pcr_Quantity
- ,Pcr_CreateTime
- ,Pcr_EntryPeople
- ,Pcr_Type
- ,(select [User_Name] from tb_ErpUser where Pcr_DigitalDivision=User_EmployeeID) as Pcr_DigitalDivisionName
- ,[dbo].[fn_GetClassCodeToName](Pcr_CompletionContents,Pcr_CompletionContents) as Pcr_CompletionContentsName
- ,(select [User_Name] from tb_ErpUser where Pcr_EntryPeople=User_EmployeeID) as Pcr_EntryPeopleName
- ,Ord_Type
- ,Ord_Class
- ,(select Cus_Name from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as Cus_Name
- ,(select Cus_Telephone from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as Cus_Telephone
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- FROM tb_ErpPieceCommissionRecords
- left join tb_ErpOrder on tb_ErpPieceCommissionRecords.Pcr_OrderNumber=tb_ErpOrder.Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_OrdersWagePaymentRecords')
- BEGIN
- DROP VIEW [dbo].View_OrdersWagePaymentRecords
- END
- GO
- create VIEW [dbo].[View_OrdersWagePaymentRecords]
- AS
- SELECT View_ErpPayment.ID
- ,Pay_OrdNumber
- ,Pay_AmountOf
- ,Pay_OpenSingle
- ,Pay_ThePayee
- ,Pay_PaymentMethod
- ,Pay_OrdersLocation
- ,Pay_ReceivableProject
- ,Pay_CustomNumber
- ,Pay_Remark
- ,convert(varchar(10),Pay_CreateDatetime,120) as Pay_CreateDatetime
- ,Pay_Category
- ,Pay_TwoPinsCategory
- ,Pay_UserName
- ,Pay_ThePayeeName
- ,Pay_PaymentMethodName
- ,Pay_TwoPinsCategoryName
- ,Pay_FinancialAuditdPeople
- ,Pay_FinancialAudit
- ,Pay_FinancialAuditdPeopleName
- ,Pay_ShootingName
- ,Ord_Number
- ,Ord_DividedShop
- ,Ord_Type
- ,Ord_Class
- ,Ord_CustomerName1
- ,Ord_CustomerName2
- ,(select Tsorder_Name from tb_ErpTwoSalesOrder where Pay_OrdNumber= Tsorder_Number) as Tsorder_Name
- ,(select Cus_Name from View_DressSaleRentalOrder where Pay_OrdNumber=Dsro_Number) as Cus_Name
- ,(select Tsorder_CustomerName from View_TwoSalesOrder where Pay_OrdNumber= Tsorder_Number) as Tsorder_CustomerName
- ,Ord_CreateDatetime
- ,(select OrdPe_Type from tb_ErpOrdersPerson where OrdPe_OrderNumber=Pay_OrdNumber and OrdPe_OrdersPerson=Pay_OpenSingle) as OrdPe_Type
- ,Ord_SeriesName
- FROM View_ErpPayment
- left join View_Customer_PaymentOrdersTwo on View_ErpPayment.Pay_OrdNumber=View_Customer_PaymentOrdersTwo.Ord_Number
- GO
- if not exists
- (select * from tb_ErpSystemCategory where sc_className='订单类别' or Sc_ClassCode='BFAGAHBFDGCABAJIH')
- begin
- insert into tb_ErpSystemCategory (Sc_ClassCode,Sc_ClassName,Sc_ClassParentID,Sc_IsDisable,Sc_IsReadOnly,Sc_IsDelete,Sc_IsEnabledURL,Sc_CreateDatetime)
- Values ('BFAGAHBFDGCABAJIH','订单类别','0','0',1,1,'0','2015-06-15 00:00')
- end
- GO
- --创建表
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomerGroup]') AND type in (N'U'))
- begin
- --创建客户组表
- CREATE TABLE [dbo].[tb_ErpCustomerGroup](
- [id] [int] IDENTITY(1,1) NOT NULL,
- --订单号 老客户时订单号为空
- [GP_OrderNumber] [nvarchar](50) not NULL,
- --客户关系组ID编号
- [GP_CustomerGroupID] [nvarchar](50) not NULL,
- --客户组类型 0 为其它客户/订单客户 1 为老客户 2 为意向客户
- [GP_GroupType] [int] not NULL,
- --客户类型 0 为婚纱订单客户 1 为儿童订单客户 2 写真订单客户 3 为服务套系 4 为其它订单客户
- [GP_CustomerType] [int] not NULL,
- --客户状态 正常 意向 溜单 流失
- [GP_CustomerStatus] [nvarchar](50) not NULL,
- --客户流失或溜单原因 少于800 字
- [GP_LossReason] [nvarchar](800) not NULL,
- --意向程度 有点意向 很有意向 非常有意向等
- [GP_DegreeOfIntent] [nvarchar](50) not NULL,
- --客户来源
- [GP_CustomerSource] [nvarchar](50) not NULL,
- --介绍人CustomerID 如果为老客户转介绍来的客户时填写介绍人ID
- [GP_IntroducerCustomerID] [nvarchar](50) NULL,
- --备注说明 少于800 字
- [GP_Remark] [nvarchar](800) NULL,
- --本组客户所属人的ID (隶属于谁的客户) 如果为空时为公共客户
- [GP_BelongsPersonID] [nvarchar](50) NULL,
- --客户添加时间
- [GP_CreateDatetime] [datetime] not NULL,
- --客户修改时间
- [GP_UpdateDatetime] [datetime] not NULL,
- [GP_CreateName] [nvarchar](50) not NULL,
- [GP_UpdateName] [nvarchar](50) not NULL,
- )
- --联合主键
- ALTER TABLE [dbo].[tb_ErpCustomerGroup] ADD CONSTRAINT
- PK_tb_ErpCustomerGroup_OrderNumber_And_CustomerGroupID PRIMARY KEY CLUSTERED
- (
- GP_OrderNumber,
- GP_CustomerGroupID
- )
- --唯一索引
- CREATE UNIQUE NONCLUSTERED INDEX [IX_tb_ErpCustomerGroup_CustomerGroupID] ON [dbo].[tb_ErpCustomerGroup]
- (
- [GP_CustomerGroupID] ASC
- )
- CREATE UNIQUE NONCLUSTERED INDEX [IX_tb_ErpCustomerGroup_OrderNumber] ON [dbo].[tb_ErpCustomerGroup]
- (
- [GP_OrderNumber] ASC
- )
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户组表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'订单号 老客户时订单号为空' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_OrderNumber'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户关系组ID编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_CustomerGroupID'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户组类型 0 为其它客户/订单客户 1 为老客户 2 为意向客户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_GroupType'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户类型 0 为婚纱订单客户 1 为儿童订单客户 2 写真订单客户 3 为服务套系 4 为其它订单客户 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_CustomerType'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户状态 正常 意向 溜单 流失' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_CustomerStatus'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户流失或溜单原因 少于800 字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_LossReason'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'意向程度 有点意向 很有意向 非常有意向等' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_DegreeOfIntent'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户来源' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_CustomerSource'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'介绍人CustomerID 如果为老客户转介绍来的客户时填写介绍人ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_IntroducerCustomerID'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注说明 少于800字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_Remark'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本组客户所属人的ID (隶属于谁的客户) 如果为空时为公共客户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_BelongsPersonID'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_CreateDatetime'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后修改时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroup', @level2type=N'COLUMN',@level2name=N'GP_UpdateDatetime'
- end
- GO
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomerGroupMembers]') AND type in (N'U'))
- begin
- --创建客户组成员表
- CREATE TABLE [dbo].[tb_ErpCustomerGroupMembers](
- [id] [int] IDENTITY(1,1) NOT NULL,
- --客户关系组ID编号
- [GM_CustomerGroupID] [nvarchar](50) not NULL,
- --客户人员表中的客户编号ID
- [GM_CustomerID] [varchar](50) not NULL,
- --是否为主联系人 1 为主联系人
- [GM_Master] [int] not NULL,
- --是否为摄影主角 1 为摄影主角 表示在本次订单中要参与拍摄的客户
- [GM_ProtagonistCustomer] [int] not NULL,
- --相关人ID 儿童版订单客户时为宝贝ID 其它订单客户时为主联系人ID
- [GM_RelatedPersonID] [nvarchar](50) not NULL,
- --与相关人的关系 如 本人、情吕、夫妻、父子、母子、父女、母女、兄弟、姐妹、亲人和朋友等
- [GM_Relation] [nvarchar](50) not NULL,
- --是否已成功下单 1 为已成功下单 0 为下单未成功
- [GM_IsOrder] [int] not NULL,
- --已订单号 如果 IsOrder 为 1 填入订单号
- [GM_IsOrderNumber] [nvarchar](50) NULL,
-
- )
- --联合主键
- ALTER TABLE [dbo].[tb_ErpCustomerGroupMembers] ADD CONSTRAINT
- PK_tb_ErpCustomerGroupMembers_CustomerGroupID_And_CustomerID PRIMARY KEY CLUSTERED
- (
- GM_CustomerGroupID,
- GM_CustomerID
- )
- --索引
- CREATE NONCLUSTERED INDEX [IX_tb_ErpCustomerGroupMembers_GM_CustomerGroupID] ON [dbo].[tb_ErpCustomerGroupMembers]
- (
- [GM_CustomerGroupID] ASC
- )
- CREATE NONCLUSTERED INDEX [IX_tb_ErpCustomerGroupMembers_GM_CustomerID] ON [dbo].[tb_ErpCustomerGroupMembers]
- (
- [GM_CustomerID] ASC
- )
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户组成员表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroupMembers'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户关系组ID编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroupMembers', @level2type=N'COLUMN',@level2name=N'GM_CustomerGroupID'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户人员表中的客户编号ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroupMembers', @level2type=N'COLUMN',@level2name=N'GM_CustomerID'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否为主联系人 1 为主联系人 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroupMembers', @level2type=N'COLUMN',@level2name=N'GM_Master'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否为摄影主角 1 为摄影主角 表示在本次订单中要参与拍摄的客户' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroupMembers', @level2type=N'COLUMN',@level2name=N'GM_ProtagonistCustomer'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'相关人ID 儿童版订单客户时为宝贝ID 其它订单客户时为主联系人ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroupMembers', @level2type=N'COLUMN',@level2name=N'GM_RelatedPersonID'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'与相关人的关系 如 本人、情吕、夫妻、父子、母子、父女、母女、兄弟、姐妹、亲人和朋友等' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroupMembers', @level2type=N'COLUMN',@level2name=N'GM_Relation'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否已成功下单 1 为已成功下单 0 为下单未成功' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroupMembers', @level2type=N'COLUMN',@level2name=N'GM_IsOrder'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'已订单号 如果 IsOrder 为 1 填入订单号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomerGroupMembers', @level2type=N'COLUMN',@level2name=N'GM_IsOrderNumber'
- end
- GO
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomersTrackRecord]') AND type in (N'U'))
- begin
- --创建客户跟踪记录表
- CREATE TABLE [dbo].[tb_ErpCustomersTrackRecord](
- [id] [int] IDENTITY(1,1) NOT NULL,
- --跟踪的客户组ID编号
- [TR_CustomerGroupID] [nvarchar](50) not NULL,
- --本次联系的客户人员表中的客户编号ID
- [TR_CustomerID] [nvarchar](50) not NULL,
- --本次跟踪方式 面谈、坐机电话、手机通话、邮件、短信、QQ、微信、网络留言、其它通信
- [TR_TraceWay] [nvarchar](50) not NULL,
- --本次跟踪类型 流程按排、业务咨询、满意度调查、意向跟踪、溜单追回、关系维护、活动推广
- [TR_TraceType] [nvarchar](50) not NULL,
- --本次沟通具体事项 如:按排拍摄时间、按排选片时间和打结婚纪念日电话等
- [TR_SpecificMatters] [nvarchar](4000) not NULL,
- --本次沟通细节记录 如果客户返馈的信息 短信内容 QQ聊天记录等
- [TR_TraceDetailedly] [nvarchar](max) not NULL,
- --如果是电话(一搬指通过来电精灵通话)沟通的通话录音文件路径
- [TR_CallRecording] [nvarchar](500) not NULL,
- --少于4000字的备注说明 本次跟踪的特殊说明
- [TR_Remark] [nvarchar](4000) NULL,
- --本次跟踪时间(为与客户沟通的开始时间)
- [TR_TraceDateTime] [DateTime] not NULL,
- --本次路踪时长(为与客户沟通所用时间 单位为分钟) 如:15 (分钟)
- [TR_TraceTimeLength] int not null,
- --本次跟踪人员ID(如门市)
- [TR_TracePersonID] [nvarchar](50) not NULL,
- --记录录入时间
- [TR_CreateDateTime] [DateTime] not NULL,
- --记录修改时间
- [TR_UpdateDateTime] [DateTime] not NULL,
- )
- --联合主键
- ALTER TABLE [dbo].[tb_ErpCustomersTrackRecord] ADD CONSTRAINT
- PK_tb_ErpCustomersTrackRecord_CustomerGroupID_And_CustomerID PRIMARY KEY CLUSTERED
- (
- TR_CustomerGroupID,
- TR_CustomerID
- )
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户跟踪记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'客户关系组ID编号' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_CustomerGroupID'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本次联系的客户人员表中的客户编号ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_CustomerID'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本次跟踪方式 面谈、坐机电话、手机通话、邮件、短信、QQ、微信、网络留言、其它通信 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_TraceWay'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本次跟踪类型 流程按排、业务咨询、满意度调查、意向跟踪、溜单追回、关系维护、活动推广' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_TraceType'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本次沟通具体事项 如:按排拍摄时间、按排选片时间和打结婚纪念日电话等' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_SpecificMatters'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本次沟通细节记录 如果客户返馈的信息 短信内容 QQ聊天记录等' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_TraceDetailedly'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'如果是电话(一搬指通过来电精灵通话)沟通的通话录音文件路径' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_CallRecording'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'少于4000字的备注说明 本次跟踪的特殊说明' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_Remark'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本次跟踪时间(为与客户沟通的开始时间)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_TraceDateTime'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本次路踪时长(为与客户沟通所用时间 单位为分钟) 如:15 (分钟)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_TraceTimeLength'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'本次跟踪人员ID(如门市)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_TracePersonID'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'记录录入时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_CreateDateTime'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'记录修改时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpCustomersTrackRecord', @level2type=N'COLUMN',@level2name=N'TR_UpdateDateTime'
- end
- GO
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Fun_ConvertSex]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
- DROP FUNCTION [dbo].[Fun_ConvertSex]
- GO
- CREATE FUNCTION dbo.Fun_ConvertSex(
- @value int --性别值
- )
- /******
- 转换性别
- 创建人:刘超
- 创建日期:2015-6-11 14:10
- 修改人:
- 修改说明:
- 修改日期:
- ******/
- RETURNS nvarchar(10)
- AS
- BEGIN
- DECLARE @ret nvarchar(10)
- SET @ret = '男'
- if @value=0
- SELECT @ret = '男'
- else
- SELECT @ret = '女'
- Return @ret
- END
- GO
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Fun_GetAgeString]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
- DROP FUNCTION [dbo].[Fun_GetAgeString]
- GO
- CREATE FUNCTION dbo.Fun_GetAgeString(
- @Birthday datetime
- )
- /******
- 根据公历生日日期计算返回年龄大小字符串 小于1岁的返回天数
- 创建人:刘超
- 创建日期:2015-6-11 14:10
- 修改人:
- 修改说明:
- 修改日期:
- ******/
- RETURNS nvarchar(100)
- AS
- begin
- declare @ret nvarchar(100)
- declare @age int
- declare @age_day int
- set @age=FLOOR(datediff(day,@Birthday,getdate())/365.25)
- set @age_day=DATEDIFF(day, @Birthday,Getdate())
- if @age < 1
- set @ret =CONVERT(varchar(100), @age_day)+'天'
- else
- set @ret =CONVERT(varchar(100), @age)+'岁'
- return @ret
- end
- GO
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_SMSTemplates]') AND type in (N'U'))
- begin
- --创建短信模板表
- CREATE TABLE [dbo].[tb_SMSTemplates](
- [id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
- --信息发送通道 0 为短信通道发送 1 为微信通道发送
- [ST_SendChannel] int not NULL,
- --短信模板类型 0 为人工短信 1 流程短信 2 事件短信
- [ST_Type] int not NULL,
- --短信模板类别 0 儿童摄影客户 1 为其它摄影客户(如婚纱客户、写真客户、积分和财务短信等)
- [ST_Category] [int] not NULL,
- --短信发送事件
- [ST_SendEvent] [int] not NULL,
- --事件值 如:X分钟的分钟数 或积分 X的积分分值 X天 X岁 X日期/时间
- [ST_SendEventValue] [nvarchar](50) not NULL,
- --短信接收对象 AllC 所有客户 AllE所有员工 或 X手机号(最多500个手机号)
- [ST_ReceiveObjects] [varchar](8000) not NULL,
- --短信模板标题
- [ST_Title] [nvarchar](200) not NULL,
- --短信模板内容 (建义不要超过270个字符长度)
- [ST_SMSContent] [nvarchar](500) not NULL,
- --是否启用模板 0 为禁用 1 为启用
- [ST_IsEnabled] int not NULL,
- --备注说明 少于800 字
- [ST_Remark] [nvarchar](800) NULL,
- --添加时间
- [ST_CreateDatetime] [datetime] not NULL,
- --修改时间
- [ST_UpdateDatetime] [datetime] not NULL
- )
- --索引
- CREATE NONCLUSTERED INDEX [IX_tb_SMSTemplates_SendEvent] ON [dbo].[tb_SMSTemplates]
- (
- [ST_SendEvent] ASC
- )
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信模板表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息发送通道 0 为短信通道发送 1 为微信通道发送' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_SendChannel'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信模板类型 0 为人工短信 1 流程短信 2 事件短信 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_Type'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信模板类别 0 儿童摄影客户 1 为其它摄影客户(如婚纱客户、写真客户、积分和财务短信等)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_Category'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信发送事件' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_SendEvent'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'事件值 如:X分钟的分钟数 或积分 X的积分分值 X天 X岁 X日期/时间 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_SendEventValue'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信接收对象 AllC 所有客户 AllE所有员工 或 X手机号(最多500个手机号)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_ReceiveObjects'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信模板标题' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_Title'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信模板内容 (建义不要超过270个字符长度)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_SMSContent'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否启用模板 0 为禁用 1 为启用 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_IsEnabled'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'备注说明 少于800 字' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_Remark'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'添加时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_CreateDatetime'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'修改时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSTemplates', @level2type=N'COLUMN',@level2name=N'ST_UpdateDatetime'
- end
- GO
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_SMSRecords]') AND type in (N'U'))
- begin
- --创建短信发送记录表
- CREATE TABLE [dbo].[tb_SMSRecords](
- [id] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL,
- --信息发送通道 0 为短信通道发送 1 为微信通道发送
- [SR_SendChannel] int not NULL,
- --短信模板类型 0 为人工短信 1 流程短信 2 事件短信
- [SR_Type] int not NULL,
- --短信发送事件
- [SR_SendEvent] [int] not NULL,
- --短信生成标识 (生成短信记录时的唯一标识) 避免短信成复生成
- [SR_SMSGenerateIdentity] [nvarchar](50) not NULL,
- --短信发送后获取服务器返回的发送短信唯一标识(用于查询短信发送情况) 短信记录在服务器上只保存1个月
- [SR_SMSSendIdentity] [nvarchar](50) not NULL,
- --接收人手机号码,多个时用“,”号分隔
- [SR_RecipientNumber] [nvarchar](4000) not NULL,
- --短信内容 (建义不要超过270个字符长度)
- [SR_Content] [nvarchar](500) not NULL,
- --短信预设开始发送时间
- [SR_StartSendDatetime] [datetime] not NULL,
- --短信发送条数
- [SR_SendSumCount] int not NULL,
- --发送状态 -1 为发送失败 0 为等待发送 1 为发送成功 2 为发送中 3 为超时短信
- [SR_Status] int not NULL,
- --发送日志
- [SR_SendLogs] [nvarchar](max) NULL,
- --发送报告
- [SR_SendReport] [nvarchar](800) NULL,
- --短信生成时间
- [SR_CreateDatetime] [datetime] not NULL,
- --短信发送时间 短信实际发送时间
- [SR_SendDatetime] [datetime] NULL,
- --短信发送人
- [SR_SMSSendSender] [nvarchar](50) not NULL,
- )
- --创建表唯一索引
- CREATE UNIQUE NONCLUSTERED INDEX [IX_tb_SMSRecords_SMSGenerateIdentity] ON [dbo].[tb_SMSRecords]
- (
- [SR_SMSGenerateIdentity] ASC
- )
- --创建表非唯一索引
- CREATE NONCLUSTERED INDEX [IX_tb_SMSRecords_SMSSendIdentity] ON [dbo].[tb_SMSRecords]
- (
- [SR_SMSSendIdentity] ASC
- )
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信发送记录表' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'信息发送通道 0 为短信通道发送 1 为微信通道发送' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_SendChannel'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信模板类型 0 为人工短信 1 流程短信 2 事件短信 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_Type'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信发送事件' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_SendEvent'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信生成标识 (生成短信记录时的唯一标识) 避免短信成复生成 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_SMSGenerateIdentity'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信发送后获取服务器返回的发送短信唯一标识(用于查询短信发送情况) 短信记录在服务器上只保存1个月 ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_SMSSendIdentity'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'接收人手机号码,多个时用“,”号分隔' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_RecipientNumber'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信内容 (建义不要超过270个字符长度)' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_Content'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信预设开始发送时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_StartSendDatetime'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信发送条数' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_SendSumCount'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发送状态 -1 为发送失败 0 为等待发送 1 为发送成功 2 为发送中 3 为超时短信' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_Status'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发送日志' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_SendLogs'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发送报告' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_SendReport'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信生成时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_CreateDatetime'
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'短信发送时间 短信实际发送时间' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_SMSRecords', @level2type=N'COLUMN',@level2name=N'SR_SendDatetime'
- end
- GO
- --创建表结束
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpSmsAccountInfo') and name='Smsa_SumSendCount')
- begin
- alter table tb_ErpSmsAccountInfo add Smsa_SumSendCount int NULL
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_SMSTemplates') and name='ST_IsEnabled')
- begin
- ALTER TABLE tb_SMSTemplates ALTER COLUMN ST_IsEnabled int not null;
- end
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_SMSRecords') and name='SR_SMSSendSender')
- begin
- alter table tb_SMSRecords add SR_SMSSendSender nvarchar(50) NULL
- end
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpPrinterSet') and name='ps_PaperFeed')
- begin
- alter table tb_ErpPrinterSet add ps_PaperFeed nvarchar(2) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpPrinterSet', N'COLUMN',N'ps_PaperFeed'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'打印机进纸方向设置 0:前进纸 1:后进纸' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpPrinterSet', @level2type=N'COLUMN',@level2name=N'ps_PaperFeed'
- GO
- --类别设置中的‘服务’ 改成 ‘服务类别’
- if (select count(ID) from tb_ErpSystemCategory where Sc_ClassCode = 'BEBADABBEEEGAEGFG') > 0
- begin
- update tb_ErpSystemCategory set Sc_ClassName = '服务类别' where Sc_ClassCode = 'BEBADABBEEEGAEGFG'
- end
- GO
- IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tb_SMSRecords]') AND name = N'IX_tb_SMSRecords_SMSSendIdentity')
- DROP INDEX [IX_tb_SMSRecords_SMSSendIdentity] ON [dbo].[tb_SMSRecords] WITH ( ONLINE = OFF )
- GO
- --创建表非唯一索引
- CREATE NONCLUSTERED INDEX [IX_tb_SMSRecords_SMSSendIdentity] ON [dbo].[tb_SMSRecords]
- (
- [SR_SMSSendIdentity] ASC
- )
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_SMSRecords') and name='SR_SMSSendIdentity')
- begin
- ALTER TABLE tb_SMSRecords ALTER COLUMN SR_SMSSendIdentity nvarchar(50) null;
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_SMSRecords') and name='SR_SendDatetime')
- begin
- ALTER TABLE tb_SMSRecords ALTER COLUMN SR_SendDatetime datetime null;
- end
- GO
- --2015-08-13
- truncate table dbo.[tb_ErpPermissionTemplate]
- GO
- SET IDENTITY_INSERT [dbo].[tb_ErpPermissionTemplate] ON
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (1, N'StoresOPenSingle', N'门市开单', N'Print|NewOrder|ModifyOrder|OrderClsssSet|OrderClientRegionSet|OrderClientRelationSet|OrderPackagesNameSet|OrderSightsOrStageSet|OrderClientSourceSet|OrderLoveStyleSet', CAST(0x0000A485011FCE52 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012FB828 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (6, N'StoresPhotograph', N'拍照', N'PhotoImport|PhotoExport|PhotoView|PhotoDelete|PhotographClientAvatarSeeView|PhotographMicroShare|ProcessStatusReset', CAST(0x0000A4860139EC0B AS DateTime), N'20141125111443713', CAST(0x0000A4F1012BD1A9 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (7, N'StoresRepairPiece', N'初修', N'PhotoImport|PhotoExport|PhotoView|PhotoDelete|ProcessStatusReset|RepairPieceSeparatePhoto', CAST(0x0000A486013A17DD AS DateTime), N'20141125111443713', CAST(0x0000A4F1012C1D75 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (8, N'StoresFilmSelection', N'选片', N'PhotoExport|Print|StartFilmSelection|ProcessStatusReset|FilmSelectionCache|FilmSelectionCacheManage', CAST(0x0000A486013A3D95 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012C76C1 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (9, N'StoresRefinedRepair', N'精修', N'PhotoImport|PhotoExport|PhotoView|PhotoDelete|ProcessStatusReset', CAST(0x0000A486013A4984 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012C9F69 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (10, N'StoresDesign', N'设计', N'PhotoImport|PhotoExport|PhotoView|PhotoDelete|LookDesign|ProcessStatusResetDesign|ProcessStatusResetLookDesign', CAST(0x0000A486013A59A3 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012CC262 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (11, N'StoresDigital', N'数码', N'AnPaiWork|SeeAnPaiWork', CAST(0x0000A486013A7B43 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012D540F AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (12, N'OrderReport', N'订单报表', N'Delete|DataExport|OrderIntent', CAST(0x0000A486013AB2DB AS DateTime), N'20141125111443713', CAST(0x0000A4F1012D6DA4 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (13, N'UserCompetence', N'员工设置权限', N'Add|Delete|Update|SeeView', CAST(0x0000A48601619A02 AS DateTime), N'20141125111443713', CAST(0x0000A48601619A01 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (14, N'DressEntry', N'礼服录入', N'Add|Delete|Update|DataExport', CAST(0x0000A4A000B8ED4B AS DateTime), N'20141125111443713', CAST(0x0000A4A500EE5934 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (15, N'DressView', N'礼服查询', N'SeeView', CAST(0x0000A4A000B8FD7F AS DateTime), N'20141125111443713', CAST(0x0000A4A000B8FD7F AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (16, N'DressManagement', N'礼服管理', N'Dress_Preselection|Dress_Rental|Dress_Valet', CAST(0x0000A4A000B90796 AS DateTime), N'20141125111443713', CAST(0x0000A4A000B90796 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (17, N'ProductCompetence', N'商品设置', N'Add|Delete|Update', CAST(0x0000A4A500E86312 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EE68C9 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (18, N'AttractionsCompetence', N'景点/次数设置', N'Add|Delete|Update', CAST(0x0000A4A500E88107 AS DateTime), N'20141125111443713', CAST(0x0000A4A500E91A0B AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (19, N'PackagesGoodsCompetence', N'套系赠送商品设置', N'Add|Delete|Update', CAST(0x0000A4A500E8B482 AS DateTime), N'20141125111443713', CAST(0x0000A4A500E8B482 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (20, N'SupplierCompetence', N'供应商设置', N'Add|Delete|Update', CAST(0x0000A4A500E8E4D9 AS DateTime), N'20141125111443713', CAST(0x0000A4A500E8E4D9 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (21, N'GoodsManufacturersCompetence', N'商品厂商设置', N'Add|Delete|Update', CAST(0x0000A4A500E931A1 AS DateTime), N'20141125111443713', CAST(0x0000A4A500E931A1 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (22, N'WageCompetence', N'工资设置', N'Add|Update', CAST(0x0000A4A500E96348 AS DateTime), N'20141125111443713', CAST(0x0000A4A500E96348 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (23, N'RatingsProportionCompetence', N'工资提成比重设置', N'Add', CAST(0x0000A4A500E984E2 AS DateTime), N'20141125111443713', CAST(0x0000A4A500E984E2 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (24, N'SystemCompetence', N'系统类别设置', N'Add|Delete|Update', CAST(0x0000A4A500E9BE49 AS DateTime), N'20141125111443713', CAST(0x0000A4A500E9BE49 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (25, N'CustomerSatisfactionRecordCompetence', N'客户满意度设置', N'SatisfactionSurvey|SatisfactionSurveySet', CAST(0x0000A4A500E9F63C AS DateTime), N'20141125111443713', CAST(0x0000A4D400C19672 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (26, N'CustomerCallsCompetence', N'客户来电设置', N'Delete', CAST(0x0000A4A500EA2348 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EA2348 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (27, N'OutgoingCallsCompetence', N'拨出电话设置', N'Delete', CAST(0x0000A4A500EA2DB0 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EA2DB0 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (28, N'MissedCallCompetence', N'未接电话设置', N'Delete', CAST(0x0000A4A500EA4466 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EA4466 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (29, N'OrdersCustomerCompetence', N'订单客户设置', N'Update|DataExport', CAST(0x0000A4A500EA6500 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EA70BD AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (30, N'OldCustomerCompetence', N'老客户设置', N'Add|Delete|Update|DataExport|SMSSend', CAST(0x0000A4A500EA8E8F AS DateTime), N'20141125111443713', CAST(0x0000A4A500EA8E8F AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (31, N'IntentionCustomerCompetence', N'意向客户设置', N'Add|Delete|Update|DataExport|SMSSend', CAST(0x0000A4A500EAC4D2 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EAC4D2 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (32, N'StockCompetence', N'库存查询设置', N'Add|Delete|InstockInventory|ProcurementApplication', CAST(0x0000A4A500EB3D52 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EB3D52 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (33, N'ReceiptCompetence', N'入库记录设置', N'Receipt', CAST(0x0000A4A500EB6066 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EB6066 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (34, N'DeliveryCompetence', N'出库记录设置', N'Delivery', CAST(0x0000A4A500EB6EA6 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EB6EA6 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (35, N'PurchasingManagementCompetence', N'采购管理设置', N'PurchasingManagement|AcceptanceManagement', CAST(0x0000A4A500EB8996 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EB8996 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (36, N'FixedAssetManagementCompetence', N'固定资料管理设置', N'Add|Delete|Update', CAST(0x0000A4A500EB9882 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EB9882 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (37, N'ShortSmsMessageCompetence', N'短信群发设置', N'DataExport|SMSSend', CAST(0x0000A4A500EC0D01 AS DateTime), N'20141125111443713', CAST(0x0000A4E601252F28 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (38, N'SmsSendCompetence', N'短信发送设置', N'SMSSend', CAST(0x0000A4A500EC19FB AS DateTime), N'20141125111443713', CAST(0x0000A4A500EC19FB AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (39, N'SMSProcessCompetence', N'流程短信设置', N'SMSSend', CAST(0x0000A4A500EC2909 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EC2909 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (40, N'SMSEmployeesCompetence', N'员工短信设置', N'SMSSend', CAST(0x0000A4A500EC3774 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EC3774 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (41, N'SendRecordsCompetence', N'发送记录', N'Delete|DataExport|SMSResendSend', CAST(0x0000A4A500EC4659 AS DateTime), N'20141125111443713', CAST(0x0000A4E600B790CC AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (42, N'SMSSettingsCompetence', N'短信设置', N'Add|Delete|Update', CAST(0x0000A4A500EC62D0 AS DateTime), N'20141125111443713', CAST(0x0000A4E600B76CE5 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (43, N'DayFinanceCompetence', N'日财务设置', N'DataExport|Print|FinancialAudit|FinancialExpenses', CAST(0x0000A4A500EC9037 AS DateTime), N'20141125111443713', CAST(0x0000A4BA01153D60 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (44, N'MonthFinanceCompetence', N'月财务设置', N'DataExport|Print|FinancialExpenses', CAST(0x0000A4A500EC9DA6 AS DateTime), N'20141125111443713', CAST(0x0000A4BA01154EEB AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (45, N'YearFinanceCompetence', N'年财务设置', N'DataExport|Print|FinancialExpenses', CAST(0x0000A4A500ECA76C AS DateTime), N'20141125111443713', CAST(0x0000A4BA01155CD1 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (46, N'CostingCompetence', N'成本核算设置', N'DataExport', CAST(0x0000A4A500ECB2C8 AS DateTime), N'20141125111443713', CAST(0x0000A4A500ECB2C8 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (47, N'StatisticalInquiryAllWagesCompetence', N'工资管理设置', N'ViewAll', CAST(0x0000A4A500ECC2EA AS DateTime), N'20141125111443713', CAST(0x0000A4F800A354C7 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (48, N'TwoSalesOrderCompetence', N'其它消费设置', N'Add|Delete|Update|SMSSend|OtherConsumerReceivables', CAST(0x0000A4A500ED3D56 AS DateTime), N'20141125111443713', CAST(0x0000A4A500ED3D56 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (49, N'CashExpendituresCompetence', N'现金支出设置', N'Add|Delete|Update|Print|ReportForm', CAST(0x0000A4A500ED6136 AS DateTime), N'20141125111443713', CAST(0x0000A4A500ED6136 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (50, N'OtherIncomeCompetence', N'其它收入设置', N'Add|Delete|Print', CAST(0x0000A4A500ED738F AS DateTime), N'20141125111443713', CAST(0x0000A4A500ED738F AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (51, N'PieceCommissionRecordsCompetence', N'计件提成设置', N'Add|Delete', CAST(0x0000A4A500ED9612 AS DateTime), N'20141125111443713', CAST(0x0000A4A500ED9612 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (52, N'StaffAwardPunishCompetence', N'员工奖罚设置', N'Add|Delete|Update', CAST(0x0000A4A500EDA5E5 AS DateTime), N'20141125111443713', CAST(0x0000A4A500EDA5E5 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (53, N'OrdersReceivablesCompetence', N'订单收款设置', N'Delete|OrdersReceivables|UpdatePaymentTime|OrdersLatePayment|OrdersLatePickGoods|OrderPaymentMethodSet', CAST(0x0000A4A500EDBA19 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012FA04F AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (54, N'BulletinBoardCompetence', N'公告栏', N'Delete|Update|Announcement', CAST(0x0000A4A500EDE073 AS DateTime), N'20141125111443713', CAST(0x0000A4F2009B1A80 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (55, N'StoresPhotosPrints', N'相片冲印', N'Delete|PhotosPrints|OrderSendOut|OrderRework|OrderComplete', CAST(0x0000A4A600B7DAB6 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012CFDBD AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (56, N'StoresTotakePiece', N'发片取件', N'DataExport|TotakePiece|OrderSendOut|OrderRework|OrderComplete|OrderPickup|TotakePieceMonthRework|TotakePieceSentNotBack', CAST(0x0000A4A600B7F555 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012D22CF AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (57, N'MemberManage', N'会员管理', N'Delete|DataImport|DataExport|Print|SMSSend|Member_Recharge|Member_Cash|Member_PointsRedeem|Member_TurnPoints|Member_Logout|Member_ChangingCard|Member_SendPoint|Member_PasswordSet|Member_SendViceCard|Member_OpenCard|Member_CashBackCash|Member_GradeUpdateType|Member_ServiceData|Member_PhotographerOpenCard|Member_PhotographerReturnAmount|Member_PhotographerUseGift|Member_ServiceKoufei|Member_ParameterSet_BaseSet|Member_ParameterSet_PointsSet|Member_ParameterSet_CashBackProportionSet|Member_ParameterSet_RechargeTypeSet|Member_ParameterSet_GradeSet|Member_ParameterSet_ServiceContentSet|Member_ParameterSet_PackageServiceSet|Member_ParameterSet_PhotographerConferenceSet|Member_ViceCardReclaim', CAST(0x0000A4A600B830A7 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012E799C AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (58, N'PhotoStudioInfo', N'本店信息设置', N'Update', CAST(0x0000A4A600EE9711 AS DateTime), N'20141125111443713', CAST(0x0000A4A600EE9711 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (59, N'PrinterSetup', N'打印机设置', N'Update', CAST(0x0000A4A600EEA53A AS DateTime), N'20141125111443713', CAST(0x0000A4A600EEA53A AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (60, N'Attendance', N'考勤管理', N'AttendanceSigning|AttendanceDataManager', CAST(0x0000A4A800DBFAEF AS DateTime), N'20141125111443713', CAST(0x0000A4A800DBFAEF AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (61, N'FinancialExpensesCompetence', N'财务支出设置', N'Add|Delete|Update|Print|ReportForm', CAST(0x0000A4B900E2B3BF AS DateTime), N'20141125111443713', CAST(0x0000A4B900E2B3BF AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (62, N'SystemRightsManagement', N'权限管理', N'AddRole|DelRole|SetUserRole|SetUserExclusiveCompetence', CAST(0x0000A4C000E29B8C AS DateTime), N'20141125111443713', CAST(0x0000A4C000E29B8C AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (63, N'GroupInfo', N'集团信息', N'SeeView', CAST(0x0000A4F1012B3AF1 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012B3AF1 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (64, N'StoresKePan', N'刻盘', N'KePanCD|KePanUDisk', CAST(0x0000A4F1012CD5B4 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012CD5B4 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (65, N'CameraControlBook', N'摄控本', N'Print|SMSSend|CameraControlBook_PhotographClientAnPai|CameraControlBook_FilmsSelectionClientAnPai|CameraControlBook_LookDesignClientAnPai|CameraControlBook_TakePiecesClientAnPai|CameraControlBook_ServiceClientAnPai|CameraControlBook_SelectDressClientAnPai|CameraControlBook_AnPaiQuantitySet|CameraControlBook_SelectDress', CAST(0x0000A4F1012E3227 AS DateTime), N'20141125111443713', CAST(0x0000A4F1012E3227 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (66, N'TasksAssigned', N'任务交办', N'Add|Delete|Update', CAST(0x0000A4F2009B76C5 AS DateTime), N'20141125111443713', CAST(0x0000A4F2009B76C5 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (67, N'MattersApplication', N'事项申请', N'Add|Delete|Update|Audit', CAST(0x0000A4F2009B8CE6 AS DateTime), N'20141125111443713', CAST(0x0000A4F2009B8CE6 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (68, N'CommunicationAide', N'沟通助手', N'Add|Delete|AudioPlayback', CAST(0x0000A4F2009BC74E AS DateTime), N'20141125111443713', CAST(0x0000A4F2009C5810 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (69, N'MyCallCenter', N'通话中心', N'AudioPlayback', CAST(0x0000A4F2009C6884 AS DateTime), N'20141125111443713', CAST(0x0000A4F2009C6884 AS DateTime), N'20141125111443713')
- INSERT [dbo].[tb_ErpPermissionTemplate] ([ID], [Pte_TemplateMark], [Pte_TemplateName], [Pte_PermissionValue], [Pte_CreateDatetime], [Pte_CreateName], [Pte_UpdateDatetime], [Pte_UpdateName]) VALUES (70, N'SatisticalInquiryEmployeesCompetence', N'统计员工资料', N'ViewAll', CAST(0x0000A4F800A5FA3B AS DateTime), N'20141125111443713', CAST(0x0000A4F800A5FA3B AS DateTime), N'20141125111443713')
- SET IDENTITY_INSERT [dbo].[tb_ErpPermissionTemplate] OFF
- GO
- IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomerGroup]') AND name = N'PK_tb_ErpCustomerGroup_OrderNumber_And_CustomerGroupID')
- ALTER TABLE [dbo].[tb_ErpCustomerGroup] DROP CONSTRAINT [PK_tb_ErpCustomerGroup_OrderNumber_And_CustomerGroupID]
- GO
- --设置主键
- IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomerGroup]') AND name = N'PK_tb_ErpCustomerGroup_CustomerGroupID')
- ALTER TABLE [dbo].[tb_ErpCustomerGroup] ADD CONSTRAINT
- PK_tb_ErpCustomerGroup_CustomerGroupID PRIMARY KEY CLUSTERED
- (
- GP_CustomerGroupID
- )
- GO
- IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomerGroup]') AND name = N'IX_tb_ErpCustomerGroup_OrderNumber')
- DROP INDEX [IX_tb_ErpCustomerGroup_OrderNumber] ON [dbo].[tb_ErpCustomerGroup] WITH ( ONLINE = OFF )
- GO
- IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomerGroup]') AND name = N'IX_tb_ErpCustomerGroup_OrderNumber')
- CREATE NONCLUSTERED INDEX [IX_tb_ErpCustomerGroup_OrderNumber] ON [dbo].[tb_ErpCustomerGroup]
- (
- [GP_OrderNumber] ASC
- )
- GO
- IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomer]') AND name = N'IX_tb_ErpOrderNumberRecord_Cus_CustomerNumber')
- CREATE UNIQUE NONCLUSTERED INDEX [IX_tb_ErpOrderNumberRecord_Cus_CustomerNumber] ON [dbo].[tb_ErpCustomer]
- (
- [Cus_CustomerNumber] ASC
- )
- GO
- --打印设置 分辨率名称
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpPrinterSet') and name='ps_ResolutionName')
- begin
- alter table tb_ErpPrinterSet add ps_ResolutionName nvarchar(2) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpPrinterSet', N'COLUMN',N'ps_ResolutionName'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分辨率名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpPrinterSet', @level2type=N'COLUMN',@level2name=N'ps_ResolutionName'
- GO
- --打印设置 分辨率X
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpPrinterSet') and name='ps_ResolutionX')
- begin
- alter table tb_ErpPrinterSet add ps_ResolutionX nvarchar(2) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpPrinterSet', N'COLUMN',N'ps_ResolutionX'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分辨率X' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpPrinterSet', @level2type=N'COLUMN',@level2name=N'ps_ResolutionX'
- GO
- --打印设置 分辨率名称Y
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpPrinterSet') and name='ps_ResolutionY')
- begin
- alter table tb_ErpPrinterSet add ps_ResolutionY nvarchar(2) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpPrinterSet', N'COLUMN',N'ps_ResolutionY'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分辨率名称Y' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpPrinterSet', @level2type=N'COLUMN',@level2name=N'ps_ResolutionY'
- GO
- --打印设置 打印进纸设置
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpPrinterSet') and name='ps_PaperFeed')
- begin
- alter table tb_ErpPrinterSet add ps_PaperFeed nvarchar(2) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpPrinterSet', N'COLUMN',N'ps_PaperFeed'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'打印机进纸方向设置 0:前进纸 1:后进纸' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpPrinterSet', @level2type=N'COLUMN',@level2name=N'ps_PaperFeed'
- GO
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_ConvertDate]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
- DROP FUNCTION [dbo].[fn_ConvertDate]
- GO
- CREATE function [dbo].[fn_ConvertDate](@date datetime)
- /******
- --转换日期如果日小于等于1900-01-01 返回null
- 创建人:刘工
- 创建日期:2015-7-30
- 修改人:
- 修改说明:
- 修改日期:
- ******/
- Returns datetime
- As
- Begin
- Declare @ReturnDate datetime
- if(@date>'1900-01-01')
- set @ReturnDate=@date
- Return @ReturnDate
- End
- GO
- UPDATE [dbo].[tb_ErpProduct] SET [Prod_Number] = Replace([Prod_Number],'*','x') WHERE [Prod_Number] like '%*%'
- GO
- UPDATE [dbo].[tb_ErpProduct] SET [Prod_Number] = Replace([Prod_Number],'?','_') WHERE [Prod_Number] like '%?%'
- GO
- UPDATE [dbo].[tb_ErpProduct] SET [Prod_Number] = Replace([Prod_Number],':','_') WHERE [Prod_Number] like '%:%'
- GO
- UPDATE [dbo].[tb_ErpProduct] SET [Prod_Number] = Replace([Prod_Number],'|','_') WHERE [Prod_Number] like '%|%'
- GO
- UPDATE [dbo].[tb_ErpOrderProductList] SET [OPlist_ProdName] = Replace([OPlist_ProdName],'*','x') WHERE [OPlist_ProdName] like '%*%'
- GO
- UPDATE [dbo].[tb_ErpProduct] SET [Prod_Number] = Replace([Prod_Number],'?','_') WHERE [Prod_Number] like '%?%'
- GO
- UPDATE [dbo].[tb_ErpProduct] SET [Prod_Number] = Replace([Prod_Number],':','_') WHERE [Prod_Number] like '%:%'
- GO
- UPDATE [dbo].[tb_ErpProduct] SET [Prod_Number] = Replace([Prod_Number],'|','_') WHERE [Prod_Number] like '%|%'
- GO
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_ReservationPhotographyTime]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
- DROP FUNCTION [dbo].[fn_ReservationPhotographyTime]
- GO
- CREATE function [dbo].[fn_ReservationPhotographyTime](@CreateDateTime datetime,@ReservationTime datetime, @ordtype char(1))
- /******
- --获取预约拍照时间 如果是成长套系时返回开单时按排的预计拍照时间
- --如果不是成长套系时返回的是开单时间
- 创建人:刘工
- 创建日期:2015-7-30
- 修改人:
- 修改说明:
- 修改日期:
- ******/
- Returns datetime
- As
- Begin
- Declare @ReturnDate datetime
- set @ReturnDate=@CreateDateTime
- if(@ordtype='1' and len(@ReservationTime)>=10)
- set @ReturnDate=@ReservationTime
- Return @ReturnDate
- End
- GO
- --摄影视图 记录拍摄状态 拍摄时间
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[Vw_PhotographyView]'))
- DROP VIEW [dbo].[Vw_PhotographyView]
- GO
- CREATE VIEW [dbo].[Vw_PhotographyView]
- AS
- select
- max(Ordpg_Number) as Ordpg_Number,
- Ordpg_ViceNumber,
- max(Ordpg_PhotographyTime) as Ordpg_PhotographyTime,
- --拍摄状态 0:未拍 Ordpg_PhotographyStatus=Ordpg_PhotographyCount: OK(已拍) 否则:拍照中
- sum(CONVERT(int,Ordpg_PhotographyStatus)) as Ordpg_PhotographyStatus,
- Count(Ordpg_PhotographyStatus) as Ordpg_PhotographyCount
- from tb_ErpOrdersPhotography
- group by Ordpg_ViceNumber
- GO
- --订单商品取件状态视图
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[Vw_OrderProductPickupView]'))
- DROP VIEW [dbo].[Vw_OrderProductPickupView]
- GO
- CREATE VIEW [dbo].[Vw_OrderProductPickupView]
- AS
- select
- max(OPlist_OrderNumber) as OPlist_OrderNumber,
- OPlist_ViceNumber,
- sum(CONVERT(int,[OPlist_PickupStatus])) as OPlist_PickupStatus,
- max(OPlist_PickupTime) as OPlist_PickupTime,
- sum(CONVERT(int,OPlist_CompletedStatus)) as OPlist_CompletedStatus,
- max(OPlist_CompletedTime) as OPlist_CompletedTime,
- count(id) productCount
- from [tb_ErpOrderProductList]
- where OPlist_Type ='2'
- group by OPlist_ViceNumber
- GO
- --订单流程客户 只显示未取件的客户
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[Vw_OrderProcessCustomer]'))
- DROP VIEW [dbo].[Vw_OrderProcessCustomer]
- GO
- CREATE VIEW [dbo].[Vw_OrderProcessCustomer]
- AS
- --订单流程客户 只显示未取件的客户
- SELECT tb_ErpOrder.ID,dbo.tb_ErpOrder.Ord_DividedShop, dbo.tb_ErpOrder.Ord_Number, dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- dbo.tb_ErpOrder.Ord_Class,CONVERT(int,Ord_Type) as Ord_Type, Ord_OrderClass,
- CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- [Age_String] AS 年龄,
- [Age_Day] AS 天,
- [Age_Year] AS 年,
- dbo.tb_ErpOrder.Ord_PhotographyCategory AS 套系类别,
- dbo.tb_ErpOrder.Ord_CustomerSource AS 客户来源,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- (select stuff((select ',' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('')),1,1,'')) as 接单人,
- --dbo.fn_ChineseToSpell((select stuff((select ','+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('')),1,1,''))) as 接单人拼音,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime([dbo].[Vw_PhotographyView].Ordpg_PhotographyTime)) AS 拍摄时间,
- (case when (isnull([dbo].[Vw_PhotographyView].Ordpg_PhotographyStatus,1)) =0 then '未拍'
- else case when (isnull([dbo].[Vw_PhotographyView].Ordpg_PhotographyStatus,1)) = isnull([dbo].[Vw_PhotographyView].Ordpg_PhotographyCount,1) then 'OK' else '拍照中' end end) AS 拍照状态,
- isnull([dbo].[Vw_PhotographyView].Ordpg_PhotographyCount,0) as Ordpg_PhotographyCount,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_EarlyRepairTime)) AS 初修时间,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_FilmSelectionTime)) AS 选片时间,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_DesignerTime)) AS 设计时间,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_RefinementTime)) AS 精修时间,
- dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) AS 精修状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_LookDesignTime)) AS 看设计时间,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- (case when (isnull([dbo].[Vw_OrderProductPickupView].[OPlist_PickupStatus],1)) =0 then '未取'
- else case when (isnull([dbo].[Vw_OrderProductPickupView].[OPlist_PickupStatus],1)) = isnull([dbo].[Vw_OrderProductPickupView].productCount,1) then 'OK' else '部分取件' end end) AS 取件状态,
- isnull([dbo].[Vw_OrderProductPickupView].productCount,0) as productCount,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime([dbo].[Vw_OrderProductPickupView].OPlist_PickupTime)) AS 取件日期,
- (case when (isnull([dbo].[Vw_OrderProductPickupView].OPlist_CompletedStatus,1)) =0 then '未完'
- else case when (isnull([dbo].[Vw_OrderProductPickupView].OPlist_CompletedStatus,1)) = isnull([dbo].[Vw_OrderProductPickupView].productCount,1) then 'OK' else '部分完件' end end) AS 齐件状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime([dbo].[Vw_OrderProductPickupView].OPlist_CompletedTime)) AS 齐件日期,
- dbo.fn_ReservationPhotographyTime(Ord_CreateDateTime,(select top 1 dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationPhotographyTime is not null order by Ordpg_ReservationPhotographyTime DESC),Ord_Type) AS 预约日期
- ,Ord_CreateDateTime
- FROM
- dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join [dbo].[Vw_PhotographyView] on dbo.tb_ErpOrderDigital.Ordv_ViceNumber=[dbo].[Vw_PhotographyView].Ordpg_ViceNumber
- left join [dbo].[Vw_OrderProductPickupView] on dbo.tb_ErpOrderDigital.Ordv_ViceNumber=[dbo].[Vw_OrderProductPickupView].OPlist_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- where CONVERT(int,Ord_Type) < 3 and( isnull([dbo].[Vw_OrderProductPickupView].[OPlist_PickupStatus],1) <> isnull([dbo].[Vw_OrderProductPickupView].productCount,1)
- or isnull([dbo].[Vw_PhotographyView].Ordpg_PhotographyStatus,1) <> isnull([dbo].[Vw_PhotographyView].Ordpg_PhotographyCount,1))
- GO
- --订单流程客户 显示已取件和未取件的所有客户 数据效多查询时较慢
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[Vw_OrderProcessCustomerAll]'))
- DROP VIEW [dbo].[Vw_OrderProcessCustomerAll]
- GO
- CREATE VIEW [dbo].[Vw_OrderProcessCustomerAll]
- AS
- --订单流程客户 显示已取件和未取件的所有客户 数据效多查询时较慢
- SELECT tb_ErpOrder.ID,dbo.tb_ErpOrder.Ord_DividedShop, dbo.tb_ErpOrder.Ord_Number, dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- dbo.tb_ErpOrder.Ord_Class,CONVERT(int,Ord_Type) as Ord_Type, Ord_OrderClass,
- CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- [Age_String] AS 年龄,
- [Age_Day] AS 天,
- [Age_Year] AS 年,
- dbo.tb_ErpOrder.Ord_PhotographyCategory AS 套系类别,
- dbo.tb_ErpOrder.Ord_CustomerSource AS 客户来源,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- (select stuff((select ',' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('')),1,1,'')) as 接单人,
- --dbo.fn_ChineseToSpell((select stuff((select ','+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('')),1,1,''))) as 接单人拼音,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime([dbo].[Vw_PhotographyView].Ordpg_PhotographyTime)) AS 拍摄时间,
- (case when (isnull([dbo].[Vw_PhotographyView].Ordpg_PhotographyStatus,1)) =0 then '未拍'
- else case when (isnull([dbo].[Vw_PhotographyView].Ordpg_PhotographyStatus,1)) = isnull([dbo].[Vw_PhotographyView].Ordpg_PhotographyCount,1) then 'OK' else '拍照中' end end) AS 拍照状态,
- isnull([dbo].[Vw_PhotographyView].Ordpg_PhotographyCount,0) as Ordpg_PhotographyCount,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_EarlyRepairTime)) AS 初修时间,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_FilmSelectionTime)) AS 选片时间,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_DesignerTime)) AS 设计时间,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_RefinementTime)) AS 精修时间,
- dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) AS 精修状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_LookDesignTime)) AS 看设计时间,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- (case when (isnull([dbo].[Vw_OrderProductPickupView].[OPlist_PickupStatus],1)) =0 then '未取'
- else case when (isnull([dbo].[Vw_OrderProductPickupView].[OPlist_PickupStatus],1)) = isnull([dbo].[Vw_OrderProductPickupView].productCount,1) then 'OK' else '部分取件' end end) AS 取件状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime([dbo].[Vw_OrderProductPickupView].OPlist_PickupTime)) AS 取件日期,
- isnull([dbo].[Vw_OrderProductPickupView].productCount,0) as productCount,
- (case when (isnull([dbo].[Vw_OrderProductPickupView].OPlist_CompletedStatus,1)) =0 then '未完'
- else case when (isnull([dbo].[Vw_OrderProductPickupView].OPlist_CompletedStatus,1)) = isnull([dbo].[Vw_OrderProductPickupView].productCount,1) then 'OK' else '部分完件' end end) AS 齐件状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime([dbo].[Vw_OrderProductPickupView].OPlist_CompletedTime)) AS 齐件日期,
- dbo.fn_ReservationPhotographyTime(Ord_CreateDateTime,(select top 1 dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationPhotographyTime is not null order by Ordpg_ReservationPhotographyTime DESC),Ord_Type) AS 预约日期
- ,Ord_CreateDateTime
- FROM
- dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join [dbo].[Vw_PhotographyView] on dbo.tb_ErpOrderDigital.Ordv_ViceNumber=[dbo].[Vw_PhotographyView].Ordpg_ViceNumber
- left join [dbo].[Vw_OrderProductPickupView] on dbo.tb_ErpOrderDigital.Ordv_ViceNumber=[dbo].[Vw_OrderProductPickupView].OPlist_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- where CONVERT(int,Ord_Type) < 3
- GO
- --查询员工生日视图
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[Vw_MemorialDayEmployeeList]'))
- DROP VIEW [dbo].[Vw_MemorialDayEmployeeList]
- GO
- CREATE VIEW [Vw_MemorialDayEmployeeList]
- AS
- SELECT [ID]
- ,[User_Name]
- ,[User_Sex]
- ,[User_Telephone]
- ,User_DateOfBirth
- ,dbo.Fun_GetGregorianCalendarNowYearBirthday([User_DateOfBirth],[User_BirthdayLunar]) as GregorianCalendar_NowYearBirthday
- FROM [dbo].[tb_ErpUser]
- where User_Status='在职'
- and len(User_DateOfBirth)>=10
- and len(User_DateOfBirth)>=10
- and len(User_Telephone)>=11
- GO
- IF EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomersTrackRecord]') AND name = N'PK_tb_ErpCustomersTrackRecord_CustomerGroupID_And_CustomerID')
- ALTER TABLE [dbo].[tb_ErpCustomersTrackRecord] DROP CONSTRAINT [PK_tb_ErpCustomersTrackRecord_CustomerGroupID_And_CustomerID]
- GO
- --设置主键
- IF not EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomersTrackRecord]') AND name = N'PK_tb_ErpCustomersTrackRecord_id')
- begin
- ALTER TABLE [dbo].[tb_ErpCustomersTrackRecord] ADD CONSTRAINT
- PK_tb_ErpCustomersTrackRecord_id PRIMARY KEY CLUSTERED
- (
- id
- )
- end
- GO
- --索引
- IF not EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomersTrackRecord]') AND name = N'IX_tb_ErpCustomersTrackRecord_CustomerGroupID')
- begin
- CREATE NONCLUSTERED INDEX [IX_tb_ErpCustomersTrackRecord_CustomerGroupID] ON [dbo].[tb_ErpCustomersTrackRecord]
- (
- [TR_CustomerGroupID] ASC
- )
- end
- GO
- --索引
- IF not EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomersTrackRecord]') AND name = N'IX_tb_ErpCustomersTrackRecord_CustomerID')
- begin
- CREATE NONCLUSTERED INDEX [IX_tb_ErpCustomersTrackRecord_CustomerID] ON [dbo].[tb_ErpCustomersTrackRecord]
- (
- [TR_CustomerID] ASC
- )
- end
- GO
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Fun_GetGregorianCalendarNowYearBirthday]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
- DROP FUNCTION [dbo].[Fun_GetGregorianCalendarNowYearBirthday]
- GO
- CREATE FUNCTION [dbo].[Fun_GetGregorianCalendarNowYearBirthday](
- @Birthday varchar(100),
- @BirthdayLunar nvarchar(10)--, --是否为农历日期 0 为公历直接原日期返回 1 为农历将转为公历日期 2 为农历闰月将转为对闰月对应的公历日期
- )
- /******
- 根据生日获取当前年的公历生日日期
- 创建人:刘超
- 创建日期:2015-6-11 14:10
- 修改人:
- 修改说明:
- 修改日期:
- ******/
- RETURNS datetime
- AS
- begin
- declare @retdates datetime
- declare @isLeapMonth bit
- set @isLeapMonth=0
- declare @month varchar(3)
- declare @day varchar(3)
- declare @now datetime
- if CONVERT(int, left(@Birthday,4))>1900
- begin
- if len(@Birthday)>=8
- begin
- set @month=Month(Replace(Replace(@Birthday,'-29','-28'),'-30','-28'))
- set @day =Replace(Right(@Birthday,2),'-','')
- set @now=Getdate()
-
- if @BirthdayLunar='2'
- set @isLeapMonth=1
-
- if @BirthdayLunar='0'
- set @retdates=CONVERT(varchar(100),YEAR(@now))+'-'+@month+'-'+@day
- else
- set @retdates= dbo.GetCalender(@month,@day,@now,@isLeapMonth)
- end
- end
- return CONVERT(varchar(100), @retdates, 20)
- end
- GO
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Fun_GetGregorianCalendar]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
- DROP FUNCTION [dbo].[Fun_GetGregorianCalendar]
- GO
- CREATE FUNCTION [dbo].[Fun_GetGregorianCalendar](
- @Birthday varchar(100),
- @BirthdayLunar nvarchar(10)--, --是否为农历日期 0 为公历直接原日期返回 1 为农历将转为公历日期 2 为农历闰月将转为对闰月对应的公历日期
- )
- /******
- 转农历为公历 获取公历生日日期
- 创建人:刘超
- 创建日期:2015-6-11 14:10
- 修改人:
- 修改说明:
- 修改日期:
- ******/
- RETURNS datetime
- AS
- begin
-
- declare @retdates datetime
- declare @isLeapMonth bit
- if CONVERT(int, left(@Birthday,4))>1900
- begin
- if len(@Birthday)>=8
- begin
- set @isLeapMonth=0
- if @BirthdayLunar='2'
- set @isLeapMonth=1
- if @BirthdayLunar='0'
- set @retdates=@Birthday
- else
- set @retdates= dbo.GetCalender(Month(Replace(Replace(@Birthday,'-29','-28'),'-30','-28')),Replace(Right(@Birthday,2),'-',''),Left(@Birthday,4),@isLeapMonth)
- end
- end
- return CONVERT(varchar(100), @retdates, 20)
- end
- GO
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_Version]') AND type in (N'U'))
- begin
- --软件版本表
- CREATE TABLE [dbo].[tb_Version](
- [id] [int] IDENTITY(1,1) NOT NULL,
- --版本号
- [TV_Version] [nvarchar](50) not NULL,
- --控制命
- [TV_ControlCommand] [nvarchar](50) NULL,
- [TV_ValidDateRun] [datetime] NULL,
- [TV_CreateDatetime] [datetime] not NULL,
- [TV_UpdateDatetime] [datetime] not NULL,
- )
- end
- GO
- --在选片日志表中添加选片信息字段
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpOrderProductLOG') and name='Ordplg_SelectionFilmInfo')
- begin
- alter table tb_ErpOrderProductLOG add [Ordplg_SelectionFilmInfo] nvarchar(max) NULL
- end
- GO
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[View_UserInfo]'))
- DROP VIEW [dbo].[View_UserInfo]
- GO
- CREATE VIEW [dbo].[View_UserInfo]
- AS
- SELECT
- User_Account as Account,
- User_Password as PWD,
- User_EmployeeID AS UserID,
- [User_Name] AS UserName,
- User_Status as dimission,
- User_Sex AS Sex,
- User_FirstFingerprintID AS loginnoID1,
- User_SecondaryFingerprintID AS loginnoID2,
- 0 as [level]
- FROM dbo.tb_ErpUser
- GO
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PROCE_UpdateAggregationCustomerAll]') AND type in (N'P', N'PC'))
- DROP PROCEDURE [dbo].[PROCE_UpdateAggregationCustomerAll]
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: 刘超
- -- Create date: 2015-08-09
- -- Description: 更新聚合客户表中所有客户
- -- =============================================
- CREATE PROCEDURE [dbo].[PROCE_UpdateAggregationCustomerAll]
- (
- @ReturnI int output --返回更新记录数
- )
- AS
- BEGIN
- truncate table [dbo].[tempTB_AggregationCustomer]
- insert into [tempTB_AggregationCustomer] select * from [Vw_AggregationCustomer]
- truncate table [dbo].[tempTB_GroupByAggregationCustomer]
- insert into [tempTB_GroupByAggregationCustomer] select * from [Vw_GroupByAggregationCustomer]
- set @ReturnI=(select count(*) from [tempTB_AggregationCustomer])
- -----
- END
- GO
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpCustomersTrackRecord]') AND type in (N'U'))
- DROP TABLE [dbo].[tb_ErpCustomersTrackRecord]
- GO
- --------2015-08-13--更新----
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vwp_GetLastClientTrackRecord')
- BEGIN
- DROP VIEW [dbo].Vwp_GetLastClientTrackRecord
- END
- GO
- CREATE TABLE [dbo].[tb_ErpCustomersTrackRecord](
- [id] [int] IDENTITY(1,1) NOT NULL,
- [TR_CustomerGroupID] [nvarchar](50) NULL,
- [TR_CustomerID] [nvarchar](50) NULL,
- [TR_TraceWay] [nvarchar](50) NULL,
- [TR_TraceType] [nvarchar](50) NULL,
- [TR_SpecificMatters] [nvarchar](4000) NULL,
- [TR_Communicationstatus] [nvarchar](50) NULL,
- [TR_TraceDetailedly] [nvarchar](max) NULL,
- [TR_CallRecording] [nvarchar](500) NULL,
- [TR_Remark] [nvarchar](4000) NULL,
- [TR_TraceDateTime] [datetime] NULL,
- [TR_TraceTimeLength] [int] NULL,
- [TR_TracePersonID] [nvarchar](50) NULL,
- [TR_CreateDateTime] [datetime] NULL,
- [TR_UpdateDateName] [nvarchar](50) NULL,
- CONSTRAINT [PK_tb_ErpCustomersTrackRecord_id] PRIMARY KEY CLUSTERED
- (
- [id] ASC
- )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
- ) ON [PRIMARY]
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[Vwp_GetLastClientTrackRecord]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[Vwp_GetLastClientTrackRecord]
- AS
- SELECT id, TR_CustomerGroupID, TR_CustomerID, TR_TraceWay, TR_TraceType, TR_SpecificMatters,
- TR_Communicationstatus, TR_TraceDetailedly, TR_CallRecording, TR_Remark, TR_TraceDateTime,
- TR_TraceTimeLength, TR_TracePersonID, TR_CreateDateTime, TR_UpdateDateName
- FROM dbo.tb_ErpCustomersTrackRecord
- WHERE (id IN
- (SELECT MAX(id) AS Expr1
- FROM dbo.tb_ErpCustomersTrackRecord AS tb_ErpCustomersTrackRecord_1
- GROUP BY TR_CustomerGroupID))
- '
- GO
- -------------------2015-08-04------------------------
- if (select count(ID) from tb_ErpSystemCategory where Sc_ClassCode = 'AAAAAAJ') <= 0
- begin
- insert into tb_ErpSystemCategory(Sc_ClassCode, Sc_ClassName, Sc_ClassParentID, Sc_IsDisable, Sc_IsReadOnly, Sc_URL, Sc_IsDelete, Sc_IsEnabledURL) values('AAAAAAJ', '沟通情况', '0', 'False', 'True', '', 'True', 'False')
- end
- --添加函数(客户意向类型)
- if exists(select 1 from sysobjects where id=object_id('fn_CheckClientIntentType') and objectproperty(id,'IsInlineFunction')=0)
- begin
- drop function fn_CheckClientIntentType
- end
- GO
- IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_CheckClientIntentType]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
- BEGIN
- execute dbo.sp_executesql @statement = N'--客户意向类型
- CREATE function [dbo].[fn_CheckClientIntentType](@FID varchar(800))
- /******
- 分类字符转换
- 创建人:滕工
- 创建日期:2014-6-23 14:55:29
- 修改人:
- 修改说明:
- 修改日期:
- ******/
- Returns varchar(800)
- As
- Begin
- Declare @ReturnName varchar(1000)
- set @ReturnName = ''''
- if @FID = ''0''
- begin
- set @ReturnName = ''婚纱意向''
- end
- else if @FID = ''1''
- begin
- set @ReturnName = ''儿童意向''
- end
- else if @FID = ''2''
- begin
- set @ReturnName = ''写真意向''
- end
- else if @FID = ''3''
- begin
- set @ReturnName = ''服务意向''
- end
- else if @FID = ''4''
- begin
- set @ReturnName = ''其他意向''
- end
- Return @ReturnName
- End
- '
- END
- GO
- -------------------2015-07-28------------------------
- --影楼字段长度
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_ReservationExplanation')
- begin
- ALTER TABLE tb_ErpCompanyInfo ALTER COLUMN Company_ReservationExplanation nvarchar(2000)
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_SingleExplanation')
- begin
- ALTER TABLE tb_ErpCompanyInfo ALTER COLUMN Company_SingleExplanation nvarchar(2000)
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_SingleTitle')
- begin
- ALTER TABLE tb_ErpCompanyInfo ALTER COLUMN Company_SingleTitle nvarchar(500)
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_ProductionNotes')
- begin
- ALTER TABLE tb_ErpCompanyInfo ALTER COLUMN Company_ProductionNotes nvarchar(2000)
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_DressDescription')
- begin
- ALTER TABLE tb_ErpCompanyInfo ALTER COLUMN Company_DressDescription nvarchar(2000)
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_About')
- begin
- ALTER TABLE tb_ErpCompanyInfo ALTER COLUMN Company_About nvarchar(2000)
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_PhotoThumbnail')
- begin
- ALTER TABLE tb_ErpCompanyInfo ALTER COLUMN Company_PhotoThumbnail nvarchar(2000)
- end
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_PhotoAlbum')
- begin
- ALTER TABLE tb_ErpCompanyInfo ALTER COLUMN Company_PhotoAlbum nvarchar(2000)
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_URL')
- begin
- ALTER TABLE tb_ErpCompanyInfo ALTER COLUMN Company_URL nvarchar(200)
- end
- GO
- if exists
- (select * from syscolumns where id=object_id('tb_ErpCompanyInfo') and name='Company_Address')
- begin
- ALTER TABLE tb_ErpCompanyInfo ALTER COLUMN Company_Address nvarchar(200)
- end
- GO
- -------------------2015-07-28------------------------
- --打印设置 分辨率名称
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpPrinterSet') and name='ps_ResolutionName')
- begin
- alter table tb_ErpPrinterSet add ps_ResolutionName nvarchar(2) NULL
- end
- GO
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpPrinterSet', N'COLUMN',N'ps_ResolutionName'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分辨率名称' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpPrinterSet', @level2type=N'COLUMN',@level2name=N'ps_ResolutionName'
- GO
- --打印设置 分辨率X
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpPrinterSet') and name='ps_ResolutionX')
- begin
- alter table tb_ErpPrinterSet add ps_ResolutionX nvarchar(2) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpPrinterSet', N'COLUMN',N'ps_ResolutionX'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分辨率X' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpPrinterSet', @level2type=N'COLUMN',@level2name=N'ps_ResolutionX'
- GO
- --打印设置 分辨率名称Y
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpPrinterSet') and name='ps_ResolutionY')
- begin
- alter table tb_ErpPrinterSet add ps_ResolutionY nvarchar(2) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpPrinterSet', N'COLUMN',N'ps_ResolutionY'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'分辨率名称Y' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpPrinterSet', @level2type=N'COLUMN',@level2name=N'ps_ResolutionY'
- GO
- -------------------2015-07-23------------------------
- --打印设置 打印进纸设置
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpPrinterSet') and name='ps_PaperFeed')
- begin
- alter table tb_ErpPrinterSet add ps_PaperFeed nvarchar(2) NULL
- end
- IF NOT EXISTS (SELECT * FROM ::fn_listextendedproperty(N'MS_Description' , N'SCHEMA',N'dbo', N'TABLE',N'tb_ErpPrinterSet', N'COLUMN',N'ps_PaperFeed'))
- EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'打印机进纸方向设置 0:前进纸 1:后进纸' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_ErpPrinterSet', @level2type=N'COLUMN',@level2name=N'ps_PaperFeed'
- GO
- --类别设置中的‘服务’ 改成 ‘服务类别’
- if (select count(ID) from tb_ErpSystemCategory where Sc_ClassCode = 'BEBADABBEEEGAEGFG') > 0
- begin
- update tb_ErpSystemCategory set Sc_ClassName = '服务类别' where Sc_ClassCode = 'BEBADABBEEEGAEGFG'
- end
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MemberCard')
- BEGIN
- DROP VIEW [dbo].BView_MemberCard
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MemberCard]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_MemberCard]
- AS
- SELECT
- dbo.tb_ErpCustomer.ID AS Cus_ID,
- dbo.tb_ErpCustomer.Cus_CustomerNumber,
- dbo.tb_ErpCustomer.Cus_Type,
- dbo.tb_ErpCustomer.Cus_Name,
- dbo.tb_ErpCustomer.Cus_Sex,
- dbo.tb_ErpCustomer.Cus_Birthday,
- dbo.tb_ErpCustomer.Cus_BirthdayLunar,
- dbo.tb_ErpCustomer.Cus_Relations,
- dbo.tb_ErpCustomer.Cus_QQ,
- dbo.tb_ErpCustomer.Cus_MicroSignal,
- dbo.tb_ErpCustomer.Cus_Telephone,
- dbo.tb_ErpCustomer.Cus_FixedPhone,
- dbo.tb_ErpCustomer.Cus_Region,
- dbo.tb_ErpCustomer.Cus_Address,
- dbo.tb_ErpCustomer.Cus_WorkUnit,
- dbo.tb_ErpCustomer.Cus_BabyWeight,
- dbo.tb_ErpCustomer.Cus_BornHospital,
- dbo.tb_ErpCustomer.Cus_Zodiac,
- dbo.tb_ErpCustomer.Cus_DayForMarriage,
- dbo.tb_ErpCustomer.Cus_DayForMarriageLunar,
- dbo.tb_ErpCustomer.Cus_CustomerSource,
- dbo.tb_ErpCustomer.Cus_Status,
- dbo.tb_ErpCustomer.Cus_LossReason,
- dbo.tb_ErpCustomer.Cus_ServiceType,
- dbo.tb_ErpCustomer.Cus_Remark,
- dbo.tb_ErpCustomer.Cus_CreateName,
- dbo.tb_ErpCustomer.Cus_CreateDateTime,
- dbo.tb_ErpCustomer.Cus_UpdateName,
- dbo.tb_ErpCustomer.Cus_UpdateDateTime,
- dbo.tb_ErpCustomer.Cus_CustomizeNumber,
- dbo.tb_ErpCustomer.Cus_DegreeOfIntent,
- dbo.tb_ErpMemberCard.ID,
- dbo.tb_ErpMemberCard.Mc_Number,
- dbo.tb_ErpMemberCard.Mc_CradNumber,
- dbo.tb_ErpMemberCard.Mc_CustomerNumber,
- dbo.tb_ErpMemberCard.Mc_CardType,
- dbo.tb_ErpMemberCard.Mc_Money,
- dbo.tb_ErpMemberCard.Mc_TraderPassword,
- dbo.tb_ErpMemberCard.Mc_UsedNumber,
- dbo.tb_ErpMemberCard.Mc_Status,
- dbo.tb_ErpMemberCard.Mc_Remark,
- dbo.tb_ErpMemberCard.Mc_CreateDatetime,
- dbo.tb_ErpMemberCard.Mc_CreateName,
- dbo.tb_ErpMemberCard.Mc_UpdateDateTime,
- dbo.tb_ErpMemberCard.Mc_UpdateName
- FROM dbo.tb_ErpCustomer RIGHT OUTER JOIN
- dbo.tb_ErpMemberCard ON dbo.tb_ErpCustomer.Cus_CustomerNumber = dbo.tb_ErpMemberCard.Mc_CustomerNumber
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MemberMain_GoldMember')
- BEGIN
- DROP VIEW [dbo].BView_MemberMain_GoldMember
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MemberMain_GoldMember]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_MemberMain_GoldMember]
- AS
- SELECT Cus_ID, ID AS Mc_ID,
- Mc_Status,
- Mc_Number,
- Mc_CradNumber AS 会员卡号,
- Cus_Name AS 姓名,
- dbo.fn_CheckSex(Cus_Sex) AS 性别,
- Cus_Telephone AS 电话,
- Mc_CardType AS 类型,
- dbo.fn_GetMember(Mc_Number, 1) AS 积分,
- Mc_Money AS 金额,
- dbo.fn_GetMember(Mc_Number, 2) AS 折扣,
- dbo.fn_GetMember(Mc_Number, 3) AS 套系金额,
- dbo.fn_GetMember(Mc_Number, 4) AS 已返金额,
- dbo.fn_GetMember(Mc_Number, 5) AS 已取出金额,
- (SELECT COUNT(Mcse_ServiceCount) AS Expr1 FROM dbo.tb_ErpMemberCardServiceContent WHERE (Mcse_Number = dbo.BView_MemberCard.Mc_Number)) AS 服务次数,
- (SELECT COUNT(Mvc_Number) AS Expr1 FROM dbo.tb_ErpMemberCardViceCard WHERE (Mvc_Number = dbo.BView_MemberCard.Mc_Number) AND (Mvc_Status = ''1'') AND (Mvc_ViceCardType = ''积分副卡'')) AS 积分副卡,
- (SELECT COUNT(Mvc_Number) AS Expr1 FROM dbo.tb_ErpMemberCardViceCard AS tb_ErpMemberViceCard_2 WHERE (Mvc_Number = dbo.BView_MemberCard.Mc_Number) AND (Mvc_Status = ''1'') AND (Mvc_ViceCardType = ''现金副卡'')) AS 现金副卡,
- (SELECT COUNT(Mvc_Number) AS Expr1 FROM dbo.tb_ErpMemberCardViceCard AS tb_ErpMemberViceCard_1 WHERE (Mvc_Number = dbo.BView_MemberCard.Mc_Number) AND (Mvc_Status = ''1'') AND (Mvc_ViceCardType = ''返现副卡'')) AS 返现副卡,
- Mc_Remark AS 备注,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Mc_CreateDatetime)) AS 办卡日期
- FROM dbo.BView_MemberCard
- WHERE (Mc_Status = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookDeputyStatisticNotFilmSelection')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookDeputyStatisticNotFilmSelection
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookDeputyStatisticNotFilmSelection]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookDeputyStatisticNotFilmSelection]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop, Ord_Type,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- CASE Ord_Type WHEN ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionName) AS 选片师,
- dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionTime) AS 选片时间,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionDispatcher) AS 录入,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionDispatchTime)) AS 录入时间,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1
- FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1
- WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookDeputyStatisticNotLookDesign')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookDeputyStatisticNotLookDesign
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookDeputyStatisticNotLookDesign]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookDeputyStatisticNotLookDesign]
- AS
- SELECT tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- Ord_Type,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- CASE Ord_Type WHEN ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignName) AS 看设计师,
- dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignTime) AS 看设计时间,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_LookDesignDispatcher) AS 录入者,
- dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_LookDesignDispatchTime) AS 录入时间,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookDeputyStatisticNotPhotographed')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookDeputyStatisticNotPhotographed
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookDeputyStatisticNotPhotographed]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_CameraControlBookDeputyStatisticNotPhotographed]
- AS
- SELECT tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop, Ord_Type,
- dbo.tb_ErpOrdersPhotography.ID AS PID,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrder.Ord_CreateDateTime)) AS 订单日期,
- dbo.tb_ErpOrdersPhotography.Ordpg_Sights AS 拍摄名称,
- dbo.fn_CheckPhotographyStatus(dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus) AS 拍摄状态,
- dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime) AS 摄影时间,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyName) AS 摄影师,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyAssistant) AS 摄影助理,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupArtist) AS 化妆师,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupAssistant) AS 化妆助理,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationBootDivision) AS 引导师,
- dbo.tb_ErpOrdersPhotography.Ordpg_Remark AS 备注,
- (SELECT COUNT(tb_ErpOrdersPhotography_1.Ordpg_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrdersPhotography AS tb_ErpOrdersPhotography_1 LEFT OUTER JOIN dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 ON
- tb_ErpOrdersPhotography_1.Ordpg_ViceNumber = tb_ErpOrderDigital_1.Ordv_ViceNumber WHERE (tb_ErpOrderDigital_1.Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookDeputyStatisticNotPickup')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookDeputyStatisticNotPickup
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookDeputyStatisticNotPickup]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookDeputyStatisticNotPickup]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop, Ord_Type,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- CASE WHEN Ord_Type = ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
- tb_ErpOrderProductList.ID AS PPID,
- OPlist_ProdName AS 商品名称,
- dbo.fn_CheckProductTakePiecesStatus(OPlist_PickupStatus) AS 取件状态,
- dbo.fn_CheckProductCompletedStatus(OPlist_CompletedStatus) AS 完成状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime)) AS 取件日期,
- OPlist_ReservationTakeName AS 取件人,
- dbo.fn_CheckIsExpedited(OPlist_IsExpedited) AS 加急,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime)) AS 加急日期
- ,Case when (select Count(ID) from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber)>0 then (select Count(ID) from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber) else (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital WHERE Ordv_Number = dbo.tb_ErpOrder.Ord_Number) end AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- Left Join tb_ErpOrderProductList ON OPlist_ViceNumber = Ordv_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookDeputyStatisticNotSelectDress')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookDeputyStatisticNotSelectDress
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookDeputyStatisticNotSelectDress]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookDeputyStatisticNotSelectDress]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop, Ord_Type,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- CASE Ord_Type WHEN ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
- dbo.fn_CheckOrderClothingStatus(dbo.tb_ErpOrderDigital.Ordv_ClothingStatus) AS 选礼服状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationClothingName) AS 选礼服师,
- dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationClothingTime) AS 选礼服时间,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ClothingDispatcher) AS 安排人,
- dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ClothingDispatchTime) AS 安排时间,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookDeputyStatisticNotWedding')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookDeputyStatisticNotWedding
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookDeputyStatisticNotWedding]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookDeputyStatisticNotWedding]
- AS
- SELECT tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- dbo.tb_ErpWeddingService.ID AS WID,
- Ord_Type,
- dbo.tb_ErpOrder.Ord_Number,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.tb_ErpWeddingService.Ws_ProdName AS 婚庆内容,
- dbo.fn_CheckWeddingServiceStatus(dbo.tb_ErpWeddingService.Ws_Status) AS 服务状态,
- dbo.fn_CheckDateTime(dbo.tb_ErpWeddingService.Ws_WeddingDate) AS 婚庆日期,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpWeddingService.Ws_Serviceman1) AS 服务人员1,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpWeddingService.Ws_Serviceman2) AS 服务人员2,
- dbo.tb_ErpWeddingService.Ws_Remark AS 服务备注,
- (SELECT COUNT(Ws_Number) AS Expr1 FROM dbo.tb_ErpWeddingService AS tb_ErpWeddingService_1 WHERE (Ws_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpWeddingService ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpWeddingService.Ws_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainFilmSelection')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainFilmSelection
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainFilmSelection]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_CameraControlBookMainFilmSelection]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- Ord_Type,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionName) AS 选片师,
- dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionTime) AS 选片时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionTime AS 选片时间查询,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionDispatcher) AS 安排人,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionDispatchTime)) AS 安排时间,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainFilmSelection_DetailPrint')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainFilmSelection_DetailPrint
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainFilmSelection_DetailPrint]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookMainFilmSelection_DetailPrint]
- AS
- SELECT
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Telephone AS 客户电话,
- M_Cus_Name AS 主客户姓名,
- M_Cus_Telephone AS 主客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionName AS 选片师,
- dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionTime) AS 选片时间
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainLately_Birthday')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainLately_Birthday
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainLately_Birthday]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookMainLately_Birthday]
- AS
- SELECT
- ID,
- Cus_Name AS 姓名,
- dbo.fn_CheckSex(Cus_Sex) AS 性别,
- Cus_Telephone AS 电话,
- Cus_Birthday AS 生日,
- case when Cus_Birthday = '''' then '''' else dbo.fn_CheckLunar(Cus_BirthdayLunar) end AS 是否农历,
- Cus_Type AS 客户类型
- FROM dbo.tb_ErpCustomer
- WHERE (Cus_Birthday IS NOT NULL and Cus_Birthday != '''')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainLately_GetMarried')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainLately_GetMarried
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainLately_GetMarried]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookMainLately_GetMarried]
- AS
- SELECT
- ID,
- Cus_Name AS 姓名,
- dbo.fn_CheckSex(Cus_Sex) AS 性别,
- Cus_DayForMarriage AS 婚期,
- case when Cus_Birthday = '''' then '''' else dbo.fn_CheckLunar(Cus_DayForMarriageLunar) end AS 是否农历,
- Cus_Type AS 客户类型,
- Cus_Telephone AS 电话
- FROM dbo.tb_ErpCustomer
- WHERE (Cus_DayForMarriage IS NOT NULL) AND (Cus_DayForMarriage !='''')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainLately_MarryAnniversary')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainLately_MarryAnniversary
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainLately_MarryAnniversary]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookMainLately_MarryAnniversary]
- AS
- SELECT ID, Cus_Name AS 姓名, dbo.fn_CheckSex(Cus_Sex) AS 性别, Cus_Telephone AS 电话, Cus_Type AS 客户类型,
- Cus_DayForMarriage AS 婚期, case when Cus_Birthday = '''' then '''' else dbo.fn_CheckLunar(Cus_DayForMarriageLunar) end AS 是否农历
- FROM dbo.tb_ErpCustomer
- WHERE (Cus_DayForMarriage != '''' and Cus_DayForMarriage is not null)
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainLookDesign')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainLookDesign
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainLookDesign]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_CameraControlBookMainLookDesign]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- Ord_Type,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE Ord_SinceOrderNumber WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignName) AS 看设计师,
- dbo.fn_CheckDateTime(Ordv_ReservationLookDesignTime) AS 看设计时间,
- Ordv_ReservationLookDesignTime AS 看设计时间查询,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_LookDesignDispatcher) AS 安排人,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_LookDesignDispatchTime)) AS 安排时间,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainLookDesign_DetailPrint')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainLookDesign_DetailPrint
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainLookDesign_DetailPrint]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookMainLookDesign_DetailPrint]
- AS
- SELECT
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Telephone AS 客户电话,
- M_Cus_Name AS 主客户姓名,
- M_Cus_Telephone AS 主客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignName AS 看设计师,
- dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignTime) AS 看设计时间
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainPhotographed')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainPhotographed
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainPhotographed]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_CameraControlBookMainPhotographed]
- AS
- SELECT tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- Ord_Type,
- dbo.tb_ErpOrdersPhotography.ID AS VID,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- (Ord_SeriesPrice - (Case when (select sum(Pay_AmountOf) from dbo.tb_ErpPayment where Pay_OrdNumber =Ord_Number and Pay_Category in (''全款'',''后期收款'',''预约收款'',''预约补款'')) is null then 0 else (select sum(Pay_AmountOf) from dbo.tb_ErpPayment where Pay_OrdNumber =Ord_Number and Pay_Category in (''全款'',''后期收款'',''预约收款'',''预约补款'')) end) + (Select sum(Plu_Amount) as Plu_Amount from tb_ErpPlusPickItems where Plu_OrdNumber = Ord_Number)) AS 欠款,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.tb_ErpOrdersPhotography.Ordpg_Sights AS 拍摄名称,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS 摄影时间,
- Ordpg_ReservationPhotographyTime AS 摄影时间查询,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyName) AS 摄影师,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyAssistant) AS 摄影助理,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupArtist) AS 化妆师,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupAssistant) AS 化妆助理,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationBootDivision) AS 引导师,
- dbo.tb_ErpOrdersPhotography.Ordpg_Remark AS 录入备注,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_Dispatcher) AS 安排人,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_DispatchTime)) AS 安排时间,
- (SELECT COUNT(tb_ErpOrdersPhotography_1.Ordpg_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrdersPhotography AS tb_ErpOrdersPhotography_1 LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 ON tb_ErpOrdersPhotography_1.Ordpg_ViceNumber = tb_ErpOrderDigital_1.Ordv_ViceNumber WHERE (tb_ErpOrderDigital_1.Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainPhotographed_DetailPrint')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainPhotographed_DetailPrint
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainPhotographed_DetailPrint]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookMainPhotographed_DetailPrint]
- AS
- SELECT dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Telephone AS 客户电话,
- M_Cus_Name AS 主客户姓名,
- M_Cus_Telephone AS 主客户电话,
- dbo.tb_ErpOrderDigital.Ordv_ReservationClothingName AS 服装师,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (select top 1 Ordpg_ReservationPhotographyTime from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationPhotographyTime is not null order by Ordpg_ReservationPhotographyTime ASC) AS 摄影时间,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_ReservationPhotographyName) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationPhotographyName != '''' group by Ordpg_ReservationPhotographyName for xml path('''')),1,1,'''')) as 摄影师,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_ReservationPhotographyAssistant) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationPhotographyAssistant != '''' group by Ordpg_ReservationPhotographyAssistant for xml path('''')),1,1,'''')) as 摄影助理,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_ReservationMakeupArtist) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationMakeupArtist != '''' group by Ordpg_ReservationMakeupArtist for xml path('''')),1,1,'''')) as 化妆师,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_ReservationMakeupAssistant) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationMakeupAssistant != '''' group by Ordpg_ReservationMakeupAssistant for xml path('''')),1,1,'''')) as 化妆助理,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_ReservationBootDivision) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationBootDivision != '''' group by Ordpg_ReservationBootDivision for xml path('''')),1,1,'''')) as 引导师
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainPhotographed_DispatchPrint')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainPhotographed_DispatchPrint
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainPhotographed_DispatchPrint]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookMainPhotographed_DispatchPrint]
- AS
- SELECT
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Telephone AS 客户电话,
- M_Cus_Name AS 主客户姓名,
- M_Cus_Telephone AS 主客户电话,
- dbo.tb_ErpOrderDigital.Ordv_ReservationClothingName AS 服装师,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (select top 1 Ordpg_ReservationPhotographyTime from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationPhotographyTime is not null order by Ordpg_ReservationPhotographyTime ASC) AS 摄影时间,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_ReservationPhotographyName) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationPhotographyName != '''' group by Ordpg_ReservationPhotographyName for xml path('''')),1,1,'''')) as 摄影师,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_ReservationPhotographyAssistant) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationPhotographyAssistant != '''' group by Ordpg_ReservationPhotographyAssistant for xml path('''')),1,1,'''')) as 摄影助理,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_ReservationMakeupArtist) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationMakeupArtist != '''' group by Ordpg_ReservationMakeupArtist for xml path('''')),1,1,'''')) as 化妆师,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_ReservationMakeupAssistant) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationMakeupAssistant != '''' group by Ordpg_ReservationMakeupAssistant for xml path('''')),1,1,'''')) as 化妆助理,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_ReservationBootDivision) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_ReservationBootDivision != '''' group by Ordpg_ReservationBootDivision for xml path('''')),1,1,'''')) as 引导师,
- (select stuff((select '','' + Ordpg_Remark from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_Remark!= '''' for xml path('''')),1,1,'''')) as 备注
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainPickup')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainPickup
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainPickup]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_CameraControlBookMainPickup]
- AS
- SELECT
- dbo.tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,Ord_Type,
- tb_ErpOrderProductList.ID AS PID,
- dbo.tb_ErpOrder.Ord_Number, dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- CASE WHEN Ord_Type = ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
- dbo.tb_ErpOrderProductList.OPlist_ProdName AS 商品名称,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime)) AS 取件时间,
- OPlist_ReservationTakeTime AS 取件时间查询,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderProductList.OPlist_PickupName) AS 取件人,
- dbo.fn_CheckTakePiecesStatus(dbo.tb_ErpOrderProductList.OPlist_PickupStatus) AS 取件状态,
- dbo.fn_CheckProductCompletedStatus(dbo.tb_ErpOrderProductList.OPlist_CompletedStatus) AS 完成状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderProductList.OPlist_ArrangeNmae) AS 安排人,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderProductList.OPlist_ArrangeTime)) AS 安排时间
- ,Case when (select Count(ID) from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber)>0 then (select Count(ID) from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber) else (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital WHERE Ordv_Number = dbo.tb_ErpOrder.Ord_Number) end AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
- dbo.tb_ErpOrderProductList ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrderProductList.OPlist_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrderProductList.OPlist_Type = ''2'') AND
- (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainPickup_DetailPrint')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainPickup_DetailPrint
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainPickup_DetailPrint]'))
- EXEC dbo.sp_executesql @statement = N'
- create VIEW [dbo].[BView_CameraControlBookMainPickup_DetailPrint]
- AS
- SELECT dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Telephone AS 客户电话,
- M_Cus_Name AS 主客户姓名,
- M_Cus_Telephone AS 主客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_GetProductListCompletedStatus(dbo.tb_ErpOrderDigital.Ordv_ViceNumber) AS 完成状态,
- dbo.fn_GetProductList(dbo.tb_ErpOrderDigital.Ordv_Number, 5) AS 取件人,
- dbo.fn_GetProductListPickupDate(dbo.tb_ErpOrderDigital.Ordv_ViceNumber, 2) AS 取件时间
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainSelectDress')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainSelectDress
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainSelectDress]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookMainSelectDress]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- Ord_Type,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- dbo.fn_CheckOrderClothingStatus(dbo.tb_ErpOrderDigital.Ordv_ClothingStatus) AS 选礼服状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationClothingName) AS 选礼服师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationClothingTime)) AS 选礼服时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationClothingTime AS 选礼服时间查询,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ClothingDispatcher) AS 安排人,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ClothingDispatchTime)) AS 安排时间,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainWedding')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainWedding
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainWedding]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_CameraControlBookMainWedding]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop, Ord_Type,
- dbo.tb_ErpWeddingService.Ws_Type,
- dbo.tb_ErpWeddingService.ID AS VID,
- dbo.tb_ErpOrder.Ord_Number,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.tb_ErpWeddingService.Ws_ProdName AS 服务内容,
- dbo.fn_CheckWeddingServiceStatus(dbo.tb_ErpWeddingService.Ws_Status) AS 服务状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ws_WeddingDate)) AS 服务日期,
- Ws_WeddingDate AS 服务日期查询,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpWeddingService.Ws_Serviceman1) AS 服务人员1,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpWeddingService.Ws_Serviceman2) AS 服务人员2,
- dbo.tb_ErpWeddingService.Ws_Remark AS 服务备注,
- (SELECT COUNT(Ws_Number) AS Expr1 FROM dbo.tb_ErpWeddingService AS tb_ErpWeddingService_1 WHERE (Ws_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpWeddingService ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpWeddingService.Ws_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- --AND (dbo.tb_ErpWeddingService.Ws_Status = ''1'') OR
- --(dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpWeddingService.Ws_WeddingDate IS NOT NULL) OR
- --(dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpWeddingService.Ws_Serviceman1 <> '''') OR
- --(dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpWeddingService.Ws_Serviceman2 <> '''')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainWedding_DetailPrint')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookMainWedding_DetailPrint
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainWedding_DetailPrint]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookMainWedding_DetailPrint]
- AS
- SELECT
- dbo.tb_ErpOrder.Ord_Number,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Telephone AS 客户电话,
- M_Cus_Name AS 主客户姓名,
- M_Cus_Telephone AS 主客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpWeddingService.Ws_ProdName AS 服务内容,
- dbo.fn_CheckDateTime(dbo.tb_ErpWeddingService.Ws_WeddingDispatchDate) AS 服务时间,
- dbo.tb_ErpWeddingService.Ws_Serviceman1 AS 服务人员1,
- dbo.tb_ErpWeddingService.Ws_Serviceman2 AS 服务人员2
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpWeddingService ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpWeddingService.Ws_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookReservationFilmSelectionRemind')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookReservationFilmSelectionRemind
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookReservationFilmSelectionRemind]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookReservationFilmSelectionRemind]
- AS
- SELECT
- dbo.tb_ErpOrder.Ord_DividedShop, Ord_Number,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Sex_cs AS 客户性别,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- CASE Ord_Type WHEN ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionTime) AS 选片时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionTime AS 选片时间查询
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookReservationLookDesignRemind')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookReservationLookDesignRemind
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookReservationLookDesignRemind]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_CameraControlBookReservationLookDesignRemind]
- AS
- SELECT
- dbo.tb_ErpOrder.Ord_DividedShop, Ord_Number,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Sex_cs AS 客户性别,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- CASE Ord_Type WHEN ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignTime) AS 看设计时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignTime AS 看设计时间查询
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookReservationPhotographedRemind')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookReservationPhotographedRemind
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookReservationPhotographedRemind]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_CameraControlBookReservationPhotographedRemind]
- AS
- SELECT
- dbo.tb_ErpOrder.Ord_DividedShop, Ordv_Number AS Ord_Number,
- dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber,
- CASE Ord_SinceOrderNumber WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Sex_cs AS 客户性别,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称
- ,Ordpg_Sights AS 拍摄名称
- ,dbo.fn_CheckDateTimeReturn_Date(Ordpg_ReservationPhotographyTime) AS 拍摄时间
- ,dbo.fn_CheckUserIDGetUserName(Ordpg_Dispatcher) AS 安排者
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookReservationSelectDressRemind')
- BEGIN
- DROP VIEW [dbo].BView_CameraControlBookReservationSelectDressRemind
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookReservationSelectDressRemind]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_CameraControlBookReservationSelectDressRemind]
- AS
- SELECT
- dbo.tb_ErpOrder.Ord_DividedShop, Ord_Number,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Sex_cs AS 客户性别,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- CASE Ord_Type WHEN ''1'' THEN (SELECT TOP 1 Ordpg_Sights FROM tb_ErpOrdersPhotography WHERE Ordpg_ViceNumber = Ordv_ViceNumber) ELSE '''' END AS 拍摄名称,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_ClothingStatus) AS 选礼服状态,
- dbo.fn_CheckUserIDGetUserName(Ordv_ReservationClothingName) AS 选礼服负责人,
- dbo.tb_ErpOrderDigital.Ordv_ReservationClothingTime AS 选礼服时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationClothingTime AS 选礼服时间查询
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityDesign')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityDesign
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityDesign]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_DoorCityDesign]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- Ord_Type,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.fn_GetProductExpedited(dbo.tb_ErpOrderDigital.Ordv_ViceNumber) AS 加急,
- (case when (select count(OPlist_IsExpedited) from dbo.tb_ErpOrderProductList where OPlist_ViceNumber =Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_IsExpedited=''1'') = 0 then '''' else
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime((select top 1 OPlist_ExpeditedTime from dbo.tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_ExpeditedTime != '''' order by OPlist_ExpeditedTime ASC))) end ) AS 加急日期,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_Photographer) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_Photographer!= '''' group by Ordpg_Photographer for xml path('''')),1,1,'''')) as 摄影师,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) AS 精修状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_RefinementTime)) AS 精修日期,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_DesignerName) AS 设计师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_DesignerTime)) AS 设计日期,
- dbo.tb_ErpOrderDigital.Ordv_DesignerTime AS 设计查询日期,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_LookDesignName) AS 看设计师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_LookDesignTime)) AS 看设计日期,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- dbo.tb_ErpOrderDigital.Ordv_LookDesignClaim AS 看设计要求,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1
- FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1
- WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityDigitalArrange')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityDigitalArrange
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityDigitalArrange]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_DoorCityDigitalArrange]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, Ord_Type,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- --dbo.fn_GetPhotographerStatus(dbo.tb_ErpOrderDigital.Ordv_ViceNumber) AS 拍摄状态,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) + ''/'' + dbo.fn_CheckUserIDGetUserName((case when Ordv_EarlyRepairName <> '''' then Ordv_EarlyRepairName else Ordv_ReservationEarlyRepairName end)) AS 初修状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairTime)) AS 初修日期,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) + ''/'' + dbo.fn_CheckUserIDGetUserName((case when Ordv_FilmSelectionName <> '''' then Ordv_FilmSelectionName else Ordv_ReservationFilmSelectionName end)) AS 选片状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionTime)) AS 选片日期,
- dbo.tb_ErpOrderDigital.Ordv_FilmSelectionTime AS 选片查询日期,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) + ''/'' + dbo.fn_CheckUserIDGetUserName((case when Ordv_DesignerName <> '''' then Ordv_DesignerName else Ordv_ReservationDesignerName end)) AS 设计状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerTime)) AS 设计日期,
- dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) + ''/'' + dbo.fn_CheckUserIDGetUserName((case when Ordv_RefinementName <> '''' then Ordv_RefinementName else Ordv_ReservationRefinementName end)) AS 精修状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementTime)) AS 精修日期,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) + ''/'' + dbo.fn_CheckUserIDGetUserName((case when Ordv_LookDesignName <> '''' then Ordv_LookDesignName else Ordv_ReservationLookDesignName end)) AS 看设计状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_LookDesignTime)) AS 看设计日期,
- dbo.tb_ErpOrderDigital.Ordv_LookDesignTime AS 看设计查询日期,
- dbo.fn_GetProductExpedited(dbo.tb_ErpOrderDigital.Ordv_ViceNumber) AS 加急,
- (case when (select count(OPlist_IsExpedited) from dbo.tb_ErpOrderProductList where OPlist_ViceNumber =Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_IsExpedited=''1'') = 0 then '''' else
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime((select top 1 OPlist_ExpeditedTime from dbo.tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_ExpeditedTime != '''' order by OPlist_ExpeditedTime ASC))) end ) AS 加急日期,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityDigitalArrangeAnPaiWork_A')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityDigitalArrangeAnPaiWork_A
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityDigitalArrangeAnPaiWork_A]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_DoorCityDigitalArrangeAnPaiWork_A]
- AS
- SELECT
- tb_ErpOrderDigital.ID, dbo.tb_ErpOrder.Ord_DividedShop, dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairName AS 初修师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairTime)) AS 初修期限,
- dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerName AS 设计师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerTime)) AS 设计期限,
- dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementName AS 精修师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementTime)) AS 精修期限,
- dbo.tb_ErpOrderDigital.Ordv_ReservationSendPhotoName AS 发片师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationSendPhotoTime)) AS 发片期限
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityDigitalArrangeAnPaiWork_NoDoTask_A')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityDigitalArrangeAnPaiWork_NoDoTask_A
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityDigitalArrangeAnPaiWork_NoDoTask_A]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_DoorCityDigitalArrangeAnPaiWork_NoDoTask_A]
- AS
- SELECT
- User_DividedShop,
- User_Name,
- Ord_EarlyRepairCout,
- Ord_RefinementCount,
- Ord_DesignerCount,
- Ord_SendPhotoCount
- FROM (SELECT User_DividedShop, User_Name,(SELECT COUNT(Ordv_ReservationEarlyRepairName) AS Expr1 FROM dbo.tb_ErpOrderDigital WHERE (Ordv_ReservationEarlyRepairName = dbo.tb_ErpUser.User_EmployeeID) AND (Ordv_EarlyRepairStatus <> ''2'')) AS Ord_EarlyRepairCout,
- (SELECT COUNT(Ordv_ReservationRefinementName) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_2 WHERE (Ordv_ReservationRefinementName = dbo.tb_ErpUser.User_EmployeeID) AND (Ordv_DesignerStatus <> ''2'')) AS Ord_RefinementCount,
- (SELECT COUNT(Ordv_ReservationDesignerName) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_ReservationDesignerName = dbo.tb_ErpUser.User_EmployeeID) AND (Ordv_RefinementStatus <> ''2'')) AS Ord_DesignerCount,
- (Select COunt(Ordv_ReservationSendPhotoName) AS Expr1 from dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_3 where (Ordv_ReservationSendPhotoName = dbo.tb_ErpUser.User_EmployeeID) AND (Ordv_ReservationSendPhotoStatus <> ''2'')) AS Ord_SendPhotoCount
- FROM dbo.tb_ErpUser) AS tb
- WHERE
- (Ord_EarlyRepairCout > 0) OR
- (Ord_RefinementCount > 0) OR
- (Ord_DesignerCount > 0)OR
- (Ord_SendPhotoCount > 0)
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityDigitalArrangeAnPaiWorkDigital')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityDigitalArrangeAnPaiWorkDigital
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityDigitalArrangeAnPaiWorkDigital]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_DoorCityDigitalArrangeAnPaiWorkDigital]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop, Ord_Type,
- Ord_Number,dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairName) + ''/'' + dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairTime)) AS 初修完成期限,
- dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairTime AS 初修完成期限查询,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerName) + ''/'' + dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerTime)) AS 设计完成期限,
- dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerTime AS 设计完成期限查询,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementName) + ''/'' + dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) AS 精修,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementTime)) AS 精修完成期限,
- dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementTime AS 精修完成期限查询
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairName <> '''') OR
- (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2'')) AND
- (dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerName <> '''') OR
- (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2'')) AND
- (dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementName <> '''')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityFilmSelection')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityFilmSelection
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityFilmSelection]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_DoorCityFilmSelection]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- Ord_Type,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.tb_ErpOrder.Ord_PlusPickNumber AS 加挑张数,
- dbo.fn_GetPlusPickAmount(dbo.tb_ErpOrder.Ord_Number) AS 加挑金额,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_Photographer) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_Photographer!= '''' group by Ordpg_Photographer for xml path('''')),1,1,'''')) as 摄影师,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairTime)) AS 初修日期,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionName) AS 选片师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionTime)) AS 选片日期,
- dbo.tb_ErpOrderDigital.Ordv_FilmSelectionTime AS 选片日期查询,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) AS 精修状态,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityFilmSelectionPrint')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityFilmSelectionPrint
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityFilmSelectionPrint]'))
- EXEC dbo.sp_executesql @statement = N'
- create VIEW [dbo].[BView_DoorCityFilmSelectionPrint]
- AS
- SELECT
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrder.Ord_Type,
- Cus_Name AS 客户姓名,
- Cus_Telephone AS 客户电话,
- M_Cus_Name AS 主客户姓名,
- M_Cus_Telephone AS 主客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_Photographer) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_Photographer!= '''' group by Ordpg_Photographer for xml path('''')),1,1,'''')) as 摄影师,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_MakeupArtist) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_MakeupArtist!= '''' group by Ordpg_MakeupArtist for xml path('''')),1,1,'''')) as 化妆师,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_BootDivision) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_BootDivision!= '''' group by Ordpg_BootDivision for xml path('''')),1,1,'''')) as 引导师,
- (select top 1 Ordpg_PhotographyTime from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyTime is not null order by Ordpg_PhotographyTime DESC) AS 拍摄日期,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityInputMemberCard')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityInputMemberCard
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityInputMemberCard]'))
- EXEC dbo.sp_executesql @statement = N'
- Create VIEW [dbo].[BView_DoorCityInputMemberCard]
- AS
- Select ''0'' AS MainVice,Mc_Number,Mc_CradNumber,
- Mc_CardType,
- dbo.fn_GetCustomer(dbo.tb_ErpMemberCard.Mc_CustomerNumber, 1, 1) AS Cus_Name,
- dbo.fn_ChineseToSpell(dbo.fn_GetCustomer(dbo.tb_ErpMemberCard.Mc_CustomerNumber, 1, 1)) AS Cus_PName,
- dbo.fn_GetCustomer(dbo.tb_ErpMemberCard.Mc_CustomerNumber, 1, 3) AS Cus_Telephone
- from dbo.tb_ErpMemberCard where Mc_Status = ''1''
- UNION
- select ''1'' AS MainVice,Mvc_ViceNumber AS Mc_Number,Mvc_ViceCardNumber AS Mc_CradNumber,
- (select Mc_CardType from dbo.tb_ErpMemberCard where Mc_Number = Mvc_Number) AS Mc_CardType,
- dbo.fn_GetCustomer((select Mc_CustomerNumber from dbo.tb_ErpMemberCard where Mc_Number = Mvc_Number), 1, 1) AS Cus_Name,
- dbo.fn_ChineseToSpell(dbo.fn_GetCustomer((select Mc_CustomerNumber from dbo.tb_ErpMemberCard where Mc_Number = Mvc_Number), 1, 1)) AS Cus_PName,
- dbo.fn_GetCustomer((select Mc_CustomerNumber from dbo.tb_ErpMemberCard where Mc_Number = Mvc_Number), 1, 3) AS Cus_Telephone
- from dbo.tb_ErpMemberCardViceCard where Mvc_Status = ''1''
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityKePan')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityKePan
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityKePan]'))
- EXEC dbo.sp_executesql @statement = N'
- create VIEW [dbo].[BView_DoorCityKePan]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- Ord_Type,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.fn_GetProductExpedited(dbo.tb_ErpOrderDigital.Ordv_ViceNumber) AS 加急,
- (case when (select count(OPlist_IsExpedited) from dbo.tb_ErpOrderProductList where OPlist_ViceNumber =Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_IsExpedited=''1'') = 0 then '''' else
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime((select top 1 OPlist_ExpeditedTime from dbo.tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_ExpeditedTime != '''' order by OPlist_ExpeditedTime ASC))) end ) AS 加急日期,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- dbo.fn_GetKePan(dbo.tb_ErpOrderDigital.Ordv_ViceNumber, 1) AS 刻盘次数,
- dbo.fn_GetKePan(dbo.tb_ErpOrderDigital.Ordv_ViceNumber, 2) AS 刻盘状态,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) AS 精修状态,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_DesignerTime)) AS 设计日期,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_LookDesignTime)) AS 看设计日期,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityPhotographed')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityPhotographed
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityPhotographed]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_DoorCityPhotographed]
- AS
- SELECT
- tb_ErpOrder.ID, dbo.tb_ErpOrder.Ord_DividedShop, dbo.tb_ErpOrdersPhotography.ID AS JID,
- dbo.tb_ErpOrder.Ord_Number, dbo.tb_ErpOrderDigital.Ordv_ViceNumber, dbo.tb_ErpOrder.Ord_CustomerSource,
- dbo.tb_ErpOrder.Ord_PhotographyCategory, Ord_Type,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.tb_ErpOrdersPhotography.Ordpg_Sights AS 拍摄名称,
- dbo.fn_CheckOrderPhotographyStatus(dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus) AS 拍摄状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_Photographer) AS 摄影师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime)) AS 拍摄日期,
- dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime AS 拍摄日期查询,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyAssistant) AS 拍摄助理,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_MakeupArtist) AS 化妆师,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_MakeupAssistant) AS 化妆助理,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_BootDivision) AS 引导师,
- dbo.fn_CheckOrderClothingStatus(dbo.tb_ErpOrderDigital.Ordv_ClothingStatus) AS 选衣状态,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) AS 精修状态,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- (SELECT COUNT(tb_ErpOrdersPhotography_1.Ordpg_ViceNumber) AS Expr1
- FROM dbo.tb_ErpOrdersPhotography AS tb_ErpOrdersPhotography_1 LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 ON
- tb_ErpOrdersPhotography_1.Ordpg_ViceNumber = tb_ErpOrderDigital_1.Ordv_ViceNumber
- WHERE (tb_ErpOrderDigital_1.Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber = dbo.tb_ErpOrderDigital.Ordv_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityPhotosPrints')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityPhotosPrints
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityPhotosPrints]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_DoorCityPhotosPrints]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, Ord_Type,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- (select Cus_NamePinyin from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as 姓名拼音1,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.fn_GetProductExpedited(dbo.tb_ErpOrderDigital.Ordv_ViceNumber) AS 加急,
- (case when (select count(OPlist_IsExpedited) from dbo.tb_ErpOrderProductList where OPlist_ViceNumber =Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_IsExpedited=''1'') = 0 then '''' else
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime((select top 1 OPlist_ExpeditedTime from dbo.tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_ExpeditedTime != '''' order by OPlist_ExpeditedTime ASC))) end ) AS 加急日期,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_DesignerName) AS 设计师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_DesignerTime)) AS 设计日期,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_LookDesignName) AS 看设计师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_LookDesignTime)) AS 看设计日期,
- tb_ErpOrderPhotoPrints.ID AS PPID,
- Opps_PhotoName AS 相片名称, Opps_PhotoQuantity AS 数量, Opps_PhotoArea AS 面积,Opps_SendVendor AS 发出状态, dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Opps_SendTime)) AS 发出日期,
- dbo.fn_CheckPhotoPrintsReworkStatus(Opps_ReworkStatus) AS 返工状态, dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Opps_ReworkTime)) AS 返工日期,
- dbo.fn_CheckProductCompletedStatus(Opps_CompletedStatus) AS 完成状态, dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Opps_CompletedTime)) AS 完成日期,
- Case when (select Count(ID) from tb_ErpOrderPhotoPrints where Opps_OrderNumber = Ordv_ViceNumber)>0 then (select Count(ID) from tb_ErpOrderPhotoPrints where Opps_OrderNumber = Ordv_ViceNumber) else (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital WHERE Ordv_Number = dbo.tb_ErpOrder.Ord_Number) end AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- Left Join tb_ErpOrderPhotoPrints on Opps_OrderNumber = Ordv_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityPhotosPrintsMonthPrint')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityPhotosPrintsMonthPrint
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityPhotosPrintsMonthPrint]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_DoorCityPhotosPrintsMonthPrint]
- AS
- SELECT
- tb_ErpOrder.ID, dbo.tb_ErpOrder.Ord_DividedShop,
- dbo.tb_ErpOrderPhotoPrints.ID AS PPID,Ord_Number, Ordv_ViceNumber,Ord_Type,dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber ) else '''' end) AS 拍摄名称,
- dbo.tb_ErpOrderPhotoPrints.Opps_PhotoName AS 相片名称, dbo.tb_ErpOrderPhotoPrints.Opps_PhotoQuantity AS 数量,
- dbo.tb_ErpOrderPhotoPrints.Opps_PhotoArea AS 面积m2, dbo.tb_ErpOrderPhotoPrints.Opps_SendVendor AS 是否发出,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderPhotoPrints.Opps_SendTime)) AS 发出日期,
- dbo.tb_ErpOrderPhotoPrints.Opps_SendTime AS 发出日期查询,
- dbo.fn_CheckProductCompletedStatus(dbo.tb_ErpOrderPhotoPrints.Opps_CompletedStatus) AS 是否完成,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderPhotoPrints.Opps_CompletedTime)) AS 完成日期,
- dbo.tb_ErpOrderPhotoPrints.Opps_CompletedTime AS 完成日期查询
- ,(select Count(ID) from tb_ErpOrderPhotoPrints where Opps_OrderNumber = Ordv_ViceNumber) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
- dbo.tb_ErpOrderPhotoPrints ON
- dbo.tb_ErpOrderPhotoPrints.Opps_OrderNumber = dbo.tb_ErpOrderDigital.Ordv_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityPhotosPrintsPrintManage')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityPhotosPrintsPrintManage
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityPhotosPrintsPrintManage]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_DoorCityPhotosPrintsPrintManage]
- AS
- SELECT ID, Opps_OrderNumber, Opps_PhotoName AS 相片名称, Opps_PhotoQuantity AS 数量, Opps_PhotoArea AS 面积,
- Opps_SendStatus, Opps_SendVendor AS 是否发出,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Opps_SendTime)) AS 发出日期,
- dbo.fn_CheckProductReworkStatus(Opps_ReworkStatus)
- + CASE [Opps_ReworkRemark] WHEN '''' THEN '''' ELSE ''/['' + [Opps_ReworkRemark] + '']'' END AS 返工,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Opps_ReworkTime)) AS 返工日期,
- dbo.fn_CheckProductCompletedStatus(Opps_CompletedStatus) AS 是否完成,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Opps_CompletedTime)) AS 完成日期
- FROM dbo.tb_ErpOrderPhotoPrints
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityRefinedRepair')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityRefinedRepair
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityRefinedRepair]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_DoorCityRefinedRepair]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- Ord_Type,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.fn_GetProductExpedited(dbo.tb_ErpOrderDigital.Ordv_ViceNumber) AS 加急,
- (case when (select count(OPlist_IsExpedited) from dbo.tb_ErpOrderProductList where OPlist_ViceNumber =Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_IsExpedited=''1'') = 0 then '''' else
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime((select top 1 OPlist_ExpeditedTime from dbo.tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_ExpeditedTime != '''' order by OPlist_ExpeditedTime ASC))) end ) AS 加急日期,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_Photographer) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_Photographer!= '''' group by Ordpg_Photographer for xml path('''')),1,1,'''')) as 摄影师,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionTime)) AS 选片日期,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_RefinementName) AS 精修师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_RefinementTime)) AS 精修日期,
- dbo.tb_ErpOrderDigital.Ordv_RefinementTime AS 精修日期查询,
- dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) AS 精修状态,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityRepairPiece')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityRepairPiece
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityRepairPiece]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_DoorCityRepairPiece]
- AS
- SELECT
- tb_ErpOrder.ID, dbo.tb_ErpOrder.Ord_DividedShop, dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, Ord_Type,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- dbo.fn_GetProductExpedited(dbo.tb_ErpOrderDigital.Ordv_ViceNumber) AS 加急,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_Photographer) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_Photographer!= '''' group by Ordpg_Photographer for xml path('''')),1,1,'''')) as 摄影师,
- (select top 1 dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_PhotographyTime)) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyTime is not null order by Ordpg_PhotographyTime DESC) AS 拍摄日期,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairName) AS 初修师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairTime)) AS 初修日期,
- dbo.tb_ErpOrderDigital.Ordv_EarlyRepairTime AS 初修日期查询,
- dbo.fn_CheckOrderEarlyRepairStatus(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckOrderFilmSelectionStatus(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckOrderRefinementStatus(dbo.tb_ErpOrderDigital.Ordv_RefinementStatus) AS 精修状态,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1
- FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1
- WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityTotakePiece')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityTotakePiece
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityTotakePiece]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_DoorCityTotakePiece]
- AS
- SELECT
- tb_ErpOrder.ID,
- dbo.tb_ErpOrder.Ord_DividedShop,
- dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- Ord_Type,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- (Ord_SeriesPrice - (Case when (select sum(Pay_AmountOf) from dbo.tb_ErpPayment where Pay_OrdNumber =Ord_Number and Pay_Category in (''全款'',''后期收款'',''预约收款'',''预约补款'')) is null then 0 else (select sum(Pay_AmountOf) from dbo.tb_ErpPayment where Pay_OrdNumber =Ord_Number and Pay_Category in (''全款'',''后期收款'',''预约收款'',''预约补款'')) end) + (Select sum(Plu_Amount) as Plu_Amount from tb_ErpPlusPickItems where Plu_OrdNumber = Ord_Number)) AS 欠款,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- dbo.fn_CheckOrderDesignerStatus(dbo.tb_ErpOrderDigital.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_DesignerName) AS 设计师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_DesignerTime)) AS 设计日期,
- dbo.fn_CheckOrderLookDesignStatus(dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus) AS 看设计状态,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_LookDesignName) AS 看设计师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_LookDesignTime)) AS 看设计日期,
- (case when (select count(OPlist_CompletedStatus) from dbo.tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type = ''2'' and OPlist_CompletedStatus = ''0'' and OPlist_CompletedStatus = ''1'')>0 then ''未完'' else
- (case when (select count(OPlist_CompletedStatus) from dbo.tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type = ''2'' and OPlist_CompletedStatus = ''0'') > 0 then ''未完'' else
- (case when (select count(OPlist_CompletedStatus) from dbo.tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type = ''2'' and OPlist_CompletedStatus = ''1'') > 0 then ''OK'' else '''' end )end )end ) AS 是否完成,
- (select top 1 dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_PickupTime)) from dbo.tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_PickupTime != '''' order by OPlist_PickupTime DESC) AS 取件日期,
- (select top 1 OPlist_PickupTime from dbo.tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type=''2'' and OPlist_PickupTime != '''' order by OPlist_PickupTime DESC) AS 取件日期查询,
- tb_ErpOrderProductList.ID AS OPID,
- OPlist_ProdName AS 商品名称,
- dbo.fn_CheckIsExpedited(OPlist_IsExpedited) AS 加急,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_PickupTime)) AS 商品取件日期,
- OPlist_SendVendor AS 是否发出,
- dbo.fn_CheckProductReworkStatus(OPlist_ReworkStatus) AS 是否返工,
- dbo.fn_CheckProductCompletedStatus(OPlist_CompletedStatus) AS 商品完成状态,
- dbo.fn_CheckProductTakePiecesStatus(OPlist_PickupStatus) AS 是否取走
- ,Case when (select Count(ID) from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber)>0 then (select Count(ID) from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber) else (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital WHERE Ordv_Number = dbo.tb_ErpOrder.Ord_Number) end AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- Left Join tb_ErpOrderProductList ON OPlist_ViceNumber = Ordv_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityTotakePieceHairPiece')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityTotakePieceHairPiece
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityTotakePieceHairPiece]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_DoorCityTotakePieceHairPiece]
- AS
- SELECT ID, OPlist_ViceNumber, OPlist_ProdName AS 商品名称, OPlist_ProdQuantity AS 数量,
- dbo.fn_CheckIsExpedited(OPlist_IsExpedited) AS 加急, OPlist_SendStatus, OPlist_SendVendor AS 发出,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_SendTime)) + ''/'' + dbo.fn_CheckUserIDGetUserName(OPlist_SendName) AS 发出日期, OPlist_SendName AS OPlist_SendNameCode,
- dbo.fn_CheckProductReworkStatus(OPlist_ReworkStatus) + CASE [OPlist_ReworkRemark] WHEN '''' THEN '''' ELSE ''['' + [OPlist_ReworkRemark] + '']'' END AS 返工,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReworkTime)) + ''/'' + dbo.fn_CheckUserIDGetUserName(OPlist_ReworName) AS 返工日期,
- OPlist_ReworName AS OPlist_ReworNameCode, OPlist_CompletedStatus,
- dbo.fn_CheckProductCompletedStatus(OPlist_CompletedStatus) AS 完成,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_CompletedTime)) + ''/'' + dbo.fn_CheckUserIDGetUserName(OPlist_CompletedName) AS 完成日期,
- OPlist_CompletedName AS OPlist_CompletedNameCode, dbo.fn_CheckTakePiecesStatus(OPlist_PickupStatus) AS 取走,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_PickupTime)) + ''/'' + dbo.fn_CheckUserIDGetUserName(OPlist_PickupName) AS 取走日期,
- OPlist_PickupName AS OPlist_PickupNameCode
- FROM dbo.tb_ErpOrderProductList
- WHERE (OPlist_Type = ''2'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityTotakePieceMonthPieces')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityTotakePieceMonthPieces
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityTotakePieceMonthPieces]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_DoorCityTotakePieceMonthPieces]
- AS
- SELECT
- tb_ErpOrder.ID, dbo.tb_ErpOrder.Ord_DividedShop, dbo.tb_ErpOrder.Ord_Type, dbo.tb_ErpOrderProductList.ID AS TPID,
- dbo.tb_ErpOrder.Ord_Number, dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrderDigital.Ordv_DesignerName) AS 设计师,
- OPlist_ProdNumber,
- OPlist_ProdName AS 产品名称,
- OPlist_Class,
- (select Sc_ClassName from tb_ErpSystemCategory where Sc_ClassCode = OPlist_Class) AS 商品类别,
- dbo.tb_ErpOrderProductList.OPlist_ProdQuantity AS 数量, dbo.tb_ErpOrderProductList.OPlist_CostPrice AS 制作费用,
- dbo.tb_ErpOrderProductList.OPlist_SendVendor AS 是否发出,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderProductList.OPlist_SendTime)) AS 发出日期,
- dbo.tb_ErpOrderProductList.OPlist_SendTime AS 发出日期查询,
- dbo.fn_CheckProductCompletedStatus(dbo.tb_ErpOrderProductList.OPlist_CompletedStatus) AS 是否完成,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderProductList.OPlist_CompletedTime)) AS 完成日期,
- dbo.tb_ErpOrderProductList.OPlist_CompletedTime AS 完成日期查询,
- (select Count(ID) from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber AND OPlist_Type = ''2'') AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
- dbo.tb_ErpOrderProductList ON
- dbo.tb_ErpOrderProductList.OPlist_ViceNumber = dbo.tb_ErpOrderDigital.Ordv_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrderProductList.OPlist_Type = ''2'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityTotakePieceMonthPiecesNotBack')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityTotakePieceMonthPiecesNotBack
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityTotakePieceMonthPiecesNotBack]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_DoorCityTotakePieceMonthPiecesNotBack]
- AS
- SELECT
- tb_ErpOrder.ID, dbo.tb_ErpOrder.Ord_DividedShop, dbo.tb_ErpOrder.Ord_Type,tb_ErpOrderProductList_1.ID AS PPID, dbo.tb_ErpOrder.Ord_Number,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- tb_ErpOrderProductList_1.OPlist_ProdNumber, tb_ErpOrderProductList_1.OPlist_ProdName AS 产品名称,
- tb_ErpOrderProductList_1.OPlist_Class,
- (SELECT Sc_ClassName
- FROM dbo.tb_ErpSystemCategory
- WHERE (Sc_ClassCode = tb_ErpOrderProductList_1.OPlist_Class)) AS 商品类别,
- tb_ErpOrderProductList_1.OPlist_ProdQuantity AS 数量, tb_ErpOrderProductList_1.OPlist_CostPrice AS 制作费用,
- tb_ErpOrderProductList_1.OPlist_SendVendor AS 是否发出,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(tb_ErpOrderProductList_1.OPlist_SendTime)) AS 发出日期,
- tb_ErpOrderProductList_1.OPlist_SendTime AS 发出日期查询,
- dbo.fn_CheckProductCompletedStatus(tb_ErpOrderProductList_1.OPlist_CompletedStatus) AS 是否完成,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(tb_ErpOrderProductList_1.OPlist_CompletedTime)) AS 完成日期,
- (SELECT COUNT(ID) AS Expr1 FROM dbo.tb_ErpOrderProductList
- WHERE (OPlist_ViceNumber = dbo.tb_ErpOrderDigital.Ordv_ViceNumber) AND (OPlist_Type = ''2'')) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
- dbo.tb_ErpOrderProductList AS tb_ErpOrderProductList_1 ON
- tb_ErpOrderProductList_1.OPlist_ViceNumber = dbo.tb_ErpOrderDigital.Ordv_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (tb_ErpOrderProductList_1.OPlist_Type = ''2'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_DoorCityTotakePieceMonthReworkStatistic')
- BEGIN
- DROP VIEW [dbo].BView_DoorCityTotakePieceMonthReworkStatistic
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_DoorCityTotakePieceMonthReworkStatistic]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_DoorCityTotakePieceMonthReworkStatistic]
- AS
- SELECT
- tb_ErpOrder.ID, dbo.tb_ErpOrder.Ord_DividedShop, dbo.tb_ErpOrder.Ord_Type, tb_ErpOrderProductList_1.ID AS PPID,
- dbo.tb_ErpOrder.Ord_Number, dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- tb_ErpOrderProductList_1.OPlist_ProdNumber, tb_ErpOrderProductList_1.OPlist_ProdName AS 产品名称,
- tb_ErpOrderProductList_1.OPlist_Class,
- (SELECT Sc_ClassName FROM dbo.tb_ErpSystemCategory WHERE (Sc_ClassCode = tb_ErpOrderProductList_1.OPlist_Class)) AS 商品类别,
- tb_ErpOrderProductList_1.OPlist_ProdQuantity AS 数量, tb_ErpOrderProductList_1.OPlist_SendVendor AS 是否发出,
- dbo.fn_CheckProductReworkStatus(tb_ErpOrderProductList_1.OPlist_ReworkStatus)
- + CASE OPlist_ReworkRemark WHEN '''' THEN '''' ELSE ''/['' + OPlist_ReworkRemark + '']'' END AS 是否返工,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(tb_ErpOrderProductList_1.OPlist_ReworkTime)) AS 返工日期,
- tb_ErpOrderProductList_1.OPlist_ReworkTime AS 返工日期查询,
- dbo.fn_CheckProductCompletedStatus(tb_ErpOrderProductList_1.OPlist_CompletedStatus) AS 是否完成,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(tb_ErpOrderProductList_1.OPlist_CompletedTime)) AS 完成日期,
- (SELECT COUNT(ID) AS Expr1 FROM dbo.tb_ErpOrderProductList
- WHERE (OPlist_ViceNumber = dbo.tb_ErpOrderDigital.Ordv_ViceNumber) AND (OPlist_Type = ''2'')) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
- dbo.tb_ErpOrderProductList AS tb_ErpOrderProductList_1 ON
- tb_ErpOrderProductList_1.OPlist_ViceNumber = dbo.tb_ErpOrderDigital.Ordv_ViceNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (tb_ErpOrderProductList_1.OPlist_Type = ''2'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_IntentClientGroup')
- BEGIN
- DROP VIEW [dbo].BView_IntentClientGroup
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_IntentClientGroup]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_IntentClientGroup]
- AS
- SELECT
- GP_CustomerGroupID,
- GP_OrderNumber,
- GP_GroupType,
- case when isnull((select Ord_SinceOrderNumber from tb_ErpOrder where Ord_Number = GP_OrderNumber),'''') = '''' then GP_OrderNumber else (select Ord_SinceOrderNumber from tb_ErpOrder where Ord_Number = GP_OrderNumber) end as 订单号,
- Cus_Name AS 客户姓名,
- Cus_Name_py,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- dbo.fn_CheckClientIntentType(GP_CustomerType) AS 客户意向类型,
- dbo.fn_CheckDateTime(GP_CreateDatetime) AS 下单时间
- from tempTB_AggregationCustomer
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkBootDivision_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkBootDivision_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkBootDivision_No]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_MyWorkBootDivision_No]
- AS
- SELECT
- tb_ErpOrder.ID,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationBootDivision AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime)) AS 工作时间,
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationBootDivision = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus = ''0'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkBootDivision_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkBootDivision_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkBootDivision_Ok]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkBootDivision_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrdersPhotography.Ordpg_BootDivision AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime)) AS 工作时间,
- dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_BootDivision = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkClothing_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkClothing_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkClothing_No]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkClothing_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpOrderDigital.Ordv_ReservationClothingName AS 员工编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationClothingTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationClothingTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ReservationClothingName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_ClothingStatus = ''0'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkClothing_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkClothing_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkClothing_Ok]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkClothing_Ok]
- AS
- SELECT
- tb_ErpOrder.ID,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpOrderDigital.Ordv_ClothingName AS 员工编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ClothingTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_ClothingTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ClothingName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_ClothingStatus = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkDesigner_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkDesigner_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkDesigner_No]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkDesigner_No]
- AS
- SELECT
- tb_ErpOrder.ID,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ReservationDesignerName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_DesignerStatus IN (''0'', ''1''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkDesigner_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkDesigner_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkDesigner_Ok]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_MyWorkDesigner_Ok]
- AS
- SELECT
- tb_ErpOrder.ID,
- CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrderDigital.Ordv_DesignerName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_DesignerTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_DesignerTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_DesignerName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_DesignerStatus = ''2'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkEarlyRepairName_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkEarlyRepairName_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkEarlyRepairName_No]'))
- EXEC dbo.sp_executesql @statement = N'create VIEW [dbo].[BView_MyWorkEarlyRepairName_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号, dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ReservationEarlyRepairName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus IN (''0'', ''1''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkEarlyRepairName_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkEarlyRepairName_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkEarlyRepairName_Ok]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_MyWorkEarlyRepairName_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrderDigital.Ordv_EarlyRepairName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_EarlyRepairTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_EarlyRepairTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_EarlyRepairName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_EarlyRepairStatus = ''2'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkFilmSelection_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkFilmSelection_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkFilmSelection_No]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_MyWorkFilmSelection_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ReservationFilmSelectionName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus = ''0'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkFilmSelection_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkFilmSelection_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkFilmSelection_Ok]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_MyWorkFilmSelection_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrderDigital.Ordv_FilmSelectionName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_FilmSelectionTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_FilmSelectionTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_FilmSelectionName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_FilmSelectionStatus = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkLookDesign_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkLookDesign_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkLookDesign_No]'))
- EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[BView_MyWorkLookDesign_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号, dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ReservationLookDesignName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus IN (''0'', ''2'', ''3'', ''4''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkLookDesign_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkLookDesign_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkLookDesign_Ok]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkLookDesign_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号, dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrderDigital.Ordv_LookDesignName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_LookDesignTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_LookDesignTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_LookDesignName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_LookDesignStatus = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkMakeupArtist_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkMakeupArtist_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkMakeupArtist_No]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkMakeupArtist_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名, dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupArtist AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime)) AS 工作时间,
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupArtist = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus = ''0'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkMakeupArtist_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkMakeupArtist_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkMakeupArtist_Ok]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkMakeupArtist_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名, dbo.tb_ErpOrdersPhotography.Ordpg_MakeupArtist AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime)) AS 工作时间,
- dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_MakeupArtist = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkMakeupAssistant_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkMakeupAssistant_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkMakeupAssistant_No]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkMakeupAssistant_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupAssistant AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime)) AS 工作时间,
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupAssistant = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus = ''0'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkMakeupAssistant_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkMakeupAssistant_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkMakeupAssistant_Ok]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkMakeupAssistant_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名, dbo.tb_ErpOrdersPhotography.Ordpg_MakeupArtist AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime)) AS 工作时间,
- dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_MakeupAssistant = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkPhotographyAssistant_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkPhotographyAssistant_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkPhotographyAssistant_No]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkPhotographyAssistant_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyAssistant AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime)) AS 工作时间,
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyAssistant = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER
- JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus = ''0'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkPhotographyAssistant_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkPhotographyAssistant_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkPhotographyAssistant_Ok]'))
- EXEC dbo.sp_executesql @statement = N'
- create VIEW [dbo].[BView_MyWorkPhotographyAssistant_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名, dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyAssistant AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime)) AS 工作时间,
- dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyAssistant = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkPhotographyName_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkPhotographyName_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkPhotographyName_No]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkPhotographyName_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime)) AS 工作时间,
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus = ''0'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkPhotographyName_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkPhotographyName_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkPhotographyName_Ok]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkPhotographyName_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber, dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名, dbo.tb_ErpOrdersPhotography.Ordpg_Photographer AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime)) AS 工作时间,
- dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrdersPhotography ON
- dbo.tb_ErpOrdersPhotography.Ordpg_Photographer = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrdersPhotography.Ordpg_PhotographyStatus = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkPickup_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkPickup_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkPickup_No]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkPickup_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderProductList.OPlist_ViceNumber, dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名, dbo.tb_ErpOrderProductList.OPlist_ReservationTakeName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderProductList.OPlist_ReservationTakeTime)) AS 工作时间,
- dbo.tb_ErpOrderProductList.OPlist_ReservationTakeTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderProductList ON
- dbo.tb_ErpOrderProductList.OPlist_ReservationTakeName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderProductList.OPlist_OrderNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderProductList.OPlist_PickupStatus = ''0'') AND (dbo.tb_ErpOrderProductList.OPlist_Type = ''2'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkPickup_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkPickup_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkPickup_Ok]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkPickup_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpOrderProductList.OPlist_ViceNumber, dbo.tb_ErpUser.User_DividedShop AS 分店编号,
- dbo.tb_ErpUser.User_Name AS 员工姓名, dbo.tb_ErpOrderProductList.OPlist_PickupName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderProductList.OPlist_PickupTime)) AS 工作时间,
- dbo.tb_ErpOrderProductList.OPlist_PickupTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderProductList ON
- dbo.tb_ErpOrderProductList.OPlist_PickupName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderProductList.OPlist_OrderNumber
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderProductList.OPlist_PickupStatus = ''1'') AND (dbo.tb_ErpOrderProductList.OPlist_Type = ''2'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkRefinement_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkRefinement_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkRefinement_No]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkRefinement_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号, dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_ReservationRefinementName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_RefinementStatus IN (''0'', ''1''))
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkRefinement_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkRefinement_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkRefinement_Ok]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkRefinement_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- dbo.tb_ErpUser.User_DividedShop AS 分店编号, dbo.tb_ErpUser.User_Name AS 员工姓名,
- dbo.tb_ErpOrderDigital.Ordv_RefinementName AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrderDigital.Ordv_RefinementTime)) AS 工作时间,
- dbo.tb_ErpOrderDigital.Ordv_RefinementTime AS 工作时间查询
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpOrderDigital ON
- dbo.tb_ErpOrderDigital.Ordv_RefinementName = dbo.tb_ErpUser.User_EmployeeID LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrderDigital.Ordv_RefinementStatus = ''2'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkService_No')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkService_No
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkService_No]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkService_No]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- tb1.User_DividedShop AS 分店编号, tb1.User_Name AS 员工姓名, tb1.Ws_Status, tb1.Ws_Serviceman AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(tb1.Ws_WeddingDate)) AS 工作时间,
- tb1.Ws_WeddingDate AS 工作时间查询
- FROM (SELECT dbo.tb_ErpWeddingService.Ws_Number, dbo.tb_ErpUser.User_DividedShop, dbo.tb_ErpUser.User_Name,
- dbo.tb_ErpWeddingService.Ws_WeddingDate, dbo.tb_ErpWeddingService.Ws_Status,
- dbo.tb_ErpWeddingService.Ws_Serviceman1 AS Ws_Serviceman
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpWeddingService ON
- dbo.tb_ErpWeddingService.Ws_Serviceman1 = dbo.tb_ErpUser.User_EmployeeID
- WHERE (dbo.tb_ErpWeddingService.Ws_Serviceman1 <> '''')
- UNION
- SELECT tb_ErpWeddingService_1.Ws_Number, tb_ErpUser_1.User_DividedShop, tb_ErpUser_1.User_Name,
- tb_ErpWeddingService_1.Ws_WeddingDate, tb_ErpWeddingService_1.Ws_Status,
- tb_ErpWeddingService_1.Ws_Serviceman2 AS Ws_Serviceman
- FROM dbo.tb_ErpUser AS tb_ErpUser_1 LEFT OUTER JOIN
- dbo.tb_ErpWeddingService AS tb_ErpWeddingService_1 ON
- tb_ErpWeddingService_1.Ws_Serviceman2 = tb_ErpUser_1.User_EmployeeID
- WHERE (tb_ErpWeddingService_1.Ws_Serviceman2 <> '''')) AS tb1 LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = tb1.Ws_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (tb1.Ws_Status = ''0'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_MyWorkService_Ok')
- BEGIN
- DROP VIEW [dbo].BView_MyWorkService_Ok
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_MyWorkService_Ok]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_MyWorkService_Ok]
- AS
- SELECT
- tb_ErpOrder.ID, CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- tb1.User_DividedShop AS 分店编号, tb1.User_Name AS 员工姓名, tb1.Ws_Status, tb1.Ws_Serviceman AS 员工编号,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(tb1.Ws_WeddingDate)) AS 工作时间,
- tb1.Ws_WeddingDate AS 工作时间查询
- FROM (SELECT dbo.tb_ErpWeddingService.Ws_Number, dbo.tb_ErpUser.User_DividedShop, dbo.tb_ErpUser.User_Name,
- dbo.tb_ErpWeddingService.Ws_WeddingDate, dbo.tb_ErpWeddingService.Ws_Status,
- dbo.tb_ErpWeddingService.Ws_Serviceman1 AS Ws_Serviceman
- FROM dbo.tb_ErpUser LEFT OUTER JOIN
- dbo.tb_ErpWeddingService ON
- dbo.tb_ErpWeddingService.Ws_Serviceman1 = dbo.tb_ErpUser.User_EmployeeID
- WHERE (dbo.tb_ErpWeddingService.Ws_Serviceman1 <> '''')
- UNION
- SELECT tb_ErpWeddingService_1.Ws_Number, tb_ErpUser_1.User_DividedShop, tb_ErpUser_1.User_Name,
- tb_ErpWeddingService_1.Ws_WeddingDate, tb_ErpWeddingService_1.Ws_Status,
- tb_ErpWeddingService_1.Ws_Serviceman2 AS Ws_Serviceman
- FROM dbo.tb_ErpUser AS tb_ErpUser_1 LEFT OUTER JOIN
- dbo.tb_ErpWeddingService AS tb_ErpWeddingService_1 ON
- tb_ErpWeddingService_1.Ws_Serviceman2 = tb_ErpUser_1.User_EmployeeID
- WHERE (tb_ErpWeddingService_1.Ws_Serviceman2 <> '''')) AS tb1 LEFT OUTER JOIN
- dbo.tb_ErpOrder ON dbo.tb_ErpOrder.Ord_Number = tb1.Ws_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (tb1.Ws_Status = ''1'')
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_OrderReport')
- BEGIN
- DROP VIEW [dbo].BView_OrderReport
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_OrderReport]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_OrderReport]
- AS
- SELECT tb_ErpOrder.ID,dbo.tb_ErpOrder.Ord_DividedShop, dbo.tb_ErpOrder.Ord_Number, tb_ErpOrderDigital_1.Ordv_ViceNumber,
- dbo.tb_ErpOrder.Ord_Class, Ord_Type, Ord_OrderClass,
- CASE Ord_SinceOrderNumber WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- [Age_String] AS 年龄,
- [Age_Day] AS 天,
- [Age_Year] AS 年,
- dbo.tb_ErpOrder.Ord_PhotographyCategory AS 套系类别,
- dbo.tb_ErpOrder.Ord_CustomerSource AS 客户来源,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_Photographer) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_Photographer!= '''' group by Ordpg_Photographer for xml path('''')),1,1,'''')) as 摄影师,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName(Ordpg_MakeupArtist) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_MakeupArtist!= '''' group by Ordpg_MakeupArtist for xml path('''')),1,1,'''')) as 化妆师,
- (select top 1 dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_PhotographyTime)) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyTime is not null order by Ordpg_PhotographyTime DESC) AS 拍摄时间,
- (case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''2'') > 0 then ''拍摄中''
- else case when (select Count(Ordpg_PhotographyStatus) from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber and Ordpg_PhotographyStatus = ''1'') > 0 then ''OK'' else ''未拍'' end end) AS 拍照状态,
- dbo.fn_CheckUserIDGetUserName(tb_ErpOrderDigital_1.Ordv_EarlyRepairName) AS 初修师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_EarlyRepairTime)) AS 初修时间,
- dbo.fn_CheckOrderEarlyRepairStatus(tb_ErpOrderDigital_1.Ordv_EarlyRepairStatus) AS 初修状态,
- dbo.fn_CheckUserIDGetUserName(tb_ErpOrderDigital_1.Ordv_FilmSelectionName) AS 选片师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_FilmSelectionTime)) AS 选片时间,
- dbo.fn_CheckOrderFilmSelectionStatus(tb_ErpOrderDigital_1.Ordv_FilmSelectionStatus) AS 选片状态,
- dbo.fn_CheckUserIDGetUserName(tb_ErpOrderDigital_1.Ordv_DesignerName) AS 设计师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(tb_ErpOrderDigital_1.Ordv_DesignerTime)) AS 设计时间,
- dbo.fn_CheckOrderDesignerStatus(tb_ErpOrderDigital_1.Ordv_DesignerStatus) AS 设计状态,
- dbo.fn_CheckUserIDGetUserName(tb_ErpOrderDigital_1.Ordv_RefinementName) AS 精修师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(tb_ErpOrderDigital_1.Ordv_RefinementTime)) AS 精修时间,
- dbo.fn_CheckOrderRefinementStatus(tb_ErpOrderDigital_1.Ordv_RefinementStatus) AS 精修状态,
- dbo.fn_CheckUserIDGetUserName(tb_ErpOrderDigital_1.Ordv_LookDesignName) AS 看设计师,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(tb_ErpOrderDigital_1.Ordv_LookDesignTime)) AS 看设计时间,
- dbo.fn_CheckOrderLookDesignStatus(tb_ErpOrderDigital_1.Ordv_LookDesignStatus) AS 看设计状态,
- tb_ErpOrderDigital_1.Ordv_LookDesignClaim AS 看设计要求,
- (case when (select count(OPlist_PickupStatus) from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type = ''2'' and OPlist_PickupStatus = ''0'') >0 then ''未取'' else ''OK'' end) AS 取件状态,
- (select top 1 dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_PickupTime)) from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type = ''2'' and OPlist_PickupTime != null order by OPlist_PickupTime) AS 取件日期,
- dbo.tb_ErpOrder.Ord_Remark AS 备注,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrder.Ord_CreateName) AS 录入员,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ord_CreateDateTime)) AS 下单日期,
- Ord_CreateDateTime AS 下单日期查询,
- (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital WHERE (Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM
- dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 ON dbo.tb_ErpOrder.Ord_Number = tb_ErpOrderDigital_1.Ordv_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- where Ord_Type <> ''3''
- '
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_OrderReport_Server')
- BEGIN
- DROP VIEW [dbo].BView_OrderReport_Server
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_OrderReport_Server]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[BView_OrderReport_Server]
- AS
- SELECT tb_ErpOrder.ID, dbo.tb_ErpOrder.Ord_DividedShop, dbo.tb_ErpOrder.Ord_Number, dbo.tb_ErpWeddingService.ID AS Ordv_ViceNumber,
- dbo.tb_ErpOrder.Ord_Class, dbo.tb_ErpOrder.Ord_Type,Ord_OrderClass, dbo.tb_ErpOrder.Ord_Number AS 订单号,
- dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
- Cus_Name AS 客户姓名,
- Cus_Name_py AS 客户拼音,
- Cus_Sex_cs AS 客户性别,
- Cus_Telephone AS 客户电话,
- [Age_String] AS 年龄,
- [Age_Day] AS 天,
- [Age_Year] AS 年,
- dbo.tb_ErpOrder.Ord_CustomerSource AS 客户来源,
- dbo.tb_ErpOrder.Ord_PhotographyCategory AS 套系类别,
- dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
- dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
- (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber = Ord_Number for xml path('''')),1,1,'''')) as 接单人,
- dbo.fn_ChineseToSpell((select stuff((select '',''+ dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,''''))) as 接单人拼音,
- dbo.tb_ErpWeddingService.Ws_ProdName AS 服务名称,
- dbo.tb_ErpWeddingService.Ws_ProdQuantity AS 数量,
- dbo.fn_CheckWeddingServiceStatus(dbo.tb_ErpWeddingService.Ws_Status) AS 服务状态,
- dbo.fn_CheckDateTime(dbo.tb_ErpWeddingService.Ws_WeddingDate) AS 服务时间,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpWeddingService.Ws_Serviceman1) AS 服务人员1,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpWeddingService.Ws_Serviceman2) AS 服务人员2,
- dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrder.Ord_CreateName) AS 录入员,
- dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrder.Ord_CreateDateTime)) AS 下单日期,
- dbo.tb_ErpOrder.Ord_CreateDateTime AS 下单日期查询,
- (SELECT COUNT(Ws_Number) AS Expr1 FROM dbo.tb_ErpWeddingService AS tb_ErpWeddingService_1 WHERE (Ws_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
- FROM dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpWeddingService ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpWeddingService.Ws_Number
- left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
- WHERE (dbo.tb_ErpOrder.Ord_Type IN (''3''))
- '
- GO
- -----胡工---
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_OrdersWageDigital')
- BEGIN
- DROP VIEW [dbo].View_OrdersWageDigital
- END
- GO
- create view View_OrdersWageDigital
- as
- select
- tb_ErpOrderDigital.Id
- , Ordv_Number
- ,Ordv_ViceNumber
- ,Ordv_DigitalNumber
- ,Ord_Number
- ,Ord_Type
- ,Ord_Class
- ,Ord_PhotographyCategory
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- ,(case when Ord_Type = '1' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else (select top 1 Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_Number = Ord_Number) end) as 拍摄名称
- ,(select Cus_Name from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as 客户名称
- ,(select Cus_Telephone from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as 客户电话
- ,Ordv_ClothingName as 礼服师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_ClothingName) as 礼服师
- ,Ordv_ClothingStatus as 礼服师状态
- ,Ordv_ClothingTime as 选衣时间
- , Ordv_FilmSelectionName as 选片师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_FilmSelectionName) as 选片师
- , Ordv_FilmSelectionStatus as 选片状态
- , Ordv_FilmSelectionTime as 选片时间
- , Ordv_EarlyRepairName as 初修师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_EarlyRepairName) as 初修师
- , Ordv_EarlyRepairStatus as 初修状态
- , Ordv_EarlyRepairTime as 初修时间
- , Ordv_RefinementName as 精修师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_RefinementName)as 精修师
- , Ordv_RefinementStatus as 精修状态
- , Ordv_RefinementTime as 精修时间
- ,Ordv_LookDesignName as 看设计师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_LookDesignName) as 看设计师
- ,Ordv_LookDesignStatus as 看设计状态
- ,Ordv_LookDesignTime as 看设计时间
- ,Ordv_DesignerName as 设计师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_DesignerName) as 设计师
- ,Ordv_DesignerStatus as 设计状态
- , Ordv_DesignerTime as 设计时间
- ,(case when (select Count(*) from (select [OPlist_PickupStatus] from [tb_ErpOrderProductList] where [OPlist_ViceNumber]=Ordv_ViceNumber and OPlist_Type = '2' and [OPlist_PickupStatus] = '0') as ta)>0 then '未取' else 'OK' end) AS 取件状态
- ,(select top 1 OPlist_PickupTime from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type = '2' and OPlist_PickupTime is not null order by OPlist_PickupTime) AS 取件日期
- from tb_ErpOrderDigital
- left join tb_ErpOrder on tb_ErpOrderDigital.Ordv_Number=tb_ErpOrder.Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_OrdersWagePhotography')
- BEGIN
- DROP VIEW [dbo].View_OrdersWagePhotography
- END
- GO
- create view View_OrdersWagePhotography
- as
- SELECT tb_ErpOrdersPhotography.ID
- ,Ordpg_Number
- ,Ordpg_ViceNumber
- ,Ord_Type
- ,Ord_Class
- ,Ord_PhotographyCategory
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- ,(select Cus_Name from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as 客户名称
- ,(select Cus_Telephone from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as 客户电话
- ,Ordpg_Sights as 拍摄名称
- --,Ordpg_SightsLevel
- --,[dbo].[fn_GetClassCodeToName](Ordpg_SightsLevel,Ordpg_SightsLevel) as Sc_ClassName
- ,Ordpg_SightsType as 景点类别
- ,Ordpg_ApparelQuantity as 服装套数
- ,Ordpg_Photographer as 摄影师ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_Photographer) as 摄影师名称
- ,Ordpg_PhotographyTime as 拍摄时间
- ,Ordpg_PhotographyStatus as 拍摄状态
- --,[dbo].fn_CheckOrderPhotographyStatus(Ordpg_PhotographyStatus) as OrdPg_PhotographyStatusName
- ,Ordpg_PhotographyAssistant as 摄影助理ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_PhotographyAssistant) as 摄影助理名称
- ,Ordpg_MakeupArtist as 化妆师ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_MakeupArtist) as 化妆师名称
- ,Ordpg_MakeupAssistant as 化妆助理ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_MakeupAssistant) as 化妆助理名称
- ,Ordpg_BootDivision as 引导师ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_BootDivision) as 引导师名称
- --,Ordpg_ReservationPhotographyName
- --,Ordpg_ReservationPhotographyTime
- --,Ordpg_ReservationPhotographyAssistant
- --,Ordpg_ReservationMakeupArtist
- --,Ordpg_ReservationMakeupAssistant
- --,Ordpg_ReservationBootDivision
- FROM tb_ErpOrdersPhotography
- left join tb_ErpOrder on tb_ErpOrdersPhotography.Ordpg_Number=tb_ErpOrder.Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_ErpSatisfactionReturningMattersSet')
- BEGIN
- DROP VIEW [dbo].View_ErpSatisfactionReturningMattersSet
- END
- GO
- create view View_ErpSatisfactionReturningMattersSet
- as
- SELECT tb_ErpSatisfactionReturningMattersSet.ID
- ,Sfrms_SurveySetID
- ,Sfrms_Contents
- ,Sfrms_EnableStatus
- ,Sfrms_CreateTime
- ,Sfrms_CreateName
- ,Sfrms_UpdateTime
- ,Sfrms_UpdateName
- ,Sfss_Name
- ,(CASE sfrms_EnableStatus WHEN '0' THEN '启用' ELSE '不启用' END ) as sfrms_EnableStatusName
- FROM tb_ErpSatisfactionReturningMattersSet
- left join tb_ErpSatisfactionSurveySet on tb_ErpSatisfactionReturningMattersSet.Sfrms_SurveySetID=tb_ErpSatisfactionSurveySet.ID
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_ErpSatisfactionSurvey')
- BEGIN
- DROP VIEW [dbo].View_ErpSatisfactionSurvey
- END
- GO
- create view View_ErpSatisfactionSurvey
- as
- SELECT tb_ErpSatisfactionSurvey.ID
- ,Sfs_OrderNumber
- ,Sfs_OrderNumberDeputy
- ,Sfs_EmployeeID
- ,(select [User_Name] from tb_ErpUser where Sfs_EmployeeID=User_EmployeeID) as Sfs_EmployeeName
- ,Sfs_Type
- ,Sfs_SurveySetID
- ,Sfss_Name as Sfs_SurveySetName
- ,Sfs_ReturningMattersSetID
- ,Sfrms_Contents
- ,Sfs_RatingSetID
- ,Sfrs_Name as Sfs_RatingSetName
- ,Sfs_Remark
- ,Sfs_CreateName as Sfs_CreateNameID
- ,(select [User_Name] from tb_ErpUser where Sfs_CreateName=User_EmployeeID) as Sfs_CreateName
- ,Sfs_CreateTime
- ,Sfs_UpdateTime
- ,Sfs_UpdateName as Sfs_UpdateNameID
- ,(select [User_Name] from tb_ErpUser where Sfs_UpdateName=User_EmployeeID) as Sfs_UpdateName
- ,Ord_CustomerName1
- ,Ord_CustomerSex1
- ,Ord_CustomerTelephone1
- ,Sfrs_Scores
- ,(select count(id) from tb_ErpSatisfactionReturningMattersSet where Sfrms_SurveySetID=Sfs_SurveySetID) as SatisfactionReturningMattersSetCount
- FROM tb_ErpSatisfactionSurvey
- left join tb_ErpSatisfactionSurveySet on Sfs_SurveySetID=tb_ErpSatisfactionSurveySet.ID
- left join tb_ErpSatisfactionReturningMattersSet on Sfs_ReturningMattersSetID=tb_ErpSatisfactionReturningMattersSet.ID
- left join tb_ErpSatisfactionRatingSet on Sfs_RatingSetID=tb_ErpSatisfactionRatingSet.ID
- left join View_Customer_PaymentOrdersTwo on Sfs_OrderNumber=Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_OtherCustomers')
- BEGIN
- DROP VIEW [dbo].View_OtherCustomers
- END
- GO
- Create View View_OtherCustomers
- as
- SELECT distinct
- Tsorder_CustomerNumber
- , [Tsorder_CustomerName]
- ,[Tsorder_Telephone]
- ,Cus_NamePinyin
- FROM Vw_TwoSalesOrder
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_Customer_PaymentOrdersTwo')
- BEGIN
- DROP VIEW [dbo].View_Customer_PaymentOrdersTwo
- END
- GO
- Create view [dbo].[View_Customer_PaymentOrdersTwo]
- as
- select ID,
- Ord_Number,
- Ord_DividedShop,
- Ord_Type,
- Ord_SeriesName,
- Ord_SeriesPrice,
- Ord_Class,
- Ord_CustomerListID,
- Ord_MainContact,
- (select Cus_Name from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as Ord_CustomerName1,
- (select Cus_Sex from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as Ord_CustomerSex1,
- (select Cus_Telephone from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) as Ord_CustomerTelephone1,
- (CASE Ord_Type
- WHEN '0' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- WHEN '1' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- ELSE '' END ) as Ord_CustomerListID2 ,
- (select Cus_Name from tb_ErpCustomer where (CASE Ord_Type
- WHEN '0' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- WHEN '1' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- ELSE '' END )=Cus_CustomerNumber) as Ord_CustomerName2,
- (select Cus_Telephone from tb_ErpCustomer where (CASE Ord_Type
- WHEN '0' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- WHEN '1' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- ELSE '' END )=Cus_CustomerNumber) as Ord_CustomerTelephone2,
- (select stuff((select ','+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('')),1,1,'')) as Ord_OrdersPerson,
- (select [Cus_NamePinyin] from tb_ErpCustomer where Ord_MainContact=Cus_CustomerNumber) AS name1,
- ((select [Cus_NamePinyin] from tb_ErpCustomer where (CASE Ord_Type
- WHEN '0' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- WHEN '1' THEN ( select substring(Ord_CustomerListID,charindex(',',Ord_CustomerListID+',')+1,charindex(',',Ord_CustomerListID+',')-1))
- ELSE '' END )=Cus_CustomerNumber)) AS name2,
- (select stuff((select ','+ OrdPe_OrdersPerson from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('')),1,1,'')) as Ord_OrdersPersonID,
- Ord_CreateDatetime
- ,( SELECT count(id) FROM tb_ErpOrderProductList where OPlist_OrderNumber=Ord_Number and OPlist_PickupStatus=0) as PickupStatusCount
- from tb_ErpOrder
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_ErpPieceCommissionRecords')
- BEGIN
- DROP VIEW [dbo].View_ErpPieceCommissionRecords
- END
- GO
- Create view [dbo].[View_ErpPieceCommissionRecords]
- as
- SELECT tb_ErpPieceCommissionRecords.ID
- ,Pcr_OrderNumber
- ,Pcr_DigitalDivision
- ,Pcr_Date
- ,Pcr_CompletionContents
- ,Pcr_Quantity
- ,Pcr_CreateTime
- ,Pcr_EntryPeople
- ,Pcr_Type
- ,(select [User_Name] from tb_ErpUser where Pcr_DigitalDivision=User_EmployeeID) as Pcr_DigitalDivisionName
- ,[dbo].[fn_GetClassCodeToName](Pcr_CompletionContents,Pcr_CompletionContents) as Pcr_CompletionContentsName
- ,(select [User_Name] from tb_ErpUser where Pcr_EntryPeople=User_EmployeeID) as Pcr_EntryPeopleName
- ,Ord_Type
- ,Ord_Class
- ,(select Cus_Name from tempTB_AggregationCustomer where Pcr_OrderNumber=GP_OrderNumber) as Cus_Name
- ,(select Cus_Telephone from tempTB_AggregationCustomer where Pcr_OrderNumber=GP_OrderNumber) as Cus_Telephone
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- FROM tb_ErpPieceCommissionRecords
- left join tb_ErpOrder on tb_ErpPieceCommissionRecords.Pcr_OrderNumber=tb_ErpOrder.Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_OrdersWagePaymentRecords')
- BEGIN
- DROP VIEW [dbo].View_OrdersWagePaymentRecords
- END
- GO
- Create VIEW [dbo].[View_OrdersWagePaymentRecords]
- AS
- SELECT View_ErpPayment.ID
- ,Pay_OrdNumber
- ,Pay_AmountOf
- ,Pay_OpenSingle
- ,Pay_ThePayee
- ,Pay_PaymentMethod
- ,Pay_OrdersLocation
- ,Pay_ReceivableProject
- ,Pay_CustomNumber
- ,Pay_Remark
- ,convert(varchar(10),Pay_CreateDatetime,120) as Pay_CreateDatetime
- ,Pay_Category
- ,Pay_TwoPinsCategory
- ,Pay_UserName
- ,Pay_ThePayeeName
- ,Pay_PaymentMethodName
- ,Pay_TwoPinsCategoryName
- ,Pay_FinancialAuditdPeople
- ,Pay_FinancialAudit
- ,Pay_FinancialAuditdPeopleName
- ,Pay_ShootingName
- ,Ord_Number
- ,Ord_DividedShop
- ,Ord_Type
- ,Ord_Class
- , Ord_CustomerName1
- ,name1
- ,Ord_CustomerTelephone1
- ,(select Tsorder_Name from tb_ErpTwoSalesOrder where Pay_OrdNumber= Tsorder_Number) as Tsorder_Name
- ,(select Cus_Name from View_DressSaleRentalOrder where Pay_OrdNumber=Dsro_Number) as Cus_Name
- ,(select Tsorder_CustomerName from View_TwoSalesOrder where Pay_OrdNumber= Tsorder_Number) as Tsorder_CustomerName
- ,Ord_CreateDatetime
- ,(select OrdPe_Type from tb_ErpOrdersPerson where OrdPe_OrderNumber=Pay_OrdNumber and OrdPe_OrdersPerson=Pay_OpenSingle) as OrdPe_Type
- ,Ord_SeriesName
- FROM View_ErpPayment
- left join View_Customer_PaymentOrdersTwo on View_ErpPayment.Pay_OrdNumber=View_Customer_PaymentOrdersTwo.Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_ErpSatisfactionSurvey')
- BEGIN
- DROP VIEW [dbo].View_ErpSatisfactionSurvey
- END
- GO
- Create view [dbo].[View_ErpSatisfactionSurvey]
- as
- SELECT tb_ErpSatisfactionSurvey.ID
- ,Sfs_OrderNumber
- ,Sfs_OrderNumberDeputy
- ,Sfs_EmployeeID
- ,(select User_Name from tb_ErpUser where Sfs_EmployeeID=User_EmployeeID) as Sfs_EmployeeName
- ,Sfs_Type
- ,Sfs_SurveySetID
- ,Sfss_Name as Sfs_SurveySetName
- ,Sfs_ReturningMattersSetID
- ,Sfrms_Contents
- ,Sfs_RatingSetID
- ,Sfrs_Name as Sfs_RatingSetName
- ,Sfs_Remark
- ,Sfs_CreateName as Sfs_CreateNameID
- ,(select User_Name from tb_ErpUser where Sfs_CreateName=User_EmployeeID) as Sfs_CreateName
- ,Sfs_CreateTime
- ,Sfs_UpdateTime
- ,Sfs_UpdateName as Sfs_UpdateNameID
- ,(select User_Name from tb_ErpUser where Sfs_UpdateName=User_EmployeeID) as Sfs_UpdateName
- , Ord_CustomerName1
- ,name1
- ,Ord_CustomerTelephone1
- ,Sfrs_Scores
- ,(select count(id) from tb_ErpSatisfactionReturningMattersSet where Sfrms_SurveySetID=Sfs_SurveySetID) as SatisfactionReturningMattersSetCount
- FROM tb_ErpSatisfactionSurvey
- left join tb_ErpSatisfactionSurveySet on Sfs_SurveySetID=tb_ErpSatisfactionSurveySet.ID
- left join tb_ErpSatisfactionReturningMattersSet on Sfs_ReturningMattersSetID=tb_ErpSatisfactionReturningMattersSet.ID
- left join tb_ErpSatisfactionRatingSet on Sfs_RatingSetID=tb_ErpSatisfactionRatingSet.ID
- left join View_Customer_PaymentOrdersTwo on Sfs_OrderNumber=Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_OrdersWageDigital')
- BEGIN
- DROP VIEW [dbo].View_OrdersWageDigital
- END
- GO
- Create view [dbo].[View_OrdersWageDigital]
- as
- select
- tb_ErpOrderDigital.Id
- , Ordv_Number
- ,Ordv_ViceNumber
- ,Ordv_DigitalNumber
- ,Ord_Number
- ,Ord_Type
- ,Ord_Class
- ,Ord_PhotographyCategory
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- ,(case when Ord_Type = '1' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else (select top 1 Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_Number = Ord_Number) end) as 拍摄名称
- ,(select Cus_Name from tempTB_AggregationCustomer where Ord_Number=GP_OrderNumber) as 客户名称
- ,(select Cus_Telephone from tempTB_AggregationCustomer where Ord_Number=GP_OrderNumber) as 客户电话
- ,Ordv_ClothingName as 礼服师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_ClothingName) as 礼服师
- ,Ordv_ClothingStatus as 礼服师状态
- ,Ordv_ClothingTime as 选衣时间
- , Ordv_FilmSelectionName as 选片师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_FilmSelectionName) as 选片师
- , Ordv_FilmSelectionStatus as 选片状态
- , Ordv_FilmSelectionTime as 选片时间
- , Ordv_EarlyRepairName as 初修师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_EarlyRepairName) as 初修师
- , Ordv_EarlyRepairStatus as 初修状态
- , Ordv_EarlyRepairTime as 初修时间
- , Ordv_RefinementName as 精修师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_RefinementName)as 精修师
- , Ordv_RefinementStatus as 精修状态
- , Ordv_RefinementTime as 精修时间
- ,Ordv_LookDesignName as 看设计师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_LookDesignName) as 看设计师
- ,Ordv_LookDesignStatus as 看设计状态
- ,Ordv_LookDesignTime as 看设计时间
- ,Ordv_DesignerName as 设计师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_DesignerName) as 设计师
- ,Ordv_DesignerStatus as 设计状态
- , Ordv_DesignerTime as 设计时间
- ,(case when (select Count(*) from (select [OPlist_PickupStatus] from [tb_ErpOrderProductList] where [OPlist_ViceNumber]=Ordv_ViceNumber and OPlist_Type = '2' and [OPlist_PickupStatus] = '0') as ta)>0 then '未取' else 'OK' end) AS 取件状态
- ,(select top 1 OPlist_PickupTime from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type = '2' and OPlist_PickupTime is not null order by OPlist_PickupTime) AS 取件日期
- ,(case Ord_Type
- when 0 then (select count(id) as id from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- when 1 then (select count(id) as id from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- when 2 then (select count(id) as id from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- else '' end) as 未拍个数
- from tb_ErpOrderDigital
- left join tb_ErpOrder on tb_ErpOrderDigital.Ordv_Number=tb_ErpOrder.Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'View_OrdersWagePhotography')
- BEGIN
- DROP VIEW [dbo].View_OrdersWagePhotography
- END
- GO
- Create view [dbo].[View_OrdersWagePhotography]
- as
- SELECT tb_ErpOrdersPhotography.ID
- ,Ordpg_Number
- ,Ordpg_ViceNumber
- ,Ord_Type
- ,Ord_Class
- ,Ord_PhotographyCategory
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- ,(select Cus_Name from tempTB_AggregationCustomer where Ord_Number=GP_OrderNumber) as 客户名称
- ,(select Cus_Telephone from tempTB_AggregationCustomer where Ord_Number=GP_OrderNumber) as 客户电话
- ,Ordpg_Sights as 拍摄名称
- --,Ordpg_SightsLevel
- --,[dbo].[fn_GetClassCodeToName](Ordpg_SightsLevel,Ordpg_SightsLevel) as Sc_ClassName
- ,Ordpg_SightsType as 景点类别
- ,Ordpg_ApparelQuantity as 服装套数
- ,Ordpg_Photographer as 摄影师ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_Photographer) as 摄影师名称
- ,Ordpg_PhotographyTime as 拍摄时间
- ,Ordpg_PhotographyStatus as 拍摄状态
- --,[dbo].fn_CheckOrderPhotographyStatus(Ordpg_PhotographyStatus) as OrdPg_PhotographyStatusName
- ,Ordpg_PhotographyAssistant as 摄影助理ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_PhotographyAssistant) as 摄影助理名称
- ,Ordpg_MakeupArtist as 化妆师ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_MakeupArtist) as 化妆师名称
- ,Ordpg_MakeupAssistant as 化妆助理ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_MakeupAssistant) as 化妆助理名称
- ,Ordpg_BootDivision as 引导师ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_BootDivision) as 引导师名称
- --,Ordpg_ReservationPhotographyName
- --,Ordpg_ReservationPhotographyTime
- --,Ordpg_ReservationPhotographyAssistant
- --,Ordpg_ReservationMakeupArtist
- --,Ordpg_ReservationMakeupAssistant
- --,Ordpg_ReservationBootDivision
- FROM tb_ErpOrdersPhotography
- left join tb_ErpOrder on tb_ErpOrdersPhotography.Ordpg_Number=tb_ErpOrder.Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_Customer_PaymentOrders')
- BEGIN
- DROP VIEW [dbo].Vw_Customer_PaymentOrders
- END
- GO
- Create view [dbo].Vw_Customer_PaymentOrders
- as
- select
- tb_ErpOrder.ID
- ,Ord_Number
- ,Ord_DividedShop
- ,Ord_Type
- ,Ord_PhotographyCategory
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- ,Ord_Class
- ,GP_OrderNumber
- ,GP_CustomerGroupID
- ,Cus_Name
- ,Cus_Name_py
- ,Cus_Telephone
- ,M_Cus_CustomerNumber
- ,(select stuff((select ','+ OrdPe_OrdersPerson from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('')),1,1,'')) as Ord_OrdersPersonID
- ,(select stuff((select ','+dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('')),1,1,'')) as Ord_OrdersPerson
- ,Ord_CreateDatetime
- ,( SELECT count(id) FROM tb_ErpOrderProductList where OPlist_OrderNumber=Ord_Number and OPlist_PickupStatus=0) as PickupStatusCount
- from tb_ErpOrder
- left join tempTB_AggregationCustomer on Ord_Number=GP_OrderNumber
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_OrdersWagePaymentRecords')
- BEGIN
- DROP VIEW [dbo].Vw_OrdersWagePaymentRecords
- END
- GO
- Create VIEW [dbo].Vw_OrdersWagePaymentRecords
- AS
- SELECT View_ErpPayment.ID
- ,Pay_OrdNumber
- ,Pay_AmountOf
- ,Pay_OpenSingle
- ,Pay_ThePayee
- ,Pay_PaymentMethod
- ,Pay_OrdersLocation
- ,Pay_ReceivableProject
- ,Pay_CustomNumber
- ,Pay_Remark
- ,convert(varchar(10),Pay_CreateDatetime,120) as Pay_CreateDatetime
- ,Pay_Category
- ,Pay_TwoPinsCategory
- ,Pay_UserName
- ,Pay_ThePayeeName
- ,Pay_PaymentMethodName
- ,Pay_TwoPinsCategoryName
- ,Pay_FinancialAuditdPeople
- ,Pay_FinancialAudit
- ,Pay_FinancialAuditdPeopleName
- ,Pay_ShootingName
- ,Ord_Number
- ,Ord_DividedShop
- ,Ord_Type
- ,Ord_Class
- ,Cus_Name as Ord_CustomerName1
- ,Cus_Name_py
- ,Cus_Telephone
- ,(select Tsorder_Name from tb_ErpTwoSalesOrder where Pay_OrdNumber= Tsorder_Number) as Tsorder_Name
- ,(select Cus_Name from View_DressSaleRentalOrder where Pay_OrdNumber=Dsro_Number) as Cus_Name
- ,(select Tsorder_CustomerName from View_TwoSalesOrder where Pay_OrdNumber= Tsorder_Number) as Tsorder_CustomerName
- ,Ord_CreateDatetime
- ,(select OrdPe_Type from tb_ErpOrdersPerson where OrdPe_OrderNumber=Pay_OrdNumber and OrdPe_OrdersPerson=Pay_OpenSingle) as OrdPe_Type
- ,Ord_SeriesName
- ,Ord_PhotographyCategory
- FROM View_ErpPayment
- left join Vw_Customer_PaymentOrders on View_ErpPayment.Pay_OrdNumber=Vw_Customer_PaymentOrders.Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_ErpPieceCommissionRecords')
- BEGIN
- DROP VIEW [dbo].Vw_ErpPieceCommissionRecords
- END
- GO
- Create view [dbo].Vw_ErpPieceCommissionRecords
- as
- SELECT tb_ErpPieceCommissionRecords.ID
- ,Pcr_OrderNumber
- ,Pcr_DigitalDivision
- ,Pcr_Date
- ,Pcr_CompletionContents
- ,Pcr_Quantity
- ,Pcr_CreateTime
- ,Pcr_EntryPeople
- ,Pcr_Type
- ,(select [User_Name] from tb_ErpUser where Pcr_DigitalDivision=User_EmployeeID) as Pcr_DigitalDivisionName
- ,[dbo].[fn_GetClassCodeToName](Pcr_CompletionContents,Pcr_CompletionContents) as Pcr_CompletionContentsName
- ,(select [User_Name] from tb_ErpUser where Pcr_EntryPeople=User_EmployeeID) as Pcr_EntryPeopleName
- ,Ord_Type
- ,Ord_Class
- ,(select Cus_Name from tempTB_AggregationCustomer where Pcr_OrderNumber=GP_OrderNumber) as Cus_Name
- ,(select Cus_Telephone from tempTB_AggregationCustomer where Pcr_OrderNumber=GP_OrderNumber) as Cus_Telephone
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- ,Pcr_Quantity*(select Wcs_Percentage from tb_ErpWageCommissionSet where Pcr_CompletionContents=Wcs_TypeCode) as 总价格
- FROM tb_ErpPieceCommissionRecords
- left join tb_ErpOrder on tb_ErpPieceCommissionRecords.Pcr_OrderNumber=tb_ErpOrder.Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_ErpSatisfactionSurvey')
- BEGIN
- DROP VIEW [dbo].Vw_ErpSatisfactionSurvey
- END
- GO
- Create view [dbo].Vw_ErpSatisfactionSurvey
- as
- SELECT tb_ErpSatisfactionSurvey.ID
- ,Sfs_OrderNumber
- ,Sfs_OrderNumberDeputy
- ,Sfs_EmployeeID
- ,(select User_Name from tb_ErpUser where Sfs_EmployeeID=User_EmployeeID) as Sfs_EmployeeName
- ,Sfs_Type
- ,Sfs_SurveySetID
- ,Sfss_Name as Sfs_SurveySetName
- ,Sfs_ReturningMattersSetID
- ,Sfrms_Contents
- ,Sfs_RatingSetID
- ,Sfrs_Name as Sfs_RatingSetName
- ,Sfs_Remark
- ,Sfs_CreateName as Sfs_CreateNameID
- ,(select User_Name from tb_ErpUser where Sfs_CreateName=User_EmployeeID) as Sfs_CreateName
- ,Sfs_CreateTime
- ,Sfs_UpdateTime
- ,Sfs_UpdateName as Sfs_UpdateNameID
- ,(select User_Name from tb_ErpUser where Sfs_UpdateName=User_EmployeeID) as Sfs_UpdateName
- ,Cus_Name
- ,Cus_Name_py
- ,Cus_Telephone
- ,Sfrs_Scores
- ,(select count(id) from tb_ErpSatisfactionReturningMattersSet where Sfrms_SurveySetID=Sfs_SurveySetID) as SatisfactionReturningMattersSetCount
- FROM tb_ErpSatisfactionSurvey
- left join tb_ErpSatisfactionSurveySet on Sfs_SurveySetID=tb_ErpSatisfactionSurveySet.ID
- left join tb_ErpSatisfactionReturningMattersSet on Sfs_ReturningMattersSetID=tb_ErpSatisfactionReturningMattersSet.ID
- left join tb_ErpSatisfactionRatingSet on Sfs_RatingSetID=tb_ErpSatisfactionRatingSet.ID
- left join Vw_Customer_PaymentOrders on Sfs_OrderNumber=Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_OrdersWageDigital')
- BEGIN
- DROP VIEW [dbo].Vw_OrdersWageDigital
- END
- GO
- Create view [dbo].Vw_OrdersWageDigital
- as
- select
- tb_ErpOrderDigital.Id
- , Ordv_Number
- ,Ordv_ViceNumber
- ,Ordv_DigitalNumber
- ,Ord_Number
- ,Ord_Type
- ,Ord_Class
- ,Ord_PhotographyCategory
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- ,(case when Ord_Type = '1' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else (select top 1 Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_Number = Ord_Number) end) as 拍摄名称
- ,(select Cus_Name from tempTB_AggregationCustomer where Ord_Number=GP_OrderNumber) as 客户名称
- ,(select Cus_Telephone from tempTB_AggregationCustomer where Ord_Number=GP_OrderNumber) as 客户电话
- ,Ordv_ClothingName as 礼服师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_ClothingName) as 礼服师
- ,Ordv_ClothingStatus as 礼服师状态
- ,Ordv_ClothingTime as 选衣时间
- , Ordv_FilmSelectionName as 选片师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_FilmSelectionName) as 选片师
- , Ordv_FilmSelectionStatus as 选片状态
- , Ordv_FilmSelectionTime as 选片时间
- , Ordv_EarlyRepairName as 初修师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_EarlyRepairName) as 初修师
- , Ordv_EarlyRepairStatus as 初修状态
- , Ordv_EarlyRepairTime as 初修时间
- , Ordv_RefinementName as 精修师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_RefinementName)as 精修师
- , Ordv_RefinementStatus as 精修状态
- , Ordv_RefinementTime as 精修时间
- ,Ordv_LookDesignName as 看设计师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_LookDesignName) as 看设计师
- ,Ordv_LookDesignStatus as 看设计状态
- ,Ordv_LookDesignTime as 看设计时间
- ,Ordv_DesignerName as 设计师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_DesignerName) as 设计师
- ,Ordv_DesignerStatus as 设计状态
- , Ordv_DesignerTime as 设计时间
- ,(case when (select Count(*) from (select [OPlist_PickupStatus] from [tb_ErpOrderProductList] where [OPlist_ViceNumber]=Ordv_ViceNumber and OPlist_Type = '2' and [OPlist_PickupStatus] = '0') as ta)>0 then '未取' else 'OK' end) AS 取件状态
- ,(select top 1 OPlist_PickupTime from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type = '2' and OPlist_PickupTime is not null order by OPlist_PickupTime) AS 取件日期
- from tb_ErpOrderDigital
- left join tb_ErpOrder on tb_ErpOrderDigital.Ordv_Number=tb_ErpOrder.Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_OrdersWagePhotography')
- BEGIN
- DROP VIEW [dbo].Vw_OrdersWagePhotography
- END
- GO
- Create view [dbo].Vw_OrdersWagePhotography
- as
- SELECT tb_ErpOrdersPhotography.ID
- ,Ordpg_Number
- ,Ordpg_ViceNumber
- ,Ord_Type
- ,Ord_Class
- ,Ord_PhotographyCategory
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- ,(select Cus_Name from tempTB_AggregationCustomer where Ord_Number=GP_OrderNumber) as 客户名称
- ,(select Cus_Telephone from tempTB_AggregationCustomer where Ord_Number=GP_OrderNumber) as 客户电话
- ,Ordpg_Sights as 拍摄名称
- --,Ordpg_SightsLevel
- --,[dbo].[fn_GetClassCodeToName](Ordpg_SightsLevel,Ordpg_SightsLevel) as Sc_ClassName
- ,Ordpg_SightsType as 景点类别
- ,Ordpg_ApparelQuantity as 服装套数
- ,Ordpg_Photographer as 摄影师ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_Photographer) as 摄影师名称
- ,Ordpg_PhotographyTime as 拍摄时间
- ,Ordpg_PhotographyStatus as 拍摄状态
- --,[dbo].fn_CheckOrderPhotographyStatus(Ordpg_PhotographyStatus) as OrdPg_PhotographyStatusName
- ,Ordpg_PhotographyAssistant as 摄影助理ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_PhotographyAssistant) as 摄影助理名称
- ,Ordpg_MakeupArtist as 化妆师ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_MakeupArtist) as 化妆师名称
- ,Ordpg_MakeupAssistant as 化妆助理ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_MakeupAssistant) as 化妆助理名称
- ,Ordpg_BootDivision as 引导师ID
- ,[dbo].[fn_CheckUserIDGetUserName](Ordpg_BootDivision) as 引导师名称
- --,Ordpg_ReservationPhotographyName
- --,Ordpg_ReservationPhotographyTime
- --,Ordpg_ReservationPhotographyAssistant
- --,Ordpg_ReservationMakeupArtist
- --,Ordpg_ReservationMakeupAssistant
- --,Ordpg_ReservationBootDivision
- FROM tb_ErpOrdersPhotography
- left join tb_ErpOrder on tb_ErpOrdersPhotography.Ordpg_Number=tb_ErpOrder.Ord_Number
- GO
- update tb_ErpSystemCategory set Sc_ClassName='提成点方案' where Sc_ClassCode='BEBBAFACDCCFBJFI'
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpPayment') and name='Pay_Type')
- begin
- alter table tb_ErpPayment add Pay_Type int
- end
- GO
- if not exists
- (select * from syscolumns where id=object_id('tb_ErpTwoSalesOrder') and name='Tsorder_CustomerNumber')
- begin
- alter table tb_ErpTwoSalesOrder add Tsorder_CustomerNumber nvarchar(50)
- end
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_TwoSalesOrder')
- BEGIN
- DROP VIEW [dbo].Vw_TwoSalesOrder
- END
- GO
- Create view [dbo].Vw_TwoSalesOrder
- as
- SELECT
- dbo.tb_ErpTwoSalesOrder.ID,
- Tsorder_Number,
- Tsorder_Name,
- (select Cus_Name from tb_ErpCustomer where Tsorder_CustomerNumber=Cus_CustomerNumber) as Tsorder_CustomerName,
- (select Cus_Telephone from tb_ErpCustomer where Tsorder_CustomerNumber=Cus_CustomerNumber) as Tsorder_Telephone,
- (select Cus_NamePinyin from tb_ErpCustomer where Tsorder_CustomerNumber=Cus_CustomerNumber) as Cus_NamePinyin,
- Tsorder_Money,
- Tsorder_Quantity,
- Tsorder_Category,
- Tsorder_OpenSingle,
- Tsorder_PersonHandling,
- Tsorder_Remark,
- Tsorder_CreateDatetime,
- Tsorder_UpdateDatetime,
- dbo.fn_CheckUserIDGetUserName(Tsorder_OpenSingle) AS [User_Name],
- dbo.fn_CheckUserIDGetUserName(Tsorder_PersonHandling) AS Tsorder_PersonHandlingName,
- dbo.fn_GetClassCodeToName(Tsorder_Category,Tsorder_Category) AS Tsorder_CategoryName,
- Tsorder_CustomerNumber
- FROM dbo.tb_ErpTwoSalesOrder
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_OrdersWagePaymentRecords')
- BEGIN
- DROP VIEW [dbo].Vw_OrdersWagePaymentRecords
- END
- GO
- Create view [dbo].Vw_OrdersWagePaymentRecords
- as
- SELECT
- tb_ErpPayment.ID,
- Pay_OrdNumber,
- Pay_AmountOf,
- Pay_OpenSingle,
- Pay_ThePayee,
- Pay_PaymentMethod,
- Pay_OrdersLocation,
- Pay_ReceivableProject,
- Pay_Remark,
- convert(varchar(10),Pay_CreateDatetime,120) as Pay_CreateDatetime,
- Pay_Category,
- Pay_TwoPinsCategory,
- dbo.fn_CheckUserIDGetUserName(Pay_OpenSingle) AS Pay_UserName,
- dbo.fn_CheckUserIDGetUserName(Pay_ThePayee) AS Pay_ThePayeeName,
- dbo.fn_GetClassCodeToName(Pay_PaymentMethod, Pay_PaymentMethod) AS Pay_PaymentMethodName,
- dbo.fn_GetClassCodeToName(Pay_TwoPinsCategory, Pay_TwoPinsCategory) AS Pay_TwoPinsCategoryName,
- Pay_FinancialAuditdPeople,
- Pay_FinancialAudit,
- dbo.fn_CheckUserIDGetUserName(Pay_FinancialAuditdPeople)AS Pay_FinancialAuditdPeopleName,
- Pay_ShootingName,
- Pay_Type,
- Ord_DividedShop,
- Ord_Type,
- Cus_Name as Ord_CustomerName1,
- (select Tsorder_Name from Vw_TwoSalesOrder where Pay_OrdNumber= Tsorder_Number) as Tsorder_Name,
- (select Tsorder_CustomerName from Vw_TwoSalesOrder where Pay_OrdNumber= Tsorder_Number) as Tsorder_CustomerName,
- (select Cus_Name from View_DressSaleRentalOrder where Pay_OrdNumber=Dsro_Number) as Cus_Name,
- Ord_CreateDatetime,
- Ord_SeriesName,
- Ord_PhotographyCategory
- FROM tb_ErpPayment
- left join Vw_Customer_PaymentOrders on Pay_OrdNumber=Ord_Number
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_StaffPerformance_OrdersPerson')
- BEGIN
- DROP VIEW [dbo].Vw_StaffPerformance_OrdersPerson
- END
- GO
- create View Vw_StaffPerformance_OrdersPerson
- as
- SELECT
- ID
- ,Pay_OrdNumber as 订单号
- ,Pay_ShootingName as 拍摄阶段
- ,Pay_Category as 收款类别
- ,Pay_TwoPinsCategory as 二销类别编号
- ,dbo.fn_GetClassCodeToName(Pay_TwoPinsCategory, Pay_TwoPinsCategory) AS 二销类别名称
- ,Pay_AmountOf as 收款金额
- ,Pay_OpenSingle as 接单人编号
- , dbo.fn_CheckUserIDGetUserName(Pay_OpenSingle) AS 接单人名称
- ,Pay_ThePayee as 收款人编号
- ,dbo.fn_CheckUserIDGetUserName(Pay_ThePayee) AS 收款人名称
- ,Pay_PaymentMethod as 付款方式编号
- ,dbo.fn_GetClassCodeToName(Pay_PaymentMethod, Pay_PaymentMethod) AS 付款方式名称
- ,Pay_OrdersLocation as 接单地点
- ,Pay_ReceivableProject as 收款项目
- ,Pay_FinancialAudit as 审核状态
- ,Pay_FinancialAuditdPeople as 审核人
- ,Pay_Remark as 备注
- ,Pay_CreateDatetime as 收款时间
- ,Pay_Type as 收款类型
- ,(case Pay_Type
- when 0 then (select Cus_Name from tempTB_AggregationCustomer where Pay_OrdNumber=GP_OrderNumber)
- when 1 then (select Tsorder_CustomerName from Vw_TwoSalesOrder where Pay_OrdNumber=Tsorder_Number)
- when 2 then (select Cus_Name from View_DressSaleRentalOrder where Pay_OrdNumber=Dsro_Number)
- else '' end) as '客户名称'
- ,(case Pay_Type
- when 0 then (select Ord_PhotographyCategory from tb_ErpOrder where Pay_OrdNumber=Ord_Number)
- else '' end) as '套系类别'
- ,(case Pay_Type
- when 0 then (select Ord_SeriesName from tb_ErpOrder where Pay_OrdNumber=Ord_Number)
- else '' end) as '套系名称'
- ,(case Pay_Type
- when 0 then (select Ord_SeriesPrice from tb_ErpOrder where Pay_OrdNumber=Ord_Number)
- when 1 then (select Tsorder_Money from Vw_TwoSalesOrder where Pay_OrdNumber=Tsorder_Number)
- when 2 then (select Dsro_Amount from View_DressSaleRentalOrder where Pay_OrdNumber=Dsro_Number)
- end) as '应收金额'
- ,(case Pay_Type
- when 0 then (dbo.fn_GetClassCodeToName(Pay_TwoPinsCategory, Pay_TwoPinsCategory))
- when 1 then (dbo.fn_GetClassCodeToName(Pay_TwoPinsCategory, Pay_TwoPinsCategory))
- when 2 then Pay_ReceivableProject
- end) as '项目名称'
- FROM tb_ErpPayment
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_StaffPerformance_Photograph')
- BEGIN
- DROP VIEW [dbo].Vw_StaffPerformance_Photograph
- END
- GO
- create View Vw_StaffPerformance_Photograph
- as
- SELECT
- Ordv_Number as 主订单
- ,Ordv_ViceNumber as 副订单
- ,(select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number) as 订单类型
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ Ordpg_Sights from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 拍摄名称
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select max(Ordpg_PhotographyTime) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number)
- when 1 then (select max(Ordpg_PhotographyTime) from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber)
- when 2 then (select max(Ordpg_PhotographyTime) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number)
- else '' end) as 最后拍摄时间
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select count(id) as id from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- when 1 then (select count(id) as id from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- when 2 then (select count(id) as id from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- else '' end) as 未拍个数
- ,(case Ordv_FilmSelectionStatus when 1 then 'OK' else '未选' end) as 选片状态
- ,Ordv_FilmSelectionTime as 选片时间
- ,(case when (select Count(*) from (select [OPlist_PickupStatus] from [tb_ErpOrderProductList] where [OPlist_ViceNumber]=Ordv_ViceNumber and OPlist_Type = '2' and [OPlist_PickupStatus] = '0') as ta)>0 then '未取' else 'OK' end) AS 取件状态
- ,(select top 1 OPlist_PickupTime from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type = '2' and OPlist_PickupTime is not null order by OPlist_PickupTime) AS 取件日期
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ Ordpg_Photographer from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ Ordpg_Photographer from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ Ordpg_Photographer from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 主摄影师ID
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_Photographer) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_Photographer) from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_Photographer) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 主摄影师名称
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ Ordpg_PhotographyAssistant from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ Ordpg_PhotographyAssistant from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ Ordpg_PhotographyAssistant from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 摄影助理ID
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_PhotographyAssistant) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_PhotographyAssistant) from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_PhotographyAssistant) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 摄影助理名称
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ Ordpg_MakeupArtist from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ Ordpg_MakeupArtist from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ Ordpg_MakeupArtist from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 主化妆ID
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_MakeupArtist) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_MakeupArtist) from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_MakeupArtist) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 主化妆名称
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ Ordpg_MakeupAssistant from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ Ordpg_MakeupAssistant from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ Ordpg_MakeupAssistant from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 化妆助理ID
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_MakeupAssistant) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_MakeupAssistant) from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_MakeupAssistant) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 化妆助理名称
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ Ordpg_BootDivision from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ Ordpg_BootDivision from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ Ordpg_BootDivision from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 引导师ID
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_BootDivision) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- when 1 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_BootDivision) from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber for xml path('')),1,1,''))
- when 2 then (select stuff((select ','+ dbo.fn_CheckUserIDGetUserName(Ordpg_BootDivision) from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,''))
- else '' end) as 引导师名称
- ,Vw_StaffPerformance_OrdersPerson.ID
- ,订单号
- ,拍摄阶段
- ,收款类别
- ,二销类别编号
- ,二销类别名称
- ,收款金额
- ,接单人编号
- ,接单人名称
- ,收款人编号
- ,收款人名称
- ,付款方式编号
- ,付款方式名称
- ,接单地点
- ,收款项目
- ,审核状态
- ,审核人
- ,备注
- ,收款时间
- ,收款类型
- ,客户名称
- ,套系类别
- ,套系名称
- ,应收金额
- ,项目名称
- FROM tb_ErpOrderDigital
- left join Vw_StaffPerformance_OrdersPerson on Ordv_Number=订单号
- where 订单号 is not null
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_StaffPerformance_MemberCardRechargeRecord')
- BEGIN
- DROP VIEW [dbo].Vw_StaffPerformance_MemberCardRechargeRecord
- END
- GO
- create View Vw_StaffPerformance_MemberCardRechargeRecord
- as
- SELECT ID
- ,Mcrr_Number as 会员编号
- ,Mcrr_RechargeNumber as 充值编号
- ,Mcrr_RechargeName as 充值名称
- ,Mcrr_RechargeAmount as 充值金额
- ,Mcrr_DonateAmount as 赠送金额
- ,Mcrr_DonateDiscount as 消费折扣
- ,Mcrr_PaymentMethod as 支付方式编号
- ,dbo.fn_GetClassCodeToName(Mcrr_PaymentMethod, Mcrr_PaymentMethod) as 支付方式名称
- ,Mcrr_OrderPerson as 接单人编号
- ,dbo.fn_CheckUserIDGetUserName(Mcrr_OrderPerson) AS 接单人名称
- ,convert(varchar(10),Mcrr_CreateDatetime,120) as 创建时间
- ,Mcrr_CreateName as 创建人编号
- ,dbo.fn_CheckUserIDGetUserName(Mcrr_CreateName) AS 创建人名称
- ,(select Cus_Name from tb_ErpCustomer where Cus_CustomerNumber=(select Mc_CustomerNumber from tb_ErpMemberCard where Mcrr_Number=Mc_Number)) as 客户姓名
- FROM tb_ErpMemberCardRechargeRecord
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_ErpMemberCardPayment')
- BEGIN
- DROP VIEW [dbo].Vw_ErpMemberCardPayment
- END
- GO
- create View Vw_ErpMemberCardPayment
- as
- SELECT ID
- ,Mcpt_PaymentNumber as 收款编号
- ,Mcpt_Number as 会员卡编号
- ,Mcpt_PaymentType as 收款类型
- ,Mcpt_PaymentAmount as 收款金额
- ,Mcpt_PaymentMethod as 付款方式编号
- ,dbo.fn_GetClassCodeToName(Mcpt_PaymentMethod, Mcpt_PaymentMethod) as 支付方式名称
- ,Mcpt_PackageClass as 服务套系类别编号
- ,(case Mcpt_PackageClass
- when '' then (select stuff((select ','+ Mcpcd_ServiceContent from tb_ErpMemberCardPaymentContentDetail where Mcpt_PaymentNumber=Mcpcd_PaymentNumber for xml path('')),1,1,''))
- else (select MscPs_PackageName from tb_ErpMemberCardServicePackageSet where Mcpt_PackageClass=MscPs_PackageNumber) end) as 服务套系类别名称
- ,Mcpt_PackagePrice as 服务套系价格
- ,Mcpt_Discount as 优惠折扣
- ,Mcpt_OrderPerson as 接单人编号
- ,dbo.fn_CheckUserIDGetUserName(Mcpt_OrderPerson) AS 接单人名称
- ,Mcpt_PaymentRemark as 收款备注
- ,Mcpt_FinancialAudit 财务审核状态
- ,Mcpt_FinancialAuditName as 账务审核人
- ,Mcpt_FinancialAuditDateTime as 财务审核时间
- ,Mcpt_FinancialAuditRemark as 账务审核备注
- ,convert(varchar(10),Mcpt_CreateDatetime,120) as 创建日期
- ,Mcpt_CreateName as 创建人编号
- ,dbo.fn_CheckUserIDGetUserName(Mcpt_CreateName) AS 创建人名称
- ,(select Cus_Name from tb_ErpCustomer where Cus_CustomerNumber=(select Mc_CustomerNumber from tb_ErpMemberCard where Mcpt_Number=Mc_Number)) as 客户姓名
- FROM tb_ErpMemberCardPayment
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_ReportTime')
- BEGIN
- DROP VIEW [dbo].Vw_ReportTime
- END
- GO
- create View Vw_ReportTime
- as
- with t as(
- select distinct convert(varchar(10),isnull(Vw_OrdersWagePaymentRecords.Pay_CreateDatetime,View_ErpOtherIncomeAndExpenses.Oiae_IEDatetime),120) as Pay_CreateDatetimes
- ,Pay_OrdNumber,Pay_CreateDatetime,Oiae_ProjectName,Oiae_IEDatetime
- from Vw_OrdersWagePaymentRecords
- full join View_ErpOtherIncomeAndExpenses on Vw_OrdersWagePaymentRecords.Pay_CreateDatetime=View_ErpOtherIncomeAndExpenses.Oiae_IEDatetime
- )
- , t2 as(
- select distinct convert(varchar(10),isnull(t.Pay_CreateDatetimes,Vw_ErpMemberCardPayment.创建日期),120) as Pay_CreateDatetimes from t
- full join Vw_ErpMemberCardPayment on t.Pay_CreateDatetimes=Vw_ErpMemberCardPayment.创建日期
- )
- select distinct convert(varchar(10),isnull(t2.Pay_CreateDatetimes,Vw_StaffPerformance_MemberCardRechargeRecord.创建时间),120) as Pay_CreateDatetimes from t2
- full join Vw_StaffPerformance_MemberCardRechargeRecord on t2.Pay_CreateDatetimes=Vw_StaffPerformance_MemberCardRechargeRecord.创建时间
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_MonthlyReport')
- BEGIN
- DROP VIEW [dbo].Vw_MonthlyReport
- END
- GO
- create View Vw_MonthlyReport
- as
- select
- Pay_CreateDatetimes
- ,(select sum(Pay_AmountOf) from tb_ErpPayment where (Pay_Category='全款' or Pay_Category='预约收款') and Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_CreateDatetime>=Pay_CreateDatetimes and Pay_CreateDatetime<=Pay_CreateDatetimes+' 23:59:59.000') as DayOrdersIncome
- , (select sum(Pay_AmountOf) from tb_ErpPayment where Pay_Category='预约补款' and Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_CreateDatetime>=Pay_CreateDatetimes and Pay_CreateDatetime<=Pay_CreateDatetimes+' 23:59:59.000') as DayReplenishmentIncome
- ,(select sum(Pay_AmountOf) from tb_ErpPayment where Pay_Category='后期收款' and Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and Pay_CreateDatetime>=Pay_CreateDatetimes and Pay_CreateDatetime<=Pay_CreateDatetimes+' 23:59:59.000') as DayLateStageIncome
- , (select sum(Oiae_Money) from tb_ErpOtherIncomeAndExpenses where Oiae_Type='收入' and Oiae_PaymentMethod!='BEBACCAFEGECFBJFD' and Oiae_IEDatetime>=Pay_CreateDatetimes and Oiae_IEDatetime<=Pay_CreateDatetimes+' 23:59:59.000') as DayOtherIncome
- ,(select sum(Mcrr_RechargeAmount) from tb_ErpMemberCardRechargeRecord where Mcrr_CreateDatetime>=Pay_CreateDatetimes and Mcrr_CreateDatetime<=Pay_CreateDatetimes+' 23:59:59.000') as DayMemberIncome
- ,(select sum(Ord_SeriesPrice) from tb_ErpOrder where ord_class='1' and Ord_CreateDatetime>=Pay_CreateDatetimes and Ord_CreateDatetime<=Pay_CreateDatetimes+' 23:59:59.000') as DayEarlyPerformance
- ,(select sum(Plu_Amount) from tb_ErpPlusPickItems where Plu_CreateTime>=Pay_CreateDatetimes and Plu_CreateTime<=Pay_CreateDatetimes+' 23:59:59.000') as DayPluslatepickPerformance
- ,(select sum(Tsorder_Money) from tb_ErpTwoSalesOrder where Tsorder_CreateDatetime>=Pay_CreateDatetimes and Tsorder_CreateDatetime<=Pay_CreateDatetimes+' 23:59:59.000') as DayOtherPerformance
- , (select sum(Oiae_Money) from tb_ErpOtherIncomeAndExpenses where Oiae_Type='支出' and Oiae_IEDatetime>=Pay_CreateDatetimes and Oiae_IEDatetime<=Pay_CreateDatetimes+' 23:59:59.000') as DayExpenditure
- ,(select sum(Mcpt_PaymentAmount) from tb_ErpMemberCardPayment where Mcpt_CreateDatetime>=Pay_CreateDatetimes and Mcpt_CreateDatetime<=Pay_CreateDatetimes+' 23:59:59.000') as DayMemberCardPaymentIncome
- from
- (
- select Pay_CreateDatetimes from Vw_ReportTime
- ) as MonthlyReport
- group by Pay_CreateDatetimes
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_YearReport')
- BEGIN
- DROP VIEW [dbo].Vw_YearReport
- END
- GO
- create View Vw_YearReport
- as
- select
- Pay_CreateDatetimes
- ,(select sum(Pay_AmountOf) from tb_ErpPayment where (Pay_Category='全款' or Pay_Category='预约收款') and Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and convert(varchar,Pay_CreateDatetime,120) like '%'+Pay_CreateDatetimes+'%') as DayOrdersIncome
- , (select sum(Pay_AmountOf) from tb_ErpPayment where Pay_Category='预约补款' and Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and convert(varchar,Pay_CreateDatetime,120) like '%'+Pay_CreateDatetimes+'%') as DayReplenishmentIncome
- ,(select sum(Pay_AmountOf) from tb_ErpPayment where Pay_Category='后期收款' and Pay_PaymentMethod!='BEBACCAFEGECFBJFD' and convert(varchar,Pay_CreateDatetime,120) like '%'+Pay_CreateDatetimes+'%') as DayLateStageIncome
- , (select sum(Oiae_Money) from tb_ErpOtherIncomeAndExpenses where Oiae_Type='收入' and Oiae_PaymentMethod!='BEBACCAFEGECFBJFD' and convert(varchar,Oiae_IEDatetime,120) like '%'+Pay_CreateDatetimes+'%') as DayOtherIncome
- ,(select sum(Mcrr_RechargeAmount) from tb_ErpMemberCardRechargeRecord where convert(varchar,Mcrr_CreateDatetime,120) like '%'+Pay_CreateDatetimes+'%') as DayMemberIncome
- ,(select sum(Ord_SeriesPrice) from tb_ErpOrder where ord_class='1' and convert(varchar,Ord_CreateDatetime,120) like '%'+Pay_CreateDatetimes+'%') as DayEarlyPerformance
- ,(select sum(Plu_Amount) from tb_ErpPlusPickItems where convert(varchar,Plu_CreateTime,120) like '%'+Pay_CreateDatetimes+'%') as DayPluslatepickPerformance
- ,(select sum(Tsorder_Money) from tb_ErpTwoSalesOrder where convert(varchar,Tsorder_CreateDatetime,120) like '%'+Pay_CreateDatetimes+'%') as DayOtherPerformance
- , (select sum(Oiae_Money) from tb_ErpOtherIncomeAndExpenses where Oiae_Type='支出' and convert(varchar,Oiae_IEDatetime,120) like '%'+Pay_CreateDatetimes+'%') as DayExpenditure
- ,(select sum(Mcpt_PaymentAmount) from tb_ErpMemberCardPayment where convert(varchar,Mcpt_CreateDatetime,120) like '%'+Pay_CreateDatetimes+'%') as DayMemberCardPaymentIncome
- from
- (
- select convert(varchar(7),Pay_CreateDatetimes,120) as Pay_CreateDatetimes from Vw_ReportTime
- ) as YearReport
- group by Pay_CreateDatetimes
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_ProcessStatus')
- BEGIN
- DROP VIEW [dbo].Vw_ProcessStatus
- END
- GO
- create View [dbo].[Vw_ProcessStatus]
- as
- Select
- ID
- ,Ordv_Number as 主订单号
- ,Ordv_ViceNumber as 副订单号
- ,Ordv_DigitalNumber as 拍摄次数
- ,(select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number) as 订单类型
- ,(select Ord_Class from tb_ErpOrder where Ordv_Number=Ord_Number) as 订单类别
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 1 then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber)
- else (select stuff((select ','+ Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number for xml path('')),1,1,'')) end) as 拍摄名称
- ,(select Ord_CreateDateTime from tb_ErpOrder where Ordv_Number=Ord_Number) as 预选时间
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select count(id) as id from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- when 1 then (select count(id) as id from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- when 2 then (select count(id) as id from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- else '' end) as 未拍个数
- , (case Ordv_EarlyRepairStatus when 2 then 'OK' else '未修'end ) as 初修状态
- , (case Ordv_FilmSelectionStatus when 1 then 'OK' else '未选'end ) as 选片状态
- , (case Ordv_RefinementStatus when 2 then 'OK' else '未修'end ) as 精修状态
- , (case Ordv_DesignerStatus when 2 then 'OK' else '未设计'end ) as 设计状态
- , (case Ordv_LookDesignStatus when 1 then 'OK' else '未看'end ) as 看设计状态
- ,(select count(id) as id from tb_ErpOrderProductList where OPlist_Type=2 and OPlist_ViceNumber=Ordv_ViceNumber and OPlist_SendStatus=0) as 未发出个数
- ,(select count(id) as id from tb_ErpOrderProductList where OPlist_Type=2 and OPlist_ViceNumber=Ordv_ViceNumber and OPlist_CompletedStatus=0) as 未完成个数
- ,(case when (select Count(*) from (select [OPlist_PickupStatus] from [tb_ErpOrderProductList] where [OPlist_ViceNumber]=Ordv_ViceNumber and OPlist_Type = '2' and [OPlist_PickupStatus] = '0') as ta)>0 then '未取' else 'OK' end) AS 取件状态
- from tb_ErpOrderDigital
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_ErpCustomersTrackRecord')
- BEGIN
- DROP VIEW [dbo].Vw_ErpCustomersTrackRecord
- END
- GO
- create View Vw_ErpCustomersTrackRecord
- as
- SELECT id
- ,TR_CustomerGroupID as 客户组
- ,TR_CustomerID as 客户ID
- ,(select Cus_Name from tb_ErpCustomer where TR_CustomerID=Cus_CustomerNumber) as 客户姓名
- ,TR_TraceWay as 沟通方式
- ,TR_TraceType as 沟通类型
- ,TR_SpecificMatters
- ,TR_Communicationstatus as 沟通状态
- ,TR_TraceDetailedly
- ,TR_CallRecording as 录音路径文件
- ,TR_Remark as 备注
- ,TR_TraceDateTime as 沟通日期
- ,TR_TraceTimeLength as 沟通时长
- ,TR_TracePersonID as 跟踪人员ID
- ,(select User_Name from tb_ErpUser where TR_TracePersonID=User_EmployeeID) as 跟踪人员姓名
- ,TR_CreateDateTime as 创建时间
- FROM dbo.tb_ErpCustomersTrackRecord
- GO
- ------
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpShopEvententry]') AND type in (N'U'))
- begin
- CREATE TABLE [dbo].[tb_ErpShopEvententry](
- [ID] [int] identity(1,1) primary key not null, --ID主建
- [Matter_CreateName] [varchar](16) not null, --申请人
- [Matter_CreateDatetime] [Datetime] not null, --申请时间
- [Matter_content] [varchar](200)not null, --申请内容
- [Matter_state] [varchar](10)not null, --申请状态
- [Matter_UpdateName] [varchar](16)not null, --审批人
- [Matter_UpdateDatetime] [Datetime], --审核时间
- [Matter_opinion] [varchar](200) --审批人意见
- )
- EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'ID主建' ,
- @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
- @level2type=N'COLUMN',@level2name=N'ID'
- EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'申请人' ,
- @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
- @level2type=N'COLUMN',@level2name=N'Matter_CreateName'
- EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'申请时间' ,
- @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
- @level2type=N'COLUMN',@level2name=N'Matter_CreateDatetime'
- EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'申请内容' ,
- @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
- @level2type=N'COLUMN',@level2name=N'Matter_content'
- EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'申请状态' ,
- @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
- @level2type=N'COLUMN',@level2name=N'Matter_state'
- EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'审批人' ,
- @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
- @level2type=N'COLUMN',@level2name=N'Matter_UpdateName'
- EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'审批时间' ,
- @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
- @level2type=N'COLUMN',@level2name=N'Matter_UpdateDatetime'
- EXEC sys.sp_addextendedproperty @name=N'Evententry', @value=N'审批人意见' ,
- @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'tb_Evententry',
- @level2type=N'COLUMN',@level2name=N'Matter_opinion'
- end
- GO
- --公告表
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpShopBulletin]') AND type in (N'U'))
- begin
- CREATE TABLE [dbo].[tb_ErpShopBulletin](
- [ID] [int] identity(1,1) primary key not null, --ID主建
- [Bulletin_issuerID] [varchar](26) not null, --发布人ID
- [Bulletin_announcement] [varchar](100) not null, --公告类型
- [Bulletin_Title] [varchar](150)not null, --标题
- [Bulletin_content] [varchar](1000)not null, --内容
- [Bulletin_ReleaseTime] [Datetime] not null, --发布时间
- [Bulletin_Accessory] [varchar](200) --附件位置
- )
- end
- GO
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpShopDesignatedAnnounced]') AND type in (N'U'))
- begin
- --指定人员查看表
- CREATE TABLE [dbo].[tb_ErpShopDesignatedAnnounced](
- [ID] [int] identity(1,1) primary key not null, --ID主建
- [Announced_issuerID] [varchar](26) not null, --指定人员查看公告ID
- [Announced_announcement] [varchar](100) not null, --公告ID
- )
- end
- GO
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[View_Shopannouncement]'))
- begin
- DROP VIEW [dbo].[View_Shopannouncement]
- end
- GO
- --公告与指定人员视图
- Create view View_ShopAnnouncement
- AS
- select a.ID,
- a.Announced_issuerID,
- a.Announced_announcement,
- b.ID as 'Uid',
- b.Bulletin_issuerID,
- b.Bulletin_announcement,
- b.Bulletin_Title,
- b.Bulletin_content,
- b.Bulletin_ReleaseTime,
- b.Bulletin_Accessory from tb_ErpShopDesignatedAnnounced a Left JOIN
- tb_ErpShopBulletin b on a.Announced_announcement=b.ID
- GO
- --创建任务交办表
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpShopAssignmente]') AND type in (N'U'))
- begin
- create table tb_ErpShopAssignmente(
- ID int identity(1,1) not null,--备注ID
- Agt_Priority int not null,--任务优先级 0 为高 1 为中 2 为低
- Agt_PublishName nvarchar(20) not null,--发布人
- Agt_PublishTime datetime not null,--发布时间
- Agt_Content nvarchar(200) not null,--发布的任务内容
- Agt_ManageName nvarchar(20) not null,--办理人
- Agt_CompleteTime datetime not null,--完成时间
- Agt_CompleteStatus int not null,--任务的完成状态 0 为待执行 1 为执行中 2 为已完成 3 为已搁置 4 为无法完成 5 为延后
- Agt_Summary nvarchar(200) not null,--任务内容
- Agt_Revert nvarchar(200) not null,--发布者的回复
- Agt_CreateDatetime datetime not null,--创建的时间
- Agt_CreateName nvarchar(20) not null,--创建人
- Agt_UpdateDatetime datetime not null,--修改日期
- Agt_UpdateName nvarchar(20) not null--修改人
- )
- end
- GO
- --创建任务报告表
- IF not EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tb_ErpShopDebriefing]') AND type in (N'U'))
- begin
- create table tb_ErpShopDebriefing(
- Rpt_ID int identity(1,1) not null,--任务交办表关联
- Rpt_CompleteState int not null,--任务的完成状态 0 为待执行 1 为执行中 2 为已完成 3 为已搁置 4 为无法完成 5 为延后
- Rpt_Summary nvarchar(200) not null,--任务内容
- Rpt_CreateDatetime datetime not null,--创建的时间
- Rpt_UpdateName nvarchar(20) not null--修改人
- )
- end
- GO
- --创建视图
- --按订单查询
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[Vw_OrderCustomerList]'))
- DROP VIEW [dbo].[Vw_OrderCustomerList]
- GO
- CREATE VIEW [Vw_OrderCustomerList]
- AS
- with t as(
- SELECT Plu_OrdNumber
- ,sum(Plu_Amount)as Plu_Amount
- FROM [dbo].[tb_ErpPlusPickItems]
- group by Plu_OrdNumber
- )
- , t2 as(
- SELECT [dbo].[tb_ErpOrder].[ID]
- ,[Ord_Number]
- ,[Ord_DividedShop]
- ,[Ord_Type]
- ,dbo.fn_CheckOrderType([Ord_Type]) as Ord_Type_CH
- ,[Ord_Class]
- ,[Ord_OrderClass]
- ,[Ord_PhotographyCategory]
- ,[Ord_CustomerSource]
- ,[Ord_SeriesName]
- ,[Ord_SeriesPrice]
- ,[Ord_CreateDateTime]
- ,[Ord_CreateName]
- ,[Ord_UpdateDateTime]
- ,[Ord_UpdateName]
- ,t.Plu_Amount
- FROM [dbo].[tb_ErpOrder]
- left join
- t
- on [tb_ErpOrder].[Ord_Number]=t.Plu_OrdNumber
- )
- select t2.*
- ,(isnull(t2.Plu_Amount,0)+isnull(t2.Ord_SeriesPrice,0))as yingFuPrice
- ,[GP_CustomerGroupID]
- ,[GP_GroupType]
- ,[GP_CustomerType]
- ,[GP_CustomerStatus]
- ,[GP_LossReason]
- ,[GP_DegreeOfIntent]
- ,[GP_CustomerSource]
- ,[GP_IntroducerCustomerID]
- ,[GM_CustomerGroupID]
- ,[Cus_Name]
- ,[Cus_Name_py]
- ,[Cus_Sex_cs]
- ,[Cus_Telephone]
- ,[Cus_Region]
- ,[Age_String]
- ,[Age_Day]
- ,[Age_Year]
- ,[GregorianCalendar_Birthday]
- ,[GregorianCalendar_NowYearBirthday]
- ,[GregorianCalendar_DayForMarriage]
- ,[GregorianCalendar_NowYearDayForMarriage]
- ,[M_Cus_CustomerNumber]
- ,[M_Cus_Name]
- ,[M_Cus_Name_py]
- ,[M_Cus_Sex_cs]
- ,[M_Cus_Telephone]
- ,[M_Cus_MicroSignal]
- ,[M_Cus_QQ]
- ,[M_Cus_Region]
- ,[M_Cus_Address]
- ,[Ord_ViceOrderCount]
- ,[Mc_CradNumber]
- ,[Mc_CardType]
- from t2
- left join
- [dbo].[tempTB_AggregationCustomer]
- on t2.[Ord_Number]=dbo.[tempTB_AggregationCustomer].[GP_OrderNumber]
- GO
- --按人查询
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[Vw_PersonalCustomerList]'))
- DROP VIEW [dbo].[Vw_PersonalCustomerList]
- GO
- CREATE VIEW [Vw_PersonalCustomerList]
- AS
- with t as(
- SELECT Plu_OrdNumber
- ,sum(Plu_Amount)as Plu_Amount
- FROM [dbo].[tb_ErpPlusPickItems]
- group by Plu_OrdNumber
- )
- , t2 as(
- SELECT [dbo].[tb_ErpOrder].[ID]
- ,[Ord_Number]
- ,[Ord_DividedShop]
- ,[Ord_Type]
- ,dbo.fn_CheckOrderType([Ord_Type]) as Ord_Type_CH
- ,[Ord_Class]
- ,[Ord_OrderClass]
- ,[Ord_PhotographyCategory]
- ,[Ord_CustomerSource]
- ,[Ord_SeriesName]
- ,[Ord_SeriesPrice]
- ,[Ord_CreateDateTime]
- ,[Ord_CreateName]
- ,[Ord_UpdateDateTime]
- ,[Ord_UpdateName]
- ,t.Plu_Amount
- FROM [dbo].[tb_ErpOrder]
- left join
- t
- on [tb_ErpOrder].[Ord_Number]=t.Plu_OrdNumber
- )
- select t2.*
- ,(isnull(t2.Plu_Amount,0)+isnull(t2.Ord_SeriesPrice,0))as yingFuPrice
- ,[GP_CustomerGroupID]
- ,[GP_GroupType]
- ,[GP_CustomerType]
- ,[GP_CustomerStatus]
- ,[GP_LossReason]
- ,[GP_DegreeOfIntent]
- ,[GP_CustomerSource]
- ,[GP_IntroducerCustomerID]
- ,[GP_Remark]
- ,[GP_BelongsPersonID]
- ,[GP_CreateDatetime]
- ,[GP_UpdateDatetime]
- ,[GM_CustomerGroupID]
- ,[GM_CustomerID]
- ,[GM_Master]
- ,[GM_ProtagonistCustomer]
- ,[GM_RelatedPersonID]
- ,[GM_Relation]
- ,[GM_IsOrder]
- ,[GM_IsOrderNumber]
- ,[Cus_CustomerNumber]
- ,[Cus_CustomizeNumber]
- ,[Cus_Grade]
- ,[Cus_Name]
- ,[Cus_Name_py]
- ,[Cus_Sex]
- ,[Cus_Sex_cs]
- ,[Cus_Birthday]
- ,[Cus_BirthdayLunar]
- ,[GregorianCalendar_Birthday]
- ,[GregorianCalendar_NowYearBirthday]
- ,[Age_Year]
- ,[Age_Day]
- ,[Age_String]
- ,[Cus_DayForMarriage]
- ,[Cus_DayForMarriageLunar]
- ,[GregorianCalendar_DayForMarriage]
- ,[GregorianCalendar_NowYearDayForMarriage]
- ,[Cus_QQ]
- ,[Cus_MicroSignal]
- ,[Cus_Telephone]
- ,[Cus_FixedPhone]
- ,[Cus_Region]
- ,[Cus_Address]
- ,[Cus_WorkUnit]
- ,[Cus_BabyWeight]
- ,[Cus_BornHospital]
- ,[Cus_Zodiac]
- ,[Cus_CustomerSource]
- ,[Cus_Status]
- ,[Cus_DegreeOfIntent]
- ,[Cus_TrackName]
- ,[Cus_CreateDateTime]
- ,[Cus_CreateName]
- ,[Cus_UpdateDateTime]
- ,[Cus_UpdateName]
- from t2
- left join
- dbo.View_CustomerGroupAndCustomerGroupMembersAndErpCustomer
- on t2.[Ord_Number]=dbo.View_CustomerGroupAndCustomerGroupMembersAndErpCustomer.[GP_OrderNumber]
- GO
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[Vw_MemorialDayEmployeeList]'))
- DROP VIEW [dbo].[Vw_MemorialDayEmployeeList]
- GO
- CREATE VIEW [Vw_MemorialDayEmployeeList]
- AS
- SELECT [ID]
- ,[User_Name]
- ,[User_Sex]
- ,[User_Telephone]
- ,User_DateOfBirth
- ,dbo.Fun_GetGregorianCalendarNowYearBirthday([User_DateOfBirth],[User_BirthdayLunar]) as GregorianCalendar_NowYearBirthday
- FROM [dbo].[tb_ErpUser]
- where User_Status='在职'
- and len(User_DateOfBirth)>=10
- and len(User_DateOfBirth)>=10
- and len(User_Telephone)>=11
- GO
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PROCE_UpdateAggregationCustomer]') AND type in (N'P', N'PC'))
- DROP PROCEDURE [dbo].[PROCE_UpdateAggregationCustomer]
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- -- =============================================
- -- Author: 刘超
- -- Create date: 2015-07-16
- -- Description: 更新聚合客户表中指定条件的客户
- -- =============================================
- CREATE PROCEDURE [dbo].[PROCE_UpdateAggregationCustomer]
- (
- @WhereString varchar(2000) =N'', --条件值 为 [GP_OrderNumber]订单号,[GP_CustomerGroupID]客户组ID 字段的值
- @ReturnI int output --返回更新记录数
- )
- AS
- BEGIN
- DECLARE @M_Cus_CustomerNumber varchar(2000)
- DECLARE @GP_CustomerGroupID varchar(2000)
- --处理开始点和结束点
- delete [tempTB_AggregationCustomer] where len(@WhereString)>0 and (GP_OrderNumber=@WhereString or GP_CustomerGroupID=@WhereString)
- insert into [tempTB_AggregationCustomer]
- select * from [Vw_AggregationCustomer]
- where len(@WhereString)>0 and (GP_OrderNumber=@WhereString or GP_CustomerGroupID=@WhereString)
- set @ReturnI=(select count(*) from [tempTB_AggregationCustomer] where GP_OrderNumber=@WhereString or GP_CustomerGroupID=@WhereString)
-
- ---更新group by Cus_Name,M_Cus_CustomerNumber后的客户组临时表--
- set @M_Cus_CustomerNumber=(select top 1 M_Cus_CustomerNumber from [tempTB_AggregationCustomer] where GP_OrderNumber=@WhereString or GP_CustomerGroupID=@WhereString)
- delete [tempTB_GroupByAggregationCustomer] where M_Cus_CustomerNumber =@M_Cus_CustomerNumber;
- set @GP_CustomerGroupID=(select top 1 GP_CustomerGroupID from [tempTB_AggregationCustomer] where GP_OrderNumber=@WhereString or GP_CustomerGroupID=@WhereString)
- delete [tempTB_GroupByAggregationCustomer] where GP_CustomerGroupID =@GP_CustomerGroupID;
- with t as(
- SELECT
- max(GP_CustomerGroupID) as GP_CustomerGroupID
- from tempTB_AggregationCustomer
- where M_Cus_CustomerNumber =@M_Cus_CustomerNumber
- group by Cus_Name,M_Cus_CustomerNumber
- ),t2 as(
- select * from tempTB_AggregationCustomer
- where GP_CustomerGroupID in (select GP_CustomerGroupID from t)
- )
- insert into [tempTB_GroupByAggregationCustomer] select * from t2
- -----
- END
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_OrdersWageDigital')
- BEGIN
- DROP VIEW [dbo].Vw_OrdersWageDigital
- END
- GO
- create View Vw_OrdersWageDigital
- as
- select
- tb_ErpOrderDigital.Id
- , Ordv_Number
- ,Ordv_ViceNumber
- ,Ordv_DigitalNumber
- ,Ord_Number
- ,Ord_Type
- ,Ord_Class
- ,Ord_PhotographyCategory
- ,Ord_SeriesName
- ,Ord_SeriesPrice
- ,(case when Ord_Type = '1' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else (select top 1 Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_Number = Ord_Number) end) as 拍摄名称
- ,(select Cus_Name from tempTB_AggregationCustomer where Ord_Number=GP_OrderNumber) as 客户名称
- ,(select Cus_Telephone from tempTB_AggregationCustomer where Ord_Number=GP_OrderNumber) as 客户电话
- ,Ordv_ClothingName as 礼服师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_ClothingName) as 礼服师
- ,Ordv_ClothingStatus as 礼服师状态
- ,Ordv_ClothingTime as 选衣时间
- , Ordv_FilmSelectionName as 选片师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_FilmSelectionName) as 选片师
- , Ordv_FilmSelectionStatus as 选片状态
- , Ordv_FilmSelectionTime as 选片时间
- , Ordv_EarlyRepairName as 初修师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_EarlyRepairName) as 初修师
- , Ordv_EarlyRepairStatus as 初修状态
- , Ordv_EarlyRepairTime as 初修时间
- , Ordv_RefinementName as 精修师ID
- , dbo.fn_CheckUserIDGetUserName(Ordv_RefinementName)as 精修师
- , Ordv_RefinementStatus as 精修状态
- , Ordv_RefinementTime as 精修时间
- ,Ordv_LookDesignName as 看设计师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_LookDesignName) as 看设计师
- ,Ordv_LookDesignStatus as 看设计状态
- ,Ordv_LookDesignTime as 看设计时间
- ,Ordv_DesignerName as 设计师ID
- ,dbo.fn_CheckUserIDGetUserName(Ordv_DesignerName) as 设计师
- ,Ordv_DesignerStatus as 设计状态
- , Ordv_DesignerTime as 设计时间
- ,(case when (select Count(*) from (select [OPlist_PickupStatus] from [tb_ErpOrderProductList] where [OPlist_ViceNumber]=Ordv_ViceNumber and OPlist_Type = '2' and [OPlist_PickupStatus] = '0') as ta)>0 then '未取' else 'OK' end) AS 取件状态
- ,(select top 1 OPlist_PickupTime from tb_ErpOrderProductList where OPlist_ViceNumber = Ordv_ViceNumber and OPlist_Type = '2' and OPlist_PickupTime is not null order by OPlist_PickupTime) AS 取件日期
- ,(case (select Ord_Type from tb_ErpOrder where Ordv_Number=Ord_Number)
- when 0 then (select count(id) as id from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- when 1 then (select count(id) as id from tb_ErpOrdersPhotography where Ordv_ViceNumber=Ordpg_ViceNumber and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- when 2 then (select count(id) as id from tb_ErpOrdersPhotography where Ordpg_Number=Ordv_Number and (Ordpg_PhotographyStatus=0 or Ordpg_PhotographyStatus=2))
- else '' end) as 未拍个数
- from tb_ErpOrderDigital
- left join tb_ErpOrder on tb_ErpOrderDigital.Ordv_Number=tb_ErpOrder.Ord_Number
- GO
- if exists(select 1 from sysobjects where id=object_id('fn_GetOrderArrears') and objectproperty(id,'IsInlineFunction')=0)
- BEGIN
- DROP function [dbo].fn_GetOrderArrears
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_GetOrderArrears]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
- BEGIN
- execute dbo.sp_executesql @statement = N'--欠款
- CREATE function [dbo].[fn_GetOrderArrears](@FID varchar(800))
- /******
- 分类字符转换
- 创建人:滕工
- 创建日期:2014-6-23 14:55:29
- 修改人:
- 修改说明:
- 修改日期:
- ******/
- Returns varchar(800)
- As
- Begin
- Declare @Arrears decimal(10, 2)
- Declare @Aoumnt decimal(10, 2)
- set @Arrears = (select Ord_SeriesPrice from tb_ErpOrder where Ord_Number = @FID)
- set @Aoumnt = (Select sum(Plu_Amount) as Plu_Amount from tb_ErpPlusPickItems where Plu_OrdNumber = @FID)
- if @Aoumnt is not null
- begin
- set @Arrears = @Arrears + @Aoumnt
- end
- set @Aoumnt = 0
- set @Aoumnt = (select sum(Pay_AmountOf) from dbo.tb_ErpPayment where Pay_OrdNumber =@FID)
- if @Aoumnt is not null
- begin
- set @Arrears = @Arrears - @Aoumnt
- end
- Return @Arrears
- End
- '
- END
- GO
- if exists(select 1 from sysobjects where id=object_id('fn_GetOrderReceivable') and objectproperty(id,'IsInlineFunction')=0)
- BEGIN
- DROP function [dbo].fn_GetOrderReceivable
- END
- GO
- IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fn_GetOrderReceivable]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
- BEGIN
- execute dbo.sp_executesql @statement = N'
- --应收帐款
- CREATE function [dbo].[fn_GetOrderReceivable](@FID varchar(800))
- /******
- 分类字符转换
- 创建人:滕工
- 创建日期:2014-6-23 14:55:29
- 修改人:
- 修改说明:
- 修改日期:
- ******/
- Returns varchar(800)
- As
- Begin
- Declare @Arrears decimal(10, 2)
- Declare @Aoumnt decimal(10, 2)
- set @Arrears = (select Ord_SeriesPrice from tb_ErpOrder where Ord_Number = @FID)
- set @Aoumnt = (Select sum(Plu_Amount) as Plu_Amount from tb_ErpPlusPickItems where Plu_OrdNumber = @FID)
- if @Aoumnt is not null
- begin
- set @Arrears = @Arrears + @Aoumnt
- end
- Return @Arrears
- End
- '
- END
- GO
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vwp_GetLastClientTrackRecord')
- BEGIN
- DROP VIEW [dbo].Vwp_GetLastClientTrackRecord
- END
- GO
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[Vwp_GetLastClientTrackRecord]'))
- EXEC dbo.sp_executesql @statement = N'
- CREATE VIEW [dbo].[Vwp_GetLastClientTrackRecord]
- AS
- SELECT id, TR_CustomerGroupID, TR_CustomerID, TR_TraceWay, TR_TraceType, TR_SpecificMatters,
- TR_Communicationstatus, TR_TraceDetailedly, TR_CallRecording, TR_Remark, TR_TraceDateTime,
- TR_TraceTimeLength, TR_TracePersonID, TR_CreateDateTime, TR_UpdateDateName
- FROM dbo.tb_ErpCustomersTrackRecord
- WHERE (id IN
- (SELECT MAX(id) AS Expr1
- FROM dbo.tb_ErpCustomersTrackRecord AS tb_ErpCustomersTrackRecord_1
- GROUP BY TR_CustomerGroupID,TR_TraceType))
- '
- GO
- --创建视图
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[View_CustomerGroupMembersAndErpCustomer]'))
- DROP VIEW [dbo].[View_CustomerGroupMembersAndErpCustomer]
- GO
- CREATE VIEW [View_CustomerGroupMembersAndErpCustomer]
- AS
- SELECT [tb_ErpCustomerGroupMembers].[id]
- ,[GM_CustomerGroupID]
- ,[GM_CustomerID]
- ,[GM_Master]
- ,[GM_ProtagonistCustomer]
- ,[GM_RelatedPersonID]
- ,[GM_Relation]
- ,[GM_IsOrder]
- ,[GM_IsOrderNumber]
- ,[Cus_CustomerNumber]
- ,[Cus_CustomizeNumber]
- ,[Cus_Grade]
- ,[Cus_Name]
- ,[Cus_Name_py]
- ,[Cus_Sex]
- ,[Cus_Sex_cs]
- ,[Cus_Birthday]
- ,[Cus_BirthdayLunar]
- ,GregorianCalendar_Birthday
- ,GregorianCalendar_NowYearBirthday
- ,FLOOR(datediff(day,GregorianCalendar_Birthday,getdate())/365.25) as Age_Year
- ,DATEDIFF(day, GregorianCalendar_Birthday,Getdate()) as Age_Day
- ,dbo.Fun_GetAgeString(GregorianCalendar_Birthday) as Age_String
- ,[Cus_DayForMarriage]
- ,[Cus_DayForMarriageLunar]
- ,GregorianCalendar_DayForMarriage
- ,GregorianCalendar_NowYearDayForMarriage
- ,[Cus_QQ]
- ,[Cus_MicroSignal]
- ,[Cus_Telephone]
- ,[Cus_FixedPhone]
- ,[Cus_Region]
- ,[Cus_Address]
- ,[Cus_WorkUnit]
- ,[Cus_BabyWeight]
- ,[Cus_BornHospital]
- ,[Cus_Zodiac]
- ,[Cus_CustomerSource]
- ,[Cus_Status]
- ,[Cus_DegreeOfIntent]
- ,[Cus_TrackName]
- ,[Cus_CreateDateTime]
- ,[Cus_CreateName]
- ,[Cus_UpdateDateTime]
- ,[Cus_UpdateName]
- ,[dbo].[tb_ErpMemberCard].[Mc_CradNumber]
- ,[dbo].[tb_ErpMemberCard].[Mc_CardType]
- FROM [tb_ErpCustomerGroupMembers]
- left join [View_ErpCustomer]
- on [tb_ErpCustomerGroupMembers].[GM_CustomerID]=[View_ErpCustomer].Cus_CustomerNumber
- left join
- [dbo].[tb_ErpMemberCard]
- on [View_ErpCustomer].Cus_CustomerNumber=[dbo].[tb_ErpMemberCard].[Mc_CustomerNumber]
- GO
- IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[View_CustomerGroupAndCustomerGroupMembersAndErpCustomer]'))
- DROP VIEW [dbo].[View_CustomerGroupAndCustomerGroupMembersAndErpCustomer]
- GO
- CREATE VIEW [View_CustomerGroupAndCustomerGroupMembersAndErpCustomer]
- AS
- SELECT [tb_ErpCustomerGroup].[id]
- ,[GP_OrderNumber]
- ,[GP_CustomerGroupID]
- ,[GP_GroupType]
- ,[GP_CustomerType]
- ,[GP_CustomerStatus]
- ,[GP_LossReason]
- ,[GP_DegreeOfIntent]
- ,[GP_CustomerSource]
- ,[GP_IntroducerCustomerID]
- ,[GP_Remark]
- ,[GP_BelongsPersonID]
- ,[GP_CreateDatetime]
- ,[GP_UpdateDatetime]
- ,[GM_CustomerGroupID]
- ,[GM_CustomerID]
- ,[GM_Master]
- ,[GM_ProtagonistCustomer]
- ,[GM_RelatedPersonID]
- ,[GM_Relation]
- ,[GM_IsOrder]
- ,[GM_IsOrderNumber]
-
- ,[Cus_CustomerNumber]
- ,[Cus_CustomizeNumber]
- ,[Cus_Grade]
- ,[Cus_Name]
- ,[Cus_Name_py]
- ,[Cus_Sex]
- ,[Cus_Sex_cs]
- ,[Cus_Birthday]
- ,[Cus_BirthdayLunar]
- ,[GregorianCalendar_Birthday]
- ,[GregorianCalendar_NowYearBirthday]
- ,FLOOR(datediff(day,GregorianCalendar_Birthday,getdate())/365.25) as Age_Year
- ,DATEDIFF(day, GregorianCalendar_Birthday,Getdate()) as Age_Day
- ,dbo.Fun_GetAgeString(GregorianCalendar_Birthday) as Age_String
- ,[Cus_DayForMarriage]
- ,[Cus_DayForMarriageLunar]
- ,GregorianCalendar_DayForMarriage
- ,GregorianCalendar_NowYearDayForMarriage
- ,[Cus_QQ]
- ,[Cus_MicroSignal]
- ,[Cus_Telephone]
- ,[Cus_FixedPhone]
- ,[Cus_Region]
- ,[Cus_Address]
- ,[Cus_WorkUnit]
- ,[Cus_BabyWeight]
- ,[Cus_BornHospital]
- ,[Cus_Zodiac]
- ,[Cus_CustomerSource]
- ,[Cus_Status]
- ,[Cus_DegreeOfIntent]
- ,[Cus_TrackName]
- ,[Cus_CreateDateTime]
- ,[Cus_CreateName]
- ,[Cus_UpdateDateTime]
- ,[Cus_UpdateName]
- FROM [tb_ErpCustomerGroup]
- left join
- dbo.tb_ErpCustomerGroupMembers
- on [tb_ErpCustomerGroup].[GP_CustomerGroupID]=dbo.tb_ErpCustomerGroupMembers.[GM_CustomerGroupID]
- left join
- [dbo].[View_ErpCustomer]
- on dbo.tb_ErpCustomerGroupMembers.GM_CustomerID=[dbo].[View_ErpCustomer].Cus_CustomerNumber
- GO
-
-
- IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Fun_ConvertSex]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
- DROP FUNCTION [dbo].[Fun_ConvertSex]
- GO
- CREATE FUNCTION dbo.Fun_ConvertSex(
- @value int --性别值
- )
- /******
- 转换性别
- 创建人:刘超
- 创建日期:2015-6-11 14:10
- 修改人:
- 修改说明:
- 修改日期:
- ******/
- RETURNS nvarchar(10)
- AS
- BEGIN
- DECLARE @ret nvarchar(10)
- SET @ret = '男'
- if @value=0
- SELECT @ret = '男'
- else
- SELECT @ret = '女'
- Return @ret
- END
- GO
|