sync.order.cs 671 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using BizCom.Enum;
  50. using NPOI.POIFS.Properties;
  51. using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
  52. using static SiteCore.taoObj.Api_tmc_refund_info_Obj;
  53. using System.Threading.Tasks;
  54. using SiteCore.taoObj.WebApi;
  55. namespace SiteCore.Handler
  56. {
  57. public partial class sync
  58. {
  59. public void get_erp_orderlist()
  60. {
  61. string poscode = CurrentUser.UserPost.Post.Code;
  62. DataStruct dStruct = GetPostStruct();
  63. //commonHelper.setDeliveryUnusualOrder2();
  64. //string a = SecurityHelper.DecryptSymmetric("kncY+n90QZs=");
  65. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  66. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  67. //banniuApiHelper.sendLogisticsInfo(null);
  68. //commonHelper.autoDistributeToSupplier(CeErpTradeCell.GetByCode("260112211259328680"));
  69. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  70. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  71. //int sid = commonHelper.autoDistributeToSupplier(entity);
  72. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  73. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1767755073000,\"deliveryType\":\"NONE\",\"discountFee\":12.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1770347015000,\"lines\":[{\"mark2\":[],\"num\":53,\"outerId\":\"\",\"payment\":74.92,\"picUrl\":\"https://img.pddpic.com/garner-api-new/e8713e37e8de8dd2061900ac1bcf4bca.jpeg\",\"platServiceFee\":0.0,\"price\":1.64,\"refOlId\":\"2601071-211151798634092_1625548099674\",\"refSkuId\":\"1625548099674\",\"refSpuId\":\"543300089267\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":1.414,\"singleFee\":1.41,\"spuOuterId\":\"HK_1\",\"standards\":\"创意餐桌卡片【包邮免费排版】,极速发货\",\"status\":\"NOT_SHIPPED\",\"title\":\"婚礼餐盘卡定制婚礼席位卡高级手工高颜值结婚餐盘创意餐桌装饰品\",\"totalFee\":74.92,\"totalPrice\":86.92,\"totalSellPrice\":74.92}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1767755057000,\"openBuyerId\":\"***********\",\"orderSource\":\"SYNC\",\"orderTime\":1767755009000,\"payTime\":1767755014000,\"payment\":74.92,\"platServiceFee\":0.0,\"posCode\":\"jingshangtianhua\",\"posId\":650737,\"postFee\":0.0,\"props\":{},\"receivedPayment\":74.92,\"receiverCity\":\"普洱市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"澜沧拉祜族自治县\",\"receiverId\":\"ca16574d75e647aedf34fb28e61299c8$\",\"receiverState\":\"云南省\",\"receiverTown\":\"澜沧拉祜族自治县\",\"refOid\":\"2601071-211151798634092\",\"refType\":\"PDD\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"80x110mm-180张-卡片-300克铜板纸-双面印刷覆膜裁切-阿伟\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"sysTags\":[],\"totalFee\":74.92,\"totalPrice\":86.92,\"totalSellPrice\":74.92,\"type\":\"SALE\"}}");
  74. //refundTmcHelper.Api_TmcRefundMsg("{\"content\":{\"afterStatus\":\"SUCCESS\",\"createTime\":1735287446000,\"desc\":\"\",\"interceptInvestor\":\"NONE\",\"interceptStatus\":\"NONE\",\"interceptType\":\"NONE\",\"lines\":[{\"num\":2,\"outerId\":\"\",\"price\":50.0,\"refAid\":\"313001208133750610\",\"refAlId\":\"313001208133750610\",\"refBoughtSkuId\":\"\",\"refOid\":\"4181722704291751006\",\"refOlId\":\"4181722704291751006\",\"refSkuId\":\"0\",\"refSpuId\":\"865893808768\",\"refundFee\":98.86,\"refundStatus\":\"SUCCESS\",\"title\":\"新年会抽奖券定制2025蛇年公司活动正副可撕代金券打印纪念票根奖品兑换尾牙晚宴邀请卡号码牌创意入场券设计\",\"totalFee\":98.86,\"type\":1}],\"logisticsCompany\":\"\",\"logisticsOrderNo\":\"\",\"mark2\":[],\"openBuyerNick\":\"0**\",\"openSellerNick\":\"万慕办公旗舰店\",\"posCode\":\"wanmu\",\"posId\":598798,\"reason\":\"订单信息拍错(规格/尺码/颜色等)\",\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"\",\"receiverState\":\"\",\"receiverTown\":\"\",\"receiverZip\":\"\",\"refAid\":\"313001208133750610\",\"refOid\":\"4181722704291751006\",\"refPlatform\":\"TB\",\"refType\":\"TMALL\",\"refundCreateTime\":1735287358000,\"refundFee\":\"98.86\",\"refundPhase\":\"ON_SALE\",\"refundTime\":1735289443000,\"refundUpdateTime\":1735289443000,\"refundVersion\":1735287358100,\"senderAddress\":\"\",\"senderCity\":\"\",\"senderCountry\":\"中国\",\"senderDistrict\":\"\",\"senderMobile\":\"\",\"senderName\":\"\",\"senderPhone\":\"\",\"senderState\":\"\",\"senderTown\":\"\",\"senderZip\":\"\",\"status\":\"SUCCESS\",\"statusCode\":\"SUCCESS\",\"statusName\":\"退款成功\",\"totalFee\":\"98.86\",\"type\":\"REFUND\",\"updateTime\":1735289479000}}");
  75. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  76. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  77. //preSalesHelper.dealMessageInfo("{\"bizOrder\":{\"id\":235819,\"parentId\":null,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderNo\":\"4624034580248409502\",\"shopId\":4,\"shopCode\":\"aolifu\",\"customerId\":345874,\"customerServiceId\":3184,\"thirdOrderId\":\"4624034580248409502\",\"orderPlatform\":\"TMALL\",\"openBuyerId\":\"AAEORHraABkUZRHgSx6ksuhU\",\"openBuyerNick\":\"tb278604202340\",\"openSellerNick\":\"奥丽芙旗舰店\",\"productUrl\":null,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"payAmount\":125.0,\"unrefundedAmount\":125.0,\"discountAmount\":5.0,\"csDiscountAmount\":-35.0,\"num\":13,\"province\":\"山西省\",\"city\":\"吕梁市\",\"area\":\"孝义市\",\"receiverTown\":\"孝义市\",\"address\":null,\"thirdReceiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"receiverName\":null,\"receiverMobile\":null,\"weChatId\":null,\"phone\":null,\"designContent\":\"\",\"designPics\":\"[]\",\"weChatQrPics\":\"[]\",\"addressFileUrl\":\"\",\"thirdFlag\":\"NONE\",\"remark\":null,\"sellerRemark\":\"\",\"buyerRemark\":\"\",\"timeoutRemark\":null,\"discountRemark\":null,\"status\":\"NOT_SHIPPED\",\"refundStatus\":0,\"internalStatus\":2,\"auditStatus\":null,\"auditUserId\":null,\"auditor\":null,\"customTag\":null,\"isRepurchase\":false,\"isOffline\":false,\"paymentFile\":null,\"orderTime\":\"2025-07-10 14:46:13\",\"modifyTime\":\"2025-07-10 14:46:37\",\"payTime\":\"2025-07-10 14:46:37\",\"confirmTime\":\"2025-07-10 14:51:23\",\"auditTime\":null,\"shippingTime\":null,\"finishTime\":null,\"erpCustomerServiceId\":3319,\"openBuyerID\":\"AAEORHraABkUZRHgSx6ksuhU\",\"orderFrom\":\"10\",\"receiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"bizOrderItems\":[{\"id\":310334,\"orderId\":235819,\"thirdOrderItemId\":\"4624034580248409502\",\"thirdSpuId\":\"740203900330\",\"thirdSkuId\":\"0\",\"title\":\"pvc贴纸定制防水不干胶圆形贴标自粘商标logo广告二维码标签印刷\",\"specification\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2433960672/O1CN01D0ZzzR1GppCHSoBjD_!!4611686018427382496-0-item_pic.jpg\",\"price\":10.0,\"sellPrice\":9.62,\"amount\":9.62,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"totalAmount\":125.0,\"num\":13,\"refundStatus\":\"NO_REFUND\"}],\"bizOrderSplits\":[{\"id\":151557,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328848\",\"splitNo\":\"C1_4624034580248409502\",\"splitInfoNo\":\"C2+1\",\"splitAmount\":52.64,\"quoteRecordId\":520208,\"quoteAmount\":40.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328848)-[C2+1]-80x20mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328848\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":40.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":80.00,\"width\":20.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"80x20mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":40.00,\"numberType\":\"\",\"isDianziOrder\":0},{\"id\":151558,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328853\",\"splitNo\":\"C2_4624034580248409502\",\"splitInfoNo\":\"C2+2\",\"splitAmount\":72.36,\"quoteRecordId\":520209,\"quoteAmount\":55.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328853)-[C2+2]-90x50mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328853\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":55.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":90.00,\"width\":50.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"90x50mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":55.00,\"numberType\":\"\",\"isDianziOrder\":0}]}}");
  78. /*string path = "C:\\Users\\231010\\Downloads\\tids.txt";
  79. string path1 = "C:\\Users\\231010\\Downloads\\tid.txt";
  80. string tids = File.ReadAllText(path);
  81. List<string> list = tids.Split(',').ToList();
  82. int index = 0;
  83. foreach (string item in list)
  84. {
  85. CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
  86. try
  87. {
  88. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  89. if (string.IsNullOrEmpty(ceErpTrade.buyer_nick))
  90. {
  91. sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  92. }
  93. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  94. List<string> tidList = new List<string>();
  95. if (dataTable != null && dataTable.Rows.Count > 0)
  96. {
  97. foreach (DataRow row in dataTable.Rows)
  98. {
  99. tidList.Add("'" + row["tid"].ToString() + "'");
  100. }
  101. }
  102. if (tidList.Count > 0)
  103. {
  104. sql = string.Format("SELECT count(*) as number FROM [dbo].[CE_ErpTradeCell] WITH(NOLOCK) WHERE tid in ({0}) AND IsSample = 0 ", string.Join(",", tidList));
  105. dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  106. if (dataTable != null && dataTable.Rows.Count > 0)
  107. {
  108. int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
  109. if (count > 0)
  110. {
  111. Debug.WriteLine(index++);
  112. continue;
  113. }
  114. }
  115. }
  116. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  117. }
  118. catch (Exception e)
  119. {
  120. File.AppendAllText(path1, "e:" + ceErpTrade.tid + "\n");
  121. }
  122. Debug.WriteLine(index++);
  123. }*/
  124. //string a = commonHelper.convertQNMemo("48x61mm-4款各40个-铜版纸-不干胶-覆膜模切-tb963561715-金陵-顺丰到付.粘成品.6.5cm牙签-老客户改稿找金陵拉群-16发", CeErpTradeCell.GetByCtid("2879265072537265386"));
  125. List<string> lw = new List<string>();
  126. string tid = GetPostString("ctid");
  127. string date1 = GetPostString("date1");
  128. //12-1 修改
  129. string urgent = GetPostString("urgent");
  130. string back = GetPostString("back");
  131. string offlineSearch = GetPostString("offlineSearch");
  132. int paramsCount = 0;
  133. if (!string.IsNullOrWhiteSpace(urgent))
  134. {
  135. if (urgent.Equals("true"))
  136. {
  137. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  138. }
  139. }
  140. if (!string.IsNullOrWhiteSpace(back))
  141. {
  142. if (back.Equals("true"))
  143. {
  144. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  145. }
  146. }
  147. if (!string.IsNullOrWhiteSpace(offlineSearch))
  148. {
  149. if (offlineSearch.Equals("true"))
  150. {
  151. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  152. }
  153. }
  154. //end
  155. string date2 = GetPostString("date2");
  156. string buyernick = GetPostString("buyer_nick");
  157. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  158. {
  159. if (tid.Length <= 0 && buyernick.Length <= 0)
  160. {
  161. return;
  162. }
  163. }
  164. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  165. {
  166. if (tid.Length > 0)
  167. {
  168. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  169. if (ceErpTradeCell != null)
  170. {
  171. tid = ceErpTradeCell.tid;
  172. }
  173. List<string> select_tid = getTidByCtidMore(tid);
  174. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  175. }
  176. if (buyernick.Length > 0)
  177. {
  178. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  179. }
  180. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  181. if (dw.Length > 0)
  182. {
  183. lw.Add(dw);
  184. }
  185. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  186. {
  187. string usershop = "0," + CurrentUser.User.pemShop;
  188. lw.Add(string.Format("ShopId in ({0})", usershop));
  189. }
  190. }
  191. else
  192. {
  193. if (ex_psize == 0)
  194. {
  195. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  196. }
  197. if (PKey != "admin" && poscode != "SysAdmin")
  198. {
  199. string usershop = "0," + CurrentUser.User.pemShop;
  200. lw.Add(string.Format("ShopId in ({0})", usershop));
  201. paramsCount++;
  202. }
  203. }
  204. string uploaddate1 = GetPostString("uploaddate1");
  205. string uploaddate2 = GetPostString("uploaddate2");
  206. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  207. if (update.Length > 0) lw.Add(update);
  208. string deliverydate1 = GetPostString("deliverydate1");
  209. string deliverydate2 = GetPostString("deliverydate2");
  210. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  211. if (deliverydate.Length > 0)
  212. {
  213. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  214. };
  215. string shopname = GetPostString("shopname");
  216. if (shopname.Length > 0)
  217. {
  218. CeErpShop ceErpShop = CeErpShop.GetShopIdByName(shopname);
  219. if (ceErpShop != null)
  220. {
  221. lw.Add(string.Format("shopId = {0}", ceErpShop.ID));
  222. }
  223. }
  224. string addwechat = GetPostString("addwechat");
  225. if (addwechat.Length > 0)
  226. {
  227. int addWt = Convert.ToInt32(addwechat);
  228. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  229. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  230. }
  231. string customer = GetPostString("customer");
  232. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  233. string design = GetPostString("design");
  234. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  235. string orderState = GetPostString("orderState");
  236. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  237. string address = GetPostString("address");
  238. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  239. string sellermemo = GetPostString("seller_memo");
  240. if (sellermemo.Length > 0)
  241. {
  242. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  243. }
  244. string otherMemo = GetPostString("otherMemo");
  245. if (otherMemo.Length > 0)
  246. {
  247. lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  248. }
  249. string backReason = GetPostString("backReason");
  250. if (backReason.Length > 0)
  251. {
  252. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  253. }
  254. string apdate1 = GetPostString("apdate1");
  255. string apdate2 = GetPostString("apdate2");
  256. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  257. if (dwap.Length > 0) lw.Add(dwap);
  258. string price1 = GetPostString("price1");
  259. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  260. string price2 = GetPostString("price2");
  261. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  262. string isoldcustomer = GetPostString("isoldcus");
  263. string buyer_id = GetPostString("buyer_id");
  264. if (buyer_id.Length > 0) lw.Add(string.Format("buyer_id = '{0}'", buyer_id));
  265. string spudata = GetPostString("spudata");
  266. if ("0".Equals(spudata))
  267. {
  268. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  269. }
  270. if ("1".Equals(spudata))
  271. {
  272. lw.Add(string.Format("spu_id <> ''"));
  273. }
  274. string finishdate1 = GetPostString("finishdate1");
  275. string finishdate2 = GetPostString("finishdate2");
  276. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  277. bool isFinish = false;
  278. if (finishdate.Length > 0)
  279. {
  280. lw.Add(finishdate);
  281. isFinish = true;
  282. paramsCount++;
  283. }
  284. if (isoldcustomer.Length > 0)
  285. {
  286. if ("2".Equals(isoldcustomer))
  287. {
  288. lw.Add(string.Format("VipCustomer=1"));
  289. }
  290. else
  291. {
  292. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  293. }
  294. }
  295. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  296. if (ex_psize > 0)
  297. {
  298. int UserID = CurrentUser.UserID;
  299. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  300. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  301. {
  302. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  303. }
  304. dStruct.Order = "pay_time desc";
  305. }
  306. string isNew = GetPostString("isNew");
  307. if (isNew == "true")
  308. {
  309. lw.Add(string.Format("IsNew = {0}", 1));
  310. }
  311. string overtime = GetPostString("overtime");
  312. if (overtime == "1")
  313. {
  314. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  315. }
  316. String usePost = CurrentUser.UserPost.Post.Code;
  317. if (usePost.Equals("Operation") == true)
  318. {
  319. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  320. }
  321. else
  322. {
  323. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  324. }
  325. //dStruct.Fileds = "tid,ctid,SplitTag,pay_time,seller_nick,buyer_nick,payment,seller_memo,OrderState,status,CustomerTb,DesignUserName,DesignPrice,end_time,WaitDesignTime,FinishDesignTime,FinishDeliveryTime,buyer_message,SupplierName,OutSid,receiver_name,receiver_mobile,receiver_state,receiver_city,receiver_address,isRefund,IsUrgency";
  326. if (dStruct.PageSize == 100000)
  327. {
  328. dStruct.Order = "";
  329. }
  330. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  331. DataTable dt = null;
  332. string tablename = "view_orderlist";
  333. if (isFinish)
  334. {
  335. tablename = "view_orderlist_end";
  336. }
  337. dt = WebCache.GetData(tablename, dStruct);
  338. if (dt != null && dt.Rows.Count > 0)
  339. {
  340. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  341. foreach (DataRow dr in dt.Rows)
  342. {
  343. try
  344. {
  345. if (dr["refund_fees"] != null)
  346. {
  347. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  348. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  349. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  350. if (payment == refund_fees)
  351. {
  352. dr["refund_fees"] = Math.Round(refund_fees, 2);
  353. }
  354. else if (refund_fees == total_fee)
  355. {
  356. dr["refund_fees"] = payment;
  357. }
  358. else
  359. {
  360. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  361. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  362. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  363. }
  364. }
  365. // 对象操作
  366. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  367. ceErpTradeCell.ctid = dr["ctid"].ToString();
  368. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  369. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  370. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  371. if (dStruct.PageSize != 100000)
  372. {
  373. if (dr["DispatchSort"].ToString() == "2")
  374. {
  375. dr["gongchuang"] = 200;
  376. }
  377. else if ("外协".Equals(dr["ToType"].ToString()))
  378. {
  379. dr["gongchuang"] = 200;
  380. }
  381. else if ("内部".Equals(dr["ToType"].ToString()))
  382. {
  383. dr["gongchuang"] = -1;
  384. }
  385. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  386. {
  387. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  388. dr["gongchuang"] = response.code;
  389. }
  390. }
  391. }
  392. catch (NullReferenceException ex)
  393. {
  394. // 处理空引用异常
  395. dr["refund_fees"] = "0.00";
  396. }
  397. }
  398. }
  399. writeGridDataTableJson(dStruct.TotalCount, dt);
  400. }
  401. public void get_erp_orderlist_sumprice()
  402. {
  403. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  404. return;
  405. List<string> lw = new List<string>();
  406. string tid = GetPostString("ctid");
  407. string date1 = GetPostString("date1");
  408. string date2 = GetPostString("date2");
  409. if (tid.Length > 0 || date1.Length > 0)
  410. {
  411. lw.Add(string.Format("ctid like '%{0}%'", tid));
  412. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  413. if (dw.Length > 0) lw.Add(dw);
  414. }
  415. else
  416. {
  417. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  418. }
  419. string shopname = GetPostString("shopname");
  420. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  421. string buyernick = GetPostString("buyer_nick");
  422. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  423. string customer = GetPostString("customer");
  424. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  425. string design = GetPostString("design");
  426. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  427. string orderState = GetPostString("orderState");
  428. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  429. string address = GetPostString("address");
  430. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  431. string sellermemo = GetPostString("seller_memo");
  432. if (sellermemo.Length > 0)
  433. {
  434. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  435. }
  436. string apdate1 = GetPostString("apdate1");
  437. string apdate2 = GetPostString("apdate2");
  438. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  439. if (dwap.Length > 0) lw.Add(dwap);
  440. string price1 = GetPostString("price1");
  441. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  442. string price2 = GetPostString("price2");
  443. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  444. string isoldcustomer = GetPostString("isoldcus");
  445. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  446. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  447. if (PKey != "admin")
  448. {
  449. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  450. lw.Add(string.Format("shopId in ({0})", usershop));
  451. }
  452. //dStruct.Fileds = "tid,ctid,SplitTag,pay_time,seller_nick,buyer_nick,payment,seller_memo,OrderState,status,CustomerTb,DesignUserName,DesignPrice,end_time,WaitDesignTime,FinishDesignTime,FinishDeliveryTime,buyer_message,SupplierName,OutSid,receiver_name,receiver_mobile,receiver_state,receiver_city,receiver_address,isRefund,IsUrgency";
  453. string mainWhere = string.Join(" and ", lw.ToArray());
  454. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  455. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  456. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  457. decimal total = 0;
  458. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  459. {
  460. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  461. }
  462. var res = new
  463. {
  464. data = total
  465. };
  466. string ro_jsond = JsonConvert.SerializeObject(res);
  467. returnSuccess(ro_jsond);
  468. return;
  469. }
  470. public void get_erp_CustomerServiceGather()
  471. {
  472. string userWhere = "", orderWhere = "";
  473. List<string> lw = new List<string>();
  474. string customer = GetPostString("customer");
  475. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  476. string shopname = GetPostString("shopname");
  477. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  478. string date1 = GetPostString("date1");
  479. string date2 = GetPostString("date2");
  480. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  481. if (dw.Length > 0) lw.Add(dw);
  482. orderWhere = string.Join(" and ", lw.ToArray());
  483. string sql = string.Format("select a.Name CusName,isnull(b.Amount,0) Amount, isnull(b.AllOrder,0) AllOrder, isnull(d.WaitRelease,0) WaitRelease, isnull(e.WaitRob,0) WaitRob, isnull(f.RefundCount,0) RefundCount, isnull(f.RefundSum,0) RefundSum " +
  484. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  485. "left join " +
  486. "( " +
  487. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  488. ") as b on a.ID = b.CustomerUserId " +
  489. "left join " +
  490. "( " +
  491. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  492. ") as d on a.ID = d.CustomerUserId " +
  493. "left join " +
  494. "( " +
  495. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  496. ") as e on a.ID = e.CustomerUserId " +
  497. "left join " +
  498. "( " +
  499. " select CustomerUserId, RefundCount, RefundSum from " +
  500. " ( " +
  501. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  502. " from CE_ErpTradeRefund a " +
  503. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  504. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  505. " group by CustomerUserId " +
  506. " ) as a " +
  507. ") as f on a.ID = f.CustomerUserId " +
  508. "where a.PostCode = 'CustomerService'",
  509. userWhere, orderWhere);
  510. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  511. writeGridDataTableJson(dt.Rows.Count, dt);
  512. //writeGridDataTableJson(dt.Rows.Count, dt);
  513. }
  514. //设计汇总
  515. public void get_erp_DesignerGather()
  516. {
  517. string userWhere = "", orderWhere = "";
  518. List<string> lw = new List<string>();
  519. string Designer = GetPostString("designer");
  520. int org = GetPostInt("org");
  521. if (Designer.Length > 0)
  522. {
  523. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  524. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  525. }
  526. else if (org > 0)
  527. {
  528. userWhere = string.Format(" where OrgID ={0}", org);
  529. }
  530. string shopname = GetPostString("shopname");
  531. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  532. string state = GetPostString("state");
  533. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  534. string OrderArea = GetPostString("order_area");
  535. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  536. string date1 = GetPostString("date1");
  537. string date2 = GetPostString("date2");
  538. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  539. if (dw.Length > 0) lw.Add(dw);
  540. string UpDate1 = GetPostString("UpDate1");
  541. string UpDate2 = GetPostString("UpDate2");
  542. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  543. if (dw.Length > 0) lw.Add(dw);
  544. orderWhere = string.Join(" and ", lw.ToArray());
  545. string sql = string.Format("select *,cast(cast(z.DesignFinish as float) / (case z.AllOrder when 0 then 1 else z.AllOrder end) * 100 as numeric(18,2)) as FinalizationRate from (" +
  546. "select a.Name DesignerName,isnull(b.Amount,0) Amount, isnull(b.AllOrder,0) AllOrder, isnull(d.WaitDesign,0) WaitDesign, isnull(e.Designing,0) Designing, isnull(g.DesignFinish,0) DesignFinish, isnull(f.RefundCount,0) RefundCount, isnull(f.RefundSum,0) RefundSum " +
  547. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  548. "left join " +
  549. "( " +
  550. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  551. ") as b on a.ID = b.DesignUserId " +
  552. "left join " +
  553. "( " +
  554. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  555. ") as d on a.ID = d.DesignUserId " +
  556. "left join " +
  557. "( " +
  558. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  559. ") as e on a.ID = e.DesignUserId " +
  560. "left join " +
  561. "( " +
  562. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  563. ") as g on a.ID = g.DesignUserId " +
  564. "left join " +
  565. "( " +
  566. " select CustomerUserId, RefundCount, RefundSum from " +
  567. " ( " +
  568. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  569. " from CE_ErpTradeRefund a " +
  570. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  571. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  572. " group by CustomerUserId " +
  573. " ) as a " +
  574. ") as f on a.ID = f.CustomerUserId " +
  575. "where a.PostCode = 'Designer') as z",
  576. userWhere, orderWhere);
  577. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  578. writeGridDataTableJson(dt.Rows.Count, dt);
  579. }
  580. //删除tradecell的订单
  581. public void del_erp_cellorder()
  582. {
  583. if (UrlPostParmsCheck("ctid"))
  584. {
  585. string eid = GetPostString("ctid");
  586. CeErpTradeCell.DelByCtid(eid);
  587. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  588. returnSuccessMsg("删除成功");
  589. }
  590. }
  591. public void clear_erp_refundstate()
  592. {
  593. if (UrlPostParmsCheck("ids"))
  594. {
  595. string eids = GetPostString("ids");
  596. string[] ctidList = eids.Split(',');
  597. foreach (string ctid in ctidList)
  598. {
  599. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  600. if (entity != null)
  601. {
  602. entity.IsRefund = 0;
  603. entity.Update();
  604. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  605. }
  606. else
  607. continue;
  608. }
  609. returnSuccessMsg("操作成功");
  610. return;
  611. }
  612. returnErrorMsg("缺少必要参数");
  613. }
  614. public void set_erp_urgency()
  615. {
  616. if (UrlPostParmsCheck("ctid"))
  617. {
  618. string eid = GetPostString("ctid");
  619. CeErpTradeCell entity = null;
  620. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  621. if (entity != null)
  622. {
  623. double prices = commonHelper.calculationPrice(entity);
  624. if (prices <= 100)
  625. {
  626. returnErrorMsg("此订单金额不足100元,无法加急。");
  627. return;
  628. }
  629. string utime = GetPostString("urgencytime");
  630. if (utime.Length > 0)
  631. {
  632. entity.UrgencyTime = Convert.ToDateTime(utime);
  633. }
  634. else
  635. {
  636. returnErrorMsg("请选择加急时间");
  637. return;
  638. }
  639. if (entity.OrderState <= 4)
  640. {
  641. //entity.seller_memo = entity.seller_memo + "-加急";
  642. string smemo = entity.seller_memo;
  643. int kindex = smemo.IndexOf(")");
  644. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  645. if (lastoneStr != "-")
  646. {
  647. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  648. }
  649. string prememo = smemo.Substring(0, kindex + 2);
  650. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  651. int lastkindex = lastmemo.IndexOf("(");
  652. DateTime urgtime = Convert.ToDateTime(utime);
  653. string newlastmemo = "";
  654. if (lastkindex == 0)
  655. {
  656. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  657. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  658. }
  659. else
  660. {
  661. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  662. }
  663. entity.seller_memo = prememo + newlastmemo;
  664. }
  665. entity.IsUrgency = true;
  666. entity.UpdateTime = DateTime.Now;
  667. entity.Update();
  668. ApiVo apiVo = new ApiVo();
  669. apiVo.orderNumber = entity.ctid;
  670. apiVo.actionName = "changeDesign";
  671. apiVo.orderRemarks = entity.seller_memo;
  672. apiVo.remarkSign = 3;
  673. designHelper.API_WorkCore(apiVo); //changeDesign
  674. CeErpSukuraData.createInfo(entity.ctid, 7);
  675. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  676. returnSuccessMsg("设置成功!");
  677. return;
  678. }
  679. returnErrorMsg("找不到记录");
  680. }
  681. }
  682. public void set_erp_reset()
  683. {
  684. if (UrlPostParmsCheck("ctid"))
  685. {
  686. string eid = GetPostString("ctid");
  687. CeErpTradeCell entity = null;
  688. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  689. if (entity != null)
  690. {
  691. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  692. {
  693. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  694. {
  695. returnErrorMsg("财务要求已下单已发货无法重置");
  696. return;
  697. }
  698. }
  699. entity.IsUrgency = false;
  700. entity.seller_memo = "";
  701. entity.OtherMemo = "";
  702. entity.OrderState = 0;
  703. entity.IsReturn = 0;
  704. //entity.IsRefund = 0;
  705. entity.MemoOpt = 0;
  706. entity.AfterSaleState = 0;
  707. entity.AfterSaleResponsible = "";
  708. entity.AfterSaleUserId = 0;
  709. entity.IsNeedBill = 0;
  710. entity.CustomerUserId = 0;
  711. entity.DesignUserId = 0;
  712. entity.SupplierId = 0;
  713. entity.PlaceUserId = 0;
  714. entity.ptid = "";
  715. entity.IsSample = 0;
  716. entity.IsXianHuo = 0;
  717. entity.isDianziOrder = 0;
  718. entity.DispatchSort = 0;
  719. entity.IsVerifyToSupplier = false;
  720. entity.FinishPlaceTime = null;
  721. entity.Update();
  722. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  723. if (trade != null)
  724. {
  725. trade.seller_memo = "";
  726. trade.Update();
  727. }
  728. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  729. returnSuccessMsg("重置成功!");
  730. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  731. if (desginBill != null)
  732. {
  733. desginBill.isDel = 1;
  734. desginBill.Update();
  735. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  736. }
  737. ApiVo apiVo = new ApiVo();
  738. apiVo.orderNumber = entity.ctid;
  739. apiVo.actionName = "resetDesign";
  740. designHelper.API_WorkCore(apiVo);//resetDesign
  741. return;
  742. }
  743. returnErrorMsg("找不到记录");
  744. }
  745. }
  746. public void save_erp_sellermemo()
  747. {
  748. if (UrlPostParmsCheck("ctid"))
  749. {
  750. string ctid = GetPostString("ctid");
  751. CeErpTradeCell entity = null;
  752. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  753. if (entity != null)
  754. {
  755. string memo = GetPostString("seller_memo");
  756. string qn_memo = GetPostString("qn_memo");
  757. memo = memo.Replace(" ", "");
  758. if (memo.Contains("补差"))
  759. {
  760. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  761. return;
  762. }
  763. List<string> bitList = new List<string>
  764. {
  765. "\\","/",":","*","?", "\"","<" ,">","|"
  766. };
  767. bool isIn = false;
  768. foreach (string bit in bitList)
  769. {
  770. if (memo.Contains(bit))
  771. {
  772. isIn = true;
  773. }
  774. }
  775. if (isIn)
  776. {
  777. returnErrorMsg("不能使用 一些符合作为文件名");
  778. return;
  779. }
  780. if (entity.seller_memo != memo)
  781. {
  782. if (entity.IsSample == 2)
  783. {
  784. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  785. return;
  786. }
  787. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  788. {
  789. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  790. {
  791. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  792. return;
  793. }
  794. /*if (CurrentUser.UserPost.Post.Code != "Place")
  795. {
  796. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  797. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  798. {
  799. returnErrorMsg("售前系统订单无法再此修改!");
  800. return;
  801. }
  802. }*/
  803. }
  804. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  805. }
  806. if (!string.IsNullOrEmpty(qn_memo) && !(entity.IsSample > 0 || entity.ctid.Contains("N_") || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物")))
  807. {
  808. if (entity.OrderState >= 5)
  809. {
  810. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  811. return;
  812. }
  813. string delMemo = commonHelper.convertQNMemo(qn_memo, ref entity);
  814. if (string.IsNullOrEmpty(delMemo))
  815. {
  816. returnErrorMsg("备注不规范,无法识别");
  817. return;
  818. }
  819. memo = delMemo;
  820. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统千牛修改为:" + memo, entity.OrderState, 1);
  821. }
  822. //commonHelper.getCytPrice(entity);
  823. int memoopt = GetPostInt("MemoOpt");
  824. Boolean ismemoopt = false;
  825. if (memoopt > 0)
  826. {
  827. string stropt = "";
  828. if (memoopt == 1)
  829. {
  830. stropt = "“改稿”";
  831. ismemoopt = true;
  832. }
  833. else if (memoopt == 2)
  834. {
  835. stropt = "“定稿”";
  836. }
  837. else if (memoopt == 3)
  838. {
  839. stropt = "“查货”";
  840. CeErpSukuraData.createInfo(entity.ctid, 6);
  841. }
  842. entity.MemoOpt = Convert.ToInt32(memoopt);
  843. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  844. }
  845. if (entity.OrderState < 5)
  846. {
  847. memo = memo.Replace("(", "(");
  848. memo = memo.Replace(")", ")");
  849. }
  850. /* if (entity.OrderState < 3)
  851. {
  852. entity.DispatchSort = 0;
  853. }*/
  854. entity.seller_memo = memo;
  855. entity.UpdateTime = DateTime.Now;
  856. entity.Update();
  857. ApiVo apiVo = new ApiVo();
  858. apiVo.orderNumber = entity.ctid;
  859. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  860. apiVo.orderRemarks = memo;
  861. apiVo.remarkSign = memoopt;
  862. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  863. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  864. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  865. {
  866. //dataHelper.api_orderBack(entity.ctid, "0", "");
  867. }
  868. if (entity.seller_memo.Contains("改稿"))
  869. {
  870. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  871. }
  872. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  873. returnSuccessMsg("保存成功!");
  874. return;
  875. }
  876. returnErrorMsg("找不到记录");
  877. }
  878. }
  879. public void ins_erp_checkorder()
  880. {
  881. if (UrlPostParmsCheck("ctid"))
  882. {
  883. string ctid = GetPostString("ctid");
  884. CeErpTradeCell entity = null;
  885. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  886. if (entity != null)
  887. {
  888. if (entity.OrderState < 6)
  889. {
  890. returnErrorMsg("下单完成后才可查货");
  891. return;
  892. }
  893. /*if (entity.OrderState > 6)
  894. {
  895. returnErrorMsg("订单已发货");
  896. return;
  897. }*/
  898. if (entity.FinishPlaceTime != null)
  899. {
  900. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  901. {
  902. returnErrorMsg("下单时间不足,无法查货");
  903. return;
  904. }
  905. }
  906. entity.MemoOpt = 3;
  907. entity.CheckOrderTime = DateTime.Now;
  908. entity.UpdateTime = DateTime.Now;
  909. entity.Update();
  910. CeErpSukuraData.createInfo(entity.ctid, 6);
  911. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  912. returnSuccessMsg("操作成功!");
  913. return;
  914. }
  915. returnErrorMsg("找不到记录");
  916. }
  917. }
  918. public void save_erp_othermemo()
  919. {
  920. if (UrlPostParmsCheck("ctid"))
  921. {
  922. string ctid = GetPostString("ctid");
  923. CeErpTradeCell entity = null;
  924. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  925. if (entity != null)
  926. {
  927. entity.OtherMemo = GetPostString("otherMemo");
  928. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  929. {
  930. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  931. StringBuilder sql = new StringBuilder();
  932. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  933. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  934. if (dt != null && dt.Rows.Count > 0)
  935. {
  936. foreach (DataRow dr in dt.Rows)
  937. {
  938. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  939. {
  940. //品类一直
  941. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  942. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  943. if (ceErpSampleCustomer == null)
  944. {
  945. ceErpSampleCustomer = new CeErpSampleCustomer();
  946. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  947. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  948. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  949. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  950. ceErpSampleCustomer.shopId = entity.ShopId;
  951. }
  952. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  953. ceErpSampleCustomer.lastTid = entity.tid;
  954. if (ceErpSampleCustomer.ID > 0)
  955. {
  956. ceErpSampleCustomer.Update();
  957. }
  958. else
  959. {
  960. ceErpSampleCustomer.Create();
  961. }
  962. }
  963. }
  964. }
  965. }
  966. //if (entity.IsOldCustomer == 1)
  967. //{
  968. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  969. //{
  970. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  971. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  972. //}
  973. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  974. //{
  975. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  976. // {
  977. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  978. // {
  979. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  980. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  981. // }
  982. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  983. // {
  984. // entity.OrderState = 2;
  985. // entity.DesignUserId = 0;
  986. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  987. // }
  988. // else
  989. // {
  990. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  991. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  992. // }
  993. // }
  994. //}
  995. //}
  996. entity.UpdateTime = DateTime.Now;
  997. entity.Update();
  998. returnSuccessMsg("保存成功!");
  999. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  1000. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  1001. if (entity.OtherMemo.Contains("改稿"))
  1002. {
  1003. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  1004. }
  1005. return;
  1006. }
  1007. returnErrorMsg("找不到记录");
  1008. }
  1009. }
  1010. public void save_erp_customermemo()
  1011. {
  1012. if (UrlPostParmsCheck("ctid"))
  1013. {
  1014. string ctid = GetPostString("ctid");
  1015. CeErpTradeCell entity = null;
  1016. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  1017. if (entity != null)
  1018. {
  1019. entity.UpdateTime = DateTime.Now;
  1020. entity.CustomerMemo = GetPostString("CustomerMemo");
  1021. entity.Update();
  1022. ApiVo apiVo = new ApiVo();
  1023. apiVo.orderNumber = entity.ctid;
  1024. apiVo.actionName = "followRemarks";
  1025. apiVo.orderRemarks = entity.CustomerMemo;
  1026. designHelper.API_WorkCore(apiVo);//followRemarks
  1027. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1028. returnSuccessMsg("保存成功!");
  1029. return;
  1030. }
  1031. returnErrorMsg("找不到记录");
  1032. }
  1033. }
  1034. public void upd_erp_addmemotag()
  1035. {
  1036. if (UrlPostParmsCheck("ctid"))
  1037. {
  1038. ;
  1039. string eid = GetPostString("ctid");
  1040. string sfTagstr = GetPostString("memotag");
  1041. CeErpTradeCell entity = null;
  1042. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1043. if (entity != null)
  1044. {
  1045. ApiVo apiVo = new ApiVo();
  1046. if (entity.OrderState == 0)
  1047. {
  1048. returnErrorMsg("请先领单");
  1049. return;
  1050. }
  1051. //撤销顺丰
  1052. if (sfTagstr == "撤销顺丰")
  1053. {
  1054. entity.IsSF = 0;
  1055. string reMsg = "";
  1056. string oldmemo = entity.seller_memo;
  1057. if (entity.OrderState < 5)
  1058. {
  1059. oldmemo = oldmemo.Replace("顺丰到付", "");
  1060. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1061. entity.seller_memo = oldmemo;
  1062. }
  1063. else
  1064. {
  1065. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1066. {
  1067. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1068. }
  1069. }
  1070. entity.Update();
  1071. apiVo.orderNumber = entity.ctid;
  1072. apiVo.actionName = "orderRemarks";
  1073. apiVo.orderRemarks = entity.seller_memo;
  1074. apiVo.isSf = entity.IsSF.ToString();
  1075. designHelper.API_WorkCore(apiVo);//orderRemarks
  1076. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1077. returnSuccessMsg("撤销成功!" + reMsg);
  1078. return;
  1079. }
  1080. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1081. {
  1082. //string oldmemo = entity.seller_memo;
  1083. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1084. string sfStr = GetPostString("memotag");
  1085. string smemo = entity.seller_memo;
  1086. int kindex = smemo.IndexOf(")");
  1087. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1088. if (lastoneStr != "-")
  1089. {
  1090. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1091. }
  1092. string prememo = smemo.Substring(0, kindex + 2);
  1093. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1094. int lastkindex = lastmemo.IndexOf("(");
  1095. string newlastmemo = "";
  1096. if (lastkindex == 0)
  1097. {
  1098. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1099. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1100. }
  1101. else
  1102. {
  1103. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1104. }
  1105. entity.seller_memo = prememo + newlastmemo;
  1106. }
  1107. string sfTagMSg = "";
  1108. if (sfTagstr == "顺丰寄付")
  1109. {
  1110. entity.IsSF = 1;
  1111. sfTagMSg = "顺丰寄付";
  1112. }
  1113. else if (sfTagstr == "顺丰到付")
  1114. {
  1115. entity.IsSF = 2;
  1116. sfTagMSg = "顺丰到付";
  1117. }
  1118. if (entity.SupplierId == 19 && entity.OrderState == 6)
  1119. {
  1120. string deliveryWayName = "";
  1121. if (sfTagstr == "撤销顺丰")
  1122. {
  1123. sfTagstr = "普通快递";
  1124. }
  1125. if (sfTagstr == "顺丰寄付")
  1126. {
  1127. sfTagstr = "顺丰特快寄付";
  1128. }
  1129. if (sfTagstr == "顺丰到付")
  1130. {
  1131. sfTagstr = "顺丰特快到付";
  1132. }
  1133. string result = apichyHelper.updateExpressMark(entity.tid, sfTagstr);
  1134. if ("修改失败".Equals(result))
  1135. {
  1136. returnErrorMsg("修改失败");
  1137. return;
  1138. }
  1139. }
  1140. entity.Update();
  1141. apiVo = new ApiVo();
  1142. apiVo.orderNumber = entity.ctid;
  1143. apiVo.actionName = "orderRemarks";
  1144. apiVo.orderRemarks = entity.seller_memo;
  1145. apiVo.isSf = entity.IsSF.ToString();
  1146. designHelper.API_WorkCore(apiVo);//orderRemarks
  1147. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1148. returnSuccessMsg("标记成功!");
  1149. return;
  1150. }
  1151. returnErrorMsg("找不到记录");
  1152. }
  1153. }
  1154. public void upd_erp_ordertag()
  1155. {
  1156. if (UrlPostParmsCheck("ctid"))
  1157. {
  1158. string eid = GetPostString("ctid");
  1159. CeErpTradeCell entity = null;
  1160. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1161. if (entity != null)
  1162. {
  1163. int tag = GetPostInt("wechattag");
  1164. //if(tag==4 && entity.IsSample == 2)
  1165. //{
  1166. // returnErrorMsg("补差价单不能标记微信单");
  1167. // return;
  1168. //}
  1169. entity.wechatTag = tag;
  1170. entity.Update();
  1171. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1172. if (tag == 1)
  1173. {
  1174. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1175. if (cash == null)
  1176. {
  1177. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1178. cash = new CeErpReturnCash();
  1179. cash.tid = entity.tid;
  1180. cash.seller_nick = main.seller_nick;
  1181. cash.payment = trade.payment;
  1182. cash.buyer_nick = main.buyer_nick;
  1183. cash.cashstate = 0;
  1184. cash.rtype = "微信返现";
  1185. cash.returnprice = 0;
  1186. cash.created = DateTime.Now;
  1187. cash.con = "订单标记微信单";
  1188. cash.img = "";
  1189. cash.applyuserid = CurrentUser.UserID;
  1190. cash.Create();
  1191. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1192. }
  1193. else
  1194. {
  1195. cash.cashstate = 0;
  1196. cash.Update();
  1197. }
  1198. CeErpSukuraData.createInfo(entity.ctid, 9);
  1199. }
  1200. else if (tag == 2)
  1201. {
  1202. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1203. if (cash == null)
  1204. {
  1205. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1206. cash = new CeErpReturnCash();
  1207. cash.tid = entity.tid;
  1208. cash.seller_nick = main.seller_nick;
  1209. cash.payment = trade.payment;
  1210. cash.buyer_nick = main.buyer_nick;
  1211. cash.cashstate = 0;
  1212. cash.rtype = "推购返现";
  1213. cash.returnprice = 5;
  1214. cash.created = DateTime.Now;
  1215. cash.con = "订单标记推购单";
  1216. cash.img = "";
  1217. cash.applyuserid = CurrentUser.UserID;
  1218. cash.Create();
  1219. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1220. }
  1221. else
  1222. {
  1223. cash.cashstate = 0;
  1224. cash.Update();
  1225. }
  1226. CeErpSukuraData.createInfo(entity.ctid, 9);
  1227. }
  1228. else if (tag == 3)
  1229. {
  1230. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1231. if (pers == null)
  1232. {
  1233. pers = new CeErpPersuade();
  1234. pers.ctid = entity.ctid;
  1235. pers.pstate = 0;
  1236. pers.created = DateTime.Now;
  1237. pers.applyuserid = CurrentUser.UserID;
  1238. pers.Create();
  1239. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1240. }
  1241. else
  1242. {
  1243. pers.pstate = 0;
  1244. pers.Update();
  1245. }
  1246. }
  1247. else if (tag == 4 || tag == 5)
  1248. {
  1249. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1250. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1251. if (pers == null)
  1252. {
  1253. pers = CeErpStayGoods.GetByTid(entity.tid);
  1254. }
  1255. if (pers == null)
  1256. {
  1257. pers = new CeErpStayGoods();
  1258. pers.t_id = entity.tid;
  1259. pers.ctid = entity.ctid;
  1260. pers.status = "待审核";
  1261. pers.audit_type = 0;
  1262. if (tag == 4)
  1263. {
  1264. pers.stay_type = "微信推购";
  1265. }
  1266. else
  1267. {
  1268. pers.stay_type = "旺旺推购";
  1269. }
  1270. if (entity.IsXianHuo == 0)
  1271. {
  1272. pers.product_id = entity.ProductId;
  1273. }
  1274. pers.wangwang = main.buyer_nick;
  1275. pers.shop_name = main.seller_nick;
  1276. pers.creata_time = DateTime.Now;
  1277. pers.create_u_id = CurrentUser.UserID;
  1278. pers.create_u_name = CurrentUser.UserName;
  1279. pers.Create();
  1280. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1281. }
  1282. else
  1283. {
  1284. pers.ctid = entity.ctid;
  1285. pers.audit_type = 0;
  1286. pers.Update();
  1287. }
  1288. CeErpSukuraData.createInfo(entity.ctid, 10);
  1289. }
  1290. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1291. returnSuccessMsg("标记成功!");
  1292. return;
  1293. }
  1294. returnErrorMsg("找不到记录");
  1295. }
  1296. }
  1297. public void upd_erp_ordertag_cancel()
  1298. {
  1299. if (UrlPostParmsCheck("ctid"))
  1300. {
  1301. string eid = GetPostString("ctid");
  1302. CeErpTradeCell entity = null;
  1303. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1304. if (entity != null)
  1305. {
  1306. entity.wechatTag = 0;
  1307. entity.Update();
  1308. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1309. if (pers != null)
  1310. {
  1311. pers.status = "取消推购";
  1312. pers.audit_type = 3;
  1313. pers.Update();
  1314. }
  1315. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1316. returnSuccessMsg("标记成功!");
  1317. return;
  1318. }
  1319. returnErrorMsg("找不到记录");
  1320. }
  1321. }
  1322. public void upd_erp_addweichattag()
  1323. {
  1324. if (UrlPostParmsCheck("ctid"))
  1325. {
  1326. ;
  1327. string eid = GetPostString("ctid");
  1328. CeErpTradeCell entity = null;
  1329. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1330. if (entity != null)
  1331. {
  1332. if (entity.IsAddWechat > 0)
  1333. {
  1334. returnErrorMsg("此单已经标记过了");
  1335. return;
  1336. }
  1337. string sql = string.Format("select * from view_erptradecell where IsAddWechat>0 and buyer_nick=(select buyer_nick from ce_erptrade where tid='{0}')", entity.tid);
  1338. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1339. if (dt.Rows.Count > 0)
  1340. {
  1341. entity.IsAddWechat = 2;
  1342. }
  1343. else
  1344. {
  1345. entity.IsAddWechat = 1;
  1346. }
  1347. entity.Update();
  1348. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1349. returnSuccessMsg("标记成功!");
  1350. return;
  1351. }
  1352. returnErrorMsg("找不到记录");
  1353. }
  1354. }
  1355. public void upd_erp_getmyorder()
  1356. {
  1357. if (UrlPostParmsCheck("ctid"))
  1358. {
  1359. string eid = GetPostString("ctid");
  1360. CeErpTradeCell entity = null;
  1361. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1362. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1363. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1364. {
  1365. returnErrorMsg("台湾客户需填写身份证号!");
  1366. return;
  1367. }
  1368. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1369. {
  1370. returnErrorMsg("偏远地区需要填写物流费!");
  1371. return;
  1372. }
  1373. if (entity != null)
  1374. {
  1375. if (entity.ctid.IndexOf("C") != -1)
  1376. {
  1377. StringBuilder sql = new StringBuilder();
  1378. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1379. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1380. if (dt.Rows.Count > 0)
  1381. {
  1382. decimal total = 0;
  1383. foreach (DataRow dr in dt.Rows)
  1384. {
  1385. total += Convert.ToDecimal(dr["payment"]);
  1386. }
  1387. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1388. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1389. {
  1390. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1391. return;
  1392. }
  1393. }
  1394. }
  1395. if (entity.OrderState == -1)
  1396. {
  1397. returnErrorMsg("待审核订单无法领取!");
  1398. return;
  1399. }
  1400. entity.CustomerUserId = CurrentUser.UserID;
  1401. if (entity.OrderState < 2)
  1402. {
  1403. entity.OrderState = 2;
  1404. if (entity.ShopId != 0)
  1405. {
  1406. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1407. }
  1408. }
  1409. entity.UpdateTime = DateTime.Now;
  1410. entity.Update();
  1411. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1412. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1413. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1414. {
  1415. //dataHelper.api_orderBack(entity.ctid, "0", "");
  1416. }
  1417. returnSuccessMsg("领单成功!");
  1418. return;
  1419. }
  1420. returnErrorMsg("找不到记录");
  1421. }
  1422. }
  1423. public void getmyorder_from_init()
  1424. {
  1425. if (UrlPostParmsCheck("ctid"))
  1426. {
  1427. string eid = GetPostString("ctid");
  1428. CeErpTradeCell entity = null;
  1429. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1430. if (entity != null)
  1431. {
  1432. string sellerMemo = GetPostString("sellerMemo");
  1433. if (sellerMemo.Length > 0)
  1434. {
  1435. entity.seller_memo = sellerMemo;
  1436. }
  1437. string oterhMemo = GetPostString("otherMemo");
  1438. if (oterhMemo.Length > 0)
  1439. {
  1440. entity.OtherMemo = oterhMemo;
  1441. }
  1442. int urg = GetPostInt("urgency");
  1443. entity.IsUrgency = (urg == 1 ? true : false);
  1444. int wechat = GetPostInt("wechat");
  1445. int command = GetPostInt("command");
  1446. if (wechat == 1)
  1447. {
  1448. entity.wechatTag = 1;
  1449. }
  1450. if (command == 1)
  1451. {
  1452. entity.wechatTag = 2;
  1453. }
  1454. string pPro = GetPostString("pprofession");
  1455. if (pPro.Length > 0)
  1456. {
  1457. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1458. string spro = GetPostString("profession");
  1459. if (spro.Length > 0)
  1460. {
  1461. entity.ProfessionId = Convert.ToInt32(spro);
  1462. }
  1463. }
  1464. string proId = GetPostString("productId");
  1465. if (proId.Length > 0)
  1466. {
  1467. entity.ProductId = Convert.ToInt32(proId);
  1468. }
  1469. entity.Material = GetPostString("material");
  1470. entity.Craft = GetPostString("craft");
  1471. entity.CustomerUserId = CurrentUser.UserID;
  1472. if (entity.OrderState < 2)
  1473. {
  1474. entity.OrderState = 2;
  1475. if (entity.ShopId != 0)
  1476. {
  1477. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1478. }
  1479. }
  1480. entity.Update();
  1481. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1482. returnSuccessMsg("领单成功!");
  1483. return;
  1484. }
  1485. returnErrorMsg("找不到记录");
  1486. }
  1487. }
  1488. public void upd_erp_setrelationorder()
  1489. {
  1490. if (UrlPostParmsCheck("ctid"))
  1491. {
  1492. ;
  1493. string eid = GetPostString("ctid");
  1494. string ftid = GetPostString("ftid");
  1495. CeErpTradeCell entity = null;
  1496. CeErpTradeCell fentity = null;
  1497. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1498. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1499. if (fentity == null)
  1500. {
  1501. returnErrorMsg("找不到关联的主订单");
  1502. return;
  1503. }
  1504. if (entity != null)
  1505. {
  1506. if (entity.OrderState >= 5)
  1507. {
  1508. returnErrorMsg("本单已经设计完成无法关联");
  1509. return;
  1510. }
  1511. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1512. {
  1513. returnErrorMsg("线下单续审核后才能关联!");
  1514. return;
  1515. }
  1516. entity.ptid = ftid;
  1517. entity.OrderState = fentity.OrderState;
  1518. //entity.status = fentity.status;
  1519. entity.CustomerUserId = fentity.CustomerUserId;
  1520. entity.DesignUserId = fentity.DesignUserId;
  1521. entity.seller_memo = "补差价单:" + ftid;
  1522. entity.IsSample = 2;
  1523. entity.Update();
  1524. ApiVo apiVo = new ApiVo();
  1525. apiVo.orderNumber = ftid;
  1526. apiVo.payment = entity.payment;
  1527. apiVo.actionName = "repairDesign";
  1528. designHelper.API_WorkCore(apiVo);//repairDesign
  1529. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1530. returnSuccessMsg("关联成功!");
  1531. return;
  1532. }
  1533. else
  1534. returnErrorMsg("找不到记录");
  1535. }
  1536. }
  1537. public void download_erp_neworder()
  1538. {
  1539. string seller = GetPostString("seller_nick");
  1540. string tid = GetPostString("tid");
  1541. if (seller.Length <= 0 || tid.Length <= 0)
  1542. {
  1543. returnErrorMsg("数据错误");
  1544. }
  1545. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1546. //{
  1547. // returnErrorMsg("找不到店铺Sessionkey");
  1548. //}
  1549. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1550. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1551. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1552. if (res.IndexOf("refOid") == -1)
  1553. {
  1554. returnErrorMsg("下载订单数据失败");
  1555. return;
  1556. }
  1557. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1558. returnSuccessMsg("下载完成");
  1559. //tmcHelper.createNewOrder(res);
  1560. //CeErpTrade entr = null;
  1561. //entr = CeErpTrade.Get(tid);
  1562. //if (entr != null)
  1563. //{
  1564. // returnSuccess("下载成功");
  1565. // //下载成功之后,Cell表生成对应的订单;
  1566. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1567. //}
  1568. //else
  1569. //{
  1570. // returnErrorMsg("下载失败或者创建订单失败");
  1571. //}
  1572. }
  1573. public void set_erp_atersale()
  1574. {
  1575. if (UrlPostParmsCheck("ctid"))
  1576. {
  1577. string eid = GetPostString("ctid");
  1578. string reason = GetPostString("AfterSaleReason");
  1579. CeErpTradeCell entity = null;
  1580. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1581. if (entity != null)
  1582. {
  1583. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1584. {
  1585. returnErrorMsg("此订单已经在售后");
  1586. return;
  1587. }*/
  1588. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1589. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1590. entity.AfterSaleTime = DateTime.Now;
  1591. entity.HandleTime = null;
  1592. entity.Update();
  1593. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1594. returnSuccessMsg("转售后成功!");
  1595. return;
  1596. }
  1597. returnErrorMsg("找不到记录");
  1598. }
  1599. }
  1600. public void set_erp_withdraw()
  1601. {
  1602. if (UrlPostParmsCheck("ctid"))
  1603. {
  1604. try
  1605. {
  1606. string eid = GetPostString("ctid");//商品id
  1607. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1608. CeWithdraw ceWithdrawSelect = null;
  1609. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1610. if (ceWithdrawSelect != null)
  1611. {
  1612. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1613. {
  1614. ceWithdrawSelect.status = -1;
  1615. ceWithdrawSelect.Update();
  1616. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1617. returnSuccessMsg("重新发起审核成功");
  1618. return;
  1619. }
  1620. else
  1621. {
  1622. returnSuccessMsg("请勿重复申请!");
  1623. return;
  1624. }
  1625. }
  1626. else
  1627. {
  1628. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1629. if (string.IsNullOrEmpty(CustomerUserId))
  1630. {
  1631. CustomerUserId = "-1";
  1632. }
  1633. int Userid = CurrentUser.UserID;//用户id
  1634. CeWithdraw ceWithdraw = new CeWithdraw();
  1635. ceWithdraw.tid = eid;
  1636. ceWithdraw.userid = Userid;
  1637. ceWithdraw.providerid = CustomerUserId;
  1638. ceWithdraw.status = 3;
  1639. ceWithdraw.creationtime = DateTime.Now;
  1640. ceWithdraw.Create();
  1641. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1642. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1643. return;
  1644. }
  1645. }
  1646. catch
  1647. {
  1648. returnErrorMsg("申请撤回订单失败");
  1649. return;
  1650. }
  1651. }
  1652. }
  1653. public void ins_erp_billinfo()
  1654. {
  1655. if (UrlPostParmsCheck("ctid"))
  1656. {
  1657. string eid = GetPostString("ctid");
  1658. CeErpTradeCell entity = null;
  1659. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1660. if (entity != null)
  1661. {
  1662. CeErpBill bill = CeErpBill.GetByTid(eid);
  1663. bool isHave = false;
  1664. if (bill != null)
  1665. {
  1666. isHave = true;
  1667. if (bill.state != 4)
  1668. {
  1669. returnErrorMsg("此单已经申请过发票了");
  1670. return;
  1671. }
  1672. }
  1673. if (entity.IsNeedBill == 0)
  1674. {
  1675. entity.IsNeedBill = 1;
  1676. }
  1677. entity.Update();
  1678. string errjson = "";
  1679. try
  1680. {
  1681. CeErpBill bill_entity = new CeErpBill();
  1682. bill_entity.tid = entity.tid;
  1683. bill_entity.title = GetPostString("title");
  1684. string taxstr = GetPostString("tax");
  1685. taxstr = taxstr.Replace(" ", "");
  1686. bill_entity.tax = taxstr;
  1687. bill_entity.bank = GetPostString("bank");
  1688. string bankacstr = GetPostString("bankac");
  1689. bankacstr = bankacstr.Replace(" ", "");
  1690. bill_entity.bankac = bankacstr;
  1691. bill_entity.address = GetPostString("address");
  1692. bill_entity.phone = GetPostString("phone");
  1693. bill_entity.price = GetPostString("price");
  1694. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1695. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1696. {
  1697. billCount += 1;
  1698. }
  1699. string prebill = "ltb";
  1700. for (int idx = 1; idx <= 1; idx++)
  1701. {
  1702. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1703. string billoid = prebill + idx + dtstr;
  1704. bill_entity.billOrderId += billoid;
  1705. if (idx < billCount)
  1706. {
  1707. bill_entity.billOrderId += ",";
  1708. }
  1709. }
  1710. bill_entity.productId = GetPostInt("ProductName");
  1711. bill_entity.num = GetPostInt("num");
  1712. bill_entity.unit = GetPostString("unit");
  1713. bill_entity.type = GetPostString("type");
  1714. bill_entity.sendType = GetPostString("SendType");
  1715. bill_entity.email = GetPostString("email");
  1716. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1717. bill_entity.shopName = GetPostString("ShopName");
  1718. bill_entity.applymemo = GetPostString("applyMemo");
  1719. bill_entity.createTime = DateTime.Now;
  1720. bill_entity.state = 0;
  1721. bill_entity.userId = CurrentUser.UserID;
  1722. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1723. bill_entity.Create();
  1724. }
  1725. catch (Exception ex)
  1726. {
  1727. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1728. returnErrorMsg("创建发票出错!");
  1729. return;
  1730. }
  1731. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1732. returnSuccessMsg("发票申请成功!");
  1733. return;
  1734. }
  1735. returnErrorMsg("找不到记录");
  1736. }
  1737. }
  1738. public void ins_erp_neworder()
  1739. {
  1740. if (UrlPostParmsCheck("receiver_name"))
  1741. {
  1742. CeErpTrade entity = new CeErpTrade();
  1743. string plat_form = GetPostString("platform");
  1744. string preStr = "N_";
  1745. if (plat_form == "拼多多")
  1746. {
  1747. preStr = "P_";
  1748. }
  1749. else if (plat_form == "阿里巴巴")
  1750. {
  1751. preStr = "A_";
  1752. }
  1753. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1754. entity.seller_nick = GetPostString("seller_nick");
  1755. entity.buyer_nick = GetPostString("buyer_nick");
  1756. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1757. entity.total_fee = entity.payment;
  1758. entity.pay_time = DateTime.Now;
  1759. entity.status = "NOT_SHIPPED";
  1760. entity.receiver_name = GetPostString("receiver_name");
  1761. entity.receiver_mobile = GetPostString("receiver_mobile");
  1762. entity.receiver_state = GetPostString("receiver_state");
  1763. entity.receiver_city = GetPostString("receiver_city");
  1764. entity.receiver_district = GetPostString("receiver_district");
  1765. entity.receiver_address = GetPostString("receiver_address");
  1766. if (entity.receiver_state == "" || entity.receiver_city == "")
  1767. {
  1768. returnErrorMsg("收件地址不能为空");
  1769. return;
  1770. }
  1771. int shopId = 0;
  1772. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1773. if (nShop != null)
  1774. {
  1775. shopId = nShop.ID;
  1776. }
  1777. if (shopId != 34 && entity.payment == 0)
  1778. {
  1779. returnErrorMsg("公司自用的单金额才能为0");
  1780. return;
  1781. }
  1782. entity.Create();
  1783. CeErpTradeCell entitycell = new CeErpTradeCell();
  1784. entitycell.ctid = entity.tid;
  1785. entitycell.tid = entity.tid;
  1786. entitycell.ShopId = shopId;
  1787. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1788. entitycell.OrderState = 0;
  1789. entitycell.pay_time = entity.pay_time;
  1790. entitycell.IsOffLineOrder = 1;
  1791. entitycell.Create();
  1792. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1793. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1794. return;
  1795. }
  1796. }
  1797. public void ins_erp_neworder2()
  1798. {
  1799. if (UrlPostParmsCheck("receiver_name"))
  1800. {
  1801. //string plat_form = GetPostString("platform");
  1802. string preStr = "X_";
  1803. string memo = GetPostString("memo");
  1804. string productId = GetPostString("productId");
  1805. string primg = GetPostString("proofimg");
  1806. string sellerNick = GetPostString("seller_nick");
  1807. string addFrom = GetPostString("addfrom");
  1808. if (addFrom == "1")
  1809. {
  1810. preStr = "N_";
  1811. }
  1812. int shopId = 0;
  1813. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1814. if (nShop != null)
  1815. {
  1816. shopId = nShop.ID;
  1817. }
  1818. else
  1819. {
  1820. returnErrorMsg("找不到对应店铺");
  1821. return;
  1822. }
  1823. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1824. {
  1825. returnErrorMsg("必须上传付款凭证");
  1826. return;
  1827. }
  1828. CeErpTrade entity = new CeErpTrade();
  1829. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1830. entity.seller_nick = sellerNick;
  1831. entity.buyer_nick = GetPostString("buyer_nick");
  1832. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1833. entity.total_fee = entity.payment;
  1834. entity.pay_time = DateTime.Now;
  1835. entity.status = "NOT_SHIPPED";
  1836. entity.receiver_name = GetPostString("receiver_name");
  1837. entity.receiver_mobile = GetPostString("receiver_mobile");
  1838. entity.receiver_state = GetPostString("receiver_state");
  1839. entity.receiver_city = GetPostString("receiver_city");
  1840. entity.receiver_district = GetPostString("receiver_district");
  1841. entity.receiver_address = GetPostString("receiver_address");
  1842. entity.seller_memo = memo;
  1843. entity.orderFrom = 20;
  1844. entity.orderType = 15;
  1845. if (entity.receiver_state == "" || entity.receiver_city == "")
  1846. {
  1847. returnErrorMsg("收件地址不能为空");
  1848. return;
  1849. }
  1850. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1851. {
  1852. returnErrorMsg("公司自用的单金额才能为0");
  1853. return;
  1854. }
  1855. entity.Create();
  1856. string toWhere = GetPostString("towhere");
  1857. string oldOrder = GetPostString("oldOrder");
  1858. CeErpTradeCell entitycell = new CeErpTradeCell();
  1859. entitycell.ctid = entity.tid;
  1860. //唯一标识
  1861. entitycell.OrderSn = entity.tid;
  1862. string orderSn = commonHelper.generateDateTimeRandomNos();
  1863. if (orderSn != "")
  1864. {
  1865. entitycell.OrderSn = orderSn;
  1866. }
  1867. entitycell.tid = entity.tid;
  1868. //if (preStr == "X_")
  1869. //{
  1870. entitycell.IsOffLineOrder = 1;
  1871. if ("1".Equals(oldOrder))
  1872. {
  1873. entitycell.IsOldCustomer = 1;
  1874. }
  1875. //}
  1876. entitycell.CustomerUserId = CurrentUser.UserID;
  1877. entitycell.PayProofImg = primg;
  1878. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1879. entitycell.ProductId = Convert.ToInt32(productId);
  1880. entitycell.ShopId = shopId;
  1881. entitycell.UpdateTime = DateTime.Now;
  1882. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1883. if (entitycell.ProductId > 0)
  1884. {
  1885. CeErpProduct ceErpProduct = CeErpProduct.GetById(entitycell.ProductId);
  1886. if (ceErpProduct.CreateTime != null && DateTime.Compare(ceErpProduct.CreateTime, DateTime.Now.AddDays(-90)) > 0)
  1887. {
  1888. entitycell.NewProduct = 1;
  1889. }
  1890. }
  1891. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1892. {
  1893. entitycell.IsXianHuo = 1;
  1894. }
  1895. entitycell.pay_time = entity.pay_time;
  1896. if (toWhere == "1")
  1897. {
  1898. entitycell.OrderState = 2;
  1899. }
  1900. else
  1901. {
  1902. entitycell.OrderState = 6;
  1903. entitycell.FinishPlaceTime = entitycell.pay_time;
  1904. }
  1905. if (shopId == 94)
  1906. {
  1907. entitycell.OrderState = 4;
  1908. entitycell.WaitDesignTime = entitycell.pay_time;
  1909. entitycell.StartDesignTime = entitycell.pay_time;
  1910. entitycell.DesignUserId = 218;
  1911. }
  1912. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114 && shopId != 158))
  1913. {
  1914. entitycell.OrderState = -1;//修改12-5
  1915. CeWithdraw ceWithdraw = new CeWithdraw();
  1916. ceWithdraw.tid = entity.tid;
  1917. ceWithdraw.providerid = "-1";
  1918. ceWithdraw.status = -1;
  1919. ceWithdraw.creationtime = DateTime.Now;
  1920. ceWithdraw.userid = 4634;
  1921. ceWithdraw.Create();
  1922. }
  1923. entitycell.Create();
  1924. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1925. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1926. {
  1927. addPlaceRegist(entitycell, CurrentUser.UserID);
  1928. }
  1929. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1930. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1931. return;
  1932. }
  1933. }
  1934. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1935. {
  1936. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1937. entity.PlactTime = tradecell.pay_time;
  1938. entity.AddUserId = userid;
  1939. entity.FileName = tradecell.seller_memo;
  1940. entity.Supplier = 24;
  1941. entity.CreateTime = DateTime.Now;
  1942. entity.Did = tradecell.ctid;
  1943. entity.tid = tradecell.tid;
  1944. entity.splitTag = tradecell.SplitTag;
  1945. entity.CurState = "未完成";
  1946. entity.Create();
  1947. }
  1948. public void get_erp_offlinelist()
  1949. {
  1950. DataStruct dStruct = GetPostStruct();
  1951. List<string> lw = new List<string>();
  1952. string tid = GetPostString("ctid");
  1953. string date1 = GetPostString("date1");
  1954. string date2 = GetPostString("date2");
  1955. if (tid.Length > 0 || date1.Length > 0)
  1956. {
  1957. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1958. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1959. if (dw.Length > 0) lw.Add(dw);
  1960. }
  1961. else
  1962. {
  1963. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1964. }
  1965. string shopname = GetPostString("shopname");
  1966. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1967. string buyernick = GetPostString("buyer_nick");
  1968. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1969. string customer = GetPostString("customer");
  1970. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1971. string design = GetPostString("design");
  1972. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1973. string orderState = GetPostString("orderState");
  1974. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1975. string address = GetPostString("address");
  1976. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  1977. string sellermemo = GetPostString("seller_memo");
  1978. if (sellermemo.Length > 0)
  1979. {
  1980. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1981. }
  1982. string price1 = GetPostString("price1");
  1983. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1984. string price2 = GetPostString("price2");
  1985. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1986. //if (PKey != "admin")
  1987. //{
  1988. // string usershop = CurrentUser.User.pemShop;
  1989. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1990. //}
  1991. //if (ex_psize > 0)
  1992. //{
  1993. dStruct.Order = "pay_time desc";
  1994. //}
  1995. //else
  1996. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1997. lw.Add(string.Format("IsOffLineOrder=1"));
  1998. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1999. DataTable dt = null;
  2000. dt = WebCache.GetData("view_erptradecell", dStruct);
  2001. writeGridDataTableJson(dStruct.TotalCount, dt);
  2002. }
  2003. public void get_erp_returncashrecord()
  2004. {
  2005. DataStruct dStruct = GetPostStruct();
  2006. List<string> lw = new List<string>();
  2007. string tid = GetPostString("ctid");
  2008. if (tid.Length > 0)
  2009. {
  2010. lw.Add(string.Format("tid like '%{0}%'", tid));
  2011. dStruct.Order = "id desc";
  2012. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2013. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  2014. //writeGridDataTableJson(dStruct.TotalCount, dt);
  2015. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2016. return;
  2017. }
  2018. returnErrorMsg("id数据错误!");
  2019. }
  2020. public void ins_erp_returncashrecord()
  2021. {
  2022. if (UrlPostParmsCheck("tid"))
  2023. {
  2024. string tid = GetPostString("tid");
  2025. string retype = GetPostString("type");
  2026. StringBuilder sql = new StringBuilder();
  2027. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  2028. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2029. if (dt.Rows.Count > 0)
  2030. {
  2031. returnErrorMsg("相同返现类型记录已存在");
  2032. return;
  2033. }
  2034. CeErpReturnCash entity = new CeErpReturnCash();
  2035. entity.tid = tid;
  2036. entity.seller_nick = GetPostString("seller_nick");
  2037. string pment = GetPostString("payment");
  2038. if (pment.Length > 0)
  2039. {
  2040. entity.payment = Convert.ToDouble(pment);
  2041. }
  2042. entity.buyer_nick = GetPostString("buyer_nick");
  2043. entity.cashstate = 0;
  2044. entity.rtype = retype;
  2045. string rPrice = GetPostString("returnprice");
  2046. if (rPrice.Length > 0)
  2047. {
  2048. entity.returnprice = Convert.ToDouble(rPrice);
  2049. }
  2050. entity.created = DateTime.Now;
  2051. entity.con = GetPostString("con");
  2052. entity.img = GetPostString("img");
  2053. entity.applyuserid = CurrentUser.UserID;
  2054. entity.Create();
  2055. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  2056. returnSuccessMsg("操作成功!");
  2057. return;
  2058. }
  2059. }
  2060. public void set_erp_predelivery()
  2061. {
  2062. if (UrlPostParmsCheck("ctid"))
  2063. {
  2064. string eid = GetPostString("ctid");
  2065. CeErpTradeCell entity = null;
  2066. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2067. if (entity != null)
  2068. {
  2069. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2070. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2071. //{
  2072. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2073. // return;
  2074. //}
  2075. entity.IsPreDelivery = 1;
  2076. entity.Update();
  2077. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2078. returnSuccessMsg("预发货成功!");
  2079. return;
  2080. //string shop = GetPostString("seller_nick");
  2081. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2082. //string comName = GetPostString("comName");
  2083. //string comCode = GetPostString("comCode");
  2084. //string outSid = GetPostString("outSid");//运单号
  2085. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2086. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2087. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2088. //string apires = "";
  2089. //if (deliveryType == "虚拟发货")
  2090. //{
  2091. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2092. //}
  2093. //else
  2094. //{
  2095. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2096. //}
  2097. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2098. ////{
  2099. //if (apires.IndexOf("发货成功") != -1)
  2100. //{
  2101. // if (deliveryType != "虚拟发货")
  2102. // {
  2103. // //还要插入快递信息到 快递信息表
  2104. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2105. // exinfo.tid = eid;
  2106. // exinfo.out_sid = outSid;
  2107. // exinfo.company_code = comCode;
  2108. // exinfo.company_name = comName;
  2109. // exinfo.delivery_memo = deliveryMemo;
  2110. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2111. // exinfo.deliveryType = deliveryType;
  2112. // exinfo.Create();
  2113. // }
  2114. // returnSuccessMsg("发货成功!");
  2115. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2116. //}
  2117. //else
  2118. //{
  2119. // returnErrorMsg("淘宝发货失败!!");
  2120. //}
  2121. //return;
  2122. }
  2123. returnErrorMsg("找不到订单记录");
  2124. }
  2125. }
  2126. public void get_erp_unusuallist()
  2127. {
  2128. DataStruct dStruct = GetPostStruct();
  2129. List<string> lw = new List<string>();
  2130. string tid = GetPostString("ctid");
  2131. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2132. string shopname = GetPostString("shopname");
  2133. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2134. string buyernick = GetPostString("buyer_nick");
  2135. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2136. string ResponsibleMan = GetPostString("responsible");
  2137. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2138. string date1 = GetPostString("date1");
  2139. string date2 = GetPostString("date2");
  2140. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2141. if (dw.Length > 0) lw.Add(dw);
  2142. string price1 = GetPostString("price1");
  2143. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2144. string price2 = GetPostString("price2");
  2145. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2146. string orderState = GetPostString("orderState");
  2147. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2148. string sellermemo = GetPostString("seller_memo");
  2149. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2150. lw.Add(string.Format("UnusualTag > 0"));
  2151. lw.Add(string.Format("IsRefund<={0}", 1));
  2152. dStruct.Order = "pay_time desc";
  2153. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2154. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2155. writeGridDataTableJson(dStruct.TotalCount, dt);
  2156. }
  2157. public void set_erp_unusualtonomal()
  2158. {
  2159. if (UrlPostParmsCheck("ctid"))
  2160. {
  2161. string eid = GetPostString("ctid");
  2162. CeErpTradeCell entity = null;
  2163. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2164. if (entity != null)
  2165. {
  2166. entity.UnusualTag = -1;
  2167. entity.Update();
  2168. returnSuccessMsg("忽略成功!");
  2169. return;
  2170. }
  2171. returnErrorMsg("找不到记录");
  2172. }
  2173. }
  2174. public void ins_erp_unusualreason()
  2175. {
  2176. if (UrlPostParmsCheck("ctid"))
  2177. {
  2178. string eid = GetPostString("ctid");
  2179. CeErpTradeCell entity = null;
  2180. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2181. if (entity != null)
  2182. {
  2183. entity.MemoOpt = 4;
  2184. entity.UnusualCon = GetPostString("con");
  2185. entity.Update();
  2186. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2187. if (trade != null)
  2188. {
  2189. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2190. }
  2191. //查货是否超时
  2192. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2193. if (ceErpTradeCellExtend == null)
  2194. {
  2195. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2196. ceErpTradeCellExtend.ctid = entity.ctid;
  2197. }
  2198. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2199. {
  2200. ceErpTradeCellExtend.CheckOut += 1;
  2201. }
  2202. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2203. if (ceErpTradeCellExtend.ID > 0)
  2204. {
  2205. ceErpTradeCellExtend.Update();
  2206. }
  2207. else
  2208. {
  2209. ceErpTradeCellExtend.Create();
  2210. }
  2211. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2212. returnSuccessMsg("操作成功!");
  2213. return;
  2214. }
  2215. returnErrorMsg("找不到记录");
  2216. }
  2217. }
  2218. public void upd_erp_sampleorder()
  2219. {
  2220. if (UrlPostParmsCheck("ctid"))
  2221. {
  2222. string eid = GetPostString("ctid");
  2223. string[] eArr = eid.Split(',');
  2224. if (eArr.Length > 1)
  2225. {
  2226. List<string> eLst = new List<string>();
  2227. for (int i = 0; i < eArr.Length; i++)
  2228. {
  2229. eLst.Add("'" + eArr[i] + "'");
  2230. }
  2231. eid = string.Join(",", eLst.ToArray());
  2232. }
  2233. else
  2234. {
  2235. eid = "'" + eid + "'";
  2236. }
  2237. StringBuilder sql = new StringBuilder();
  2238. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2239. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2240. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2241. if (dt.Rows.Count > 0)
  2242. {
  2243. string errmsg = "";
  2244. foreach (DataRow dr in dt.Rows)
  2245. {
  2246. StringBuilder sqlsb = new StringBuilder();
  2247. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2248. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2249. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2250. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2251. //string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2252. /*if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2253. {
  2254. continue;
  2255. }
  2256. else
  2257. {
  2258. string emsg = commonHelper.KeepChinese(apires);
  2259. errmsg += emsg;
  2260. }*/
  2261. }
  2262. if (errmsg.Length > 0)
  2263. {
  2264. returnErrorMsg(errmsg);
  2265. return;
  2266. }
  2267. returnSuccessMsg("操作成功");
  2268. return;
  2269. }
  2270. returnErrorMsg("找不到记录");
  2271. }
  2272. }
  2273. public void upd_erp_transcustomer()
  2274. {
  2275. if (UrlPostParmsCheck("ctid"))
  2276. {
  2277. string eid = GetPostString("ctid");
  2278. int userid = GetPostInt("CustomerUserId");
  2279. CeErpTradeCell entity = null;
  2280. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2281. if (entity != null)
  2282. {
  2283. //string[] mlist = entity.seller_memo.Split('-');
  2284. //string sql = "select * from view_erpuser where id=" + userid;
  2285. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2286. //if (dt != null && dt.Rows.Count > 0)
  2287. //{
  2288. // string nmemo = "";
  2289. // for(int i = 0; i < mlist.Length - 1; i++)
  2290. // {
  2291. // nmemo += mlist[i];
  2292. // nmemo += "-";
  2293. // }
  2294. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2295. // entity.seller_memo = nmemo;
  2296. //}
  2297. entity.CustomerUserId = userid;
  2298. entity.Update();
  2299. returnSuccessMsg("操作成功!");
  2300. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2301. return;
  2302. }
  2303. returnErrorMsg("找不到记录");
  2304. }
  2305. }
  2306. public void upd_erp_transdesigner()
  2307. {
  2308. if (UrlPostParmsCheck("ctid"))
  2309. {
  2310. string eids = GetPostString("ctid");
  2311. string[] ctidList = eids.Split(',');
  2312. int userid = GetPostInt("DesignUserId");
  2313. foreach (string ctid in ctidList)
  2314. {
  2315. CeErpTradeCell entity = null;
  2316. CeErpDesignerBill entitys = null;
  2317. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2318. entitys = CeErpDesignerBill.GetByTid(ctid);
  2319. if (entity != null)
  2320. {
  2321. if (entity.OrderState > 4)
  2322. {
  2323. continue;
  2324. }
  2325. //存在退款不能流转
  2326. if (entity.IsRefund > 0)
  2327. {
  2328. continue;
  2329. }
  2330. entity.DesignUserId = userid;
  2331. entity.WaitDesignTime = DateTime.Now;
  2332. entity.Update();
  2333. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2334. }
  2335. }
  2336. returnSuccessMsg("操作成功!");
  2337. }
  2338. }
  2339. public void upd_erp_distributedesigner()
  2340. {
  2341. if (UrlPostParmsCheck("ctid"))
  2342. {
  2343. string eid = GetPostString("ctid");
  2344. int userid = GetPostInt("DesignUserId");
  2345. string[] idlist = eid.Split(',');
  2346. if (idlist.Length <= 0)
  2347. {
  2348. returnErrorMsg("订单不能为空");
  2349. return;
  2350. }
  2351. foreach (string ctid in idlist)
  2352. {
  2353. CeErpTradeCell entity = null;
  2354. CeErpDesignerBill entitys = null;
  2355. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2356. else continue;
  2357. if (entity != null)
  2358. {
  2359. if (userid == 2125 || userid == 3542)
  2360. { }
  2361. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2362. {
  2363. returnErrorMsg("金额错误的订单无法指派");
  2364. return;
  2365. }
  2366. if (entity.OrderState >= 5)
  2367. {
  2368. returnErrorMsg("已经设计完成无法指派");
  2369. return;
  2370. }
  2371. if (entity.OrderState == -1)
  2372. {
  2373. returnErrorMsg("审核中的订单无法指派");
  2374. return;
  2375. }
  2376. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2377. {
  2378. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2379. return;
  2380. }
  2381. //157赖橙帆 159林晨 73 静之颖
  2382. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479 && CurrentUser.UserID != 73)
  2383. {
  2384. returnErrorMsg("指派设计共创无法再次指派!");
  2385. return;
  2386. }
  2387. entity.OrderState = 3;
  2388. if (entity.SupplierId == 0)
  2389. {
  2390. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2391. entity.SupplierId = suid;
  2392. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2393. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2394. }
  2395. if (userid == 2125 && entity.seller_memo != "")
  2396. {
  2397. //apiDesign.API_GetPrintData_CreateOrder(entity);
  2398. }
  2399. List<int> shopIds = new List<int>() { 17, 21, 52, 54, 64, 63, 66, 49, 67, 105, 35, 57, 53, 65, 87, 140, 26, 45, 2, 77, 122, 121, 153, 154, 158 };
  2400. if (userid == 3542 && entity.seller_memo != "")
  2401. {
  2402. string userPost = CurrentUser.UserPost.Post.Code;
  2403. if (CurrentUser.UserID == 4516 || CurrentUser.UserID == 73 || shopIds.Contains(entity.ShopId))
  2404. {
  2405. userPost = "SysAdmin";
  2406. }
  2407. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2408. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2409. if (response.msg != "设计共创:成功")
  2410. {
  2411. returnErrorMsg(response.msg);
  2412. return;
  2413. }
  2414. entity.DispatchSort = 2;
  2415. }
  2416. else
  2417. {
  2418. if (entity.DispatchSort == 2)
  2419. {
  2420. ApiVo apiVo = new ApiVo();
  2421. apiVo.actionName = "closeDesign";
  2422. apiVo.orderNumber = entity.ctid;
  2423. designHelper.API_WorkCore(apiVo);//closeDesign
  2424. }
  2425. entity.DispatchSort = 0;
  2426. }
  2427. entity.DesignUserId = userid;
  2428. entity.WaitDesignTime = DateTime.Now;
  2429. entity.UpdateTime = DateTime.Now;
  2430. entity.Update();
  2431. string name = commonHelper.getUserNameById(userid);
  2432. commonHelper.UpdateRelationOrder(entity.ctid);
  2433. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2434. }
  2435. }
  2436. returnSuccessMsg("操作成功!");
  2437. return;
  2438. }
  2439. }
  2440. public string getTidByCtid(string ctid)
  2441. {
  2442. string tid = "";
  2443. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2444. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2445. if (dataTable != null && dataTable.Rows.Count > 0)
  2446. {
  2447. tid = dataTable.Rows[0]["tid"].ToString();
  2448. }
  2449. return tid;
  2450. }
  2451. public List<string> getTidByCtidMore(string ctid)
  2452. {
  2453. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or tid = '{0}' or orderSn = '{0}' or ( ParentSplitNo = '{0}' and IsSample =2) or (ptid = '{0}' and IsSample =2 ))", ctid);
  2454. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2455. List<string> list = new List<string>();
  2456. if (dataTable != null && dataTable.Rows.Count > 0)
  2457. {
  2458. foreach (DataRow item in dataTable.Rows)
  2459. {
  2460. list.Add("'" + item["tid"].ToString() + "'");
  2461. }
  2462. }
  2463. return list;
  2464. }
  2465. public List<string> getTidByCtidLike(string ctid)
  2466. {
  2467. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2468. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2469. List<string> list = new List<string>();
  2470. if (dataTable != null && dataTable.Rows.Count > 0)
  2471. {
  2472. foreach (DataRow item in dataTable.Rows)
  2473. {
  2474. list.Add("'" + item["tid"].ToString() + "'");
  2475. }
  2476. }
  2477. return list;
  2478. }
  2479. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2480. {
  2481. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2482. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2483. List<string> list = new List<string>();
  2484. if (dataTable != null && dataTable.Rows.Count > 0)
  2485. {
  2486. foreach (DataRow item in dataTable.Rows)
  2487. {
  2488. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2489. {
  2490. continue;
  2491. }
  2492. list.Add("'" + item["receiverId"].ToString() + "'");
  2493. }
  2494. }
  2495. return list;
  2496. }
  2497. public void get_erp_myorderlist()
  2498. {
  2499. DataStruct dStruct = GetPostStruct();
  2500. List<string> lw = new List<string>();
  2501. string tid = GetPostString("ctid");
  2502. if (tid.Length > 0)
  2503. {
  2504. string select_tid = getTidByCtid(tid);
  2505. lw.Add(string.Format("tid='{0}'", select_tid));
  2506. }
  2507. else
  2508. {
  2509. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2510. }
  2511. //12-1 修改
  2512. string urgent = GetPostString("urgent");
  2513. string back = GetPostString("back");
  2514. string offlineSearch = GetPostString("offlineSearch");
  2515. if (!string.IsNullOrWhiteSpace(urgent))
  2516. {
  2517. if (urgent.Equals("true"))
  2518. {
  2519. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2520. }
  2521. }
  2522. if (!string.IsNullOrWhiteSpace(back))
  2523. {
  2524. if (back.Equals("true"))
  2525. {
  2526. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2527. }
  2528. }
  2529. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2530. {
  2531. if (offlineSearch.Equals("true"))
  2532. {
  2533. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2534. }
  2535. }
  2536. //end
  2537. string shopname = GetPostString("shopname");
  2538. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2539. string buyernick = GetPostString("buyer_nick");
  2540. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2541. string design = GetPostString("design");
  2542. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2543. string orderState = GetPostString("orderState");
  2544. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2545. string sellermemo = GetPostString("seller_memo");
  2546. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2547. string date1 = GetPostString("date1");
  2548. string date2 = GetPostString("date2");
  2549. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2550. if (dw.Length > 0) lw.Add(dw);
  2551. string price1 = GetPostString("price1");
  2552. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2553. string price2 = GetPostString("price2");
  2554. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2555. string urgency = GetPostString("urgency");
  2556. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2557. string after = GetPostString("after");
  2558. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2559. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2560. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2561. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2562. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2563. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2564. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2565. if (dt != null && dt.Rows.Count > 0)
  2566. {
  2567. foreach (DataRow dr in dt.Rows)
  2568. {
  2569. try
  2570. {
  2571. // 对象操作
  2572. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2573. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2574. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2575. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2576. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2577. if (dStruct.PageSize != 100000)
  2578. {
  2579. if (dr["DispatchSort"].ToString() == "2")
  2580. {
  2581. dr["gongchuang"] = 200;
  2582. }
  2583. else if ("外协".Equals(dr["ToType"].ToString()))
  2584. {
  2585. dr["gongchuang"] = 200;
  2586. }
  2587. else if ("内部".Equals(dr["ToType"].ToString()))
  2588. {
  2589. dr["gongchuang"] = -1;
  2590. }
  2591. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2592. {
  2593. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2594. dr["gongchuang"] = response.code;
  2595. }
  2596. }
  2597. }
  2598. catch (NullReferenceException ex)
  2599. {
  2600. }
  2601. }
  2602. }
  2603. writeGridDataTableJson(dStruct.TotalCount, dt);
  2604. }
  2605. public void get_erp_myreturnorderlist()
  2606. {
  2607. DataStruct dStruct = GetPostStruct();
  2608. List<string> lw = new List<string>();
  2609. string tid = GetPostString("ctid");
  2610. if (tid.Length > 0)
  2611. {
  2612. string select_tid = getTidByCtid(tid);
  2613. lw.Add(string.Format("tid='{0}'", select_tid));
  2614. }
  2615. else
  2616. {
  2617. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2618. }
  2619. string shopname = GetPostString("shopname");
  2620. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2621. string buyernick = GetPostString("buyer_nick");
  2622. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2623. string design = GetPostString("design");
  2624. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2625. string orderState = GetPostString("orderState");
  2626. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2627. string sellermemo = GetPostString("seller_memo");
  2628. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2629. string date1 = GetPostString("date1");
  2630. string date2 = GetPostString("date2");
  2631. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2632. if (dw.Length > 0) lw.Add(dw);
  2633. string price1 = GetPostString("price1");
  2634. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2635. string price2 = GetPostString("price2");
  2636. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2637. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2638. {
  2639. lw.Add(string.Format("CusOrgID = 94"));
  2640. }
  2641. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2642. {
  2643. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2644. }
  2645. else
  2646. {
  2647. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2648. }
  2649. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2650. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2651. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2652. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2653. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2654. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2655. if (dt != null && dt.Rows.Count > 0)
  2656. {
  2657. foreach (DataRow dr in dt.Rows)
  2658. {
  2659. try
  2660. {
  2661. // 对象操作
  2662. if (dStruct.PageSize != 100000)
  2663. {
  2664. if (dr["DispatchSort"].ToString() == "2")
  2665. {
  2666. dr["gongchuang"] = 200;
  2667. }
  2668. else if ("外协".Equals(dr["ToType"].ToString()))
  2669. {
  2670. dr["gongchuang"] = 200;
  2671. }
  2672. else if ("内部".Equals(dr["ToType"].ToString()))
  2673. {
  2674. dr["gongchuang"] = -1;
  2675. }
  2676. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2677. {
  2678. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2679. dr["gongchuang"] = response.code;
  2680. }
  2681. }
  2682. }
  2683. catch (NullReferenceException ex)
  2684. {
  2685. // 处理空引用异常
  2686. }
  2687. }
  2688. }
  2689. writeGridDataTableJson(dStruct.TotalCount, dt);
  2690. }
  2691. public void get_erp_myorderlist_pregather()
  2692. {
  2693. string date1 = GetPostString("date1");
  2694. string date2 = GetPostString("date2");
  2695. int userId = CurrentUser.UserID; //客服id
  2696. string orderWhere = "";
  2697. List<string> lw = new List<string>();
  2698. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2699. if (dw.Length > 0) lw.Add(dw);
  2700. lw.Add(string.Format("CustomerUserId={0}", userId));
  2701. lw.Add(string.Format("OrderState<9"));
  2702. orderWhere = string.Join(" and ", lw.ToArray());
  2703. string orderWhere2 = "";
  2704. List<string> lw2 = new List<string>();
  2705. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2706. if (dw2.Length > 0) lw2.Add(dw2);
  2707. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2708. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2709. string sql = string.Format("select *" +
  2710. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2711. "left join(select CustomerUserId, count(ctid) as dCount from View_ErpTradeCell where OrderState = 6 and " + orderWhere2 + " group by CustomerUserId) b on a.CustomerUserId = b.CustomerUserId " +
  2712. "left join(select CustomerUserId, count(ctid) as jCount from View_ErpTradeCell where IsUrgency = 1 and " + orderWhere + " group by CustomerUserId) c on a.CustomerUserId = c.CustomerUserId " +
  2713. "left join(select CustomerUserId, count(ctid) as sCount from View_ErpTradeCell where AfterSaleState > 0 and CHARINDEX(','+CONVERT(varchar," + userId + ")+'_k,',','+ResponsibleUserId+',')>0 and " + orderWhere + " group by CustomerUserId) d on a.CustomerUserId = d.CustomerUserId");
  2714. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2715. //writeGridDataTableJson(dt.Rows.Count, dt);
  2716. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2717. }
  2718. public void upd_erp_publishorder()
  2719. {
  2720. if (UrlPostParmsCheck("ctid"))
  2721. {
  2722. string eid = GetPostString("ctid");
  2723. CeErpTradeCell entity = null;
  2724. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2725. if (entity != null)
  2726. {
  2727. entity.OrderState = 0; //发布后,变为待抢单
  2728. entity.Update();
  2729. commonHelper.UpdateRelationOrder(entity.ctid);
  2730. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2731. returnSuccessMsg("发布成功!");
  2732. return;
  2733. }
  2734. returnErrorMsg("找不到记录");
  2735. }
  2736. }
  2737. public void get_erp_my_tiporder()
  2738. {
  2739. StringBuilder sql = new StringBuilder();
  2740. int userId = 0;
  2741. if (CurrentUser != null) userId = CurrentUser.UserID;
  2742. string posCode = CurrentUser.UserPost.Post.Code;
  2743. string isTipedAfterSaleVerify = GetPostString("af");
  2744. DataTable dt = new DataTable();
  2745. if (posCode != "Supplier")
  2746. {
  2747. if (posCode == "CustomerService" || posCode == "Director")
  2748. {
  2749. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2750. }
  2751. else if (posCode == "Place" || posCode == "PlaceMr")
  2752. {
  2753. }
  2754. else
  2755. {
  2756. string teamIds = CurrentUser.User.TeamIds;
  2757. if (teamIds == "")
  2758. {
  2759. teamIds = "0";
  2760. }
  2761. sql.AppendFormat("select * from ce_erptradecell where (DesignUserId={0} or DesignUserId in (select ID from view_erpuser where OnDuty=0 and ID in ({1}))) and OrderState in (3,4) and IsReadTag>0 ", userId, teamIds);
  2762. }
  2763. if (sql.Length > 0)
  2764. {
  2765. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2766. }
  2767. }
  2768. if (dt.Rows.Count <= 0)
  2769. {
  2770. string key = "aftersale_order_" + userId;
  2771. if (RedisHelper.HasKey(key))
  2772. {
  2773. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2774. dt.Columns.Add("ctid", typeof(string));
  2775. dt.Columns.Add("IsReadTag", typeof(int));
  2776. foreach (var i in list)
  2777. {
  2778. DataRow data = dt.NewRow();
  2779. data["ctid"] = i;
  2780. data["IsReadTag"] = 4;
  2781. dt.Rows.Add(data);
  2782. }
  2783. RedisHelper.StringDelete(key);
  2784. }
  2785. }
  2786. if (dt.Rows.Count <= 0)
  2787. {
  2788. sql = new StringBuilder();
  2789. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2790. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2791. }
  2792. if (posCode == "Supplier")
  2793. {
  2794. string ids = CurrentUser.User.pemVend;
  2795. if (ids != null && ids.Length > 0)
  2796. {
  2797. string[] ids_list = ids.Split(',');
  2798. foreach (var item in ids_list)
  2799. {
  2800. string key = "return_order_" + item;
  2801. if (RedisHelper.HasKey(key))
  2802. {
  2803. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2804. dt.Columns.Add("ctid", typeof(string));
  2805. dt.Columns.Add("IsReadTag", typeof(int));
  2806. foreach (var i in list)
  2807. {
  2808. DataRow data = dt.NewRow();
  2809. data["ctid"] = i;
  2810. data["IsReadTag"] = 1;
  2811. dt.Rows.Add(data);
  2812. }
  2813. RedisHelper.StringDelete(key);
  2814. }
  2815. }
  2816. }
  2817. if (dt.Rows.Count <= 0)
  2818. {
  2819. sql = new StringBuilder();
  2820. sql.AppendFormat("select MemoOpt,SupplierId,ctid from ce_erptradecell where SupplierId in ({0}) and MemoOpt=3 and DATEDIFF(MINUTE,CheckOrderTime,GETDATE())<=3", CurrentUser.User.pemVend);
  2821. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2822. }
  2823. }
  2824. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2825. }
  2826. public void reset_erp_tiporder()
  2827. {
  2828. string ids = GetPostString("ids");
  2829. string[] ctidList = ids.Split(',');
  2830. foreach (string ctid in ctidList)
  2831. {
  2832. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2833. if (enty != null)
  2834. {
  2835. enty.IsReadTag = 0;
  2836. enty.Update();
  2837. }
  2838. }
  2839. returnSuccessMsg("成功!");
  2840. return;
  2841. }
  2842. public void get_erp_designlist()
  2843. {
  2844. DataStruct dStruct = GetPostStruct();
  2845. List<string> lw = new List<string>();
  2846. string tid = GetPostString("ctid");
  2847. if (tid.Length > 0)
  2848. {
  2849. string select_tid = getTidByCtid(tid);
  2850. lw.Add(string.Format("tid='{0}'", select_tid));
  2851. }
  2852. string shopname = GetPostString("shopname");
  2853. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2854. string buyernick = GetPostString("buyer_nick");
  2855. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2856. string customer = GetPostString("customer");
  2857. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2858. string design = GetPostString("design");
  2859. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2860. string orderState = GetPostString("orderState");
  2861. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2862. lw.Add(string.Format("OrderState<6"));
  2863. string address = GetPostString("address");
  2864. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2865. string sellermemo = GetPostString("seller_memo");
  2866. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2867. string date1 = GetPostString("date1");
  2868. string date2 = GetPostString("date2");
  2869. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2870. if (dw.Length > 0) lw.Add(dw);
  2871. string apdate1 = GetPostString("apdate1");
  2872. string apdate2 = GetPostString("apdate2");
  2873. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2874. if (dwap.Length > 0) lw.Add(dwap);
  2875. string price1 = GetPostString("price1");
  2876. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2877. string price2 = GetPostString("price2");
  2878. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2879. string designTime = GetPostString("designtime");
  2880. if (designTime.Length > 0)
  2881. {
  2882. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2883. }
  2884. string usershop = CurrentUser.User.pemShop;
  2885. if (usershop.Length > 0)
  2886. {
  2887. lw.Add(string.Format("shopId in ({0})", usershop));
  2888. }
  2889. int myOrgid = CurrentUser.UserPost.OrgID;
  2890. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2891. if (myOrgCode.IndexOf("Designer") != -1)
  2892. {
  2893. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2894. {
  2895. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2896. }
  2897. else
  2898. {
  2899. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2900. }
  2901. }
  2902. else
  2903. {
  2904. string orgId = GetPostString("designerhd");
  2905. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2906. }
  2907. if (tid.Length > 0 || buyernick.Length > 0)
  2908. {
  2909. lw.Add(string.Format("OrderState >= 3"));
  2910. }
  2911. else
  2912. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2913. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2914. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2915. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2916. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2917. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2918. if (dt != null && dt.Rows.Count > 0)
  2919. {
  2920. foreach (DataRow dr in dt.Rows)
  2921. {
  2922. try
  2923. {
  2924. // 对象操作
  2925. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2926. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2927. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2928. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2929. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2930. if (dStruct.PageSize != 100000)
  2931. {
  2932. if (dr["DispatchSort"].ToString() == "2")
  2933. {
  2934. dr["gongchuang"] = 200;
  2935. }
  2936. else if ("外协".Equals(dr["ToType"].ToString()))
  2937. {
  2938. dr["gongchuang"] = 200;
  2939. }
  2940. else if ("内部".Equals(dr["ToType"].ToString()))
  2941. {
  2942. dr["gongchuang"] = -1;
  2943. }
  2944. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2945. {
  2946. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2947. dr["gongchuang"] = response.code;
  2948. }
  2949. }
  2950. }
  2951. catch (NullReferenceException ex)
  2952. {
  2953. }
  2954. }
  2955. }
  2956. writeGridDataTableJson(dStruct.TotalCount, dt);
  2957. }
  2958. public void get_erp_mydesignlist()
  2959. {
  2960. DataStruct dStruct = GetPostStruct();
  2961. List<string> lw = new List<string>();
  2962. string tid = GetPostString("ctid");
  2963. if (tid.Length > 0)
  2964. {
  2965. string select_tid = getTidByCtid(tid);
  2966. lw.Add(string.Format("tid='{0}'", select_tid));
  2967. }
  2968. string shopname = GetPostString("shopname");
  2969. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2970. string buyernick = GetPostString("buyer_nick");
  2971. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2972. string customer = GetPostString("customer");
  2973. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2974. string orderState = GetPostString("orderState");
  2975. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2976. //lw.Add(string.Format("OrderState<6"));
  2977. string date1 = GetPostString("date1");
  2978. string date2 = GetPostString("date2");
  2979. string dw = GetDateWhere("pay_time", date1, date2);
  2980. if (dw.Length > 0) lw.Add(dw);
  2981. string apdate1 = GetPostString("apdate1");
  2982. string apdate2 = GetPostString("apdate2");
  2983. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2984. if (dwap.Length > 0) lw.Add(dwap);
  2985. string price1 = GetPostString("price1");
  2986. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2987. string price2 = GetPostString("price2");
  2988. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2989. string olddownload = GetPostString("olddown");
  2990. if (olddownload == "1")
  2991. {
  2992. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2993. }
  2994. else if (olddownload == "2")
  2995. {
  2996. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2997. }
  2998. string sellermemo = GetPostString("seller_memo");
  2999. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3000. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  3001. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  3002. {
  3003. if (CurrentUser.User.TeamIds.Length > 0)
  3004. {
  3005. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  3006. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3007. else
  3008. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3009. }
  3010. else
  3011. {
  3012. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  3013. }
  3014. }
  3015. if (tid.Length <= 0)
  3016. {
  3017. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  3018. }
  3019. lw.Add(string.Format("IsReturn!=3"));
  3020. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  3021. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3022. string teamids = CurrentUser.User.TeamIds.ToString();
  3023. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3024. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  3025. if (dt != null && dt.Rows.Count > 0)
  3026. {
  3027. foreach (DataRow dr in dt.Rows)
  3028. {
  3029. try
  3030. {
  3031. // 对象操作
  3032. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  3033. ceErpTradeCell.ctid = dr["ctid"].ToString();
  3034. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  3035. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  3036. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  3037. if (dStruct.PageSize != 100000)
  3038. {
  3039. if (dr["DispatchSort"].ToString() == "2")
  3040. {
  3041. dr["gongchuang"] = 200;
  3042. }
  3043. else if ("外协".Equals(dr["ToType"].ToString()))
  3044. {
  3045. dr["gongchuang"] = 200;
  3046. }
  3047. else if ("内部".Equals(dr["ToType"].ToString()))
  3048. {
  3049. dr["gongchuang"] = -1;
  3050. }
  3051. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  3052. {
  3053. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  3054. dr["gongchuang"] = response.code;
  3055. }
  3056. }
  3057. }
  3058. catch (NullReferenceException ex)
  3059. {
  3060. }
  3061. }
  3062. }
  3063. writeGridDataTableJson(dStruct.TotalCount, dt);
  3064. }
  3065. public void set_erp_startdesign()
  3066. {
  3067. if (UrlPostParmsCheck("ctid"))
  3068. {
  3069. string eid = GetPostString("ctid");
  3070. CeErpTradeCell entity = null;
  3071. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3072. if (entity != null)
  3073. {
  3074. if (entity.OrderState != 3)
  3075. {
  3076. returnErrorMsg("请刷新,订单已经设计了");
  3077. return;
  3078. }
  3079. entity.StartDesignTime = DateTime.Now;
  3080. entity.OrderState = 4;
  3081. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3082. {
  3083. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3084. entity.SupplierId = suid;
  3085. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3086. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3087. }
  3088. entity.UpdateTime = DateTime.Now;
  3089. //entity.MakeSupplier = suname;
  3090. entity.Update();
  3091. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3092. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3093. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3094. commonHelper.getCytPrice(entity);
  3095. returnSuccessMsg("操作成功!");
  3096. return;
  3097. }
  3098. returnErrorMsg("找不到记录");
  3099. }
  3100. }
  3101. public void ins_erp_designselfmemo()
  3102. {
  3103. if (UrlPostParmsCheck("ctid"))
  3104. {
  3105. string eid = GetPostString("ctid");
  3106. string con = GetPostString("con");
  3107. CeErpTradeCell entity = null;
  3108. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3109. if (entity != null)
  3110. {
  3111. entity.DesignSelfMemo = con;
  3112. entity.Update();
  3113. returnSuccessMsg("操作成功!");
  3114. return;
  3115. }
  3116. returnErrorMsg("找不到记录");
  3117. }
  3118. }
  3119. public void ins_erp_designprice()
  3120. {
  3121. if (UrlPostParmsCheck("ctid"))
  3122. {
  3123. string eid = GetPostString("ctid");
  3124. int uid = CurrentUser.UserID;
  3125. string userName = CurrentUser.UserName;
  3126. CeErpTradeCell entity = null;
  3127. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3128. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3129. if (entitys == null)
  3130. {
  3131. entitys = new CeErpDesignerBill();
  3132. }
  3133. if (entity != null)
  3134. {
  3135. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3136. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3137. entity.StartDesignTime = DateTime.Now;
  3138. entity.OrderState = 4;
  3139. string suname = "";
  3140. if (entity.SupplierId == 0)
  3141. {
  3142. int sid = commonHelper.autoDistributeToSupplier(entity);
  3143. entity.SupplierId = sid;
  3144. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3145. }
  3146. entity.Update();
  3147. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3148. if (ceErpUserPost != null)
  3149. {
  3150. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3151. if (ceErpPost != null)
  3152. {
  3153. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3154. {
  3155. entitys.tid = entity.ctid;
  3156. entitys.oid = entity.tid;
  3157. entitys.uid = uid;
  3158. entitys.userName = userName;
  3159. entitys.designerType = 1;
  3160. entitys.designerTypeText = "内部设计师";
  3161. entitys.price = Convert.ToDouble(GetPostString("price"));
  3162. entitys.designNum = GetPostInt("designNum");
  3163. entitys.modifyNum = GetPostInt("modifyNum");
  3164. entitys.designSize = GetPostString("designSize");
  3165. entitys.modifySize = GetPostString("modifySize");
  3166. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3167. {
  3168. entitys.create_time = DateTime.Now;
  3169. entitys.create_u_id = uid;
  3170. entitys.create_u_name = userName;
  3171. entitys.Save();
  3172. }
  3173. else
  3174. {
  3175. entitys.update_time = DateTime.Now;
  3176. entitys.update_u_id = uid;
  3177. entitys.update_u_name = userName;
  3178. entitys.Update();
  3179. }
  3180. }
  3181. }
  3182. }
  3183. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3184. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3185. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3186. if (suname != "")
  3187. {
  3188. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3189. }
  3190. commonHelper.getCytPrice(entity);
  3191. returnSuccessMsg("操作成功!");
  3192. return;
  3193. }
  3194. returnErrorMsg("找不到记录");
  3195. }
  3196. }
  3197. public void upload_erp_filecomplete()
  3198. {
  3199. if (UrlPostParmsCheck("ctid"))
  3200. {
  3201. string eid = GetPostString("ctid");
  3202. CeErpTradeCell entity = null;
  3203. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3204. if (entity != null)
  3205. {
  3206. entity.OrderState = 5; //设计完成
  3207. entity.Update();
  3208. returnSuccessMsg(eid + "上传成功,设计完成!");
  3209. return;
  3210. }
  3211. returnErrorMsg("找不到订单记录");
  3212. }
  3213. }
  3214. public void get_erp_designovertimelist()
  3215. {
  3216. DataStruct dStruct = GetPostStruct();
  3217. List<string> lw = new List<string>();
  3218. string tid = GetPostString("ctid");
  3219. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3220. string shopname = GetPostString("shopname");
  3221. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3222. string buyernick = GetPostString("buyer_nick");
  3223. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3224. string ResponsibleMan = GetPostString("responsible");
  3225. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3226. string date1 = GetPostString("date1");
  3227. string date2 = GetPostString("date2");
  3228. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3229. if (dw.Length > 0) lw.Add(dw);
  3230. string price1 = GetPostString("price1");
  3231. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3232. string price2 = GetPostString("price2");
  3233. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3234. string orderState = GetPostString("orderState");
  3235. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3236. string sellermemo = GetPostString("seller_memo");
  3237. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3238. lw.Add(string.Format("UnusualTag=3"));
  3239. lw.Add(string.Format("IsRefund<={0}", 1));
  3240. dStruct.Order = "WaitDesignTime desc";
  3241. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3242. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3243. writeGridDataTableJson(dStruct.TotalCount, dt);
  3244. }
  3245. //设计管理 获取抢单大厅列表
  3246. public void get_erp_grabinglist()
  3247. {
  3248. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3249. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3250. bool oldOrder = false;
  3251. if (org != null)
  3252. {
  3253. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3254. }
  3255. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3256. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3257. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3258. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3259. //先处理订单数据
  3260. if (dt.Rows.Count > 0)
  3261. {
  3262. Dictionary<string, int> design = null;
  3263. int count = 0;
  3264. foreach (DataRow row in dt.Rows)
  3265. {
  3266. if (map.ContainsKey(row["ShopId"].ToString()))
  3267. {
  3268. map.TryGetValue(row["ShopId"].ToString(), out design);
  3269. }
  3270. else
  3271. {
  3272. design = new Dictionary<string, int>();
  3273. }
  3274. if (design.ContainsKey(row["ProductId"].ToString()))
  3275. {
  3276. design.TryGetValue(row["ProductId"].ToString(), out count);
  3277. }
  3278. count++;
  3279. design[row["ProductId"].ToString()] = count;
  3280. map[row["ShopId"].ToString()] = design;
  3281. }
  3282. }
  3283. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3284. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3285. //把店铺排序和技能排序分类
  3286. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3287. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3288. if (design_dt.Rows.Count > 0)
  3289. {
  3290. Dictionary<string, string> design = null;
  3291. List<string> shopIds = null;
  3292. foreach (DataRow row in design_dt.Rows)
  3293. {
  3294. if ("0".Equals(row["designId"].ToString()))
  3295. {
  3296. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3297. {
  3298. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3299. }
  3300. else
  3301. {
  3302. shopIds = new List<string>();
  3303. }
  3304. shopIds.Add(row["shopId"].ToString());
  3305. shop_orders[row["orders"].ToString()] = shopIds;
  3306. }
  3307. else
  3308. {
  3309. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3310. {
  3311. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3312. }
  3313. else
  3314. {
  3315. design = new Dictionary<string, string>();
  3316. }
  3317. design[row["orders"].ToString()] = row["designId"].ToString();
  3318. design_orders[row["shopId"].ToString()] = design;
  3319. }
  3320. }
  3321. //处理成key value后根据key排序
  3322. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3323. foreach (List<string> val in shop_orders.Values)
  3324. {
  3325. if (val != null)
  3326. {
  3327. foreach (string key in val)
  3328. {
  3329. if (design_orders.ContainsKey(key.ToString()))
  3330. {
  3331. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3332. }
  3333. }
  3334. }
  3335. }
  3336. }
  3337. //校验哪个优先级有订单
  3338. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3339. foreach (string key in shop_orders.Keys)
  3340. {
  3341. List<string> ids = null;
  3342. shop_orders.TryGetValue(key, out ids);
  3343. //id为shopid
  3344. foreach (string id in ids)
  3345. {
  3346. Dictionary<string, int> list = null;
  3347. Dictionary<string, string> desing = null;
  3348. map.TryGetValue(id, out list);
  3349. design_orders.TryGetValue(id, out desing);
  3350. if (list != null && desing != null)
  3351. {
  3352. foreach (var item in desing)
  3353. {
  3354. int count = 0;
  3355. if (list.ContainsKey(item.Value))
  3356. {
  3357. list.TryGetValue(item.Value, out count);
  3358. if (count > 0)
  3359. {
  3360. designIds[id] = item.Value;
  3361. break;
  3362. }
  3363. }
  3364. }
  3365. }
  3366. }
  3367. if (designIds.Count > 0)
  3368. {
  3369. break;
  3370. }
  3371. }
  3372. DataTable table = new DataTable();
  3373. table.Columns.Add("tid", typeof(string));
  3374. table.Columns.Add("ctid", typeof(string));
  3375. table.Columns.Add("seller_nick", typeof(string));
  3376. table.Columns.Add("productName", typeof(string));
  3377. table.Columns.Add("pay_time", typeof(string));
  3378. table.Columns.Add("seller_memo", typeof(string));
  3379. if (designIds.Count > 0)
  3380. {
  3381. string shopId = "";
  3382. string productId = "";
  3383. foreach (var designInfo in designIds)
  3384. {
  3385. shopId = designInfo.Key;
  3386. productId = designInfo.Value;
  3387. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3388. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3389. if (dt.Rows.Count > 0)
  3390. {
  3391. foreach (DataRow row in dt.Rows)
  3392. {
  3393. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3394. {
  3395. DataRow data = table.NewRow();
  3396. data["ctid"] = row["ctid"].ToString();
  3397. data["tid"] = row["tid"].ToString();
  3398. data["seller_nick"] = ceErpShop.ShopName;
  3399. data["pay_time"] = row["pay_time"].ToString();
  3400. data["seller_memo"] = row["seller_memo"].ToString();
  3401. data["productName"] = ceErpProduct.PType;
  3402. table.Rows.Add(data);
  3403. }
  3404. }
  3405. }
  3406. }
  3407. }
  3408. writeGridDataTableJson(table.Rows.Count, table);
  3409. }
  3410. private object rushLockObject = new object();
  3411. public void set_erp_grabingorder()
  3412. {
  3413. if (UrlPostParmsCheck("ctid"))
  3414. {
  3415. int total = CurrentUser.User.Person.Total;
  3416. int userId = CurrentUser.User.ID;
  3417. int noFinish = CurrentUser.User.Person.NoFinish;
  3418. int finalization = CurrentUser.User.Person.Finalization;
  3419. string eids = GetPostString("ctid");
  3420. string key = "RushKey_" + userId;
  3421. int count = 0;
  3422. if (erpRedis.RedisHelper.KeyExists(key))
  3423. {
  3424. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3425. if (redisCount != null)
  3426. {
  3427. count = Convert.ToInt32(redisCount);
  3428. }
  3429. }
  3430. if (count >= total)
  3431. {
  3432. returnErrorMsg("半小时内已经抢" + total + "单");
  3433. return;
  3434. }
  3435. string[] ctidlist = eids.Split(',');
  3436. if (count + ctidlist.Length > total)
  3437. {
  3438. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3439. return;
  3440. }
  3441. int itag = 0;
  3442. lock (rushLockObject)
  3443. {
  3444. if (ctidlist.Length > 0)
  3445. {
  3446. string[] dtList = new string[ctidlist.Length];
  3447. for (int i = 0; i < ctidlist.Length; i++)
  3448. {
  3449. dtList[i] = "'" + ctidlist[i] + "'";
  3450. }
  3451. string sql_user = string.Format("select OrderState from CE_ErpTradeCell where DesignUserId = {0} and WaitDesignTime BETWEEN '{1}' and '{2}'", userId, DateTime.Now.ToString("yyyy-MM-dd 00:00:00"), DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  3452. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3453. if (dt_user.Rows.Count > 0)
  3454. {
  3455. int doing = 0;//未定稿
  3456. int finish = 0;//已完成
  3457. foreach (DataRow dr in dt_user.Rows)
  3458. {
  3459. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3460. {
  3461. doing++;
  3462. }
  3463. else
  3464. {
  3465. finish++;
  3466. }
  3467. }
  3468. if (doing >= noFinish)
  3469. {
  3470. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3471. return;
  3472. }
  3473. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3474. {
  3475. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3476. return;
  3477. }
  3478. }
  3479. //校验选择单子状态
  3480. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3481. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3482. if (dt.Rows.Count > 0)
  3483. {
  3484. List<string> list = new List<string>();
  3485. foreach (DataRow dr in dt.Rows)
  3486. {
  3487. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3488. {
  3489. list.Add(dr["ctid"].ToString());
  3490. }
  3491. }
  3492. if (list.Count > 0)
  3493. {
  3494. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3495. return;
  3496. }
  3497. }
  3498. foreach (string ctid in ctidlist)
  3499. {
  3500. CeErpTradeCell entity = null;
  3501. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3502. if (entity != null)
  3503. {
  3504. entity.OrderState = 3;
  3505. entity.DesignUserId = CurrentUser.UserID;
  3506. entity.WaitDesignTime = DateTime.Now;
  3507. entity.StartDesignTime = DateTime.Now;
  3508. entity.Update();
  3509. commonHelper.UpdateRelationOrder(entity.ctid);
  3510. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3511. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3512. itag++;
  3513. }
  3514. }
  3515. }
  3516. }
  3517. count += ctidlist.Length;
  3518. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3519. if (itag == 0)
  3520. returnErrorMsg("没有找到相关订单");
  3521. else
  3522. returnSuccessMsg("抢单成功!");
  3523. return;
  3524. }
  3525. }
  3526. public void get_erp_waitorderlist()
  3527. {
  3528. DataStruct dStruct = GetPostStruct();
  3529. List<string> lw = new List<string>();
  3530. string tid = GetPostString("ctid");
  3531. if (tid.Length > 0)
  3532. {
  3533. string select_tid = getTidByCtid(tid);
  3534. lw.Add(string.Format("tid='{0}'", select_tid));
  3535. }
  3536. string shopname = GetPostString("shopname");
  3537. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3538. string buyernick = GetPostString("buyer_nick");
  3539. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3540. string customer = GetPostString("customer");
  3541. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3542. string design = GetPostString("design");
  3543. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3544. string orderState = GetPostString("orderState");
  3545. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3546. string supplier = GetPostString("supplier");
  3547. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3548. string sellermemo = GetPostString("seller_memo");
  3549. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3550. string otherMemo = GetPostString("otherMemo");
  3551. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3552. string address = GetPostString("address");
  3553. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  3554. string date1 = GetPostString("date1");
  3555. string date2 = GetPostString("date2");
  3556. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3557. if (dw.Length > 0) lw.Add(dw);
  3558. string price1 = GetPostString("price1");
  3559. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3560. string price2 = GetPostString("price2");
  3561. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3562. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3563. lw.Add(string.Format("IsSample != 2 "));
  3564. lw.Add(string.Format("OrderState = 5 "));
  3565. lw.Add(string.Format("IsRefund<={0}", 1));
  3566. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3567. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3568. string pagesize = GetPostString("pagesize");
  3569. if (pagesize != null)
  3570. {
  3571. dStruct.PageSize = 200;
  3572. }
  3573. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3574. List<string> tids = new List<string>();
  3575. if (dt != null)
  3576. {
  3577. dt.Columns.Add("compenPrice", typeof(double));
  3578. foreach (DataRow dr in dt.Rows)
  3579. {
  3580. if (Convert.IsDBNull(dr["compenPrice"]))
  3581. {
  3582. dr["compenPrice"] = 0;
  3583. }
  3584. tids.Add("'" + dr["tid"].ToString() + "'");
  3585. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  3586. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3587. {
  3588. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3589. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3590. entity.SupplierId = suid;
  3591. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3592. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3593. entity.Update();
  3594. }
  3595. }
  3596. }
  3597. if (tids.Count > 0)
  3598. {
  3599. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3600. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3601. if (dt_price != null && dt_price.Rows.Count > 0)
  3602. {
  3603. foreach (DataRow dr in dt_price.Rows)
  3604. {
  3605. foreach (DataRow row in dt.Rows)
  3606. {
  3607. if (row["tid"].Equals(dr["ptid"]))
  3608. {
  3609. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3610. break;
  3611. }
  3612. }
  3613. }
  3614. }
  3615. }
  3616. writeGridDataTableJson(dStruct.TotalCount, dt);
  3617. }
  3618. public void get_erp_supplierwaitorderlist()
  3619. {
  3620. DataStruct dStruct = GetPostStruct();
  3621. List<string> lw = new List<string>();
  3622. string tid = GetPostString("ctid");
  3623. if (tid.Length > 0)
  3624. {
  3625. string select_tid = getTidByCtid(tid);
  3626. lw.Add(string.Format("tid='{0}'", select_tid));
  3627. }
  3628. string shopname = GetPostString("shopname");
  3629. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3630. string sellermemo = GetPostString("seller_memo");
  3631. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3632. string date1 = GetPostString("date1");
  3633. string date2 = GetPostString("date2");
  3634. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3635. if (dw.Length > 0) lw.Add(dw);
  3636. lw.Add(string.Format("OrderState = 5 "));
  3637. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3638. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3639. {
  3640. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3641. }
  3642. string supplier = GetPostString("supplier");
  3643. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3644. {
  3645. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3646. }
  3647. lw.Add(string.Format("IsRefund<={0}", 1));
  3648. dStruct.Order = "FinishDesignTime desc";
  3649. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3650. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3651. if (dt != null)
  3652. {
  3653. foreach (DataRow dr in dt.Rows)
  3654. {
  3655. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  3656. }
  3657. }
  3658. writeGridDataTableJson(dStruct.TotalCount, dt);
  3659. }
  3660. public void upd_erp_verifytosupplier()
  3661. {
  3662. if (UrlPostParmsCheck("ctid"))
  3663. {
  3664. string eids = GetPostString("ctid");
  3665. CeErpTradeCell entity = null;
  3666. string[] eidsList = eids.Split(',');
  3667. if (eidsList.Length <= 0)
  3668. {
  3669. returnErrorMsg("订单号不能空");
  3670. return;
  3671. }
  3672. List<string> tLst = new List<string>();
  3673. foreach (string ctidstr in eidsList)
  3674. {
  3675. tLst.Add("'" + ctidstr + "'");
  3676. CeErpDataSendOrderInfo.createObject(ctidstr);
  3677. }
  3678. string needtids = string.Join(",", tLst.ToArray());
  3679. StringBuilder sql = new StringBuilder();
  3680. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3681. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 AND OrderState = 5 and ctid in ({0});", needtids, CurrentUser.UserID);
  3682. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3683. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3684. returnSuccessMsg("操作成功!");
  3685. return;
  3686. /**foreach (string ctidstr in eidsList)
  3687. {
  3688. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3689. if (entity != null)
  3690. {
  3691. if (entity.SupplierId == 0)
  3692. {
  3693. continue;
  3694. }
  3695. entity.IsVerifyToSupplier = true;
  3696. if (entity.IsReturn == 1) //1是供应商打回
  3697. {
  3698. entity.IsReturn = 0;
  3699. }
  3700. entity.FinishPlaceTime = DateTime.Now;
  3701. entity.PlaceUserId = CurrentUser.UserID;
  3702. entity.Update();
  3703. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3704. }
  3705. }
  3706. returnSuccessMsg("操作成功!");
  3707. return;**/
  3708. }
  3709. }
  3710. public void upd_erp_supplierback()
  3711. {
  3712. if (UrlPostParmsCheck("ctid"))
  3713. {
  3714. string eid = GetPostString("ctid");
  3715. string reason = GetPostString("returnreason");
  3716. CeErpTradeCell entity = null;
  3717. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3718. if (entity != null)
  3719. {
  3720. string message = "操作成功!";
  3721. string isDown = "";
  3722. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3723. {
  3724. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3725. isDown = "被点击下载";
  3726. }
  3727. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3728. {
  3729. string key = "return_order_" + entity.SupplierId;
  3730. List<string> list = new List<string>();
  3731. if (RedisHelper.HasKey(key))
  3732. {
  3733. object data = RedisHelper.StringGet(key);
  3734. list = Convert.ToString(data).Split(',').ToList();
  3735. }
  3736. list.Add(eid);
  3737. RedisHelper.StringSet(key, string.Join(",", list));
  3738. }
  3739. entity.IsVerifyToSupplier = false;
  3740. entity.IsReturn = 1;
  3741. entity.IsHaveNewOrder = 0;
  3742. entity.ReturnTime = DateTime.Now;
  3743. entity.ReturnReason = reason;
  3744. if (entity.OrderState == 6)
  3745. {
  3746. entity.OrderState = 5;
  3747. }
  3748. entity.Update();
  3749. CeErpSukuraData.createInfo(entity.ctid, 5);
  3750. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3751. returnSuccessMsg(message);
  3752. return;
  3753. }
  3754. returnErrorMsg("找不到订单记录");
  3755. }
  3756. }
  3757. public void upd_erp_toaftersaleorder()
  3758. {
  3759. if (UrlPostParmsCheck("ctid"))
  3760. {
  3761. string eid = GetPostString("ctid");
  3762. string reason = GetPostString("returnreason");
  3763. CeErpTradeCell entity = null;
  3764. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3765. if (entity != null)
  3766. {
  3767. if (entity.isAfterSaleOrder != 1)
  3768. {
  3769. returnErrorMsg("带S的售后单才能打回给售后");
  3770. return;
  3771. }
  3772. if (entity.OrderState >= 5)
  3773. {
  3774. returnErrorMsg("已经设计完成了不能打回给售后");
  3775. return;
  3776. }
  3777. entity.OrderState = 0;
  3778. entity.IsReturn = 3;
  3779. entity.ReturnTime = DateTime.Now;
  3780. entity.UpdateTime = DateTime.Now;
  3781. entity.ReturnReason = reason;
  3782. entity.Update();
  3783. CeErpSukuraData.createInfo(entity.ctid, 5);
  3784. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3785. returnSuccessMsg("操作成功!");
  3786. return;
  3787. }
  3788. returnErrorMsg("找不到订单记录");
  3789. }
  3790. }
  3791. public void upd_erp_aftersaletodesign()
  3792. {
  3793. if (UrlPostParmsCheck("ctid"))
  3794. {
  3795. string eid = GetPostString("ctid");
  3796. CeErpTradeCell entity = null;
  3797. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3798. if (entity != null)
  3799. {
  3800. entity.OrderState = 3;
  3801. entity.IsReturn = 0;
  3802. entity.UpdateTime = DateTime.Now;
  3803. entity.Update();
  3804. CeErpSukuraData.createInfo(entity.ctid, 5);
  3805. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3806. returnSuccessMsg("操作成功!");
  3807. return;
  3808. }
  3809. returnErrorMsg("找不到订单记录");
  3810. }
  3811. }
  3812. public void assign_erp_supplier()
  3813. {
  3814. if (UrlPostParmsCheck("ctid"))
  3815. {
  3816. string eids = GetPostString("ctid");
  3817. int sid = GetPostInt("SupplierName");
  3818. string fromTag = GetPostString("tag");
  3819. string[] eidList = eids.Split(',');
  3820. if (eidList.Length <= 0)
  3821. {
  3822. returnErrorMsg("指派不能为空");
  3823. return;
  3824. }
  3825. string errMsg = "";
  3826. string suname = commonHelper.getSupplierNameById(sid);
  3827. foreach (string ctid in eidList)
  3828. {
  3829. CeErpTradeCell entity = null;
  3830. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3831. if (entity != null)
  3832. {
  3833. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3834. {
  3835. errMsg += (ctid + "指派失败!!!");
  3836. continue;
  3837. }
  3838. entity.SupplierId = sid;
  3839. entity.Update();
  3840. commonHelper.UpdateRelationOrder(entity.ctid);
  3841. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3842. if (entity.OrderState >= 6)
  3843. {
  3844. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3845. //{
  3846. // string msl = entity.MakeSupplier;
  3847. // string[] mslist = msl.Split(',');
  3848. // sql.AppendFormat("update ce_erptradecell2 with(rowlock) set SupplierId={2} where ID in (select top {1} ID from ce_erptradecell2 where ctid='{0}' order by ID desc)", entity.ctid, mslist.Length,sid);
  3849. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3850. //}
  3851. //else
  3852. //{
  3853. StringBuilder sql = new StringBuilder();
  3854. sql.AppendFormat("update ce_erptradecell2 with(rowlock) set SupplierId={1},MakeSupplier='{2}' where ID in (select top 1 ID from ce_erptradecell2 where ctid='{0}' order by ID desc)", entity.ctid, sid, entity.MakeSupplier);
  3855. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3856. //}
  3857. }
  3858. }
  3859. else
  3860. {
  3861. continue;
  3862. }
  3863. }
  3864. if (errMsg.Length > 0)
  3865. {
  3866. returnErrorMsg(errMsg);
  3867. return;
  3868. }
  3869. returnSuccessMsg("操作成功!");
  3870. return;
  3871. }
  3872. }
  3873. public void assign_erp_makesupplier()
  3874. {
  3875. if (UrlPostParmsCheck("ctid"))
  3876. {
  3877. string eids = GetPostString("ctid");
  3878. string sname = GetPostString("SupplierName");
  3879. string[] eidList = eids.Split(',');
  3880. if (eidList.Length <= 0)
  3881. {
  3882. returnErrorMsg("指派不能为空");
  3883. return;
  3884. }
  3885. List<string> tLst = new List<string>();
  3886. foreach (string ctid in eidList)
  3887. {
  3888. CeErpTradeCell entity = null;
  3889. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3890. if (entity != null)
  3891. {
  3892. entity.MakeSupplier = sname;
  3893. entity.Update();
  3894. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3895. tLst.Add("'" + ctid + "'");
  3896. }
  3897. else
  3898. {
  3899. continue;
  3900. }
  3901. }
  3902. string ctids = string.Join(",", tLst.ToArray());
  3903. StringBuilder sql2 = new StringBuilder();
  3904. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3905. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3906. returnSuccessMsg("操作成功!");
  3907. return;
  3908. }
  3909. }
  3910. public void ins_erp_returnreason()
  3911. {
  3912. if (UrlPostParmsCheck("ctid"))
  3913. {
  3914. string eid = GetPostString("ctid");
  3915. CeErpTradeCell entity = null;
  3916. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3917. string userpost = CurrentUser.UserPost.Post.Code;
  3918. if (entity != null)
  3919. {
  3920. bool isPlace = false;
  3921. if (entity.OrderState > 6)
  3922. {
  3923. returnErrorMsg("已发货无法打回!");
  3924. return;
  3925. }
  3926. if (entity.OrderState == 6)
  3927. {
  3928. isPlace = true;
  3929. }
  3930. bool isNeedUpdateCell2 = false;
  3931. if (entity.OrderState >= 6)
  3932. {
  3933. isNeedUpdateCell2 = true;
  3934. }
  3935. int returnTag = 2;
  3936. if (userpost == "Supplier")
  3937. {
  3938. returnTag = 1;
  3939. }
  3940. int toType = GetPostInt("totype");
  3941. string fromType = "3";
  3942. if (entity.OrderState < 5)
  3943. {
  3944. fromType = "3";
  3945. }
  3946. else
  3947. {
  3948. fromType = "4";
  3949. }
  3950. if (entity.IsXianHuo == 0)
  3951. {
  3952. if (returnTag == 2)
  3953. {
  3954. if (toType == 1)
  3955. {
  3956. entity.OrderState = 0;
  3957. entity.ReturnUserType = 1;
  3958. string clearman = GetPostString("clearman");
  3959. if (!string.IsNullOrEmpty(clearman))
  3960. {
  3961. entity.DesignUserId = 0;
  3962. }
  3963. }
  3964. else
  3965. {
  3966. entity.OrderState = 3;
  3967. entity.ReturnUserType = 2;
  3968. }
  3969. entity.IsReadTag = 1;
  3970. }
  3971. else if (returnTag == 1)
  3972. {
  3973. entity.OrderState = 5;
  3974. }
  3975. entity.IsVerifyToSupplier = false;
  3976. }
  3977. if (entity.IsXianHuo == 1)
  3978. {
  3979. entity.OrderState = 5;
  3980. }
  3981. entity.UnusualTag = 0;
  3982. entity.UnusualTime = null;
  3983. entity.UnusualCon = "";
  3984. entity.IsReturn = returnTag;
  3985. entity.ReturnTime = DateTime.Now;
  3986. entity.UpdateTime = DateTime.Now;
  3987. entity.ReturnReason = GetPostString("returnreason");
  3988. entity.Update();
  3989. if (entity.OrderState == 3)
  3990. {
  3991. ApiVo apiVo = new ApiVo();
  3992. apiVo.orderNumber = entity.ctid;
  3993. apiVo.actionName = "rebutDesign";
  3994. apiVo.orderRemarks = entity.ReturnReason;
  3995. designHelper.API_WorkCore(apiVo);//rebutDesign
  3996. }
  3997. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3998. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3999. {
  4000. //dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  4001. }
  4002. //CeErpSukuraData.createInfo(entity.ctid, 5);
  4003. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4004. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4005. if (isPlace)
  4006. {
  4007. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  4008. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4009. if (dth != null && dth.Rows.Count > 0)
  4010. {
  4011. dataSendOrderBean dataSendOrderBean = null;
  4012. foreach (DataRow item in dth.Rows)
  4013. {
  4014. try
  4015. {
  4016. dataSendOrderBean = new dataSendOrderBean();
  4017. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  4018. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  4019. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  4020. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  4021. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  4022. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  4023. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  4024. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  4025. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  4026. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  4027. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  4028. dataSendOrderBean.Radio1723534706288 = "打回";
  4029. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  4030. if (result != null)
  4031. {
  4032. if ("0".Equals(result.errcode))
  4033. {
  4034. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  4035. }
  4036. else
  4037. {
  4038. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  4039. }
  4040. }
  4041. }
  4042. catch (Exception ex)
  4043. {
  4044. }
  4045. }
  4046. }
  4047. }
  4048. /*if (isNeedUpdateCell2)
  4049. {
  4050. if (entity.MakeSupplier.IndexOf(",") != -1)
  4051. {
  4052. StringBuilder sql2 = new StringBuilder();
  4053. sql2.AppendFormat("update ce_erptradecell2 WITH(ROWLOCK) set BackState='已打回',ReturnReason='{0}',IsReturn={2} where ID in (select top 2 ID from ce_erptradecell2 where ctid='{1}' order by ID desc) ", entity.ReturnReason, entity.ctid, returnTag);
  4054. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4055. }
  4056. else
  4057. {
  4058. StringBuilder sql2 = new StringBuilder();
  4059. sql2.AppendFormat("update ce_erptradecell2 WITH(ROWLOCK) set BackState='已打回',ReturnReason='{0}',IsReturn={2} where ID in (select top 1 ID from ce_erptradecell2 where ctid='{1}' order by ID desc)", entity.ReturnReason, entity.ctid, returnTag);
  4060. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4061. }
  4062. }*/
  4063. returnSuccessMsg("操作成功!");
  4064. return;
  4065. }
  4066. returnErrorMsg("找不到订单记录");
  4067. }
  4068. }
  4069. public void cyt_erp_returnreason()
  4070. {
  4071. if (UrlPostParmsCheck("ctid"))
  4072. {
  4073. string eid = GetPostString("ctid");
  4074. CeErpTradeCell entity = null;
  4075. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4076. string userpost = CurrentUser.UserPost.Post.Code;
  4077. if (entity != null)
  4078. {
  4079. if (entity.OrderState > 6)
  4080. {
  4081. returnErrorMsg("已发货无法打回!");
  4082. return;
  4083. }
  4084. JObject jsonObject = new JObject
  4085. {
  4086. { "Userid", "77886" },
  4087. { "Pwd", "lt666888" },
  4088. { "LTOrderId",eid }
  4089. };
  4090. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4091. JObject jsonObjects = JObject.Parse(response);
  4092. string msg = (string)jsonObjects["msg"];
  4093. if (msg != "取消成功")
  4094. {
  4095. returnErrorMsg(msg);
  4096. return;
  4097. }
  4098. bool isNeedUpdateCell2 = false;
  4099. if (entity.OrderState >= 6)
  4100. {
  4101. isNeedUpdateCell2 = true;
  4102. }
  4103. int returnTag = 2;
  4104. if (userpost == "Supplier")
  4105. {
  4106. returnTag = 1;
  4107. }
  4108. if (entity.IsXianHuo == 0)
  4109. {
  4110. if (returnTag == 2)
  4111. {
  4112. int toType = GetPostInt("totype");
  4113. if (toType == 1)
  4114. {
  4115. entity.OrderState = 0;
  4116. entity.ReturnUserType = 1;
  4117. }
  4118. else
  4119. {
  4120. entity.OrderState = 4;
  4121. entity.ReturnUserType = 2;
  4122. }
  4123. entity.IsReadTag = 1;
  4124. }
  4125. else if (returnTag == 1)
  4126. {
  4127. entity.OrderState = 5;
  4128. }
  4129. entity.IsVerifyToSupplier = false;
  4130. }
  4131. entity.UnusualTag = 0;
  4132. entity.UnusualTime = null;
  4133. entity.UnusualCon = "";
  4134. entity.IsReturn = returnTag;
  4135. entity.ReturnTime = DateTime.Now;
  4136. entity.ReturnReason = GetPostString("returnreason");
  4137. entity.Update();
  4138. if (entity.OrderState == 4)
  4139. {
  4140. ApiVo apiVo = new ApiVo();
  4141. apiVo.orderNumber = entity.ctid;
  4142. apiVo.actionName = "rebutDesign";
  4143. apiVo.orderRemarks = entity.ReturnReason;
  4144. designHelper.API_WorkCore(apiVo);//rebutDesign
  4145. }
  4146. CeErpSukuraData.createInfo(entity.ctid, 5);
  4147. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4148. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4149. if (isNeedUpdateCell2)
  4150. {
  4151. if (entity.MakeSupplier.IndexOf(",") != -1)
  4152. {
  4153. StringBuilder sql2 = new StringBuilder();
  4154. sql2.AppendFormat("update ce_erptradecell2 WITH(ROWLOCK) set BackState='已打回',ReturnReason='{0}',IsReturn={2} where ID in (select top 2 ID from ce_erptradecell2 where ctid='{1}' order by ID desc) ", entity.ReturnReason, entity.ctid, returnTag);
  4155. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4156. }
  4157. else
  4158. {
  4159. StringBuilder sql2 = new StringBuilder();
  4160. sql2.AppendFormat("update ce_erptradecell2 WITH(ROWLOCK) set BackState='已打回',ReturnReason='{0}',IsReturn={2} where ID in (select top 1 ID from ce_erptradecell2 where ctid='{1}' order by ID desc)", entity.ReturnReason, entity.ctid, returnTag);
  4161. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4162. }
  4163. }
  4164. returnSuccessMsg("操作成功!");
  4165. return;
  4166. }
  4167. returnErrorMsg("找不到订单记录");
  4168. }
  4169. }
  4170. public void upd_erp_xianhuoreturntag()
  4171. {
  4172. if (UrlPostParmsCheck("ctid"))
  4173. {
  4174. string eids = GetPostString("ctid");
  4175. string[] ctids = eids.Split(',');
  4176. foreach (string ctid in ctids)
  4177. {
  4178. CeErpTradeCell entity = null;
  4179. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4180. if (entity != null)
  4181. {
  4182. entity.IsReturn = 0;
  4183. entity.Update();
  4184. CeErpSukuraData.createInfo(entity.ctid, 5);
  4185. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4186. }
  4187. }
  4188. returnSuccessMsg("操作成功!");
  4189. return;
  4190. }
  4191. }
  4192. public void get_erp_waitdeliverylist()
  4193. {
  4194. DataStruct dStruct = GetPostStruct();
  4195. List<string> lw = new List<string>();
  4196. string tid = GetPostString("ctid");
  4197. if (tid.Length > 0)
  4198. {
  4199. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4200. if (tid.Length > 5)
  4201. {
  4202. List<string> tids = getTidByCtidLike(tid);
  4203. if (tids.Count > 0 && tids.Count < 10)
  4204. {
  4205. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4206. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4207. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4208. {
  4209. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4210. }*/
  4211. }
  4212. }
  4213. lw.Add(tid_sql);
  4214. }
  4215. string shopname = GetPostString("shopname");
  4216. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4217. string buyernick = GetPostString("buyer_nick");
  4218. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4219. //if (tid.Length == 0 && buyernick.Length == 0)
  4220. //{
  4221. // lw.Add(string.Format("IsRefund<={0}", 1));
  4222. //}
  4223. string customer = GetPostString("customer");
  4224. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4225. string design = GetPostString("design");
  4226. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4227. string orderState = GetPostString("orderState");
  4228. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4229. string address = GetPostString("address");
  4230. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  4231. string sellermemo = GetPostString("seller_memo");
  4232. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4233. string supplier = GetPostString("supplier");
  4234. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4235. string OrderArea = GetPostString("order_area");
  4236. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4237. string placedate1 = GetPostString("placedate1");
  4238. string placedate2 = GetPostString("placedate2");
  4239. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4240. if (fdw.Length > 0) lw.Add(fdw);
  4241. string price1 = GetPostString("price1");
  4242. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4243. string price2 = GetPostString("price2");
  4244. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4245. string unusualCon = GetPostString("unusualcon");
  4246. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4247. string otherMemo = GetPostString("otherMemo");
  4248. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4249. string posTag = CurrentUser.UserPost.Post.Code;
  4250. if (posTag == "Supplier")
  4251. {
  4252. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4253. }
  4254. else
  4255. {
  4256. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4257. {
  4258. string usershop = CurrentUser.User.pemShop;
  4259. lw.Add(string.Format("ShopId in ({0})", usershop));
  4260. }
  4261. }
  4262. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4263. lw.Add(string.Format("type != 'PDD' "));
  4264. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4265. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4266. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4267. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4268. writeGridDataTableJson(dStruct.TotalCount, dt);
  4269. }
  4270. public void get_erp_changedeliverylist()
  4271. {
  4272. DataStruct dStruct = GetPostStruct();
  4273. List<string> lw = new List<string>();
  4274. string tid = GetPostString("ctid");
  4275. if (tid.Length > 0)
  4276. {
  4277. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4278. if (tid.Length > 5)
  4279. {
  4280. List<string> tids = getTidByCtidLike(tid);
  4281. if (tids.Count > 0 && tids.Count < 10)
  4282. {
  4283. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4284. }
  4285. }
  4286. lw.Add(tid_sql);
  4287. }
  4288. string shopname = GetPostString("shopname");
  4289. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4290. string buyernick = GetPostString("buyer_nick");
  4291. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4292. //if (tid.Length == 0 && buyernick.Length == 0)
  4293. //{
  4294. // lw.Add(string.Format("IsRefund<={0}", 1));
  4295. //}
  4296. string customer = GetPostString("customer");
  4297. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4298. string design = GetPostString("design");
  4299. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4300. string orderState = GetPostString("orderState");
  4301. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4302. string address = GetPostString("address");
  4303. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  4304. string sellermemo = GetPostString("seller_memo");
  4305. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4306. string supplier = GetPostString("supplier");
  4307. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4308. string OrderArea = GetPostString("order_area");
  4309. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4310. string placedate1 = GetPostString("placedate1");
  4311. string placedate2 = GetPostString("placedate2");
  4312. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4313. if (fdw.Length > 0) lw.Add(fdw);
  4314. string price1 = GetPostString("price1");
  4315. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4316. string price2 = GetPostString("price2");
  4317. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4318. string unusualCon = GetPostString("unusualcon");
  4319. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4320. string otherMemo = GetPostString("otherMemo");
  4321. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4322. string posTag = CurrentUser.UserPost.Post.Code;
  4323. if (posTag == "Supplier")
  4324. {
  4325. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4326. }
  4327. else
  4328. {
  4329. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4330. {
  4331. string usershop = CurrentUser.User.pemShop;
  4332. lw.Add(string.Format("ShopId in ({0})", usershop));
  4333. }
  4334. }
  4335. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4336. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4337. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4338. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4339. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4340. /*if (tid.Length > 0)
  4341. {
  4342. List<string> tids = new List<string>();
  4343. if (dt != null && dt.Rows.Count > 0)
  4344. {
  4345. foreach (DataRow item in dt.Rows)
  4346. {
  4347. tids.Add("'" + item["tid"] + "'");
  4348. }
  4349. }
  4350. if (tids.Count > 0)
  4351. {
  4352. lw.RemoveAt(0);
  4353. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4354. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4355. dt = WebCache.GetData("view_erptradecell", dStruct);
  4356. }
  4357. }*/
  4358. writeGridDataTableJson(dStruct.TotalCount, dt);
  4359. }
  4360. public void get_erp_pddderiving()
  4361. {
  4362. DataStruct dStruct = GetPostStruct();
  4363. List<string> lw = new List<string>();
  4364. string tid = GetPostString("ctid");
  4365. if (tid.Length > 0)
  4366. {
  4367. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4368. if (tid.Length > 5)
  4369. {
  4370. List<string> tids = getTidByCtidLike(tid);
  4371. if (tids.Count > 0 && tids.Count < 10)
  4372. {
  4373. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4374. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4375. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4376. {
  4377. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4378. }*/
  4379. }
  4380. }
  4381. lw.Add(tid_sql);
  4382. }
  4383. string shopname = GetPostString("shopname");
  4384. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4385. string buyernick = GetPostString("buyer_nick");
  4386. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4387. //if (tid.Length == 0 && buyernick.Length == 0)
  4388. //{
  4389. // lw.Add(string.Format("IsRefund<={0}", 1));
  4390. //}
  4391. string customer = GetPostString("customer");
  4392. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4393. string design = GetPostString("design");
  4394. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4395. string orderState = GetPostString("orderState");
  4396. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4397. string address = GetPostString("address");
  4398. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  4399. string sellermemo = GetPostString("seller_memo");
  4400. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4401. string supplier = GetPostString("supplier");
  4402. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4403. string OrderArea = GetPostString("order_area");
  4404. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4405. string placedate1 = GetPostString("placedate1");
  4406. string placedate2 = GetPostString("placedate2");
  4407. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4408. if (fdw.Length > 0) lw.Add(fdw);
  4409. string price1 = GetPostString("price1");
  4410. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4411. string price2 = GetPostString("price2");
  4412. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4413. string unusualCon = GetPostString("unusualcon");
  4414. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4415. string posTag = CurrentUser.UserPost.Post.Code;
  4416. if (posTag == "Supplier")
  4417. {
  4418. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4419. }
  4420. else
  4421. {
  4422. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4423. {
  4424. string usershop = CurrentUser.User.pemShop;
  4425. lw.Add(string.Format("ShopId in ({0})", usershop));
  4426. }
  4427. }
  4428. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4429. lw.Add(string.Format("type = 'PDD' "));
  4430. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4431. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4432. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4433. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4434. /*if (tid.Length > 0)
  4435. {
  4436. List<string> tids = new List<string>();
  4437. if (dt != null && dt.Rows.Count > 0)
  4438. {
  4439. foreach (DataRow item in dt.Rows)
  4440. {
  4441. tids.Add("'" + item["tid"] + "'");
  4442. }
  4443. }
  4444. if (tids.Count > 0)
  4445. {
  4446. lw.RemoveAt(0);
  4447. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4448. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4449. dt = WebCache.GetData("view_erptradecell", dStruct);
  4450. }
  4451. }*/
  4452. writeGridDataTableJson(dStruct.TotalCount, dt);
  4453. }
  4454. public void get_erp_jdderiving()
  4455. {
  4456. DataStruct dStruct = GetPostStruct();
  4457. List<string> lw = new List<string>();
  4458. string tid = GetPostString("ctid");
  4459. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4460. string shopname = GetPostString("shopname");
  4461. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4462. string buyernick = GetPostString("buyer_nick");
  4463. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4464. //if (tid.Length == 0 && buyernick.Length == 0)
  4465. //{
  4466. // lw.Add(string.Format("IsRefund<={0}", 1));
  4467. //}
  4468. string customer = GetPostString("customer");
  4469. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4470. string design = GetPostString("design");
  4471. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4472. string orderState = GetPostString("orderState");
  4473. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4474. string address = GetPostString("address");
  4475. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  4476. string sellermemo = GetPostString("seller_memo");
  4477. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4478. string supplier = GetPostString("supplier");
  4479. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4480. string OrderArea = GetPostString("order_area");
  4481. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4482. string placedate1 = GetPostString("placedate1");
  4483. string placedate2 = GetPostString("placedate2");
  4484. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4485. if (fdw.Length > 0) lw.Add(fdw);
  4486. string price1 = GetPostString("price1");
  4487. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4488. string price2 = GetPostString("price2");
  4489. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4490. string unusualCon = GetPostString("unusualcon");
  4491. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4492. string posTag = CurrentUser.UserPost.Post.Code;
  4493. if (posTag == "Supplier")
  4494. {
  4495. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4496. }
  4497. lw.Add(string.Format("OrderState = 6 "));
  4498. lw.Add(string.Format("type = 'JD' "));
  4499. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4500. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4501. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4502. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4503. writeGridDataTableJson(dStruct.TotalCount, dt);
  4504. }
  4505. public void get_erp_demoorderlist()
  4506. {
  4507. DataStruct dStruct = GetPostStruct();
  4508. List<string> lw = new List<string>();
  4509. string tid = GetPostString("ctid");
  4510. if (tid.Length > 0)
  4511. {
  4512. string select_tid = getTidByCtid(tid);
  4513. lw.Add(string.Format("tid='{0}'", select_tid));
  4514. }
  4515. string shopname = GetPostString("shopname");
  4516. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4517. string buyernick = GetPostString("buyer_nick");
  4518. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4519. string customer = GetPostString("customer");
  4520. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4521. string design = GetPostString("design");
  4522. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4523. string orderState = GetPostString("orderState");
  4524. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4525. string address = GetPostString("address");
  4526. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4527. string sellermemo = GetPostString("seller_memo");
  4528. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4529. string supplier = GetPostString("supplier");
  4530. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4531. string OrderArea = GetPostString("order_area");
  4532. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4533. string date1 = GetPostString("date1");
  4534. string date2 = GetPostString("date2");
  4535. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4536. if (dw.Length > 0) lw.Add(dw);
  4537. string price1 = GetPostString("price1");
  4538. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4539. string price2 = GetPostString("price2");
  4540. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4541. string posTag = CurrentUser.UserPost.Post.Code;
  4542. if (posTag == "Supplier")
  4543. {
  4544. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4545. }
  4546. //lw.Add(string.Format("OrderState = 6 "));
  4547. lw.Add(string.Format("IsSample={0}", 3));
  4548. lw.Add(string.Format("IsRefund<={0}", 1));
  4549. dStruct.Order = "pay_time desc";
  4550. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4551. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4552. writeGridDataTableJson(dStruct.TotalCount, dt);
  4553. }
  4554. public void save_erp_checkmemo()
  4555. {
  4556. if (UrlPostParmsCheck("ctid"))
  4557. {
  4558. string ctid = GetPostString("ctid");
  4559. CeErpTradeCell entity = null;
  4560. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4561. if (entity != null)
  4562. {
  4563. entity.CheckMemo = GetPostString("CheckMemo");
  4564. entity.Update();
  4565. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4566. if (trade != null)
  4567. {
  4568. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4569. }
  4570. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4571. returnSuccessMsg("保存成功!");
  4572. return;
  4573. }
  4574. returnErrorMsg("找不到记录");
  4575. }
  4576. }
  4577. public void get_erp_returnlist()
  4578. {
  4579. DataStruct dStruct = GetPostStruct();
  4580. List<string> lw = new List<string>();
  4581. string tid = GetPostString("ctid");
  4582. if (tid.Length > 0)
  4583. {
  4584. string select_tid = getTidByCtid(tid);
  4585. lw.Add(string.Format("tid='{0}'", select_tid));
  4586. }
  4587. string shopname = GetPostString("shopname");
  4588. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4589. string buyernick = GetPostString("buyer_nick");
  4590. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4591. string customer = GetPostString("customer");
  4592. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4593. string design = GetPostString("design");
  4594. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4595. string orderState = GetPostString("orderState");
  4596. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4597. string address = GetPostString("address");
  4598. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4599. string sellermemo = GetPostString("seller_memo");
  4600. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4601. string supplier = GetPostString("supplier");
  4602. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4603. string date1 = GetPostString("date1");
  4604. string date2 = GetPostString("date2");
  4605. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4606. if (dw.Length > 0) lw.Add(dw);
  4607. string bdate1 = GetPostString("backdate1");
  4608. string bdate2 = GetPostString("backdate2");
  4609. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4610. if (dw_back.Length > 0) lw.Add(dw_back);
  4611. string price1 = GetPostString("price1");
  4612. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4613. string price2 = GetPostString("price2");
  4614. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4615. lw.Add(string.Format("IsReturn>0"));
  4616. lw.Add(string.Format("IsXianHuo=0"));
  4617. lw.Add(string.Format("IsReturn!=3"));
  4618. string backtype = GetPostString("backtype");
  4619. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4620. dStruct.Order = "FinishDesignTime desc";
  4621. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4622. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4623. writeGridDataTableJson(dStruct.TotalCount, dt);
  4624. }
  4625. public void get_erp_today_sumreturn()
  4626. {
  4627. DataStruct dStruct = GetPostStruct();
  4628. List<string> lw = new List<string>();
  4629. string bdate1 = GetPostString("returnTimeS");
  4630. string bdate2 = GetPostString("returnTimeE");
  4631. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4632. if (dw_back.Length > 0) lw.Add(dw_back);
  4633. lw.Add(string.Format("IsReturn=0"));
  4634. lw.Add(string.Format("IsXianHuo=0"));
  4635. string mainWhere = string.Join(" and ", lw.ToArray());
  4636. string sql = "";
  4637. if (dw_back.Length > 0)
  4638. {
  4639. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4640. }
  4641. else
  4642. {
  4643. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + " and ReturnTime >= '" + DateTime.Now.Date + "') as today_finish from view_erptradecell where ReturnTime >= '" + DateTime.Now.Date + "'";
  4644. }
  4645. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4646. decimal total = 0, today_finish = 0;
  4647. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4648. {
  4649. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4650. }
  4651. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4652. {
  4653. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4654. }
  4655. var res = new
  4656. {
  4657. data = total,
  4658. data1 = today_finish,
  4659. };
  4660. string ro_jsond = JsonConvert.SerializeObject(res);
  4661. returnSuccess(ro_jsond);
  4662. return;
  4663. }
  4664. public void get_erp_allreturnlist()
  4665. {
  4666. DataStruct dStruct = GetPostStruct();
  4667. List<string> lw = new List<string>();
  4668. string tid = GetPostString("ctid");
  4669. if (tid.Length > 0)
  4670. {
  4671. string select_tid = getTidByCtid(tid);
  4672. lw.Add(string.Format("tid='{0}'", select_tid));
  4673. }
  4674. string shopname = GetPostString("shopname");
  4675. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4676. string buyernick = GetPostString("buyer_nick");
  4677. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4678. string customer = GetPostString("customer");
  4679. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4680. string design = GetPostString("design");
  4681. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4682. string orderState = GetPostString("orderState");
  4683. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4684. string address = GetPostString("address");
  4685. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4686. string sellermemo = GetPostString("seller_memo");
  4687. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4688. string supplier = GetPostString("supplier");
  4689. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4690. string date1 = GetPostString("date1");
  4691. string date2 = GetPostString("date2");
  4692. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4693. if (dw.Length > 0) lw.Add(dw);
  4694. string bdate1 = GetPostString("backdate1");
  4695. string bdate2 = GetPostString("backdate2");
  4696. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4697. if (dw_back.Length > 0) lw.Add(dw_back);
  4698. string price1 = GetPostString("price1");
  4699. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4700. string price2 = GetPostString("price2");
  4701. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4702. string backreason = GetPostString("backreason");
  4703. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4704. lw.Add(string.Format("IsXianHuo=0"));
  4705. lw.Add(string.Format("ReturnTime != ''"));
  4706. string backtype = GetPostString("backtype");
  4707. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4708. string posTag = CurrentUser.UserPost.Post.Code;
  4709. if (posTag == "Supplier")
  4710. {
  4711. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4712. }
  4713. else
  4714. {
  4715. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4716. {
  4717. string usershop = CurrentUser.User.pemShop;
  4718. lw.Add(string.Format("ShopId in ({0})", usershop));
  4719. }
  4720. }
  4721. dStruct.Order = "FinishDesignTime desc";
  4722. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4723. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4724. writeGridDataTableJson(dStruct.TotalCount, dt);
  4725. }
  4726. public void get_erp_aftersalereturnlist()
  4727. {
  4728. DataStruct dStruct = GetPostStruct();
  4729. List<string> lw = new List<string>();
  4730. string tid = GetPostString("ctid");
  4731. if (tid.Length > 0)
  4732. {
  4733. string select_tid = getTidByCtid(tid);
  4734. lw.Add(string.Format("tid='{0}'", select_tid));
  4735. }
  4736. string shopname = GetPostString("shopname");
  4737. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4738. string buyernick = GetPostString("buyer_nick");
  4739. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4740. string customer = GetPostString("customer");
  4741. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4742. string design = GetPostString("design");
  4743. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4744. string orderState = GetPostString("orderState");
  4745. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4746. string address = GetPostString("address");
  4747. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4748. string sellermemo = GetPostString("seller_memo");
  4749. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4750. string supplier = GetPostString("supplier");
  4751. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4752. string date1 = GetPostString("date1");
  4753. string date2 = GetPostString("date2");
  4754. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4755. if (dw.Length > 0) lw.Add(dw);
  4756. string bdate1 = GetPostString("backdate1");
  4757. string bdate2 = GetPostString("backdate2");
  4758. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4759. if (dw_back.Length > 0) lw.Add(dw_back);
  4760. string price1 = GetPostString("price1");
  4761. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4762. string price2 = GetPostString("price2");
  4763. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4764. lw.Add(string.Format("IsReturn=3"));
  4765. string backtype = GetPostString("backtype");
  4766. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4767. string backreason = GetPostString("backreason");
  4768. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4769. dStruct.Order = "ReturnTime desc";
  4770. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4771. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4772. writeGridDataTableJson(dStruct.TotalCount, dt);
  4773. }
  4774. public void get_erp_xianhuoreturnlist()
  4775. {
  4776. DataStruct dStruct = GetPostStruct();
  4777. List<string> lw = new List<string>();
  4778. string tid = GetPostString("ctid");
  4779. if (tid.Length > 0)
  4780. {
  4781. string select_tid = getTidByCtid(tid);
  4782. lw.Add(string.Format("tid='{0}'", select_tid));
  4783. }
  4784. string shopname = GetPostString("shopname");
  4785. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4786. string buyernick = GetPostString("buyer_nick");
  4787. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4788. string customer = GetPostString("customer");
  4789. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4790. string design = GetPostString("design");
  4791. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4792. string orderState = GetPostString("orderState");
  4793. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4794. string address = GetPostString("address");
  4795. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4796. string sellermemo = GetPostString("seller_memo");
  4797. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4798. string supplier = GetPostString("supplier");
  4799. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4800. string OrderArea = GetPostString("order_area");
  4801. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4802. string date1 = GetPostString("date1");
  4803. string date2 = GetPostString("date2");
  4804. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4805. if (dw.Length > 0) lw.Add(dw);
  4806. string price1 = GetPostString("price1");
  4807. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4808. string price2 = GetPostString("price2");
  4809. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4810. string posTag = CurrentUser.UserPost.Post.Code;
  4811. if (posTag == "Supplier")
  4812. {
  4813. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4814. }
  4815. lw.Add(string.Format("OrderState=6 "));
  4816. lw.Add(string.Format("IsXianHuo=1 "));
  4817. lw.Add(string.Format("IsReturn>0 "));
  4818. lw.Add(string.Format("IsReturn!=3"));
  4819. lw.Add(string.Format("IsRefund<={0}", 1));
  4820. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4821. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4822. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4823. writeGridDataTableJson(dStruct.TotalCount, dt);
  4824. }
  4825. public void set_erp_orderdelivery()
  4826. {
  4827. if (UrlPostParmsCheck("ctid"))
  4828. {
  4829. string eid = GetPostString("ctid");
  4830. CeErpTradeCell entity = null;
  4831. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4832. if (entity != null)
  4833. {
  4834. if (entity.OrderState >= 7)
  4835. {
  4836. returnErrorMsg("此单已发货,无需重复发货");
  4837. return;
  4838. }
  4839. if (entity.OrderState != 6)
  4840. {
  4841. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4842. return;
  4843. }
  4844. string shop = GetPostString("seller_nick");
  4845. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4846. string comName = GetPostString("comName");
  4847. string comCode = GetPostString("comCode");
  4848. string outSid = GetPostString("outSid");
  4849. string deliveryType = GetPostString("deliveryType");
  4850. string deliveryMemo = GetPostString("deliveryMemo");
  4851. outSid = outSid.Trim();
  4852. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4853. if (mainEn == null)
  4854. {
  4855. returnErrorMsg("找不到原始订单记录");
  4856. return;
  4857. }
  4858. bool isInitOrderDeliv = false;
  4859. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4860. {
  4861. isInitOrderDeliv = true;
  4862. }
  4863. string apires = "";
  4864. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4865. if (entity.ctid.IndexOf("N") != -1 || entity.ctid.IndexOf("P") != -1 || entity.ctid.IndexOf("A") != -1 || entity.ctid.IndexOf("X") != -1 || entity.ctid.IndexOf("S") != -1)
  4866. {
  4867. apires = "发货成功true";
  4868. }
  4869. else
  4870. {
  4871. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4872. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid, entity.ctid);
  4873. }
  4874. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4875. {
  4876. entity.OrderState = 7;//发货后订单已发货
  4877. entity.OutSid = outSid;
  4878. entity.MemoOpt = 0;
  4879. entity.UpdateTime = DateTime.Now;
  4880. entity.FinishDeliveryTime = DateTime.Now;
  4881. entity.Update();
  4882. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4883. commonHelper.UpdateRelationOrder(entity.ctid);
  4884. //还要插入快递信息到 快递信息表
  4885. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4886. exinfo.tid = eid;
  4887. exinfo.out_sid = outSid;
  4888. exinfo.company_code = comCode;
  4889. exinfo.company_name = comName;
  4890. exinfo.delivery_memo = deliveryMemo;
  4891. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4892. exinfo.deliveryType = deliveryType;
  4893. exinfo.printUser = CurrentUser.UserName;
  4894. exinfo.print_time = DateTime.Now;
  4895. exinfo.Create();
  4896. returnSuccessMsg("发货操作成功!");
  4897. commonHelper.UpdateRelationOrder(entity.ctid);
  4898. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4899. CeErpSukuraData.createInfo(entity.ctid, 4);
  4900. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  4901. {
  4902. commonHelper.sendCytExpress(exinfo);
  4903. }
  4904. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4905. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid + ",备注:" + deliveryMemo, entity.OrderState);
  4906. }
  4907. else
  4908. {
  4909. string errmsg = commonHelper.KeepChinese(apires);
  4910. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4911. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4912. }
  4913. return;
  4914. }
  4915. returnErrorMsg("找不到订单记录");
  4916. }
  4917. }
  4918. public void set_erp_multidelivery()
  4919. {
  4920. string eids = GetPostString("tids");
  4921. string[] eidList = eids.Split(',');
  4922. if (eidList.Length <= 0)
  4923. {
  4924. returnErrorMsg("发货不能为空");
  4925. return;
  4926. }
  4927. foreach (string ctid in eidList)
  4928. {
  4929. if (ctid.Length <= 0) continue;
  4930. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4931. if (expInfo != null)
  4932. {
  4933. StringBuilder sql = new StringBuilder();
  4934. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4935. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4936. if (dt.Rows.Count > 0)
  4937. {
  4938. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4939. {
  4940. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4941. expInfo.state = "异常";
  4942. expInfo.isMultiDelivery = 1;
  4943. expInfo.Update();
  4944. continue;
  4945. }
  4946. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4947. {
  4948. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4949. expInfo.state = "异常";
  4950. expInfo.Update();
  4951. continue;
  4952. }
  4953. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4954. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4955. bool isInitOrderDeliv = false;
  4956. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4957. {
  4958. isInitOrderDeliv = true;
  4959. expInfo.isMultiDelivery = 1;
  4960. }
  4961. if (ctid.IndexOf("N") != -1)
  4962. {
  4963. StringBuilder sqlbucha = new StringBuilder();
  4964. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4965. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4966. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4967. commonHelper.UpdateRelationOrder(ctid);
  4968. expInfo.delivery_memo = "发货成功";
  4969. expInfo.state = "发货成功";
  4970. expInfo.isMultiDelivery = 1;
  4971. expInfo.Update();
  4972. }
  4973. else
  4974. {
  4975. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4976. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid, ctid);
  4977. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4978. {
  4979. expInfo.delivery_memo = "发货成功";
  4980. expInfo.state = "发货成功";
  4981. expInfo.isMultiDelivery = 1;
  4982. expInfo.Update();
  4983. commonHelper.UpdateRelationOrder(ctid);
  4984. CeErpSukuraData.createInfo(ctid, 4);
  4985. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4986. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4987. }
  4988. else
  4989. {
  4990. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4991. expInfo.state = "异常";
  4992. expInfo.Update();
  4993. }
  4994. }
  4995. }
  4996. }
  4997. }
  4998. returnSuccessMsg("操作完成");
  4999. }
  5000. public void reset_erp_memoopt()
  5001. {
  5002. if (UrlPostParmsCheck("ctid"))
  5003. {
  5004. string eid = GetPostString("ctid");
  5005. CeErpTradeCell entity = null;
  5006. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5007. if (entity != null)
  5008. {
  5009. string stropt = "";
  5010. if (entity.MemoOpt == 1)
  5011. {
  5012. stropt = "“改稿”";
  5013. }
  5014. else if (entity.MemoOpt == 2)
  5015. {
  5016. stropt = "“定稿”";
  5017. }
  5018. else if (entity.MemoOpt == 3)
  5019. {
  5020. stropt = "“完成查货”";
  5021. CeErpSukuraData.createInfo(entity.ctid, 6);
  5022. }
  5023. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  5024. entity.UpdateTime = DateTime.Now;
  5025. entity.MemoOpt = 0;
  5026. entity.Update();
  5027. returnSuccessMsg("操作成功!");
  5028. return;
  5029. }
  5030. returnErrorMsg("找不到记录");
  5031. }
  5032. }
  5033. public void get_erp_deliveryunusual()
  5034. {
  5035. DataStruct dStruct = GetPostStruct();
  5036. List<string> lw = new List<string>();
  5037. string tid = GetPostString("ctid");
  5038. if (tid.Length > 0)
  5039. {
  5040. string select_tid = getTidByCtid(tid);
  5041. lw.Add(string.Format("tid='{0}'", select_tid));
  5042. }
  5043. string shopname = GetPostString("shopname");
  5044. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5045. string buyernick = GetPostString("buyer_nick");
  5046. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5047. string customer = GetPostString("customer");
  5048. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5049. string design = GetPostString("design");
  5050. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5051. string sellermemo = GetPostString("seller_memo");
  5052. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5053. string supplier = GetPostString("supplier");
  5054. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5055. string date1 = GetPostString("date1");
  5056. string date2 = GetPostString("date2");
  5057. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5058. if (dw.Length > 0) lw.Add(dw);
  5059. string placedate1 = GetPostString("placedate1");
  5060. string placedate2 = GetPostString("placedate2");
  5061. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5062. if (dw_place.Length > 0) lw.Add(dw_place);
  5063. string price1 = GetPostString("price1");
  5064. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5065. string price2 = GetPostString("price2");
  5066. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5067. string unusualCon = GetPostString("unusualcon");
  5068. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  5069. string posTag = CurrentUser.UserPost.Post.Code;
  5070. if (posTag == "Supplier")
  5071. {
  5072. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5073. }
  5074. lw.Add(string.Format("OrderState = 6"));
  5075. lw.Add(string.Format("UnusualTag = 5"));
  5076. lw.Add(string.Format("IsRefund<={0}", 1));
  5077. dStruct.Order = "FinishPlaceTime desc";
  5078. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5079. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5080. writeGridDataTableJson(dStruct.TotalCount, dt);
  5081. }
  5082. public void get_erp_deliveryedlist()
  5083. {
  5084. DataStruct dStruct = GetPostStruct();
  5085. List<string> lw = new List<string>();
  5086. string tid = GetPostString("ctid");
  5087. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5088. string shopname = GetPostString("shopname");
  5089. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5090. string buyernick = GetPostString("buyer_nick");
  5091. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5092. string customer = GetPostString("customer");
  5093. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5094. string design = GetPostString("design");
  5095. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5096. string sellermemo = GetPostString("seller_memo");
  5097. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5098. string logistics = GetPostString("logistics");
  5099. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5100. string date1 = GetPostString("date1");
  5101. string date2 = GetPostString("date2");
  5102. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5103. //if (dw.Length > 0) lw.Add(dw);
  5104. string placedate1 = GetPostString("placedate1");
  5105. string placedate2 = GetPostString("placedate2");
  5106. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5107. if (fdw.Length > 0) lw.Add(fdw);
  5108. string devdate1 = GetPostString("deliverydate1");
  5109. string devdate2 = GetPostString("deliverydate2");
  5110. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5111. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5112. string price1 = GetPostString("price1");
  5113. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5114. string price2 = GetPostString("price2");
  5115. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5116. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5117. {
  5118. if (tid.Length > 0)
  5119. {
  5120. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5121. if (tid.Length > 5)
  5122. {
  5123. List<string> tids = getTidByCtidLike(tid);
  5124. if (tids.Count > 0 && tids.Count < 10)
  5125. {
  5126. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5127. }
  5128. }
  5129. lw.Add(tid_sql);
  5130. }
  5131. if (buyernick.Length > 0)
  5132. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5133. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5134. if (dw.Length > 0) lw.Add(dw);
  5135. }
  5136. else
  5137. {
  5138. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5139. }
  5140. string posTag = CurrentUser.UserPost.Post.Code;
  5141. if (posTag == "Supplier")
  5142. {
  5143. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5144. }
  5145. else
  5146. {
  5147. string supplier = GetPostString("supplier");
  5148. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5149. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5150. {
  5151. string usershop = CurrentUser.User.pemShop;
  5152. lw.Add(string.Format("ShopId in ({0})", usershop));
  5153. }
  5154. }
  5155. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5156. lw.Add(string.Format("type != 'PDD' "));
  5157. lw.Add(string.Format("IsRefund!={0}", 2));
  5158. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5159. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5160. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5161. /*if (tid.Length > 0)
  5162. {
  5163. List<string> tids = new List<string>();
  5164. if (dt != null && dt.Rows.Count > 0)
  5165. {
  5166. foreach (DataRow item in dt.Rows)
  5167. {
  5168. tids.Add("'" + item["tid"] + "'");
  5169. }
  5170. }
  5171. if (tids.Count > 0)
  5172. {
  5173. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5174. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5175. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5176. dt = WebCache.GetData("view_erptradecell", dStruct);
  5177. }
  5178. }*/
  5179. if (dt != null)
  5180. {
  5181. foreach (DataRow dr in dt.Rows)
  5182. {
  5183. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  5184. }
  5185. }
  5186. writeGridDataTableJson(dStruct.TotalCount, dt);
  5187. }
  5188. public void get_erp_pdddeliveryed()
  5189. {
  5190. DataStruct dStruct = GetPostStruct();
  5191. List<string> lw = new List<string>();
  5192. string tid = GetPostString("ctid");
  5193. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5194. string shopname = GetPostString("shopname");
  5195. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5196. string buyernick = GetPostString("buyer_nick");
  5197. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5198. string customer = GetPostString("customer");
  5199. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5200. string design = GetPostString("design");
  5201. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5202. string sellermemo = GetPostString("seller_memo");
  5203. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5204. string logistics = GetPostString("logistics");
  5205. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5206. string date1 = GetPostString("date1");
  5207. string date2 = GetPostString("date2");
  5208. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5209. //if (dw.Length > 0) lw.Add(dw);
  5210. string placedate1 = GetPostString("placedate1");
  5211. string placedate2 = GetPostString("placedate2");
  5212. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5213. if (fdw.Length > 0) lw.Add(fdw);
  5214. string devdate1 = GetPostString("deliverydate1");
  5215. string devdate2 = GetPostString("deliverydate2");
  5216. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5217. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5218. string price1 = GetPostString("price1");
  5219. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5220. string price2 = GetPostString("price2");
  5221. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5222. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5223. {
  5224. if (tid.Length > 0)
  5225. {
  5226. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5227. if (tid.Length > 5)
  5228. {
  5229. List<string> tids = getTidByCtidLike(tid);
  5230. if (tids.Count > 0 && tids.Count < 10)
  5231. {
  5232. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5233. }
  5234. }
  5235. lw.Add(tid_sql);
  5236. }
  5237. if (buyernick.Length > 0)
  5238. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5239. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5240. if (dw.Length > 0) lw.Add(dw);
  5241. }
  5242. else
  5243. {
  5244. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5245. }
  5246. string posTag = CurrentUser.UserPost.Post.Code;
  5247. if (posTag == "Supplier")
  5248. {
  5249. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5250. }
  5251. else
  5252. {
  5253. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5254. {
  5255. string usershop = CurrentUser.User.pemShop;
  5256. lw.Add(string.Format("ShopId in ({0})", usershop));
  5257. }
  5258. string supplier = GetPostString("supplier");
  5259. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5260. }
  5261. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5262. lw.Add(string.Format("type = 'PDD' "));
  5263. lw.Add(string.Format("IsRefund!={0}", 2));
  5264. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5265. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5266. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5267. /* if (tid.Length > 0)
  5268. {
  5269. List<string> tids = new List<string>();
  5270. if (dt != null && dt.Rows.Count > 0)
  5271. {
  5272. foreach (DataRow item in dt.Rows)
  5273. {
  5274. tids.Add("'" + item["tid"] + "'");
  5275. }
  5276. }
  5277. if (tids.Count > 0)
  5278. {
  5279. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5280. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5281. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5282. dt = WebCache.GetData("view_erptradecell", dStruct);
  5283. }
  5284. }*/
  5285. foreach (DataRow dr in dt.Rows)
  5286. {
  5287. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  5288. }
  5289. writeGridDataTableJson(dStruct.TotalCount, dt);
  5290. }
  5291. public void get_erp_jddeliveryed()
  5292. {
  5293. DataStruct dStruct = GetPostStruct();
  5294. List<string> lw = new List<string>();
  5295. string tid = GetPostString("ctid");
  5296. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5297. string shopname = GetPostString("shopname");
  5298. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5299. string buyernick = GetPostString("buyer_nick");
  5300. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5301. string customer = GetPostString("customer");
  5302. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5303. string design = GetPostString("design");
  5304. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5305. string sellermemo = GetPostString("seller_memo");
  5306. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5307. string date1 = GetPostString("date1");
  5308. string date2 = GetPostString("date2");
  5309. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5310. //if (dw.Length > 0) lw.Add(dw);
  5311. string placedate1 = GetPostString("placedate1");
  5312. string placedate2 = GetPostString("placedate2");
  5313. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5314. if (fdw.Length > 0) lw.Add(fdw);
  5315. string devdate1 = GetPostString("deliverydate1");
  5316. string devdate2 = GetPostString("deliverydate2");
  5317. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5318. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5319. string price1 = GetPostString("price1");
  5320. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5321. string price2 = GetPostString("price2");
  5322. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5323. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5324. {
  5325. if (tid.Length > 0)
  5326. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5327. if (buyernick.Length > 0)
  5328. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5329. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5330. if (dw.Length > 0) lw.Add(dw);
  5331. }
  5332. else
  5333. {
  5334. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5335. }
  5336. string posTag = CurrentUser.UserPost.Post.Code;
  5337. if (posTag == "Supplier")
  5338. {
  5339. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5340. }
  5341. else
  5342. {
  5343. string supplier = GetPostString("supplier");
  5344. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5345. }
  5346. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5347. lw.Add(string.Format("type = 'JD' "));
  5348. lw.Add(string.Format("IsRefund!={0}", 2));
  5349. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5350. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5351. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5352. foreach (DataRow dr in dt.Rows)
  5353. {
  5354. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  5355. }
  5356. writeGridDataTableJson(dStruct.TotalCount, dt);
  5357. }
  5358. public void get_erp_allplacelist()
  5359. {
  5360. DataStruct dStruct = GetPostStruct();
  5361. List<string> lw = new List<string>();
  5362. string tid = GetPostString("ctid");
  5363. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5364. string shopname = GetPostString("shopname");
  5365. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5366. string buyernick = GetPostString("buyer_nick");
  5367. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5368. string customer = GetPostString("customer");
  5369. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5370. string design = GetPostString("design");
  5371. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5372. string sellermemo = GetPostString("seller_memo");
  5373. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5374. string supplier = GetPostString("supplier");
  5375. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5376. string date1 = GetPostString("date1");
  5377. string date2 = GetPostString("date2");
  5378. string pldate1 = GetPostString("placedate1");
  5379. string pldate2 = GetPostString("placedate2");
  5380. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5381. //if (dw.Length > 0) lw.Add(dw);
  5382. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5383. {
  5384. if (tid.Length > 0)
  5385. {
  5386. string select_tid = getTidByCtid(tid);
  5387. lw.Add(string.Format("tid='{0}'", select_tid));
  5388. }
  5389. if (buyernick.Length > 0)
  5390. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5391. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5392. if (dw.Length > 0) lw.Add(dw);
  5393. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5394. if (dw_place.Length > 0) lw.Add(dw_place);
  5395. }
  5396. else
  5397. {
  5398. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5399. {
  5400. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5401. }
  5402. }
  5403. string price1 = GetPostString("price1");
  5404. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5405. string price2 = GetPostString("price2");
  5406. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5407. string posTag = CurrentUser.UserPost.Post.Code;
  5408. if (posTag == "Supplier")
  5409. {
  5410. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5411. }
  5412. lw.Add(string.Format("OrderState >= 6"));
  5413. lw.Add(string.Format("IsSample != 2 "));
  5414. //lw.Add(string.Format("isDianziOrder = 0 "));
  5415. lw.Add(string.Format("SupplierId > 0 "));
  5416. //lw.Add(string.Format("IsRefund<={0}", 1));
  5417. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5418. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5419. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5420. foreach (DataRow dr in dt.Rows)
  5421. {
  5422. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  5423. }
  5424. writeGridDataTableJson(dStruct.TotalCount, dt);
  5425. }
  5426. public void get_erp_financeallplacelist()
  5427. {
  5428. DataStruct dStruct = GetPostStruct();
  5429. List<string> lw = new List<string>();
  5430. string tid = GetPostString("ctid");
  5431. string shopname = GetPostString("shopname");
  5432. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5433. string buyernick = GetPostString("buyer_nick");
  5434. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5435. string customer = GetPostString("customer");
  5436. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5437. string design = GetPostString("design");
  5438. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5439. string sellermemo = GetPostString("seller_memo");
  5440. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5441. string supplier = GetPostString("supplier");
  5442. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5443. string date1 = GetPostString("date1");
  5444. string date2 = GetPostString("date2");
  5445. string pldate1 = GetPostString("placedate1");
  5446. string pldate2 = GetPostString("placedate2");
  5447. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5448. {
  5449. if (tid.Length > 0)
  5450. {
  5451. string select_tid = getTidByCtid(tid);
  5452. lw.Add(string.Format("tid='{0}'", select_tid));
  5453. }
  5454. if (buyernick.Length > 0)
  5455. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5456. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5457. if (dw.Length > 0) lw.Add(dw);
  5458. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5459. if (dw_place.Length > 0) lw.Add(dw_place);
  5460. }
  5461. else
  5462. {
  5463. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5464. {
  5465. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5466. }
  5467. }
  5468. string price1 = GetPostString("price1");
  5469. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5470. string price2 = GetPostString("price2");
  5471. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5472. string posTag = CurrentUser.UserPost.Post.Code;
  5473. if (posTag == "Supplier")
  5474. {
  5475. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5476. }
  5477. //lw.Add(string.Format("OrderState >= 6"));
  5478. lw.Add(string.Format("IsSample != 2 "));
  5479. lw.Add(string.Format("isDianziOrder = 0 "));
  5480. //lw.Add(string.Format("IsRefund<={0}", 1));
  5481. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5482. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5483. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5484. foreach (DataRow dr in dt.Rows)
  5485. {
  5486. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  5487. }
  5488. writeGridDataTableJson(dStruct.TotalCount, dt);
  5489. }
  5490. public void get_erp_expresslist()
  5491. {
  5492. int listtype = GetInt("ltype");
  5493. DataStruct dStruct = GetPostStruct();
  5494. List<string> lw = new List<string>();
  5495. string tid = GetPostString("tid");
  5496. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5497. string outsid = GetPostString("out_sid");
  5498. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5499. string importer = GetPostString("ImportUserName");
  5500. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5501. string file = GetPostString("import_file");
  5502. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5503. string printman = GetPostString("printman");
  5504. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5505. string date1 = GetPostString("date1");
  5506. string date2 = GetPostString("date2");
  5507. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5508. if (dw.Length > 0) lw.Add(dw);
  5509. string fdate1 = GetPostString("finishdate1");
  5510. string fdate2 = GetPostString("finishdate2");
  5511. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5512. if (fdw.Length > 0) lw.Add(fdw);
  5513. string supplierId = GetPostString("supplierId");
  5514. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5515. if (listtype == 1)
  5516. {
  5517. lw.Add(string.Format("importUserId !=0"));
  5518. }
  5519. string posTag = CurrentUser.UserPost.Post.Code;
  5520. if (posTag == "Supplier")
  5521. {
  5522. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5523. }
  5524. if (dStruct.PageSize != 100000)
  5525. {
  5526. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5527. }
  5528. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5529. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5530. writeGridDataTableJson(dStruct.TotalCount, dt);
  5531. }
  5532. public void set_erp_buchaorderdelivery()
  5533. {
  5534. if (UrlPostParmsCheck("ctid"))
  5535. {
  5536. string eid = GetPostString("ctid");
  5537. CeErpTradeCell entity = null;
  5538. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5539. if (entity != null)
  5540. {
  5541. if (entity.IsSample != 2)
  5542. {
  5543. returnErrorMsg("补差价单才能标记为已发货");
  5544. return;
  5545. }
  5546. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5547. entity.OrderState = 7;
  5548. entity.Update();
  5549. returnSuccessMsg("操作成功!");
  5550. return;
  5551. }
  5552. returnErrorMsg("找不到记录");
  5553. }
  5554. }
  5555. public void get_stdtemplates()
  5556. {
  5557. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5558. //string res = taobaoHelper.test();
  5559. string res = apiHelper.API_PrintTemplate();
  5560. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5561. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5562. {
  5563. int sidx = res.IndexOf("error_code");
  5564. int eidx = res.IndexOf("success");
  5565. string msg = res.Substring(sidx, eidx - sidx);
  5566. returnErrorMsg(msg);
  5567. return;
  5568. }
  5569. if (res.Length <= 0)
  5570. {
  5571. returnErrorMsg("模板数据为空!");
  5572. return;
  5573. }
  5574. ReturnSuccess(res);
  5575. }
  5576. public void cancel_print_order()
  5577. {
  5578. if (UrlPostParmsCheck("ctid"))
  5579. {
  5580. string ctid = GetPostString("ctid");
  5581. CeErpTradeCell entity = null;
  5582. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5583. if (entity != null)
  5584. {
  5585. string res = "";
  5586. string code = entity.LastBillWaybillCode;
  5587. if (code == "")
  5588. {
  5589. code = entity.OutSid;
  5590. }
  5591. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5592. XLog.SaveLog(0, "取消面单" + res);
  5593. }
  5594. }
  5595. }
  5596. public void set_erp_printwaybill()
  5597. {
  5598. if (UrlPostParmsCheck("ctid"))
  5599. {
  5600. string ctid = GetPostString("ctid");
  5601. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5602. string cpName = GetPostString("cpname");
  5603. string isTogether = GetPostString("together");
  5604. string printType = GetPostString("printType");
  5605. //var res_obj = new
  5606. //{
  5607. // restype = 1,
  5608. // data = "{\"response\":{\"data\":{\"content\":[{\"openOrderSubId\":\"\",\"parentWaybillCode\":\"\",\"platformType\":\"WB_PDD\",\"updateTime\":1686537867000,\"orderPlatform\":\"PDD\",\"openOrderId\":\"230611-632307127861975\",\"merchId\":1,\"props\":{\"ver\":\"8\",\"signature\":\"lYwcylRHKaeMOxfUvBg7ySYTGGur75biVxO5LTXxM3KeTpMaf6rIvIUFG0HtW4m7+JynVGS83sdGaIAYK3Rrr4QZZTKskIXWKGHKES7lmCP1yM7xD8Cm50aBAfelZo390L1PBb5WSn3EQB40vNIuV2itH2ajXqHtr93Mk2mDnno=\",\"dataVerification\":\"c609dcf70cf85832458adffe1aec3933\",\"encryptedData\":\"50830ac2124673c1abf81fc49c845bd5c55e9e4d1b2d03cd5f7b5445b79a95d763c60072c76649bec3effe329c02bc8c0a6ef3b43603bcfe31fd83dea03352a019cd2ab261c89b883168484f512c03f3fd586e2d487f2b612ed74ffd7d00ccc933739947ca46579f6187e4e23417a7b4f5b09faeb3045aa995fc177d9cc854ba6c1f0f345ad92320e1ed2bbdabc285b86f92b1e705e70bf2d3472b375a0bff031b385a1d2365865b0723d1fd0ecafd45ef01cb1cbf70613d83aa09d5a8c381d2099f5badee8c39e757159f86d6162e1f4bda68723eabb70526c2c0671df7463b281c43bca1b1a4f47b8b59ed666e76353eb4bb5e0be1223c150c8ebd6c623bb2b2448a8c818a76da9fbf1bcc5c3ec45545439f9d4d508fd72b2b127a478cf42b81300fae885c06a0459006bf6fe95db21fab2d7ba9a9a5d635df5eae7ec96248e067dd9ee3fb86b6c93f85a4eb91a290474495cd82b345aa977427946ae6f4034c14fc9b62252657fc03aae9d13d58380affce3c3138690391f1b895da3413d764258aeb26a94ffacec8ab511693462c2bc039a6674b18f7a1bf82abfaf9ebbfd40b2ed77fc7ea95db5ef34c24ee93fc5107cfa13de5ff674f259df1817276ab05f1716c276bd517719a164ab0c4490250f5bd10b6fe1e8b2212fc91a99bc1c42fd6273ef3a68f9c7fc900dc0b2792c2810d361aa054db691ac4c6b578b146f31b9413d43b3af8b8b54ff606b500891e0cbac7d4c4fed8398ccf63ce952e1babe6dbb5deb469ad5f791f2f8df175c6bcfb2c2659441b1e3f4752ef3e727b80587b8a354abe6230263bf4f6e4460154342737ead1f7520f18570ecc633575f7c9d5c23f1c1fe578b5a495398bd14b641d76df38a36f6c6db025258cf02e59e04fa931c00a077bf91aa74ec3d2c03a5b83ded3ff73942699006b36390bed0372683e49cc06a5e906350dcc9ea96f42be381be814c3b9035b8385cdc6f1195b124bfbe42d05406dc7b5d76e096d938e31b5255532271fbc1786459c9081cc068c2f62ffc1a901686b55cd1e712e4bdcfe2a83c324366f8ea734c15332365a9f738746252472e44995d75c2114fbf804bf0769bda4310df5ee95cc94ccd965661cb446af66e048db112bad54dccdc650fa723761baa9449ee6af9196ef936f209310117b4b74aaf955bc1d279d00fe74e3ef9aa96023b714a710cf7e820437106eb10f0d17a4ad7fd100241c56d387e4c4caefbd9d4b438ba0b5799bec54da643f91a65c8fcc0c7dde39e7eca708e237b92a99133c48c9e2a0aaa616acfc0d7336abec25314628ae778e84b35a4319ad6f2ef87f271fd60eba53811ea02a4d5e023216e1dee04fc8960a2bfcaba873ba204cdc675f66f8230818f84e9d7e893867088469ec90e54b96fa78cde6a51e2a2ab4611dfbf4aa8f8c802547a5f24fbc2912786cfb045ef821aa277797211012c28fd836921dba83e1829325bbdf17ad0302e16455b4defbe5a5fadbdc3677505f1d4901531e1db7b13981f31556d743ad3d48eaf2c000be18d5b036837f979240fa3afee74790e82f01dcbd434ff129ecbfed3a0dabaa2a615bac9487a1197323476556eb05469ad8bf75ba95e82a527b93115b360a5920cc23c1f5cf885022dd65e1bd430ffa3d1baf6592b3d6a226c53161a11be8133d3f254ac845e69ed02dd3758cc9adccf42985d8695f8942e08d08d0b27ee49b4bacd4954fe6804e202318f9143feaec7569c7a0759d0d0ee7b537f95b21f4c8ba9743c12da95802ab2600bdecd7bb3c676207e624a35711287afaeeec6ca2be07eebbc4bf1a56c3615ad6830f3e7dd28ed88a6f9ce8b80727316f959b5f09d9a7545ce2609309e71662910fa702b59f8fc07b55c24a254a1e3237dbd054569832111658f3e747aaa619124e2c2467e241d30c1e756a1338a89bad3ce6b8c7fccbd656b1cfbd1cec8bb46e05a5f5f8d87c1f43058389bc64f1f4cbb3fefe5b427892a4064ed83855cdab9f645810170bdee8d8d0e2c5f1cea3732d4699071803a62f3bb056cdd019ac74ce899cc653b76765c0bafee7cfc17521cc3162e01efe25497fe04af1f91fe7033b66f34b08a9451149e4be0ab5b6ce0e2b236626eec93b1e645515fd98b781dceef19b299c692def81095d3114e091c0fb4d6f37d83bb47c1282efd0361716aaebf8b837cc8a17b7ade3305cedcc7736062ac8b4619eb7ee48d6ee954ae977ef4f393ceefe50117874556c30f892f522f0bdb94fa3faceef691579397c1666d21c3264e58eded67f95f6f5b17bf8737ef73d4fd6f66168a148be89368d262807d0817fb67c9580b8d03ea8009951754722?v=8&pv=1\",\"templateUrl\":\"https://file-link.pinduoduo.com/yto_one\"},\"updateBy\":0,\"tenantId\":34,\"waybillCode\":\"YT8910742640842\",\"id\":989598,\"partnerId\":794928,\"mark\":[],\"status\":\"USED\"}]},\"success\":true},\"_req_id\":\"W4Yffp19yC\"}"
  5609. //};
  5610. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5611. //ReturnSuccess(ro_json);
  5612. //return;
  5613. bool isUseLastWayBillCode = false;
  5614. CeErpTradeCell entity = null;
  5615. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5616. if (entity != null)
  5617. {
  5618. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5619. {
  5620. isUseLastWayBillCode = true;
  5621. }
  5622. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5623. {
  5624. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5625. return;
  5626. }
  5627. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5628. {
  5629. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5630. return;
  5631. }
  5632. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5633. {
  5634. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5635. return;
  5636. }
  5637. }
  5638. string res = "";
  5639. Api_waybill_code_response_Obj fullObj = null;
  5640. string pData_str = "";
  5641. string curUseWayBillCode = "";
  5642. if (isUseLastWayBillCode == false)
  5643. {
  5644. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5645. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5646. if (res.IndexOf("failure") != -1)
  5647. {
  5648. //int idx = res.IndexOf("sub_message");
  5649. //int idx2 = res.IndexOf("flag");
  5650. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5651. string errMsgNeed = commonHelper.KeepChinese(res);
  5652. var res_objd = new
  5653. {
  5654. restype = 0,
  5655. data = "获取面单失败" + errMsgNeed
  5656. };
  5657. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5658. returnSuccess(ro_jsond);
  5659. if (res.IndexOf("停发") != -1)
  5660. {
  5661. entity.UnusualCon = "物流停发";
  5662. entity.Update();
  5663. }
  5664. //returnErrorMsg("获取面单失败,"+emsg);
  5665. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5666. return;
  5667. }
  5668. else if (res.IndexOf("errorMsg") != -1)
  5669. {
  5670. //int idx = res.IndexOf("errorMsg");
  5671. //int idx2 = res.IndexOf("}]}");
  5672. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5673. string errMsgNeed = commonHelper.KeepChinese(res);
  5674. var res_objf = new
  5675. {
  5676. restype = 0,
  5677. data = "获取面单失败2" + errMsgNeed
  5678. };
  5679. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5680. if (res.IndexOf("停发") != -1)
  5681. {
  5682. entity.UnusualCon = "物流停发";
  5683. entity.Update();
  5684. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5685. if (trade != null)
  5686. {
  5687. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5688. }
  5689. }
  5690. returnSuccess(ro_jsonf);
  5691. //returnErrorMsg("获取面单失败," + emsg);
  5692. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5693. return;
  5694. }
  5695. try
  5696. {
  5697. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5698. //res = res.Replace(" ", "");
  5699. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5700. }
  5701. catch (Exception ex)
  5702. {
  5703. XLog.SaveLog(0, "生成fullObj" + res);
  5704. var res_objf = new
  5705. {
  5706. restype = 0,
  5707. data = "生成fullObj发生错误" + ex.Message
  5708. };
  5709. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5710. returnSuccess(ro_jsonf);
  5711. return;
  5712. }
  5713. if (fullObj.response.data.content.Count > 0)
  5714. {
  5715. ContentItem codeObj = fullObj.response.data.content[0];
  5716. if (cpCode.IndexOf("SFFQ-") != -1)
  5717. {
  5718. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5719. }
  5720. else
  5721. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5722. curUseWayBillCode = codeObj.waybillCode;
  5723. }
  5724. else
  5725. {
  5726. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5727. var res_objf = new
  5728. {
  5729. restype = 0,
  5730. data = "生成fullObj找不到快递单号waybillCode"
  5731. };
  5732. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5733. returnSuccess(ro_jsonf);
  5734. return;
  5735. }
  5736. }
  5737. else
  5738. {
  5739. //使用上次打印的快递单号
  5740. if (cpCode == "SFFQ-LY")
  5741. {
  5742. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5743. }
  5744. else
  5745. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5746. curUseWayBillCode = entity.LastBillWaybillCode;
  5747. }
  5748. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5749. {
  5750. var res_obje = new
  5751. {
  5752. restype = 0,
  5753. data = "获取加密打印数据失败"
  5754. };
  5755. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5756. returnSuccess(ro_jsone);
  5757. entity.LastBillCpCode = cpCode;
  5758. entity.LastBillWaybillCode = curUseWayBillCode;
  5759. entity.Update();
  5760. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5761. //returnErrorMsg("获取加密打印数据失败");
  5762. return;
  5763. }
  5764. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5765. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5766. string btnType = "";
  5767. string errorMsg = "";
  5768. if (entity != null)
  5769. {
  5770. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5771. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5772. //cpcode是 YTO-CAINIAO
  5773. //string comCode = cpCode.Split('-')[0].ToString();
  5774. string apires = "";
  5775. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5776. //isTogether=2是新的合包弹窗
  5777. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5778. {
  5779. if (ctid.IndexOf("N") != -1)
  5780. {
  5781. apires = "发货成功";
  5782. }
  5783. else
  5784. {
  5785. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode, entity.ctid);
  5786. }
  5787. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5788. //打单后发货
  5789. StringBuilder sql = new StringBuilder();
  5790. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5791. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5792. {
  5793. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5794. }
  5795. else
  5796. {
  5797. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5798. }
  5799. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5800. foreach (DataRow row in dt.Rows)
  5801. {
  5802. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5803. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5804. {
  5805. try
  5806. {
  5807. btnType = "待发货";
  5808. entity.OutSid = curUseWayBillCode;
  5809. entity.OrderState = 7;
  5810. entity.IsUrgency = false;
  5811. entity.LastBillCpCode = "";
  5812. entity.LastBillWaybillCode = "";
  5813. entity.FinishDeliveryTime = DateTime.Now;
  5814. entity.IsReturn = 0;
  5815. entity.MemoOpt = 0;
  5816. entity.UpdateTime = DateTime.Now;
  5817. entity.Update();
  5818. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5819. //还要插入快递信息到 快递信息表
  5820. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5821. exinfo.tid = entity.ctid;
  5822. exinfo.out_sid = curUseWayBillCode;
  5823. exinfo.company_code = cpCode;
  5824. exinfo.company_name = cpName;
  5825. exinfo.supplierUserName = supplierName;
  5826. exinfo.deliveryType = "发货成功";
  5827. exinfo.print_time = DateTime.Now;
  5828. exinfo.printUser = CurrentUser.UserName;
  5829. exinfo.postData = pData_str;
  5830. exinfo.Create();
  5831. commonHelper.UpdateRelationOrder(entity.ctid);
  5832. CeErpSukuraData.createInfo(ctid, 4);
  5833. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5834. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5835. {
  5836. commonHelper.sendCytExpress(exinfo);
  5837. }
  5838. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5839. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5840. }
  5841. catch (Exception ex)
  5842. {
  5843. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5844. }
  5845. }
  5846. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5847. {
  5848. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5849. if (entity.OrderState == 6)
  5850. {
  5851. entity.OrderState = 7;
  5852. }
  5853. entity.UpdateTime = DateTime.Now;
  5854. entity.FinishDeliveryTime = DateTime.Now;
  5855. btnType = "已发货";
  5856. entity.Update();
  5857. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5858. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5859. exinfo.tid = entity.ctid;
  5860. exinfo.out_sid = curUseWayBillCode;
  5861. exinfo.company_code = cpCode;
  5862. exinfo.company_name = cpName;
  5863. exinfo.supplierUserName = supplierName;
  5864. exinfo.deliveryType = "发货成功";
  5865. exinfo.print_time = DateTime.Now;
  5866. exinfo.printUser = CurrentUser.UserName;
  5867. exinfo.postData = pData_str;
  5868. exinfo.Create();
  5869. commonHelper.UpdateRelationOrder(entity.ctid);
  5870. CeErpSukuraData.createInfo(entity.ctid, 4);
  5871. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5872. {
  5873. commonHelper.sendCytExpress(exinfo);
  5874. }
  5875. //不处理
  5876. }
  5877. else
  5878. {
  5879. entity.UpdateTime = DateTime.Now;
  5880. entity.LastBillCpCode = cpCode;
  5881. entity.LastBillWaybillCode = curUseWayBillCode;
  5882. entity.Update();
  5883. string errmsg = commonHelper.KeepChinese(apires);
  5884. var res_objz = new
  5885. {
  5886. restype = 0,
  5887. data = "打单后发货失败"
  5888. };
  5889. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5890. returnSuccess(ro_jsonz);
  5891. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5892. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5893. return;
  5894. }
  5895. }
  5896. }
  5897. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5898. {
  5899. string ctids = GetPostString("ctids");
  5900. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5901. List<string> list = new List<string>();
  5902. List<string> send_list = new List<string>();
  5903. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5904. CeErpTrade ceErpTrade = new CeErpTrade();
  5905. //可合包的合并一起发货
  5906. if (dt == null && string.IsNullOrEmpty(ctids))
  5907. {
  5908. var res_objz = new
  5909. {
  5910. restype = 0,
  5911. data = "打单后发货失败"
  5912. };
  5913. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5914. returnSuccess(ro_jsonz);
  5915. return;
  5916. }
  5917. if (!string.IsNullOrEmpty(ctids))
  5918. {
  5919. StringBuilder sql = new StringBuilder();
  5920. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5921. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5922. }
  5923. foreach (DataRow row in dt.Rows)
  5924. {
  5925. list.Add("'" + row["ctid"] + "'");
  5926. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5927. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5928. if (ctid.IndexOf("N") != -1)
  5929. {
  5930. apires = "发货成功";
  5931. }
  5932. else
  5933. {
  5934. if (!send_list.Contains(ceErpTrade.tid))
  5935. {
  5936. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode, ctid);
  5937. }
  5938. else
  5939. {
  5940. apires = "发货成功";
  5941. }
  5942. }
  5943. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5944. {
  5945. send_list.Add(ceErpTrade.tid);
  5946. try
  5947. {
  5948. btnType = "待发货";
  5949. ceErpTradeCell.OutSid = curUseWayBillCode;
  5950. ceErpTradeCell.OrderState = 7;
  5951. ceErpTradeCell.IsUrgency = false;
  5952. ceErpTradeCell.LastBillCpCode = "";
  5953. ceErpTradeCell.LastBillWaybillCode = "";
  5954. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5955. ceErpTradeCell.IsReturn = 0;
  5956. ceErpTradeCell.MemoOpt = 0;
  5957. ceErpTradeCell.UpdateTime = DateTime.Now;
  5958. ceErpTradeCell.Update();
  5959. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5960. //还要插入快递信息到 快递信息表
  5961. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5962. exinfo.tid = ceErpTradeCell.ctid;
  5963. exinfo.out_sid = curUseWayBillCode;
  5964. exinfo.company_code = cpCode;
  5965. exinfo.company_name = cpName;
  5966. exinfo.supplierUserName = supplierName;
  5967. exinfo.deliveryType = "发货成功";
  5968. exinfo.print_time = DateTime.Now;
  5969. exinfo.printUser = CurrentUser.UserName;
  5970. exinfo.postData = pData_str;
  5971. exinfo.Create();
  5972. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5973. CeErpSukuraData.createInfo(ctid, 4);
  5974. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5975. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80 || entity.SupplierId == 126)
  5976. {
  5977. commonHelper.sendCytExpress(exinfo);
  5978. }
  5979. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5980. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5981. }
  5982. catch (Exception ex)
  5983. {
  5984. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5985. }
  5986. }
  5987. else
  5988. {
  5989. ceErpTradeCell.UpdateTime = DateTime.Now;
  5990. ceErpTradeCell.LastBillCpCode = cpCode;
  5991. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5992. ceErpTradeCell.Update();
  5993. string errmsg = commonHelper.KeepChinese(apires);
  5994. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5995. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5996. }
  5997. }
  5998. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5999. }
  6000. }
  6001. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  6002. var res_obj = new
  6003. {
  6004. restype = 1,
  6005. data = pData_str,
  6006. errorMsg
  6007. };
  6008. string ro_json = JsonConvert.SerializeObject(res_obj);
  6009. ReturnSuccess(ro_json);
  6010. return;
  6011. }
  6012. }
  6013. private string GetUTF8String(byte[] vs)
  6014. {
  6015. throw new NotImplementedException();
  6016. }
  6017. public void set_erp_printwaybill_cn()
  6018. {
  6019. if (UrlPostParmsCheck("ctid"))
  6020. {
  6021. string ctid = GetPostString("ctid");
  6022. string cpCode = GetPostString("cpcode");
  6023. string cpName = GetPostString("cpname");
  6024. string tempUrl = GetPostString("tempurl");
  6025. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6026. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  6027. //string res = taobaoHelper.test();
  6028. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6029. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  6030. {
  6031. int sidx = res.IndexOf("errorMsg");
  6032. int eidx = res.IndexOf("}");
  6033. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  6034. var res_objzxx = new
  6035. {
  6036. restype = 0,
  6037. data = msg
  6038. };
  6039. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  6040. returnSuccess(ro_jsonzxx);
  6041. //returnErrorMsg(msg);
  6042. return;
  6043. }
  6044. int idx = res.IndexOf("waybillCode");
  6045. int idx2 = res.IndexOf("printData");
  6046. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  6047. string eid = GetPostString("ctid");
  6048. CeErpTradeCell entity = null;
  6049. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6050. if (entity != null)
  6051. {
  6052. string osid = entity.OutSid;
  6053. entity.OutSid = osid + "," + outsid;
  6054. entity.FinishDeliveryTime = DateTime.Now;
  6055. entity.OrderState = 7;
  6056. entity.UpdateTime = DateTime.Now;
  6057. entity.IsReturn = 0;
  6058. entity.Update();
  6059. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  6060. exinfo.tid = entity.ctid;
  6061. exinfo.out_sid = outsid;
  6062. exinfo.company_code = cpCode;
  6063. exinfo.company_name = cpName;
  6064. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  6065. exinfo.deliveryType = "发货成功";
  6066. exinfo.print_time = DateTime.Now;
  6067. exinfo.printUser = CurrentUser.UserName;
  6068. exinfo.Create();
  6069. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  6070. {
  6071. commonHelper.sendCytExpress(exinfo);
  6072. }
  6073. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  6074. }
  6075. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  6076. var res_objz = new
  6077. {
  6078. restype = 1,
  6079. data = res
  6080. };
  6081. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6082. returnSuccess(ro_jsonz);
  6083. //ReturnSuccess(res);
  6084. }
  6085. }
  6086. ////打单,打印面单 获取面单号
  6087. //public void set_erp_printwaybill()
  6088. //{
  6089. // if (UrlPostParmsCheck("ctid"))
  6090. // {
  6091. // string ctid = GetPostString("ctid");
  6092. // string cpCode = GetPostString("cpcode");
  6093. // string tempUrl = GetPostString("tempurl");
  6094. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6095. // //string res = taobaoHelper.test();
  6096. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6097. // if (res.IndexOf("error_response") != -1)
  6098. // {
  6099. // int sidx = res.IndexOf("sub_msg");
  6100. // int eidx = res.IndexOf("request_id");
  6101. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  6102. // returnErrorMsg(msg);
  6103. // return;
  6104. // }
  6105. // int idx = res.IndexOf("waybill_code");
  6106. // int idx2 = res.IndexOf("}]}");
  6107. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  6108. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  6109. // ReturnSuccess(res);
  6110. // }
  6111. //}
  6112. public void cancel_erp_aftersale()
  6113. {
  6114. if (UrlPostParmsCheck("ctid"))
  6115. {
  6116. string eid = GetPostString("ctid");
  6117. CeErpTradeCell entity = null;
  6118. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6119. if (entity != null)
  6120. {
  6121. //有过处理的售后,取消也不能删除 售 字,保留
  6122. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6123. {
  6124. entity.AfterSaleState = 4;
  6125. }
  6126. else
  6127. entity.AfterSaleState = 0;
  6128. entity.UpdateTime = DateTime.Now;
  6129. entity.Update();
  6130. returnSuccessMsg("操作成功!");
  6131. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6132. return;
  6133. }
  6134. returnErrorMsg("找不到订单记录");
  6135. }
  6136. }
  6137. public void get_erp_aftersalelist()
  6138. {
  6139. DataStruct dStruct = GetPostStruct();
  6140. List<string> lw = new List<string>();
  6141. int st = GetInt("st");
  6142. string tid = GetPostString("ctid");
  6143. if (st == 3)
  6144. {
  6145. if (tid.Length > 0)
  6146. {
  6147. string select_tid = getTidByCtid(tid);
  6148. lw.Add(string.Format("tid='{0}'", select_tid));
  6149. }
  6150. }
  6151. else
  6152. {
  6153. if (tid.Length > 0)
  6154. {
  6155. string select_tid = getTidByCtid(tid);
  6156. lw.Add(string.Format("tid='{0}'", select_tid));
  6157. }
  6158. }
  6159. string shopname = GetPostString("shopname");
  6160. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6161. string buyernick = GetPostString("buyer_nick");
  6162. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6163. string sellermemo = GetPostString("seller_memo");
  6164. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6165. string orderState = GetPostString("orderState");
  6166. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6167. string afterState = GetPostString("afterstate");
  6168. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6169. string date1 = GetPostString("date1");
  6170. string date2 = GetPostString("date2");
  6171. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6172. if (dw.Length > 0) lw.Add(dw);
  6173. string price1 = GetPostString("price1");
  6174. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6175. string price2 = GetPostString("price2");
  6176. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6177. //lw.Add(string.Format("IsRefund!={0}", 1));
  6178. string reason = GetPostString("reason");
  6179. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6180. string method = GetPostString("method");
  6181. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6182. string handler = GetPostString("handler");
  6183. if (handler.Length > 0)
  6184. {
  6185. lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6186. }
  6187. string handledate1 = GetPostString("handledate1");
  6188. string handledate2 = GetPostString("handledate2");
  6189. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6190. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6191. string finish1 = GetPostString("finishdate1");
  6192. string finish2 = GetPostString("finishdate2");
  6193. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6194. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6195. string afterdate1 = GetPostString("afterdate1");
  6196. string afterdate2 = GetPostString("afterdate2");
  6197. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6198. if (afterDate.Length > 0) lw.Add(afterDate);
  6199. string supplier = GetPostString("supplier");
  6200. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6201. string responsible = GetPostString("responsibleman");
  6202. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6203. string customer = GetPostString("customer");
  6204. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6205. string design = GetPostString("design");
  6206. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6207. string afterMemoType = GetPostString("aftermemotype");
  6208. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6209. string posCode = CurrentUser.UserPost.Post.Code;
  6210. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6211. //{
  6212. // string vstate = GetPostString("vstate");
  6213. // if (vstate.Length > 0)
  6214. // {
  6215. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6216. // }
  6217. // if (posCode == "Supplier")
  6218. // {
  6219. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6220. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6221. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6222. // }
  6223. // else
  6224. // {
  6225. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6226. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6227. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6228. // {
  6229. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6230. // }
  6231. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6232. // {
  6233. // int orgid = CurrentUser.UserPost.OrgID;
  6234. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6235. // }
  6236. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6237. // {
  6238. // string shopid = CurrentUser.User.pemShop;
  6239. // lw.Add(string.Format("shopId in ({0})", shopid));
  6240. // }
  6241. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6242. // //{
  6243. // // int org_id = CurrentUser.UserPost.OrgID;
  6244. // // lw.Add(string.Format("OrgID={0}", org_id));
  6245. // //}
  6246. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6247. // }
  6248. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6249. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6250. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6251. //}
  6252. if (st == 5)
  6253. {
  6254. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6255. {
  6256. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6257. {
  6258. string shopid = CurrentUser.User.pemShop;
  6259. lw.Add(string.Format("shopId in ({0})", shopid));
  6260. }
  6261. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6262. {
  6263. int mrOrgid = CurrentUser.UserPost.OrgID;
  6264. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6265. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6266. }
  6267. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6268. //{
  6269. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6270. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6271. //}
  6272. else
  6273. {
  6274. string userIdStr = "";
  6275. if (posCode == "CustomerService")
  6276. {
  6277. userIdStr = CurrentUser.UserID + "_k";
  6278. }
  6279. else if (posCode == "Designer" || posCode == "wxDesigner")
  6280. {
  6281. userIdStr = CurrentUser.UserID + "_s";
  6282. }
  6283. else if (posCode == "Place")
  6284. {
  6285. userIdStr = CurrentUser.UserID + "_x";
  6286. }
  6287. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6288. }
  6289. }
  6290. string placedate1 = GetPostString("placedate1");
  6291. string placedate2 = GetPostString("placedate2");
  6292. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6293. if (dwplace.Length > 0) lw.Add(dwplace);
  6294. string supState = GetPostString("supState");
  6295. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6296. string searchType = GetPostString("searchType");
  6297. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6298. {
  6299. lw.Add(string.Format("BackNum>1"));
  6300. }
  6301. lw.Add(string.Format("AfterSaleState>0"));
  6302. if (ex_psize > 0)
  6303. {
  6304. if (CurrentUser.UserPost.Post.Code == "Finance")
  6305. dStruct.Order = "pay_time desc";
  6306. else
  6307. dStruct.Order = "HandleTime desc";
  6308. }
  6309. else
  6310. dStruct.Order = "HandleTime desc";
  6311. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6312. DataTable dt = WebCache.GetData("view_test", dStruct);
  6313. writeGridDataTableJson(dStruct.TotalCount, dt);
  6314. }
  6315. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6316. //{
  6317. // lw.Add(string.Format("AfterSaleState=4"));
  6318. // string code = CurrentUser.UserPost.Post.Code;
  6319. // if (code == "CustomerService")
  6320. // {
  6321. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6322. // }
  6323. // else if (code == "Designer" || code == "DesignerMr")
  6324. // {
  6325. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6326. // }
  6327. // else if (code == "Place" || code == "PlaceMr")
  6328. // {
  6329. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6330. // }
  6331. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6332. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6333. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6334. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6335. //}
  6336. //else //处理中的售后,待处理和处理中合并
  6337. //{
  6338. // if (afterState.Length <= 0)
  6339. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6340. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6341. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6342. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6343. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6344. //}
  6345. }
  6346. public void get_erp_disagreeftersalelist()
  6347. {
  6348. DataStruct dStruct = GetPostStruct();
  6349. List<string> lw = new List<string>();
  6350. int st = 2;
  6351. string tid = GetPostString("ctid");
  6352. if (tid.Length > 0)
  6353. {
  6354. string select_tid = getTidByCtid(tid);
  6355. lw.Add(string.Format("tid='{0}'", select_tid));
  6356. }
  6357. string shopname = GetPostString("shopname");
  6358. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6359. string buyernick = GetPostString("buyer_nick");
  6360. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6361. string sellermemo = GetPostString("seller_memo");
  6362. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6363. string orderState = GetPostString("orderState");
  6364. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6365. string afterState = GetPostString("afterstate");
  6366. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6367. string date1 = GetPostString("date1");
  6368. string date2 = GetPostString("date2");
  6369. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6370. if (dw.Length > 0) lw.Add(dw);
  6371. string price1 = GetPostString("price1");
  6372. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6373. string price2 = GetPostString("price2");
  6374. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6375. //lw.Add(string.Format("IsRefund!={0}", 1));
  6376. string reason = GetPostString("reason");
  6377. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6378. string method = GetPostString("method");
  6379. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6380. string handler = GetPostString("handler");
  6381. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6382. string handledate1 = GetPostString("handledate1");
  6383. string handledate2 = GetPostString("handledate2");
  6384. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6385. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6386. string afterdate1 = GetPostString("afterdate1");
  6387. string afterdate2 = GetPostString("afterdate2");
  6388. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6389. if (afterDate.Length > 0) lw.Add(afterDate);
  6390. string backdate1 = GetPostString("backdate1");
  6391. string backdate2 = GetPostString("backdate2");
  6392. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6393. if (backDate.Length > 0) lw.Add(backDate);
  6394. string supplier = GetPostString("supplier");
  6395. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6396. string responsible = GetPostString("responsibleman");
  6397. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6398. string customer = GetPostString("customer");
  6399. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6400. string design = GetPostString("design");
  6401. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6402. string afterSaleMemo = GetPostString("afterSaleMemo");
  6403. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6404. string afterMemoType = GetPostString("aftermemotype");
  6405. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6406. string aftersakereason = GetPostString("aftersakereason");
  6407. if (aftersakereason.Length > 0)
  6408. {
  6409. if (aftersakereason == "1")
  6410. {
  6411. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6412. }
  6413. if (aftersakereason == "2")
  6414. {
  6415. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6416. }
  6417. }
  6418. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6419. string poscode = CurrentUser.UserPost.Post.Code;
  6420. if (poscode != "SysAdmin")
  6421. {
  6422. string shopid = CurrentUser.User.pemShop;
  6423. lw.Add(string.Format("shopId in ({0})", shopid));
  6424. }
  6425. string searchType = GetPostString("searchType");
  6426. if (searchType == "wait")
  6427. {
  6428. lw.Add(string.Format("HandleTime is null"));
  6429. }
  6430. if (searchType == "handling")
  6431. {
  6432. lw.Add(string.Format("HandleTime is not null "));
  6433. }
  6434. if (searchType == "back" || searchType == "puBack")
  6435. {
  6436. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6437. }
  6438. if (searchType == "reBack")
  6439. {
  6440. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6441. }
  6442. if (searchType == "moreBack")
  6443. {
  6444. lw.Add(string.Format("backNum > 1"));
  6445. }
  6446. lw.Add(string.Format("(AfterSaleState=5)"));
  6447. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6448. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6449. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6450. writeGridDataTableJson(dStruct.TotalCount, dt);
  6451. }
  6452. public void get_erp_handlingaftersalelist()
  6453. {
  6454. DataStruct dStruct = GetPostStruct();
  6455. List<string> lw = new List<string>();
  6456. int st = 2;
  6457. string tid = GetPostString("ctid");
  6458. if (tid.Length > 0)
  6459. {
  6460. string select_tid = getTidByCtid(tid);
  6461. lw.Add(string.Format("tid='{0}'", select_tid));
  6462. }
  6463. string shopname = GetPostString("shopname");
  6464. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6465. string buyernick = GetPostString("buyer_nick");
  6466. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6467. string sellermemo = GetPostString("seller_memo");
  6468. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6469. string orderState = GetPostString("orderState");
  6470. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6471. string searchType = GetPostString("searchType");
  6472. string afterState = GetPostString("afterstate");
  6473. if (searchType != "documentary")
  6474. {
  6475. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6476. }
  6477. string date1 = GetPostString("date1");
  6478. string date2 = GetPostString("date2");
  6479. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6480. if (dw.Length > 0) lw.Add(dw);
  6481. string price1 = GetPostString("price1");
  6482. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6483. string price2 = GetPostString("price2");
  6484. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6485. //lw.Add(string.Format("IsRefund!={0}", 1));
  6486. string reason = GetPostString("reason");
  6487. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6488. string method = GetPostString("method");
  6489. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6490. string handler = GetPostString("handler");
  6491. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6492. string handledate1 = GetPostString("handledate1");
  6493. string handledate2 = GetPostString("handledate2");
  6494. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6495. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6496. string afterdate1 = GetPostString("afterdate1");
  6497. string afterdate2 = GetPostString("afterdate2");
  6498. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6499. if (afterDate.Length > 0) lw.Add(afterDate);
  6500. string supplier = GetPostString("supplier");
  6501. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6502. string responsible = GetPostString("responsibleman");
  6503. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6504. string customer = GetPostString("customer");
  6505. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6506. string design = GetPostString("design");
  6507. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6508. string afterSaleMemo = GetPostString("afterSaleMemo");
  6509. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6510. string afterMemoType = GetPostString("aftermemotype");
  6511. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6512. string afterresult = GetPostString("afterresult");
  6513. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6514. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6515. string poscode = CurrentUser.UserPost.Post.Code;
  6516. if (poscode != "SysAdmin")
  6517. {
  6518. string shopid = CurrentUser.User.pemShop;
  6519. lw.Add(string.Format("shopId in ({0})", shopid));
  6520. }
  6521. if (searchType == "wait")
  6522. {
  6523. lw.Add(string.Format("HandleTime is null"));
  6524. }
  6525. if (searchType == "documentary")
  6526. {
  6527. lw.Add(string.Format(" AfterSaleState > 2 AND HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' AND AfterSalSend = 0 "));
  6528. afterState = "2";
  6529. }
  6530. if (searchType == "handling")
  6531. {
  6532. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6533. }
  6534. if (searchType == "back" || searchType == "puBack")
  6535. {
  6536. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6537. }
  6538. if (searchType == "reBack")
  6539. {
  6540. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6541. }
  6542. if (afterState.Length <= 0)
  6543. {
  6544. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6545. }
  6546. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6547. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6548. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6549. writeGridDataTableJson(dStruct.TotalCount, dt);
  6550. }
  6551. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6552. //public void get_erp_back_handlingaftersalelist()
  6553. //{
  6554. // DataStruct dStruct = GetPostStruct();
  6555. // List<string> lw = new List<string>();
  6556. // string tid = GetPostString("ctid");
  6557. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6558. // string shopname = GetPostString("shopname");
  6559. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6560. // string buyernick = GetPostString("buyer_nick");
  6561. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6562. // string sellermemo = GetPostString("seller_memo");
  6563. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6564. // string orderState = GetPostString("orderState");
  6565. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6566. // string afterState = GetPostString("afterstate");
  6567. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6568. // string date1 = GetPostString("date1");
  6569. // string date2 = GetPostString("date2");
  6570. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6571. // if (dw.Length > 0) lw.Add(dw);
  6572. // string price1 = GetPostString("price1");
  6573. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6574. // string price2 = GetPostString("price2");
  6575. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6576. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6577. // string reason = GetPostString("reason");
  6578. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6579. // string method = GetPostString("method");
  6580. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6581. // string handler = GetPostString("handler");
  6582. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6583. // string handledate1 = GetPostString("handledate1");
  6584. // string handledate2 = GetPostString("handledate2");
  6585. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6586. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6587. // string afterdate1 = GetPostString("afterdate1");
  6588. // string afterdate2 = GetPostString("afterdate2");
  6589. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6590. // if (afterDate.Length > 0) lw.Add(afterDate);
  6591. // string supplier = GetPostString("supplier");
  6592. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6593. // string responsible = GetPostString("responsibleman");
  6594. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6595. // string customer = GetPostString("customer");
  6596. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6597. // string design = GetPostString("design");
  6598. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6599. // string afterMemoType = GetPostString("aftermemotype");
  6600. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6601. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6602. // if (afterState.Length <= 0)
  6603. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6604. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6605. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6606. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6607. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6608. //}
  6609. public void get_erp_aftersaleverifylist()
  6610. {
  6611. DataStruct dStruct = GetPostStruct();
  6612. List<string> lw = new List<string>();
  6613. string tid = GetPostString("ctid");
  6614. if (tid.Length > 0)
  6615. {
  6616. string select_tid = getTidByCtid(tid);
  6617. lw.Add(string.Format("otid='{0}'", select_tid));
  6618. }
  6619. string shopname = GetPostString("shopname");
  6620. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6621. string buyernick = GetPostString("buyer_nick");
  6622. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6623. string sellermemo = GetPostString("seller_memo");
  6624. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6625. string orderState = GetPostString("orderState");
  6626. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6627. //lw.Add(string.Format("IsRefund!={0}", 1));
  6628. string reason = GetPostString("reason");
  6629. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6630. string method = GetPostString("method");
  6631. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6632. string handler = GetPostString("handler");
  6633. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6634. string handledate1 = GetPostString("handledate1");
  6635. string handledate2 = GetPostString("handledate2");
  6636. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6637. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6638. string finish1 = GetPostString("finishdate1");
  6639. string finish2 = GetPostString("finishdate2");
  6640. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6641. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6642. string supplier = GetPostString("supplier");
  6643. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6644. string responsible = GetPostString("responsibleman");
  6645. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6646. string posCode = CurrentUser.UserPost.Post.Code;
  6647. string vstate = GetPostString("vstate");
  6648. if (vstate.Length > 0)
  6649. {
  6650. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6651. }
  6652. if (posCode == "Supplier")
  6653. {
  6654. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6655. lw.Add(string.Format("VerifyState = 0"));
  6656. lw.Add("type = 1");
  6657. lw.Add(string.Format("AfterSaleState={0}", 3));
  6658. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6659. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6660. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6661. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6662. writeGridDataTableJson(dStruct.TotalCount, dt);
  6663. }
  6664. else if (posCode == "logistics")
  6665. {
  6666. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6667. lw.Add(string.Format("VerifyState = 0"));
  6668. lw.Add("type = 2");
  6669. lw.Add(string.Format("AfterSaleState={0}", 3));
  6670. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6671. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6672. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6673. writeGridDataTableJson(dStruct.TotalCount, dt);
  6674. }
  6675. else
  6676. {
  6677. lw.Add(string.Format("(AfterSaleState = 3)"));
  6678. lw.Add("type = 0");
  6679. string reasonState = GetPostString("reasonState");
  6680. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6681. {
  6682. if (reasonState == "2")
  6683. {
  6684. lw.Add("VerifyState = 3");
  6685. }
  6686. else if (reasonState == "1")
  6687. {
  6688. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6689. }
  6690. else
  6691. {
  6692. lw.Add("VerifyState in (0,3)");
  6693. }
  6694. //不加条件,可以看全部
  6695. }
  6696. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMaster" || CurrentUser.UserPost.Post.Code == "CustomerMr" || CurrentUser.UserPost.Post.Code == "DesignerMr" || CurrentUser.UserPost.Post.Code == "wxDesignerMr" || CurrentUser.UserPost.Post.Code == "Designerhd" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  6697. {
  6698. int orgid = CurrentUser.UserPost.OrgID;
  6699. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6700. if (string.IsNullOrEmpty(manageOrgId))
  6701. {
  6702. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6703. }
  6704. else
  6705. {
  6706. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6707. }
  6708. if (reasonState == "1")
  6709. {
  6710. lw.Add("VerifyState = 3");
  6711. }
  6712. else if (reasonState == "2")
  6713. {
  6714. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6715. }
  6716. else
  6717. {
  6718. }
  6719. }
  6720. else
  6721. {
  6722. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6723. }
  6724. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6725. //{
  6726. // int org_id = CurrentUser.UserPost.OrgID;
  6727. // lw.Add(string.Format("OrgID={0}", org_id));
  6728. //}
  6729. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6730. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6731. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6732. writeGridDataTableJson(dStruct.TotalCount, dt);
  6733. }
  6734. }
  6735. public void get_erp_finishaftersalelist()
  6736. {
  6737. DataStruct dStruct = GetPostStruct();
  6738. List<string> lw = new List<string>();
  6739. int st = 4;
  6740. string tid = GetPostString("ctid");
  6741. if (tid.Length > 0)
  6742. {
  6743. string select_tid = getTidByCtid(tid);
  6744. lw.Add(string.Format("otid='{0}'", select_tid));
  6745. }
  6746. string shopname = GetPostString("shopname");
  6747. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6748. //lw.Add(string.Format("IsRefund!={0}", 1));
  6749. string reason = GetPostString("reason");
  6750. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6751. string method = GetPostString("method");
  6752. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6753. string buyernick = GetPostString("buyer_nick");
  6754. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6755. string handler = GetPostString("handler");
  6756. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6757. string handledate1 = GetPostString("handledate1");
  6758. string handledate2 = GetPostString("handledate2");
  6759. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6760. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6761. string finish1 = GetPostString("finishdate1");
  6762. string finish2 = GetPostString("finishdate2");
  6763. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6764. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6765. string supplier = GetPostString("supplier");
  6766. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6767. string responsible = GetPostString("responsibleman");
  6768. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6769. string vstate = GetPostString("vstate");
  6770. if (vstate.Length > 0)
  6771. {
  6772. if ("3".Equals(vstate))
  6773. {
  6774. lw.Add(string.Format("IsTem=1"));
  6775. }
  6776. else
  6777. {
  6778. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6779. }
  6780. }
  6781. lw.Add(string.Format("AfterSaleState=4"));
  6782. string code = CurrentUser.UserPost.Post.Code;
  6783. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6784. {
  6785. //不加条件,可以看全部
  6786. }
  6787. else if (code == "Supplier")
  6788. {
  6789. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6790. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6791. lw.Add("type = 1");
  6792. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6793. }
  6794. else if (code == "logistics")
  6795. {
  6796. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6797. lw.Add("type = 2");
  6798. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6799. }
  6800. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMaster" || CurrentUser.UserPost.Post.Code == "CustomerMr" || CurrentUser.UserPost.Post.Code == "DesignerMr" || CurrentUser.UserPost.Post.Code == "wxDesignerMr" || CurrentUser.UserPost.Post.Code == "Designerhd" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  6801. {
  6802. lw.Add("type = 0");
  6803. int orgid = CurrentUser.UserPost.OrgID;
  6804. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6805. if (string.IsNullOrEmpty(manageOrgIds))
  6806. {
  6807. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6808. }
  6809. else
  6810. {
  6811. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6812. }
  6813. }
  6814. else
  6815. {
  6816. lw.Add("type = 0");
  6817. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6818. }
  6819. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6820. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6821. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6822. writeGridDataTableJson(dStruct.TotalCount, dt);
  6823. }
  6824. public void handle_erp_aftersale()
  6825. {
  6826. if (UrlPostParmsCheck("ctid"))
  6827. {
  6828. string eid = GetPostString("ctid");
  6829. string responStr = GetPostString("AfterSaleResponsible");
  6830. if (responStr.Length <= 0)
  6831. {
  6832. returnErrorMsg("售后责任人不能为空");
  6833. return;
  6834. }
  6835. bool isDesign = false;
  6836. double designFree = 0.00;
  6837. int responsibleId = 0;
  6838. CeErpTradeCell entity = null;
  6839. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6840. if (entity != null)
  6841. {
  6842. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6843. string afterMethod = GetPostString("AfterSaleMethod");
  6844. if (isNeedNewOrder == 1)
  6845. {
  6846. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6847. bool ishav = true;
  6848. if (newentity == null)
  6849. {
  6850. newentity = entity.Clone() as CeErpTradeCell;
  6851. ishav = false;
  6852. newentity.ctid = "S_" + entity.ctid;
  6853. newentity.OrderState = 0;
  6854. //唯一标识
  6855. newentity.OrderSn = newentity.ctid;
  6856. string orderSn = commonHelper.generateDateTimeRandomNos();
  6857. if (orderSn != "")
  6858. {
  6859. newentity.OrderSn = orderSn;
  6860. }
  6861. }
  6862. newentity.UpdateTime = DateTime.Now;
  6863. newentity.AfterSaleState = 0;
  6864. newentity.AfterSaleMethod = afterMethod;
  6865. if (!ishav)
  6866. {
  6867. string memo_str = newentity.seller_memo;
  6868. memo_str = memo_str.Replace("(", "(");
  6869. memo_str = memo_str.Replace(")", ")");
  6870. int sIndex = memo_str.IndexOf("(");
  6871. int eIndex = memo_str.IndexOf(")");
  6872. if (sIndex == -1 || eIndex == -1)
  6873. {
  6874. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6875. return;
  6876. }
  6877. string first = memo_str.Substring(0, sIndex + 1);
  6878. string memoCtid = newentity.OrderSn;
  6879. //if (memoCtid.IndexOf("C") != -1)
  6880. //{
  6881. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6882. //if (CIdx.IndexOf("+") != -1)
  6883. //{
  6884. //CIdx = "C" + CIdx.Split('+')[1];
  6885. //}
  6886. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6887. //}
  6888. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6889. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6890. string newMemo = first + memoCtid + last;
  6891. newentity.seller_memo = newMemo;
  6892. newentity.FinishPlaceTime = null;
  6893. newentity.UnusualTag = 0;
  6894. newentity.UnusualCon = "";
  6895. newentity.UnusualTime = null;
  6896. newentity.AfterSaleMemo = "";
  6897. newentity.AfterSaleMethod = afterMethod;
  6898. newentity.AfterSalePreTime = null;
  6899. newentity.AfterSaleReason = "";
  6900. newentity.AfterSaleResponsible = "";
  6901. newentity.AfterSaleState = 0;
  6902. newentity.AfterSaleTime = null;
  6903. newentity.AfterSaleUserId = 0;
  6904. newentity.AfterSaleSupplierState = 0;
  6905. newentity.LastBillWaybillCode = "";
  6906. newentity.LastBillCpCode = "";
  6907. newentity.FinishAfterSaleTime = null;
  6908. newentity.HandleTime = null;
  6909. newentity.IsSF = 0;
  6910. newentity.IsOldCustomer = 0;
  6911. newentity.UrgencyTime = null;
  6912. newentity.ResponsibleUserId = "";
  6913. newentity.IsVerifyToSupplier = false;
  6914. newentity.payment = 0;
  6915. newentity.CheckMemo = "";
  6916. newentity.OutSid = "";
  6917. newentity.CheckOrderTime = null;
  6918. newentity.MemoOpt = 0;
  6919. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6920. }
  6921. newentity.isAfterSaleOrder = 1;
  6922. newentity.IsRefund = 0;
  6923. string receiveMobile = GetPostString("receiver_mobile");
  6924. if (receiveMobile.Length > 0)
  6925. {
  6926. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6927. if (trade != null)
  6928. {
  6929. trade.receiver_name = GetPostString("receiver_name");
  6930. trade.receiver_mobile = receiveMobile;
  6931. trade.receiver_state = GetPostString("receiver_state");
  6932. trade.receiver_city = GetPostString("receiver_city");
  6933. trade.receiver_district = GetPostString("receiver_district");
  6934. trade.receiver_address = GetPostString("receiver_address");
  6935. newentity.IsOffLineOrder = 1;
  6936. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6937. }
  6938. }
  6939. string st = GetPostString("ToState");
  6940. if (st.Length > 0)
  6941. {
  6942. if (newentity.OrderState <= 3)
  6943. {
  6944. newentity.WaitDesignTime = DateTime.Now;
  6945. newentity.StartDesignTime = null;
  6946. newentity.FinishDesignTime = null;
  6947. newentity.OrderState = 3;
  6948. if (st == "下单员")
  6949. {
  6950. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6951. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6952. {
  6953. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6954. }
  6955. }
  6956. else
  6957. {
  6958. newentity.WaitDesignTime = DateTime.Now;
  6959. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6960. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6961. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6962. {
  6963. DataRow user = dt1.Rows[0];
  6964. //找主管
  6965. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6966. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6967. if (dt != null && dt.Rows.Count > 0)
  6968. {
  6969. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6970. newentity.DesignUserId = designMr;
  6971. string key = "aftersale_order_" + designMr;
  6972. if (RedisHelper.HasKey(key))
  6973. {
  6974. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6975. list.Add(newentity.ctid);
  6976. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6977. }
  6978. }
  6979. //账号正常
  6980. if (user["State"].ToString() == "0")
  6981. {
  6982. newentity.DesignUserId = entity.DesignUserId;
  6983. string key = "aftersale_order_" + entity.DesignUserId;
  6984. if (RedisHelper.HasKey(key))
  6985. {
  6986. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6987. list.Add(newentity.ctid);
  6988. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6989. }
  6990. }
  6991. }
  6992. }
  6993. }
  6994. if (entity.IsXianHuo == 1)
  6995. {
  6996. newentity.OrderState = 6;
  6997. entity.FinishPlaceTime = DateTime.Now;
  6998. }
  6999. }
  7000. if (ishav)
  7001. {
  7002. newentity.Update();
  7003. }
  7004. else
  7005. {
  7006. newentity.Create();
  7007. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  7008. newCellExtend.ctid = newentity.ctid;
  7009. newCellExtend.orderFrom = 20;
  7010. newCellExtend.orderType = 30;
  7011. if (st == "下单员")
  7012. {
  7013. }
  7014. else
  7015. {
  7016. newCellExtend.ReprintTime = DateTime.Now;
  7017. }
  7018. newCellExtend.Create();
  7019. }
  7020. if (st != "下单员")
  7021. {
  7022. if (entity.DispatchSort == 2)
  7023. {
  7024. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  7025. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  7026. }
  7027. }
  7028. }
  7029. //处理售后扩展
  7030. string resIdStr = GetPostString("ResponsibleUserId");
  7031. string refundFees = GetPostString("refundFrees");
  7032. int IsComplain = GetPostInt("isComplain");
  7033. int IsBad = GetPostInt("isBad");
  7034. string IsOriginal = GetPostString("isOriginal");
  7035. double diffResultPrice = GetPostDouble("diffResultPrice");
  7036. string textResult = GetPostString("textResult");
  7037. string supplierResponsible = GetPostString("supplierResponsible");
  7038. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  7039. if (ceErpTradeAfterSaleExtend == null)
  7040. {
  7041. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7042. ceErpTradeAfterSaleExtend.tid = eid;
  7043. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7044. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7045. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7046. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7047. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7048. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7049. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7050. ceErpTradeAfterSaleExtend.Create();
  7051. }
  7052. else
  7053. {
  7054. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  7055. {
  7056. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  7057. }
  7058. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7059. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7060. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7061. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7062. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7063. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7064. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7065. ceErpTradeAfterSaleExtend.Update();
  7066. }
  7067. int gysid = GetPostInt("ResponsibleSupId");
  7068. if (entity.AfterSaleUserId == 0)
  7069. {
  7070. entity.AfterSaleUserId = CurrentUser.UserID;
  7071. }
  7072. entity.ResponsibleUserId = resIdStr;
  7073. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  7074. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  7075. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  7076. {
  7077. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7078. int backNum = 0;
  7079. if (number != null)
  7080. {
  7081. backNum = number.BackNum;
  7082. }
  7083. char[] separator = { ',' };
  7084. string[] sArray = resIdStr.Split(separator);
  7085. string[] refundFreeList = { };
  7086. if (refundFees.Length > 0)
  7087. {
  7088. refundFreeList = refundFees.Split(separator);
  7089. }
  7090. int index = -1;
  7091. List<int> responsibleIds = new List<int>();
  7092. foreach (string i in sArray)
  7093. {
  7094. index++;
  7095. if (i.Length <= 0) continue;
  7096. char[] separator2 = { '_' };
  7097. string idstr = i.Split(separator2)[0];
  7098. string idtype = i.Split(separator2)[1];
  7099. double refudFree = 0;
  7100. if (refundFreeList.Length > 0)
  7101. {
  7102. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  7103. }
  7104. if (idtype == "s")
  7105. {
  7106. isDesign = true;
  7107. designFree = refudFree;
  7108. }
  7109. int userId = Convert.ToInt32(idstr);
  7110. int type = 0;
  7111. if (idtype == "g")
  7112. {
  7113. type = 1;
  7114. }
  7115. if (idtype == "w")
  7116. {
  7117. type = 2;
  7118. }
  7119. if (idtype == "t")
  7120. {
  7121. type = 3;
  7122. }
  7123. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7124. if (ceErpTradeResponsible == null)
  7125. {
  7126. ceErpTradeResponsible = new CeErpTradeResponsible();
  7127. ceErpTradeResponsible.tid = eid;
  7128. ceErpTradeResponsible.UserId = userId;
  7129. ceErpTradeResponsible.createdTime = DateTime.Now;
  7130. ceErpTradeResponsible.type = type;
  7131. if (type == 1)
  7132. {
  7133. ceErpTradeResponsible.IsSup = 1;
  7134. }
  7135. if (type == 2)
  7136. {
  7137. ceErpTradeResponsible.IsFlow = 1;
  7138. }
  7139. }
  7140. int state = 0;
  7141. //已认可的不需要再次认可
  7142. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7143. {
  7144. state = 1;
  7145. }
  7146. ceErpTradeResponsible.RefundFee = refudFree;
  7147. ceErpTradeResponsible.VerifyState = state;
  7148. if (userId == 2125 || idtype == "w")
  7149. {
  7150. ceErpTradeResponsible.VerifyState = 1;
  7151. }
  7152. if (idtype == "w" && userId == 101)
  7153. {
  7154. ceErpTradeResponsible.VerifyState = state;
  7155. }
  7156. if (ceErpTradeResponsible.ID > 0)
  7157. {
  7158. ceErpTradeResponsible.Update();
  7159. }
  7160. else
  7161. {
  7162. ceErpTradeResponsible.Create();
  7163. }
  7164. if (isDesign)
  7165. {
  7166. responsibleId = ceErpTradeResponsible.ID;
  7167. }
  7168. responsibleIds.Add(ceErpTradeResponsible.ID);
  7169. }
  7170. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7171. CeErpTradeResponsible.NumByTid(backNum, eid);
  7172. }
  7173. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7174. if (ceErpTradeCellExtend != null)
  7175. {
  7176. ceErpTradeCellExtend.returnVisit = 0;
  7177. ceErpTradeCellExtend.Update();
  7178. }
  7179. if (entity.HandleTime != null)
  7180. {
  7181. if (entity.AfterSaleState == 1)
  7182. {
  7183. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7184. }
  7185. else
  7186. {
  7187. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7188. }
  7189. }
  7190. else
  7191. {
  7192. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7193. entity.HandleTime = DateTime.Now;
  7194. }
  7195. bool isCompale = false;
  7196. if (entity.AfterSaleState == 5)
  7197. {
  7198. isCompale = true;
  7199. entity.AfterSaleState = 3;
  7200. }
  7201. entity.AfterSaleSupplierState = 0;
  7202. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7203. {
  7204. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7205. }
  7206. string sImgs = GetPostString("img");
  7207. entity.AfterSaleSupplierImg = sImgs;
  7208. entity.supRefundType = GetPostString("supRefundType");
  7209. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7210. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7211. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7212. entity.AfterSaleMemoType = GetPostString("MemoType");
  7213. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7214. {
  7215. //entity.AfterSaleSupplierState = 2;
  7216. }
  7217. string df = GetPostString("DeductFee");
  7218. if (df == "")
  7219. {
  7220. df = "0";
  7221. }
  7222. string rf = GetPostString("RefundFee");
  7223. if (rf == "")
  7224. {
  7225. rf = "0";
  7226. }
  7227. string pm = GetPostString("AfterSalePayment");
  7228. if (pm == "")
  7229. {
  7230. pm = "0";
  7231. }
  7232. entity.AfterSalePayment = Convert.ToDouble(pm);
  7233. entity.DeductFee = Convert.ToDouble(df);
  7234. entity.RefundFee = Convert.ToDouble(rf);
  7235. entity.UpdateTime = DateTime.Now;
  7236. entity.Update();
  7237. string toState = GetPostString("ToState");
  7238. string original = GetPostString("isOriginal");
  7239. ApiVo apiVo = new ApiVo();
  7240. apiVo.orderNumber = entity.ctid;
  7241. apiVo.actionName = "afterDesign";
  7242. apiVo.orderRemarks = entity.AfterSaleMethod;
  7243. apiVo.reasonRemarks = entity.AfterSaleReason;
  7244. apiVo.isDesign = isDesign;
  7245. apiVo.designFree = designFree;
  7246. apiVo.responsibleId = responsibleId;
  7247. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7248. if (toState == "设计师")
  7249. {
  7250. apiVo.isOriginal = Convert.ToBoolean(original);
  7251. }
  7252. designHelper.API_WorkCore(apiVo);//afterDesign
  7253. CeErpMethod methodSql = new CeErpMethod();
  7254. methodSql.con = entity.AfterSaleMethod;
  7255. methodSql.addTime = DateTime.Now;
  7256. methodSql.Create();
  7257. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7258. CeErpMethod.ExecuteNonQuery(delsql);
  7259. if (isCompale)
  7260. {
  7261. aftersale_data_change(entity.ctid);
  7262. }
  7263. returnSuccessMsg("操作成功!");
  7264. return;
  7265. }
  7266. returnErrorMsg("找不到订单记录");
  7267. }
  7268. }
  7269. public void ins_erp_toresponsible()
  7270. {
  7271. if (UrlPostParmsCheck("ctid"))
  7272. {
  7273. string eid = GetPostString("ctid");
  7274. CeErpTradeCell entity = null;
  7275. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7276. if (entity != null)
  7277. {
  7278. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7279. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7280. {
  7281. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7282. return;
  7283. }
  7284. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7285. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7286. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7287. if (entity.AfterSalePreTime == null)
  7288. {
  7289. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7290. {
  7291. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7292. }
  7293. }
  7294. entity.AfterSalePreTime = DateTime.Now;
  7295. //预完成给售后主管审核客户问题直接完成
  7296. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7297. {
  7298. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7299. {
  7300. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7301. }
  7302. }
  7303. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  7304. ceErpTradeAfterSaleExtend.Update();
  7305. entity.AfterSaleState = 2;
  7306. entity.UpdateTime = DateTime.Now;
  7307. entity.Update();
  7308. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7309. aftersale_data_change(entity.ctid);
  7310. returnSuccessMsg("操作成功!");
  7311. return;
  7312. }
  7313. returnErrorMsg("找不到订单记录");
  7314. }
  7315. }
  7316. public void cancel_erp_aftersaleanddelnew()
  7317. {
  7318. if (UrlPostParmsCheck("ctid"))
  7319. {
  7320. string eid = GetPostString("ctid");
  7321. CeErpTradeCell entity = null;
  7322. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7323. if (entity != null)
  7324. {
  7325. entity.AfterSaleState = 0;
  7326. entity.AfterSaleReason = "";
  7327. entity.AfterSaleMethod = "";
  7328. entity.AfterSaleMemo = "";
  7329. entity.AfterSaleResponsible = "";
  7330. entity.ResponsibleUserId = "";
  7331. entity.DeductFee = 0;
  7332. entity.RefundFee = 0;
  7333. entity.IsArbitrate = 0;
  7334. CeErpTradeResponsible.DelByTid(eid, -1);
  7335. entity.Update();
  7336. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7337. if (after != null)
  7338. {
  7339. if (after.OrderState < 5)
  7340. CeErpTradeCell.DelByCtid("S_" + eid);
  7341. }
  7342. returnSuccessMsg("操作成功!");
  7343. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7344. return;
  7345. }
  7346. returnErrorMsg("找不到订单记录");
  7347. }
  7348. }
  7349. public void get_erp_aftersale_pregather()
  7350. {
  7351. List<string> lw = new List<string>();
  7352. int st = GetInt("st");
  7353. string tid = GetPostString("ctid");
  7354. if (tid.Length > 0)
  7355. {
  7356. string select_tid = getTidByCtid(tid);
  7357. lw.Add(string.Format("tid='{0}'", select_tid));
  7358. }
  7359. string shopname = GetPostString("shopname");
  7360. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7361. string buyernick = GetPostString("buyer_nick");
  7362. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7363. string sellermemo = GetPostString("seller_memo");
  7364. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7365. string orderState = GetPostString("orderState");
  7366. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7367. string reason = GetPostString("reason");
  7368. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7369. string method = GetPostString("method");
  7370. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7371. string handler = GetPostString("handler");
  7372. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7373. string handledate1 = GetPostString("handledate1");
  7374. string handledate2 = GetPostString("handledate2");
  7375. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7376. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7377. string supplier = GetPostString("supplier");
  7378. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7379. string responsible = GetPostString("responsibleman");
  7380. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7381. string customer = GetPostString("customer");
  7382. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7383. string design = GetPostString("design");
  7384. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7385. string afterMemoType = GetPostString("aftermemotype");
  7386. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7387. string afterSaleMemo = GetPostString("afterSaleMemo");
  7388. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7389. string afterresult = GetPostString("afterresult");
  7390. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7391. string poscode = CurrentUser.UserPost.Post.Code;
  7392. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7393. {
  7394. string shopid = CurrentUser.User.pemShop;
  7395. lw.Add(string.Format("shopId in ({0})", shopid));
  7396. }
  7397. var mainwhere = string.Join(" and ", lw.ToArray());
  7398. string ro_json = "";
  7399. string type = GetPostString("gather_type");
  7400. int number = 0;
  7401. if (poscode == "AfterSale")
  7402. {
  7403. //处理中
  7404. if (type == "Handling")
  7405. {
  7406. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7407. DataTable dt = null;
  7408. try
  7409. {
  7410. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7411. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7412. }
  7413. catch (Exception e)
  7414. {
  7415. dt = new DataTable();
  7416. }
  7417. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7418. return;
  7419. }
  7420. if (type == "Wait")
  7421. {
  7422. //待处理
  7423. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7424. DataTable dt1 = null;
  7425. try
  7426. {
  7427. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7428. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7429. }
  7430. catch (Exception e)
  7431. {
  7432. dt1 = new DataTable();
  7433. }
  7434. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7435. return;
  7436. }
  7437. if (type == "back")
  7438. {
  7439. //打回
  7440. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7441. DataTable dt2 = null;
  7442. try
  7443. {
  7444. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7445. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7446. }
  7447. catch (Exception e)
  7448. {
  7449. dt2 = new DataTable();
  7450. }
  7451. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7452. return;
  7453. }
  7454. if (type == "preCompletion")
  7455. {
  7456. //预完成
  7457. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7458. DataTable dt3 = null;
  7459. try
  7460. {
  7461. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7462. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7463. }
  7464. catch (Exception e)
  7465. {
  7466. dt3 = new DataTable();
  7467. }
  7468. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7469. return;
  7470. }
  7471. if (type == "documentary")
  7472. {
  7473. //跟单中
  7474. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate > 2 and HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSalSend = 0 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7475. DataTable dt4 = null;
  7476. try
  7477. {
  7478. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7479. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7480. }
  7481. catch (Exception e)
  7482. {
  7483. dt4 = new DataTable();
  7484. }
  7485. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7486. return;
  7487. }
  7488. if (type == "reBack")
  7489. {
  7490. //被打回
  7491. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7492. DataTable dt1 = null;
  7493. try
  7494. {
  7495. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7496. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7497. }
  7498. catch (Exception e)
  7499. {
  7500. dt1 = new DataTable();
  7501. }
  7502. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7503. return;
  7504. }
  7505. }
  7506. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7507. {
  7508. if (type == "puBack")
  7509. {
  7510. //退回
  7511. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7512. DataTable dt = null;
  7513. try
  7514. {
  7515. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7516. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7517. }
  7518. catch (Exception e)
  7519. {
  7520. dt = new DataTable();
  7521. }
  7522. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7523. return;
  7524. }
  7525. if (type == "reBack")
  7526. {
  7527. //打回
  7528. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7529. DataTable dt1 = null;
  7530. try
  7531. {
  7532. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7533. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7534. }
  7535. catch (Exception e)
  7536. {
  7537. dt1 = new DataTable();
  7538. }
  7539. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7540. return;
  7541. }
  7542. if (type == "examEd")
  7543. {
  7544. //已审核
  7545. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7546. DataTable dt2 = null;
  7547. try
  7548. {
  7549. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7550. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7551. }
  7552. catch (Exception e)
  7553. {
  7554. dt2 = new DataTable();
  7555. }
  7556. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7557. return;
  7558. }
  7559. if (type == "waitExam")
  7560. {
  7561. //待审核
  7562. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7563. DataTable dt3 = null;
  7564. try
  7565. {
  7566. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7567. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7568. }
  7569. catch (Exception e)
  7570. {
  7571. dt3 = new DataTable();
  7572. }
  7573. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7574. return;
  7575. }
  7576. if (type == "Handling")
  7577. {
  7578. //处理中
  7579. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7580. DataTable dt4 = null;
  7581. try
  7582. {
  7583. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7584. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7585. }
  7586. catch (Exception e)
  7587. {
  7588. dt4 = new DataTable();
  7589. }
  7590. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7591. return;
  7592. }
  7593. if (type == "Wait")
  7594. {
  7595. //待处理
  7596. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7597. DataTable dt5 = null;
  7598. try
  7599. {
  7600. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7601. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7602. }
  7603. catch (Exception e)
  7604. {
  7605. dt5 = new DataTable();
  7606. }
  7607. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7608. return;
  7609. }
  7610. if (type == "documentary")
  7611. {
  7612. //跟单中
  7613. string sql6 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate > 2 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSalSend = 0 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7614. DataTable dt6 = null;
  7615. try
  7616. {
  7617. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7618. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7619. }
  7620. catch (Exception e)
  7621. {
  7622. dt6 = new DataTable();
  7623. }
  7624. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7625. return;
  7626. }
  7627. }
  7628. returnSuccess(ro_json);
  7629. }
  7630. public void end_erp_aftersale()
  7631. {
  7632. if (UrlPostParmsCheck("ctid"))
  7633. {
  7634. string eid = GetPostString("ctid");
  7635. CeErpTradeCell entity = null;
  7636. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7637. if (entity != null)
  7638. {
  7639. string stype = GetPostString("stype");
  7640. string typeStr = stype;
  7641. entity.AfterSaleState = 4;
  7642. entity.FinishAfterSaleTime = DateTime.Now;
  7643. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7644. entity.Update();
  7645. ApiVo apiVo = new ApiVo();
  7646. apiVo.orderNumber = entity.ctid;
  7647. apiVo.actionName = "afterOver";
  7648. designHelper.API_WorkCore(apiVo); //afterOver
  7649. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7650. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7651. CeErpSukuraData.createInfo(entity.ctid, 8);
  7652. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7653. returnSuccessMsg("操作成功!");
  7654. return;
  7655. }
  7656. returnErrorMsg("找不到订单记录");
  7657. }
  7658. }
  7659. public void ins_erp_finishaftersale()
  7660. {
  7661. if (UrlPostParmsCheck("id"))
  7662. {
  7663. string eid = GetPostString("id");
  7664. CeErpTradeResponsible entity = null;
  7665. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7666. if (entity != null)
  7667. {
  7668. entity.VerifyState = 1;
  7669. entity.VerifyTime = DateTime.Now;
  7670. entity.Update();
  7671. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7672. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7673. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7674. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7675. if (dt.Rows.Count <= 0)
  7676. {
  7677. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7678. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7679. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7680. CeErpSukuraData.createInfo(entity.tid, 8);
  7681. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7682. {
  7683. CeErpDesignerBill.Del(entity.tid);
  7684. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7685. }
  7686. }
  7687. returnSuccessMsg("操作成功!");
  7688. return;
  7689. }
  7690. returnErrorMsg("找不到订单记录");
  7691. }
  7692. }
  7693. public void upd_erp_arbitrateaftersale()
  7694. {
  7695. if (UrlPostParmsCheck("id"))
  7696. {
  7697. string eid = GetPostString("id");
  7698. CeErpTradeResponsible entity = null;
  7699. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7700. if (entity != null)
  7701. {
  7702. entity.IsArbitrate = 1;
  7703. entity.ArbitradeMemo = GetPostString("reason");
  7704. entity.VerifyState = 2;
  7705. entity.Update();
  7706. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7707. if (tradecell != null)
  7708. {
  7709. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7710. tradecell.IsArbitrate = 1;
  7711. tradecell.Update();
  7712. }
  7713. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7714. returnSuccessMsg("操作成功!");
  7715. return;
  7716. }
  7717. returnErrorMsg("找不到订单记录");
  7718. }
  7719. }
  7720. public void upd_erp_backaftersale()
  7721. {
  7722. if (UrlPostParmsCheck("tid"))
  7723. {
  7724. string eid = GetPostString("tid");
  7725. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7726. int backNum = 0;
  7727. if (number != null)
  7728. {
  7729. backNum = number.BackNum;
  7730. }
  7731. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7732. CeErpTradeCell entity = null;
  7733. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7734. if (entity != null)
  7735. {
  7736. entity.AfterSaleBackReason = GetPostString("backreason");
  7737. entity.AfterSaleState = 1;
  7738. entity.AfterSaleSupplierState = 0;
  7739. entity.UpdateTime = DateTime.Now;
  7740. entity.Update();
  7741. returnSuccessMsg("操作成功!");
  7742. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7743. return;
  7744. }
  7745. returnErrorMsg("找不到订单记录");
  7746. }
  7747. }
  7748. public void get_erp_supplieraftersalelist()
  7749. {
  7750. DataStruct dStruct = GetPostStruct();
  7751. List<string> lw = new List<string>();
  7752. string tid = GetPostString("ctid");
  7753. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7754. string shopname = GetPostString("shopname");
  7755. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7756. string buyernick = GetPostString("buyer_nick");
  7757. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7758. string sellermemo = GetPostString("seller_memo");
  7759. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7760. string orderState = GetPostString("orderState");
  7761. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7762. string afterState = GetPostString("afterstate");
  7763. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7764. string date1 = GetPostString("date1");
  7765. string date2 = GetPostString("date2");
  7766. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7767. if (dw.Length > 0) lw.Add(dw);
  7768. string price1 = GetPostString("price1");
  7769. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7770. string price2 = GetPostString("price2");
  7771. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7772. string reason = GetPostString("reason");
  7773. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7774. string method = GetPostString("method");
  7775. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7776. string handledate1 = GetPostString("handledate1");
  7777. string handledate2 = GetPostString("handledate2");
  7778. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7779. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7780. string handler = GetPostString("handler");
  7781. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7782. string afterdate1 = GetPostString("afterdate1");
  7783. string afterdate2 = GetPostString("afterdate2");
  7784. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7785. if (afterDate.Length > 0) lw.Add(afterDate);
  7786. string customer = GetPostString("customer");
  7787. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7788. string design = GetPostString("design");
  7789. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7790. string afterMemoType = GetPostString("aftermemotype");
  7791. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7792. string vstate = GetPostString("vstate");
  7793. if (vstate.Length > 0)
  7794. {
  7795. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7796. }
  7797. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7798. string supplier = GetPostString("supplier");
  7799. int supid = commonHelper.getSupplierIDByName(supplier);
  7800. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7801. string posCode = CurrentUser.UserPost.Post.Code;
  7802. if (posCode == "Supplier")
  7803. {
  7804. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7805. }
  7806. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7807. {
  7808. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7809. }
  7810. else
  7811. {
  7812. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7813. }
  7814. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7815. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7816. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7817. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7818. writeGridDataTableJson(dStruct.TotalCount, dt);
  7819. }
  7820. public void upd_erp_supverifyaftersale()
  7821. {
  7822. if (UrlPostParmsCheck("id"))
  7823. {
  7824. string id = GetPostString("id");
  7825. int st = GetPostInt("afterstate");
  7826. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7827. CeErpTradeCell entity = null;
  7828. if (ceErpTradeResponsible != null)
  7829. {
  7830. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7831. }
  7832. string afmemo = GetPostString("supmemo");
  7833. string image = GetPostString("image");
  7834. if (entity != null)
  7835. {
  7836. entity.AfterSaleSupplierState = st;
  7837. entity.AfterSaleSupplierMemo = afmemo;
  7838. if (st == 1)
  7839. {
  7840. ceErpTradeResponsible.VerifyState = 1;
  7841. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7842. ceErpTradeResponsible.Update();
  7843. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7844. if (isAll)
  7845. {
  7846. entity.AfterSaleState = 4;
  7847. entity.FinishAfterSaleTime = DateTime.Now;
  7848. }
  7849. }
  7850. else
  7851. {
  7852. CeErpTradeResponsible.dateByTid(entity.ctid);
  7853. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7854. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7855. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7856. if (num <= 1)
  7857. {
  7858. entity.AfterSaleState = 1;
  7859. }
  7860. else
  7861. {
  7862. entity.AfterSaleState = 5;
  7863. }
  7864. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7865. if (ceErpTradeAfterSaleExtend != null)
  7866. {
  7867. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7868. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7869. ceErpTradeAfterSaleExtend.Update();
  7870. }
  7871. else
  7872. {
  7873. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7874. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7875. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7876. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7877. ceErpTradeAfterSaleExtend.Create();
  7878. }
  7879. }
  7880. if (entity.AfterSaleState == 4)
  7881. {
  7882. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7883. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7884. {
  7885. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7886. }
  7887. ApiVo apiVo = new ApiVo();
  7888. apiVo.orderNumber = entity.ctid;
  7889. apiVo.actionName = "afterOver";
  7890. designHelper.API_WorkCore(apiVo); //afterOver
  7891. }
  7892. entity.UpdateTime = DateTime.Now;
  7893. entity.Update();
  7894. returnSuccessMsg("操作成功!");
  7895. CeErpSukuraData.createInfo(entity.ctid, 8);
  7896. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7897. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7898. return;
  7899. }
  7900. returnErrorMsg("找不到订单记录");
  7901. }
  7902. }
  7903. public void upd_erp_masteraftersale()
  7904. {
  7905. if (UrlPostParmsCheck("id"))
  7906. {
  7907. string id = GetPostString("id");
  7908. int st = GetPostInt("afterstate");
  7909. string afmemo = GetPostString("supmemo");
  7910. string image = GetPostString("image");
  7911. string textResult = GetPostString("textResult");
  7912. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7913. if (ceErpTradeResponsible != null)
  7914. {
  7915. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7916. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7917. ceErpTradeResponsible.Update();
  7918. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7919. if (entity != null)
  7920. {
  7921. entity.AfterSaleSupplierState = st;
  7922. entity.AfterSaleSupplierMemo = afmemo;
  7923. if (st == 1)
  7924. {
  7925. }
  7926. else
  7927. {
  7928. CeErpTradeResponsible.dateByTid(entity.ctid);
  7929. //退回到售后
  7930. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7931. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7932. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7933. if (num <= 1)
  7934. {
  7935. entity.AfterSaleState = 1;
  7936. }
  7937. else
  7938. {
  7939. entity.AfterSaleState = 5;
  7940. }
  7941. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7942. if (ceErpTradeAfterSaleExtend != null)
  7943. {
  7944. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7945. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7946. ceErpTradeAfterSaleExtend.Update();
  7947. }
  7948. else
  7949. {
  7950. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7951. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7952. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7953. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7954. ceErpTradeAfterSaleExtend.Create();
  7955. }
  7956. }
  7957. entity.UpdateTime = DateTime.Now;
  7958. entity.Update();
  7959. returnSuccessMsg("操作成功!");
  7960. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7961. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7962. return;
  7963. }
  7964. }
  7965. returnErrorMsg("找不到订单记录");
  7966. }
  7967. }
  7968. public void upd_erp_personaftersale()
  7969. {
  7970. if (UrlPostParmsCheck("id"))
  7971. {
  7972. //林小连
  7973. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7974. {
  7975. upd_erp_masteraftersale();
  7976. return;
  7977. }
  7978. string id = GetPostString("id");
  7979. int st = GetPostInt("afterstate");
  7980. string afmemo = GetPostString("supmemo");
  7981. string image = GetPostString("image");
  7982. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7983. if (ceErpTradeResponsible != null)
  7984. {
  7985. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7986. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7987. ceErpTradeResponsible.Update();
  7988. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7989. if (entity != null)
  7990. {
  7991. entity.AfterSaleSupplierMemo = afmemo;
  7992. entity.AfterSaleSupplierState = st;
  7993. if (st == 1)
  7994. {
  7995. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7996. if (isAll)
  7997. {
  7998. entity.AfterSaleState = 4;
  7999. entity.FinishAfterSaleTime = DateTime.Now;
  8000. }
  8001. }
  8002. else
  8003. {
  8004. CeErpTradeResponsible.dateByTid(entity.ctid);
  8005. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  8006. if (ceErpTradeAfterSaleExtend != null)
  8007. {
  8008. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8009. ceErpTradeAfterSaleExtend.Update();
  8010. }
  8011. else
  8012. {
  8013. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  8014. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  8015. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8016. ceErpTradeAfterSaleExtend.Create();
  8017. }
  8018. //退回到主管
  8019. //entity.AfterSaleState = 2;
  8020. }
  8021. if (entity.AfterSaleState == 4)
  8022. {
  8023. ApiVo apiVo = new ApiVo();
  8024. apiVo.orderNumber = entity.ctid;
  8025. apiVo.actionName = "afterOver";
  8026. designHelper.API_WorkCore(apiVo); //afterOver
  8027. }
  8028. entity.UpdateTime = DateTime.Now;
  8029. entity.Update();
  8030. returnSuccessMsg("操作成功!");
  8031. CeErpSukuraData.createInfo(entity.ctid, 8);
  8032. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  8033. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  8034. return;
  8035. }
  8036. }
  8037. returnErrorMsg("找不到订单记录");
  8038. }
  8039. }
  8040. public void set_erp_supplierrefundtag()
  8041. {
  8042. if (UrlPostParmsCheck("ctid"))
  8043. {
  8044. string eid = GetPostString("ctid");
  8045. CeErpTradeCell entity = null;
  8046. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8047. if (entity != null)
  8048. {
  8049. entity.IsSupplierRefund = GetPostInt("tag");
  8050. entity.Update();
  8051. returnSuccessMsg("操作成功!");
  8052. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  8053. return;
  8054. }
  8055. returnErrorMsg("找不到订单记录");
  8056. }
  8057. }
  8058. public void get_erp_refundlist()
  8059. {
  8060. DataStruct dStruct = GetPostStruct();
  8061. List<string> lw = new List<string>();
  8062. string tid = GetPostString("tid");
  8063. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8064. //string rid = GetPostString("refund_id");
  8065. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  8066. string shopname = GetPostString("shopname");
  8067. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8068. string buyernick = GetPostString("buyer_nick");
  8069. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8070. string customer = GetPostString("customer");
  8071. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8072. string design = GetPostString("design");
  8073. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8074. string sellermemo = GetPostString("seller_memo");
  8075. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8076. //string date1 = GetPostString("date1");
  8077. //string date2 = GetPostString("date2");
  8078. //string dateType = GetPostString("dateType");
  8079. //if (dateType.Length > 0)
  8080. //{
  8081. // if (dateType == "1001") dateType = "0";
  8082. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  8083. // if (searchDT.Count == 2)
  8084. // {
  8085. // date1 = searchDT[0].ToString();
  8086. // date2 = searchDT[1].ToString();
  8087. // }
  8088. //}
  8089. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8090. //if (dw.Length > 0) lw.Add(dw);
  8091. string redate1 = GetPostString("refunddate1");
  8092. string redate2 = GetPostString("refunddate2");
  8093. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8094. if (dwdate.Length > 0) lw.Add(dwdate);
  8095. string price1 = GetPostString("price1");
  8096. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8097. string price2 = GetPostString("price2");
  8098. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8099. string ispartrefund = GetPostString("ispartrefund");
  8100. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8101. string refundState = GetPostString("refundvstate");
  8102. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  8103. int st = GetInt("st");
  8104. if (st == 2) //待确认列表中,把state=3已确认的也显示
  8105. {
  8106. string responsible = GetPostString("responsibleman");
  8107. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8108. lw.Add(string.Format("RefundState>={0}", st));
  8109. string code = CurrentUser.UserPost.Post.Code;
  8110. if (code == "CustomerService")
  8111. {
  8112. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  8113. }
  8114. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  8115. {
  8116. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  8117. }
  8118. else if (code == "Place" || code == "PlaceMr")
  8119. {
  8120. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8121. }
  8122. dStruct.Order = "RefundState asc,created desc";
  8123. }
  8124. else if (st == 10)
  8125. {
  8126. string responsible = GetPostString("responsibleman");
  8127. if (responsible == "空白")
  8128. {
  8129. lw.Add(string.Format("ResponsibleUserName = ''"));
  8130. }
  8131. else if (responsible.Length > 0)
  8132. {
  8133. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8134. }
  8135. lw.Add(string.Format("RefundState>=0"));
  8136. dStruct.Order = "created desc";
  8137. }
  8138. else
  8139. {
  8140. string responsible = GetPostString("responsibleman");
  8141. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8142. lw.Add(string.Format("RefundState={0}", st));
  8143. dStruct.Order = "created desc";
  8144. }
  8145. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8146. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8147. dt.Columns.Add("refund_fees");
  8148. foreach (DataRow dr in dt.Rows)
  8149. {
  8150. String status = dr["status"].ToString();
  8151. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8152. {
  8153. dr["refund_fees"] = dr["refund_fee"];
  8154. }
  8155. else
  8156. {
  8157. dr["refund_fees"] = "0.0";
  8158. }
  8159. }
  8160. writeGridDataTableJson(dStruct.TotalCount, dt);
  8161. }
  8162. public void get_erp_refunddesignlist()
  8163. {
  8164. DataStruct dStruct = GetPostStruct();
  8165. List<string> lw = new List<string>();
  8166. string tid = GetPostString("tid");
  8167. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8168. string shopname = GetPostString("shopname");
  8169. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8170. string buyernick = GetPostString("buyer_nick");
  8171. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8172. string customer = GetPostString("customer");
  8173. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8174. string design = GetPostString("design");
  8175. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8176. string sellermemo = GetPostString("seller_memo");
  8177. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8178. string redate1 = GetPostString("refunddate1");
  8179. string redate2 = GetPostString("refunddate2");
  8180. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8181. if (dwdate.Length > 0) lw.Add(dwdate);
  8182. string price1 = GetPostString("price1");
  8183. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8184. string price2 = GetPostString("price2");
  8185. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8186. string ispartrefund = GetPostString("ispartrefund");
  8187. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8188. string designerorg = GetPostString("designerorg");
  8189. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8190. string refundState = GetPostString("refundState");
  8191. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8192. int myOrgid = CurrentUser.UserPost.OrgID;
  8193. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8194. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8195. {
  8196. if (CurrentUser.User.TeamIds.Length > 0)
  8197. {
  8198. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8199. }
  8200. else
  8201. {
  8202. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8203. }
  8204. }
  8205. else if ("SysAdmin".Equals(myOrgCode))
  8206. {
  8207. }
  8208. else
  8209. {
  8210. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8211. {
  8212. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8213. }
  8214. else
  8215. {
  8216. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8217. }
  8218. }
  8219. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8220. dStruct.Order = "created desc";
  8221. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8222. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8223. dt.Columns.Add("refund_fees");
  8224. foreach (DataRow dr in dt.Rows)
  8225. {
  8226. String status = dr["status"].ToString();
  8227. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8228. {
  8229. dr["refund_fees"] = dr["refund_fee"];
  8230. }
  8231. else
  8232. {
  8233. dr["refund_fees"] = "0.0";
  8234. }
  8235. }
  8236. writeGridDataTableJson(dStruct.TotalCount, dt);
  8237. }
  8238. public void handle_erp_refundtag()
  8239. {
  8240. if (UrlPostParmsCheck("refund_id"))
  8241. {
  8242. string eid = GetPostString("refund_id");
  8243. string respMan = GetPostString("ResponsibleName");
  8244. if (respMan.Length <= 0)
  8245. {
  8246. returnErrorMsg("责任人不能为空");
  8247. return;
  8248. }
  8249. CeErpTradeRefund entity = null;
  8250. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8251. if (entity != null)
  8252. {
  8253. entity.ResponsibleUserName = respMan;
  8254. string userid = GetPostString("ResponsibleUserId");
  8255. if (userid.Length > 0)
  8256. {
  8257. entity.ResponsibleUserId = userid;
  8258. }
  8259. entity.Memo = GetPostString("Memo");
  8260. if (respMan.IndexOf("客服") != -1 ||
  8261. respMan.IndexOf("设计师") != -1 ||
  8262. respMan.IndexOf("下单员") != -1)
  8263. {
  8264. entity.RefundState = 2;
  8265. }
  8266. else
  8267. {
  8268. entity.RefundState = 3;
  8269. }
  8270. entity.modified = DateTime.Now;
  8271. entity.Update();
  8272. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8273. returnSuccessMsg("操作成功!");
  8274. return;
  8275. }
  8276. returnErrorMsg("找不到订单记录");
  8277. }
  8278. }
  8279. public void handle_erp_designrefundtag()
  8280. {
  8281. if (UrlPostParmsCheck("refund_id"))
  8282. {
  8283. string eid = GetPostString("refund_id");
  8284. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8285. if (ceErpTradeCellExtend == null)
  8286. {
  8287. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8288. ceErpTradeCellExtend.ctid = eid;
  8289. }
  8290. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8291. if (ceErpTradeCellExtend.ID > 0)
  8292. {
  8293. ceErpTradeCellExtend.Update();
  8294. }
  8295. else
  8296. {
  8297. ceErpTradeCellExtend.Create();
  8298. }
  8299. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8300. returnSuccessMsg("操作成功!");
  8301. return;
  8302. }
  8303. returnErrorMsg("找不到订单记录");
  8304. }
  8305. public void upd_erp_refundverify()
  8306. {
  8307. if (UrlPostParmsCheck("refund_id"))
  8308. {
  8309. string eid = GetPostString("refund_id");
  8310. CeErpTradeRefund entity = null;
  8311. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8312. if (entity != null)
  8313. {
  8314. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8315. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8316. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8317. {
  8318. entity.RefundState = 2;
  8319. }
  8320. else
  8321. {
  8322. entity.RefundState = 3;
  8323. }
  8324. entity.Update();
  8325. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8326. returnSuccessMsg("操作成功!");
  8327. return;
  8328. }
  8329. returnErrorMsg("找不到订单记录");
  8330. }
  8331. }
  8332. public void upd_erp_refundapprove()
  8333. {
  8334. if (UrlPostParmsCheck("refund_id"))
  8335. {
  8336. string eid = GetPostString("refund_id");
  8337. CeErpTradeRefund entity = null;
  8338. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8339. if (entity != null)
  8340. {
  8341. int apr = GetPostInt("approve");
  8342. if (apr == 0)
  8343. {
  8344. entity.RefundState = 1;
  8345. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8346. }
  8347. else if (apr == 1)
  8348. {
  8349. entity.RefundState = 3;
  8350. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8351. }
  8352. entity.modified = DateTime.Now;
  8353. entity.Update();
  8354. returnSuccessMsg("操作成功!");
  8355. return;
  8356. }
  8357. returnErrorMsg("找不到订单记录");
  8358. }
  8359. }
  8360. public void get_erp_billlist()
  8361. {
  8362. DataStruct dStruct = GetPostStruct();
  8363. List<string> lw = new List<string>();
  8364. string title = GetPostString("title");
  8365. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8366. string tid = GetPostString("tid");
  8367. string tids = GetPostString("tids");
  8368. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8369. if (tids.Length > 0)
  8370. {
  8371. tids = "'" + tids + "'";
  8372. tids = tids.Replace(",", "','");
  8373. lw.Add(string.Format("tid in ({0})", tids));
  8374. }
  8375. string shopname = GetPostString("shopname");
  8376. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8377. string buyernick = GetPostString("buyer_nick");
  8378. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8379. string customer = GetPostString("customer");
  8380. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8381. string date1 = GetPostString("date1");
  8382. string date2 = GetPostString("date2");
  8383. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8384. if (dw.Length > 0) lw.Add(dw);
  8385. string price1 = GetPostString("price1");
  8386. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8387. string price2 = GetPostString("price2");
  8388. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8389. string returndate1 = GetPostString("returndate1");
  8390. string returndate2 = GetPostString("returndate2");
  8391. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8392. if (dw1.Length > 0) lw.Add(dw1);
  8393. string billtype = GetPostString("billtype");
  8394. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8395. string billstate = GetPostString("billstate");
  8396. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8397. string usershop = CurrentUser.User.pemShop;
  8398. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8399. dStruct.Order = "createTime desc";
  8400. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8401. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8402. //foreach (DataRow dr in dt.Rows)
  8403. //{
  8404. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8405. //}
  8406. writeGridDataTableJson(dStruct.TotalCount, dt);
  8407. }
  8408. public void modify_erp_billinfo()
  8409. {
  8410. if (UrlPostParmsCheck("ID"))
  8411. {
  8412. string eid = GetPostString("ID");
  8413. CeErpBill bill_entity = null;
  8414. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8415. if (bill_entity != null)
  8416. {
  8417. bill_entity.tid = GetPostString("tid");
  8418. bill_entity.title = GetPostString("title");
  8419. bill_entity.tax = GetPostString("tax");
  8420. bill_entity.bank = GetPostString("bank");
  8421. bill_entity.bankac = GetPostString("bankac");
  8422. bill_entity.address = GetPostString("address");
  8423. bill_entity.phone = GetPostString("phone");
  8424. bill_entity.price = GetPostString("price");
  8425. bill_entity.productId = GetPostInt("ProductName");
  8426. bill_entity.num = GetPostInt("num");
  8427. bill_entity.unit = GetPostString("unit");
  8428. bill_entity.type = GetPostString("type");
  8429. bill_entity.sendType = GetPostString("SendType");
  8430. bill_entity.email = GetPostString("email");
  8431. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8432. bill_entity.shopName = GetPostString("ShopName");
  8433. bill_entity.applymemo = GetPostString("applymemo");
  8434. bill_entity.modifyTime = DateTime.Now;
  8435. bill_entity.createTime = DateTime.Now;
  8436. bill_entity.state = 0;
  8437. bill_entity.Update();
  8438. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8439. returnSuccessMsg("发票修改成功!");
  8440. return;
  8441. }
  8442. returnErrorMsg("找不到对应记录");
  8443. }
  8444. }
  8445. public void set_erp_invoicing()
  8446. {
  8447. if (UrlPostParmsCheck("id"))
  8448. {
  8449. try
  8450. {
  8451. string eid = GetPostString("id");
  8452. CeErpBill bill_entity = null;
  8453. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8454. if (bill_entity != null)
  8455. {
  8456. int ComId = GetPostInt("ComId");
  8457. //string memo = GetPostString("Memo");
  8458. int allInfo = GetPostInt("allinfo");
  8459. string clert = CurrentUser.User.Name;
  8460. //string detailValue = GetPostString("detailvalue");
  8461. string billId = bill_entity.billOrderId;
  8462. string[] billIdList = billId.Split(',');
  8463. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8464. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8465. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8466. {
  8467. billCount += 1;
  8468. }
  8469. if (billId.Length <= 0 || billIdList.Length != billCount)
  8470. {
  8471. bill_entity.billOrderId = "";
  8472. string prebill = "ltb";
  8473. for (int idx = 1; idx <= billCount; idx++)
  8474. {
  8475. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8476. string billoid = prebill + idx + dtstr;
  8477. bill_entity.billOrderId += billoid;
  8478. if (idx < billCount)
  8479. {
  8480. bill_entity.billOrderId += ",";
  8481. }
  8482. }
  8483. }
  8484. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8485. if (bill_entity.state == 5)
  8486. {
  8487. string errMsg = bill_entity.failerror;
  8488. string[] errlist = errMsg.Split('|');
  8489. string[] errTags = new string[errlist.Length];
  8490. for (int itag = 0; itag < errlist.Length; itag++)
  8491. {
  8492. if (errlist[itag].Length <= 0) continue;
  8493. errTags[itag] = errlist[itag].Split('&')[0];
  8494. }
  8495. for (int iii = 0; iii < errTags.Length; iii++)
  8496. {
  8497. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8498. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8499. if (billOrderList.Length >= erroBillOrderTag)
  8500. {
  8501. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8502. if (needModifyBillId.Length <= 19)
  8503. {
  8504. needModifyBillId = needModifyBillId + "1";
  8505. }
  8506. else
  8507. {
  8508. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8509. last = last + 1;
  8510. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8511. }
  8512. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8513. }
  8514. }
  8515. }
  8516. bool isHaveBillSucces = false;
  8517. string totalRes = "";
  8518. bill_entity.failerror = "";
  8519. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8520. {
  8521. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8522. totalRes += res;
  8523. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8524. {
  8525. isHaveBillSucces = true;
  8526. bill_entity.comId = ComId;
  8527. bill_entity.state = 1;
  8528. bill_entity.executeTime = DateTime.Now;
  8529. bill_entity.executeUser = clert;
  8530. }
  8531. else
  8532. {
  8533. bill_entity.state = 5;
  8534. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8535. }
  8536. }
  8537. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8538. bill_entity.Update();
  8539. if (isHaveBillSucces)
  8540. {
  8541. StringBuilder sql = new StringBuilder();
  8542. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8543. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8544. }
  8545. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8546. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8547. {
  8548. returnErrorMsg("开票失败");
  8549. }
  8550. else
  8551. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8552. return;
  8553. }
  8554. returnErrorMsg("找不到对应记录");
  8555. }
  8556. catch (Exception ex)
  8557. {
  8558. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8559. returnErrorMsg("操作失败");
  8560. }
  8561. }
  8562. }
  8563. public void get_erp_invoicing_back()
  8564. {
  8565. if (UrlPostParmsCheck("id"))
  8566. {
  8567. try
  8568. {
  8569. string id = GetPostString("id");
  8570. CeErpBill entiy = CeErpBill.Get(id);
  8571. if (entiy != null)
  8572. {
  8573. if (entiy.state == 0)
  8574. {
  8575. returnErrorMsg("发票还未开具");
  8576. return;
  8577. }
  8578. string[] billOrderList = entiy.billOrderId.Split(',');
  8579. int iTag = 0;
  8580. entiy.fplsh = "";
  8581. entiy.fpdm = "";
  8582. entiy.fphm = "";
  8583. foreach (string billOrderId in billOrderList)
  8584. {
  8585. iTag++;
  8586. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8587. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8588. {
  8589. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8590. try
  8591. {
  8592. Invoicing_get_response_Obj iObj = null;
  8593. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8594. if (iObj != null)
  8595. {
  8596. entiy.state = 2;
  8597. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8598. entiy.fpdm += iObj.list[0].c_fpdm;
  8599. entiy.fphm += iObj.list[0].c_fphm;
  8600. if (iTag < billOrderList.Length)
  8601. {
  8602. entiy.fplsh += ",";
  8603. entiy.fpdm += ",";
  8604. entiy.fphm += ",";
  8605. }
  8606. entiy.Update();
  8607. }
  8608. StringBuilder sql = new StringBuilder();
  8609. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8610. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8611. returnSuccessMsg("开票成功");
  8612. }
  8613. catch (Exception ex)
  8614. {
  8615. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8616. }
  8617. return;
  8618. }
  8619. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8620. {
  8621. var res_obj = new
  8622. {
  8623. data = "开票中"
  8624. };
  8625. string ro_json = JsonConvert.SerializeObject(res_obj);
  8626. returnSuccess(ro_json);
  8627. return;
  8628. }
  8629. else
  8630. {
  8631. int eidx = res.IndexOf("c_resultmsg");
  8632. int lidx = res.IndexOf("c_status");
  8633. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8634. entiy.state = 5;
  8635. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8636. entiy.Update();
  8637. returnErrorMsg("开票失败");
  8638. return;
  8639. }
  8640. }
  8641. }
  8642. }
  8643. catch (Exception ex)
  8644. {
  8645. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8646. }
  8647. return;
  8648. }
  8649. }
  8650. public void get_erp_invoicing()
  8651. {
  8652. if (UrlPostParmsCheck("id"))
  8653. {
  8654. try
  8655. {
  8656. string id = GetPostString("id");
  8657. CeErpBill entiy = CeErpBill.Get(id);
  8658. if (entiy != null)
  8659. {
  8660. if (entiy.state == 0)
  8661. {
  8662. returnErrorMsg("发票还未开具");
  8663. return;
  8664. }
  8665. if (entiy.sendType == "纸质发票")
  8666. {
  8667. if (entiy.img.Length <= 0)
  8668. {
  8669. returnErrorMsg("查无纸质发票");
  8670. return;
  8671. }
  8672. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8673. returnSuccess(returnres);
  8674. return;
  8675. }
  8676. string[] billOrderList = entiy.billOrderId.Split(',');
  8677. int iTag = 0;
  8678. string fpUrl = "";
  8679. entiy.fplsh = "";
  8680. entiy.fpdm = "";
  8681. entiy.fphm = "";
  8682. foreach (string billOrderId in billOrderList)
  8683. {
  8684. iTag++;
  8685. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8686. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8687. {
  8688. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8689. Invoicing_get_response_Obj iObj = null;
  8690. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8691. if (iObj != null)
  8692. {
  8693. //entiy.state = 2;
  8694. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8695. entiy.fpdm += iObj.list[0].c_fpdm;
  8696. entiy.fphm += iObj.list[0].c_fphm;
  8697. if (iTag < billOrderList.Length)
  8698. {
  8699. entiy.fplsh += ",";
  8700. entiy.fpdm += ",";
  8701. entiy.fphm += ",";
  8702. }
  8703. entiy.Update();
  8704. fpUrl += iObj.list[0].c_url + ",";
  8705. }
  8706. //returnSuccess(res);
  8707. StringBuilder sql = new StringBuilder();
  8708. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8709. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8710. }
  8711. else
  8712. {
  8713. int eidx = res.IndexOf("c_resultmsg");
  8714. //int lidx = res.IndexOf("c_status");
  8715. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8716. //开票失败
  8717. entiy.state = 5;
  8718. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8719. entiy.Update();
  8720. returnErrorMsg("开票失败");
  8721. return;
  8722. }
  8723. }
  8724. var returnObj = new
  8725. {
  8726. data = fpUrl
  8727. };
  8728. string ro_json = JsonConvert.SerializeObject(returnObj);
  8729. returnSuccess(ro_json);
  8730. }
  8731. }
  8732. catch (Exception ex)
  8733. {
  8734. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8735. }
  8736. return;
  8737. }
  8738. }
  8739. public void save_erp_billimg()
  8740. {
  8741. if (UrlPostParmsCheck("id"))
  8742. {
  8743. string eid = GetPostString("id");
  8744. CeErpBill bill_entity = null;
  8745. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8746. if (bill_entity != null)
  8747. {
  8748. bill_entity.img = GetPostString("img");
  8749. bill_entity.executeTime = DateTime.Now;
  8750. bill_entity.state = 2;
  8751. bill_entity.Update();
  8752. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8753. returnSuccessMsg("保存成功");
  8754. }
  8755. return;
  8756. }
  8757. }
  8758. public void upd_erp_billreturnback()
  8759. {
  8760. if (UrlPostParmsCheck("id"))
  8761. {
  8762. int eid = GetPostInt("id");
  8763. CeErpBill bill_entity = null;
  8764. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8765. if (bill_entity != null)
  8766. {
  8767. bill_entity.state = 3;
  8768. bill_entity.returnReason = GetPostString("reason");
  8769. bill_entity.Update();
  8770. returnSuccessMsg("驳回成功!");
  8771. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8772. }
  8773. return;
  8774. }
  8775. }
  8776. public void cancel_erp_bill()
  8777. {
  8778. if (UrlPostParmsCheck("id"))
  8779. {
  8780. int eid = GetPostInt("id");
  8781. int detailValue = GetPostInt("detailvalue");
  8782. CeErpBill bill_entity = null;
  8783. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8784. string cres = "";
  8785. string gres = "";
  8786. if (bill_entity != null)
  8787. {
  8788. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8789. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8790. {
  8791. int iTag = 0;
  8792. bill_entity.fplsh = "";
  8793. bill_entity.fpdm = "";
  8794. bill_entity.fphm = "";
  8795. foreach (string billOrderId in billOrderList)
  8796. {
  8797. iTag++;
  8798. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8799. if (gres.IndexOf("success") != -1)
  8800. {
  8801. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8802. Invoicing_get_response_Obj iObj = null;
  8803. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8804. if (iObj != null)
  8805. {
  8806. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8807. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8808. bill_entity.fphm += iObj.list[0].c_fphm;
  8809. if (iTag < billOrderList.Length)
  8810. {
  8811. bill_entity.fplsh += ",";
  8812. bill_entity.fpdm += ",";
  8813. bill_entity.fphm += ",";
  8814. }
  8815. bill_entity.Update();
  8816. }
  8817. }
  8818. else
  8819. {
  8820. returnErrorMsg(gres);
  8821. return;
  8822. }
  8823. }
  8824. }
  8825. if (bill_entity.sendType == "纸质发票")
  8826. {
  8827. //作废
  8828. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8829. //if (DateTime.Now.Month == extime.Month)
  8830. //{
  8831. //cres = taobaoHelper.cancel_invoicing(eid);
  8832. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8833. //{
  8834. bill_entity.state = 4;//已作废
  8835. bill_entity.Update();
  8836. returnSuccessMsg("发票已作废");
  8837. return;
  8838. //}
  8839. //else
  8840. //{
  8841. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8842. // bill_entity.Update();
  8843. // returnErrorMsg(cres);
  8844. // return;
  8845. //}
  8846. //}
  8847. //else
  8848. //{
  8849. // returnErrorMsg("纸质发票只能作废本月的发票");
  8850. // return;
  8851. //}
  8852. }
  8853. //红冲
  8854. int redTag = 0;
  8855. string[] fpdmList = bill_entity.fpdm.Split(',');
  8856. string[] fphmList = bill_entity.fphm.Split(',');
  8857. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8858. {
  8859. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8860. return;
  8861. }
  8862. foreach (string billOrderId in billOrderList)
  8863. {
  8864. redTag++;
  8865. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8866. cres += onecres;
  8867. cres += ",";
  8868. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8869. {
  8870. bill_entity.state = 4;//已作废
  8871. //bill_entity.Update();
  8872. //returnSuccessMsg("发票已红冲");
  8873. }
  8874. else if (onecres.IndexOf("重复冲红") != -1)
  8875. {
  8876. bill_entity.state = 4;//已作废
  8877. //bill_entity.Update();
  8878. //returnSuccessMsg("发票已红冲");
  8879. }
  8880. else
  8881. {
  8882. string errmsg = commonHelper.KeepChinese(onecres);
  8883. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8884. }
  8885. }
  8886. bill_entity.Update();
  8887. if (cres.IndexOf("失败") != -1)
  8888. returnErrorMsg("红冲失败");
  8889. else
  8890. returnSuccessMsg("发票已红冲");
  8891. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8892. return;
  8893. }
  8894. return;
  8895. }
  8896. }
  8897. public void del_erp_billorder()
  8898. {
  8899. if (UrlPostParmsCheck("id"))
  8900. {
  8901. string eid = GetPostString("id");
  8902. CeErpBill.Del(eid);
  8903. CeErpBill bill = CeErpBill.Get(eid);
  8904. if (bill != null)
  8905. {
  8906. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8907. }
  8908. returnSuccessMsg("删除成功");
  8909. }
  8910. }
  8911. public void finish_erp_bill()
  8912. {
  8913. if (UrlPostParmsCheck("ids"))
  8914. {
  8915. string eids = GetPostString("ids");
  8916. string[] list = eids.Split(',');
  8917. foreach (string eid in list)
  8918. {
  8919. CeErpBill bill = CeErpBill.Get(eid);
  8920. if (bill != null)
  8921. {
  8922. bill.state = 2;
  8923. bill.Update();
  8924. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8925. }
  8926. }
  8927. returnSuccessMsg("操作成功");
  8928. }
  8929. }
  8930. public void get_erp_returncash()
  8931. {
  8932. DataStruct dStruct = GetPostStruct();
  8933. List<string> lw = new List<string>();
  8934. string tid = GetPostString("tid");
  8935. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8936. string shopname = GetPostString("shopname");
  8937. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8938. string buyernick = GetPostString("buyer_nick");
  8939. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8940. string customer = GetPostString("customer");
  8941. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8942. string returndate1 = GetPostString("returndate1");
  8943. string returndate2 = GetPostString("returndate2");
  8944. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8945. if (dw.Length > 0) lw.Add(dw);
  8946. string finishDate1 = GetPostString("finishdate1");
  8947. string finishDate2 = GetPostString("finishdate2");
  8948. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8949. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8950. string returntype = GetPostString("returntype");
  8951. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8952. string returnvstate = GetPostString("returnvstate");
  8953. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8954. dStruct.Order = "created desc";
  8955. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8956. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8957. writeGridDataTableJson(dStruct.TotalCount, dt);
  8958. }
  8959. public void get_erp_staygoods()
  8960. {
  8961. DataStruct dStruct = GetPostStruct();
  8962. List<string> lw = new List<string>();
  8963. string tid = GetPostString("tid");
  8964. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8965. string shopname = GetPostString("shopname");
  8966. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8967. string wangwang = GetPostString("wangwang");
  8968. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8969. string customer = GetPostString("customer");
  8970. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8971. string returndate1 = GetPostString("returndate1");
  8972. string returndate2 = GetPostString("returndate2");
  8973. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8974. if (dw.Length > 0) lw.Add(dw);
  8975. string finishDate1 = GetPostString("finishdate1");
  8976. string finishDate2 = GetPostString("finishdate2");
  8977. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8978. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8979. string returnvstate = GetPostString("returnvstate");
  8980. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8981. string persuadetype = GetPostString("persuadetype");
  8982. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8983. string customerOrg = GetPostString("customerOrg");
  8984. if (customerOrg.Length > 0)
  8985. {
  8986. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8987. }
  8988. string designerorg = GetPostString("designerorg");
  8989. if (designerorg.Length > 0)
  8990. {
  8991. lw.Add(string.Format("OrgID = {0}", designerorg));
  8992. }
  8993. dStruct.Order = "creata_time desc";
  8994. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8995. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8996. writeGridDataTableJson(dStruct.TotalCount, dt);
  8997. }
  8998. public void upd_erp_staygoods()
  8999. {
  9000. if (UrlPostParmsCheck("id"))
  9001. {
  9002. int eid = GetPostInt("id");
  9003. CeErpStayGoods entity = null;
  9004. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  9005. if (entity != null)
  9006. {
  9007. entity.audit_type = 1;
  9008. entity.audit_time = DateTime.Now;
  9009. entity.audit_u_id = CurrentUser.UserID;
  9010. entity.audit_u_name = CurrentUser.UserName;
  9011. entity.Update();
  9012. returnSuccessMsg("审核成功!");
  9013. return;
  9014. }
  9015. returnErrorMsg("找不到订单记录");
  9016. }
  9017. }
  9018. public void upd_erp_stayGoodsback()
  9019. {
  9020. if (UrlPostParmsCheck("id"))
  9021. {
  9022. int eid = GetPostInt("id");
  9023. CeErpStayGoods entity = null;
  9024. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  9025. if (entity != null)
  9026. {
  9027. entity.audit_text = GetPostString("reason");
  9028. entity.audit_type = 2;
  9029. entity.audit_time = DateTime.Now;
  9030. entity.audit_u_id = CurrentUser.UserID;
  9031. entity.audit_u_name = CurrentUser.UserName;
  9032. entity.Update();
  9033. returnSuccessMsg("退回成功!");
  9034. return;
  9035. }
  9036. returnErrorMsg("找不到订单记录");
  9037. }
  9038. }
  9039. public void upd_erp_returncashverify()
  9040. {
  9041. if (UrlPostParmsCheck("ID"))
  9042. {
  9043. int eid = GetPostInt("ID");
  9044. CeErpReturnCash entity = null;
  9045. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9046. if (entity != null)
  9047. {
  9048. entity.cashstate = 1;
  9049. entity.verifytime = DateTime.Now;
  9050. entity.verifyuserid = CurrentUser.UserID;
  9051. entity.Update();
  9052. returnSuccessMsg("审核成功!");
  9053. return;
  9054. }
  9055. returnErrorMsg("找不到订单记录");
  9056. }
  9057. }
  9058. public void upd_all_erp_returncashverify()
  9059. {
  9060. if (UrlPostParmsCheck("ID"))
  9061. {
  9062. String[] list = GetPostString("ID").Split(',');
  9063. CeErpReturnCash entity = null;
  9064. for (int i = 0; i < list.Length; i++)
  9065. {
  9066. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  9067. if (entity != null)
  9068. {
  9069. if (entity.cashstate == 1)
  9070. {
  9071. returnErrorMsg("已审核过的订单不需要在审核!");
  9072. return;
  9073. }
  9074. entity.cashstate = 1;
  9075. entity.verifytime = DateTime.Now;
  9076. entity.verifyuserid = CurrentUser.UserID;
  9077. entity.Update();
  9078. }
  9079. }
  9080. returnSuccessMsg("审核成功!");
  9081. return;
  9082. }
  9083. }
  9084. public void upd_erp_returncashback()
  9085. {
  9086. if (UrlPostParmsCheck("ID"))
  9087. {
  9088. int eid = GetPostInt("ID");
  9089. CeErpReturnCash entity = null;
  9090. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9091. if (entity != null)
  9092. {
  9093. entity.backreason = GetPostString("reason");
  9094. entity.cashstate = 2;
  9095. entity.verifytime = DateTime.Now;
  9096. entity.verifyuserid = CurrentUser.UserID;
  9097. entity.Update();
  9098. returnSuccessMsg("退回成功!");
  9099. return;
  9100. }
  9101. returnErrorMsg("找不到订单记录");
  9102. }
  9103. }
  9104. public void upd_erp_returnprice()
  9105. {
  9106. if (UrlPostParmsCheck("ID"))
  9107. {
  9108. int eid = GetPostInt("ID");
  9109. CeErpReturnCash entity = null;
  9110. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9111. if (entity != null)
  9112. {
  9113. if (entity.cashstate == 1)
  9114. {
  9115. returnErrorMsg("审核通过了不能改");
  9116. return;
  9117. }
  9118. entity.returnprice = GetPostDouble("returnprice");
  9119. entity.Update();
  9120. returnSuccessMsg("修改成功!");
  9121. return;
  9122. }
  9123. returnErrorMsg("找不到订单记录");
  9124. }
  9125. }
  9126. public void del_erp_returncash()
  9127. {
  9128. if (UrlPostParmsCheck("ID"))
  9129. {
  9130. int eid = GetPostInt("ID");
  9131. CeErpReturnCash.Del(eid);
  9132. returnSuccessMsg("操作成功");
  9133. return;
  9134. }
  9135. }
  9136. public void test_for_do_sql()
  9137. {
  9138. string sql = GetPostString("sqlstr");
  9139. if (sql.Length > 0)
  9140. {
  9141. try
  9142. {
  9143. DbHelper.DbConn.ExecuteNonQuery(sql);
  9144. var res_obj = new
  9145. {
  9146. data = "成功",
  9147. };
  9148. string ro_json = JsonConvert.SerializeObject(res_obj);
  9149. returnSuccess(ro_json);
  9150. }
  9151. catch (Exception ex)
  9152. {
  9153. var res_obj = new
  9154. {
  9155. data = ex.Message,
  9156. };
  9157. string ro_json = JsonConvert.SerializeObject(res_obj);
  9158. returnSuccess(ro_json);
  9159. }
  9160. }
  9161. }
  9162. public void get_user_info()
  9163. {
  9164. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9165. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9166. }
  9167. public void get_total_data()
  9168. {
  9169. int userId = CurrentUser.UserID;
  9170. string sql = "";
  9171. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9172. {
  9173. sql = string.Format("SELECT c.ID, COALESCE(SUM(CASE WHEN OrderState = 8 THEN payment ELSE 0 END), 0) AS orderAmount, COALESCE(SUM(CASE WHEN OrderState = 8 THEN 1 ELSE 0 END), 0) AS orderCount, COALESCE(SUM(CASE WHEN OrderState = 3 THEN payment ELSE 0 END), 0) AS orderBeginAmount, COALESCE(SUM(CASE WHEN OrderState = 3 THEN 1 ELSE 0 END), 0) AS orderBeginCount, COALESCE(SUM(CASE WHEN OrderState = 4 THEN payment ELSE 0 END), 0) AS orderFinishAmount, COALESCE(SUM(CASE WHEN OrderState = 4 THEN 1 ELSE 0 END), 0) AS orderFinishCount, COALESCE(SUM(CASE WHEN IsRefund > 1 THEN 1 ELSE 0 END), 0) AS refundCount, COALESCE(SUM(CASE WHEN IsRefund > 1 THEN payment ELSE 0 END), 0) AS refundAmount FROM CE_ErpUser c LEFT JOIN view_ErpTradeCell v ON c.ID = v.DesignUserId WHERE c.ID = {0} GROUP BY c.ID;", userId);
  9174. }
  9175. else
  9176. {
  9177. sql = string.Format("select d.id,isnull(a.orderAmount,0) as orderAmount,isnull(a.orderCount,0) as orderCount,isnull(b.refundCount,0) as refundCount, isnull(b.refundAmount,0) as refundAmount,isnull(c.afterAmount,0) as afterAmount,isnull(c.afterCount,0) as afterCount from " +
  9178. "(select ID from CE_ErpUser where ID = {0}) d " +
  9179. "left join " +
  9180. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9181. ") a on d.ID = a.id left join " +
  9182. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9183. ") b on a.id = b.id1 left join" +
  9184. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9185. ") c on a.id = c.id2;", userId);
  9186. }
  9187. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9188. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9189. }
  9190. public void get_date_area_total_data2()
  9191. {
  9192. int userId = CurrentUser.UserID;
  9193. string date_type = GetPostString("timetype");
  9194. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9195. string sql = "";
  9196. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9197. {
  9198. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9199. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9200. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9201. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9202. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9203. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9204. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9205. ") a on e.ID = a.id left join " +
  9206. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9207. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9208. ") b on a.id = b.id1 " +
  9209. "left join " +
  9210. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9211. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9212. ") c on a.id = c.id2 " +
  9213. "left join " +
  9214. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9215. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9216. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9217. }
  9218. else
  9219. {
  9220. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9221. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9222. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9223. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9224. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9225. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9226. ") a on e.ID = a.id left join " +
  9227. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9228. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9229. ") c on a.id = c.id2 " +
  9230. "left join " +
  9231. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9232. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9233. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9234. }
  9235. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9236. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9237. }
  9238. public void get_date_area_total_data()
  9239. {
  9240. int userId = CurrentUser.UserID;
  9241. string date_type = GetPostString("timetype");
  9242. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9243. string date1 = searchDT[0].ToString();
  9244. string date2 = searchDT[1].ToString();
  9245. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9246. {
  9247. SqlParameter[] sqlParameter ={
  9248. new SqlParameter("@userId", SqlDbType.Int,4),
  9249. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9250. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9251. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9252. };
  9253. sqlParameter[0].Value = userId;
  9254. sqlParameter[1].Value = date1;
  9255. sqlParameter[2].Value = date2;
  9256. sqlParameter[3].Direction = ParameterDirection.Output;
  9257. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9258. string res = sqlParameter[3].Value.ToString();
  9259. var res_obj = new
  9260. {
  9261. data = res
  9262. };
  9263. string ro_json = JsonConvert.SerializeObject(res_obj);
  9264. returnSuccess(ro_json);
  9265. }
  9266. else
  9267. {
  9268. SqlParameter[] sqlParameter ={
  9269. new SqlParameter("@userId", SqlDbType.Int,4),
  9270. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9271. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9272. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9273. };
  9274. sqlParameter[0].Value = userId;
  9275. sqlParameter[1].Value = date1;
  9276. sqlParameter[2].Value = date2;
  9277. sqlParameter[3].Direction = ParameterDirection.Output;
  9278. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9279. string res = sqlParameter[3].Value.ToString();
  9280. var res_obj = new
  9281. {
  9282. data = res
  9283. };
  9284. string ro_json = JsonConvert.SerializeObject(res_obj);
  9285. returnSuccess(ro_json);
  9286. }
  9287. //writeGridDataViewJson(dt.Rows.Count, dv);
  9288. }
  9289. public void get_order_list()
  9290. {
  9291. string strFields = GetPostString("paraFields");
  9292. string strOrder = GetPostString("paraOrder");
  9293. string strWhere = GetPostString("paraWhere");
  9294. string strPageSize = GetPostString("paraPageSize");
  9295. DataStruct dStruct = GetPostStruct();
  9296. dStruct.PageSize = int.Parse(strPageSize);
  9297. dStruct.Fileds = strFields;
  9298. dStruct.Order = strOrder;
  9299. dStruct.MainWhere = strWhere;
  9300. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9301. writeGridDataTableJson(dStruct.TotalCount, dt);
  9302. }
  9303. ////获取待开始订单列表
  9304. //public void get_wait_design_order_list()
  9305. //{
  9306. // string date_type = GetPostString("date_type");
  9307. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9308. // DataStruct dStruct = GetPostStruct();
  9309. // dStruct.PageSize = 1000;
  9310. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9311. // List<string> lw = new List<string>();
  9312. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9313. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9314. // dStruct.Order = "WaitDesignTime asc";
  9315. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9316. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9317. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9318. //}
  9319. //获取完成单量排名
  9320. public void get_finish_order_count_ranking()
  9321. {
  9322. /* string date_type = GetPostString("date_type");
  9323. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9324. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9325. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9326. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9327. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9328. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9329. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9330. writeGridDataTableJson(0, new DataTable());
  9331. }
  9332. public void get_finish_order_amount_ranking()
  9333. {
  9334. /*string date_type = GetPostString("date_type");
  9335. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9336. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9337. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9338. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9339. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9340. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9341. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9342. writeGridDataTableJson(0, new DataTable());
  9343. }
  9344. public void get_finish_refund_count_ranking()
  9345. {
  9346. string date_type = GetPostString("date_type");
  9347. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9348. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9349. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9350. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9351. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9352. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9353. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9354. writeGridDataTableJson(dt.Rows.Count, dt);
  9355. }
  9356. public void get_finish_refund_amount_ranking()
  9357. {
  9358. string date_type = GetPostString("date_type");
  9359. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9360. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9361. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9362. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9363. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9364. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9365. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9366. writeGridDataTableJson(dt.Rows.Count, dt);
  9367. }
  9368. public void set_erp_finishorder_director()
  9369. {
  9370. if (UrlPostParmsCheck("ctid"))
  9371. {
  9372. string eid = GetPostString("ctid");
  9373. CeErpTradeCell entity = null;
  9374. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9375. if (entity != null)
  9376. {
  9377. entity.OrderState = 8;
  9378. entity.Update();
  9379. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9380. returnSuccessMsg("操作成功!");
  9381. return;
  9382. }
  9383. returnErrorMsg("找不到记录");
  9384. }
  9385. }
  9386. public void get_erp_placeregistlist()
  9387. {
  9388. DataStruct dStruct = GetPostStruct();
  9389. List<string> lw = new List<string>();
  9390. string outsid = GetPostString("outsid");
  9391. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9392. string memo = GetPostString("memo");
  9393. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9394. string filename = GetPostString("filename");
  9395. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9396. string islate = GetPostString("islate");
  9397. if (islate.Length > 0)
  9398. {
  9399. if (islate == "1")
  9400. lw.Add(string.Format("OutLate>0"));
  9401. else
  9402. lw.Add(string.Format("OutLate=0"));
  9403. }
  9404. string placedate1 = GetPostString("placedate1");
  9405. string placedate2 = GetPostString("placedate2");
  9406. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9407. if (dw.Length > 0) lw.Add(dw);
  9408. string deliveryDate1 = GetPostString("deliverydate1");
  9409. string deliveryDate2 = GetPostString("deliverydate2");
  9410. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9411. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9412. dStruct.Order = "ID desc";
  9413. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9414. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9415. writeGridDataTableJson(dStruct.TotalCount, dt);
  9416. }
  9417. public void ins_erp_placeregist()
  9418. {
  9419. if (UrlPostParmsCheck("id"))
  9420. {
  9421. string eid = GetPostString("id");
  9422. CeErpPlaceRegister entity = null;
  9423. if (eid == "0")//新增
  9424. {
  9425. entity = new CeErpPlaceRegister();
  9426. string xdTime = GetPostString("placeTime");
  9427. if (xdTime.Length > 0)
  9428. {
  9429. entity.PlactTime = Convert.ToDateTime(xdTime);
  9430. }
  9431. string fhTime = GetPostString("deliveryTime");
  9432. if (fhTime.Length > 0)
  9433. {
  9434. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9435. }
  9436. string preTime = GetPostString("preOutTime");
  9437. if (preTime.Length > 0)
  9438. {
  9439. entity.PreOutTime = Convert.ToDateTime(preTime);
  9440. }
  9441. entity.DeliveryCount = GetPostInt("deliveryCount");
  9442. entity.ReceiveCount = GetPostInt("receiveCount");
  9443. entity.OutSid = GetPostString("outSid");
  9444. entity.FileName = GetPostString("fileName");
  9445. entity.Memo = GetPostString("memo");
  9446. entity.AddUserId = CurrentUser.UserID;
  9447. entity.CreateTime = DateTime.Now;
  9448. entity.Img = GetPostString("img");
  9449. entity.Supplier = GetPostInt("supplier");
  9450. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9451. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9452. {
  9453. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9454. DateTime dt2 = (DateTime)entity.PreOutTime;
  9455. TimeSpan span = dt1.Subtract(dt2);
  9456. if (span.Days > 0)
  9457. {
  9458. entity.OutLate = span.Days;
  9459. }
  9460. }
  9461. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9462. entity.Create();
  9463. returnSuccessMsg("添加成功!");
  9464. return;
  9465. }
  9466. else //修改
  9467. {
  9468. entity = CeErpPlaceRegister.Get(eid);
  9469. if (entity != null)
  9470. {
  9471. string xdTime = GetPostString("placeTime");
  9472. if (xdTime.Length > 0)
  9473. {
  9474. entity.PlactTime = Convert.ToDateTime(xdTime);
  9475. }
  9476. string fhTime = GetPostString("deliveryTime");
  9477. if (fhTime.Length > 0)
  9478. {
  9479. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9480. }
  9481. string preTime = GetPostString("preOutTime");
  9482. if (preTime.Length > 0)
  9483. {
  9484. entity.PreOutTime = Convert.ToDateTime(preTime);
  9485. }
  9486. entity.DeliveryCount = GetPostInt("deliveryCount");
  9487. entity.ReceiveCount = GetPostInt("receiveCount");
  9488. if (entity.DeliveryCount == entity.ReceiveCount)
  9489. {
  9490. entity.CurState = "已完成";
  9491. }
  9492. else
  9493. {
  9494. entity.CurState = "未完成";
  9495. }
  9496. entity.OutSid = GetPostString("outSid");
  9497. entity.FileName = GetPostString("fileName");
  9498. entity.Memo = GetPostString("memo");
  9499. entity.Img = GetPostString("img");
  9500. entity.Supplier = GetPostInt("supplier");
  9501. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9502. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9503. {
  9504. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9505. DateTime dt2 = (DateTime)entity.PreOutTime;
  9506. TimeSpan span = dt1.Subtract(dt2);
  9507. if (span.Days > 0)
  9508. {
  9509. entity.OutLate = span.Days;
  9510. }
  9511. }
  9512. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9513. entity.Update();
  9514. returnSuccessMsg("修改成功");
  9515. return;
  9516. }
  9517. returnErrorMsg("找不到对应的记录");
  9518. return;
  9519. }
  9520. }
  9521. returnErrorMsg("缺少必要参数");
  9522. }
  9523. public void del_erp_placeregist()
  9524. {
  9525. string eid = GetPostString("id");
  9526. CeErpPlaceRegister.Del(eid);
  9527. returnSuccessMsg("删除成功!");
  9528. return;
  9529. }
  9530. public void ins_erp_placeregistbyorder()
  9531. {
  9532. string ctid = GetPostString("ctid");
  9533. if (ctid.Length > 0)
  9534. {
  9535. StringBuilder sql = new StringBuilder();
  9536. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9537. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9538. if (dt.Rows.Count > 0)
  9539. {
  9540. foreach (DataRow dr in dt.Rows)
  9541. {
  9542. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9543. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9544. entity.AddUserId = CurrentUser.UserID;
  9545. entity.tid = dr["tid"].ToString();
  9546. entity.Did = Convert.ToString(dr["ctid"]);
  9547. entity.splitTag = dr["SplitTag"].ToString();
  9548. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9549. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9550. if (pre_ctid.Length > 0)
  9551. {
  9552. sellmemo = sellmemo.Replace(pre_ctid, "");
  9553. }
  9554. sellmemo = sellmemo.Replace("[", "");
  9555. sellmemo = sellmemo.Replace("]", "");
  9556. entity.FileName = sellmemo;
  9557. string count = dr["ProductCount"].ToString();
  9558. int usecount = commonHelper.getIntCountFromString(count);
  9559. entity.DeliveryCount = usecount;
  9560. entity.CurState = "未完成";
  9561. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9562. {
  9563. entity.Supplier = 24;//dl手提袋定制
  9564. }
  9565. else
  9566. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9567. entity.CreateTime = DateTime.Now;
  9568. entity.Create();
  9569. }
  9570. returnSuccessMsg("操作成功");
  9571. return;
  9572. }
  9573. returnErrorMsg("没有找到对应订单");
  9574. return;
  9575. }
  9576. returnErrorMsg("缺少订单编号");
  9577. return;
  9578. }
  9579. public void get_erp_persuadelist()
  9580. {
  9581. DataStruct dStruct = GetPostStruct();
  9582. List<string> lw = new List<string>();
  9583. string ctid = GetPostString("ctid");
  9584. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9585. string shopname = GetPostString("shopname");
  9586. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9587. string buyernick = GetPostString("buyer_nick");
  9588. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9589. string customer = GetPostString("customer");
  9590. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9591. string returndate1 = GetPostString("returndate1");
  9592. string returndate2 = GetPostString("returndate2");
  9593. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9594. if (dw.Length > 0) lw.Add(dw);
  9595. string finishDate1 = GetPostString("finishdate1");
  9596. string finishDate2 = GetPostString("finishdate2");
  9597. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9598. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9599. string persuadetype = GetPostString("persuadetype");
  9600. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9601. string returnvstate = GetPostString("returnvstate");
  9602. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9603. dStruct.Order = "created desc";
  9604. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9605. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9606. writeGridDataTableJson(dStruct.TotalCount, dt);
  9607. }
  9608. public void upd_erp_returnpersuadeback()
  9609. {
  9610. if (UrlPostParmsCheck("ID"))
  9611. {
  9612. int eid = GetPostInt("ID");
  9613. CeErpPersuade entity = null;
  9614. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9615. if (entity != null)
  9616. {
  9617. entity.backreason = GetPostString("reason");
  9618. entity.pstate = 2;
  9619. entity.verifytime = DateTime.Now;
  9620. entity.verifyuserid = CurrentUser.UserID;
  9621. entity.Update();
  9622. returnSuccessMsg("退回成功!");
  9623. return;
  9624. }
  9625. returnErrorMsg("找不到订单记录");
  9626. }
  9627. }
  9628. public void upd_erp_returnpersuadeverify()
  9629. {
  9630. if (UrlPostParmsCheck("ID"))
  9631. {
  9632. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9633. {
  9634. returnErrorMsg("暂无权限审核");
  9635. return;
  9636. }
  9637. int eid = GetPostInt("ID");
  9638. CeErpPersuade entity = null;
  9639. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9640. if (entity != null)
  9641. {
  9642. entity.pstate = 1;
  9643. entity.verifytime = DateTime.Now;
  9644. entity.verifyuserid = CurrentUser.UserID;
  9645. entity.Update();
  9646. returnSuccessMsg("审核成功!");
  9647. return;
  9648. }
  9649. returnErrorMsg("找不到订单记录");
  9650. }
  9651. }
  9652. public void del_erp_persuade()
  9653. {
  9654. if (UrlPostParmsCheck("ID"))
  9655. {
  9656. int eid = GetPostInt("ID");
  9657. CeErpPersuade.Del(eid);
  9658. returnSuccessMsg("操作成功");
  9659. return;
  9660. }
  9661. }
  9662. public void get_erp_oldcustoupload()
  9663. {
  9664. DataStruct dStruct = GetPostStruct();
  9665. List<string> lw = new List<string>();
  9666. string buyernick = GetPostString("buyer_nick");
  9667. if (buyernick.Length > 0)
  9668. {
  9669. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9670. }
  9671. else
  9672. return;
  9673. dStruct.Order = "pay_time desc";
  9674. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9675. DataTable dt = null;
  9676. dt = WebCache.GetData("view_erptradecell", dStruct);
  9677. writeGridDataTableJson(dStruct.TotalCount, dt);
  9678. }
  9679. public void get_erp_checkorderlist()
  9680. {
  9681. DataStruct dStruct = GetPostStruct();
  9682. List<string> lw = new List<string>();
  9683. string tid = GetPostString("ctid");
  9684. if (tid.Length > 0)
  9685. {
  9686. string select_tid = getTidByCtid(tid);
  9687. lw.Add(string.Format("tid='{0}'", select_tid));
  9688. }
  9689. string shopname = GetPostString("shopname");
  9690. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9691. string buyernick = GetPostString("buyer_nick");
  9692. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9693. string customer = GetPostString("customer");
  9694. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9695. string design = GetPostString("design");
  9696. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9697. string orderState = GetPostString("orderState");
  9698. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9699. string address = GetPostString("address");
  9700. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9701. string sellermemo = GetPostString("seller_memo");
  9702. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9703. string supplier = GetPostString("supplier");
  9704. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9705. {
  9706. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9707. }
  9708. else
  9709. {
  9710. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9711. }
  9712. string date1 = GetPostString("date1");
  9713. string date2 = GetPostString("date2");
  9714. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9715. if (dw.Length > 0) lw.Add(dw);
  9716. string placedate1 = GetPostString("placedate1");
  9717. string placedate2 = GetPostString("placedate2");
  9718. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9719. if (fdw.Length > 0) lw.Add(fdw);
  9720. string price1 = GetPostString("price1");
  9721. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9722. string price2 = GetPostString("price2");
  9723. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9724. string checkst = GetPostString("checkstate");
  9725. if (checkst.Length > 0 && "10".Equals(checkst))
  9726. {
  9727. lw.Add(string.Format("CheckOut>0"));
  9728. }
  9729. else
  9730. {
  9731. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9732. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9733. }
  9734. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9735. {
  9736. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9737. }
  9738. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9739. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9740. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9741. writeGridDataTableJson(dStruct.TotalCount, dt);
  9742. }
  9743. public void ins_erp_startCheck()
  9744. {
  9745. if (UrlPostParmsCheck("ctid"))
  9746. {
  9747. string eid = GetPostString("ctid");
  9748. CeErpTradeCell entity = null;
  9749. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9750. if (entity != null)
  9751. {
  9752. entity.MemoOpt = 4;
  9753. entity.UpdateTime = DateTime.Now;
  9754. entity.Update();
  9755. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9756. CeErpSukuraData.createInfo(entity.ctid, 6);
  9757. returnSuccessMsg("操作成功!");
  9758. return;
  9759. }
  9760. returnErrorMsg("找不到记录");
  9761. }
  9762. }
  9763. public void upd_erp_sendXlw()
  9764. {
  9765. if (UrlPostParmsCheck("ctid"))
  9766. {
  9767. string eid = GetPostString("ctid");
  9768. CeErpTradeCell entity = null;
  9769. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9770. if (entity != null)
  9771. {
  9772. if (entity.IsSendGift == 1)
  9773. {
  9774. returnErrorMsg("请勿重复标记");
  9775. return;
  9776. }
  9777. entity.IsSendGift = 1;
  9778. entity.Update();
  9779. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9780. returnSuccessMsg("操作成功!");
  9781. return;
  9782. }
  9783. returnErrorMsg("找不到记录");
  9784. }
  9785. }
  9786. public void cancel_sendXlw()
  9787. {
  9788. if (UrlPostParmsCheck("ctid"))
  9789. {
  9790. string eid = GetPostString("ctid");
  9791. CeErpTradeCell entity = null;
  9792. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9793. if (entity != null)
  9794. {
  9795. if (entity.IsSendGift == 0)
  9796. {
  9797. returnErrorMsg("未标记小礼物");
  9798. return;
  9799. }
  9800. entity.IsSendGift = 0;
  9801. entity.Update();
  9802. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9803. returnSuccessMsg("操作成功!");
  9804. return;
  9805. }
  9806. returnErrorMsg("找不到记录");
  9807. }
  9808. }
  9809. public void get_erp_designbill()
  9810. {
  9811. DataStruct dStruct = GetPostStruct();
  9812. List<string> lw = new List<string>();
  9813. int isMy = GetInt("my");
  9814. if (isMy == 1)
  9815. {
  9816. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9817. }
  9818. string tid = GetPostString("tid");
  9819. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9820. string userName = GetPostString("design");
  9821. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9822. string price1 = GetPostString("price1");
  9823. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9824. string price2 = GetPostString("price2");
  9825. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9826. string rePrice1 = GetPostString("rePrice1");
  9827. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9828. string rePrice2 = GetPostString("rePrice2");
  9829. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9830. string designerType = GetPostString("designerType");
  9831. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9832. string orderState = GetPostString("orderState");
  9833. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9834. string endTime1 = GetPostString("endTime1");
  9835. string endTime2 = GetPostString("endTime2");
  9836. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9837. if (dw.Length > 0) lw.Add(dw);
  9838. string isDk = GetPostString("isDk");
  9839. if (isDk == "1")
  9840. {
  9841. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9842. }
  9843. else if (isDk == "0")
  9844. {
  9845. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9846. }
  9847. dStruct.Order = "oid, create_time desc";
  9848. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9849. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9850. writeGridDataTableJson(dStruct.TotalCount, dt);
  9851. }
  9852. public void upd_erp_designerbill()
  9853. {
  9854. if (UrlPostParmsCheck("ID"))
  9855. {
  9856. string eid = GetPostString("ID");
  9857. CeErpDesignerBill entity = null;
  9858. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9859. if (entity != null)
  9860. {
  9861. if (GetPostDouble("designerpirce") > 0)
  9862. {
  9863. entity.realPrice = GetPostDouble("designerpirce");
  9864. entity.update_time = DateTime.Now;
  9865. entity.update_u_id = CurrentUser.UserID;
  9866. entity.update_u_name = CurrentUser.UserName;
  9867. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9868. entity.Update();
  9869. returnSuccessMsg("操作成功!");
  9870. return;
  9871. }
  9872. else
  9873. {
  9874. entity.price = GetPostDouble("price");
  9875. entity.update_time = DateTime.Now;
  9876. entity.update_u_id = CurrentUser.UserID;
  9877. entity.update_u_name = CurrentUser.UserName;
  9878. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9879. entity.Update();
  9880. returnSuccessMsg("操作成功!");
  9881. return;
  9882. }
  9883. }
  9884. returnErrorMsg("找不到记录");
  9885. }
  9886. }
  9887. public void audit_erp_designerbill()
  9888. {
  9889. if (UrlPostParmsCheck("ID"))
  9890. {
  9891. string eid = GetPostString("ID");
  9892. CeErpDesignerBill entity = null;
  9893. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9894. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9895. if (entity != null)
  9896. {
  9897. entity.realPrice = GetPostDouble("designerpirce");
  9898. entity.update_time = DateTime.Now;
  9899. entity.update_u_id = CurrentUser.UserID;
  9900. entity.update_u_name = CurrentUser.UserName;
  9901. entity.isAudit = 1;
  9902. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9903. entity.Update();
  9904. if (orderEntity != null)
  9905. {
  9906. orderEntity.IsReadTag = 3;
  9907. orderEntity.Update();
  9908. }
  9909. returnSuccessMsg("操作成功!");
  9910. return;
  9911. }
  9912. returnErrorMsg("找不到记录");
  9913. }
  9914. }
  9915. public void all_audit_erp_designerbill()
  9916. {
  9917. if (UrlPostParmsCheck("idList"))
  9918. {
  9919. string[] list = GetPostString("idList").Split(',');
  9920. CeErpDesignerBill entity = null;
  9921. for (int i = 0; i < list.Length; i++)
  9922. {
  9923. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9924. if (entity == null) return;
  9925. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9926. if (orderEntity == null) return;
  9927. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9928. entity.update_time = DateTime.Now;
  9929. entity.update_u_id = CurrentUser.UserID;
  9930. entity.update_u_name = CurrentUser.UserName;
  9931. entity.isAudit = 1;
  9932. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9933. entity.Update();
  9934. orderEntity.IsReadTag = 3;
  9935. orderEntity.Update();
  9936. }
  9937. returnSuccessMsg("操作成功!");
  9938. return;
  9939. }
  9940. }
  9941. public void get_erp_sameorders()
  9942. {
  9943. if (UrlPostParmsCheck("ctid"))
  9944. {
  9945. string eid = GetPostString("ctid");
  9946. CeErpTradeCell entity = null;
  9947. entity = CeErpTradeCell.GetByCtid(eid);
  9948. if (entity != null)
  9949. {
  9950. StringBuilder sql = new StringBuilder();
  9951. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9952. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9953. var res = new
  9954. {
  9955. data = dt.Rows.Count
  9956. };
  9957. string ro_jsond = JsonConvert.SerializeObject(res);
  9958. returnSuccess(ro_jsond);
  9959. return;
  9960. }
  9961. returnErrorMsg("未找到订单");
  9962. return;
  9963. }
  9964. returnErrorMsg("缺少必要的参数");
  9965. }
  9966. public void get_erp_islasthavesameorder()
  9967. {
  9968. if (UrlPostParmsCheck("ctid"))
  9969. {
  9970. string eid = GetPostString("ctid");
  9971. string[] ctidList = eid.Split(',');
  9972. StringBuilder sql = new StringBuilder();
  9973. string tisCtid = "";
  9974. foreach (string ctid in ctidList)
  9975. {
  9976. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9977. if (entity != null)
  9978. {
  9979. sql = new StringBuilder();
  9980. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9981. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9982. if (dth.Rows.Count > 0)
  9983. {
  9984. tisCtid += entity.ctid;
  9985. tisCtid += ",";
  9986. }
  9987. }
  9988. }
  9989. if (tisCtid.Length > 0)
  9990. {
  9991. var res = new
  9992. {
  9993. data = tisCtid
  9994. };
  9995. string ro_jsond = JsonConvert.SerializeObject(res);
  9996. returnSuccess(ro_jsond);
  9997. }
  9998. else
  9999. {
  10000. var res = new
  10001. {
  10002. data = ""
  10003. };
  10004. string ro_jsond = JsonConvert.SerializeObject(res);
  10005. returnSuccess(ro_jsond);
  10006. }
  10007. return;
  10008. }
  10009. returnErrorMsg("缺少必要的参数");
  10010. }
  10011. public void file_client_down_url()
  10012. {
  10013. if (!UrlPostParmsCheck("userId"))
  10014. {
  10015. returnErrorMsg("缺少必要的参数");
  10016. }
  10017. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  10018. }
  10019. public void checkout_form_data()
  10020. {
  10021. if (!UrlPostParmsCheck("tid"))
  10022. {
  10023. returnErrorMsg("缺少必要的参数");
  10024. }
  10025. string tid = GetPostString("tid");
  10026. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  10027. if (ceErpOrderFormData != null)
  10028. {
  10029. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  10030. returnSuccess(ro_jsond);
  10031. return;
  10032. }
  10033. returnErrorMsg("尚未有文件!");
  10034. }
  10035. public void back_supplier_audit()
  10036. {
  10037. int userId = CurrentUser.UserID;
  10038. StringBuilder sql = new StringBuilder();
  10039. sql.AppendFormat("SELECT D.tid FROM CE_ErpUser A LEFT JOIN view_ErpUserPost B ON A.ID = B.UserID LEFT JOIN CE_ErpUserInfo C ON A.InfoID = C.ID LEFT JOIN CE_Withdraw D ON A.pemVend = D.providerid WHERE a.ID ='{0}' and d.status = 3;", userId);
  10040. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10041. if (dt.Rows.Count > 0)
  10042. {
  10043. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10044. }
  10045. else
  10046. {
  10047. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10048. }
  10049. }
  10050. public void back_supplier_query()
  10051. {
  10052. string eid = GetPostString("ctid");
  10053. if (eid != "")
  10054. {
  10055. StringBuilder sql = new StringBuilder();
  10056. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  10057. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10058. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10059. }
  10060. else
  10061. {
  10062. returnErrorMsg("找不到订单记录");
  10063. return;
  10064. }
  10065. }
  10066. public void verified_to_order()
  10067. {
  10068. int userId = CurrentUser.UserID;
  10069. StringBuilder sql = new StringBuilder();
  10070. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  10071. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10072. if (dt.Rows.Count > 0)
  10073. {
  10074. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10075. }
  10076. else
  10077. {
  10078. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10079. }
  10080. }
  10081. public void upd_supplier_audit()
  10082. {
  10083. if (UrlPostParmsCheck("ctid"))
  10084. {
  10085. string eid = GetPostString("ctid");
  10086. string reason = GetPostString("returnreason");
  10087. CeErpTradeCell entity = null;
  10088. CeWithdraw withdraw = null;
  10089. withdraw = CeWithdraw.GetByTid(eid);
  10090. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  10091. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  10092. {
  10093. if (withdraw != null)
  10094. {
  10095. if (!withdraw.userid.Equals(CurrentUser.UserID))
  10096. {
  10097. returnSuccessMsg("您没有权限操作!");
  10098. return;
  10099. }
  10100. else
  10101. {
  10102. if (reason.Equals("1"))
  10103. {
  10104. if (entity.OrderState == -1)
  10105. {
  10106. if (entity.FinishPlaceTime == null)
  10107. {
  10108. entity.OrderState = 2;
  10109. }
  10110. else
  10111. {
  10112. entity.OrderState = 6;
  10113. }
  10114. }
  10115. entity.Update();
  10116. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10117. if (withdraw != null)
  10118. {
  10119. withdraw.status = int.Parse(reason);
  10120. withdraw.Update();
  10121. }
  10122. returnSuccessMsg("操作成功!");
  10123. return;
  10124. }
  10125. else
  10126. {
  10127. withdraw.status = int.Parse(reason);
  10128. withdraw.acknowledgingtime = DateTime.Now;
  10129. withdraw.Update();
  10130. returnSuccessMsg("查看详细请点击线下订单查询");
  10131. return;
  10132. }
  10133. }
  10134. }
  10135. // 第一个字符是 'N'
  10136. }
  10137. if (eid[0] != 'N')
  10138. {
  10139. }
  10140. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10141. {
  10142. entity.IsVerifyToSupplier = false;
  10143. entity.IsReturn = 1;
  10144. entity.ReturnTime = DateTime.Now;
  10145. entity.ReturnReason = reason;
  10146. if (entity.OrderState == 6)
  10147. {
  10148. entity.OrderState = 5;
  10149. }
  10150. entity.Update();
  10151. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10152. if (withdraw != null)
  10153. {
  10154. withdraw.status = int.Parse(reason);
  10155. withdraw.Update();
  10156. }
  10157. returnSuccessMsg("操作成功!");
  10158. return;
  10159. }
  10160. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10161. {
  10162. ;
  10163. if (withdraw != null)
  10164. {
  10165. withdraw.status = int.Parse(reason);
  10166. withdraw.acknowledgingtime = DateTime.Now;
  10167. withdraw.Update();
  10168. returnSuccessMsg("供应商取消撤回!");
  10169. return;
  10170. }
  10171. }
  10172. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10173. {
  10174. if (entity.OrderState == -1)
  10175. {
  10176. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10177. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10178. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10179. {
  10180. returnErrorMsg("台湾客户需填写身份证!");
  10181. return;
  10182. }
  10183. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10184. {
  10185. returnErrorMsg("偏远地区需要填写物流费!");
  10186. return;
  10187. }
  10188. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10189. {
  10190. returnErrorMsg("订单spu没有确认无法通过审核!");
  10191. return;
  10192. }
  10193. if (entity.FinishPlaceTime == null)
  10194. {
  10195. entity.OrderState = 2;
  10196. }
  10197. else
  10198. {
  10199. entity.OrderState = 3;
  10200. }
  10201. commonHelper.getCytPrice(entity);
  10202. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10203. {
  10204. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10205. }
  10206. if (entity.IsSample > 1 || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物"))
  10207. {
  10208. entity.OrderState = 6;
  10209. }
  10210. }
  10211. entity.Update();
  10212. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10213. if (withdraw != null)
  10214. {
  10215. withdraw.status = int.Parse(reason);
  10216. withdraw.Update();
  10217. }
  10218. returnSuccessMsg("操作成功!");
  10219. return;
  10220. }
  10221. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10222. {
  10223. if (withdraw == null)
  10224. {
  10225. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10226. return;
  10227. }
  10228. }
  10229. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10230. {
  10231. if (withdraw != null)
  10232. {
  10233. withdraw.status = int.Parse(reason);
  10234. withdraw.acknowledgingtime = DateTime.Now;
  10235. withdraw.Update();
  10236. returnSuccessMsg("查看详细请点击线下订单查询");
  10237. return;
  10238. }
  10239. }
  10240. return;
  10241. }
  10242. }
  10243. //校验报价
  10244. public void refund_order_tip()
  10245. {
  10246. int userid = CurrentUser.UserID;
  10247. int sectionId = CurrentUser.UserPost.OrgID;
  10248. StringBuilder sql = new StringBuilder();
  10249. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10250. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10251. List<string> ids = new List<string>();
  10252. if (dth.Rows.Count > 0)
  10253. {
  10254. foreach (DataRow dr in dth.Rows)
  10255. {
  10256. ids.Add(dr["ID"].ToString());
  10257. }
  10258. try
  10259. {
  10260. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10261. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10262. }
  10263. catch (Exception ex)
  10264. {
  10265. }
  10266. }
  10267. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10268. }
  10269. public void refund_order_Design()
  10270. {
  10271. int userid = CurrentUser.UserID;
  10272. int sectionId = CurrentUser.UserPost.OrgID;
  10273. StringBuilder sql = new StringBuilder();
  10274. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10275. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10276. List<string> ids = new List<string>();
  10277. if (dth.Rows.Count > 0)
  10278. {
  10279. foreach (DataRow dr in dth.Rows)
  10280. {
  10281. ids.Add(dr["ID"].ToString());
  10282. }
  10283. try
  10284. {
  10285. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10286. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10287. }
  10288. catch (Exception ex)
  10289. {
  10290. }
  10291. }
  10292. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10293. }
  10294. public void change_order_info()
  10295. {
  10296. int userid = CurrentUser.UserID;
  10297. StringBuilder sql = new StringBuilder();
  10298. sql.AppendFormat("select top 1 c.*,o.seller_memo as seller_memo from CE_ErpMessageTip c left join CE_ErpTradeCell o on o.ctid = c.tid where (c.userId = '{0}' ) and c.isVisit = 0 and c.type = 2;", userid);
  10299. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10300. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10301. }
  10302. public void size_order_tip()
  10303. {
  10304. int userid = CurrentUser.UserID;
  10305. StringBuilder sql = new StringBuilder();
  10306. sql.AppendFormat("select top 1 * from CE_ErpMessageTip c where (c.userId = '{0}' ) and c.isVisit = 0 and c.type = 3;", userid);
  10307. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10308. List<string> ids = new List<string>();
  10309. if (dth.Rows.Count > 0)
  10310. {
  10311. foreach (DataRow dr in dth.Rows)
  10312. {
  10313. ids.Add(dr["ID"].ToString());
  10314. }
  10315. try
  10316. {
  10317. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10318. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10319. }
  10320. catch (Exception ex)
  10321. {
  10322. }
  10323. }
  10324. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10325. }
  10326. public void change_win_mome()
  10327. {
  10328. if (UrlPostParmsCheck("id,ctid"))
  10329. {
  10330. string id = GetPostString("id");
  10331. string ctid = GetPostString("ctid");
  10332. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10333. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10334. if (ce == null || ceErpMessageTip == null)
  10335. {
  10336. returnSuccessMsg("未找到对应的订单!");
  10337. return;
  10338. }
  10339. if (ce.OrderState >= 5)
  10340. {
  10341. ceErpMessageTip.isVisit = true;
  10342. ceErpMessageTip.Update();
  10343. returnSuccessMsg("已上传文件无法修改!");
  10344. return;
  10345. }
  10346. int type = GetPostInt("type");
  10347. string content = GetPostString("content");
  10348. if (type == 0)
  10349. {
  10350. content = content.Replace("(", "(");
  10351. content = content.Replace(")", ")");
  10352. string check = MidStrEx(content, "(", ")").Trim();
  10353. if (string.IsNullOrEmpty(check))
  10354. {
  10355. returnSuccessMsg("文件名格式不正确");
  10356. return;
  10357. }
  10358. }
  10359. ce.seller_memo = content;
  10360. ce.Update();
  10361. ceErpMessageTip.isVisit = true;
  10362. ceErpMessageTip.Update();
  10363. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10364. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10365. ApiVo apiVo = new ApiVo();
  10366. apiVo.orderNumber = ce.ctid;
  10367. apiVo.actionName = "demandDesign";
  10368. apiVo.orderRemarks = content;
  10369. apiVo.demandExamine = type + 1;
  10370. designHelper.API_WorkCore(apiVo);//demandDesign
  10371. returnSuccessMsg("修改成功!");
  10372. }
  10373. }
  10374. public static string MidStrEx(string sourse, string startstr, string endstr)
  10375. {
  10376. string result = string.Empty;
  10377. int startindex, endindex;
  10378. try
  10379. {
  10380. startindex = sourse.IndexOf(startstr);
  10381. if (startindex == -1)
  10382. return result;
  10383. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10384. endindex = tmpstr.IndexOf(endstr);
  10385. if (endindex == -1)
  10386. return result;
  10387. result = tmpstr.Remove(endindex);
  10388. }
  10389. catch (Exception ex)
  10390. {
  10391. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10392. }
  10393. return result;
  10394. }
  10395. public void refund_order_list()
  10396. {
  10397. int userid = CurrentUser.UserID;
  10398. int sectionId = CurrentUser.UserPost.OrgID;
  10399. StringBuilder sql = new StringBuilder();
  10400. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10401. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10402. DataStruct dStruct = GetPostStruct();
  10403. DataTable dt = null;
  10404. List<string> ids = new List<string>();
  10405. List<string> tids = new List<string>();
  10406. if (dth.Rows.Count > 0)
  10407. {
  10408. foreach (DataRow dr in dth.Rows)
  10409. {
  10410. tids.Add("'" + dr["tid"].ToString() + "'");
  10411. ids.Add(dr["id"].ToString());
  10412. }
  10413. try
  10414. {
  10415. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10416. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10417. List<string> lw = new List<string>();
  10418. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10419. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10420. dt = WebCache.GetData("view_orderlist", dStruct);
  10421. }
  10422. catch (Exception ex)
  10423. {
  10424. }
  10425. }
  10426. writeGridDataTableJson(dStruct.TotalCount, dt);
  10427. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10428. }
  10429. //新增
  10430. public void order_batch_downloads()
  10431. {
  10432. string ceid = GetPostString("tid");
  10433. String[] tid = ceid.Split(',');
  10434. order_batch_caiyingtong(tid);
  10435. /* (string success, string errors) = UploadFiles(tid);
  10436. returnSuccessMsg(success + errors);*/
  10437. return;
  10438. }
  10439. //报价接口
  10440. public void Get_To_Quote()
  10441. {
  10442. string ceid = GetPostString("ctid");
  10443. if (ceid != null)
  10444. {
  10445. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10446. if (entity != null)
  10447. {
  10448. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10449. {
  10450. return;
  10451. }
  10452. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10453. double price = 0;
  10454. if (cp == null)
  10455. {
  10456. JObject jsonObject12 = new JObject
  10457. {
  10458. { "UserId", "77886" },
  10459. { "Pwd", "lt666888" },
  10460. { "Filename", entity.seller_memo }
  10461. };
  10462. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10463. JObject jsonObjects1 = JObject.Parse(response1);
  10464. string ms1g = (string)jsonObjects1["msg"];
  10465. if (ms1g == "报价成功")
  10466. {
  10467. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10468. string data = (string)jsonObject1["price"];
  10469. string sql_pay = "INSERT INTO CE_CaiYingTongLog (ctid, ctime,type,msg) VALUES ('" + entity.ctid + "', '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + 2 + ",'" + data + "');";
  10470. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10471. returnSuccessMsg("获取报价成功:" + data);
  10472. price = Convert.ToDouble(data);
  10473. }
  10474. else
  10475. {
  10476. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10477. return;
  10478. }
  10479. }
  10480. String[] beizhu = entity.seller_memo.Split('-');
  10481. String chanp = "";
  10482. if (beizhu.Length > 0)
  10483. {
  10484. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10485. }
  10486. else
  10487. {
  10488. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10489. }
  10490. JObject jsonObject = new JObject
  10491. {
  10492. { "UserId", "77886" },
  10493. { "Pwd", "lt666888" },
  10494. { "Filename", chanp }
  10495. };
  10496. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10497. JObject jsonObjects = JObject.Parse(response);
  10498. string msg = (string)jsonObjects["msg"];
  10499. if (msg == "报价成功")
  10500. {
  10501. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10502. string data = (string)jsonObject1["price"];
  10503. string sql_pay = "INSERT INTO CE_CaiYingTongLog (ctid, ctime,type,msg) VALUES ('" + entity.ctid + "', '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'," + 2 + ",'" + data + "');";
  10504. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10505. returnSuccessMsg("获取报价成功:" + data);
  10506. price = Convert.ToDouble(data);
  10507. }
  10508. else
  10509. {
  10510. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10511. return;
  10512. }
  10513. if (price > 0)
  10514. {
  10515. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10516. if (ceErpTradeCellExtend == null)
  10517. {
  10518. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10519. ceErpTradeCellExtend.ctid = entity.ctid;
  10520. ceErpTradeCellExtend.payment_cyt = price;
  10521. ceErpTradeCellExtend.Create();
  10522. }
  10523. else
  10524. {
  10525. ceErpTradeCellExtend.payment_cyt = price;
  10526. ceErpTradeCellExtend.Update();
  10527. }
  10528. }
  10529. return;
  10530. }
  10531. }
  10532. else
  10533. {
  10534. returnErrorMsg("请至少选择一条数据");
  10535. return;
  10536. }
  10537. }
  10538. //新增
  10539. public void order_To_Supplier()
  10540. {
  10541. string ceid = GetPostString("tid");
  10542. String[] tid = ceid.Split(',');
  10543. if (tid.Length > 0)
  10544. {
  10545. try
  10546. {
  10547. for (int i = 0; i < tid.Length; i++)
  10548. {
  10549. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10550. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10551. entity.SupplierId = suid;
  10552. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10553. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10554. entity.Update();
  10555. }
  10556. }
  10557. catch (Exception ex)
  10558. {
  10559. returnErrorMsg("自动匹配供应商失败");
  10560. return;
  10561. }
  10562. }
  10563. else
  10564. {
  10565. returnErrorMsg("请至少选择一条数据");
  10566. return;
  10567. }
  10568. returnSuccessMsg("自动匹配供应商成功");
  10569. return;
  10570. }
  10571. public (string, string) UploadFiles(string[] urls)
  10572. {
  10573. string success = "";
  10574. string errors = "";
  10575. int userid = CurrentUser.UserID;
  10576. foreach (string url in urls)
  10577. {
  10578. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10579. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10580. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10581. {
  10582. JObject jsonObject = new JObject
  10583. {
  10584. { "Userid", "77886" },
  10585. { "pwd", "cyt86435015" },
  10586. { "content", base64FileContent },
  10587. { "ext", Path.GetExtension(fileName) }
  10588. };
  10589. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10590. JObject jsonObjects = JObject.Parse(response);
  10591. string msg = (string)jsonObjects["msg"];
  10592. if (msg.Equals("上传成功"))
  10593. {
  10594. success += url + " 上传成功";
  10595. }
  10596. else
  10597. {
  10598. errors += url + " 上传失败";
  10599. }
  10600. }
  10601. else
  10602. {
  10603. errors += url + " 格式出现问题";
  10604. }
  10605. }
  10606. if (urls.Length == 0)
  10607. {
  10608. return (success, errors);
  10609. }
  10610. return (success, errors);
  10611. }
  10612. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10613. {
  10614. return true; //总是接受
  10615. }
  10616. public static string HttpPost(string url, string param = null)
  10617. {
  10618. HttpWebRequest request;
  10619. //如果是发送HTTPS请求
  10620. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10621. {
  10622. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10623. request = WebRequest.Create(url) as HttpWebRequest;
  10624. request.ProtocolVersion = HttpVersion.Version10;
  10625. }
  10626. else
  10627. {
  10628. request = WebRequest.Create(url) as HttpWebRequest;
  10629. }
  10630. request.Method = "POST";
  10631. request.ContentType = "application/json";
  10632. request.Accept = "*/*";
  10633. request.Timeout = 120000;
  10634. request.AllowAutoRedirect = false;
  10635. StreamWriter requestStream = null;
  10636. WebResponse response = null;
  10637. string responseStr = null;
  10638. try
  10639. {
  10640. requestStream = new StreamWriter(request.GetRequestStream());
  10641. requestStream.Write(param);
  10642. requestStream.Close();
  10643. response = request.GetResponse();
  10644. if (response != null)
  10645. {
  10646. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10647. responseStr = reader.ReadToEnd();
  10648. reader.Close();
  10649. }
  10650. }
  10651. catch (Exception ex)
  10652. {
  10653. return ex.Message;
  10654. }
  10655. finally
  10656. {
  10657. request = null;
  10658. requestStream = null;
  10659. response = null;
  10660. }
  10661. return responseStr;
  10662. }
  10663. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10664. {
  10665. string base64FileContent;
  10666. string fileName;
  10667. using (WebClient webClient = new WebClient())
  10668. {
  10669. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10670. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10671. {
  10672. using (Stream stream = response.GetResponseStream())
  10673. {
  10674. using (MemoryStream memoryStream = new MemoryStream())
  10675. {
  10676. stream.CopyTo(memoryStream);
  10677. byte[] fileBytes = memoryStream.ToArray();
  10678. base64FileContent = Convert.ToBase64String(fileBytes);
  10679. fileName = response.Headers["Content-Disposition"];
  10680. if (!string.IsNullOrEmpty(fileName))
  10681. {
  10682. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10683. if (index >= 0)
  10684. {
  10685. fileName = fileName.Substring(index + 9).Trim('\"');
  10686. }
  10687. }
  10688. else
  10689. {
  10690. fileName = Path.GetFileName(downloadUrl);
  10691. }
  10692. }
  10693. }
  10694. }
  10695. }
  10696. return (fileName, base64FileContent);
  10697. }
  10698. //新增
  10699. public void order_batch_caiyingtong(string[] downloadUrls)
  10700. {
  10701. try
  10702. {
  10703. //遍历文件
  10704. DataStruct dStruct = GetPostStruct();
  10705. DataTable dt = null;
  10706. int userid = CurrentUser.UserID;
  10707. List<string> ids = new List<string>();//失败组
  10708. List<string> tids = new List<string>();
  10709. using (WebClient webClient = new WebClient())
  10710. {
  10711. foreach (var url in downloadUrls)
  10712. {
  10713. try
  10714. {
  10715. tids.Add("'" + url + "'");
  10716. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10717. if (entity != null)
  10718. {
  10719. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10720. if (cp == null)
  10721. {
  10722. JObject jsonObject = new JObject
  10723. {
  10724. { "Userid", "77886" },
  10725. { "pwd", "lt666888" },
  10726. { "Filename",entity.seller_memo }
  10727. };
  10728. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10729. JObject jsonObjects = JObject.Parse(response);
  10730. string msg = (string)jsonObjects["msg"];
  10731. if (msg == "报价成功")
  10732. {
  10733. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10734. DownloadAndConvertToBase64(url1);
  10735. }
  10736. else
  10737. {
  10738. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10739. }
  10740. }
  10741. else
  10742. {
  10743. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10744. JObject jsonObject = new JObject
  10745. {
  10746. { "Userid", "77886" },
  10747. { "pwd", "lt666888" },
  10748. { "Filename",chanp }
  10749. };
  10750. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10751. JObject jsonObjects = JObject.Parse(response);
  10752. string msg = (string)jsonObjects["msg"];
  10753. if (msg == "报价成功")
  10754. {
  10755. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10756. DownloadAndConvertToBase64(url1);
  10757. }
  10758. else
  10759. {
  10760. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10761. }
  10762. }
  10763. }
  10764. // 上传文件到FTP
  10765. }
  10766. catch (Exception ex)
  10767. {
  10768. Console.WriteLine($"An error occurred: {ex.Message}");
  10769. }
  10770. }
  10771. List<string> lw = new List<string>();
  10772. lw.Add(string.Format("( OrderState < 6 )"));
  10773. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10774. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10775. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10776. if (dt.Rows.Count > 0)
  10777. {
  10778. foreach (DataRow dr in dt.Rows)
  10779. {
  10780. ids.Add(dr["ctid"].ToString());
  10781. }
  10782. }
  10783. String ErrorMsgs = "";
  10784. foreach (String id in ids)
  10785. {
  10786. ErrorMsgs += id + ",";
  10787. }
  10788. if (ErrorMsgs.Length > 1)
  10789. {
  10790. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10791. }
  10792. if (ErrorMsgs.Length < 1)
  10793. {
  10794. ErrorMsgs = "上传成功";
  10795. returnSuccessMsg(ErrorMsgs);
  10796. }
  10797. else
  10798. {
  10799. returnErrorMsg("以下订单" + ErrorMsgs);
  10800. }
  10801. }
  10802. // 删除文件夹及其内容
  10803. /* Directory.Delete(localDirectory, true);*/
  10804. }
  10805. catch { }
  10806. }
  10807. public void get_center_data()
  10808. {
  10809. int userId = CurrentUser.UserID;
  10810. string postCode = CurrentUser.UserPost.Post.Code;
  10811. List<string> lw = new List<string>();
  10812. List<string> ww = new List<string>();
  10813. DateTime currentTime = DateTime.Now;
  10814. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10815. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10816. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10817. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10818. string sql = " SELECT ";
  10819. string startTime = "2023-10-01 11:22:31";
  10820. //设计
  10821. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10822. {
  10823. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10824. ww.Add(string.Format("( SELECT COUNT ( * ) AS designCount FROM CE_ErpTradeCell WHERE pay_time < '{2}' AND OrderState < 5 AND IsReturn = 0 AND pay_time > '{0}' AND DesignUserId = {1} ) AS dc", startTime, userId, payTime));
  10825. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10826. ww.Add(string.Format("( SELECT COUNT ( * ) AS backCount FROM CE_ErpTradeCell WHERE OrderState = 4 AND ReturnTime IS NOT NULL AND pay_time > '{0}' AND DesignUserId = {1} ) AS bc", startTime, userId));
  10827. }
  10828. //客服
  10829. else if (postCode == "CustomerService" || postCode == "Director")
  10830. {
  10831. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10832. ww.Add(string.Format("( SELECT COUNT ( * ) AS designCount FROM CE_ErpTradeCell WHERE pay_time < '{2}' AND OrderState < 5 AND IsReturn = 0 AND pay_time > '{0}' AND CustomerUserId = {1} ) AS dc", startTime, userId, payTime));
  10833. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10834. ww.Add(string.Format("( SELECT COUNT ( * ) AS orderCount FROM CE_ErpTradeCell WHERE FinishDesignTime < '{2}' AND OrderState = 5 AND IsReturn = 0 AND pay_time > '{0}' AND CustomerUserId = {1} ) AS oc", startTime, userId, finishDesignTime));
  10835. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10836. ww.Add(string.Format("( SELECT COUNT ( * ) AS sendCount FROM CE_ErpTradeCell WHERE FinishPlaceTime < '{2}' AND OrderState = 6 AND IsReturn = 0 AND pay_time > '{0}' AND CustomerUserId = {1} ) AS sc", startTime, userId, finishPlaceTime));
  10837. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10838. ww.Add(string.Format("( SELECT COUNT ( * ) AS backCount FROM CE_ErpTradeCell WHERE OrderState = 0 AND ReturnTime IS NOT NULL AND pay_time > '{0}' AND CustomerUserId = {1} ) AS bc", startTime, userId));
  10839. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10840. ww.Add(string.Format("( SELECT COUNT ( * ) AS refundCount FROM CE_ErpTradeCell WHERE IsRefund > 0 AND OrderState NOT IN ( 8, 9 ) AND pay_time > '{0}' AND CustomerUserId = {1} ) AS rc", startTime, userId));
  10841. }
  10842. //售后
  10843. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10844. {
  10845. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10846. ww.Add(string.Format("( SELECT COUNT ( * ) AS sendCount FROM CE_ErpTradeCell WHERE FinishPlaceTime < '{1}' AND OrderState = 6 AND IsReturn = 0 AND pay_time > '{0}' ) AS sc", startTime, finishPlaceTime));
  10847. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10848. ww.Add(string.Format("( SELECT COUNT ( * ) AS refundCount FROM CE_ErpTradeCell WHERE IsRefund > 0 AND OrderState NOT IN ( 8, 9 ) AND pay_time > '{0}' ) AS rc", startTime));
  10849. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10850. ww.Add(string.Format("( SELECT COUNT ( * ) AS checkCount FROM CE_ErpTradeCell WHERE CheckOrderTime < '{1}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND pay_time > '{0}' ) AS cc", startTime, checkOrderTime));
  10851. }
  10852. //下单部
  10853. else if (postCode == "Place" || postCode == "PlaceMr")
  10854. {
  10855. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10856. ww.Add(string.Format("( SELECT COUNT ( * ) AS orderCount FROM CE_ErpTradeCell WHERE FinishDesignTime < '{1}' AND OrderState = 5 AND IsReturn = 0 AND pay_time > '{0}' ) AS oc", startTime, finishDesignTime));
  10857. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10858. ww.Add(string.Format("( SELECT COUNT ( * ) AS sendCount FROM CE_ErpTradeCell WHERE FinishPlaceTime < '{1}' AND OrderState = 6 AND IsReturn = 0 AND pay_time > '{0}' ) AS sc", startTime, finishPlaceTime));
  10859. }
  10860. //车间
  10861. else if (postCode == "Supplier")
  10862. {
  10863. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10864. ww.Add(string.Format("( SELECT COUNT ( * ) AS checkCount FROM CE_ErpTradeCell WHERE CheckOrderTime < '{1}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND pay_time > '{0}' AND SupplierId = {2} ) AS cc", startTime, checkOrderTime, userId));
  10865. }
  10866. DataTable dt = new DataTable();
  10867. if (lw.Count > 0)
  10868. {
  10869. sql += string.Join(" , ", lw);
  10870. sql += " FROM ";
  10871. sql += string.Join(" , ", ww);
  10872. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10873. }
  10874. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10875. }
  10876. public void get_center_data_list()
  10877. {
  10878. int userId = CurrentUser.UserID;
  10879. string postCode = CurrentUser.UserPost.Post.Code;
  10880. string shopIds = CurrentUser.User.pemShop;
  10881. DataStruct dStruct = GetPostStruct();
  10882. List<string> lw = new List<string>();
  10883. DateTime currentTime = DateTime.Now;
  10884. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10885. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10886. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10887. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10888. string startTime = "2023-10-01 11:22:31";
  10889. int order_type = GetPostInt("order_type");
  10890. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10891. {
  10892. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10893. if (order_type == 0)
  10894. {
  10895. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10896. }
  10897. else if (order_type == 3)
  10898. {
  10899. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10900. }
  10901. else
  10902. {
  10903. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10904. }
  10905. }
  10906. //客服
  10907. if (postCode == "CustomerService" || postCode == "Director")
  10908. {
  10909. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10910. if (order_type == 0)
  10911. {
  10912. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10913. }
  10914. else if (order_type == 1)
  10915. {
  10916. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10917. }
  10918. else if (order_type == 2)
  10919. {
  10920. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10921. }
  10922. else if (order_type == 3)
  10923. {
  10924. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10925. }
  10926. else if (order_type == 4)
  10927. {
  10928. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10929. }
  10930. else
  10931. {
  10932. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10933. }
  10934. }
  10935. //售后
  10936. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10937. {
  10938. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10939. if (shopIds != "")
  10940. {
  10941. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10942. }
  10943. if (order_type == 2)
  10944. {
  10945. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10946. }
  10947. else if (order_type == 4)
  10948. {
  10949. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10950. }
  10951. else if (order_type == 5)
  10952. {
  10953. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10954. }
  10955. else
  10956. {
  10957. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10958. }
  10959. }
  10960. //下单部
  10961. if (postCode == "Place" || postCode == "PlaceMr")
  10962. {
  10963. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10964. if (shopIds != "")
  10965. {
  10966. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10967. }
  10968. else if (order_type == 1)
  10969. {
  10970. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10971. }
  10972. else if (order_type == 2)
  10973. {
  10974. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10975. }
  10976. else
  10977. {
  10978. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10979. }
  10980. }
  10981. //车间
  10982. if (postCode == "Supplier")
  10983. {
  10984. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10985. if (order_type == 5)
  10986. {
  10987. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10988. }
  10989. else
  10990. {
  10991. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10992. }
  10993. }
  10994. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10995. dStruct.Fileds = "tid,ctid";
  10996. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10997. writeGridDataTableJson(dStruct.TotalCount, dt);
  10998. }
  10999. public void aftersale_audit_master()
  11000. {
  11001. if (UrlPostParmsCheck("ctid"))
  11002. {
  11003. string ctid = GetPostString("ctid");
  11004. if (ctid.Length > 0)
  11005. {
  11006. bool result = aftersale_data_change(ctid);
  11007. if (result)
  11008. {
  11009. returnSuccessMsg("修改成功!");
  11010. return;
  11011. }
  11012. }
  11013. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11014. }
  11015. }
  11016. public void aftersale_documentary_finish()
  11017. {
  11018. if (UrlPostParmsCheck("ctid"))
  11019. {
  11020. string ctid = GetPostString("ctid");
  11021. if (ctid.Length > 0)
  11022. {
  11023. List<string> list = new List<string>();
  11024. string[] ctid_list = ctid.Split(',');
  11025. foreach (var item in ctid_list)
  11026. {
  11027. try
  11028. {
  11029. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(item);
  11030. if (ceErpTradeAfterSaleExtend == null)
  11031. {
  11032. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11033. ceErpTradeAfterSaleExtend.tid = item;
  11034. }
  11035. ceErpTradeAfterSaleExtend.AfterSalSend = 1;
  11036. if (ceErpTradeAfterSaleExtend.ID > 0)
  11037. {
  11038. ceErpTradeAfterSaleExtend.Update();
  11039. }
  11040. else
  11041. {
  11042. ceErpTradeAfterSaleExtend.Create();
  11043. }
  11044. LogHelper.addLog(item, CurrentUser.UserID, "跟单完成", 6, 4);
  11045. }
  11046. catch (Exception ex)
  11047. {
  11048. list.Add(item);
  11049. }
  11050. }
  11051. if (list.Count > 0)
  11052. {
  11053. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  11054. return;
  11055. }
  11056. returnSuccessMsg("修改成功!");
  11057. return;
  11058. }
  11059. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11060. }
  11061. }
  11062. public void aftersale_batch_audit_master()
  11063. {
  11064. if (UrlPostParmsCheck("ctids"))
  11065. {
  11066. string ctids = GetPostString("ctids");
  11067. if (ctids.Length > 0)
  11068. {
  11069. List<string> list = new List<string>();
  11070. string[] ctid_list = ctids.Split(',');
  11071. foreach (var item in ctid_list)
  11072. {
  11073. bool result = aftersale_data_change(item);
  11074. if (!result)
  11075. {
  11076. list.Add(item);
  11077. }
  11078. }
  11079. if (list.Count > 0)
  11080. {
  11081. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  11082. return;
  11083. }
  11084. returnSuccessMsg("修改成功!");
  11085. return;
  11086. }
  11087. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11088. }
  11089. }
  11090. public bool aftersale_data_change(string ctid)
  11091. {
  11092. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11093. if (ceErpTradeCell != null)
  11094. {
  11095. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  11096. ceErpTradeCell.AfterSaleSupplierState = 0;
  11097. StringBuilder sql = new StringBuilder();
  11098. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  11099. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11100. CeErpTradeResponsible.DelByTid(ctid, 0);
  11101. if ((ceErpTradeCell.AfterSaleResponsible.IndexOf("客户问题") != -1 && ceErpTradeCell.AfterSaleResponsible.IndexOf(",客户问题") == -1) || (ceErpTradeCell.AfterSaleResponsible.IndexOf("系统问题") != -1 && ceErpTradeCell.AfterSaleResponsible.IndexOf(",系统问题") == -1) || ceErpTradeCell.supRefundType == "正常损耗" || ceErpTradeCell.supRefundType == "车间不售后" || ceErpTradeCell.supRefundType == "不售后" || ceErpTradeCell.supRefundType == "不理赔")
  11102. {
  11103. CeErpTradeResponsible.DelByTid(ctid, -1);
  11104. ceErpTradeCell.AfterSaleSupplierState = 1;
  11105. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11106. ceErpTradeCell.AfterSaleState = 4;
  11107. }
  11108. else
  11109. {
  11110. ceErpTradeCell.AfterSaleState = 3;
  11111. }
  11112. bool needCyt = false;
  11113. if (dt != null)
  11114. {
  11115. if (dt.Rows.Count == 1)
  11116. {
  11117. bool isEnd = false;
  11118. foreach (DataRow dr in dt.Rows)
  11119. {
  11120. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11121. {
  11122. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11123. isEnd = true;
  11124. }
  11125. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  11126. {
  11127. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11128. isEnd = true;
  11129. }
  11130. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11131. {
  11132. needCyt = true;
  11133. }
  11134. }
  11135. if (isEnd)
  11136. {
  11137. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11138. ceErpTradeCell.AfterSaleState = 4;
  11139. ceErpTradeCell.AfterSaleSupplierState = 1;
  11140. }
  11141. }
  11142. else
  11143. {
  11144. bool isAll = true;
  11145. foreach (DataRow dr in dt.Rows)
  11146. {
  11147. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11148. {
  11149. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11150. continue;
  11151. }
  11152. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  11153. {
  11154. string path = "";
  11155. int OrgID = 0;
  11156. if (!Convert.IsDBNull(dr["OrgPath"]))
  11157. {
  11158. path = dr["OrgPath"].ToString();
  11159. }
  11160. if (!Convert.IsDBNull(dr["OrgID"]))
  11161. {
  11162. OrgID = Convert.ToInt32(dr["OrgID"]);
  11163. }
  11164. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  11165. {
  11166. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11167. continue;
  11168. }
  11169. }
  11170. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11171. {
  11172. needCyt = true;
  11173. }
  11174. isAll = false;
  11175. }
  11176. if (isAll)
  11177. {
  11178. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11179. ceErpTradeCell.AfterSaleState = 4;
  11180. ceErpTradeCell.AfterSaleSupplierState = 1;
  11181. }
  11182. }
  11183. }
  11184. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  11185. {
  11186. commonHelper.sendCytAfterSale(ceErpTradeCell);
  11187. }
  11188. if (ceErpTradeCell.AfterSaleState == 4)
  11189. {
  11190. ApiVo apiVo = new ApiVo();
  11191. apiVo.orderNumber = ceErpTradeCell.ctid;
  11192. apiVo.actionName = "afterOver";
  11193. designHelper.API_WorkCore(apiVo); //afterOver
  11194. }
  11195. ceErpTradeCell.Update();
  11196. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  11197. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  11198. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11199. return true;
  11200. }
  11201. return false;
  11202. }
  11203. public void get_erp_wechatorder()
  11204. {
  11205. DataStruct dStruct = GetPostStruct();
  11206. List<string> lw = new List<string>();
  11207. string tid = GetPostString("tid");
  11208. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11209. string shopname = GetPostString("shopname");
  11210. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11211. string buyernick = GetPostString("buyer_nick");
  11212. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11213. string customer = GetPostString("customer");
  11214. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11215. string returndate1 = GetPostString("returndate1");
  11216. string returndate2 = GetPostString("returndate2");
  11217. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11218. if (dw.Length > 0) lw.Add(dw);
  11219. string finishDate1 = GetPostString("finishdate1");
  11220. string finishDate2 = GetPostString("finishdate2");
  11221. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11222. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11223. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11224. dStruct.Order = "created desc";
  11225. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11226. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11227. writeGridDataTableJson(dStruct.TotalCount, dt);
  11228. }
  11229. public void get_erp_wechatlist_sumprice()
  11230. {
  11231. DataStruct dStruct = GetPostStruct();
  11232. List<string> lw = new List<string>();
  11233. string tid = GetPostString("tid");
  11234. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11235. string shopname = GetPostString("shopname");
  11236. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11237. string buyernick = GetPostString("buyer_nick");
  11238. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11239. string customer = GetPostString("customer");
  11240. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11241. string returndate1 = GetPostString("returndate1");
  11242. string returndate2 = GetPostString("returndate2");
  11243. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11244. if (dw.Length > 0) lw.Add(dw);
  11245. string finishDate1 = GetPostString("finishdate1");
  11246. string finishDate2 = GetPostString("finishdate2");
  11247. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11248. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11249. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11250. string mainWhere = string.Join(" and ", lw.ToArray());
  11251. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11252. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11253. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11254. decimal total = 0;
  11255. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11256. {
  11257. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11258. }
  11259. var res = new
  11260. {
  11261. data = total
  11262. };
  11263. string ro_jsond = JsonConvert.SerializeObject(res);
  11264. returnSuccess(ro_jsond);
  11265. return;
  11266. }
  11267. public void get_erp_qr_waitdeliverylist()
  11268. {
  11269. DataStruct dStruct = GetPostStruct();
  11270. List<string> lw = new List<string>();
  11271. string tid = GetPostString("ctid");
  11272. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11273. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11274. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11275. var res_objz = new
  11276. {
  11277. restype = 1,
  11278. data = dt
  11279. };
  11280. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11281. returnSuccess(ro_jsonz);
  11282. }
  11283. public void get_erp_yield_list()
  11284. {
  11285. DataStruct dStruct = GetPostStruct();
  11286. List<string> lw = new List<string>();
  11287. string tid = GetPostString("ctid");
  11288. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11289. string shopname = GetPostString("shopname");
  11290. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11291. string buyernick = GetPostString("buyer_nick");
  11292. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11293. //if (tid.Length == 0 && buyernick.Length == 0)
  11294. //{
  11295. // lw.Add(string.Format("IsRefund<={0}", 1));
  11296. //}
  11297. string customer = GetPostString("customer");
  11298. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11299. string design = GetPostString("design");
  11300. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11301. string orderState = GetPostString("orderState");
  11302. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11303. string address = GetPostString("address");
  11304. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  11305. string sellermemo = GetPostString("seller_memo");
  11306. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11307. string supplier = GetPostString("supplier");
  11308. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11309. string OrderArea = GetPostString("order_area");
  11310. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11311. string placedate1 = GetPostString("placedate1");
  11312. string placedate2 = GetPostString("placedate2");
  11313. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11314. if (fdw.Length > 0) lw.Add(fdw);
  11315. string price1 = GetPostString("price1");
  11316. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11317. string price2 = GetPostString("price2");
  11318. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11319. string unusualCon = GetPostString("unusualcon");
  11320. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11321. string posTag = CurrentUser.UserPost.Post.Code;
  11322. if (posTag == "Supplier")
  11323. {
  11324. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11325. }
  11326. lw.Add(string.Format("OrderState = 6 "));
  11327. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11328. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11329. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11330. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11331. writeGridDataTableJson(dStruct.TotalCount, dt);
  11332. }
  11333. public void change_erp_sup_state()
  11334. {
  11335. if (UrlPostParmsCheck("ctid"))
  11336. {
  11337. string ctid = GetPostString("ctid");
  11338. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11339. if (ceErpTradeCell != null)
  11340. {
  11341. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11342. if (ceErpTradeCellExtend == null)
  11343. {
  11344. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11345. ceErpTradeCellExtend.ctid = ctid;
  11346. ceErpTradeCellExtend.SupState = 1;
  11347. ceErpTradeCellExtend.Create();
  11348. }
  11349. else
  11350. {
  11351. ceErpTradeCellExtend.SupState = 1;
  11352. ceErpTradeCellExtend.Update();
  11353. }
  11354. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11355. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11356. return;
  11357. }
  11358. returnErrorMsg("找不到订单");
  11359. }
  11360. }
  11361. public void supplier_all_downs()
  11362. {
  11363. if (UrlPostParmsCheck("tids"))
  11364. {
  11365. string tids = GetPostString("tids");
  11366. if (tids != null && tids.Length > 0)
  11367. {
  11368. StringBuilder sql = new StringBuilder();
  11369. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11370. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11371. sql = new StringBuilder();
  11372. sql.AppendFormat("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"), (int)OrderState.下单完成, CurrentUser.UserID, "下载设计文件");
  11373. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11374. string[] list = tids.Split(',');
  11375. foreach (string ctid in list)
  11376. {
  11377. CeErpSukuraData.createInfo(ctid, 3);
  11378. }
  11379. designHelper.api_approveDesign(tids); //approveDesign
  11380. returnSuccessMsg("下载成功!");
  11381. return;
  11382. }
  11383. returnErrorMsg("下载订单更新失败");
  11384. }
  11385. }
  11386. public void uploaderFileSuccess()
  11387. {
  11388. if (UrlPostParmsCheck("fileName"))
  11389. {
  11390. string fileName = GetPostString("fileName");
  11391. ApiVo apiVo = new ApiVo();
  11392. apiVo.orderNumber = fileName;
  11393. apiVo.actionName = "finishDesign";
  11394. designHelper.API_WorkCore(apiVo);//finishDesign
  11395. returnSuccessMsg("");
  11396. }
  11397. }
  11398. public void get_sample2_order()
  11399. {
  11400. if (UrlPostParmsCheck("ctid"))
  11401. {
  11402. string ctid = GetPostString("ctid");
  11403. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11404. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11405. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11406. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11407. double total = 0.0;
  11408. double order_price = 0.0;
  11409. if (dt_bu.Rows.Count > 0)
  11410. {
  11411. foreach (DataRow dr in dt_bu.Rows)
  11412. {
  11413. total += Convert.ToDouble(dr["payment"]);
  11414. }
  11415. }
  11416. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11417. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11418. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11419. string tid = ctid.Replace("S_", "");
  11420. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11421. double paymant = 0.0;
  11422. if (entity != null)
  11423. {
  11424. paymant = entity.payment;
  11425. }
  11426. string return_reason = "";
  11427. if (dt_after != null && dt_after.Rows.Count > 0)
  11428. {
  11429. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11430. }
  11431. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11432. }
  11433. }
  11434. public void get_erp_design_status()
  11435. {
  11436. string designName = GetPostString("designName");
  11437. DataStruct dStruct = GetPostStruct();
  11438. if (designName.Length > 0)
  11439. {
  11440. string sql_user = "select id,Name,TeamIds from view_ErpUser where (PostCode='Designer' or PostCode='DesignerMr' or PostCode='Designerhd' or PostCode='wxDesigner' or PostCode='wxDesignerMr') and isopen = 1";
  11441. sql_user += " and Name like '%" + designName + "%'";
  11442. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11443. List<string> ids_list = new List<string>();
  11444. if (user_table.Rows.Count > 0)
  11445. {
  11446. foreach (DataRow item in user_table.Rows)
  11447. {
  11448. ids_list.Add(item["id"].ToString());
  11449. string ids_s = item["TeamIds"].ToString();
  11450. if (ids_s.Length > 0)
  11451. {
  11452. ids_list.AddRange(ids_s.Split(','));
  11453. }
  11454. }
  11455. }
  11456. HashSet<string> set = new HashSet<string>(ids_list);
  11457. ids_list = set.ToList();
  11458. if (ids_list.Count > 0)
  11459. {
  11460. string sql = string.Format(" (PostCode='Designer' or PostCode='DesignerMr' or PostCode='Designerhd' or PostCode='wxDesigner' or PostCode='wxDesignerMr') and isopen = 1 and id in ({0})", string.Join(",", ids_list));
  11461. dStruct.MainWhere = sql;
  11462. DataTable dt = null;
  11463. dt = WebCache.GetData("view_ErpUser", dStruct);
  11464. writeGridDataTableJson(dStruct.TotalCount, dt);
  11465. }
  11466. }
  11467. }
  11468. public void change_erp_order_price()
  11469. {
  11470. string ctid = GetPostString("ctid");
  11471. double price = GetPostDouble("price");
  11472. if (ctid.Length > 0)
  11473. {
  11474. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11475. if (ceErpTradeCellExtend == null)
  11476. {
  11477. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11478. ceErpTradeCellExtend.ctid = ctid;
  11479. ceErpTradeCellExtend.payment_cyt = price;
  11480. ceErpTradeCellExtend.Create();
  11481. }
  11482. else
  11483. {
  11484. ceErpTradeCellExtend.payment_cyt = price;
  11485. ceErpTradeCellExtend.Update();
  11486. }
  11487. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11488. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11489. {
  11490. ceErpDataSendOrderInfo.isSync = false;
  11491. ceErpDataSendOrderInfo.Update();
  11492. }
  11493. if (ceErpDataSendOrderInfo == null)
  11494. {
  11495. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11496. ceErpDataSendOrderInfo.isSync = false;
  11497. ceErpDataSendOrderInfo.ctid = ctid;
  11498. ceErpDataSendOrderInfo.Create();
  11499. }
  11500. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11501. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11502. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11503. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11504. {
  11505. dataSendOrderBean dataSendOrderBean = null;
  11506. foreach (DataRow item in dth.Rows)
  11507. {
  11508. try
  11509. {
  11510. dataSendOrderBean = new dataSendOrderBean();
  11511. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11512. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11513. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11514. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11515. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11516. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11517. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11518. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11519. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11520. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11521. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11522. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11523. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11524. if (result != null)
  11525. {
  11526. if ("0".Equals(result.errcode))
  11527. {
  11528. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11529. }
  11530. else
  11531. {
  11532. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11533. }
  11534. }
  11535. }
  11536. catch (Exception ex)
  11537. {
  11538. }
  11539. }
  11540. }
  11541. returnSuccessMsg("修改成功!");
  11542. return;
  11543. }
  11544. returnErrorMsg("找不到订单");
  11545. }
  11546. public void find_he_together()
  11547. {
  11548. string ctid = GetPostString("ctid");
  11549. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11550. List<string> list = new List<string>();
  11551. if (ceErpTradeCell != null)
  11552. {
  11553. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11554. {
  11555. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where tid='{0}' and ctid <> '{1}' and SupplierId = {2}", ceErpTradeCell.tid, ceErpTradeCell.ctid, ceErpTradeCell.SupplierId);
  11556. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11557. if (table != null && table.Rows.Count > 0)
  11558. {
  11559. foreach (TableRow row in table.Rows)
  11560. {
  11561. }
  11562. }
  11563. }
  11564. }
  11565. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11566. }
  11567. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11568. {
  11569. //chy----19
  11570. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11571. //GD-CYT-----64
  11572. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11573. //ZHX----3
  11574. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11575. //JK----97
  11576. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11577. //ZT----70
  11578. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11579. //GD-CYTUV---126
  11580. {126, new Dictionary<string, string> {{"uv", "uv"}}},
  11581. //LHCY-----98
  11582. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11583. //XD-----90
  11584. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11585. //CYCY-----14
  11586. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}},
  11587. //THLZY----122
  11588. {122, new Dictionary<string, string> {{ "烫画", "烫画" }, { "冷转印", "冷转印" }}}
  11589. };
  11590. //其他改名
  11591. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11592. {
  11593. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11594. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11595. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11596. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11597. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11598. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11599. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11600. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" },{ 129,"种子纸"},{ 125,"胶带"},{ 127,"PET透卡"}
  11601. };
  11602. //不统计
  11603. List<int> no_suppliers = new List<int>()
  11604. {
  11605. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11606. };
  11607. //配件单
  11608. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11609. {
  11610. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11611. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11612. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11613. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11614. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11615. {"旗杆",new List<string>(){ "班旗" } },
  11616. {"牙签",new List<string>(){ "不干胶" } }
  11617. };
  11618. public void get_place_order_data()
  11619. {
  11620. string date1 = GetPostString("date1");
  11621. string date2 = GetPostString("date2");
  11622. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11623. DateTime start = DateTime.Parse(starttime);
  11624. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11625. DateTime end = DateTime.Parse(endtime);
  11626. if (date1 != null && date1.Length > 0)
  11627. {
  11628. DateTime dateTime = DateTime.Parse(date1);
  11629. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11630. start = DateTime.Parse(starttime);
  11631. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11632. end = DateTime.Parse(endtime);
  11633. }
  11634. if (date2 != null && date2.Length > 0)
  11635. {
  11636. DateTime dateTime = DateTime.Parse(date2);
  11637. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11638. end = DateTime.Parse(endtime);
  11639. }
  11640. List<int> smSupplier = new List<int>() { 97, 121, 119, 80 };
  11641. string startMonthDate = commonHelper.FirstDayOfMonth(DateTime.Now).ToString("yyyy-MM-dd 00:00:00");
  11642. string endMonthDate = commonHelper.LastDayOfMonth(DateTime.Now).ToString("yyyy-MM-dd 23:59:59");
  11643. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,UnusualTime,FinishPlaceTime,OrderState,FinishDeliveryTime,AfterSaleState=0,AfterSaleReason = '',delivery=0 from view_ErpTradeCell where ( ( FinishPlaceTime BETWEEN '{0}' AND '{1}' ) OR ( OrderState = 6 AND UnusualTag = 5 AND IsRefund <= 1 ) ) AND IsSample = 0 and SupplierId > 0 ", starttime, endtime);
  11644. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11645. sql = string.Format("SELECT SupplierId, ProductId, seller_memo, ProductCount, ProductName, payment, SupplierName, UnusualTime, FinishPlaceTime, OrderState, FinishDeliveryTime, AfterSaleState,AfterSaleReason,delivery=0 FROM view_ErpTradeCell WHERE ( AfterSalePreTime BETWEEN '{0}' AND '{1}' ) AND IsSample = 0 AND SupplierId > 0 AND FinishPlaceTime IS NOT NULL", startMonthDate, endMonthDate);
  11646. DataTable afterSaleData = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11647. data.Merge(afterSaleData);
  11648. sql = string.Format("SELECT SupplierId, ProductId, seller_memo, ProductCount, ProductName, payment, SupplierName, UnusualTime, FinishPlaceTime, OrderState, FinishDeliveryTime, AfterSaleState=0,AfterSaleReason = '',delivery=1 FROM view_ErpTradeCell WHERE orderstate = 6 AND IsSample = 0 AND SupplierId > 0 AND FinishPlaceTime > '2025-11-01 00:00:31.000' AND IsRefund <= 1 AND status = 'NOT_SHIPPED' AND LEN( ProductName ) > 0 AND SupplierId not in (86,10,105,86)", startMonthDate, endMonthDate);
  11649. DataTable deliveryData = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11650. data.Merge(deliveryData);
  11651. //不干胶-----1,卡片-----29
  11652. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11653. foreach (DataRow row in data.Rows)
  11654. {
  11655. int productId = Convert.ToInt32(row["ProductId"]);
  11656. string ProductName = row["ProductName"].ToString();
  11657. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11658. if (no_suppliers.Contains(supplierId))
  11659. {
  11660. continue;
  11661. }
  11662. string seller_memo = row["seller_memo"].ToString();
  11663. bool ispj = false;//是否配件单
  11664. bool isfirst = true;//第一个配
  11665. maps.Keys.ForEach(key =>
  11666. {
  11667. //备注包含配件
  11668. if (seller_memo.Contains(key) && isfirst)
  11669. {
  11670. List<string> list = maps[key];
  11671. ispj = true;
  11672. isfirst = false;
  11673. for (int i = 0; i < list.Count; i++)
  11674. {
  11675. if (seller_memo.Contains(list[i]))
  11676. {
  11677. ispj = false;
  11678. break;
  11679. }
  11680. }
  11681. }
  11682. });
  11683. if (ispj)
  11684. {
  11685. continue;
  11686. }
  11687. seller_memo = seller_memo.Replace("UV", "uv");
  11688. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11689. //吊牌归到卡片
  11690. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11691. seller_memo = seller_memo.Replace("卡套", "卡片");
  11692. seller_memo = seller_memo.Replace("封套", "卡片");
  11693. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11694. seller_memo = seller_memo.Replace("腰封", "卡片");
  11695. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11696. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11697. seller_memo = seller_memo.Replace("横幅", "条幅");
  11698. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11699. string map_key = "";
  11700. string type = "";
  11701. if (supplierMap.ContainsKey(supplierId))
  11702. {
  11703. foreach (var kvp in supplierMap[supplierId])
  11704. {
  11705. if (seller_memo.Contains(kvp.Key))
  11706. {
  11707. map_key = kvp.Value;
  11708. type = kvp.Value;
  11709. break;
  11710. }
  11711. }
  11712. }
  11713. if (map_key == "")
  11714. {
  11715. type = ProductName;
  11716. map_key = ProductName;
  11717. if (smSupplier.Contains(supplierId))
  11718. {
  11719. type = "数码";
  11720. map_key = "数码";
  11721. }
  11722. }
  11723. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11724. {
  11725. map_key = suppliers[supplierId];
  11726. }
  11727. map_key += "_" + row["SupplierName"].ToString();
  11728. Dictionary<string, int> map = null;
  11729. if (other_map.ContainsKey(map_key))
  11730. {
  11731. other_map.TryGetValue(map_key, out map);
  11732. }
  11733. else
  11734. {
  11735. map = new Dictionary<string, int>();
  11736. map.Add("dayDev", 0);//当天出货
  11737. map.Add("dayTotal", 0);//下单总数
  11738. map.Add("payTotal", 0);//500以上
  11739. map.Add("today", 0);//当天出货数量
  11740. map.Add("unusua", 0);//异常数
  11741. map.Add("aftersale", 0);//异常数
  11742. map.Add("deliveryNum", 0);//待发货数
  11743. other_map.Add(map_key, map);
  11744. other_map.TryGetValue(map_key, out map);
  11745. }
  11746. int afterSaleState = Convert.ToInt32(row["AfterSaleState"]);
  11747. int delivery = Convert.ToInt32(row["delivery"]);
  11748. if (afterSaleState == 0 && delivery == 0)
  11749. {
  11750. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11751. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11752. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11753. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11754. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11755. {
  11756. map["dayTotal"]++;
  11757. if (supplierId == 97)
  11758. {
  11759. supplierId = 97;
  11760. }
  11761. }
  11762. if (Convert.ToDecimal(row["payment"]) >= 500)
  11763. {
  11764. map["payTotal"]++;
  11765. }
  11766. bool istoday = false;
  11767. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11768. {
  11769. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11770. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11771. {
  11772. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11773. {
  11774. map["today"]++;
  11775. }
  11776. }
  11777. else
  11778. {
  11779. if (supplierId == 80 || supplierId == 126)
  11780. {
  11781. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11782. {
  11783. map["today"]++;
  11784. }
  11785. }
  11786. else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11787. {
  11788. map["today"]++;
  11789. istoday = true;
  11790. }
  11791. }
  11792. }
  11793. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11794. {
  11795. map["unusua"]++;
  11796. }
  11797. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11798. //GD-CYT-----64
  11799. DateTime two = palceTimeStart.AddHours(14);
  11800. DateTime three = palceTimeStart.AddHours(15);
  11801. DateTime four = palceTimeStart.AddHours(16);
  11802. DateTime six = palceTimeStart.AddHours(18);
  11803. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11804. {
  11805. //下午四点前 500-1000
  11806. string count = row["ProductCount"].ToString();
  11807. if (count != null && count.Length > 0)
  11808. {
  11809. int productCount = commonHelper.getPlaceProductCount(count);
  11810. if (productCount >= 500 && productCount <= 1000)
  11811. {
  11812. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11813. {
  11814. map["dayDev"]++;
  11815. }
  11816. }
  11817. }
  11818. }
  11819. //UV
  11820. else if ("uv".Equals(type))
  11821. {
  11822. //ZT----70
  11823. //ZHX----3
  11824. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11825. {
  11826. map["dayDev"]++;
  11827. }
  11828. //JK----97
  11829. //HZX----105
  11830. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11831. {
  11832. map["dayDev"]++;
  11833. }
  11834. if (DateTime.Compare(FinishPlaceTime, six) < 0 && (supplierId == 126))
  11835. {
  11836. map["dayDev"]++;
  11837. }
  11838. }
  11839. //帆布---52|条幅---27
  11840. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11841. {
  11842. //LHCY-----98
  11843. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11844. {
  11845. map["dayDev"]++;
  11846. }
  11847. }
  11848. //条幅
  11849. else if ("条幅".Equals(type))
  11850. {
  11851. //XD-----90
  11852. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11853. {
  11854. map["dayDev"]++;
  11855. }
  11856. }
  11857. //桌布
  11858. else if ("桌布".Equals(type))
  11859. {
  11860. //XD-----90
  11861. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11862. {
  11863. map["dayDev"]++;
  11864. }
  11865. }
  11866. //DL---10
  11867. //AYTW---119
  11868. //FS-CYT-DY ----80
  11869. //JK----97
  11870. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11871. {
  11872. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11873. {
  11874. map["dayDev"]++;
  11875. if (supplierId == 80 && istoday)
  11876. {
  11877. Debug.WriteLine(seller_memo);
  11878. }
  11879. }
  11880. }
  11881. // QC---121
  11882. else if (supplierId == 121)
  11883. {
  11884. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11885. {
  11886. map["dayDev"]++;
  11887. }
  11888. }
  11889. }
  11890. else if (delivery == 0)
  11891. {
  11892. if (row["AfterSaleReason"].ToString().Contains("车间责任"))
  11893. {
  11894. map["aftersale"]++;
  11895. }
  11896. }
  11897. else
  11898. {
  11899. map["deliveryNum"]++;
  11900. }
  11901. }
  11902. DataTable dt = new DataTable();
  11903. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11904. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11905. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11906. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11907. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11908. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11909. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11910. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11911. dt.Columns.Add(new DataColumn("aftersale", typeof(string)));
  11912. dt.Columns.Add(new DataColumn("deliveryNum", typeof(string)));
  11913. other_map.Keys.ForEach(key =>
  11914. {
  11915. DataRow dr = dt.NewRow();
  11916. Dictionary<string, int> map = other_map[key];
  11917. string[] key_list = key.Split('_');
  11918. dr[0] = key_list[0];
  11919. dr[1] = key_list[1];
  11920. if (key_list.Length > 2)
  11921. {
  11922. dr[1] += "(" + key_list[2] + ")";
  11923. }
  11924. dr[2] = map["dayTotal"];
  11925. dr[3] = map["payTotal"];
  11926. dr[4] = map["today"];
  11927. dr[5] = map["unusua"];
  11928. dr[6] = map["dayDev"];
  11929. double rate = 0.00;
  11930. if (map["dayDev"] > 0)
  11931. {
  11932. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11933. }
  11934. dr[7] = rate.ToString();
  11935. dr[8] = map["aftersale"];
  11936. dr[9] = map["deliveryNum"];
  11937. dt.Rows.Add(dr);
  11938. });
  11939. DataView dv = new DataView(dt);
  11940. dv.Sort = "SupplierName";
  11941. //dv.Sort = "ProductName desc";
  11942. DataTable dtNew = dv.ToTable();
  11943. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11944. }
  11945. public void check_order_desing_info()
  11946. {
  11947. string ctid = GetPostString("ctid");
  11948. if (!string.IsNullOrEmpty(ctid))
  11949. {
  11950. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11951. if (ceErpTradeCell != null)
  11952. {
  11953. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11954. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11955. return;
  11956. }
  11957. returnErrorMsg("找不到订单");
  11958. return;
  11959. }
  11960. returnErrorMsg("找不到订单");
  11961. }
  11962. public void get_timeout_detail()
  11963. {
  11964. string poscode = CurrentUser.UserPost.Post.Code;
  11965. DataStruct dStruct = GetPostStruct();
  11966. List<string> lw = new List<string>();
  11967. string id = GetPostString("id");
  11968. string pay_date1 = GetPostString("pay_date1");
  11969. string pay_date2 = GetPostString("pay_date2");
  11970. int type = GetPostInt("type");
  11971. if (type == 0)
  11972. {
  11973. if (pay_date1.Length > 0)
  11974. {
  11975. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11976. }
  11977. if (pay_date2.Length > 0)
  11978. {
  11979. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11980. }
  11981. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11982. }
  11983. if (type == 1)
  11984. {
  11985. if (pay_date1.Length > 0)
  11986. {
  11987. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11988. }
  11989. if (pay_date2.Length > 0)
  11990. {
  11991. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11992. }
  11993. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11994. }
  11995. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11996. DataTable dt = null;
  11997. dt = WebCache.GetData("view_orderlist", dStruct);
  11998. writeGridDataTableJson(dStruct.TotalCount, dt);
  11999. }
  12000. public void saveUrgentChargePrice()
  12001. {
  12002. string ctid = GetPostString("ctid");
  12003. if (!string.IsNullOrEmpty(ctid))
  12004. {
  12005. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12006. if (ceErpTradeCell != null)
  12007. {
  12008. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  12009. if (prices <= 100)
  12010. {
  12011. returnErrorMsg("此订单金额不足100元,无法加急。");
  12012. return;
  12013. }
  12014. double price = GetPostDouble("price");
  12015. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  12016. if (ceErpTradeCellExtend == null)
  12017. {
  12018. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12019. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  12020. }
  12021. ceErpTradeCellExtend.urgentCharge = price;
  12022. if (ceErpTradeCellExtend.ID > 0)
  12023. {
  12024. ceErpTradeCellExtend.Update();
  12025. }
  12026. else
  12027. {
  12028. ceErpTradeCellExtend.Save();
  12029. }
  12030. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  12031. returnSuccessMsg("修改成功!");
  12032. return;
  12033. }
  12034. returnErrorMsg("找不到订单");
  12035. return;
  12036. }
  12037. returnErrorMsg("找不到订单");
  12038. }
  12039. public void finish_erp_order()
  12040. {
  12041. string ctid = GetPostString("ctid");
  12042. if (!string.IsNullOrEmpty(ctid))
  12043. {
  12044. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  12045. {
  12046. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12047. if (ceErpTradeCell != null)
  12048. {
  12049. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  12050. ceErpTradeCell.Update();
  12051. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  12052. returnSuccessMsg("修改成功!");
  12053. return;
  12054. }
  12055. }
  12056. }
  12057. returnErrorMsg("找不到订单");
  12058. }
  12059. public void get_trade_order_list()
  12060. {
  12061. string tid = GetPostString("tid");
  12062. if (!string.IsNullOrEmpty(tid))
  12063. {
  12064. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  12065. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12066. writeGridDataTableJson(data.Rows.Count, data);
  12067. return;
  12068. }
  12069. returnErrorMsg("找不到订单");
  12070. }
  12071. public void save_cell_spu()
  12072. {
  12073. string ctid = GetPostString("ctid");
  12074. string spu_id = GetPostString("spu_id");
  12075. if (!string.IsNullOrEmpty(ctid))
  12076. {
  12077. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12078. if (ceErpTradeCellExtend == null)
  12079. {
  12080. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12081. ceErpTradeCellExtend.ctid = ctid;
  12082. }
  12083. ceErpTradeCellExtend.spu_id = spu_id;
  12084. if (!string.IsNullOrEmpty(spu_id))
  12085. {
  12086. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12087. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  12088. }
  12089. if (ceErpTradeCellExtend.ID == 0)
  12090. {
  12091. ceErpTradeCellExtend.Create();
  12092. }
  12093. else
  12094. {
  12095. ceErpTradeCellExtend.Update();
  12096. }
  12097. returnSuccessMsg("修改成功!");
  12098. return;
  12099. }
  12100. returnErrorMsg("找不到订单");
  12101. }
  12102. public void change_express_info()
  12103. {
  12104. string ctid = GetPostString("ctid");
  12105. string transNo = GetPostString("transNo");
  12106. string transCom = GetPostString("transCom");
  12107. if (!string.IsNullOrEmpty(ctid))
  12108. {
  12109. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12110. if (ceErpTradeCellExtend == null)
  12111. {
  12112. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12113. ceErpTradeCellExtend.ctid = ctid;
  12114. }
  12115. ceErpTradeCellExtend.modExpressNo = transNo;
  12116. ceErpTradeCellExtend.modExpressCom = transCom;
  12117. ceErpTradeCellExtend.readMod = 2;
  12118. if (ceErpTradeCellExtend.ID == 0)
  12119. {
  12120. ceErpTradeCellExtend.Create();
  12121. }
  12122. else
  12123. {
  12124. ceErpTradeCellExtend.Update();
  12125. }
  12126. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  12127. returnSuccessMsg("修改成功!");
  12128. return;
  12129. }
  12130. returnErrorMsg("找不到订单");
  12131. }
  12132. public void get_change_express_list()
  12133. {
  12134. DataStruct dStruct = GetPostStruct();
  12135. List<string> lw = new List<string>();
  12136. int st = 2;
  12137. string tid = GetPostString("ctid");
  12138. if (tid.Length > 0)
  12139. {
  12140. string select_tid = getTidByCtid(tid);
  12141. lw.Add(string.Format("tid='{0}'", select_tid));
  12142. }
  12143. string shopname = GetPostString("shopname");
  12144. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12145. string buyernick = GetPostString("buyer_nick");
  12146. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12147. string sellermemo = GetPostString("seller_memo");
  12148. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12149. string supplier = GetPostString("supplier");
  12150. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12151. string customer = GetPostString("customer");
  12152. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12153. string design = GetPostString("design");
  12154. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12155. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12156. string poscode = CurrentUser.UserPost.Post.Code;
  12157. if (poscode != "SysAdmin")
  12158. {
  12159. string shopid = CurrentUser.User.pemShop;
  12160. lw.Add(string.Format("shopId in ({0})", shopid));
  12161. }
  12162. lw.Add("readMod = 2");
  12163. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12164. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  12165. writeGridDataTableJson(dStruct.TotalCount, dt);
  12166. }
  12167. public void deal_express_complete()
  12168. {
  12169. string ctid = GetPostString("ctid");
  12170. if (!string.IsNullOrEmpty(ctid))
  12171. {
  12172. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12173. if (ceErpTradeCellExtend == null)
  12174. {
  12175. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12176. ceErpTradeCellExtend.ctid = ctid;
  12177. }
  12178. ceErpTradeCellExtend.readMod = 1;
  12179. if (ceErpTradeCellExtend.ID == 0)
  12180. {
  12181. ceErpTradeCellExtend.Create();
  12182. }
  12183. else
  12184. {
  12185. ceErpTradeCellExtend.Update();
  12186. }
  12187. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  12188. returnSuccessMsg("修改成功!");
  12189. return;
  12190. }
  12191. returnErrorMsg("找不到订单");
  12192. }
  12193. public void aftersale_return_visit()
  12194. {
  12195. string ctid = GetPostString("ctid");
  12196. if (!string.IsNullOrEmpty(ctid))
  12197. {
  12198. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12199. if (ceErpTradeCellExtend == null)
  12200. {
  12201. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12202. ceErpTradeCellExtend.ctid = ctid;
  12203. }
  12204. ceErpTradeCellExtend.returnVisit = 1;
  12205. if (ceErpTradeCellExtend.ID == 0)
  12206. {
  12207. ceErpTradeCellExtend.Create();
  12208. }
  12209. else
  12210. {
  12211. ceErpTradeCellExtend.Update();
  12212. }
  12213. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12214. if (ceErpTradeAfterSaleExtend != null)
  12215. {
  12216. ceErpTradeAfterSaleExtend.TextResult = "";
  12217. ceErpTradeAfterSaleExtend.Update();
  12218. }
  12219. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  12220. returnSuccessMsg("修改成功!");
  12221. return;
  12222. }
  12223. returnErrorMsg("找不到订单");
  12224. }
  12225. public void orderPlaceInfo()
  12226. {
  12227. string ctids = GetPostString("ctids");
  12228. string[] list = ctids.Split(',');
  12229. foreach (string ctid in list)
  12230. {
  12231. CeErpSukuraData.createInfo(ctid, 3);
  12232. }
  12233. StringBuilder sql = new StringBuilder();
  12234. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  12235. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  12236. designHelper.api_approveDesign(ctids); //approveDesign
  12237. returnSuccessMsg("");
  12238. }
  12239. public void get_issue_list()
  12240. {
  12241. DataStruct dStruct = GetPostStruct();
  12242. List<string> lw = new List<string>();
  12243. int st = 2;
  12244. string tid = GetPostString("ctid");
  12245. if (tid.Length > 0)
  12246. {
  12247. string select_tid = getTidByCtid(tid);
  12248. lw.Add(string.Format("tid='{0}'", select_tid));
  12249. }
  12250. string shopname = GetPostString("shopname");
  12251. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12252. string buyernick = GetPostString("buyer_nick");
  12253. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12254. string sellermemo = GetPostString("seller_memo");
  12255. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12256. string supplier = GetPostString("supplier");
  12257. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12258. string customer = GetPostString("customer");
  12259. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12260. string design = GetPostString("design");
  12261. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12262. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12263. string poscode = CurrentUser.UserPost.Post.Code;
  12264. if (poscode != "SysAdmin")
  12265. {
  12266. string shopid = CurrentUser.User.pemShop;
  12267. lw.Add(string.Format("shopId in ({0})", shopid));
  12268. }
  12269. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12270. {
  12271. lw.Add("IssueState = 1");
  12272. }
  12273. else
  12274. {
  12275. string iisstate = GetPostString("iisstate");
  12276. if ("1".Equals(iisstate))
  12277. {
  12278. lw.Add("IssueState =1");
  12279. }
  12280. else if ("2".Equals(iisstate))
  12281. {
  12282. lw.Add("IssueState = 2");
  12283. }
  12284. else
  12285. {
  12286. lw.Add("IssueState > 0");
  12287. }
  12288. }
  12289. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12290. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12291. writeGridDataTableJson(dStruct.TotalCount, dt);
  12292. }
  12293. public void saveIssueContent()
  12294. {
  12295. string ctid = GetPostString("ctid");
  12296. if (!string.IsNullOrEmpty(ctid))
  12297. {
  12298. string content = GetPostString("content");
  12299. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12300. if (ceErpTradeAfterSaleExtend == null)
  12301. {
  12302. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12303. ceErpTradeAfterSaleExtend.tid = ctid;
  12304. }
  12305. ceErpTradeAfterSaleExtend.IssueContent = content;
  12306. ceErpTradeAfterSaleExtend.IssueState = 1;
  12307. if (ceErpTradeAfterSaleExtend.ID > 0)
  12308. {
  12309. ceErpTradeAfterSaleExtend.Update();
  12310. }
  12311. else
  12312. {
  12313. ceErpTradeAfterSaleExtend.Create();
  12314. }
  12315. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12316. returnSuccessMsg("添加成功!");
  12317. return;
  12318. }
  12319. returnErrorMsg("找不到订单");
  12320. }
  12321. public void dealIssueContent()
  12322. {
  12323. string ctid = GetPostString("ctid");
  12324. if (!string.IsNullOrEmpty(ctid))
  12325. {
  12326. string content = GetPostString("content");
  12327. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12328. if (ceErpTradeAfterSaleExtend != null)
  12329. {
  12330. ceErpTradeAfterSaleExtend.IssueState = 2;
  12331. ceErpTradeAfterSaleExtend.Update();
  12332. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12333. returnSuccessMsg("修改完成!");
  12334. return;
  12335. }
  12336. }
  12337. returnErrorMsg("找不到订单");
  12338. }
  12339. public void set_tid_attachments()
  12340. {
  12341. string tid = GetPostString("tid");
  12342. string atta = GetPostString("atta");
  12343. if (!string.IsNullOrEmpty(tid))
  12344. {
  12345. if (string.IsNullOrEmpty(atta))
  12346. {
  12347. returnErrorMsg("文件地址为空");
  12348. return;
  12349. }
  12350. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12351. if (ceErpTradeCell != null)
  12352. {
  12353. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12354. if (ceErpTrade == null)
  12355. {
  12356. returnErrorMsg("找不到订单");
  12357. return;
  12358. }
  12359. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12360. bool isSend = false;
  12361. if (dt != null && dt.Rows.Count > 0)
  12362. {
  12363. foreach (DataRow row in dt.Rows)
  12364. {
  12365. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12366. {
  12367. isSend = true;
  12368. }
  12369. }
  12370. if (isSend)
  12371. {
  12372. returnErrorMsg("已发货无法修改");
  12373. return;
  12374. }
  12375. ceErpTrade.Attachments = atta;
  12376. ceErpTrade.Update();
  12377. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12378. returnSuccessMsg("上传成功!");
  12379. return;
  12380. }
  12381. }
  12382. }
  12383. returnErrorMsg("找不到订单");
  12384. }
  12385. public void get_tid_attachments()
  12386. {
  12387. string tid = GetPostString("tid");
  12388. if (!string.IsNullOrEmpty(tid))
  12389. {
  12390. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12391. if (ceErpTradeCell != null)
  12392. {
  12393. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12394. if (ceErpTrade == null)
  12395. {
  12396. returnErrorMsg("找不到订单");
  12397. return;
  12398. }
  12399. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12400. return;
  12401. }
  12402. }
  12403. returnErrorMsg("找不到订单");
  12404. }
  12405. public void check_erp_sameorders()
  12406. {
  12407. if (UrlPostParmsCheck("ctid"))
  12408. {
  12409. string eid = GetPostString("ctid");
  12410. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12411. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12412. if (entity != null && ceErpTrade != null)
  12413. {
  12414. if (entity.OrderState > 6)
  12415. {
  12416. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12417. return;
  12418. }
  12419. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12420. List<string> ids = new List<string>();
  12421. if (dt != null && dt.Rows.Count > 1)
  12422. {
  12423. bool needhe = true;
  12424. foreach (DataRow dr in dt.Rows)
  12425. {
  12426. ids.Add("'" + dr["ctid"] + "'");
  12427. /* //备注有合包
  12428. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12429. {
  12430. needhe = true;
  12431. }
  12432. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12433. {
  12434. needhe = true;
  12435. }
  12436. //顺丰快递
  12437. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12438. {
  12439. needhe = true;
  12440. }*/
  12441. }
  12442. if (!needhe)
  12443. {
  12444. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12445. return;
  12446. }
  12447. StringBuilder sql = new StringBuilder();
  12448. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12449. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12450. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12451. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12452. foreach (DataRow dr in dt.Rows)
  12453. {
  12454. dr["dstate"] = 0;
  12455. dr["dnumber"] = 0;
  12456. foreach (DataRow row in dt1.Rows)
  12457. {
  12458. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12459. {
  12460. dr["dstate"] = 2;
  12461. dr["default"] = 1;
  12462. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12463. }
  12464. }
  12465. if (eid.Equals(dr["ctid"].ToString()))
  12466. {
  12467. dr["dstate"] = 1;
  12468. dr["default"] = 1;
  12469. }
  12470. }
  12471. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12472. return;
  12473. }
  12474. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12475. return;
  12476. }
  12477. returnErrorMsg("未找到订单");
  12478. return;
  12479. }
  12480. returnErrorMsg("缺少必要的参数");
  12481. }
  12482. public void get_mark_number()
  12483. {
  12484. string eid = GetPostString("ctid");
  12485. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12486. if (entity != null)
  12487. {
  12488. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12489. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12490. int current = 1;
  12491. if (ceErpDeliverMark == null)
  12492. {
  12493. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12494. List<string> ids = new List<string>();
  12495. if (dt != null && dt.Rows.Count > 1)
  12496. {
  12497. foreach (DataRow dr in dt.Rows)
  12498. {
  12499. ids.Add("'" + dr["ctid"] + "'");
  12500. }
  12501. //查询已有的编号
  12502. StringBuilder sql = new StringBuilder();
  12503. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12504. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12505. if (dt1 == null || dt1.Rows.Count == 0)
  12506. {
  12507. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12508. List<int> list_number = new List<int>();
  12509. foreach (DataRow row in numbers.Rows)
  12510. {
  12511. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12512. }
  12513. //查询空余编号
  12514. for (int i = 0; i < list_number.Count + 2; i++)
  12515. {
  12516. if (!list_number.Contains(current))
  12517. {
  12518. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12519. //防止查询过程中有新数据生成
  12520. if (ceErpDeliverMark1 == null)
  12521. {
  12522. break;
  12523. }
  12524. }
  12525. current++;
  12526. }
  12527. }
  12528. else
  12529. {
  12530. foreach (DataRow row in dt1.Rows)
  12531. {
  12532. current = Convert.ToInt32(row["markNumber"]);
  12533. }
  12534. }
  12535. ceErpDeliverMark = new CeErpDeliverMark();
  12536. ceErpDeliverMark.ctid = eid;
  12537. ceErpDeliverMark.createtime = DateTime.Now;
  12538. if (ceErpTrade != null)
  12539. {
  12540. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12541. }
  12542. ceErpDeliverMark.markNumber = current;
  12543. ceErpDeliverMark.Create();
  12544. }
  12545. }
  12546. else
  12547. {
  12548. current = ceErpDeliverMark.markNumber;
  12549. }
  12550. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12551. return;
  12552. }
  12553. }
  12554. public void aftersaleCytSend()
  12555. {
  12556. string ctid = GetPostString("ctid");
  12557. if (!string.IsNullOrEmpty(ctid))
  12558. {
  12559. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12560. if (ceErpTradeCell != null)
  12561. {
  12562. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12563. }
  12564. returnSuccessMsg("推送成功");
  12565. return;
  12566. }
  12567. returnErrorMsg("缺少必要的参数");
  12568. }
  12569. public void packOrderInfo()
  12570. {
  12571. string ctids = GetPostString("ctids");
  12572. if (!string.IsNullOrEmpty(ctids))
  12573. {
  12574. string[] ctid_list = ctids.Split(',');
  12575. if (ctid_list.Length > 20)
  12576. {
  12577. returnErrorMsg("单次下载次数不能超过20个");
  12578. return;
  12579. }
  12580. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12581. StringBuilder sql = new StringBuilder();
  12582. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12583. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12584. int supplierId = 0;
  12585. StringBuilder insterSql = new StringBuilder();
  12586. for (int i = 0; i < dt.Rows.Count; i++)
  12587. {
  12588. DataRow row = dt.Rows[i];
  12589. if (i == 0)
  12590. {
  12591. supplierId = Convert.ToInt32(row["SupplierId"]);
  12592. }
  12593. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12594. {
  12595. returnErrorMsg("同车间的订单才能一起打包");
  12596. return;
  12597. }
  12598. int orderState = Convert.ToInt32(row["OrderState"]);
  12599. if (orderState != 5)
  12600. {
  12601. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12602. return;
  12603. }
  12604. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12605. }
  12606. CeErpPackData ceErpPackData = new CeErpPackData();
  12607. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12608. ceErpPackData.supplierId = supplierId;
  12609. ceErpPackData.createtime = DateTime.Now;
  12610. ceErpPackData.createBy = CurrentUser.UserID;
  12611. ceErpPackData.createName = CurrentUser.UserName;
  12612. ceErpPackData.Create();
  12613. if (ceErpPackData.ID > 0)
  12614. {
  12615. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12616. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12617. }
  12618. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12619. returnSuccessMsg("打包成功");
  12620. return;
  12621. }
  12622. returnErrorMsg("缺少必要的参数");
  12623. }
  12624. public void rePackOrderInfo()
  12625. {
  12626. string id = GetPostString("id");
  12627. if (!string.IsNullOrEmpty(id))
  12628. {
  12629. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12630. if (ceErpPackData == null)
  12631. {
  12632. returnSuccessMsg("查无数据");
  12633. return;
  12634. }
  12635. ceErpPackData.upStatus = 0;
  12636. ceErpPackData.message = "";
  12637. ceErpPackData.Update();
  12638. returnSuccessMsg("打包成功");
  12639. return;
  12640. }
  12641. returnErrorMsg("缺少必要的参数");
  12642. }
  12643. public void backPackOrderInfo()
  12644. {
  12645. string id = GetPostString("id");
  12646. if (!string.IsNullOrEmpty(id))
  12647. {
  12648. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12649. if (ceErpPackData == null)
  12650. {
  12651. returnSuccessMsg("查无数据");
  12652. return;
  12653. }
  12654. ceErpPackData.upStatus = 4;
  12655. ceErpPackData.Update();
  12656. List<string> list = new List<string>();
  12657. StringBuilder sql = new StringBuilder();
  12658. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12659. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12660. for (int i = 0; i < dt.Rows.Count; i++)
  12661. {
  12662. DataRow row = dt.Rows[i];
  12663. list.Add("'" + row["ctid"].ToString() + "'");
  12664. }
  12665. string textCtids = string.Join(",", list);
  12666. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=5,IsVerifyToSupplier=0,IsReturn=1,ReturnTime=GETDATE(),ReturnReason='无法打包' where ctid in ({0}) and OrderState=6", textCtids));
  12667. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", textCtids, (int)OrderState.下单完成, 0, "无法打包退回"));
  12668. returnSuccessMsg("退回成功");
  12669. return;
  12670. }
  12671. returnErrorMsg("缺少必要的参数");
  12672. }
  12673. public void addPackDownNum()
  12674. {
  12675. string id = GetPostString("id");
  12676. if (!string.IsNullOrEmpty(id))
  12677. {
  12678. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12679. returnSuccessMsg("下载成功");
  12680. return;
  12681. }
  12682. returnErrorMsg("缺少必要的参数");
  12683. }
  12684. public void get_pack_list()
  12685. {
  12686. DataStruct dStruct = GetPostStruct();
  12687. List<string> lw = new List<string>();
  12688. string supplier = GetPostString("supplier");
  12689. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12690. string posTag = CurrentUser.UserPost.Post.Code;
  12691. if (posTag == "Supplier")
  12692. {
  12693. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12694. }
  12695. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12696. dStruct.Order = "createtime desc";
  12697. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12698. writeGridDataTableJson(dStruct.TotalCount, dt);
  12699. }
  12700. public void get_pack_order_list()
  12701. {
  12702. string packId = GetPostString("packId");
  12703. if (string.IsNullOrEmpty(packId))
  12704. {
  12705. returnErrorMsg("缺少必要的参数");
  12706. return;
  12707. }
  12708. StringBuilder sql = new StringBuilder();
  12709. sql.AppendFormat("select c.ctid,c.seller_memo,i.message from CE_ErpPackDataItem i left join CE_ErpTradeCell c on i.ctid=c.ctid where i.packId = {0}", packId);
  12710. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12711. if (dt == null || dt.Rows.Count == 0)
  12712. {
  12713. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12714. return;
  12715. }
  12716. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12717. return;
  12718. }
  12719. public void get_supplier_product_time_list()
  12720. {
  12721. DataStruct dStruct = GetPostStruct();
  12722. List<string> lw = new List<string>();
  12723. string txtKey = GetPostString("txtKey");
  12724. if (txtKey.Length > 0)
  12725. {
  12726. lw.Add(string.Format("(supplierName = '{0}' or productName like '%{0}%')", txtKey));
  12727. }
  12728. string posTag = CurrentUser.UserPost.Post.Code;
  12729. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12730. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12731. writeGridDataTableJson(dStruct.TotalCount, dt);
  12732. }
  12733. public void saveSupplierProductTime()
  12734. {
  12735. string productId = GetPostString("productId");
  12736. if (string.IsNullOrEmpty(productId))
  12737. {
  12738. returnErrorMsg("缺少必要的参数");
  12739. return;
  12740. }
  12741. string productName = GetPostString("productName");
  12742. int supplierId = GetPostInt("supplierId");
  12743. if (supplierId == 0)
  12744. {
  12745. returnErrorMsg("缺少必要的参数");
  12746. return;
  12747. }
  12748. int quantity = GetPostInt("quantity");
  12749. int sendDay = GetPostInt("sendTime");
  12750. string supplierName = GetPostString("supplierName");
  12751. string craft = GetPostString("craft");
  12752. string deadLine = GetPostString("deadLine");
  12753. string dayDeadLine = GetPostString("dayDeadLine");
  12754. try
  12755. {
  12756. int eid = GetPostInt("eid");
  12757. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12758. if (ceErpSupplierProductTime == null)
  12759. {
  12760. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12761. }
  12762. ceErpSupplierProductTime.productId = productId;
  12763. ceErpSupplierProductTime.productName = productName;
  12764. ceErpSupplierProductTime.supplierId = supplierId;
  12765. ceErpSupplierProductTime.supplierName = supplierName;
  12766. ceErpSupplierProductTime.craft = craft;
  12767. ceErpSupplierProductTime.sendDay = sendDay;
  12768. ceErpSupplierProductTime.quantity = quantity;
  12769. if (!string.IsNullOrEmpty(deadLine))
  12770. {
  12771. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12772. }
  12773. if (!string.IsNullOrEmpty(dayDeadLine))
  12774. {
  12775. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12776. }
  12777. if (ceErpSupplierProductTime.ID == 0)
  12778. {
  12779. ceErpSupplierProductTime.Save();
  12780. }
  12781. else
  12782. {
  12783. ceErpSupplierProductTime.Update();
  12784. }
  12785. }
  12786. catch (Exception e)
  12787. {
  12788. }
  12789. returnSuccessMsg("保存成功");
  12790. return;
  12791. }
  12792. public void delSupplierProductTime()
  12793. {
  12794. int eid = GetPostInt("eid");
  12795. if (eid > 0)
  12796. {
  12797. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12798. if (ceErpSupplierProductTime == null)
  12799. {
  12800. returnErrorMsg("查无数据");
  12801. return;
  12802. }
  12803. ceErpSupplierProductTime.Delete();
  12804. returnSuccessMsg("保存成功");
  12805. return;
  12806. }
  12807. returnErrorMsg("缺少必要的参数");
  12808. }
  12809. public void getExpressInfo()
  12810. {
  12811. string ctid = GetPostString("ctid");
  12812. if (!string.IsNullOrEmpty(ctid))
  12813. {
  12814. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12815. if (ceErpTradeCell != null)
  12816. {
  12817. string outSid = ceErpTradeCell.OutSid;
  12818. if (outSid.Length > 0)
  12819. {
  12820. string sql = string.Format("SELECT out_sid FROM [dbo].[CE_ErpExpressInfo] WHERE (out_sid in ({0}) or tid = '{1}') and ISNULL(DATALENGTH(postData), 0)>0;", "'" + outSid.Replace(",", "','") + "'", ceErpTradeCell.tid);
  12821. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12822. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12823. return;
  12824. }
  12825. }
  12826. returnErrorMsg("查无记录");
  12827. return;
  12828. }
  12829. returnErrorMsg("缺少必要的参数");
  12830. }
  12831. public void getExpressPostData()
  12832. {
  12833. string express = GetPostString("express");
  12834. if (!string.IsNullOrEmpty(express))
  12835. {
  12836. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12837. if (ceErpExpressInfo != null)
  12838. {
  12839. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12840. return;
  12841. }
  12842. }
  12843. returnErrorMsg("缺少必要的参数");
  12844. }
  12845. public void checkSupplierOrder()
  12846. {
  12847. string ctids = GetPostString("ctids");
  12848. if (ctids != null)
  12849. {
  12850. List<string> list = new List<string>();
  12851. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12852. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12853. for (int i = 0; i < dt.Rows.Count; i++)
  12854. {
  12855. DataRow row = dt.Rows[i];
  12856. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12857. {
  12858. continue;
  12859. }
  12860. list.Add(row["seller_memo"].ToString());
  12861. }
  12862. if (list.Count > 0)
  12863. {
  12864. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", "'" + ctids.Replace(",", "','") + "'", (int)OrderState.下单完成, CurrentUser.UserID, "点击下载按钮"));
  12865. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12866. return;
  12867. }
  12868. }
  12869. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12870. return;
  12871. }
  12872. public void addPersonId()
  12873. {
  12874. string tid = GetPostString("tid");
  12875. string personId = GetPostString("personId");
  12876. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12877. if (ceErpTrade != null)
  12878. {
  12879. ceErpTrade.receiver_zip = personId;
  12880. ceErpTrade.Update();
  12881. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12882. returnSuccessMsg("保存成功");
  12883. return;
  12884. }
  12885. returnErrorMsg("缺少必要的参数");
  12886. }
  12887. public void addDeliveryPaymant()
  12888. {
  12889. string tid = GetPostString("tid");
  12890. string paymant = GetPostString("paymant");
  12891. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12892. if (ceErpTrade != null)
  12893. {
  12894. if (!string.IsNullOrEmpty(paymant))
  12895. {
  12896. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12897. }
  12898. ceErpTrade.Update();
  12899. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12900. returnSuccessMsg("保存成功");
  12901. return;
  12902. }
  12903. returnErrorMsg("缺少必要的参数");
  12904. }
  12905. public void saveCellFile()
  12906. {
  12907. string tid = GetPostString("tid");
  12908. string ctid = GetPostString("ctid");
  12909. string urls = GetPostString("urls");
  12910. string type = GetPostString("type");
  12911. string del = GetPostString("del");
  12912. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12913. {
  12914. if (tradeCellFile == TradeCellFile.AUTH_FILE)
  12915. {
  12916. ctid = tid;
  12917. }
  12918. if ("1".Equals(del))
  12919. {
  12920. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12921. }
  12922. string[] list = urls.Split(',');
  12923. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12924. {
  12925. foreach (string item in list)
  12926. {
  12927. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12928. ceErpTradeCellFile.Create();
  12929. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12930. }
  12931. }
  12932. returnSuccessMsg("保存成功");
  12933. return;
  12934. }
  12935. returnErrorMsg("缺少必要的参数");
  12936. }
  12937. public void getCellFile()
  12938. {
  12939. string tid = GetPostString("tid");
  12940. string ctid = GetPostString("ctid");
  12941. string type = GetPostString("type");
  12942. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12943. {
  12944. if (tradeCellFile == TradeCellFile.AUTH_FILE)
  12945. {
  12946. ctid = tid;
  12947. }
  12948. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12949. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12950. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12951. return;
  12952. }
  12953. returnErrorMsg("缺少必要的参数");
  12954. }
  12955. public void delCellFile()
  12956. {
  12957. string id = GetPostString("id");
  12958. if (string.IsNullOrEmpty(id))
  12959. {
  12960. returnErrorMsg("缺少必要的参数");
  12961. return;
  12962. }
  12963. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12964. CeErpTradeCellFile.delByID(id);
  12965. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12966. returnSuccessMsg("保存成功");
  12967. }
  12968. public void getInvoiceOrder()
  12969. {
  12970. string tid = GetPostString("tid");
  12971. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12972. List<string> tids = new List<string>();
  12973. if (!string.IsNullOrEmpty(ceErpTrade.buyer_nick) && !string.IsNullOrEmpty(ceErpTrade.buyer_id))
  12974. {
  12975. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WHERE buyer_id = '{0}' AND seller_nick = '{1}' order by pay_time desc;", ceErpTrade.buyer_id, ceErpTrade.seller_nick);
  12976. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12977. foreach (DataRow dr in dt.Rows)
  12978. {
  12979. tids.Add("'" + dr["tid"].ToString() + "'");
  12980. }
  12981. }
  12982. else
  12983. {
  12984. tids.Add("'" + ceErpTrade.tid + "'");
  12985. }
  12986. DataTable cell_dt = new DataTable();
  12987. if (tids.Count > 0)
  12988. {
  12989. cell_dt = DbHelper.DbConn.ExecuteDataset(string.Format("SELECT * FROM [dbo].[CE_ErpTradeCell] WHERE tid in ({0});", string.Join(",", tids))).Tables[0];
  12990. }
  12991. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(cell_dt));
  12992. return;
  12993. }
  12994. public void getOrderLogInfo()
  12995. {
  12996. string ctid = GetPostString("ctid");
  12997. if (!string.IsNullOrEmpty(ctid))
  12998. {
  12999. StringBuilder sql = new StringBuilder();
  13000. sql.AppendFormat("select * from view_erptradelog where tid='{0}' order by id;", ctid);
  13001. DataSet ds = DbHelper.DbConn.ExecuteDataset(sql.ToString());
  13002. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(ds.Tables[0])) + "}");
  13003. return;
  13004. }
  13005. returnErrorMsg("缺少必要的参数");
  13006. }
  13007. public void setCellTeampId()
  13008. {
  13009. string ctid = GetPostString("ctid");
  13010. string tempId = GetPostString("tempId");
  13011. if (!string.IsNullOrEmpty(ctid))
  13012. {
  13013. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  13014. if (ceErpTradeCellExtend == null)
  13015. {
  13016. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  13017. ceErpTradeCellExtend.ctid = ctid;
  13018. }
  13019. ceErpTradeCellExtend.tempId = tempId;
  13020. if (ceErpTradeCellExtend.ID > 0)
  13021. {
  13022. ceErpTradeCellExtend.Update();
  13023. }
  13024. else
  13025. {
  13026. ceErpTradeCellExtend.Create();
  13027. }
  13028. designHelper.API_sendTempInfo(ctid, tempId);
  13029. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "修改模板id" + tempId, 6);
  13030. returnSuccessMsg("保存成功");
  13031. return;
  13032. }
  13033. returnErrorMsg("缺少必要的参数");
  13034. }
  13035. }
  13036. }