sync.order.cs 660 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119
  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. namespace SiteCore.Handler
  54. {
  55. public partial class sync
  56. {
  57. public void get_erp_orderlist()
  58. {
  59. string poscode = CurrentUser.UserPost.Post.Code;
  60. DataStruct dStruct = GetPostStruct();
  61. //string a = SecurityHelper.DecryptSymmetric("BnK3+504SQ8=");
  62. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\新建文件夹\\tj21hf.psd");
  63. //apiHelper.Api_SyncOrderByTime("598825");
  64. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  65. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  66. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  67. //banniuApiHelper.sendLogisticsInfo(null);
  68. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  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\":1756945416000,\"deliveryType\":\"OFFLINE\",\"discountFee\":20.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1757118213000,\"lines\":[{\"latestDeliveryTime\":1757118213000,\"mark2\":[\"DELIVERED\"],\"num\":1,\"outerId\":\"JSBHUVZYT\",\"payment\":10.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/490100363/O1CN01pEaojF1EYIjYhp76h_!!490100363.jpg\",\"platServiceFee\":0.0,\"price\":30.0,\"refOlId\":\"4718408366815008220\",\"refSkuId\":\"5139754537453\",\"refSpuId\":\"641811002682\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":10.0,\"singleFee\":10.0,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"【撕膜留字 | 易撕无残留】\",\"status\":\"SHIPPED\",\"title\":\"水晶标贴UV转印贴logo定制透明标识贴纸设计金属商标烫金标签定做\",\"totalFee\":10.0,\"totalPrice\":30.0,\"totalSellPrice\":10.0}],\"logisticsOrderNo\":\"YT7568465598389\",\"mark2\":[],\"modifyTime\":1756946987000,\"openBuyerId\":\"AAEVRHraABkUZRPgSx3gFRIR\",\"openBuyerNick\":\"a**\",\"openSellerNick\":\"琳19890725\",\"orderSource\":\"SYNC\",\"orderTime\":1756945412000,\"payTime\":1756945413000,\"payment\":10.0,\"platServiceFee\":0.0,\"posCode\":\"guliang\",\"posId\":598696,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0,\"logisticList\":[{\"logisticNo\":\"YT7568465598389\",\"logisticName\":\"圆通速递\"}]},\"receivedPayment\":0.0,\"receiverCity\":\"苏州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吴江区\",\"receiverId\":\"871dbaa880a955e031c5061436d7a5c1$\",\"receiverState\":\"江苏省\",\"receiverTown\":\"江陵街道\",\"refOid\":\"4718408366815008220\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"寄样-不干胶-uv转印贴小尺寸字母银色黑色-aa_小f-龙井-5,寄样-不干胶-金属标字母银色黑色-aa_小f-龙井-5\",\"serviceFee\":0.0,\"shippingTime\":1756946983000,\"status\":\"SHIPPED\",\"sysTags\":[],\"totalFee\":10.0,\"totalPrice\":30.0,\"totalSellPrice\":10.0,\"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 = 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 = 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) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  217. string addwechat = GetPostString("addwechat");
  218. if (addwechat.Length > 0)
  219. {
  220. int addWt = Convert.ToInt32(addwechat);
  221. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  222. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  223. }
  224. string customer = GetPostString("customer");
  225. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  226. string design = GetPostString("design");
  227. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  228. string orderState = GetPostString("orderState");
  229. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  230. string address = GetPostString("address");
  231. 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));
  232. string sellermemo = GetPostString("seller_memo");
  233. if (sellermemo.Length > 0)
  234. {
  235. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  236. }
  237. string otherMemo = GetPostString("otherMemo");
  238. if (otherMemo.Length > 0)
  239. {
  240. lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  241. }
  242. string backReason = GetPostString("backReason");
  243. if (backReason.Length > 0)
  244. {
  245. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  246. }
  247. string apdate1 = GetPostString("apdate1");
  248. string apdate2 = GetPostString("apdate2");
  249. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  250. if (dwap.Length > 0) lw.Add(dwap);
  251. string price1 = GetPostString("price1");
  252. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  253. string price2 = GetPostString("price2");
  254. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  255. string isoldcustomer = GetPostString("isoldcus");
  256. string spudata = GetPostString("spudata");
  257. if ("0".Equals(spudata))
  258. {
  259. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  260. }
  261. if ("1".Equals(spudata))
  262. {
  263. lw.Add(string.Format("spu_id <> ''"));
  264. }
  265. string finishdate1 = GetPostString("finishdate1");
  266. string finishdate2 = GetPostString("finishdate2");
  267. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  268. bool isFinish = false;
  269. if (finishdate.Length > 0)
  270. {
  271. lw.Add(finishdate);
  272. isFinish = true;
  273. paramsCount++;
  274. }
  275. if (isoldcustomer.Length > 0)
  276. {
  277. if ("2".Equals(isoldcustomer))
  278. {
  279. lw.Add(string.Format("VipCustomer=1"));
  280. }
  281. else
  282. {
  283. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  284. }
  285. }
  286. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  287. if (ex_psize > 0)
  288. {
  289. int UserID = CurrentUser.UserID;
  290. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  291. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  292. {
  293. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  294. }
  295. dStruct.Order = "pay_time desc";
  296. }
  297. string isNew = GetPostString("isNew");
  298. if (isNew == "true")
  299. {
  300. lw.Add(string.Format("IsNew = {0}", 1));
  301. }
  302. string overtime = GetPostString("overtime");
  303. if (overtime == "1")
  304. {
  305. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  306. }
  307. String usePost = CurrentUser.UserPost.Post.Code;
  308. if (usePost.Equals("Operation") == true)
  309. {
  310. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  311. }
  312. else
  313. {
  314. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  315. }
  316. //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";
  317. if (dStruct.PageSize == 100000)
  318. {
  319. dStruct.Order = "";
  320. }
  321. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  322. DataTable dt = null;
  323. string tablename = "view_orderlist";
  324. if (isFinish)
  325. {
  326. tablename = "view_orderlist_end";
  327. }
  328. dt = WebCache.GetData(tablename, dStruct);
  329. if (dt != null && dt.Rows.Count > 0)
  330. {
  331. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  332. foreach (DataRow dr in dt.Rows)
  333. {
  334. try
  335. {
  336. if (dr["refund_fees"] != null)
  337. {
  338. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  339. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  340. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  341. if (payment == refund_fees)
  342. {
  343. dr["refund_fees"] = Math.Round(refund_fees, 2);
  344. }
  345. else if (refund_fees == total_fee)
  346. {
  347. dr["refund_fees"] = payment;
  348. }
  349. else
  350. {
  351. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  352. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  353. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  354. }
  355. }
  356. // 对象操作
  357. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  358. ceErpTradeCell.ctid = dr["ctid"].ToString();
  359. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  360. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  361. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  362. if (dStruct.PageSize != 100000)
  363. {
  364. if (dr["DispatchSort"].ToString() == "2")
  365. {
  366. dr["gongchuang"] = 200;
  367. }
  368. else if ("外协".Equals(dr["ToType"].ToString()))
  369. {
  370. dr["gongchuang"] = 200;
  371. }
  372. else if ("内部".Equals(dr["ToType"].ToString()))
  373. {
  374. dr["gongchuang"] = -1;
  375. }
  376. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  377. {
  378. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  379. dr["gongchuang"] = response.code;
  380. }
  381. }
  382. }
  383. catch (NullReferenceException ex)
  384. {
  385. // 处理空引用异常
  386. dr["refund_fees"] = "0.00";
  387. }
  388. }
  389. }
  390. writeGridDataTableJson(dStruct.TotalCount, dt);
  391. }
  392. public void get_erp_orderlist_sumprice()
  393. {
  394. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  395. return;
  396. List<string> lw = new List<string>();
  397. string tid = GetPostString("ctid");
  398. string date1 = GetPostString("date1");
  399. string date2 = GetPostString("date2");
  400. if (tid.Length > 0 || date1.Length > 0)
  401. {
  402. lw.Add(string.Format("ctid like '%{0}%'", tid));
  403. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  404. if (dw.Length > 0) lw.Add(dw);
  405. }
  406. else
  407. {
  408. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  409. }
  410. string shopname = GetPostString("shopname");
  411. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  412. string buyernick = GetPostString("buyer_nick");
  413. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  414. string customer = GetPostString("customer");
  415. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  416. string design = GetPostString("design");
  417. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  418. string orderState = GetPostString("orderState");
  419. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  420. string address = GetPostString("address");
  421. 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));
  422. string sellermemo = GetPostString("seller_memo");
  423. if (sellermemo.Length > 0)
  424. {
  425. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  426. }
  427. string apdate1 = GetPostString("apdate1");
  428. string apdate2 = GetPostString("apdate2");
  429. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  430. if (dwap.Length > 0) lw.Add(dwap);
  431. string price1 = GetPostString("price1");
  432. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  433. string price2 = GetPostString("price2");
  434. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  435. string isoldcustomer = GetPostString("isoldcus");
  436. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  437. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  438. if (PKey != "admin")
  439. {
  440. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  441. lw.Add(string.Format("shopId in ({0})", usershop));
  442. }
  443. //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";
  444. string mainWhere = string.Join(" and ", lw.ToArray());
  445. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  446. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  447. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  448. decimal total = 0;
  449. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  450. {
  451. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  452. }
  453. var res = new
  454. {
  455. data = total
  456. };
  457. string ro_jsond = JsonConvert.SerializeObject(res);
  458. returnSuccess(ro_jsond);
  459. return;
  460. }
  461. public void get_erp_CustomerServiceGather()
  462. {
  463. string userWhere = "", orderWhere = "";
  464. List<string> lw = new List<string>();
  465. string customer = GetPostString("customer");
  466. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  467. string shopname = GetPostString("shopname");
  468. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  469. string date1 = GetPostString("date1");
  470. string date2 = GetPostString("date2");
  471. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  472. if (dw.Length > 0) lw.Add(dw);
  473. orderWhere = string.Join(" and ", lw.ToArray());
  474. 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 " +
  475. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  476. "left join " +
  477. "( " +
  478. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  479. ") as b on a.ID = b.CustomerUserId " +
  480. "left join " +
  481. "( " +
  482. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  483. ") as d on a.ID = d.CustomerUserId " +
  484. "left join " +
  485. "( " +
  486. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  487. ") as e on a.ID = e.CustomerUserId " +
  488. "left join " +
  489. "( " +
  490. " select CustomerUserId, RefundCount, RefundSum from " +
  491. " ( " +
  492. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  493. " from CE_ErpTradeRefund a " +
  494. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  495. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  496. " group by CustomerUserId " +
  497. " ) as a " +
  498. ") as f on a.ID = f.CustomerUserId " +
  499. "where a.PostCode = 'CustomerService'",
  500. userWhere, orderWhere);
  501. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  502. writeGridDataTableJson(dt.Rows.Count, dt);
  503. //writeGridDataTableJson(dt.Rows.Count, dt);
  504. }
  505. //设计汇总
  506. public void get_erp_DesignerGather()
  507. {
  508. string userWhere = "", orderWhere = "";
  509. List<string> lw = new List<string>();
  510. string Designer = GetPostString("designer");
  511. int org = GetPostInt("org");
  512. if (Designer.Length > 0)
  513. {
  514. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  515. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  516. }
  517. else if (org > 0)
  518. {
  519. userWhere = string.Format(" where OrgID ={0}", org);
  520. }
  521. string shopname = GetPostString("shopname");
  522. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  523. string state = GetPostString("state");
  524. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  525. string OrderArea = GetPostString("order_area");
  526. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  527. string date1 = GetPostString("date1");
  528. string date2 = GetPostString("date2");
  529. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  530. if (dw.Length > 0) lw.Add(dw);
  531. string UpDate1 = GetPostString("UpDate1");
  532. string UpDate2 = GetPostString("UpDate2");
  533. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  534. if (dw.Length > 0) lw.Add(dw);
  535. orderWhere = string.Join(" and ", lw.ToArray());
  536. 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 (" +
  537. "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 " +
  538. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  539. "left join " +
  540. "( " +
  541. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  542. ") as b on a.ID = b.DesignUserId " +
  543. "left join " +
  544. "( " +
  545. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  546. ") as d on a.ID = d.DesignUserId " +
  547. "left join " +
  548. "( " +
  549. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  550. ") as e on a.ID = e.DesignUserId " +
  551. "left join " +
  552. "( " +
  553. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  554. ") as g on a.ID = g.DesignUserId " +
  555. "left join " +
  556. "( " +
  557. " select CustomerUserId, RefundCount, RefundSum from " +
  558. " ( " +
  559. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  560. " from CE_ErpTradeRefund a " +
  561. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  562. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  563. " group by CustomerUserId " +
  564. " ) as a " +
  565. ") as f on a.ID = f.CustomerUserId " +
  566. "where a.PostCode = 'Designer') as z",
  567. userWhere, orderWhere);
  568. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  569. writeGridDataTableJson(dt.Rows.Count, dt);
  570. }
  571. //删除tradecell的订单
  572. public void del_erp_cellorder()
  573. {
  574. if (UrlPostParmsCheck("ctid"))
  575. {
  576. string eid = GetPostString("ctid");
  577. CeErpTradeCell.DelByCtid(eid);
  578. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  579. returnSuccessMsg("删除成功");
  580. }
  581. }
  582. public void clear_erp_refundstate()
  583. {
  584. if (UrlPostParmsCheck("ids"))
  585. {
  586. string eids = GetPostString("ids");
  587. string[] ctidList = eids.Split(',');
  588. foreach (string ctid in ctidList)
  589. {
  590. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  591. if (entity != null)
  592. {
  593. entity.IsRefund = 0;
  594. entity.Update();
  595. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  596. }
  597. else
  598. continue;
  599. }
  600. returnSuccessMsg("操作成功");
  601. return;
  602. }
  603. returnErrorMsg("缺少必要参数");
  604. }
  605. public void set_erp_urgency()
  606. {
  607. if (UrlPostParmsCheck("ctid"))
  608. {
  609. string eid = GetPostString("ctid");
  610. CeErpTradeCell entity = null;
  611. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  612. if (entity != null)
  613. {
  614. double prices = commonHelper.calculationPrice(entity);
  615. if (prices <= 100)
  616. {
  617. returnErrorMsg("此订单金额不足100元,无法加急。");
  618. return;
  619. }
  620. string utime = GetPostString("urgencytime");
  621. if (utime.Length > 0)
  622. {
  623. entity.UrgencyTime = Convert.ToDateTime(utime);
  624. }
  625. else
  626. {
  627. returnErrorMsg("请选择加急时间");
  628. return;
  629. }
  630. if (entity.OrderState <= 4)
  631. {
  632. //entity.seller_memo = entity.seller_memo + "-加急";
  633. string smemo = entity.seller_memo;
  634. int kindex = smemo.IndexOf(")");
  635. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  636. if (lastoneStr != "-")
  637. {
  638. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  639. }
  640. string prememo = smemo.Substring(0, kindex + 2);
  641. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  642. int lastkindex = lastmemo.IndexOf("(");
  643. DateTime urgtime = Convert.ToDateTime(utime);
  644. string newlastmemo = "";
  645. if (lastkindex == 0)
  646. {
  647. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  648. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  649. }
  650. else
  651. {
  652. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  653. }
  654. entity.seller_memo = prememo + newlastmemo;
  655. }
  656. entity.IsUrgency = true;
  657. entity.UpdateTime = DateTime.Now;
  658. entity.Update();
  659. ApiVo apiVo = new ApiVo();
  660. apiVo.orderNumber = entity.ctid;
  661. apiVo.actionName = "changeDesign";
  662. apiVo.orderRemarks = entity.seller_memo;
  663. apiVo.remarkSign = 3;
  664. designHelper.API_WorkCore(apiVo); //changeDesign
  665. CeErpSukuraData.createInfo(entity.ctid, 7);
  666. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  667. returnSuccessMsg("设置成功!");
  668. return;
  669. }
  670. returnErrorMsg("找不到记录");
  671. }
  672. }
  673. public void set_erp_reset()
  674. {
  675. if (UrlPostParmsCheck("ctid"))
  676. {
  677. string eid = GetPostString("ctid");
  678. CeErpTradeCell entity = null;
  679. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  680. if (entity != null)
  681. {
  682. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  683. {
  684. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  685. {
  686. returnErrorMsg("财务要求已下单已发货无法重置");
  687. return;
  688. }
  689. }
  690. entity.IsUrgency = false;
  691. entity.seller_memo = "";
  692. entity.OtherMemo = "";
  693. entity.OrderState = 0;
  694. entity.IsReturn = 0;
  695. //entity.IsRefund = 0;
  696. entity.MemoOpt = 0;
  697. entity.AfterSaleState = 0;
  698. entity.AfterSaleResponsible = "";
  699. entity.AfterSaleUserId = 0;
  700. entity.IsNeedBill = 0;
  701. entity.CustomerUserId = 0;
  702. entity.DesignUserId = 0;
  703. entity.SupplierId = 0;
  704. entity.PlaceUserId = 0;
  705. entity.ptid = "";
  706. entity.IsSample = 0;
  707. entity.IsXianHuo = 0;
  708. entity.isDianziOrder = 0;
  709. entity.DispatchSort = 0;
  710. entity.IsVerifyToSupplier = false;
  711. entity.FinishPlaceTime = null;
  712. entity.Update();
  713. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  714. if (trade != null)
  715. {
  716. trade.seller_memo = "";
  717. trade.Update();
  718. }
  719. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  720. returnSuccessMsg("重置成功!");
  721. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  722. if (desginBill != null)
  723. {
  724. desginBill.isDel = 1;
  725. desginBill.Update();
  726. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  727. }
  728. ApiVo apiVo = new ApiVo();
  729. apiVo.orderNumber = entity.ctid;
  730. apiVo.actionName = "resetDesign";
  731. designHelper.API_WorkCore(apiVo);//resetDesign
  732. return;
  733. }
  734. returnErrorMsg("找不到记录");
  735. }
  736. }
  737. public void save_erp_sellermemo()
  738. {
  739. if (UrlPostParmsCheck("ctid"))
  740. {
  741. string ctid = GetPostString("ctid");
  742. CeErpTradeCell entity = null;
  743. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  744. if (entity != null)
  745. {
  746. string memo = GetPostString("seller_memo");
  747. string qn_memo = GetPostString("qn_memo");
  748. memo = memo.Replace(" ", "");
  749. if (memo.Contains("补差"))
  750. {
  751. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  752. return;
  753. }
  754. List<string> bitList = new List<string>
  755. {
  756. "\\","/",":","*","?", "\"","<" ,">","|"
  757. };
  758. bool isIn = false;
  759. foreach (string bit in bitList)
  760. {
  761. if (memo.Contains(bit))
  762. {
  763. isIn = true;
  764. }
  765. }
  766. if (isIn)
  767. {
  768. returnErrorMsg("不能使用 一些符合作为文件名");
  769. return;
  770. }
  771. if (entity.seller_memo != memo)
  772. {
  773. if (entity.IsSample == 2)
  774. {
  775. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  776. return;
  777. }
  778. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  779. {
  780. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  781. {
  782. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  783. return;
  784. }
  785. /*if (CurrentUser.UserPost.Post.Code != "Place")
  786. {
  787. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  788. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  789. {
  790. returnErrorMsg("售前系统订单无法再此修改!");
  791. return;
  792. }
  793. }*/
  794. }
  795. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  796. }
  797. if (!string.IsNullOrEmpty(qn_memo) && !(entity.IsSample > 0 || entity.ctid.Contains("N_") || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物")))
  798. {
  799. if (entity.OrderState >= 5)
  800. {
  801. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  802. return;
  803. }
  804. string delMemo = commonHelper.convertQNMemo(qn_memo, ref entity);
  805. if (string.IsNullOrEmpty(delMemo))
  806. {
  807. returnErrorMsg("备注不规范,无法识别");
  808. return;
  809. }
  810. memo = delMemo;
  811. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统千牛修改为:" + memo, entity.OrderState, 1);
  812. }
  813. commonHelper.getCytPrice(entity);
  814. int memoopt = GetPostInt("MemoOpt");
  815. Boolean ismemoopt = false;
  816. if (memoopt > 0)
  817. {
  818. string stropt = "";
  819. if (memoopt == 1)
  820. {
  821. stropt = "“改稿”";
  822. ismemoopt = true;
  823. }
  824. else if (memoopt == 2)
  825. {
  826. stropt = "“定稿”";
  827. }
  828. else if (memoopt == 3)
  829. {
  830. stropt = "“查货”";
  831. CeErpSukuraData.createInfo(entity.ctid, 6);
  832. }
  833. entity.MemoOpt = Convert.ToInt32(memoopt);
  834. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  835. }
  836. if (entity.OrderState < 5)
  837. {
  838. memo = memo.Replace("(", "(");
  839. memo = memo.Replace(")", ")");
  840. }
  841. /* if (entity.OrderState < 3)
  842. {
  843. entity.DispatchSort = 0;
  844. }*/
  845. entity.seller_memo = memo;
  846. entity.UpdateTime = DateTime.Now;
  847. entity.Update();
  848. ApiVo apiVo = new ApiVo();
  849. apiVo.orderNumber = entity.ctid;
  850. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  851. apiVo.orderRemarks = memo;
  852. apiVo.remarkSign = memoopt;
  853. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  854. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  855. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  856. {
  857. dataHelper.api_orderBack(entity.ctid, "0", "");
  858. }
  859. if (entity.seller_memo.Contains("改稿"))
  860. {
  861. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  862. }
  863. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  864. returnSuccessMsg("保存成功!");
  865. return;
  866. }
  867. returnErrorMsg("找不到记录");
  868. }
  869. }
  870. public void ins_erp_checkorder()
  871. {
  872. if (UrlPostParmsCheck("ctid"))
  873. {
  874. string ctid = GetPostString("ctid");
  875. CeErpTradeCell entity = null;
  876. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  877. if (entity != null)
  878. {
  879. if (entity.OrderState < 6)
  880. {
  881. returnErrorMsg("下单完成后才可查货");
  882. return;
  883. }
  884. /*if (entity.OrderState > 6)
  885. {
  886. returnErrorMsg("订单已发货");
  887. return;
  888. }*/
  889. if (entity.FinishPlaceTime != null)
  890. {
  891. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  892. {
  893. returnErrorMsg("下单时间不足,无法查货");
  894. return;
  895. }
  896. }
  897. entity.MemoOpt = 3;
  898. entity.CheckOrderTime = DateTime.Now;
  899. entity.UpdateTime = DateTime.Now;
  900. entity.Update();
  901. CeErpSukuraData.createInfo(entity.ctid, 6);
  902. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  903. returnSuccessMsg("操作成功!");
  904. return;
  905. }
  906. returnErrorMsg("找不到记录");
  907. }
  908. }
  909. public void save_erp_othermemo()
  910. {
  911. if (UrlPostParmsCheck("ctid"))
  912. {
  913. string ctid = GetPostString("ctid");
  914. CeErpTradeCell entity = null;
  915. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  916. if (entity != null)
  917. {
  918. entity.OtherMemo = GetPostString("otherMemo");
  919. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  920. {
  921. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  922. StringBuilder sql = new StringBuilder();
  923. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  924. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  925. if (dt != null && dt.Rows.Count > 0)
  926. {
  927. foreach (DataRow dr in dt.Rows)
  928. {
  929. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  930. {
  931. //品类一直
  932. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  933. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  934. if (ceErpSampleCustomer == null)
  935. {
  936. ceErpSampleCustomer = new CeErpSampleCustomer();
  937. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  938. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  939. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  940. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  941. ceErpSampleCustomer.shopId = entity.ShopId;
  942. }
  943. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  944. ceErpSampleCustomer.lastTid = entity.tid;
  945. if (ceErpSampleCustomer.ID > 0)
  946. {
  947. ceErpSampleCustomer.Update();
  948. }
  949. else
  950. {
  951. ceErpSampleCustomer.Create();
  952. }
  953. }
  954. }
  955. }
  956. }
  957. //if (entity.IsOldCustomer == 1)
  958. //{
  959. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  960. //{
  961. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  962. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  963. //}
  964. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  965. //{
  966. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  967. // {
  968. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  969. // {
  970. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  971. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  972. // }
  973. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  974. // {
  975. // entity.OrderState = 2;
  976. // entity.DesignUserId = 0;
  977. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  978. // }
  979. // else
  980. // {
  981. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  982. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  983. // }
  984. // }
  985. //}
  986. //}
  987. entity.UpdateTime = DateTime.Now;
  988. entity.Update();
  989. returnSuccessMsg("保存成功!");
  990. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  991. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  992. if (entity.OtherMemo.Contains("改稿"))
  993. {
  994. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  995. }
  996. return;
  997. }
  998. returnErrorMsg("找不到记录");
  999. }
  1000. }
  1001. public void save_erp_customermemo()
  1002. {
  1003. if (UrlPostParmsCheck("ctid"))
  1004. {
  1005. string ctid = GetPostString("ctid");
  1006. CeErpTradeCell entity = null;
  1007. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  1008. if (entity != null)
  1009. {
  1010. entity.UpdateTime = DateTime.Now;
  1011. entity.CustomerMemo = GetPostString("CustomerMemo");
  1012. entity.Update();
  1013. ApiVo apiVo = new ApiVo();
  1014. apiVo.orderNumber = entity.ctid;
  1015. apiVo.actionName = "followRemarks";
  1016. apiVo.orderRemarks = entity.CustomerMemo;
  1017. designHelper.API_WorkCore(apiVo);//followRemarks
  1018. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1019. returnSuccessMsg("保存成功!");
  1020. return;
  1021. }
  1022. returnErrorMsg("找不到记录");
  1023. }
  1024. }
  1025. public void upd_erp_addmemotag()
  1026. {
  1027. if (UrlPostParmsCheck("ctid"))
  1028. {
  1029. ;
  1030. string eid = GetPostString("ctid");
  1031. string sfTagstr = GetPostString("memotag");
  1032. CeErpTradeCell entity = null;
  1033. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1034. if (entity != null)
  1035. {
  1036. ApiVo apiVo = new ApiVo();
  1037. if (entity.OrderState == 0)
  1038. {
  1039. returnErrorMsg("请先领单");
  1040. return;
  1041. }
  1042. //撤销顺丰
  1043. if (sfTagstr == "撤销顺丰")
  1044. {
  1045. entity.IsSF = 0;
  1046. string reMsg = "";
  1047. string oldmemo = entity.seller_memo;
  1048. if (entity.OrderState < 5)
  1049. {
  1050. oldmemo = oldmemo.Replace("顺丰到付", "");
  1051. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1052. entity.seller_memo = oldmemo;
  1053. }
  1054. else
  1055. {
  1056. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1057. {
  1058. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1059. }
  1060. }
  1061. entity.Update();
  1062. apiVo.orderNumber = entity.ctid;
  1063. apiVo.actionName = "orderRemarks";
  1064. apiVo.orderRemarks = entity.seller_memo;
  1065. apiVo.isSf = entity.IsSF.ToString();
  1066. designHelper.API_WorkCore(apiVo);//orderRemarks
  1067. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1068. returnSuccessMsg("撤销成功!" + reMsg);
  1069. return;
  1070. }
  1071. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1072. {
  1073. //string oldmemo = entity.seller_memo;
  1074. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1075. string sfStr = GetPostString("memotag");
  1076. string smemo = entity.seller_memo;
  1077. int kindex = smemo.IndexOf(")");
  1078. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1079. if (lastoneStr != "-")
  1080. {
  1081. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1082. }
  1083. string prememo = smemo.Substring(0, kindex + 2);
  1084. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1085. int lastkindex = lastmemo.IndexOf("(");
  1086. string newlastmemo = "";
  1087. if (lastkindex == 0)
  1088. {
  1089. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1090. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1091. }
  1092. else
  1093. {
  1094. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1095. }
  1096. entity.seller_memo = prememo + newlastmemo;
  1097. }
  1098. string sfTagMSg = "";
  1099. if (sfTagstr == "顺丰寄付")
  1100. {
  1101. entity.IsSF = 1;
  1102. sfTagMSg = "顺丰寄付";
  1103. }
  1104. else if (sfTagstr == "顺丰到付")
  1105. {
  1106. entity.IsSF = 2;
  1107. sfTagMSg = "顺丰到付";
  1108. }
  1109. if (entity.SupplierId == 19 && entity.OrderState == 6)
  1110. {
  1111. string deliveryWayName = "";
  1112. if (sfTagstr == "撤销顺丰")
  1113. {
  1114. sfTagstr = "普通快递";
  1115. }
  1116. if (sfTagstr == "顺丰寄付")
  1117. {
  1118. sfTagstr = "顺丰特快寄付";
  1119. }
  1120. if (sfTagstr == "顺丰到付")
  1121. {
  1122. sfTagstr = "顺丰特快到付";
  1123. }
  1124. string result = apichyHelper.updateExpressMark(entity.tid, sfTagstr);
  1125. if ("修改失败".Equals(result))
  1126. {
  1127. returnErrorMsg("修改失败");
  1128. return;
  1129. }
  1130. }
  1131. entity.Update();
  1132. apiVo = new ApiVo();
  1133. apiVo.orderNumber = entity.ctid;
  1134. apiVo.actionName = "orderRemarks";
  1135. apiVo.orderRemarks = entity.seller_memo;
  1136. apiVo.isSf = entity.IsSF.ToString();
  1137. designHelper.API_WorkCore(apiVo);//orderRemarks
  1138. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1139. returnSuccessMsg("标记成功!");
  1140. return;
  1141. }
  1142. returnErrorMsg("找不到记录");
  1143. }
  1144. }
  1145. public void upd_erp_ordertag()
  1146. {
  1147. if (UrlPostParmsCheck("ctid"))
  1148. {
  1149. string eid = GetPostString("ctid");
  1150. CeErpTradeCell entity = null;
  1151. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1152. if (entity != null)
  1153. {
  1154. int tag = GetPostInt("wechattag");
  1155. //if(tag==4 && entity.IsSample == 2)
  1156. //{
  1157. // returnErrorMsg("补差价单不能标记微信单");
  1158. // return;
  1159. //}
  1160. entity.wechatTag = tag;
  1161. entity.Update();
  1162. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1163. if (tag == 1)
  1164. {
  1165. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1166. if (cash == null)
  1167. {
  1168. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1169. cash = new CeErpReturnCash();
  1170. cash.tid = entity.tid;
  1171. cash.seller_nick = main.seller_nick;
  1172. cash.payment = trade.payment;
  1173. cash.buyer_nick = main.buyer_nick;
  1174. cash.cashstate = 0;
  1175. cash.rtype = "微信返现";
  1176. cash.returnprice = 0;
  1177. cash.created = DateTime.Now;
  1178. cash.con = "订单标记微信单";
  1179. cash.img = "";
  1180. cash.applyuserid = CurrentUser.UserID;
  1181. cash.Create();
  1182. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1183. }
  1184. else
  1185. {
  1186. cash.cashstate = 0;
  1187. cash.Update();
  1188. }
  1189. CeErpSukuraData.createInfo(entity.ctid, 9);
  1190. }
  1191. else if (tag == 2)
  1192. {
  1193. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1194. if (cash == null)
  1195. {
  1196. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1197. cash = new CeErpReturnCash();
  1198. cash.tid = entity.tid;
  1199. cash.seller_nick = main.seller_nick;
  1200. cash.payment = trade.payment;
  1201. cash.buyer_nick = main.buyer_nick;
  1202. cash.cashstate = 0;
  1203. cash.rtype = "推购返现";
  1204. cash.returnprice = 5;
  1205. cash.created = DateTime.Now;
  1206. cash.con = "订单标记推购单";
  1207. cash.img = "";
  1208. cash.applyuserid = CurrentUser.UserID;
  1209. cash.Create();
  1210. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1211. }
  1212. else
  1213. {
  1214. cash.cashstate = 0;
  1215. cash.Update();
  1216. }
  1217. CeErpSukuraData.createInfo(entity.ctid, 9);
  1218. }
  1219. else if (tag == 3)
  1220. {
  1221. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1222. if (pers == null)
  1223. {
  1224. pers = new CeErpPersuade();
  1225. pers.ctid = entity.ctid;
  1226. pers.pstate = 0;
  1227. pers.created = DateTime.Now;
  1228. pers.applyuserid = CurrentUser.UserID;
  1229. pers.Create();
  1230. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1231. }
  1232. else
  1233. {
  1234. pers.pstate = 0;
  1235. pers.Update();
  1236. }
  1237. }
  1238. else if (tag == 4 || tag == 5)
  1239. {
  1240. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1241. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1242. if (pers == null)
  1243. {
  1244. pers = CeErpStayGoods.GetByTid(entity.tid);
  1245. }
  1246. if (pers == null)
  1247. {
  1248. pers = new CeErpStayGoods();
  1249. pers.t_id = entity.tid;
  1250. pers.ctid = entity.ctid;
  1251. pers.status = "待审核";
  1252. pers.audit_type = 0;
  1253. if (tag == 4)
  1254. {
  1255. pers.stay_type = "微信推购";
  1256. }
  1257. else
  1258. {
  1259. pers.stay_type = "旺旺推购";
  1260. }
  1261. if (entity.IsXianHuo == 0)
  1262. {
  1263. pers.product_id = entity.ProductId;
  1264. }
  1265. pers.wangwang = main.buyer_nick;
  1266. pers.shop_name = main.seller_nick;
  1267. pers.creata_time = DateTime.Now;
  1268. pers.create_u_id = CurrentUser.UserID;
  1269. pers.create_u_name = CurrentUser.UserName;
  1270. pers.Create();
  1271. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1272. }
  1273. else
  1274. {
  1275. pers.ctid = entity.ctid;
  1276. pers.audit_type = 0;
  1277. pers.Update();
  1278. }
  1279. CeErpSukuraData.createInfo(entity.ctid, 10);
  1280. }
  1281. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1282. returnSuccessMsg("标记成功!");
  1283. return;
  1284. }
  1285. returnErrorMsg("找不到记录");
  1286. }
  1287. }
  1288. public void upd_erp_ordertag_cancel()
  1289. {
  1290. if (UrlPostParmsCheck("ctid"))
  1291. {
  1292. string eid = GetPostString("ctid");
  1293. CeErpTradeCell entity = null;
  1294. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1295. if (entity != null)
  1296. {
  1297. entity.wechatTag = 0;
  1298. entity.Update();
  1299. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1300. if (pers != null)
  1301. {
  1302. pers.status = "取消推购";
  1303. pers.audit_type = 3;
  1304. pers.Update();
  1305. }
  1306. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1307. returnSuccessMsg("标记成功!");
  1308. return;
  1309. }
  1310. returnErrorMsg("找不到记录");
  1311. }
  1312. }
  1313. public void upd_erp_addweichattag()
  1314. {
  1315. if (UrlPostParmsCheck("ctid"))
  1316. {
  1317. ;
  1318. string eid = GetPostString("ctid");
  1319. CeErpTradeCell entity = null;
  1320. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1321. if (entity != null)
  1322. {
  1323. if (entity.IsAddWechat > 0)
  1324. {
  1325. returnErrorMsg("此单已经标记过了");
  1326. return;
  1327. }
  1328. 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);
  1329. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1330. if (dt.Rows.Count > 0)
  1331. {
  1332. entity.IsAddWechat = 2;
  1333. }
  1334. else
  1335. {
  1336. entity.IsAddWechat = 1;
  1337. }
  1338. entity.Update();
  1339. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1340. returnSuccessMsg("标记成功!");
  1341. return;
  1342. }
  1343. returnErrorMsg("找不到记录");
  1344. }
  1345. }
  1346. public void upd_erp_getmyorder()
  1347. {
  1348. if (UrlPostParmsCheck("ctid"))
  1349. {
  1350. string eid = GetPostString("ctid");
  1351. CeErpTradeCell entity = null;
  1352. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1353. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1354. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1355. {
  1356. returnErrorMsg("台湾客户需填写身份证号!");
  1357. return;
  1358. }
  1359. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1360. {
  1361. returnErrorMsg("偏远地区需要填写物流费!");
  1362. return;
  1363. }
  1364. if (entity != null)
  1365. {
  1366. if (entity.ctid.IndexOf("C") != -1)
  1367. {
  1368. StringBuilder sql = new StringBuilder();
  1369. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1370. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1371. if (dt.Rows.Count > 0)
  1372. {
  1373. decimal total = 0;
  1374. foreach (DataRow dr in dt.Rows)
  1375. {
  1376. total += Convert.ToDecimal(dr["payment"]);
  1377. }
  1378. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1379. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1380. {
  1381. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1382. return;
  1383. }
  1384. }
  1385. }
  1386. if (entity.OrderState == -1)
  1387. {
  1388. returnErrorMsg("待审核订单无法领取!");
  1389. return;
  1390. }
  1391. entity.CustomerUserId = CurrentUser.UserID;
  1392. if (entity.OrderState < 2)
  1393. {
  1394. entity.OrderState = 2;
  1395. if (entity.ShopId != 0)
  1396. {
  1397. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1398. }
  1399. }
  1400. entity.UpdateTime = DateTime.Now;
  1401. entity.Update();
  1402. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1403. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1404. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1405. {
  1406. dataHelper.api_orderBack(entity.ctid, "0", "");
  1407. }
  1408. returnSuccessMsg("领单成功!");
  1409. return;
  1410. }
  1411. returnErrorMsg("找不到记录");
  1412. }
  1413. }
  1414. public void getmyorder_from_init()
  1415. {
  1416. if (UrlPostParmsCheck("ctid"))
  1417. {
  1418. string eid = GetPostString("ctid");
  1419. CeErpTradeCell entity = null;
  1420. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1421. if (entity != null)
  1422. {
  1423. string sellerMemo = GetPostString("sellerMemo");
  1424. if (sellerMemo.Length > 0)
  1425. {
  1426. entity.seller_memo = sellerMemo;
  1427. }
  1428. string oterhMemo = GetPostString("otherMemo");
  1429. if (oterhMemo.Length > 0)
  1430. {
  1431. entity.OtherMemo = oterhMemo;
  1432. }
  1433. int urg = GetPostInt("urgency");
  1434. entity.IsUrgency = (urg == 1 ? true : false);
  1435. int wechat = GetPostInt("wechat");
  1436. int command = GetPostInt("command");
  1437. if (wechat == 1)
  1438. {
  1439. entity.wechatTag = 1;
  1440. }
  1441. if (command == 1)
  1442. {
  1443. entity.wechatTag = 2;
  1444. }
  1445. string pPro = GetPostString("pprofession");
  1446. if (pPro.Length > 0)
  1447. {
  1448. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1449. string spro = GetPostString("profession");
  1450. if (spro.Length > 0)
  1451. {
  1452. entity.ProfessionId = Convert.ToInt32(spro);
  1453. }
  1454. }
  1455. string proId = GetPostString("productId");
  1456. if (proId.Length > 0)
  1457. {
  1458. entity.ProductId = Convert.ToInt32(proId);
  1459. }
  1460. entity.Material = GetPostString("material");
  1461. entity.Craft = GetPostString("craft");
  1462. entity.CustomerUserId = CurrentUser.UserID;
  1463. if (entity.OrderState < 2)
  1464. {
  1465. entity.OrderState = 2;
  1466. if (entity.ShopId != 0)
  1467. {
  1468. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1469. }
  1470. }
  1471. entity.Update();
  1472. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1473. returnSuccessMsg("领单成功!");
  1474. return;
  1475. }
  1476. returnErrorMsg("找不到记录");
  1477. }
  1478. }
  1479. public void upd_erp_setrelationorder()
  1480. {
  1481. if (UrlPostParmsCheck("ctid"))
  1482. {
  1483. ;
  1484. string eid = GetPostString("ctid");
  1485. string ftid = GetPostString("ftid");
  1486. CeErpTradeCell entity = null;
  1487. CeErpTradeCell fentity = null;
  1488. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1489. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1490. if (fentity == null)
  1491. {
  1492. returnErrorMsg("找不到关联的主订单");
  1493. return;
  1494. }
  1495. if (entity != null)
  1496. {
  1497. if (entity.OrderState >= 5)
  1498. {
  1499. returnErrorMsg("本单已经设计完成无法关联");
  1500. return;
  1501. }
  1502. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1503. {
  1504. returnErrorMsg("线下单续审核后才能关联!");
  1505. return;
  1506. }
  1507. entity.ptid = ftid;
  1508. entity.OrderState = fentity.OrderState;
  1509. //entity.status = fentity.status;
  1510. entity.CustomerUserId = fentity.CustomerUserId;
  1511. entity.DesignUserId = fentity.DesignUserId;
  1512. entity.seller_memo = "补差价单:" + ftid;
  1513. entity.IsSample = 2;
  1514. entity.Update();
  1515. ApiVo apiVo = new ApiVo();
  1516. apiVo.orderNumber = ftid;
  1517. apiVo.payment = entity.payment;
  1518. apiVo.actionName = "repairDesign";
  1519. designHelper.API_WorkCore(apiVo);//repairDesign
  1520. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1521. returnSuccessMsg("关联成功!");
  1522. return;
  1523. }
  1524. else
  1525. returnErrorMsg("找不到记录");
  1526. }
  1527. }
  1528. public void download_erp_neworder()
  1529. {
  1530. string seller = GetPostString("seller_nick");
  1531. string tid = GetPostString("tid");
  1532. if (seller.Length <= 0 || tid.Length <= 0)
  1533. {
  1534. returnErrorMsg("数据错误");
  1535. }
  1536. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1537. //{
  1538. // returnErrorMsg("找不到店铺Sessionkey");
  1539. //}
  1540. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1541. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1542. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1543. if (res.IndexOf("refOid") == -1)
  1544. {
  1545. returnErrorMsg("下载订单数据失败");
  1546. return;
  1547. }
  1548. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1549. returnSuccessMsg("下载完成");
  1550. //tmcHelper.createNewOrder(res);
  1551. //CeErpTrade entr = null;
  1552. //entr = CeErpTrade.Get(tid);
  1553. //if (entr != null)
  1554. //{
  1555. // returnSuccess("下载成功");
  1556. // //下载成功之后,Cell表生成对应的订单;
  1557. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1558. //}
  1559. //else
  1560. //{
  1561. // returnErrorMsg("下载失败或者创建订单失败");
  1562. //}
  1563. }
  1564. public void set_erp_atersale()
  1565. {
  1566. if (UrlPostParmsCheck("ctid"))
  1567. {
  1568. string eid = GetPostString("ctid");
  1569. string reason = GetPostString("AfterSaleReason");
  1570. CeErpTradeCell entity = null;
  1571. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1572. if (entity != null)
  1573. {
  1574. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1575. {
  1576. returnErrorMsg("此订单已经在售后");
  1577. return;
  1578. }*/
  1579. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1580. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1581. entity.AfterSaleTime = DateTime.Now;
  1582. entity.HandleTime = null;
  1583. entity.Update();
  1584. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1585. returnSuccessMsg("转售后成功!");
  1586. return;
  1587. }
  1588. returnErrorMsg("找不到记录");
  1589. }
  1590. }
  1591. public void set_erp_withdraw()
  1592. {
  1593. if (UrlPostParmsCheck("ctid"))
  1594. {
  1595. try
  1596. {
  1597. string eid = GetPostString("ctid");//商品id
  1598. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1599. CeWithdraw ceWithdrawSelect = null;
  1600. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1601. if (ceWithdrawSelect != null)
  1602. {
  1603. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1604. {
  1605. ceWithdrawSelect.status = -1;
  1606. ceWithdrawSelect.Update();
  1607. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1608. returnSuccessMsg("重新发起审核成功");
  1609. return;
  1610. }
  1611. else
  1612. {
  1613. returnSuccessMsg("请勿重复申请!");
  1614. return;
  1615. }
  1616. }
  1617. else
  1618. {
  1619. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1620. if (string.IsNullOrEmpty(CustomerUserId))
  1621. {
  1622. CustomerUserId = "-1";
  1623. }
  1624. int Userid = CurrentUser.UserID;//用户id
  1625. CeWithdraw ceWithdraw = new CeWithdraw();
  1626. ceWithdraw.tid = eid;
  1627. ceWithdraw.userid = Userid;
  1628. ceWithdraw.providerid = CustomerUserId;
  1629. ceWithdraw.status = 3;
  1630. ceWithdraw.creationtime = DateTime.Now;
  1631. ceWithdraw.Create();
  1632. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1633. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1634. return;
  1635. }
  1636. }
  1637. catch
  1638. {
  1639. returnErrorMsg("申请撤回订单失败");
  1640. return;
  1641. }
  1642. }
  1643. }
  1644. public void ins_erp_billinfo()
  1645. {
  1646. if (UrlPostParmsCheck("ctid"))
  1647. {
  1648. string eid = GetPostString("ctid");
  1649. CeErpTradeCell entity = null;
  1650. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1651. if (entity != null)
  1652. {
  1653. CeErpBill bill = CeErpBill.GetByTid(eid);
  1654. bool isHave = false;
  1655. if (bill != null)
  1656. {
  1657. isHave = true;
  1658. if (bill.state != 4)
  1659. {
  1660. returnErrorMsg("此单已经申请过发票了");
  1661. return;
  1662. }
  1663. }
  1664. if (entity.IsNeedBill == 0)
  1665. {
  1666. entity.IsNeedBill = 1;
  1667. }
  1668. entity.Update();
  1669. string errjson = "";
  1670. try
  1671. {
  1672. CeErpBill bill_entity = new CeErpBill();
  1673. bill_entity.tid = entity.tid;
  1674. bill_entity.title = GetPostString("title");
  1675. string taxstr = GetPostString("tax");
  1676. taxstr = taxstr.Replace(" ", "");
  1677. bill_entity.tax = taxstr;
  1678. bill_entity.bank = GetPostString("bank");
  1679. string bankacstr = GetPostString("bankac");
  1680. bankacstr = bankacstr.Replace(" ", "");
  1681. bill_entity.bankac = bankacstr;
  1682. bill_entity.address = GetPostString("address");
  1683. bill_entity.phone = GetPostString("phone");
  1684. bill_entity.price = GetPostString("price");
  1685. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1686. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1687. {
  1688. billCount += 1;
  1689. }
  1690. string prebill = "ltb";
  1691. for (int idx = 1; idx <= billCount; idx++)
  1692. {
  1693. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1694. string billoid = prebill + idx + dtstr;
  1695. bill_entity.billOrderId += billoid;
  1696. if (idx < billCount)
  1697. {
  1698. bill_entity.billOrderId += ",";
  1699. }
  1700. }
  1701. bill_entity.productId = GetPostInt("ProductName");
  1702. bill_entity.num = GetPostInt("num");
  1703. bill_entity.unit = GetPostString("unit");
  1704. bill_entity.type = GetPostString("type");
  1705. bill_entity.sendType = GetPostString("SendType");
  1706. bill_entity.email = GetPostString("email");
  1707. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1708. bill_entity.shopName = GetPostString("ShopName");
  1709. bill_entity.applymemo = GetPostString("applyMemo");
  1710. bill_entity.createTime = DateTime.Now;
  1711. bill_entity.state = 0;
  1712. bill_entity.userId = CurrentUser.UserID;
  1713. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1714. bill_entity.Create();
  1715. }
  1716. catch (Exception ex)
  1717. {
  1718. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1719. returnErrorMsg("创建发票出错!");
  1720. return;
  1721. }
  1722. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1723. returnSuccessMsg("发票申请成功!");
  1724. return;
  1725. }
  1726. returnErrorMsg("找不到记录");
  1727. }
  1728. }
  1729. public void ins_erp_neworder()
  1730. {
  1731. if (UrlPostParmsCheck("receiver_name"))
  1732. {
  1733. CeErpTrade entity = new CeErpTrade();
  1734. string plat_form = GetPostString("platform");
  1735. string preStr = "N_";
  1736. if (plat_form == "拼多多")
  1737. {
  1738. preStr = "P_";
  1739. }
  1740. else if (plat_form == "阿里巴巴")
  1741. {
  1742. preStr = "A_";
  1743. }
  1744. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1745. entity.seller_nick = GetPostString("seller_nick");
  1746. entity.buyer_nick = GetPostString("buyer_nick");
  1747. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1748. entity.total_fee = entity.payment;
  1749. entity.pay_time = DateTime.Now;
  1750. entity.status = "NOT_SHIPPED";
  1751. entity.receiver_name = GetPostString("receiver_name");
  1752. entity.receiver_mobile = GetPostString("receiver_mobile");
  1753. entity.receiver_state = GetPostString("receiver_state");
  1754. entity.receiver_city = GetPostString("receiver_city");
  1755. entity.receiver_district = GetPostString("receiver_district");
  1756. entity.receiver_address = GetPostString("receiver_address");
  1757. if (entity.receiver_state == "" || entity.receiver_city == "")
  1758. {
  1759. returnErrorMsg("收件地址不能为空");
  1760. return;
  1761. }
  1762. int shopId = 0;
  1763. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1764. if (nShop != null)
  1765. {
  1766. shopId = nShop.ID;
  1767. }
  1768. if (shopId != 34 && entity.payment == 0)
  1769. {
  1770. returnErrorMsg("公司自用的单金额才能为0");
  1771. return;
  1772. }
  1773. entity.Create();
  1774. CeErpTradeCell entitycell = new CeErpTradeCell();
  1775. entitycell.ctid = entity.tid;
  1776. entitycell.tid = entity.tid;
  1777. entitycell.ShopId = shopId;
  1778. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1779. entitycell.OrderState = 0;
  1780. entitycell.pay_time = entity.pay_time;
  1781. entitycell.IsOffLineOrder = 1;
  1782. entitycell.Create();
  1783. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1784. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1785. return;
  1786. }
  1787. }
  1788. public void ins_erp_neworder2()
  1789. {
  1790. if (UrlPostParmsCheck("receiver_name"))
  1791. {
  1792. //string plat_form = GetPostString("platform");
  1793. string preStr = "X_";
  1794. string memo = GetPostString("memo");
  1795. string productId = GetPostString("productId");
  1796. string primg = GetPostString("proofimg");
  1797. string sellerNick = GetPostString("seller_nick");
  1798. string addFrom = GetPostString("addfrom");
  1799. if (addFrom == "1")
  1800. {
  1801. preStr = "N_";
  1802. }
  1803. int shopId = 0;
  1804. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1805. if (nShop != null)
  1806. {
  1807. shopId = nShop.ID;
  1808. }
  1809. else
  1810. {
  1811. returnErrorMsg("找不到对应店铺");
  1812. return;
  1813. }
  1814. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1815. {
  1816. returnErrorMsg("必须上传付款凭证");
  1817. return;
  1818. }
  1819. CeErpTrade entity = new CeErpTrade();
  1820. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1821. entity.seller_nick = sellerNick;
  1822. entity.buyer_nick = GetPostString("buyer_nick");
  1823. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1824. entity.total_fee = entity.payment;
  1825. entity.pay_time = DateTime.Now;
  1826. entity.status = "NOT_SHIPPED";
  1827. entity.receiver_name = GetPostString("receiver_name");
  1828. entity.receiver_mobile = GetPostString("receiver_mobile");
  1829. entity.receiver_state = GetPostString("receiver_state");
  1830. entity.receiver_city = GetPostString("receiver_city");
  1831. entity.receiver_district = GetPostString("receiver_district");
  1832. entity.receiver_address = GetPostString("receiver_address");
  1833. entity.seller_memo = memo;
  1834. entity.orderFrom = 20;
  1835. entity.orderType = 15;
  1836. if (entity.receiver_state == "" || entity.receiver_city == "")
  1837. {
  1838. returnErrorMsg("收件地址不能为空");
  1839. return;
  1840. }
  1841. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1842. {
  1843. returnErrorMsg("公司自用的单金额才能为0");
  1844. return;
  1845. }
  1846. entity.Create();
  1847. string toWhere = GetPostString("towhere");
  1848. CeErpTradeCell entitycell = new CeErpTradeCell();
  1849. entitycell.ctid = entity.tid;
  1850. //唯一标识
  1851. entitycell.OrderSn = entity.tid;
  1852. string orderSn = dataHelper.getSaleOrderSn();
  1853. if (orderSn != "")
  1854. {
  1855. entitycell.OrderSn = orderSn;
  1856. }
  1857. entitycell.tid = entity.tid;
  1858. //if (preStr == "X_")
  1859. //{
  1860. entitycell.IsOffLineOrder = 1;
  1861. //}
  1862. entitycell.CustomerUserId = CurrentUser.UserID;
  1863. entitycell.PayProofImg = primg;
  1864. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1865. entitycell.ProductId = Convert.ToInt32(productId);
  1866. entitycell.ShopId = shopId;
  1867. entitycell.UpdateTime = DateTime.Now;
  1868. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1869. if (entitycell.ProductId > 0)
  1870. {
  1871. CeErpProduct ceErpProduct = CeErpProduct.GetById(entitycell.ProductId);
  1872. if (ceErpProduct.CreateTime != null && DateTime.Compare(ceErpProduct.CreateTime, DateTime.Now.AddDays(-90)) > 0)
  1873. {
  1874. entitycell.NewProduct = 1;
  1875. }
  1876. }
  1877. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1878. {
  1879. entitycell.IsXianHuo = 1;
  1880. }
  1881. entitycell.pay_time = entity.pay_time;
  1882. if (toWhere == "1")
  1883. {
  1884. entitycell.OrderState = 2;
  1885. }
  1886. else
  1887. {
  1888. entitycell.OrderState = 6;
  1889. entitycell.FinishPlaceTime = entitycell.pay_time;
  1890. }
  1891. if (shopId == 94)
  1892. {
  1893. entitycell.OrderState = 4;
  1894. entitycell.WaitDesignTime = entitycell.pay_time;
  1895. entitycell.StartDesignTime = entitycell.pay_time;
  1896. entitycell.DesignUserId = 218;
  1897. }
  1898. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1899. {
  1900. entitycell.OrderState = -1;//修改12-5
  1901. CeWithdraw ceWithdraw = new CeWithdraw();
  1902. ceWithdraw.tid = entity.tid;
  1903. ceWithdraw.providerid = "-1";
  1904. ceWithdraw.status = -1;
  1905. ceWithdraw.creationtime = DateTime.Now;
  1906. ceWithdraw.userid = 4634;
  1907. ceWithdraw.Create();
  1908. }
  1909. entitycell.Create();
  1910. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1911. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1912. {
  1913. addPlaceRegist(entitycell, CurrentUser.UserID);
  1914. }
  1915. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1916. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1917. return;
  1918. }
  1919. }
  1920. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1921. {
  1922. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1923. entity.PlactTime = tradecell.pay_time;
  1924. entity.AddUserId = userid;
  1925. entity.FileName = tradecell.seller_memo;
  1926. entity.Supplier = 24;
  1927. entity.CreateTime = DateTime.Now;
  1928. entity.Did = tradecell.ctid;
  1929. entity.tid = tradecell.tid;
  1930. entity.splitTag = tradecell.SplitTag;
  1931. entity.CurState = "未完成";
  1932. entity.Create();
  1933. }
  1934. public void get_erp_offlinelist()
  1935. {
  1936. DataStruct dStruct = GetPostStruct();
  1937. List<string> lw = new List<string>();
  1938. string tid = GetPostString("ctid");
  1939. string date1 = GetPostString("date1");
  1940. string date2 = GetPostString("date2");
  1941. if (tid.Length > 0 || date1.Length > 0)
  1942. {
  1943. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1944. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1945. if (dw.Length > 0) lw.Add(dw);
  1946. }
  1947. else
  1948. {
  1949. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1950. }
  1951. string shopname = GetPostString("shopname");
  1952. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1953. string buyernick = GetPostString("buyer_nick");
  1954. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1955. string customer = GetPostString("customer");
  1956. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1957. string design = GetPostString("design");
  1958. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1959. string orderState = GetPostString("orderState");
  1960. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1961. string address = GetPostString("address");
  1962. 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));
  1963. string sellermemo = GetPostString("seller_memo");
  1964. if (sellermemo.Length > 0)
  1965. {
  1966. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1967. }
  1968. string price1 = GetPostString("price1");
  1969. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1970. string price2 = GetPostString("price2");
  1971. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1972. //if (PKey != "admin")
  1973. //{
  1974. // string usershop = CurrentUser.User.pemShop;
  1975. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1976. //}
  1977. //if (ex_psize > 0)
  1978. //{
  1979. dStruct.Order = "pay_time desc";
  1980. //}
  1981. //else
  1982. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1983. lw.Add(string.Format("IsOffLineOrder=1"));
  1984. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1985. DataTable dt = null;
  1986. dt = WebCache.GetData("view_erptradecell", dStruct);
  1987. writeGridDataTableJson(dStruct.TotalCount, dt);
  1988. }
  1989. public void get_erp_returncashrecord()
  1990. {
  1991. DataStruct dStruct = GetPostStruct();
  1992. List<string> lw = new List<string>();
  1993. string tid = GetPostString("ctid");
  1994. if (tid.Length > 0)
  1995. {
  1996. lw.Add(string.Format("tid like '%{0}%'", tid));
  1997. dStruct.Order = "id desc";
  1998. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1999. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  2000. //writeGridDataTableJson(dStruct.TotalCount, dt);
  2001. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2002. return;
  2003. }
  2004. returnErrorMsg("id数据错误!");
  2005. }
  2006. public void ins_erp_returncashrecord()
  2007. {
  2008. if (UrlPostParmsCheck("tid"))
  2009. {
  2010. string tid = GetPostString("tid");
  2011. string retype = GetPostString("type");
  2012. StringBuilder sql = new StringBuilder();
  2013. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  2014. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2015. if (dt.Rows.Count > 0)
  2016. {
  2017. returnErrorMsg("相同返现类型记录已存在");
  2018. return;
  2019. }
  2020. CeErpReturnCash entity = new CeErpReturnCash();
  2021. entity.tid = tid;
  2022. entity.seller_nick = GetPostString("seller_nick");
  2023. string pment = GetPostString("payment");
  2024. if (pment.Length > 0)
  2025. {
  2026. entity.payment = Convert.ToDouble(pment);
  2027. }
  2028. entity.buyer_nick = GetPostString("buyer_nick");
  2029. entity.cashstate = 0;
  2030. entity.rtype = retype;
  2031. string rPrice = GetPostString("returnprice");
  2032. if (rPrice.Length > 0)
  2033. {
  2034. entity.returnprice = Convert.ToDouble(rPrice);
  2035. }
  2036. entity.created = DateTime.Now;
  2037. entity.con = GetPostString("con");
  2038. entity.img = GetPostString("img");
  2039. entity.applyuserid = CurrentUser.UserID;
  2040. entity.Create();
  2041. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  2042. returnSuccessMsg("操作成功!");
  2043. return;
  2044. }
  2045. }
  2046. public void set_erp_predelivery()
  2047. {
  2048. if (UrlPostParmsCheck("ctid"))
  2049. {
  2050. string eid = GetPostString("ctid");
  2051. CeErpTradeCell entity = null;
  2052. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2053. if (entity != null)
  2054. {
  2055. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2056. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2057. //{
  2058. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2059. // return;
  2060. //}
  2061. entity.IsPreDelivery = 1;
  2062. entity.Update();
  2063. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2064. returnSuccessMsg("预发货成功!");
  2065. return;
  2066. //string shop = GetPostString("seller_nick");
  2067. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2068. //string comName = GetPostString("comName");
  2069. //string comCode = GetPostString("comCode");
  2070. //string outSid = GetPostString("outSid");//运单号
  2071. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2072. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2073. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2074. //string apires = "";
  2075. //if (deliveryType == "虚拟发货")
  2076. //{
  2077. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2078. //}
  2079. //else
  2080. //{
  2081. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2082. //}
  2083. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2084. ////{
  2085. //if (apires.IndexOf("发货成功") != -1)
  2086. //{
  2087. // if (deliveryType != "虚拟发货")
  2088. // {
  2089. // //还要插入快递信息到 快递信息表
  2090. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2091. // exinfo.tid = eid;
  2092. // exinfo.out_sid = outSid;
  2093. // exinfo.company_code = comCode;
  2094. // exinfo.company_name = comName;
  2095. // exinfo.delivery_memo = deliveryMemo;
  2096. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2097. // exinfo.deliveryType = deliveryType;
  2098. // exinfo.Create();
  2099. // }
  2100. // returnSuccessMsg("发货成功!");
  2101. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2102. //}
  2103. //else
  2104. //{
  2105. // returnErrorMsg("淘宝发货失败!!");
  2106. //}
  2107. //return;
  2108. }
  2109. returnErrorMsg("找不到订单记录");
  2110. }
  2111. }
  2112. public void get_erp_unusuallist()
  2113. {
  2114. DataStruct dStruct = GetPostStruct();
  2115. List<string> lw = new List<string>();
  2116. string tid = GetPostString("ctid");
  2117. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2118. string shopname = GetPostString("shopname");
  2119. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2120. string buyernick = GetPostString("buyer_nick");
  2121. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2122. string ResponsibleMan = GetPostString("responsible");
  2123. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2124. string date1 = GetPostString("date1");
  2125. string date2 = GetPostString("date2");
  2126. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2127. if (dw.Length > 0) lw.Add(dw);
  2128. string price1 = GetPostString("price1");
  2129. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2130. string price2 = GetPostString("price2");
  2131. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2132. string orderState = GetPostString("orderState");
  2133. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2134. string sellermemo = GetPostString("seller_memo");
  2135. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2136. lw.Add(string.Format("UnusualTag > 0"));
  2137. lw.Add(string.Format("IsRefund<={0}", 1));
  2138. dStruct.Order = "pay_time desc";
  2139. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2140. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2141. writeGridDataTableJson(dStruct.TotalCount, dt);
  2142. }
  2143. public void set_erp_unusualtonomal()
  2144. {
  2145. if (UrlPostParmsCheck("ctid"))
  2146. {
  2147. string eid = GetPostString("ctid");
  2148. CeErpTradeCell entity = null;
  2149. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2150. if (entity != null)
  2151. {
  2152. entity.UnusualTag = -1;
  2153. entity.Update();
  2154. returnSuccessMsg("忽略成功!");
  2155. return;
  2156. }
  2157. returnErrorMsg("找不到记录");
  2158. }
  2159. }
  2160. public void ins_erp_unusualreason()
  2161. {
  2162. if (UrlPostParmsCheck("ctid"))
  2163. {
  2164. string eid = GetPostString("ctid");
  2165. CeErpTradeCell entity = null;
  2166. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2167. if (entity != null)
  2168. {
  2169. entity.MemoOpt = 4;
  2170. entity.UnusualCon = GetPostString("con");
  2171. entity.Update();
  2172. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2173. if (trade != null)
  2174. {
  2175. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2176. }
  2177. //查货是否超时
  2178. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2179. if (ceErpTradeCellExtend == null)
  2180. {
  2181. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2182. ceErpTradeCellExtend.ctid = entity.ctid;
  2183. }
  2184. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2185. {
  2186. ceErpTradeCellExtend.CheckOut += 1;
  2187. }
  2188. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2189. if (ceErpTradeCellExtend.ID > 0)
  2190. {
  2191. ceErpTradeCellExtend.Update();
  2192. }
  2193. else
  2194. {
  2195. ceErpTradeCellExtend.Create();
  2196. }
  2197. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2198. returnSuccessMsg("操作成功!");
  2199. return;
  2200. }
  2201. returnErrorMsg("找不到记录");
  2202. }
  2203. }
  2204. public void upd_erp_sampleorder()
  2205. {
  2206. if (UrlPostParmsCheck("ctid"))
  2207. {
  2208. string eid = GetPostString("ctid");
  2209. string[] eArr = eid.Split(',');
  2210. if (eArr.Length > 1)
  2211. {
  2212. List<string> eLst = new List<string>();
  2213. for (int i = 0; i < eArr.Length; i++)
  2214. {
  2215. eLst.Add("'" + eArr[i] + "'");
  2216. }
  2217. eid = string.Join(",", eLst.ToArray());
  2218. }
  2219. else
  2220. {
  2221. eid = "'" + eid + "'";
  2222. }
  2223. StringBuilder sql = new StringBuilder();
  2224. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2225. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2226. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2227. if (dt.Rows.Count > 0)
  2228. {
  2229. string errmsg = "";
  2230. foreach (DataRow dr in dt.Rows)
  2231. {
  2232. StringBuilder sqlsb = new StringBuilder();
  2233. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2234. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2235. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2236. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2237. //string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2238. /*if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2239. {
  2240. continue;
  2241. }
  2242. else
  2243. {
  2244. string emsg = commonHelper.KeepChinese(apires);
  2245. errmsg += emsg;
  2246. }*/
  2247. }
  2248. if (errmsg.Length > 0)
  2249. {
  2250. returnErrorMsg(errmsg);
  2251. return;
  2252. }
  2253. returnSuccessMsg("操作成功");
  2254. return;
  2255. }
  2256. returnErrorMsg("找不到记录");
  2257. }
  2258. }
  2259. public void upd_erp_transcustomer()
  2260. {
  2261. if (UrlPostParmsCheck("ctid"))
  2262. {
  2263. string eid = GetPostString("ctid");
  2264. int userid = GetPostInt("CustomerUserId");
  2265. CeErpTradeCell entity = null;
  2266. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2267. if (entity != null)
  2268. {
  2269. //string[] mlist = entity.seller_memo.Split('-');
  2270. //string sql = "select * from view_erpuser where id=" + userid;
  2271. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2272. //if (dt != null && dt.Rows.Count > 0)
  2273. //{
  2274. // string nmemo = "";
  2275. // for(int i = 0; i < mlist.Length - 1; i++)
  2276. // {
  2277. // nmemo += mlist[i];
  2278. // nmemo += "-";
  2279. // }
  2280. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2281. // entity.seller_memo = nmemo;
  2282. //}
  2283. entity.CustomerUserId = userid;
  2284. entity.Update();
  2285. returnSuccessMsg("操作成功!");
  2286. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2287. return;
  2288. }
  2289. returnErrorMsg("找不到记录");
  2290. }
  2291. }
  2292. public void upd_erp_transdesigner()
  2293. {
  2294. if (UrlPostParmsCheck("ctid"))
  2295. {
  2296. string eids = GetPostString("ctid");
  2297. string[] ctidList = eids.Split(',');
  2298. int userid = GetPostInt("DesignUserId");
  2299. foreach (string ctid in ctidList)
  2300. {
  2301. CeErpTradeCell entity = null;
  2302. CeErpDesignerBill entitys = null;
  2303. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2304. entitys = CeErpDesignerBill.GetByTid(ctid);
  2305. if (entity != null)
  2306. {
  2307. if (entity.OrderState > 4)
  2308. {
  2309. continue;
  2310. }
  2311. //存在退款不能流转
  2312. if (entity.IsRefund > 0)
  2313. {
  2314. continue;
  2315. }
  2316. entity.DesignUserId = userid;
  2317. entity.WaitDesignTime = DateTime.Now;
  2318. entity.Update();
  2319. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2320. }
  2321. }
  2322. returnSuccessMsg("操作成功!");
  2323. }
  2324. }
  2325. public void upd_erp_distributedesigner()
  2326. {
  2327. if (UrlPostParmsCheck("ctid"))
  2328. {
  2329. string eid = GetPostString("ctid");
  2330. int userid = GetPostInt("DesignUserId");
  2331. string[] idlist = eid.Split(',');
  2332. if (idlist.Length <= 0)
  2333. {
  2334. returnErrorMsg("订单不能为空");
  2335. return;
  2336. }
  2337. foreach (string ctid in idlist)
  2338. {
  2339. CeErpTradeCell entity = null;
  2340. CeErpDesignerBill entitys = null;
  2341. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2342. else continue;
  2343. if (entity != null)
  2344. {
  2345. if (userid == 2125 || userid == 3542)
  2346. { }
  2347. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2348. {
  2349. returnErrorMsg("金额错误的订单无法指派");
  2350. return;
  2351. }
  2352. if (entity.OrderState >= 5)
  2353. {
  2354. returnErrorMsg("已经设计完成无法指派");
  2355. return;
  2356. }
  2357. if (entity.OrderState == -1)
  2358. {
  2359. returnErrorMsg("审核中的订单无法指派");
  2360. return;
  2361. }
  2362. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2363. {
  2364. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2365. return;
  2366. }
  2367. //157赖橙帆 159林晨 73 静之颖
  2368. 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)
  2369. {
  2370. returnErrorMsg("指派设计共创无法再次指派!");
  2371. return;
  2372. }
  2373. entity.OrderState = 3;
  2374. if (entity.SupplierId == 0)
  2375. {
  2376. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2377. entity.SupplierId = suid;
  2378. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2379. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2380. }
  2381. if (userid == 2125 && entity.seller_memo != "")
  2382. {
  2383. apiDesign.API_GetPrintData_CreateOrder(entity);
  2384. }
  2385. if (userid == 3542 && entity.seller_memo != "")
  2386. {
  2387. string userPost = CurrentUser.UserPost.Post.Code;
  2388. if (CurrentUser.UserID == 73)
  2389. {
  2390. userPost = "SysAdmin";
  2391. }
  2392. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2393. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2394. if (response.msg != "设计共创:成功")
  2395. {
  2396. returnErrorMsg(response.msg);
  2397. return;
  2398. }
  2399. entity.DispatchSort = 2;
  2400. }
  2401. else
  2402. {
  2403. if (entity.DispatchSort == 2)
  2404. {
  2405. ApiVo apiVo = new ApiVo();
  2406. apiVo.actionName = "closeDesign";
  2407. apiVo.orderNumber = entity.ctid;
  2408. designHelper.API_WorkCore(apiVo);//closeDesign
  2409. }
  2410. entity.DispatchSort = 0;
  2411. }
  2412. entity.DesignUserId = userid;
  2413. entity.WaitDesignTime = DateTime.Now;
  2414. entity.UpdateTime = DateTime.Now;
  2415. entity.Update();
  2416. string name = commonHelper.getUserNameById(userid);
  2417. commonHelper.UpdateRelationOrder(entity.ctid);
  2418. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2419. }
  2420. }
  2421. returnSuccessMsg("操作成功!");
  2422. return;
  2423. }
  2424. }
  2425. public string getTidByCtid(string ctid)
  2426. {
  2427. string tid = "";
  2428. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2429. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2430. if (dataTable != null && dataTable.Rows.Count > 0)
  2431. {
  2432. tid = dataTable.Rows[0]["tid"].ToString();
  2433. }
  2434. return tid;
  2435. }
  2436. public List<string> getTidByCtidMore(string ctid)
  2437. {
  2438. 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);
  2439. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2440. List<string> list = new List<string>();
  2441. if (dataTable != null && dataTable.Rows.Count > 0)
  2442. {
  2443. foreach (DataRow item in dataTable.Rows)
  2444. {
  2445. list.Add("'" + item["tid"].ToString() + "'");
  2446. }
  2447. }
  2448. return list;
  2449. }
  2450. public List<string> getTidByCtidLike(string ctid)
  2451. {
  2452. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2453. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2454. List<string> list = new List<string>();
  2455. if (dataTable != null && dataTable.Rows.Count > 0)
  2456. {
  2457. foreach (DataRow item in dataTable.Rows)
  2458. {
  2459. list.Add("'" + item["tid"].ToString() + "'");
  2460. }
  2461. }
  2462. return list;
  2463. }
  2464. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2465. {
  2466. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2467. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2468. List<string> list = new List<string>();
  2469. if (dataTable != null && dataTable.Rows.Count > 0)
  2470. {
  2471. foreach (DataRow item in dataTable.Rows)
  2472. {
  2473. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2474. {
  2475. continue;
  2476. }
  2477. list.Add("'" + item["receiverId"].ToString() + "'");
  2478. }
  2479. }
  2480. return list;
  2481. }
  2482. public void get_erp_myorderlist()
  2483. {
  2484. DataStruct dStruct = GetPostStruct();
  2485. List<string> lw = new List<string>();
  2486. string tid = GetPostString("ctid");
  2487. if (tid.Length > 0)
  2488. {
  2489. string select_tid = getTidByCtid(tid);
  2490. lw.Add(string.Format("tid='{0}'", select_tid));
  2491. }
  2492. else
  2493. {
  2494. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2495. }
  2496. //12-1 修改
  2497. string urgent = GetPostString("urgent");
  2498. string back = GetPostString("back");
  2499. string offlineSearch = GetPostString("offlineSearch");
  2500. if (!string.IsNullOrWhiteSpace(urgent))
  2501. {
  2502. if (urgent.Equals("true"))
  2503. {
  2504. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2505. }
  2506. }
  2507. if (!string.IsNullOrWhiteSpace(back))
  2508. {
  2509. if (back.Equals("true"))
  2510. {
  2511. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2512. }
  2513. }
  2514. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2515. {
  2516. if (offlineSearch.Equals("true"))
  2517. {
  2518. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2519. }
  2520. }
  2521. //end
  2522. string shopname = GetPostString("shopname");
  2523. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2524. string buyernick = GetPostString("buyer_nick");
  2525. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2526. string design = GetPostString("design");
  2527. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2528. string orderState = GetPostString("orderState");
  2529. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2530. string sellermemo = GetPostString("seller_memo");
  2531. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2532. string date1 = GetPostString("date1");
  2533. string date2 = GetPostString("date2");
  2534. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2535. if (dw.Length > 0) lw.Add(dw);
  2536. string price1 = GetPostString("price1");
  2537. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2538. string price2 = GetPostString("price2");
  2539. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2540. string urgency = GetPostString("urgency");
  2541. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2542. string after = GetPostString("after");
  2543. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2544. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2545. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2546. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2547. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2548. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2549. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2550. if (dt != null && dt.Rows.Count > 0)
  2551. {
  2552. foreach (DataRow dr in dt.Rows)
  2553. {
  2554. try
  2555. {
  2556. // 对象操作
  2557. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2558. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2559. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2560. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2561. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2562. if (dStruct.PageSize != 100000)
  2563. {
  2564. if (dr["DispatchSort"].ToString() == "2")
  2565. {
  2566. dr["gongchuang"] = 200;
  2567. }
  2568. else if ("外协".Equals(dr["ToType"].ToString()))
  2569. {
  2570. dr["gongchuang"] = 200;
  2571. }
  2572. else if ("内部".Equals(dr["ToType"].ToString()))
  2573. {
  2574. dr["gongchuang"] = -1;
  2575. }
  2576. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2577. {
  2578. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2579. dr["gongchuang"] = response.code;
  2580. }
  2581. }
  2582. }
  2583. catch (NullReferenceException ex)
  2584. {
  2585. }
  2586. }
  2587. }
  2588. writeGridDataTableJson(dStruct.TotalCount, dt);
  2589. }
  2590. public void get_erp_myreturnorderlist()
  2591. {
  2592. DataStruct dStruct = GetPostStruct();
  2593. List<string> lw = new List<string>();
  2594. string tid = GetPostString("ctid");
  2595. if (tid.Length > 0)
  2596. {
  2597. string select_tid = getTidByCtid(tid);
  2598. lw.Add(string.Format("tid='{0}'", select_tid));
  2599. }
  2600. else
  2601. {
  2602. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2603. }
  2604. string shopname = GetPostString("shopname");
  2605. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2606. string buyernick = GetPostString("buyer_nick");
  2607. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2608. string design = GetPostString("design");
  2609. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2610. string orderState = GetPostString("orderState");
  2611. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2612. string sellermemo = GetPostString("seller_memo");
  2613. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2614. string date1 = GetPostString("date1");
  2615. string date2 = GetPostString("date2");
  2616. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2617. if (dw.Length > 0) lw.Add(dw);
  2618. string price1 = GetPostString("price1");
  2619. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2620. string price2 = GetPostString("price2");
  2621. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2622. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2623. {
  2624. lw.Add(string.Format("CusOrgID = 94"));
  2625. }
  2626. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2627. {
  2628. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2629. }
  2630. else
  2631. {
  2632. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2633. }
  2634. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2635. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2636. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2637. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2638. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2639. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2640. if (dt != null && dt.Rows.Count > 0)
  2641. {
  2642. foreach (DataRow dr in dt.Rows)
  2643. {
  2644. try
  2645. {
  2646. // 对象操作
  2647. if (dStruct.PageSize != 100000)
  2648. {
  2649. if (dr["DispatchSort"].ToString() == "2")
  2650. {
  2651. dr["gongchuang"] = 200;
  2652. }
  2653. else if ("外协".Equals(dr["ToType"].ToString()))
  2654. {
  2655. dr["gongchuang"] = 200;
  2656. }
  2657. else if ("内部".Equals(dr["ToType"].ToString()))
  2658. {
  2659. dr["gongchuang"] = -1;
  2660. }
  2661. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2662. {
  2663. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2664. dr["gongchuang"] = response.code;
  2665. }
  2666. }
  2667. }
  2668. catch (NullReferenceException ex)
  2669. {
  2670. // 处理空引用异常
  2671. }
  2672. }
  2673. }
  2674. writeGridDataTableJson(dStruct.TotalCount, dt);
  2675. }
  2676. public void get_erp_myorderlist_pregather()
  2677. {
  2678. string date1 = GetPostString("date1");
  2679. string date2 = GetPostString("date2");
  2680. int userId = CurrentUser.UserID; //客服id
  2681. string orderWhere = "";
  2682. List<string> lw = new List<string>();
  2683. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2684. if (dw.Length > 0) lw.Add(dw);
  2685. lw.Add(string.Format("CustomerUserId={0}", userId));
  2686. lw.Add(string.Format("OrderState<9"));
  2687. orderWhere = string.Join(" and ", lw.ToArray());
  2688. string orderWhere2 = "";
  2689. List<string> lw2 = new List<string>();
  2690. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2691. if (dw2.Length > 0) lw2.Add(dw2);
  2692. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2693. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2694. string sql = string.Format("select *" +
  2695. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2696. "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 " +
  2697. "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 " +
  2698. "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");
  2699. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2700. //writeGridDataTableJson(dt.Rows.Count, dt);
  2701. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2702. }
  2703. public void upd_erp_publishorder()
  2704. {
  2705. if (UrlPostParmsCheck("ctid"))
  2706. {
  2707. string eid = GetPostString("ctid");
  2708. CeErpTradeCell entity = null;
  2709. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2710. if (entity != null)
  2711. {
  2712. entity.OrderState = 0; //发布后,变为待抢单
  2713. entity.Update();
  2714. commonHelper.UpdateRelationOrder(entity.ctid);
  2715. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2716. returnSuccessMsg("发布成功!");
  2717. return;
  2718. }
  2719. returnErrorMsg("找不到记录");
  2720. }
  2721. }
  2722. public void get_erp_my_tiporder()
  2723. {
  2724. StringBuilder sql = new StringBuilder();
  2725. int userId = 0;
  2726. if (CurrentUser != null) userId = CurrentUser.UserID;
  2727. string posCode = CurrentUser.UserPost.Post.Code;
  2728. string isTipedAfterSaleVerify = GetPostString("af");
  2729. DataTable dt = new DataTable();
  2730. if (posCode != "Supplier")
  2731. {
  2732. if (posCode == "CustomerService" || posCode == "Director")
  2733. {
  2734. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2735. }
  2736. else if (posCode == "Place" || posCode == "PlaceMr")
  2737. {
  2738. }
  2739. else
  2740. {
  2741. string teamIds = CurrentUser.User.TeamIds;
  2742. if (teamIds == "")
  2743. {
  2744. teamIds = "0";
  2745. }
  2746. 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);
  2747. }
  2748. if (sql.Length > 0)
  2749. {
  2750. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2751. }
  2752. }
  2753. if (dt.Rows.Count <= 0)
  2754. {
  2755. string key = "aftersale_order_" + userId;
  2756. if (RedisHelper.HasKey(key))
  2757. {
  2758. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2759. dt.Columns.Add("ctid", typeof(string));
  2760. dt.Columns.Add("IsReadTag", typeof(int));
  2761. foreach (var i in list)
  2762. {
  2763. DataRow data = dt.NewRow();
  2764. data["ctid"] = i;
  2765. data["IsReadTag"] = 4;
  2766. dt.Rows.Add(data);
  2767. }
  2768. RedisHelper.StringDelete(key);
  2769. }
  2770. }
  2771. if (dt.Rows.Count <= 0)
  2772. {
  2773. sql = new StringBuilder();
  2774. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2775. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2776. }
  2777. if (posCode == "Supplier")
  2778. {
  2779. string ids = CurrentUser.User.pemVend;
  2780. if (ids != null && ids.Length > 0)
  2781. {
  2782. string[] ids_list = ids.Split(',');
  2783. foreach (var item in ids_list)
  2784. {
  2785. string key = "return_order_" + item;
  2786. if (RedisHelper.HasKey(key))
  2787. {
  2788. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2789. dt.Columns.Add("ctid", typeof(string));
  2790. dt.Columns.Add("IsReadTag", typeof(int));
  2791. foreach (var i in list)
  2792. {
  2793. DataRow data = dt.NewRow();
  2794. data["ctid"] = i;
  2795. data["IsReadTag"] = 1;
  2796. dt.Rows.Add(data);
  2797. }
  2798. RedisHelper.StringDelete(key);
  2799. }
  2800. }
  2801. }
  2802. if (dt.Rows.Count <= 0)
  2803. {
  2804. sql = new StringBuilder();
  2805. 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);
  2806. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2807. }
  2808. }
  2809. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2810. }
  2811. public void reset_erp_tiporder()
  2812. {
  2813. string ids = GetPostString("ids");
  2814. string[] ctidList = ids.Split(',');
  2815. foreach (string ctid in ctidList)
  2816. {
  2817. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2818. if (enty != null)
  2819. {
  2820. enty.IsReadTag = 0;
  2821. enty.Update();
  2822. }
  2823. }
  2824. returnSuccessMsg("成功!");
  2825. return;
  2826. }
  2827. public void get_erp_designlist()
  2828. {
  2829. DataStruct dStruct = GetPostStruct();
  2830. List<string> lw = new List<string>();
  2831. string tid = GetPostString("ctid");
  2832. if (tid.Length > 0)
  2833. {
  2834. string select_tid = getTidByCtid(tid);
  2835. lw.Add(string.Format("tid='{0}'", select_tid));
  2836. }
  2837. string shopname = GetPostString("shopname");
  2838. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2839. string buyernick = GetPostString("buyer_nick");
  2840. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2841. string customer = GetPostString("customer");
  2842. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2843. string design = GetPostString("design");
  2844. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2845. string orderState = GetPostString("orderState");
  2846. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2847. lw.Add(string.Format("OrderState<6"));
  2848. string address = GetPostString("address");
  2849. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2850. string sellermemo = GetPostString("seller_memo");
  2851. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2852. string date1 = GetPostString("date1");
  2853. string date2 = GetPostString("date2");
  2854. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2855. if (dw.Length > 0) lw.Add(dw);
  2856. string apdate1 = GetPostString("apdate1");
  2857. string apdate2 = GetPostString("apdate2");
  2858. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2859. if (dwap.Length > 0) lw.Add(dwap);
  2860. string price1 = GetPostString("price1");
  2861. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2862. string price2 = GetPostString("price2");
  2863. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2864. string designTime = GetPostString("designtime");
  2865. if (designTime.Length > 0)
  2866. {
  2867. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2868. }
  2869. string usershop = CurrentUser.User.pemShop;
  2870. if (usershop.Length > 0)
  2871. {
  2872. lw.Add(string.Format("shopId in ({0})", usershop));
  2873. }
  2874. int myOrgid = CurrentUser.UserPost.OrgID;
  2875. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2876. if (myOrgCode.IndexOf("Designer") != -1)
  2877. {
  2878. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2879. {
  2880. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2881. }
  2882. else
  2883. {
  2884. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2885. }
  2886. }
  2887. else
  2888. {
  2889. string orgId = GetPostString("designerhd");
  2890. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2891. }
  2892. if (tid.Length > 0 || buyernick.Length > 0)
  2893. {
  2894. lw.Add(string.Format("OrderState >= 3"));
  2895. }
  2896. else
  2897. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2898. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2899. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2900. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2901. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2902. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2903. if (dt != null && dt.Rows.Count > 0)
  2904. {
  2905. foreach (DataRow dr in dt.Rows)
  2906. {
  2907. try
  2908. {
  2909. // 对象操作
  2910. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2911. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2912. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2913. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2914. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2915. if (dStruct.PageSize != 100000)
  2916. {
  2917. if (dr["DispatchSort"].ToString() == "2")
  2918. {
  2919. dr["gongchuang"] = 200;
  2920. }
  2921. else if ("外协".Equals(dr["ToType"].ToString()))
  2922. {
  2923. dr["gongchuang"] = 200;
  2924. }
  2925. else if ("内部".Equals(dr["ToType"].ToString()))
  2926. {
  2927. dr["gongchuang"] = -1;
  2928. }
  2929. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2930. {
  2931. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2932. dr["gongchuang"] = response.code;
  2933. }
  2934. }
  2935. }
  2936. catch (NullReferenceException ex)
  2937. {
  2938. }
  2939. }
  2940. }
  2941. writeGridDataTableJson(dStruct.TotalCount, dt);
  2942. }
  2943. public void get_erp_mydesignlist()
  2944. {
  2945. DataStruct dStruct = GetPostStruct();
  2946. List<string> lw = new List<string>();
  2947. string tid = GetPostString("ctid");
  2948. if (tid.Length > 0)
  2949. {
  2950. string select_tid = getTidByCtid(tid);
  2951. lw.Add(string.Format("tid='{0}'", select_tid));
  2952. }
  2953. string shopname = GetPostString("shopname");
  2954. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2955. string buyernick = GetPostString("buyer_nick");
  2956. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2957. string customer = GetPostString("customer");
  2958. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2959. string orderState = GetPostString("orderState");
  2960. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2961. //lw.Add(string.Format("OrderState<6"));
  2962. string date1 = GetPostString("date1");
  2963. string date2 = GetPostString("date2");
  2964. string dw = GetDateWhere("pay_time", date1, date2);
  2965. if (dw.Length > 0) lw.Add(dw);
  2966. string apdate1 = GetPostString("apdate1");
  2967. string apdate2 = GetPostString("apdate2");
  2968. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2969. if (dwap.Length > 0) lw.Add(dwap);
  2970. string price1 = GetPostString("price1");
  2971. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2972. string price2 = GetPostString("price2");
  2973. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2974. string olddownload = GetPostString("olddown");
  2975. if (olddownload == "1")
  2976. {
  2977. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2978. }
  2979. else if (olddownload == "2")
  2980. {
  2981. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2982. }
  2983. string sellermemo = GetPostString("seller_memo");
  2984. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2985. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2986. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2987. {
  2988. if (CurrentUser.User.TeamIds.Length > 0)
  2989. {
  2990. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2991. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2992. else
  2993. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2994. }
  2995. else
  2996. {
  2997. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2998. }
  2999. }
  3000. if (tid.Length <= 0)
  3001. {
  3002. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  3003. }
  3004. lw.Add(string.Format("IsReturn!=3"));
  3005. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  3006. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3007. string teamids = CurrentUser.User.TeamIds.ToString();
  3008. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3009. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  3010. if (dt != null && dt.Rows.Count > 0)
  3011. {
  3012. foreach (DataRow dr in dt.Rows)
  3013. {
  3014. try
  3015. {
  3016. // 对象操作
  3017. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  3018. ceErpTradeCell.ctid = dr["ctid"].ToString();
  3019. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  3020. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  3021. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  3022. if (dStruct.PageSize != 100000)
  3023. {
  3024. if (dr["DispatchSort"].ToString() == "2")
  3025. {
  3026. dr["gongchuang"] = 200;
  3027. }
  3028. else if ("外协".Equals(dr["ToType"].ToString()))
  3029. {
  3030. dr["gongchuang"] = 200;
  3031. }
  3032. else if ("内部".Equals(dr["ToType"].ToString()))
  3033. {
  3034. dr["gongchuang"] = -1;
  3035. }
  3036. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  3037. {
  3038. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  3039. dr["gongchuang"] = response.code;
  3040. }
  3041. }
  3042. }
  3043. catch (NullReferenceException ex)
  3044. {
  3045. }
  3046. }
  3047. }
  3048. writeGridDataTableJson(dStruct.TotalCount, dt);
  3049. }
  3050. public void set_erp_startdesign()
  3051. {
  3052. if (UrlPostParmsCheck("ctid"))
  3053. {
  3054. string eid = GetPostString("ctid");
  3055. CeErpTradeCell entity = null;
  3056. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3057. if (entity != null)
  3058. {
  3059. if (entity.OrderState != 3)
  3060. {
  3061. returnErrorMsg("请刷新,订单已经设计了");
  3062. return;
  3063. }
  3064. entity.StartDesignTime = DateTime.Now;
  3065. entity.OrderState = 4;
  3066. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3067. {
  3068. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3069. entity.SupplierId = suid;
  3070. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3071. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3072. }
  3073. entity.UpdateTime = DateTime.Now;
  3074. //entity.MakeSupplier = suname;
  3075. entity.Update();
  3076. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3077. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3078. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3079. commonHelper.getCytPrice(entity);
  3080. returnSuccessMsg("操作成功!");
  3081. return;
  3082. }
  3083. returnErrorMsg("找不到记录");
  3084. }
  3085. }
  3086. public void ins_erp_designselfmemo()
  3087. {
  3088. if (UrlPostParmsCheck("ctid"))
  3089. {
  3090. string eid = GetPostString("ctid");
  3091. string con = GetPostString("con");
  3092. CeErpTradeCell entity = null;
  3093. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3094. if (entity != null)
  3095. {
  3096. entity.DesignSelfMemo = con;
  3097. entity.Update();
  3098. returnSuccessMsg("操作成功!");
  3099. return;
  3100. }
  3101. returnErrorMsg("找不到记录");
  3102. }
  3103. }
  3104. public void ins_erp_designprice()
  3105. {
  3106. if (UrlPostParmsCheck("ctid"))
  3107. {
  3108. string eid = GetPostString("ctid");
  3109. int uid = CurrentUser.UserID;
  3110. string userName = CurrentUser.UserName;
  3111. CeErpTradeCell entity = null;
  3112. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3113. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3114. if (entitys == null)
  3115. {
  3116. entitys = new CeErpDesignerBill();
  3117. }
  3118. if (entity != null)
  3119. {
  3120. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3121. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3122. entity.StartDesignTime = DateTime.Now;
  3123. entity.OrderState = 4;
  3124. string suname = "";
  3125. if (entity.SupplierId == 0)
  3126. {
  3127. int sid = commonHelper.autoDistributeToSupplier(entity);
  3128. entity.SupplierId = sid;
  3129. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3130. }
  3131. entity.Update();
  3132. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3133. if (ceErpUserPost != null)
  3134. {
  3135. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3136. if (ceErpPost != null)
  3137. {
  3138. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3139. {
  3140. entitys.tid = entity.ctid;
  3141. entitys.oid = entity.tid;
  3142. entitys.uid = uid;
  3143. entitys.userName = userName;
  3144. entitys.designerType = 1;
  3145. entitys.designerTypeText = "内部设计师";
  3146. entitys.price = Convert.ToDouble(GetPostString("price"));
  3147. entitys.designNum = GetPostInt("designNum");
  3148. entitys.modifyNum = GetPostInt("modifyNum");
  3149. entitys.designSize = GetPostString("designSize");
  3150. entitys.modifySize = GetPostString("modifySize");
  3151. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3152. {
  3153. entitys.create_time = DateTime.Now;
  3154. entitys.create_u_id = uid;
  3155. entitys.create_u_name = userName;
  3156. entitys.Save();
  3157. }
  3158. else
  3159. {
  3160. entitys.update_time = DateTime.Now;
  3161. entitys.update_u_id = uid;
  3162. entitys.update_u_name = userName;
  3163. entitys.Update();
  3164. }
  3165. }
  3166. }
  3167. }
  3168. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3169. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3170. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3171. if (suname != "")
  3172. {
  3173. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3174. }
  3175. commonHelper.getCytPrice(entity);
  3176. returnSuccessMsg("操作成功!");
  3177. return;
  3178. }
  3179. returnErrorMsg("找不到记录");
  3180. }
  3181. }
  3182. public void upload_erp_filecomplete()
  3183. {
  3184. if (UrlPostParmsCheck("ctid"))
  3185. {
  3186. string eid = GetPostString("ctid");
  3187. CeErpTradeCell entity = null;
  3188. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3189. if (entity != null)
  3190. {
  3191. entity.OrderState = 5; //设计完成
  3192. entity.Update();
  3193. returnSuccessMsg(eid + "上传成功,设计完成!");
  3194. return;
  3195. }
  3196. returnErrorMsg("找不到订单记录");
  3197. }
  3198. }
  3199. public void get_erp_designovertimelist()
  3200. {
  3201. DataStruct dStruct = GetPostStruct();
  3202. List<string> lw = new List<string>();
  3203. string tid = GetPostString("ctid");
  3204. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3205. string shopname = GetPostString("shopname");
  3206. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3207. string buyernick = GetPostString("buyer_nick");
  3208. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3209. string ResponsibleMan = GetPostString("responsible");
  3210. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3211. string date1 = GetPostString("date1");
  3212. string date2 = GetPostString("date2");
  3213. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3214. if (dw.Length > 0) lw.Add(dw);
  3215. string price1 = GetPostString("price1");
  3216. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3217. string price2 = GetPostString("price2");
  3218. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3219. string orderState = GetPostString("orderState");
  3220. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3221. string sellermemo = GetPostString("seller_memo");
  3222. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3223. lw.Add(string.Format("UnusualTag=3"));
  3224. lw.Add(string.Format("IsRefund<={0}", 1));
  3225. dStruct.Order = "WaitDesignTime desc";
  3226. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3227. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3228. writeGridDataTableJson(dStruct.TotalCount, dt);
  3229. }
  3230. //设计管理 获取抢单大厅列表
  3231. public void get_erp_grabinglist()
  3232. {
  3233. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3234. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3235. bool oldOrder = false;
  3236. if (org != null)
  3237. {
  3238. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3239. }
  3240. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3241. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3242. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3243. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3244. //先处理订单数据
  3245. if (dt.Rows.Count > 0)
  3246. {
  3247. Dictionary<string, int> design = null;
  3248. int count = 0;
  3249. foreach (DataRow row in dt.Rows)
  3250. {
  3251. if (map.ContainsKey(row["ShopId"].ToString()))
  3252. {
  3253. map.TryGetValue(row["ShopId"].ToString(), out design);
  3254. }
  3255. else
  3256. {
  3257. design = new Dictionary<string, int>();
  3258. }
  3259. if (design.ContainsKey(row["ProductId"].ToString()))
  3260. {
  3261. design.TryGetValue(row["ProductId"].ToString(), out count);
  3262. }
  3263. count++;
  3264. design[row["ProductId"].ToString()] = count;
  3265. map[row["ShopId"].ToString()] = design;
  3266. }
  3267. }
  3268. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3269. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3270. //把店铺排序和技能排序分类
  3271. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3272. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3273. if (design_dt.Rows.Count > 0)
  3274. {
  3275. Dictionary<string, string> design = null;
  3276. List<string> shopIds = null;
  3277. foreach (DataRow row in design_dt.Rows)
  3278. {
  3279. if ("0".Equals(row["designId"].ToString()))
  3280. {
  3281. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3282. {
  3283. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3284. }
  3285. else
  3286. {
  3287. shopIds = new List<string>();
  3288. }
  3289. shopIds.Add(row["shopId"].ToString());
  3290. shop_orders[row["orders"].ToString()] = shopIds;
  3291. }
  3292. else
  3293. {
  3294. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3295. {
  3296. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3297. }
  3298. else
  3299. {
  3300. design = new Dictionary<string, string>();
  3301. }
  3302. design[row["orders"].ToString()] = row["designId"].ToString();
  3303. design_orders[row["shopId"].ToString()] = design;
  3304. }
  3305. }
  3306. //处理成key value后根据key排序
  3307. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3308. foreach (List<string> val in shop_orders.Values)
  3309. {
  3310. if (val != null)
  3311. {
  3312. foreach (string key in val)
  3313. {
  3314. if (design_orders.ContainsKey(key.ToString()))
  3315. {
  3316. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3317. }
  3318. }
  3319. }
  3320. }
  3321. }
  3322. //校验哪个优先级有订单
  3323. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3324. foreach (string key in shop_orders.Keys)
  3325. {
  3326. List<string> ids = null;
  3327. shop_orders.TryGetValue(key, out ids);
  3328. //id为shopid
  3329. foreach (string id in ids)
  3330. {
  3331. Dictionary<string, int> list = null;
  3332. Dictionary<string, string> desing = null;
  3333. map.TryGetValue(id, out list);
  3334. design_orders.TryGetValue(id, out desing);
  3335. if (list != null && desing != null)
  3336. {
  3337. foreach (var item in desing)
  3338. {
  3339. int count = 0;
  3340. if (list.ContainsKey(item.Value))
  3341. {
  3342. list.TryGetValue(item.Value, out count);
  3343. if (count > 0)
  3344. {
  3345. designIds[id] = item.Value;
  3346. break;
  3347. }
  3348. }
  3349. }
  3350. }
  3351. }
  3352. if (designIds.Count > 0)
  3353. {
  3354. break;
  3355. }
  3356. }
  3357. DataTable table = new DataTable();
  3358. table.Columns.Add("tid", typeof(string));
  3359. table.Columns.Add("ctid", typeof(string));
  3360. table.Columns.Add("seller_nick", typeof(string));
  3361. table.Columns.Add("productName", typeof(string));
  3362. table.Columns.Add("pay_time", typeof(string));
  3363. table.Columns.Add("seller_memo", typeof(string));
  3364. if (designIds.Count > 0)
  3365. {
  3366. string shopId = "";
  3367. string productId = "";
  3368. foreach (var designInfo in designIds)
  3369. {
  3370. shopId = designInfo.Key;
  3371. productId = designInfo.Value;
  3372. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3373. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3374. if (dt.Rows.Count > 0)
  3375. {
  3376. foreach (DataRow row in dt.Rows)
  3377. {
  3378. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3379. {
  3380. DataRow data = table.NewRow();
  3381. data["ctid"] = row["ctid"].ToString();
  3382. data["tid"] = row["tid"].ToString();
  3383. data["seller_nick"] = ceErpShop.ShopName;
  3384. data["pay_time"] = row["pay_time"].ToString();
  3385. data["seller_memo"] = row["seller_memo"].ToString();
  3386. data["productName"] = ceErpProduct.PType;
  3387. table.Rows.Add(data);
  3388. }
  3389. }
  3390. }
  3391. }
  3392. }
  3393. writeGridDataTableJson(table.Rows.Count, table);
  3394. }
  3395. private object rushLockObject = new object();
  3396. public void set_erp_grabingorder()
  3397. {
  3398. if (UrlPostParmsCheck("ctid"))
  3399. {
  3400. int total = CurrentUser.User.Person.Total;
  3401. int userId = CurrentUser.User.ID;
  3402. int noFinish = CurrentUser.User.Person.NoFinish;
  3403. int finalization = CurrentUser.User.Person.Finalization;
  3404. string eids = GetPostString("ctid");
  3405. string key = "RushKey_" + userId;
  3406. int count = 0;
  3407. if (erpRedis.RedisHelper.KeyExists(key))
  3408. {
  3409. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3410. if (redisCount != null)
  3411. {
  3412. count = Convert.ToInt32(redisCount);
  3413. }
  3414. }
  3415. if (count >= total)
  3416. {
  3417. returnErrorMsg("半小时内已经抢" + total + "单");
  3418. return;
  3419. }
  3420. string[] ctidlist = eids.Split(',');
  3421. if (count + ctidlist.Length > total)
  3422. {
  3423. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3424. return;
  3425. }
  3426. int itag = 0;
  3427. lock (rushLockObject)
  3428. {
  3429. if (ctidlist.Length > 0)
  3430. {
  3431. string[] dtList = new string[ctidlist.Length];
  3432. for (int i = 0; i < ctidlist.Length; i++)
  3433. {
  3434. dtList[i] = "'" + ctidlist[i] + "'";
  3435. }
  3436. 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"));
  3437. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3438. if (dt_user.Rows.Count > 0)
  3439. {
  3440. int doing = 0;//未定稿
  3441. int finish = 0;//已完成
  3442. foreach (DataRow dr in dt_user.Rows)
  3443. {
  3444. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3445. {
  3446. doing++;
  3447. }
  3448. else
  3449. {
  3450. finish++;
  3451. }
  3452. }
  3453. if (doing >= noFinish)
  3454. {
  3455. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3456. return;
  3457. }
  3458. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3459. {
  3460. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3461. return;
  3462. }
  3463. }
  3464. //校验选择单子状态
  3465. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3466. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3467. if (dt.Rows.Count > 0)
  3468. {
  3469. List<string> list = new List<string>();
  3470. foreach (DataRow dr in dt.Rows)
  3471. {
  3472. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3473. {
  3474. list.Add(dr["ctid"].ToString());
  3475. }
  3476. }
  3477. if (list.Count > 0)
  3478. {
  3479. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3480. return;
  3481. }
  3482. }
  3483. foreach (string ctid in ctidlist)
  3484. {
  3485. CeErpTradeCell entity = null;
  3486. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3487. if (entity != null)
  3488. {
  3489. entity.OrderState = 3;
  3490. entity.DesignUserId = CurrentUser.UserID;
  3491. entity.WaitDesignTime = DateTime.Now;
  3492. entity.StartDesignTime = DateTime.Now;
  3493. entity.Update();
  3494. commonHelper.UpdateRelationOrder(entity.ctid);
  3495. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3496. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3497. itag++;
  3498. }
  3499. }
  3500. }
  3501. }
  3502. count += ctidlist.Length;
  3503. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3504. if (itag == 0)
  3505. returnErrorMsg("没有找到相关订单");
  3506. else
  3507. returnSuccessMsg("抢单成功!");
  3508. return;
  3509. }
  3510. }
  3511. public void get_erp_waitorderlist()
  3512. {
  3513. DataStruct dStruct = GetPostStruct();
  3514. List<string> lw = new List<string>();
  3515. string tid = GetPostString("ctid");
  3516. if (tid.Length > 0)
  3517. {
  3518. string select_tid = getTidByCtid(tid);
  3519. lw.Add(string.Format("tid='{0}'", select_tid));
  3520. }
  3521. string shopname = GetPostString("shopname");
  3522. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3523. string buyernick = GetPostString("buyer_nick");
  3524. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3525. string customer = GetPostString("customer");
  3526. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3527. string design = GetPostString("design");
  3528. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3529. string orderState = GetPostString("orderState");
  3530. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3531. string supplier = GetPostString("supplier");
  3532. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3533. string sellermemo = GetPostString("seller_memo");
  3534. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3535. string otherMemo = GetPostString("otherMemo");
  3536. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3537. string address = GetPostString("address");
  3538. 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));
  3539. string date1 = GetPostString("date1");
  3540. string date2 = GetPostString("date2");
  3541. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3542. if (dw.Length > 0) lw.Add(dw);
  3543. string price1 = GetPostString("price1");
  3544. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3545. string price2 = GetPostString("price2");
  3546. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3547. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3548. lw.Add(string.Format("IsSample != 2 "));
  3549. lw.Add(string.Format("OrderState = 5 "));
  3550. lw.Add(string.Format("IsRefund<={0}", 1));
  3551. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3552. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3553. string pagesize = GetPostString("pagesize");
  3554. if (pagesize != null)
  3555. {
  3556. dStruct.PageSize = 200;
  3557. }
  3558. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3559. List<string> tids = new List<string>();
  3560. if (dt != null)
  3561. {
  3562. dt.Columns.Add("compenPrice", typeof(double));
  3563. foreach (DataRow dr in dt.Rows)
  3564. {
  3565. if (Convert.IsDBNull(dr["compenPrice"]))
  3566. {
  3567. dr["compenPrice"] = 0;
  3568. }
  3569. tids.Add("'" + dr["tid"].ToString() + "'");
  3570. 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();
  3571. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3572. {
  3573. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3574. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3575. entity.SupplierId = suid;
  3576. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3577. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3578. entity.Update();
  3579. }
  3580. }
  3581. }
  3582. if (tids.Count > 0)
  3583. {
  3584. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3585. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3586. if (dt_price != null && dt_price.Rows.Count > 0)
  3587. {
  3588. foreach (DataRow dr in dt_price.Rows)
  3589. {
  3590. foreach (DataRow row in dt.Rows)
  3591. {
  3592. if (row["tid"].Equals(dr["ptid"]))
  3593. {
  3594. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3595. break;
  3596. }
  3597. }
  3598. }
  3599. }
  3600. }
  3601. writeGridDataTableJson(dStruct.TotalCount, dt);
  3602. }
  3603. public void get_erp_supplierwaitorderlist()
  3604. {
  3605. DataStruct dStruct = GetPostStruct();
  3606. List<string> lw = new List<string>();
  3607. string tid = GetPostString("ctid");
  3608. if (tid.Length > 0)
  3609. {
  3610. string select_tid = getTidByCtid(tid);
  3611. lw.Add(string.Format("tid='{0}'", select_tid));
  3612. }
  3613. string shopname = GetPostString("shopname");
  3614. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3615. string sellermemo = GetPostString("seller_memo");
  3616. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3617. string date1 = GetPostString("date1");
  3618. string date2 = GetPostString("date2");
  3619. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3620. if (dw.Length > 0) lw.Add(dw);
  3621. lw.Add(string.Format("OrderState = 5 "));
  3622. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3623. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3624. {
  3625. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3626. }
  3627. string supplier = GetPostString("supplier");
  3628. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3629. {
  3630. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3631. }
  3632. lw.Add(string.Format("IsRefund<={0}", 1));
  3633. dStruct.Order = "FinishDesignTime desc";
  3634. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3635. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3636. if (dt != null)
  3637. {
  3638. foreach (DataRow dr in dt.Rows)
  3639. {
  3640. 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();
  3641. }
  3642. }
  3643. writeGridDataTableJson(dStruct.TotalCount, dt);
  3644. }
  3645. public void upd_erp_verifytosupplier()
  3646. {
  3647. if (UrlPostParmsCheck("ctid"))
  3648. {
  3649. string eids = GetPostString("ctid");
  3650. CeErpTradeCell entity = null;
  3651. string[] eidsList = eids.Split(',');
  3652. if (eidsList.Length <= 0)
  3653. {
  3654. returnErrorMsg("订单号不能空");
  3655. return;
  3656. }
  3657. List<string> tLst = new List<string>();
  3658. foreach (string ctidstr in eidsList)
  3659. {
  3660. tLst.Add("'" + ctidstr + "'");
  3661. CeErpDataSendOrderInfo.createObject(ctidstr);
  3662. }
  3663. string needtids = string.Join(",", tLst.ToArray());
  3664. StringBuilder sql = new StringBuilder();
  3665. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3666. 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);
  3667. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3668. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3669. returnSuccessMsg("操作成功!");
  3670. return;
  3671. /**foreach (string ctidstr in eidsList)
  3672. {
  3673. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3674. if (entity != null)
  3675. {
  3676. if (entity.SupplierId == 0)
  3677. {
  3678. continue;
  3679. }
  3680. entity.IsVerifyToSupplier = true;
  3681. if (entity.IsReturn == 1) //1是供应商打回
  3682. {
  3683. entity.IsReturn = 0;
  3684. }
  3685. entity.FinishPlaceTime = DateTime.Now;
  3686. entity.PlaceUserId = CurrentUser.UserID;
  3687. entity.Update();
  3688. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3689. }
  3690. }
  3691. returnSuccessMsg("操作成功!");
  3692. return;**/
  3693. }
  3694. }
  3695. public void upd_erp_supplierback()
  3696. {
  3697. if (UrlPostParmsCheck("ctid"))
  3698. {
  3699. string eid = GetPostString("ctid");
  3700. string reason = GetPostString("returnreason");
  3701. CeErpTradeCell entity = null;
  3702. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3703. if (entity != null)
  3704. {
  3705. string message = "操作成功!";
  3706. string isDown = "";
  3707. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3708. {
  3709. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3710. isDown = "被点击下载";
  3711. }
  3712. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3713. {
  3714. string key = "return_order_" + entity.SupplierId;
  3715. List<string> list = new List<string>();
  3716. if (RedisHelper.HasKey(key))
  3717. {
  3718. object data = RedisHelper.StringGet(key);
  3719. list = Convert.ToString(data).Split(',').ToList();
  3720. }
  3721. list.Add(eid);
  3722. RedisHelper.StringSet(key, string.Join(",", list));
  3723. }
  3724. entity.IsVerifyToSupplier = false;
  3725. entity.IsReturn = 1;
  3726. entity.IsHaveNewOrder = 0;
  3727. entity.ReturnTime = DateTime.Now;
  3728. entity.ReturnReason = reason;
  3729. if (entity.OrderState == 6)
  3730. {
  3731. entity.OrderState = 5;
  3732. }
  3733. entity.Update();
  3734. CeErpSukuraData.createInfo(entity.ctid, 5);
  3735. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3736. returnSuccessMsg(message);
  3737. return;
  3738. }
  3739. returnErrorMsg("找不到订单记录");
  3740. }
  3741. }
  3742. public void upd_erp_toaftersaleorder()
  3743. {
  3744. if (UrlPostParmsCheck("ctid"))
  3745. {
  3746. string eid = GetPostString("ctid");
  3747. string reason = GetPostString("returnreason");
  3748. CeErpTradeCell entity = null;
  3749. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3750. if (entity != null)
  3751. {
  3752. if (entity.isAfterSaleOrder != 1)
  3753. {
  3754. returnErrorMsg("带S的售后单才能打回给售后");
  3755. return;
  3756. }
  3757. if (entity.OrderState >= 5)
  3758. {
  3759. returnErrorMsg("已经设计完成了不能打回给售后");
  3760. return;
  3761. }
  3762. entity.OrderState = 0;
  3763. entity.IsReturn = 3;
  3764. entity.ReturnTime = DateTime.Now;
  3765. entity.UpdateTime = DateTime.Now;
  3766. entity.ReturnReason = reason;
  3767. entity.Update();
  3768. CeErpSukuraData.createInfo(entity.ctid, 5);
  3769. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3770. returnSuccessMsg("操作成功!");
  3771. return;
  3772. }
  3773. returnErrorMsg("找不到订单记录");
  3774. }
  3775. }
  3776. public void upd_erp_aftersaletodesign()
  3777. {
  3778. if (UrlPostParmsCheck("ctid"))
  3779. {
  3780. string eid = GetPostString("ctid");
  3781. CeErpTradeCell entity = null;
  3782. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3783. if (entity != null)
  3784. {
  3785. entity.OrderState = 3;
  3786. entity.IsReturn = 0;
  3787. entity.UpdateTime = DateTime.Now;
  3788. entity.Update();
  3789. CeErpSukuraData.createInfo(entity.ctid, 5);
  3790. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3791. returnSuccessMsg("操作成功!");
  3792. return;
  3793. }
  3794. returnErrorMsg("找不到订单记录");
  3795. }
  3796. }
  3797. public void assign_erp_supplier()
  3798. {
  3799. if (UrlPostParmsCheck("ctid"))
  3800. {
  3801. string eids = GetPostString("ctid");
  3802. int sid = GetPostInt("SupplierName");
  3803. string fromTag = GetPostString("tag");
  3804. string[] eidList = eids.Split(',');
  3805. if (eidList.Length <= 0)
  3806. {
  3807. returnErrorMsg("指派不能为空");
  3808. return;
  3809. }
  3810. string errMsg = "";
  3811. string suname = commonHelper.getSupplierNameById(sid);
  3812. foreach (string ctid in eidList)
  3813. {
  3814. CeErpTradeCell entity = null;
  3815. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3816. if (entity != null)
  3817. {
  3818. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3819. {
  3820. errMsg += (ctid + "指派失败!!!");
  3821. continue;
  3822. }
  3823. entity.SupplierId = sid;
  3824. entity.Update();
  3825. commonHelper.UpdateRelationOrder(entity.ctid);
  3826. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3827. if (entity.OrderState >= 6)
  3828. {
  3829. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3830. //{
  3831. // string msl = entity.MakeSupplier;
  3832. // string[] mslist = msl.Split(',');
  3833. // 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);
  3834. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3835. //}
  3836. //else
  3837. //{
  3838. StringBuilder sql = new StringBuilder();
  3839. 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);
  3840. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3841. //}
  3842. }
  3843. }
  3844. else
  3845. {
  3846. continue;
  3847. }
  3848. }
  3849. if (errMsg.Length > 0)
  3850. {
  3851. returnErrorMsg(errMsg);
  3852. return;
  3853. }
  3854. returnSuccessMsg("操作成功!");
  3855. return;
  3856. }
  3857. }
  3858. public void assign_erp_makesupplier()
  3859. {
  3860. if (UrlPostParmsCheck("ctid"))
  3861. {
  3862. string eids = GetPostString("ctid");
  3863. string sname = GetPostString("SupplierName");
  3864. string[] eidList = eids.Split(',');
  3865. if (eidList.Length <= 0)
  3866. {
  3867. returnErrorMsg("指派不能为空");
  3868. return;
  3869. }
  3870. List<string> tLst = new List<string>();
  3871. foreach (string ctid in eidList)
  3872. {
  3873. CeErpTradeCell entity = null;
  3874. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3875. if (entity != null)
  3876. {
  3877. entity.MakeSupplier = sname;
  3878. entity.Update();
  3879. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3880. tLst.Add("'" + ctid + "'");
  3881. }
  3882. else
  3883. {
  3884. continue;
  3885. }
  3886. }
  3887. string ctids = string.Join(",", tLst.ToArray());
  3888. StringBuilder sql2 = new StringBuilder();
  3889. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3890. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3891. returnSuccessMsg("操作成功!");
  3892. return;
  3893. }
  3894. }
  3895. public void ins_erp_returnreason()
  3896. {
  3897. if (UrlPostParmsCheck("ctid"))
  3898. {
  3899. string eid = GetPostString("ctid");
  3900. CeErpTradeCell entity = null;
  3901. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3902. string userpost = CurrentUser.UserPost.Post.Code;
  3903. if (entity != null)
  3904. {
  3905. bool isPlace = false;
  3906. if (entity.OrderState > 6)
  3907. {
  3908. returnErrorMsg("已发货无法打回!");
  3909. return;
  3910. }
  3911. if (entity.OrderState == 6)
  3912. {
  3913. isPlace = true;
  3914. }
  3915. bool isNeedUpdateCell2 = false;
  3916. if (entity.OrderState >= 6)
  3917. {
  3918. isNeedUpdateCell2 = true;
  3919. }
  3920. int returnTag = 2;
  3921. if (userpost == "Supplier")
  3922. {
  3923. returnTag = 1;
  3924. }
  3925. int toType = GetPostInt("totype");
  3926. string fromType = "3";
  3927. if (entity.OrderState < 5)
  3928. {
  3929. fromType = "3";
  3930. }
  3931. else
  3932. {
  3933. fromType = "4";
  3934. }
  3935. if (entity.IsXianHuo == 0)
  3936. {
  3937. if (returnTag == 2)
  3938. {
  3939. if (toType == 1)
  3940. {
  3941. entity.OrderState = 0;
  3942. entity.ReturnUserType = 1;
  3943. string clearman = GetPostString("clearman");
  3944. if (!string.IsNullOrEmpty(clearman))
  3945. {
  3946. entity.DesignUserId = 0;
  3947. }
  3948. }
  3949. else
  3950. {
  3951. entity.OrderState = 3;
  3952. entity.ReturnUserType = 2;
  3953. }
  3954. entity.IsReadTag = 1;
  3955. }
  3956. else if (returnTag == 1)
  3957. {
  3958. entity.OrderState = 5;
  3959. }
  3960. entity.IsVerifyToSupplier = false;
  3961. }
  3962. if (entity.IsXianHuo == 1)
  3963. {
  3964. entity.OrderState = 5;
  3965. }
  3966. entity.UnusualTag = 0;
  3967. entity.UnusualTime = null;
  3968. entity.UnusualCon = "";
  3969. entity.IsReturn = returnTag;
  3970. entity.ReturnTime = DateTime.Now;
  3971. entity.UpdateTime = DateTime.Now;
  3972. entity.ReturnReason = GetPostString("returnreason");
  3973. entity.Update();
  3974. if (entity.OrderState == 3)
  3975. {
  3976. ApiVo apiVo = new ApiVo();
  3977. apiVo.orderNumber = entity.ctid;
  3978. apiVo.actionName = "rebutDesign";
  3979. apiVo.orderRemarks = entity.ReturnReason;
  3980. designHelper.API_WorkCore(apiVo);//rebutDesign
  3981. }
  3982. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3983. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3984. {
  3985. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3986. }
  3987. CeErpSukuraData.createInfo(entity.ctid, 5);
  3988. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3989. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3990. if (isPlace)
  3991. {
  3992. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3993. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3994. if (dth != null && dth.Rows.Count > 0)
  3995. {
  3996. dataSendOrderBean dataSendOrderBean = null;
  3997. foreach (DataRow item in dth.Rows)
  3998. {
  3999. try
  4000. {
  4001. dataSendOrderBean = new dataSendOrderBean();
  4002. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  4003. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  4004. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  4005. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  4006. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  4007. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  4008. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  4009. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  4010. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  4011. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  4012. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  4013. dataSendOrderBean.Radio1723534706288 = "打回";
  4014. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  4015. if (result != null)
  4016. {
  4017. if ("0".Equals(result.errcode))
  4018. {
  4019. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  4020. }
  4021. else
  4022. {
  4023. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  4024. }
  4025. }
  4026. }
  4027. catch (Exception ex)
  4028. {
  4029. }
  4030. }
  4031. }
  4032. }
  4033. if (isNeedUpdateCell2)
  4034. {
  4035. if (entity.MakeSupplier.IndexOf(",") != -1)
  4036. {
  4037. StringBuilder sql2 = new StringBuilder();
  4038. 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);
  4039. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4040. }
  4041. else
  4042. {
  4043. StringBuilder sql2 = new StringBuilder();
  4044. 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);
  4045. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4046. }
  4047. }
  4048. returnSuccessMsg("操作成功!");
  4049. return;
  4050. }
  4051. returnErrorMsg("找不到订单记录");
  4052. }
  4053. }
  4054. public void cyt_erp_returnreason()
  4055. {
  4056. if (UrlPostParmsCheck("ctid"))
  4057. {
  4058. string eid = GetPostString("ctid");
  4059. CeErpTradeCell entity = null;
  4060. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4061. string userpost = CurrentUser.UserPost.Post.Code;
  4062. if (entity != null)
  4063. {
  4064. if (entity.OrderState > 6)
  4065. {
  4066. returnErrorMsg("已发货无法打回!");
  4067. return;
  4068. }
  4069. JObject jsonObject = new JObject
  4070. {
  4071. { "Userid", "77886" },
  4072. { "Pwd", "lt666888" },
  4073. { "LTOrderId",eid }
  4074. };
  4075. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4076. JObject jsonObjects = JObject.Parse(response);
  4077. string msg = (string)jsonObjects["msg"];
  4078. if (msg != "取消成功")
  4079. {
  4080. returnErrorMsg(msg);
  4081. return;
  4082. }
  4083. bool isNeedUpdateCell2 = false;
  4084. if (entity.OrderState >= 6)
  4085. {
  4086. isNeedUpdateCell2 = true;
  4087. }
  4088. int returnTag = 2;
  4089. if (userpost == "Supplier")
  4090. {
  4091. returnTag = 1;
  4092. }
  4093. if (entity.IsXianHuo == 0)
  4094. {
  4095. if (returnTag == 2)
  4096. {
  4097. int toType = GetPostInt("totype");
  4098. if (toType == 1)
  4099. {
  4100. entity.OrderState = 0;
  4101. entity.ReturnUserType = 1;
  4102. }
  4103. else
  4104. {
  4105. entity.OrderState = 4;
  4106. entity.ReturnUserType = 2;
  4107. }
  4108. entity.IsReadTag = 1;
  4109. }
  4110. else if (returnTag == 1)
  4111. {
  4112. entity.OrderState = 5;
  4113. }
  4114. entity.IsVerifyToSupplier = false;
  4115. }
  4116. entity.UnusualTag = 0;
  4117. entity.UnusualTime = null;
  4118. entity.UnusualCon = "";
  4119. entity.IsReturn = returnTag;
  4120. entity.ReturnTime = DateTime.Now;
  4121. entity.ReturnReason = GetPostString("returnreason");
  4122. entity.Update();
  4123. if (entity.OrderState == 4)
  4124. {
  4125. ApiVo apiVo = new ApiVo();
  4126. apiVo.orderNumber = entity.ctid;
  4127. apiVo.actionName = "rebutDesign";
  4128. apiVo.orderRemarks = entity.ReturnReason;
  4129. designHelper.API_WorkCore(apiVo);//rebutDesign
  4130. }
  4131. CeErpSukuraData.createInfo(entity.ctid, 5);
  4132. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4133. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4134. if (isNeedUpdateCell2)
  4135. {
  4136. if (entity.MakeSupplier.IndexOf(",") != -1)
  4137. {
  4138. StringBuilder sql2 = new StringBuilder();
  4139. 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);
  4140. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4141. }
  4142. else
  4143. {
  4144. StringBuilder sql2 = new StringBuilder();
  4145. 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);
  4146. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4147. }
  4148. }
  4149. returnSuccessMsg("操作成功!");
  4150. return;
  4151. }
  4152. returnErrorMsg("找不到订单记录");
  4153. }
  4154. }
  4155. public void upd_erp_xianhuoreturntag()
  4156. {
  4157. if (UrlPostParmsCheck("ctid"))
  4158. {
  4159. string eids = GetPostString("ctid");
  4160. string[] ctids = eids.Split(',');
  4161. foreach (string ctid in ctids)
  4162. {
  4163. CeErpTradeCell entity = null;
  4164. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4165. if (entity != null)
  4166. {
  4167. entity.IsReturn = 0;
  4168. entity.Update();
  4169. CeErpSukuraData.createInfo(entity.ctid, 5);
  4170. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4171. }
  4172. }
  4173. returnSuccessMsg("操作成功!");
  4174. return;
  4175. }
  4176. }
  4177. public void get_erp_waitdeliverylist()
  4178. {
  4179. DataStruct dStruct = GetPostStruct();
  4180. List<string> lw = new List<string>();
  4181. string tid = GetPostString("ctid");
  4182. if (tid.Length > 0)
  4183. {
  4184. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4185. if (tid.Length > 5)
  4186. {
  4187. List<string> tids = getTidByCtidLike(tid);
  4188. if (tids.Count > 0 && tids.Count < 10)
  4189. {
  4190. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4191. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4192. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4193. {
  4194. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4195. }*/
  4196. }
  4197. }
  4198. lw.Add(tid_sql);
  4199. }
  4200. string shopname = GetPostString("shopname");
  4201. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4202. string buyernick = GetPostString("buyer_nick");
  4203. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4204. //if (tid.Length == 0 && buyernick.Length == 0)
  4205. //{
  4206. // lw.Add(string.Format("IsRefund<={0}", 1));
  4207. //}
  4208. string customer = GetPostString("customer");
  4209. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4210. string design = GetPostString("design");
  4211. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4212. string orderState = GetPostString("orderState");
  4213. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4214. string address = GetPostString("address");
  4215. 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));
  4216. string sellermemo = GetPostString("seller_memo");
  4217. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4218. string supplier = GetPostString("supplier");
  4219. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4220. string OrderArea = GetPostString("order_area");
  4221. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4222. string placedate1 = GetPostString("placedate1");
  4223. string placedate2 = GetPostString("placedate2");
  4224. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4225. if (fdw.Length > 0) lw.Add(fdw);
  4226. string price1 = GetPostString("price1");
  4227. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4228. string price2 = GetPostString("price2");
  4229. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4230. string unusualCon = GetPostString("unusualcon");
  4231. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4232. string otherMemo = GetPostString("otherMemo");
  4233. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4234. string posTag = CurrentUser.UserPost.Post.Code;
  4235. if (posTag == "Supplier")
  4236. {
  4237. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4238. }
  4239. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4240. lw.Add(string.Format("type != 'PDD' "));
  4241. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4242. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4243. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4244. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4245. writeGridDataTableJson(dStruct.TotalCount, dt);
  4246. }
  4247. public void get_erp_changedeliverylist()
  4248. {
  4249. DataStruct dStruct = GetPostStruct();
  4250. List<string> lw = new List<string>();
  4251. string tid = GetPostString("ctid");
  4252. if (tid.Length > 0)
  4253. {
  4254. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4255. if (tid.Length > 5)
  4256. {
  4257. List<string> tids = getTidByCtidLike(tid);
  4258. if (tids.Count > 0 && tids.Count < 10)
  4259. {
  4260. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4261. }
  4262. }
  4263. lw.Add(tid_sql);
  4264. }
  4265. string shopname = GetPostString("shopname");
  4266. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4267. string buyernick = GetPostString("buyer_nick");
  4268. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4269. //if (tid.Length == 0 && buyernick.Length == 0)
  4270. //{
  4271. // lw.Add(string.Format("IsRefund<={0}", 1));
  4272. //}
  4273. string customer = GetPostString("customer");
  4274. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4275. string design = GetPostString("design");
  4276. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4277. string orderState = GetPostString("orderState");
  4278. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4279. string address = GetPostString("address");
  4280. 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));
  4281. string sellermemo = GetPostString("seller_memo");
  4282. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4283. string supplier = GetPostString("supplier");
  4284. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4285. string OrderArea = GetPostString("order_area");
  4286. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4287. string placedate1 = GetPostString("placedate1");
  4288. string placedate2 = GetPostString("placedate2");
  4289. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4290. if (fdw.Length > 0) lw.Add(fdw);
  4291. string price1 = GetPostString("price1");
  4292. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4293. string price2 = GetPostString("price2");
  4294. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4295. string unusualCon = GetPostString("unusualcon");
  4296. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4297. string otherMemo = GetPostString("otherMemo");
  4298. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4299. string posTag = CurrentUser.UserPost.Post.Code;
  4300. if (posTag == "Supplier")
  4301. {
  4302. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4303. }
  4304. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4305. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4306. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4307. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4308. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4309. /*if (tid.Length > 0)
  4310. {
  4311. List<string> tids = new List<string>();
  4312. if (dt != null && dt.Rows.Count > 0)
  4313. {
  4314. foreach (DataRow item in dt.Rows)
  4315. {
  4316. tids.Add("'" + item["tid"] + "'");
  4317. }
  4318. }
  4319. if (tids.Count > 0)
  4320. {
  4321. lw.RemoveAt(0);
  4322. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4323. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4324. dt = WebCache.GetData("view_erptradecell", dStruct);
  4325. }
  4326. }*/
  4327. writeGridDataTableJson(dStruct.TotalCount, dt);
  4328. }
  4329. public void get_erp_pddderiving()
  4330. {
  4331. DataStruct dStruct = GetPostStruct();
  4332. List<string> lw = new List<string>();
  4333. string tid = GetPostString("ctid");
  4334. if (tid.Length > 0)
  4335. {
  4336. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4337. if (tid.Length > 5)
  4338. {
  4339. List<string> tids = getTidByCtidLike(tid);
  4340. if (tids.Count > 0 && tids.Count < 10)
  4341. {
  4342. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4343. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4344. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4345. {
  4346. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4347. }*/
  4348. }
  4349. }
  4350. lw.Add(tid_sql);
  4351. }
  4352. string shopname = GetPostString("shopname");
  4353. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4354. string buyernick = GetPostString("buyer_nick");
  4355. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4356. //if (tid.Length == 0 && buyernick.Length == 0)
  4357. //{
  4358. // lw.Add(string.Format("IsRefund<={0}", 1));
  4359. //}
  4360. string customer = GetPostString("customer");
  4361. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4362. string design = GetPostString("design");
  4363. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4364. string orderState = GetPostString("orderState");
  4365. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4366. string address = GetPostString("address");
  4367. 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));
  4368. string sellermemo = GetPostString("seller_memo");
  4369. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4370. string supplier = GetPostString("supplier");
  4371. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4372. string OrderArea = GetPostString("order_area");
  4373. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4374. string placedate1 = GetPostString("placedate1");
  4375. string placedate2 = GetPostString("placedate2");
  4376. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4377. if (fdw.Length > 0) lw.Add(fdw);
  4378. string price1 = GetPostString("price1");
  4379. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4380. string price2 = GetPostString("price2");
  4381. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4382. string unusualCon = GetPostString("unusualcon");
  4383. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4384. string posTag = CurrentUser.UserPost.Post.Code;
  4385. if (posTag == "Supplier")
  4386. {
  4387. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4388. }
  4389. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4390. lw.Add(string.Format("type = 'PDD' "));
  4391. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4392. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4393. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4394. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4395. /*if (tid.Length > 0)
  4396. {
  4397. List<string> tids = new List<string>();
  4398. if (dt != null && dt.Rows.Count > 0)
  4399. {
  4400. foreach (DataRow item in dt.Rows)
  4401. {
  4402. tids.Add("'" + item["tid"] + "'");
  4403. }
  4404. }
  4405. if (tids.Count > 0)
  4406. {
  4407. lw.RemoveAt(0);
  4408. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4409. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4410. dt = WebCache.GetData("view_erptradecell", dStruct);
  4411. }
  4412. }*/
  4413. writeGridDataTableJson(dStruct.TotalCount, dt);
  4414. }
  4415. public void get_erp_jdderiving()
  4416. {
  4417. DataStruct dStruct = GetPostStruct();
  4418. List<string> lw = new List<string>();
  4419. string tid = GetPostString("ctid");
  4420. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4421. string shopname = GetPostString("shopname");
  4422. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4423. string buyernick = GetPostString("buyer_nick");
  4424. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4425. //if (tid.Length == 0 && buyernick.Length == 0)
  4426. //{
  4427. // lw.Add(string.Format("IsRefund<={0}", 1));
  4428. //}
  4429. string customer = GetPostString("customer");
  4430. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4431. string design = GetPostString("design");
  4432. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4433. string orderState = GetPostString("orderState");
  4434. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4435. string address = GetPostString("address");
  4436. 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));
  4437. string sellermemo = GetPostString("seller_memo");
  4438. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4439. string supplier = GetPostString("supplier");
  4440. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4441. string OrderArea = GetPostString("order_area");
  4442. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4443. string placedate1 = GetPostString("placedate1");
  4444. string placedate2 = GetPostString("placedate2");
  4445. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4446. if (fdw.Length > 0) lw.Add(fdw);
  4447. string price1 = GetPostString("price1");
  4448. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4449. string price2 = GetPostString("price2");
  4450. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4451. string unusualCon = GetPostString("unusualcon");
  4452. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4453. string posTag = CurrentUser.UserPost.Post.Code;
  4454. if (posTag == "Supplier")
  4455. {
  4456. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4457. }
  4458. lw.Add(string.Format("OrderState = 6 "));
  4459. lw.Add(string.Format("type = 'JD' "));
  4460. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4461. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4462. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4463. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4464. writeGridDataTableJson(dStruct.TotalCount, dt);
  4465. }
  4466. public void get_erp_demoorderlist()
  4467. {
  4468. DataStruct dStruct = GetPostStruct();
  4469. List<string> lw = new List<string>();
  4470. string tid = GetPostString("ctid");
  4471. if (tid.Length > 0)
  4472. {
  4473. string select_tid = getTidByCtid(tid);
  4474. lw.Add(string.Format("tid='{0}'", select_tid));
  4475. }
  4476. string shopname = GetPostString("shopname");
  4477. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4478. string buyernick = GetPostString("buyer_nick");
  4479. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4480. string customer = GetPostString("customer");
  4481. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4482. string design = GetPostString("design");
  4483. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4484. string orderState = GetPostString("orderState");
  4485. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4486. string address = GetPostString("address");
  4487. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4488. string sellermemo = GetPostString("seller_memo");
  4489. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4490. string supplier = GetPostString("supplier");
  4491. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4492. string OrderArea = GetPostString("order_area");
  4493. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4494. string date1 = GetPostString("date1");
  4495. string date2 = GetPostString("date2");
  4496. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4497. if (dw.Length > 0) lw.Add(dw);
  4498. string price1 = GetPostString("price1");
  4499. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4500. string price2 = GetPostString("price2");
  4501. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4502. string posTag = CurrentUser.UserPost.Post.Code;
  4503. if (posTag == "Supplier")
  4504. {
  4505. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4506. }
  4507. //lw.Add(string.Format("OrderState = 6 "));
  4508. lw.Add(string.Format("IsSample={0}", 3));
  4509. lw.Add(string.Format("IsRefund<={0}", 1));
  4510. dStruct.Order = "pay_time desc";
  4511. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4512. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4513. writeGridDataTableJson(dStruct.TotalCount, dt);
  4514. }
  4515. public void save_erp_checkmemo()
  4516. {
  4517. if (UrlPostParmsCheck("ctid"))
  4518. {
  4519. string ctid = GetPostString("ctid");
  4520. CeErpTradeCell entity = null;
  4521. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4522. if (entity != null)
  4523. {
  4524. entity.CheckMemo = GetPostString("CheckMemo");
  4525. entity.Update();
  4526. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4527. if (trade != null)
  4528. {
  4529. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4530. }
  4531. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4532. returnSuccessMsg("保存成功!");
  4533. return;
  4534. }
  4535. returnErrorMsg("找不到记录");
  4536. }
  4537. }
  4538. public void get_erp_returnlist()
  4539. {
  4540. DataStruct dStruct = GetPostStruct();
  4541. List<string> lw = new List<string>();
  4542. string tid = GetPostString("ctid");
  4543. if (tid.Length > 0)
  4544. {
  4545. string select_tid = getTidByCtid(tid);
  4546. lw.Add(string.Format("tid='{0}'", select_tid));
  4547. }
  4548. string shopname = GetPostString("shopname");
  4549. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4550. string buyernick = GetPostString("buyer_nick");
  4551. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4552. string customer = GetPostString("customer");
  4553. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4554. string design = GetPostString("design");
  4555. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4556. string orderState = GetPostString("orderState");
  4557. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4558. string address = GetPostString("address");
  4559. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4560. string sellermemo = GetPostString("seller_memo");
  4561. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4562. string supplier = GetPostString("supplier");
  4563. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4564. string date1 = GetPostString("date1");
  4565. string date2 = GetPostString("date2");
  4566. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4567. if (dw.Length > 0) lw.Add(dw);
  4568. string bdate1 = GetPostString("backdate1");
  4569. string bdate2 = GetPostString("backdate2");
  4570. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4571. if (dw_back.Length > 0) lw.Add(dw_back);
  4572. string price1 = GetPostString("price1");
  4573. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4574. string price2 = GetPostString("price2");
  4575. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4576. lw.Add(string.Format("IsReturn>0"));
  4577. lw.Add(string.Format("IsXianHuo=0"));
  4578. lw.Add(string.Format("IsReturn!=3"));
  4579. string backtype = GetPostString("backtype");
  4580. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4581. dStruct.Order = "FinishDesignTime desc";
  4582. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4583. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4584. writeGridDataTableJson(dStruct.TotalCount, dt);
  4585. }
  4586. public void get_erp_today_sumreturn()
  4587. {
  4588. DataStruct dStruct = GetPostStruct();
  4589. List<string> lw = new List<string>();
  4590. string bdate1 = GetPostString("returnTimeS");
  4591. string bdate2 = GetPostString("returnTimeE");
  4592. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4593. if (dw_back.Length > 0) lw.Add(dw_back);
  4594. lw.Add(string.Format("IsReturn=0"));
  4595. lw.Add(string.Format("IsXianHuo=0"));
  4596. string mainWhere = string.Join(" and ", lw.ToArray());
  4597. string sql = "";
  4598. if (dw_back.Length > 0)
  4599. {
  4600. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4601. }
  4602. else
  4603. {
  4604. 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 + "'";
  4605. }
  4606. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4607. decimal total = 0, today_finish = 0;
  4608. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4609. {
  4610. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4611. }
  4612. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4613. {
  4614. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4615. }
  4616. var res = new
  4617. {
  4618. data = total,
  4619. data1 = today_finish,
  4620. };
  4621. string ro_jsond = JsonConvert.SerializeObject(res);
  4622. returnSuccess(ro_jsond);
  4623. return;
  4624. }
  4625. public void get_erp_allreturnlist()
  4626. {
  4627. DataStruct dStruct = GetPostStruct();
  4628. List<string> lw = new List<string>();
  4629. string tid = GetPostString("ctid");
  4630. if (tid.Length > 0)
  4631. {
  4632. string select_tid = getTidByCtid(tid);
  4633. lw.Add(string.Format("tid='{0}'", select_tid));
  4634. }
  4635. string shopname = GetPostString("shopname");
  4636. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4637. string buyernick = GetPostString("buyer_nick");
  4638. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4639. string customer = GetPostString("customer");
  4640. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4641. string design = GetPostString("design");
  4642. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4643. string orderState = GetPostString("orderState");
  4644. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4645. string address = GetPostString("address");
  4646. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4647. string sellermemo = GetPostString("seller_memo");
  4648. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4649. string supplier = GetPostString("supplier");
  4650. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4651. string date1 = GetPostString("date1");
  4652. string date2 = GetPostString("date2");
  4653. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4654. if (dw.Length > 0) lw.Add(dw);
  4655. string bdate1 = GetPostString("backdate1");
  4656. string bdate2 = GetPostString("backdate2");
  4657. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4658. if (dw_back.Length > 0) lw.Add(dw_back);
  4659. string price1 = GetPostString("price1");
  4660. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4661. string price2 = GetPostString("price2");
  4662. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4663. string backreason = GetPostString("backreason");
  4664. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4665. lw.Add(string.Format("IsXianHuo=0"));
  4666. lw.Add(string.Format("ReturnTime != ''"));
  4667. string backtype = GetPostString("backtype");
  4668. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4669. dStruct.Order = "FinishDesignTime desc";
  4670. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4671. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4672. writeGridDataTableJson(dStruct.TotalCount, dt);
  4673. }
  4674. public void get_erp_aftersalereturnlist()
  4675. {
  4676. DataStruct dStruct = GetPostStruct();
  4677. List<string> lw = new List<string>();
  4678. string tid = GetPostString("ctid");
  4679. if (tid.Length > 0)
  4680. {
  4681. string select_tid = getTidByCtid(tid);
  4682. lw.Add(string.Format("tid='{0}'", select_tid));
  4683. }
  4684. string shopname = GetPostString("shopname");
  4685. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4686. string buyernick = GetPostString("buyer_nick");
  4687. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4688. string customer = GetPostString("customer");
  4689. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4690. string design = GetPostString("design");
  4691. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4692. string orderState = GetPostString("orderState");
  4693. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4694. string address = GetPostString("address");
  4695. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4696. string sellermemo = GetPostString("seller_memo");
  4697. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4698. string supplier = GetPostString("supplier");
  4699. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4700. string date1 = GetPostString("date1");
  4701. string date2 = GetPostString("date2");
  4702. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4703. if (dw.Length > 0) lw.Add(dw);
  4704. string bdate1 = GetPostString("backdate1");
  4705. string bdate2 = GetPostString("backdate2");
  4706. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4707. if (dw_back.Length > 0) lw.Add(dw_back);
  4708. string price1 = GetPostString("price1");
  4709. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4710. string price2 = GetPostString("price2");
  4711. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4712. lw.Add(string.Format("IsReturn=3"));
  4713. string backtype = GetPostString("backtype");
  4714. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4715. string backreason = GetPostString("backreason");
  4716. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4717. dStruct.Order = "ReturnTime desc";
  4718. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4719. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4720. writeGridDataTableJson(dStruct.TotalCount, dt);
  4721. }
  4722. public void get_erp_xianhuoreturnlist()
  4723. {
  4724. DataStruct dStruct = GetPostStruct();
  4725. List<string> lw = new List<string>();
  4726. string tid = GetPostString("ctid");
  4727. if (tid.Length > 0)
  4728. {
  4729. string select_tid = getTidByCtid(tid);
  4730. lw.Add(string.Format("tid='{0}'", select_tid));
  4731. }
  4732. string shopname = GetPostString("shopname");
  4733. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4734. string buyernick = GetPostString("buyer_nick");
  4735. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4736. string customer = GetPostString("customer");
  4737. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4738. string design = GetPostString("design");
  4739. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4740. string orderState = GetPostString("orderState");
  4741. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4742. string address = GetPostString("address");
  4743. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4744. string sellermemo = GetPostString("seller_memo");
  4745. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4746. string supplier = GetPostString("supplier");
  4747. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4748. string OrderArea = GetPostString("order_area");
  4749. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4750. string date1 = GetPostString("date1");
  4751. string date2 = GetPostString("date2");
  4752. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4753. if (dw.Length > 0) lw.Add(dw);
  4754. string price1 = GetPostString("price1");
  4755. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4756. string price2 = GetPostString("price2");
  4757. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4758. string posTag = CurrentUser.UserPost.Post.Code;
  4759. if (posTag == "Supplier")
  4760. {
  4761. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4762. }
  4763. lw.Add(string.Format("OrderState=6 "));
  4764. lw.Add(string.Format("IsXianHuo=1 "));
  4765. lw.Add(string.Format("IsReturn>0 "));
  4766. lw.Add(string.Format("IsReturn!=3"));
  4767. lw.Add(string.Format("IsRefund<={0}", 1));
  4768. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4769. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4770. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4771. writeGridDataTableJson(dStruct.TotalCount, dt);
  4772. }
  4773. public void set_erp_orderdelivery()
  4774. {
  4775. if (UrlPostParmsCheck("ctid"))
  4776. {
  4777. string eid = GetPostString("ctid");
  4778. CeErpTradeCell entity = null;
  4779. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4780. if (entity != null)
  4781. {
  4782. if (entity.OrderState >= 7)
  4783. {
  4784. returnErrorMsg("此单已发货,无需重复发货");
  4785. return;
  4786. }
  4787. if (entity.OrderState != 6)
  4788. {
  4789. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4790. return;
  4791. }
  4792. string shop = GetPostString("seller_nick");
  4793. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4794. string comName = GetPostString("comName");
  4795. string comCode = GetPostString("comCode");
  4796. string outSid = GetPostString("outSid");
  4797. string deliveryType = GetPostString("deliveryType");
  4798. string deliveryMemo = GetPostString("deliveryMemo");
  4799. outSid = outSid.Trim();
  4800. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4801. if (mainEn == null)
  4802. {
  4803. returnErrorMsg("找不到原始订单记录");
  4804. return;
  4805. }
  4806. bool isInitOrderDeliv = false;
  4807. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4808. {
  4809. isInitOrderDeliv = true;
  4810. }
  4811. string apires = "";
  4812. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4813. 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)
  4814. {
  4815. apires = "发货成功true";
  4816. }
  4817. else
  4818. {
  4819. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4820. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4821. }
  4822. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4823. {
  4824. entity.OrderState = 7;//发货后订单已发货
  4825. entity.OutSid = outSid;
  4826. entity.MemoOpt = 0;
  4827. entity.UpdateTime = DateTime.Now;
  4828. entity.FinishDeliveryTime = DateTime.Now;
  4829. entity.Update();
  4830. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4831. commonHelper.UpdateRelationOrder(entity.ctid);
  4832. //还要插入快递信息到 快递信息表
  4833. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4834. exinfo.tid = eid;
  4835. exinfo.out_sid = outSid;
  4836. exinfo.company_code = comCode;
  4837. exinfo.company_name = comName;
  4838. exinfo.delivery_memo = deliveryMemo;
  4839. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4840. exinfo.deliveryType = deliveryType;
  4841. exinfo.Create();
  4842. returnSuccessMsg("发货操作成功!");
  4843. commonHelper.UpdateRelationOrder(entity.ctid);
  4844. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4845. CeErpSukuraData.createInfo(entity.ctid, 4);
  4846. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  4847. {
  4848. commonHelper.sendCytExpress(exinfo);
  4849. }
  4850. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4851. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid + ",备注:" + deliveryMemo, entity.OrderState);
  4852. }
  4853. else
  4854. {
  4855. string errmsg = commonHelper.KeepChinese(apires);
  4856. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4857. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4858. }
  4859. return;
  4860. }
  4861. returnErrorMsg("找不到订单记录");
  4862. }
  4863. }
  4864. public void set_erp_multidelivery()
  4865. {
  4866. string eids = GetPostString("tids");
  4867. string[] eidList = eids.Split(',');
  4868. if (eidList.Length <= 0)
  4869. {
  4870. returnErrorMsg("发货不能为空");
  4871. return;
  4872. }
  4873. foreach (string ctid in eidList)
  4874. {
  4875. if (ctid.Length <= 0) continue;
  4876. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4877. if (expInfo != null)
  4878. {
  4879. StringBuilder sql = new StringBuilder();
  4880. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4881. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4882. if (dt.Rows.Count > 0)
  4883. {
  4884. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4885. {
  4886. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4887. expInfo.state = "异常";
  4888. expInfo.isMultiDelivery = 1;
  4889. expInfo.Update();
  4890. continue;
  4891. }
  4892. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4893. {
  4894. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4895. expInfo.state = "异常";
  4896. expInfo.Update();
  4897. continue;
  4898. }
  4899. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4900. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4901. bool isInitOrderDeliv = false;
  4902. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4903. {
  4904. isInitOrderDeliv = true;
  4905. expInfo.isMultiDelivery = 1;
  4906. }
  4907. if (ctid.IndexOf("N") != -1)
  4908. {
  4909. StringBuilder sqlbucha = new StringBuilder();
  4910. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4911. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4912. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4913. commonHelper.UpdateRelationOrder(ctid);
  4914. expInfo.delivery_memo = "发货成功";
  4915. expInfo.state = "发货成功";
  4916. expInfo.isMultiDelivery = 1;
  4917. expInfo.Update();
  4918. }
  4919. else
  4920. {
  4921. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4922. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4923. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4924. {
  4925. expInfo.delivery_memo = "发货成功";
  4926. expInfo.state = "发货成功";
  4927. expInfo.isMultiDelivery = 1;
  4928. expInfo.Update();
  4929. commonHelper.UpdateRelationOrder(ctid);
  4930. CeErpSukuraData.createInfo(ctid, 4);
  4931. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4932. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4933. }
  4934. else
  4935. {
  4936. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4937. expInfo.state = "异常";
  4938. expInfo.Update();
  4939. }
  4940. }
  4941. }
  4942. }
  4943. }
  4944. returnSuccessMsg("操作完成");
  4945. }
  4946. public void reset_erp_memoopt()
  4947. {
  4948. if (UrlPostParmsCheck("ctid"))
  4949. {
  4950. string eid = GetPostString("ctid");
  4951. CeErpTradeCell entity = null;
  4952. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4953. if (entity != null)
  4954. {
  4955. string stropt = "";
  4956. if (entity.MemoOpt == 1)
  4957. {
  4958. stropt = "“改稿”";
  4959. }
  4960. else if (entity.MemoOpt == 2)
  4961. {
  4962. stropt = "“定稿”";
  4963. }
  4964. else if (entity.MemoOpt == 3)
  4965. {
  4966. stropt = "“完成查货”";
  4967. CeErpSukuraData.createInfo(entity.ctid, 6);
  4968. }
  4969. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4970. entity.UpdateTime = DateTime.Now;
  4971. entity.MemoOpt = 0;
  4972. entity.Update();
  4973. returnSuccessMsg("操作成功!");
  4974. return;
  4975. }
  4976. returnErrorMsg("找不到记录");
  4977. }
  4978. }
  4979. public void get_erp_deliveryunusual()
  4980. {
  4981. DataStruct dStruct = GetPostStruct();
  4982. List<string> lw = new List<string>();
  4983. string tid = GetPostString("ctid");
  4984. if (tid.Length > 0)
  4985. {
  4986. string select_tid = getTidByCtid(tid);
  4987. lw.Add(string.Format("tid='{0}'", select_tid));
  4988. }
  4989. string shopname = GetPostString("shopname");
  4990. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4991. string buyernick = GetPostString("buyer_nick");
  4992. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4993. string customer = GetPostString("customer");
  4994. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4995. string design = GetPostString("design");
  4996. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4997. string sellermemo = GetPostString("seller_memo");
  4998. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4999. string supplier = GetPostString("supplier");
  5000. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5001. string date1 = GetPostString("date1");
  5002. string date2 = GetPostString("date2");
  5003. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5004. if (dw.Length > 0) lw.Add(dw);
  5005. string placedate1 = GetPostString("placedate1");
  5006. string placedate2 = GetPostString("placedate2");
  5007. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5008. if (dw_place.Length > 0) lw.Add(dw_place);
  5009. string price1 = GetPostString("price1");
  5010. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5011. string price2 = GetPostString("price2");
  5012. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5013. string unusualCon = GetPostString("unusualcon");
  5014. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  5015. string posTag = CurrentUser.UserPost.Post.Code;
  5016. if (posTag == "Supplier")
  5017. {
  5018. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5019. }
  5020. lw.Add(string.Format("OrderState = 6"));
  5021. lw.Add(string.Format("UnusualTag = 5"));
  5022. lw.Add(string.Format("IsRefund<={0}", 1));
  5023. dStruct.Order = "FinishPlaceTime desc";
  5024. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5025. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5026. writeGridDataTableJson(dStruct.TotalCount, dt);
  5027. }
  5028. public void get_erp_deliveryedlist()
  5029. {
  5030. DataStruct dStruct = GetPostStruct();
  5031. List<string> lw = new List<string>();
  5032. string tid = GetPostString("ctid");
  5033. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5034. string shopname = GetPostString("shopname");
  5035. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5036. string buyernick = GetPostString("buyer_nick");
  5037. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5038. string customer = GetPostString("customer");
  5039. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5040. string design = GetPostString("design");
  5041. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5042. string sellermemo = GetPostString("seller_memo");
  5043. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5044. string logistics = GetPostString("logistics");
  5045. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5046. string date1 = GetPostString("date1");
  5047. string date2 = GetPostString("date2");
  5048. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5049. //if (dw.Length > 0) lw.Add(dw);
  5050. string placedate1 = GetPostString("placedate1");
  5051. string placedate2 = GetPostString("placedate2");
  5052. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5053. if (fdw.Length > 0) lw.Add(fdw);
  5054. string devdate1 = GetPostString("deliverydate1");
  5055. string devdate2 = GetPostString("deliverydate2");
  5056. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5057. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5058. string price1 = GetPostString("price1");
  5059. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5060. string price2 = GetPostString("price2");
  5061. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5062. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5063. {
  5064. if (tid.Length > 0)
  5065. {
  5066. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5067. if (tid.Length > 5)
  5068. {
  5069. List<string> tids = getTidByCtidLike(tid);
  5070. if (tids.Count > 0 && tids.Count < 10)
  5071. {
  5072. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5073. }
  5074. }
  5075. lw.Add(tid_sql);
  5076. }
  5077. if (buyernick.Length > 0)
  5078. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5079. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5080. if (dw.Length > 0) lw.Add(dw);
  5081. }
  5082. else
  5083. {
  5084. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5085. }
  5086. string posTag = CurrentUser.UserPost.Post.Code;
  5087. if (posTag == "Supplier")
  5088. {
  5089. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5090. }
  5091. else
  5092. {
  5093. string supplier = GetPostString("supplier");
  5094. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5095. }
  5096. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5097. lw.Add(string.Format("type != 'PDD' "));
  5098. lw.Add(string.Format("IsRefund!={0}", 2));
  5099. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5100. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5101. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5102. /*if (tid.Length > 0)
  5103. {
  5104. List<string> tids = new List<string>();
  5105. if (dt != null && dt.Rows.Count > 0)
  5106. {
  5107. foreach (DataRow item in dt.Rows)
  5108. {
  5109. tids.Add("'" + item["tid"] + "'");
  5110. }
  5111. }
  5112. if (tids.Count > 0)
  5113. {
  5114. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5115. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5116. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5117. dt = WebCache.GetData("view_erptradecell", dStruct);
  5118. }
  5119. }*/
  5120. if (dt != null)
  5121. {
  5122. foreach (DataRow dr in dt.Rows)
  5123. {
  5124. 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();
  5125. }
  5126. }
  5127. writeGridDataTableJson(dStruct.TotalCount, dt);
  5128. }
  5129. public void get_erp_pdddeliveryed()
  5130. {
  5131. DataStruct dStruct = GetPostStruct();
  5132. List<string> lw = new List<string>();
  5133. string tid = GetPostString("ctid");
  5134. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5135. string shopname = GetPostString("shopname");
  5136. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5137. string buyernick = GetPostString("buyer_nick");
  5138. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5139. string customer = GetPostString("customer");
  5140. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5141. string design = GetPostString("design");
  5142. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5143. string sellermemo = GetPostString("seller_memo");
  5144. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5145. string logistics = GetPostString("logistics");
  5146. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5147. string date1 = GetPostString("date1");
  5148. string date2 = GetPostString("date2");
  5149. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5150. //if (dw.Length > 0) lw.Add(dw);
  5151. string placedate1 = GetPostString("placedate1");
  5152. string placedate2 = GetPostString("placedate2");
  5153. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5154. if (fdw.Length > 0) lw.Add(fdw);
  5155. string devdate1 = GetPostString("deliverydate1");
  5156. string devdate2 = GetPostString("deliverydate2");
  5157. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5158. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5159. string price1 = GetPostString("price1");
  5160. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5161. string price2 = GetPostString("price2");
  5162. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5163. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5164. {
  5165. if (tid.Length > 0)
  5166. {
  5167. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5168. if (tid.Length > 5)
  5169. {
  5170. List<string> tids = getTidByCtidLike(tid);
  5171. if (tids.Count > 0 && tids.Count < 10)
  5172. {
  5173. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5174. }
  5175. }
  5176. lw.Add(tid_sql);
  5177. }
  5178. if (buyernick.Length > 0)
  5179. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5180. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5181. if (dw.Length > 0) lw.Add(dw);
  5182. }
  5183. else
  5184. {
  5185. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5186. }
  5187. string posTag = CurrentUser.UserPost.Post.Code;
  5188. if (posTag == "Supplier")
  5189. {
  5190. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5191. }
  5192. else
  5193. {
  5194. string supplier = GetPostString("supplier");
  5195. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5196. }
  5197. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5198. lw.Add(string.Format("type = 'PDD' "));
  5199. lw.Add(string.Format("IsRefund!={0}", 2));
  5200. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5201. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5202. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5203. /* if (tid.Length > 0)
  5204. {
  5205. List<string> tids = new List<string>();
  5206. if (dt != null && dt.Rows.Count > 0)
  5207. {
  5208. foreach (DataRow item in dt.Rows)
  5209. {
  5210. tids.Add("'" + item["tid"] + "'");
  5211. }
  5212. }
  5213. if (tids.Count > 0)
  5214. {
  5215. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5216. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5217. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5218. dt = WebCache.GetData("view_erptradecell", dStruct);
  5219. }
  5220. }*/
  5221. foreach (DataRow dr in dt.Rows)
  5222. {
  5223. 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();
  5224. }
  5225. writeGridDataTableJson(dStruct.TotalCount, dt);
  5226. }
  5227. public void get_erp_jddeliveryed()
  5228. {
  5229. DataStruct dStruct = GetPostStruct();
  5230. List<string> lw = new List<string>();
  5231. string tid = GetPostString("ctid");
  5232. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5233. string shopname = GetPostString("shopname");
  5234. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5235. string buyernick = GetPostString("buyer_nick");
  5236. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5237. string customer = GetPostString("customer");
  5238. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5239. string design = GetPostString("design");
  5240. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5241. string sellermemo = GetPostString("seller_memo");
  5242. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5243. string date1 = GetPostString("date1");
  5244. string date2 = GetPostString("date2");
  5245. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5246. //if (dw.Length > 0) lw.Add(dw);
  5247. string placedate1 = GetPostString("placedate1");
  5248. string placedate2 = GetPostString("placedate2");
  5249. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5250. if (fdw.Length > 0) lw.Add(fdw);
  5251. string devdate1 = GetPostString("deliverydate1");
  5252. string devdate2 = GetPostString("deliverydate2");
  5253. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5254. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5255. string price1 = GetPostString("price1");
  5256. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5257. string price2 = GetPostString("price2");
  5258. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5259. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5260. {
  5261. if (tid.Length > 0)
  5262. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5263. if (buyernick.Length > 0)
  5264. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5265. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5266. if (dw.Length > 0) lw.Add(dw);
  5267. }
  5268. else
  5269. {
  5270. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5271. }
  5272. string posTag = CurrentUser.UserPost.Post.Code;
  5273. if (posTag == "Supplier")
  5274. {
  5275. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5276. }
  5277. else
  5278. {
  5279. string supplier = GetPostString("supplier");
  5280. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5281. }
  5282. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5283. lw.Add(string.Format("type = 'JD' "));
  5284. lw.Add(string.Format("IsRefund!={0}", 2));
  5285. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5286. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5287. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5288. foreach (DataRow dr in dt.Rows)
  5289. {
  5290. 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();
  5291. }
  5292. writeGridDataTableJson(dStruct.TotalCount, dt);
  5293. }
  5294. public void get_erp_allplacelist()
  5295. {
  5296. DataStruct dStruct = GetPostStruct();
  5297. List<string> lw = new List<string>();
  5298. string tid = GetPostString("ctid");
  5299. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5300. string shopname = GetPostString("shopname");
  5301. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5302. string buyernick = GetPostString("buyer_nick");
  5303. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5304. string customer = GetPostString("customer");
  5305. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5306. string design = GetPostString("design");
  5307. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5308. string sellermemo = GetPostString("seller_memo");
  5309. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5310. string supplier = GetPostString("supplier");
  5311. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5312. string date1 = GetPostString("date1");
  5313. string date2 = GetPostString("date2");
  5314. string pldate1 = GetPostString("placedate1");
  5315. string pldate2 = GetPostString("placedate2");
  5316. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5317. //if (dw.Length > 0) lw.Add(dw);
  5318. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5319. {
  5320. if (tid.Length > 0)
  5321. {
  5322. string select_tid = getTidByCtid(tid);
  5323. lw.Add(string.Format("tid='{0}'", select_tid));
  5324. }
  5325. if (buyernick.Length > 0)
  5326. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5327. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5328. if (dw.Length > 0) lw.Add(dw);
  5329. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5330. if (dw_place.Length > 0) lw.Add(dw_place);
  5331. }
  5332. else
  5333. {
  5334. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5335. {
  5336. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5337. }
  5338. }
  5339. string price1 = GetPostString("price1");
  5340. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5341. string price2 = GetPostString("price2");
  5342. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5343. string posTag = CurrentUser.UserPost.Post.Code;
  5344. if (posTag == "Supplier")
  5345. {
  5346. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5347. }
  5348. lw.Add(string.Format("OrderState >= 6"));
  5349. lw.Add(string.Format("IsSample != 2 "));
  5350. //lw.Add(string.Format("isDianziOrder = 0 "));
  5351. lw.Add(string.Format("SupplierId > 0 "));
  5352. //lw.Add(string.Format("IsRefund<={0}", 1));
  5353. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5354. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5355. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5356. foreach (DataRow dr in dt.Rows)
  5357. {
  5358. 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();
  5359. }
  5360. writeGridDataTableJson(dStruct.TotalCount, dt);
  5361. }
  5362. public void get_erp_financeallplacelist()
  5363. {
  5364. DataStruct dStruct = GetPostStruct();
  5365. List<string> lw = new List<string>();
  5366. string tid = GetPostString("ctid");
  5367. string shopname = GetPostString("shopname");
  5368. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5369. string buyernick = GetPostString("buyer_nick");
  5370. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5371. string customer = GetPostString("customer");
  5372. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5373. string design = GetPostString("design");
  5374. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5375. string sellermemo = GetPostString("seller_memo");
  5376. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5377. string supplier = GetPostString("supplier");
  5378. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5379. string date1 = GetPostString("date1");
  5380. string date2 = GetPostString("date2");
  5381. string pldate1 = GetPostString("placedate1");
  5382. string pldate2 = GetPostString("placedate2");
  5383. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5384. {
  5385. if (tid.Length > 0)
  5386. {
  5387. string select_tid = getTidByCtid(tid);
  5388. lw.Add(string.Format("tid='{0}'", select_tid));
  5389. }
  5390. if (buyernick.Length > 0)
  5391. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5392. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5393. if (dw.Length > 0) lw.Add(dw);
  5394. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5395. if (dw_place.Length > 0) lw.Add(dw_place);
  5396. }
  5397. else
  5398. {
  5399. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5400. {
  5401. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5402. }
  5403. }
  5404. string price1 = GetPostString("price1");
  5405. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5406. string price2 = GetPostString("price2");
  5407. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5408. string posTag = CurrentUser.UserPost.Post.Code;
  5409. if (posTag == "Supplier")
  5410. {
  5411. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5412. }
  5413. //lw.Add(string.Format("OrderState >= 6"));
  5414. lw.Add(string.Format("IsSample != 2 "));
  5415. lw.Add(string.Format("isDianziOrder = 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_erptradecell2", 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_expresslist()
  5427. {
  5428. int listtype = GetInt("ltype");
  5429. DataStruct dStruct = GetPostStruct();
  5430. List<string> lw = new List<string>();
  5431. string tid = GetPostString("tid");
  5432. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5433. string outsid = GetPostString("out_sid");
  5434. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5435. string importer = GetPostString("ImportUserName");
  5436. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5437. string file = GetPostString("import_file");
  5438. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5439. string printman = GetPostString("printman");
  5440. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5441. string date1 = GetPostString("date1");
  5442. string date2 = GetPostString("date2");
  5443. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5444. if (dw.Length > 0) lw.Add(dw);
  5445. string fdate1 = GetPostString("finishdate1");
  5446. string fdate2 = GetPostString("finishdate2");
  5447. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5448. if (fdw.Length > 0) lw.Add(fdw);
  5449. string supplierId = GetPostString("supplierId");
  5450. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5451. if (listtype == 1)
  5452. {
  5453. lw.Add(string.Format("importUserId !=0"));
  5454. }
  5455. string posTag = CurrentUser.UserPost.Post.Code;
  5456. if (posTag == "Supplier")
  5457. {
  5458. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5459. }
  5460. if (dStruct.PageSize != 100000)
  5461. {
  5462. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5463. }
  5464. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5465. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5466. writeGridDataTableJson(dStruct.TotalCount, dt);
  5467. }
  5468. public void set_erp_buchaorderdelivery()
  5469. {
  5470. if (UrlPostParmsCheck("ctid"))
  5471. {
  5472. string eid = GetPostString("ctid");
  5473. CeErpTradeCell entity = null;
  5474. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5475. if (entity != null)
  5476. {
  5477. if (entity.IsSample != 2)
  5478. {
  5479. returnErrorMsg("补差价单才能标记为已发货");
  5480. return;
  5481. }
  5482. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5483. entity.OrderState = 7;
  5484. entity.Update();
  5485. returnSuccessMsg("操作成功!");
  5486. return;
  5487. }
  5488. returnErrorMsg("找不到记录");
  5489. }
  5490. }
  5491. public void get_stdtemplates()
  5492. {
  5493. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5494. //string res = taobaoHelper.test();
  5495. string res = apiHelper.API_PrintTemplate();
  5496. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5497. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5498. {
  5499. int sidx = res.IndexOf("error_code");
  5500. int eidx = res.IndexOf("success");
  5501. string msg = res.Substring(sidx, eidx - sidx);
  5502. returnErrorMsg(msg);
  5503. return;
  5504. }
  5505. if (res.Length <= 0)
  5506. {
  5507. returnErrorMsg("模板数据为空!");
  5508. return;
  5509. }
  5510. ReturnSuccess(res);
  5511. }
  5512. public void cancel_print_order()
  5513. {
  5514. if (UrlPostParmsCheck("ctid"))
  5515. {
  5516. string ctid = GetPostString("ctid");
  5517. CeErpTradeCell entity = null;
  5518. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5519. if (entity != null)
  5520. {
  5521. string res = "";
  5522. string code = entity.LastBillWaybillCode;
  5523. if (code == "")
  5524. {
  5525. code = entity.OutSid;
  5526. }
  5527. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5528. XLog.SaveLog(0, "取消面单" + res);
  5529. }
  5530. }
  5531. }
  5532. public void set_erp_printwaybill()
  5533. {
  5534. if (UrlPostParmsCheck("ctid"))
  5535. {
  5536. string ctid = GetPostString("ctid");
  5537. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5538. string cpName = GetPostString("cpname");
  5539. string isTogether = GetPostString("together");
  5540. string printType = GetPostString("printType");
  5541. //var res_obj = new
  5542. //{
  5543. // restype = 1,
  5544. // 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\"}"
  5545. //};
  5546. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5547. //ReturnSuccess(ro_json);
  5548. //return;
  5549. bool isUseLastWayBillCode = false;
  5550. CeErpTradeCell entity = null;
  5551. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5552. if (entity != null)
  5553. {
  5554. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5555. {
  5556. isUseLastWayBillCode = true;
  5557. }
  5558. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5559. {
  5560. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5561. return;
  5562. }
  5563. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5564. {
  5565. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5566. return;
  5567. }
  5568. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5569. {
  5570. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5571. return;
  5572. }
  5573. }
  5574. string res = "";
  5575. Api_waybill_code_response_Obj fullObj = null;
  5576. string pData_str = "";
  5577. string curUseWayBillCode = "";
  5578. if (isUseLastWayBillCode == false)
  5579. {
  5580. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5581. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5582. if (res.IndexOf("failure") != -1)
  5583. {
  5584. //int idx = res.IndexOf("sub_message");
  5585. //int idx2 = res.IndexOf("flag");
  5586. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5587. string errMsgNeed = commonHelper.KeepChinese(res);
  5588. var res_objd = new
  5589. {
  5590. restype = 0,
  5591. data = "获取面单失败" + errMsgNeed
  5592. };
  5593. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5594. returnSuccess(ro_jsond);
  5595. if (res.IndexOf("停发") != -1)
  5596. {
  5597. entity.UnusualCon = "物流停发";
  5598. entity.Update();
  5599. }
  5600. //returnErrorMsg("获取面单失败,"+emsg);
  5601. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5602. return;
  5603. }
  5604. else if (res.IndexOf("errorMsg") != -1)
  5605. {
  5606. //int idx = res.IndexOf("errorMsg");
  5607. //int idx2 = res.IndexOf("}]}");
  5608. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5609. string errMsgNeed = commonHelper.KeepChinese(res);
  5610. var res_objf = new
  5611. {
  5612. restype = 0,
  5613. data = "获取面单失败2" + errMsgNeed
  5614. };
  5615. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5616. if (res.IndexOf("停发") != -1)
  5617. {
  5618. entity.UnusualCon = "物流停发";
  5619. entity.Update();
  5620. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5621. if (trade != null)
  5622. {
  5623. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5624. }
  5625. }
  5626. returnSuccess(ro_jsonf);
  5627. //returnErrorMsg("获取面单失败," + emsg);
  5628. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5629. return;
  5630. }
  5631. try
  5632. {
  5633. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5634. //res = res.Replace(" ", "");
  5635. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5636. }
  5637. catch (Exception ex)
  5638. {
  5639. XLog.SaveLog(0, "生成fullObj" + res);
  5640. var res_objf = new
  5641. {
  5642. restype = 0,
  5643. data = "生成fullObj发生错误" + ex.Message
  5644. };
  5645. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5646. returnSuccess(ro_jsonf);
  5647. return;
  5648. }
  5649. if (fullObj.response.data.content.Count > 0)
  5650. {
  5651. ContentItem codeObj = fullObj.response.data.content[0];
  5652. if (cpCode.IndexOf("SFFQ-") != -1)
  5653. {
  5654. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5655. }
  5656. else
  5657. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5658. curUseWayBillCode = codeObj.waybillCode;
  5659. }
  5660. else
  5661. {
  5662. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5663. var res_objf = new
  5664. {
  5665. restype = 0,
  5666. data = "生成fullObj找不到快递单号waybillCode"
  5667. };
  5668. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5669. returnSuccess(ro_jsonf);
  5670. return;
  5671. }
  5672. }
  5673. else
  5674. {
  5675. //使用上次打印的快递单号
  5676. if (cpCode == "SFFQ-LY")
  5677. {
  5678. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5679. }
  5680. else
  5681. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5682. curUseWayBillCode = entity.LastBillWaybillCode;
  5683. }
  5684. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5685. {
  5686. var res_obje = new
  5687. {
  5688. restype = 0,
  5689. data = "获取加密打印数据失败"
  5690. };
  5691. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5692. returnSuccess(ro_jsone);
  5693. entity.LastBillCpCode = cpCode;
  5694. entity.LastBillWaybillCode = curUseWayBillCode;
  5695. entity.Update();
  5696. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5697. //returnErrorMsg("获取加密打印数据失败");
  5698. return;
  5699. }
  5700. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5701. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5702. string btnType = "";
  5703. string errorMsg = "";
  5704. if (entity != null)
  5705. {
  5706. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5707. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5708. //cpcode是 YTO-CAINIAO
  5709. //string comCode = cpCode.Split('-')[0].ToString();
  5710. string apires = "";
  5711. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5712. //isTogether=2是新的合包弹窗
  5713. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5714. {
  5715. if (ctid.IndexOf("N") != -1)
  5716. {
  5717. apires = "发货成功";
  5718. }
  5719. else
  5720. {
  5721. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5722. }
  5723. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5724. //打单后发货
  5725. StringBuilder sql = new StringBuilder();
  5726. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5727. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5728. {
  5729. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5730. }
  5731. else
  5732. {
  5733. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5734. }
  5735. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5736. foreach (DataRow row in dt.Rows)
  5737. {
  5738. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5739. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5740. {
  5741. try
  5742. {
  5743. btnType = "待发货";
  5744. entity.OutSid = curUseWayBillCode;
  5745. entity.OrderState = 7;
  5746. entity.IsUrgency = false;
  5747. entity.LastBillCpCode = "";
  5748. entity.LastBillWaybillCode = "";
  5749. entity.FinishDeliveryTime = DateTime.Now;
  5750. entity.IsReturn = 0;
  5751. entity.MemoOpt = 0;
  5752. entity.UpdateTime = DateTime.Now;
  5753. entity.Update();
  5754. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5755. //还要插入快递信息到 快递信息表
  5756. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5757. exinfo.tid = entity.ctid;
  5758. exinfo.out_sid = curUseWayBillCode;
  5759. exinfo.company_code = cpCode;
  5760. exinfo.company_name = cpName;
  5761. exinfo.supplierUserName = supplierName;
  5762. exinfo.deliveryType = "发货成功";
  5763. exinfo.print_time = DateTime.Now;
  5764. exinfo.printUser = CurrentUser.UserName;
  5765. exinfo.postData = pData_str;
  5766. exinfo.Create();
  5767. commonHelper.UpdateRelationOrder(entity.ctid);
  5768. CeErpSukuraData.createInfo(ctid, 4);
  5769. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5770. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5771. {
  5772. commonHelper.sendCytExpress(exinfo);
  5773. }
  5774. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5775. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5776. }
  5777. catch (Exception ex)
  5778. {
  5779. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5780. }
  5781. }
  5782. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5783. {
  5784. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5785. if (entity.OrderState == 6)
  5786. {
  5787. entity.OrderState = 7;
  5788. }
  5789. entity.UpdateTime = DateTime.Now;
  5790. entity.FinishDeliveryTime = DateTime.Now;
  5791. btnType = "已发货";
  5792. entity.Update();
  5793. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5794. exinfo.tid = entity.ctid;
  5795. exinfo.out_sid = curUseWayBillCode;
  5796. exinfo.company_code = cpCode;
  5797. exinfo.company_name = cpName;
  5798. exinfo.supplierUserName = supplierName;
  5799. exinfo.deliveryType = "发货成功";
  5800. exinfo.print_time = DateTime.Now;
  5801. exinfo.printUser = CurrentUser.UserName;
  5802. exinfo.postData = pData_str;
  5803. exinfo.Create();
  5804. commonHelper.UpdateRelationOrder(entity.ctid);
  5805. CeErpSukuraData.createInfo(entity.ctid, 4);
  5806. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5807. {
  5808. commonHelper.sendCytExpress(exinfo);
  5809. }
  5810. //不处理
  5811. }
  5812. else
  5813. {
  5814. entity.UpdateTime = DateTime.Now;
  5815. entity.LastBillCpCode = cpCode;
  5816. entity.LastBillWaybillCode = curUseWayBillCode;
  5817. entity.Update();
  5818. string errmsg = commonHelper.KeepChinese(apires);
  5819. var res_objz = new
  5820. {
  5821. restype = 0,
  5822. data = "打单后发货失败"
  5823. };
  5824. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5825. returnSuccess(ro_jsonz);
  5826. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5827. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5828. return;
  5829. }
  5830. }
  5831. }
  5832. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5833. {
  5834. string ctids = GetPostString("ctids");
  5835. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5836. List<string> list = new List<string>();
  5837. List<string> send_list = new List<string>();
  5838. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5839. CeErpTrade ceErpTrade = new CeErpTrade();
  5840. //可合包的合并一起发货
  5841. if (dt == null && string.IsNullOrEmpty(ctids))
  5842. {
  5843. var res_objz = new
  5844. {
  5845. restype = 0,
  5846. data = "打单后发货失败"
  5847. };
  5848. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5849. returnSuccess(ro_jsonz);
  5850. return;
  5851. }
  5852. if (!string.IsNullOrEmpty(ctids))
  5853. {
  5854. StringBuilder sql = new StringBuilder();
  5855. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5856. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5857. }
  5858. foreach (DataRow row in dt.Rows)
  5859. {
  5860. list.Add("'" + row["ctid"] + "'");
  5861. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5862. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5863. if (ctid.IndexOf("N") != -1)
  5864. {
  5865. apires = "发货成功";
  5866. }
  5867. else
  5868. {
  5869. if (!send_list.Contains(ceErpTrade.tid))
  5870. {
  5871. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5872. }
  5873. else
  5874. {
  5875. apires = "发货成功";
  5876. }
  5877. }
  5878. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5879. {
  5880. send_list.Add(ceErpTrade.tid);
  5881. try
  5882. {
  5883. btnType = "待发货";
  5884. ceErpTradeCell.OutSid = curUseWayBillCode;
  5885. ceErpTradeCell.OrderState = 7;
  5886. ceErpTradeCell.IsUrgency = false;
  5887. ceErpTradeCell.LastBillCpCode = "";
  5888. ceErpTradeCell.LastBillWaybillCode = "";
  5889. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5890. ceErpTradeCell.IsReturn = 0;
  5891. ceErpTradeCell.MemoOpt = 0;
  5892. ceErpTradeCell.UpdateTime = DateTime.Now;
  5893. ceErpTradeCell.Update();
  5894. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5895. //还要插入快递信息到 快递信息表
  5896. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5897. exinfo.tid = ceErpTradeCell.ctid;
  5898. exinfo.out_sid = curUseWayBillCode;
  5899. exinfo.company_code = cpCode;
  5900. exinfo.company_name = cpName;
  5901. exinfo.supplierUserName = supplierName;
  5902. exinfo.deliveryType = "发货成功";
  5903. exinfo.print_time = DateTime.Now;
  5904. exinfo.printUser = CurrentUser.UserName;
  5905. exinfo.postData = pData_str;
  5906. exinfo.Create();
  5907. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5908. CeErpSukuraData.createInfo(ctid, 4);
  5909. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5910. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80 || entity.SupplierId == 126)
  5911. {
  5912. commonHelper.sendCytExpress(exinfo);
  5913. }
  5914. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5915. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5916. }
  5917. catch (Exception ex)
  5918. {
  5919. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5920. }
  5921. }
  5922. else
  5923. {
  5924. ceErpTradeCell.UpdateTime = DateTime.Now;
  5925. ceErpTradeCell.LastBillCpCode = cpCode;
  5926. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5927. ceErpTradeCell.Update();
  5928. string errmsg = commonHelper.KeepChinese(apires);
  5929. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5930. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5931. }
  5932. }
  5933. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5934. }
  5935. }
  5936. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5937. var res_obj = new
  5938. {
  5939. restype = 1,
  5940. data = pData_str,
  5941. errorMsg
  5942. };
  5943. string ro_json = JsonConvert.SerializeObject(res_obj);
  5944. ReturnSuccess(ro_json);
  5945. return;
  5946. }
  5947. }
  5948. private string GetUTF8String(byte[] vs)
  5949. {
  5950. throw new NotImplementedException();
  5951. }
  5952. public void set_erp_printwaybill_cn()
  5953. {
  5954. if (UrlPostParmsCheck("ctid"))
  5955. {
  5956. string ctid = GetPostString("ctid");
  5957. string cpCode = GetPostString("cpcode");
  5958. string cpName = GetPostString("cpname");
  5959. string tempUrl = GetPostString("tempurl");
  5960. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5961. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5962. //string res = taobaoHelper.test();
  5963. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5964. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5965. {
  5966. int sidx = res.IndexOf("errorMsg");
  5967. int eidx = res.IndexOf("}");
  5968. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5969. var res_objzxx = new
  5970. {
  5971. restype = 0,
  5972. data = msg
  5973. };
  5974. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5975. returnSuccess(ro_jsonzxx);
  5976. //returnErrorMsg(msg);
  5977. return;
  5978. }
  5979. int idx = res.IndexOf("waybillCode");
  5980. int idx2 = res.IndexOf("printData");
  5981. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5982. string eid = GetPostString("ctid");
  5983. CeErpTradeCell entity = null;
  5984. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5985. if (entity != null)
  5986. {
  5987. string osid = entity.OutSid;
  5988. entity.OutSid = osid + "," + outsid;
  5989. entity.FinishDeliveryTime = DateTime.Now;
  5990. entity.OrderState = 7;
  5991. entity.UpdateTime = DateTime.Now;
  5992. entity.IsReturn = 0;
  5993. entity.Update();
  5994. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5995. exinfo.tid = entity.ctid;
  5996. exinfo.out_sid = outsid;
  5997. exinfo.company_code = cpCode;
  5998. exinfo.company_name = cpName;
  5999. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  6000. exinfo.deliveryType = "发货成功";
  6001. exinfo.print_time = DateTime.Now;
  6002. exinfo.printUser = CurrentUser.UserName;
  6003. exinfo.Create();
  6004. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  6005. {
  6006. commonHelper.sendCytExpress(exinfo);
  6007. }
  6008. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  6009. }
  6010. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  6011. var res_objz = new
  6012. {
  6013. restype = 1,
  6014. data = res
  6015. };
  6016. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6017. returnSuccess(ro_jsonz);
  6018. //ReturnSuccess(res);
  6019. }
  6020. }
  6021. ////打单,打印面单 获取面单号
  6022. //public void set_erp_printwaybill()
  6023. //{
  6024. // if (UrlPostParmsCheck("ctid"))
  6025. // {
  6026. // string ctid = GetPostString("ctid");
  6027. // string cpCode = GetPostString("cpcode");
  6028. // string tempUrl = GetPostString("tempurl");
  6029. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6030. // //string res = taobaoHelper.test();
  6031. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6032. // if (res.IndexOf("error_response") != -1)
  6033. // {
  6034. // int sidx = res.IndexOf("sub_msg");
  6035. // int eidx = res.IndexOf("request_id");
  6036. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  6037. // returnErrorMsg(msg);
  6038. // return;
  6039. // }
  6040. // int idx = res.IndexOf("waybill_code");
  6041. // int idx2 = res.IndexOf("}]}");
  6042. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  6043. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  6044. // ReturnSuccess(res);
  6045. // }
  6046. //}
  6047. public void cancel_erp_aftersale()
  6048. {
  6049. if (UrlPostParmsCheck("ctid"))
  6050. {
  6051. string eid = GetPostString("ctid");
  6052. CeErpTradeCell entity = null;
  6053. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6054. if (entity != null)
  6055. {
  6056. //有过处理的售后,取消也不能删除 售 字,保留
  6057. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6058. {
  6059. entity.AfterSaleState = 4;
  6060. }
  6061. else
  6062. entity.AfterSaleState = 0;
  6063. entity.UpdateTime = DateTime.Now;
  6064. entity.Update();
  6065. returnSuccessMsg("操作成功!");
  6066. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6067. return;
  6068. }
  6069. returnErrorMsg("找不到订单记录");
  6070. }
  6071. }
  6072. public void get_erp_aftersalelist()
  6073. {
  6074. DataStruct dStruct = GetPostStruct();
  6075. List<string> lw = new List<string>();
  6076. int st = GetInt("st");
  6077. string tid = GetPostString("ctid");
  6078. if (st == 3)
  6079. {
  6080. if (tid.Length > 0)
  6081. {
  6082. string select_tid = getTidByCtid(tid);
  6083. lw.Add(string.Format("tid='{0}'", select_tid));
  6084. }
  6085. }
  6086. else
  6087. {
  6088. if (tid.Length > 0)
  6089. {
  6090. string select_tid = getTidByCtid(tid);
  6091. lw.Add(string.Format("tid='{0}'", select_tid));
  6092. }
  6093. }
  6094. string shopname = GetPostString("shopname");
  6095. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6096. string buyernick = GetPostString("buyer_nick");
  6097. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6098. string sellermemo = GetPostString("seller_memo");
  6099. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6100. string orderState = GetPostString("orderState");
  6101. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6102. string afterState = GetPostString("afterstate");
  6103. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6104. string date1 = GetPostString("date1");
  6105. string date2 = GetPostString("date2");
  6106. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6107. if (dw.Length > 0) lw.Add(dw);
  6108. string price1 = GetPostString("price1");
  6109. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6110. string price2 = GetPostString("price2");
  6111. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6112. //lw.Add(string.Format("IsRefund!={0}", 1));
  6113. string reason = GetPostString("reason");
  6114. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6115. string method = GetPostString("method");
  6116. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6117. string handler = GetPostString("handler");
  6118. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6119. string handledate1 = GetPostString("handledate1");
  6120. string handledate2 = GetPostString("handledate2");
  6121. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6122. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6123. string finish1 = GetPostString("finishdate1");
  6124. string finish2 = GetPostString("finishdate2");
  6125. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6126. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6127. string afterdate1 = GetPostString("afterdate1");
  6128. string afterdate2 = GetPostString("afterdate2");
  6129. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6130. if (afterDate.Length > 0) lw.Add(afterDate);
  6131. string supplier = GetPostString("supplier");
  6132. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6133. string responsible = GetPostString("responsibleman");
  6134. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6135. string customer = GetPostString("customer");
  6136. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6137. string design = GetPostString("design");
  6138. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6139. string afterMemoType = GetPostString("aftermemotype");
  6140. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6141. string posCode = CurrentUser.UserPost.Post.Code;
  6142. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6143. //{
  6144. // string vstate = GetPostString("vstate");
  6145. // if (vstate.Length > 0)
  6146. // {
  6147. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6148. // }
  6149. // if (posCode == "Supplier")
  6150. // {
  6151. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6152. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6153. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6154. // }
  6155. // else
  6156. // {
  6157. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6158. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6159. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6160. // {
  6161. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6162. // }
  6163. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6164. // {
  6165. // int orgid = CurrentUser.UserPost.OrgID;
  6166. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6167. // }
  6168. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6169. // {
  6170. // string shopid = CurrentUser.User.pemShop;
  6171. // lw.Add(string.Format("shopId in ({0})", shopid));
  6172. // }
  6173. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6174. // //{
  6175. // // int org_id = CurrentUser.UserPost.OrgID;
  6176. // // lw.Add(string.Format("OrgID={0}", org_id));
  6177. // //}
  6178. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6179. // }
  6180. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6181. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6182. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6183. //}
  6184. if (st == 5)
  6185. {
  6186. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6187. {
  6188. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6189. {
  6190. string shopid = CurrentUser.User.pemShop;
  6191. lw.Add(string.Format("shopId in ({0})", shopid));
  6192. }
  6193. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6194. {
  6195. int mrOrgid = CurrentUser.UserPost.OrgID;
  6196. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6197. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6198. }
  6199. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6200. //{
  6201. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6202. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6203. //}
  6204. else
  6205. {
  6206. string userIdStr = "";
  6207. if (posCode == "CustomerService")
  6208. {
  6209. userIdStr = CurrentUser.UserID + "_k";
  6210. }
  6211. else if (posCode == "Designer" || posCode == "wxDesigner")
  6212. {
  6213. userIdStr = CurrentUser.UserID + "_s";
  6214. }
  6215. else if (posCode == "Place")
  6216. {
  6217. userIdStr = CurrentUser.UserID + "_x";
  6218. }
  6219. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6220. }
  6221. }
  6222. string placedate1 = GetPostString("placedate1");
  6223. string placedate2 = GetPostString("placedate2");
  6224. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6225. if (dwplace.Length > 0) lw.Add(dwplace);
  6226. string supState = GetPostString("supState");
  6227. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6228. string searchType = GetPostString("searchType");
  6229. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6230. {
  6231. lw.Add(string.Format("BackNum>1"));
  6232. }
  6233. lw.Add(string.Format("AfterSaleState>0"));
  6234. if (ex_psize > 0)
  6235. {
  6236. if (CurrentUser.UserPost.Post.Code == "Finance")
  6237. dStruct.Order = "pay_time desc";
  6238. else
  6239. dStruct.Order = "HandleTime desc";
  6240. }
  6241. else
  6242. dStruct.Order = "HandleTime desc";
  6243. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6244. DataTable dt = WebCache.GetData("view_test", dStruct);
  6245. writeGridDataTableJson(dStruct.TotalCount, dt);
  6246. }
  6247. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6248. //{
  6249. // lw.Add(string.Format("AfterSaleState=4"));
  6250. // string code = CurrentUser.UserPost.Post.Code;
  6251. // if (code == "CustomerService")
  6252. // {
  6253. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6254. // }
  6255. // else if (code == "Designer" || code == "DesignerMr")
  6256. // {
  6257. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6258. // }
  6259. // else if (code == "Place" || code == "PlaceMr")
  6260. // {
  6261. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6262. // }
  6263. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6264. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6265. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6266. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6267. //}
  6268. //else //处理中的售后,待处理和处理中合并
  6269. //{
  6270. // if (afterState.Length <= 0)
  6271. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6272. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6273. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6274. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6275. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6276. //}
  6277. }
  6278. public void get_erp_disagreeftersalelist()
  6279. {
  6280. DataStruct dStruct = GetPostStruct();
  6281. List<string> lw = new List<string>();
  6282. int st = 2;
  6283. string tid = GetPostString("ctid");
  6284. if (tid.Length > 0)
  6285. {
  6286. string select_tid = getTidByCtid(tid);
  6287. lw.Add(string.Format("tid='{0}'", select_tid));
  6288. }
  6289. string shopname = GetPostString("shopname");
  6290. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6291. string buyernick = GetPostString("buyer_nick");
  6292. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6293. string sellermemo = GetPostString("seller_memo");
  6294. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6295. string orderState = GetPostString("orderState");
  6296. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6297. string afterState = GetPostString("afterstate");
  6298. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6299. string date1 = GetPostString("date1");
  6300. string date2 = GetPostString("date2");
  6301. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6302. if (dw.Length > 0) lw.Add(dw);
  6303. string price1 = GetPostString("price1");
  6304. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6305. string price2 = GetPostString("price2");
  6306. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6307. //lw.Add(string.Format("IsRefund!={0}", 1));
  6308. string reason = GetPostString("reason");
  6309. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6310. string method = GetPostString("method");
  6311. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6312. string handler = GetPostString("handler");
  6313. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6314. string handledate1 = GetPostString("handledate1");
  6315. string handledate2 = GetPostString("handledate2");
  6316. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6317. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6318. string afterdate1 = GetPostString("afterdate1");
  6319. string afterdate2 = GetPostString("afterdate2");
  6320. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6321. if (afterDate.Length > 0) lw.Add(afterDate);
  6322. string backdate1 = GetPostString("backdate1");
  6323. string backdate2 = GetPostString("backdate2");
  6324. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6325. if (backDate.Length > 0) lw.Add(backDate);
  6326. string supplier = GetPostString("supplier");
  6327. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6328. string responsible = GetPostString("responsibleman");
  6329. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6330. string customer = GetPostString("customer");
  6331. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6332. string design = GetPostString("design");
  6333. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6334. string afterSaleMemo = GetPostString("afterSaleMemo");
  6335. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6336. string afterMemoType = GetPostString("aftermemotype");
  6337. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6338. string aftersakereason = GetPostString("aftersakereason");
  6339. if (aftersakereason.Length > 0)
  6340. {
  6341. if (aftersakereason == "1")
  6342. {
  6343. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6344. }
  6345. if (aftersakereason == "2")
  6346. {
  6347. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6348. }
  6349. }
  6350. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6351. string poscode = CurrentUser.UserPost.Post.Code;
  6352. if (poscode != "SysAdmin")
  6353. {
  6354. string shopid = CurrentUser.User.pemShop;
  6355. lw.Add(string.Format("shopId in ({0})", shopid));
  6356. }
  6357. string searchType = GetPostString("searchType");
  6358. if (searchType == "wait")
  6359. {
  6360. lw.Add(string.Format("HandleTime is null"));
  6361. }
  6362. if (searchType == "handling")
  6363. {
  6364. lw.Add(string.Format("HandleTime is not null "));
  6365. }
  6366. if (searchType == "back" || searchType == "puBack")
  6367. {
  6368. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6369. }
  6370. if (searchType == "reBack")
  6371. {
  6372. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6373. }
  6374. if (searchType == "moreBack")
  6375. {
  6376. lw.Add(string.Format("backNum > 1"));
  6377. }
  6378. lw.Add(string.Format("(AfterSaleState=5)"));
  6379. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6380. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6381. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6382. writeGridDataTableJson(dStruct.TotalCount, dt);
  6383. }
  6384. public void get_erp_handlingaftersalelist()
  6385. {
  6386. DataStruct dStruct = GetPostStruct();
  6387. List<string> lw = new List<string>();
  6388. int st = 2;
  6389. string tid = GetPostString("ctid");
  6390. if (tid.Length > 0)
  6391. {
  6392. string select_tid = getTidByCtid(tid);
  6393. lw.Add(string.Format("tid='{0}'", select_tid));
  6394. }
  6395. string shopname = GetPostString("shopname");
  6396. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6397. string buyernick = GetPostString("buyer_nick");
  6398. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6399. string sellermemo = GetPostString("seller_memo");
  6400. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6401. string orderState = GetPostString("orderState");
  6402. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6403. string afterState = GetPostString("afterstate");
  6404. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6405. string date1 = GetPostString("date1");
  6406. string date2 = GetPostString("date2");
  6407. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6408. if (dw.Length > 0) lw.Add(dw);
  6409. string price1 = GetPostString("price1");
  6410. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6411. string price2 = GetPostString("price2");
  6412. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6413. //lw.Add(string.Format("IsRefund!={0}", 1));
  6414. string reason = GetPostString("reason");
  6415. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6416. string method = GetPostString("method");
  6417. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6418. string handler = GetPostString("handler");
  6419. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6420. string handledate1 = GetPostString("handledate1");
  6421. string handledate2 = GetPostString("handledate2");
  6422. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6423. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6424. string afterdate1 = GetPostString("afterdate1");
  6425. string afterdate2 = GetPostString("afterdate2");
  6426. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6427. if (afterDate.Length > 0) lw.Add(afterDate);
  6428. string supplier = GetPostString("supplier");
  6429. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6430. string responsible = GetPostString("responsibleman");
  6431. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6432. string customer = GetPostString("customer");
  6433. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6434. string design = GetPostString("design");
  6435. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6436. string afterSaleMemo = GetPostString("afterSaleMemo");
  6437. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6438. string afterMemoType = GetPostString("aftermemotype");
  6439. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6440. string afterresult = GetPostString("afterresult");
  6441. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6442. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6443. string poscode = CurrentUser.UserPost.Post.Code;
  6444. if (poscode != "SysAdmin")
  6445. {
  6446. string shopid = CurrentUser.User.pemShop;
  6447. lw.Add(string.Format("shopId in ({0})", shopid));
  6448. }
  6449. string searchType = GetPostString("searchType");
  6450. if (searchType == "wait")
  6451. {
  6452. lw.Add(string.Format("HandleTime is null"));
  6453. }
  6454. if (searchType == "documentary")
  6455. {
  6456. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6457. }
  6458. if (searchType == "handling")
  6459. {
  6460. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6461. }
  6462. if (searchType == "back" || searchType == "puBack")
  6463. {
  6464. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6465. }
  6466. if (searchType == "reBack")
  6467. {
  6468. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6469. }
  6470. if (afterState.Length <= 0)
  6471. {
  6472. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6473. }
  6474. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6475. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6476. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6477. writeGridDataTableJson(dStruct.TotalCount, dt);
  6478. }
  6479. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6480. //public void get_erp_back_handlingaftersalelist()
  6481. //{
  6482. // DataStruct dStruct = GetPostStruct();
  6483. // List<string> lw = new List<string>();
  6484. // string tid = GetPostString("ctid");
  6485. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6486. // string shopname = GetPostString("shopname");
  6487. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6488. // string buyernick = GetPostString("buyer_nick");
  6489. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6490. // string sellermemo = GetPostString("seller_memo");
  6491. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6492. // string orderState = GetPostString("orderState");
  6493. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6494. // string afterState = GetPostString("afterstate");
  6495. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6496. // string date1 = GetPostString("date1");
  6497. // string date2 = GetPostString("date2");
  6498. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6499. // if (dw.Length > 0) lw.Add(dw);
  6500. // string price1 = GetPostString("price1");
  6501. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6502. // string price2 = GetPostString("price2");
  6503. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6504. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6505. // string reason = GetPostString("reason");
  6506. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6507. // string method = GetPostString("method");
  6508. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6509. // string handler = GetPostString("handler");
  6510. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6511. // string handledate1 = GetPostString("handledate1");
  6512. // string handledate2 = GetPostString("handledate2");
  6513. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6514. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6515. // string afterdate1 = GetPostString("afterdate1");
  6516. // string afterdate2 = GetPostString("afterdate2");
  6517. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6518. // if (afterDate.Length > 0) lw.Add(afterDate);
  6519. // string supplier = GetPostString("supplier");
  6520. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6521. // string responsible = GetPostString("responsibleman");
  6522. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6523. // string customer = GetPostString("customer");
  6524. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6525. // string design = GetPostString("design");
  6526. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6527. // string afterMemoType = GetPostString("aftermemotype");
  6528. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6529. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6530. // if (afterState.Length <= 0)
  6531. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6532. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6533. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6534. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6535. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6536. //}
  6537. public void get_erp_aftersaleverifylist()
  6538. {
  6539. DataStruct dStruct = GetPostStruct();
  6540. List<string> lw = new List<string>();
  6541. string tid = GetPostString("ctid");
  6542. if (tid.Length > 0)
  6543. {
  6544. string select_tid = getTidByCtid(tid);
  6545. lw.Add(string.Format("otid='{0}'", select_tid));
  6546. }
  6547. string shopname = GetPostString("shopname");
  6548. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6549. string buyernick = GetPostString("buyer_nick");
  6550. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6551. string sellermemo = GetPostString("seller_memo");
  6552. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6553. string orderState = GetPostString("orderState");
  6554. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6555. //lw.Add(string.Format("IsRefund!={0}", 1));
  6556. string reason = GetPostString("reason");
  6557. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6558. string method = GetPostString("method");
  6559. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6560. string handler = GetPostString("handler");
  6561. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6562. string handledate1 = GetPostString("handledate1");
  6563. string handledate2 = GetPostString("handledate2");
  6564. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6565. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6566. string finish1 = GetPostString("finishdate1");
  6567. string finish2 = GetPostString("finishdate2");
  6568. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6569. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6570. string supplier = GetPostString("supplier");
  6571. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6572. string responsible = GetPostString("responsibleman");
  6573. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6574. string posCode = CurrentUser.UserPost.Post.Code;
  6575. string vstate = GetPostString("vstate");
  6576. if (vstate.Length > 0)
  6577. {
  6578. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6579. }
  6580. if (posCode == "Supplier")
  6581. {
  6582. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6583. lw.Add(string.Format("VerifyState = 0"));
  6584. lw.Add("type = 1");
  6585. lw.Add(string.Format("AfterSaleState={0}", 3));
  6586. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6587. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6588. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6589. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6590. writeGridDataTableJson(dStruct.TotalCount, dt);
  6591. }
  6592. else if (posCode == "logistics")
  6593. {
  6594. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6595. lw.Add(string.Format("VerifyState = 0"));
  6596. lw.Add("type = 2");
  6597. lw.Add(string.Format("AfterSaleState={0}", 3));
  6598. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6599. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6600. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6601. writeGridDataTableJson(dStruct.TotalCount, dt);
  6602. }
  6603. else
  6604. {
  6605. lw.Add(string.Format("(AfterSaleState = 3)"));
  6606. lw.Add("type = 0");
  6607. string reasonState = GetPostString("reasonState");
  6608. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6609. {
  6610. if (reasonState == "2")
  6611. {
  6612. lw.Add("VerifyState = 3");
  6613. }
  6614. else if (reasonState == "1")
  6615. {
  6616. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6617. }
  6618. else
  6619. {
  6620. lw.Add("VerifyState in (0,3)");
  6621. }
  6622. //不加条件,可以看全部
  6623. }
  6624. 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")
  6625. {
  6626. int orgid = CurrentUser.UserPost.OrgID;
  6627. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6628. if (string.IsNullOrEmpty(manageOrgId))
  6629. {
  6630. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6631. }
  6632. else
  6633. {
  6634. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6635. }
  6636. if (reasonState == "1")
  6637. {
  6638. lw.Add("VerifyState = 3");
  6639. }
  6640. else if (reasonState == "2")
  6641. {
  6642. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6643. }
  6644. else
  6645. {
  6646. }
  6647. }
  6648. else
  6649. {
  6650. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6651. }
  6652. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6653. //{
  6654. // int org_id = CurrentUser.UserPost.OrgID;
  6655. // lw.Add(string.Format("OrgID={0}", org_id));
  6656. //}
  6657. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6658. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6659. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6660. writeGridDataTableJson(dStruct.TotalCount, dt);
  6661. }
  6662. }
  6663. public void get_erp_finishaftersalelist()
  6664. {
  6665. DataStruct dStruct = GetPostStruct();
  6666. List<string> lw = new List<string>();
  6667. int st = 4;
  6668. string tid = GetPostString("ctid");
  6669. if (tid.Length > 0)
  6670. {
  6671. string select_tid = getTidByCtid(tid);
  6672. lw.Add(string.Format("otid='{0}'", select_tid));
  6673. }
  6674. string shopname = GetPostString("shopname");
  6675. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6676. //lw.Add(string.Format("IsRefund!={0}", 1));
  6677. string reason = GetPostString("reason");
  6678. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6679. string method = GetPostString("method");
  6680. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6681. string buyernick = GetPostString("buyer_nick");
  6682. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6683. string handler = GetPostString("handler");
  6684. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6685. string handledate1 = GetPostString("handledate1");
  6686. string handledate2 = GetPostString("handledate2");
  6687. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6688. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6689. string finish1 = GetPostString("finishdate1");
  6690. string finish2 = GetPostString("finishdate2");
  6691. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6692. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6693. string supplier = GetPostString("supplier");
  6694. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6695. string responsible = GetPostString("responsibleman");
  6696. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6697. string vstate = GetPostString("vstate");
  6698. if (vstate.Length > 0)
  6699. {
  6700. if ("3".Equals(vstate))
  6701. {
  6702. lw.Add(string.Format("IsTem=1"));
  6703. }
  6704. else
  6705. {
  6706. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6707. }
  6708. }
  6709. lw.Add(string.Format("AfterSaleState=4"));
  6710. string code = CurrentUser.UserPost.Post.Code;
  6711. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6712. {
  6713. //不加条件,可以看全部
  6714. }
  6715. else if (code == "Supplier")
  6716. {
  6717. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6718. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6719. lw.Add("type = 1");
  6720. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6721. }
  6722. else if (code == "logistics")
  6723. {
  6724. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6725. lw.Add("type = 2");
  6726. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6727. }
  6728. 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")
  6729. {
  6730. lw.Add("type = 0");
  6731. int orgid = CurrentUser.UserPost.OrgID;
  6732. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6733. if (string.IsNullOrEmpty(manageOrgIds))
  6734. {
  6735. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6736. }
  6737. else
  6738. {
  6739. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6740. }
  6741. }
  6742. else
  6743. {
  6744. lw.Add("type = 0");
  6745. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6746. }
  6747. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6748. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6749. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6750. writeGridDataTableJson(dStruct.TotalCount, dt);
  6751. }
  6752. public void handle_erp_aftersale()
  6753. {
  6754. if (UrlPostParmsCheck("ctid"))
  6755. {
  6756. string eid = GetPostString("ctid");
  6757. string responStr = GetPostString("AfterSaleResponsible");
  6758. if (responStr.Length <= 0)
  6759. {
  6760. returnErrorMsg("售后责任人不能为空");
  6761. return;
  6762. }
  6763. bool isDesign = false;
  6764. double designFree = 0.00;
  6765. int responsibleId = 0;
  6766. CeErpTradeCell entity = null;
  6767. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6768. if (entity != null)
  6769. {
  6770. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6771. string afterMethod = GetPostString("AfterSaleMethod");
  6772. if (isNeedNewOrder == 1)
  6773. {
  6774. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6775. bool ishav = true;
  6776. if (newentity == null)
  6777. {
  6778. newentity = entity.Clone() as CeErpTradeCell;
  6779. ishav = false;
  6780. newentity.ctid = "S_" + entity.ctid;
  6781. newentity.OrderState = 0;
  6782. //唯一标识
  6783. newentity.OrderSn = newentity.ctid;
  6784. string orderSn = dataHelper.getSaleOrderSn();
  6785. if (orderSn != "")
  6786. {
  6787. newentity.OrderSn = orderSn;
  6788. }
  6789. }
  6790. newentity.UpdateTime = DateTime.Now;
  6791. newentity.AfterSaleState = 0;
  6792. newentity.AfterSaleMethod = afterMethod;
  6793. if (!ishav)
  6794. {
  6795. string memo_str = newentity.seller_memo;
  6796. memo_str = memo_str.Replace("(", "(");
  6797. memo_str = memo_str.Replace(")", ")");
  6798. int sIndex = memo_str.IndexOf("(");
  6799. int eIndex = memo_str.IndexOf(")");
  6800. if (sIndex == -1 || eIndex == -1)
  6801. {
  6802. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6803. return;
  6804. }
  6805. string first = memo_str.Substring(0, sIndex + 1);
  6806. string memoCtid = newentity.OrderSn;
  6807. //if (memoCtid.IndexOf("C") != -1)
  6808. //{
  6809. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6810. //if (CIdx.IndexOf("+") != -1)
  6811. //{
  6812. //CIdx = "C" + CIdx.Split('+')[1];
  6813. //}
  6814. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6815. //}
  6816. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6817. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6818. string newMemo = first + memoCtid + last;
  6819. newentity.seller_memo = newMemo;
  6820. newentity.FinishPlaceTime = null;
  6821. newentity.UnusualTag = 0;
  6822. newentity.UnusualCon = "";
  6823. newentity.UnusualTime = null;
  6824. newentity.AfterSaleMemo = "";
  6825. newentity.AfterSaleMethod = afterMethod;
  6826. newentity.AfterSalePreTime = null;
  6827. newentity.AfterSaleReason = "";
  6828. newentity.AfterSaleResponsible = "";
  6829. newentity.AfterSaleState = 0;
  6830. newentity.AfterSaleTime = null;
  6831. newentity.AfterSaleUserId = 0;
  6832. newentity.AfterSaleSupplierState = 0;
  6833. newentity.LastBillWaybillCode = "";
  6834. newentity.LastBillCpCode = "";
  6835. newentity.FinishAfterSaleTime = null;
  6836. newentity.HandleTime = null;
  6837. newentity.IsSF = 0;
  6838. newentity.IsOldCustomer = 0;
  6839. newentity.UrgencyTime = null;
  6840. newentity.ResponsibleUserId = "";
  6841. newentity.IsVerifyToSupplier = false;
  6842. newentity.payment = 0;
  6843. newentity.CheckMemo = "";
  6844. newentity.OutSid = "";
  6845. newentity.CheckOrderTime = null;
  6846. newentity.MemoOpt = 0;
  6847. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6848. }
  6849. newentity.isAfterSaleOrder = 1;
  6850. newentity.IsRefund = 0;
  6851. string receiveMobile = GetPostString("receiver_mobile");
  6852. if (receiveMobile.Length > 0)
  6853. {
  6854. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6855. if (trade != null)
  6856. {
  6857. trade.receiver_name = GetPostString("receiver_name");
  6858. trade.receiver_mobile = receiveMobile;
  6859. trade.receiver_state = GetPostString("receiver_state");
  6860. trade.receiver_city = GetPostString("receiver_city");
  6861. trade.receiver_district = GetPostString("receiver_district");
  6862. trade.receiver_address = GetPostString("receiver_address");
  6863. newentity.IsOffLineOrder = 1;
  6864. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6865. }
  6866. }
  6867. string st = GetPostString("ToState");
  6868. if (st.Length > 0)
  6869. {
  6870. if (newentity.OrderState <= 3)
  6871. {
  6872. newentity.WaitDesignTime = DateTime.Now;
  6873. newentity.StartDesignTime = null;
  6874. newentity.FinishDesignTime = null;
  6875. newentity.OrderState = 3;
  6876. if (st == "下单员")
  6877. {
  6878. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6879. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6880. {
  6881. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6882. }
  6883. }
  6884. else
  6885. {
  6886. newentity.WaitDesignTime = DateTime.Now;
  6887. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6888. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6889. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6890. {
  6891. DataRow user = dt1.Rows[0];
  6892. //找主管
  6893. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6894. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6895. if (dt != null && dt.Rows.Count > 0)
  6896. {
  6897. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6898. newentity.DesignUserId = designMr;
  6899. string key = "aftersale_order_" + designMr;
  6900. if (RedisHelper.HasKey(key))
  6901. {
  6902. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6903. list.Add(newentity.ctid);
  6904. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6905. }
  6906. }
  6907. //账号正常
  6908. if (user["State"].ToString() == "0")
  6909. {
  6910. newentity.DesignUserId = entity.DesignUserId;
  6911. string key = "aftersale_order_" + entity.DesignUserId;
  6912. if (RedisHelper.HasKey(key))
  6913. {
  6914. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6915. list.Add(newentity.ctid);
  6916. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6917. }
  6918. }
  6919. }
  6920. }
  6921. }
  6922. if (entity.IsXianHuo == 1)
  6923. {
  6924. newentity.OrderState = 6;
  6925. entity.FinishPlaceTime = DateTime.Now;
  6926. }
  6927. }
  6928. if (ishav)
  6929. {
  6930. newentity.Update();
  6931. }
  6932. else
  6933. {
  6934. newentity.Create();
  6935. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6936. newCellExtend.ctid = newentity.ctid;
  6937. newCellExtend.orderFrom = 20;
  6938. newCellExtend.orderType = 30;
  6939. if (st == "下单员")
  6940. {
  6941. }
  6942. else
  6943. {
  6944. newCellExtend.ReprintTime = DateTime.Now;
  6945. }
  6946. newCellExtend.Create();
  6947. }
  6948. if (st != "下单员")
  6949. {
  6950. if (entity.DispatchSort == 2)
  6951. {
  6952. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6953. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6954. }
  6955. }
  6956. }
  6957. //处理售后扩展
  6958. string resIdStr = GetPostString("ResponsibleUserId");
  6959. string refundFees = GetPostString("refundFrees");
  6960. int IsComplain = GetPostInt("isComplain");
  6961. int IsBad = GetPostInt("isBad");
  6962. string IsOriginal = GetPostString("isOriginal");
  6963. double diffResultPrice = GetPostDouble("diffResultPrice");
  6964. string textResult = GetPostString("textResult");
  6965. string supplierResponsible = GetPostString("supplierResponsible");
  6966. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6967. if (ceErpTradeAfterSaleExtend == null)
  6968. {
  6969. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6970. ceErpTradeAfterSaleExtend.tid = eid;
  6971. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6972. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6973. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6974. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6975. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6976. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6977. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6978. ceErpTradeAfterSaleExtend.Create();
  6979. }
  6980. else
  6981. {
  6982. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6983. {
  6984. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6985. }
  6986. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6987. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6988. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6989. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6990. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6991. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6992. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6993. ceErpTradeAfterSaleExtend.Update();
  6994. }
  6995. int gysid = GetPostInt("ResponsibleSupId");
  6996. if (entity.AfterSaleUserId == 0)
  6997. {
  6998. entity.AfterSaleUserId = CurrentUser.UserID;
  6999. }
  7000. entity.ResponsibleUserId = resIdStr;
  7001. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  7002. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  7003. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  7004. {
  7005. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7006. int backNum = 0;
  7007. if (number != null)
  7008. {
  7009. backNum = number.BackNum;
  7010. }
  7011. char[] separator = { ',' };
  7012. string[] sArray = resIdStr.Split(separator);
  7013. string[] refundFreeList = { };
  7014. if (refundFees.Length > 0)
  7015. {
  7016. refundFreeList = refundFees.Split(separator);
  7017. }
  7018. int index = -1;
  7019. List<int> responsibleIds = new List<int>();
  7020. foreach (string i in sArray)
  7021. {
  7022. index++;
  7023. if (i.Length <= 0) continue;
  7024. char[] separator2 = { '_' };
  7025. string idstr = i.Split(separator2)[0];
  7026. string idtype = i.Split(separator2)[1];
  7027. double refudFree = 0;
  7028. if (refundFreeList.Length > 0)
  7029. {
  7030. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  7031. }
  7032. if (idtype == "s")
  7033. {
  7034. isDesign = true;
  7035. designFree = refudFree;
  7036. }
  7037. int userId = Convert.ToInt32(idstr);
  7038. int type = 0;
  7039. if (idtype == "g")
  7040. {
  7041. type = 1;
  7042. }
  7043. if (idtype == "w")
  7044. {
  7045. type = 2;
  7046. }
  7047. if (idtype == "t")
  7048. {
  7049. type = 3;
  7050. }
  7051. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7052. if (ceErpTradeResponsible == null)
  7053. {
  7054. ceErpTradeResponsible = new CeErpTradeResponsible();
  7055. ceErpTradeResponsible.tid = eid;
  7056. ceErpTradeResponsible.UserId = userId;
  7057. ceErpTradeResponsible.createdTime = DateTime.Now;
  7058. ceErpTradeResponsible.type = type;
  7059. if (type == 1)
  7060. {
  7061. ceErpTradeResponsible.IsSup = 1;
  7062. }
  7063. if (type == 2)
  7064. {
  7065. ceErpTradeResponsible.IsFlow = 1;
  7066. }
  7067. }
  7068. int state = 0;
  7069. //已认可的不需要再次认可
  7070. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7071. {
  7072. state = 1;
  7073. }
  7074. ceErpTradeResponsible.RefundFee = refudFree;
  7075. ceErpTradeResponsible.VerifyState = state;
  7076. if (userId == 2125 || idtype == "w")
  7077. {
  7078. ceErpTradeResponsible.VerifyState = 1;
  7079. }
  7080. if (idtype == "w" && userId == 101)
  7081. {
  7082. ceErpTradeResponsible.VerifyState = state;
  7083. }
  7084. if (ceErpTradeResponsible.ID > 0)
  7085. {
  7086. ceErpTradeResponsible.Update();
  7087. }
  7088. else
  7089. {
  7090. ceErpTradeResponsible.Create();
  7091. }
  7092. if (isDesign)
  7093. {
  7094. responsibleId = ceErpTradeResponsible.ID;
  7095. }
  7096. responsibleIds.Add(ceErpTradeResponsible.ID);
  7097. }
  7098. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7099. CeErpTradeResponsible.NumByTid(backNum, eid);
  7100. }
  7101. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7102. if (ceErpTradeCellExtend != null)
  7103. {
  7104. ceErpTradeCellExtend.returnVisit = 0;
  7105. ceErpTradeCellExtend.Update();
  7106. }
  7107. if (entity.HandleTime != null)
  7108. {
  7109. if (entity.AfterSaleState == 1)
  7110. {
  7111. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7112. }
  7113. else
  7114. {
  7115. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7116. }
  7117. }
  7118. else
  7119. {
  7120. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7121. entity.HandleTime = DateTime.Now;
  7122. }
  7123. bool isCompale = false;
  7124. if (entity.AfterSaleState == 5)
  7125. {
  7126. isCompale = true;
  7127. entity.AfterSaleState = 3;
  7128. }
  7129. entity.AfterSaleSupplierState = 0;
  7130. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7131. {
  7132. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7133. }
  7134. string sImgs = GetPostString("img");
  7135. entity.AfterSaleSupplierImg = sImgs;
  7136. entity.supRefundType = GetPostString("supRefundType");
  7137. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7138. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7139. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7140. entity.AfterSaleMemoType = GetPostString("MemoType");
  7141. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7142. {
  7143. //entity.AfterSaleSupplierState = 2;
  7144. }
  7145. string df = GetPostString("DeductFee");
  7146. if (df == "")
  7147. {
  7148. df = "0";
  7149. }
  7150. string rf = GetPostString("RefundFee");
  7151. if (rf == "")
  7152. {
  7153. rf = "0";
  7154. }
  7155. string pm = GetPostString("AfterSalePayment");
  7156. if (pm == "")
  7157. {
  7158. pm = "0";
  7159. }
  7160. entity.AfterSalePayment = Convert.ToDouble(pm);
  7161. entity.DeductFee = Convert.ToDouble(df);
  7162. entity.RefundFee = Convert.ToDouble(rf);
  7163. entity.UpdateTime = DateTime.Now;
  7164. entity.Update();
  7165. string toState = GetPostString("ToState");
  7166. string original = GetPostString("isOriginal");
  7167. ApiVo apiVo = new ApiVo();
  7168. apiVo.orderNumber = entity.ctid;
  7169. apiVo.actionName = "afterDesign";
  7170. apiVo.orderRemarks = entity.AfterSaleMethod;
  7171. apiVo.reasonRemarks = entity.AfterSaleReason;
  7172. apiVo.isDesign = isDesign;
  7173. apiVo.designFree = designFree;
  7174. apiVo.responsibleId = responsibleId;
  7175. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7176. if (toState == "设计师")
  7177. {
  7178. apiVo.isOriginal = Convert.ToBoolean(original);
  7179. }
  7180. designHelper.API_WorkCore(apiVo);//afterDesign
  7181. CeErpMethod methodSql = new CeErpMethod();
  7182. methodSql.con = entity.AfterSaleMethod;
  7183. methodSql.addTime = DateTime.Now;
  7184. methodSql.Create();
  7185. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7186. CeErpMethod.ExecuteNonQuery(delsql);
  7187. if (isCompale)
  7188. {
  7189. aftersale_data_change(entity.ctid);
  7190. }
  7191. returnSuccessMsg("操作成功!");
  7192. return;
  7193. }
  7194. returnErrorMsg("找不到订单记录");
  7195. }
  7196. }
  7197. public void ins_erp_toresponsible()
  7198. {
  7199. if (UrlPostParmsCheck("ctid"))
  7200. {
  7201. string eid = GetPostString("ctid");
  7202. CeErpTradeCell entity = null;
  7203. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7204. if (entity != null)
  7205. {
  7206. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7207. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7208. {
  7209. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7210. return;
  7211. }
  7212. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7213. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7214. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7215. if (entity.AfterSalePreTime == null)
  7216. {
  7217. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7218. {
  7219. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7220. }
  7221. }
  7222. entity.AfterSalePreTime = DateTime.Now;
  7223. //预完成给售后主管审核客户问题直接完成
  7224. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7225. {
  7226. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7227. {
  7228. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7229. }
  7230. }
  7231. ceErpTradeAfterSaleExtend.Update();
  7232. entity.AfterSaleState = 2;
  7233. entity.UpdateTime = DateTime.Now;
  7234. entity.Update();
  7235. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7236. aftersale_data_change(entity.ctid);
  7237. returnSuccessMsg("操作成功!");
  7238. return;
  7239. }
  7240. returnErrorMsg("找不到订单记录");
  7241. }
  7242. }
  7243. public void cancel_erp_aftersaleanddelnew()
  7244. {
  7245. if (UrlPostParmsCheck("ctid"))
  7246. {
  7247. string eid = GetPostString("ctid");
  7248. CeErpTradeCell entity = null;
  7249. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7250. if (entity != null)
  7251. {
  7252. entity.AfterSaleState = 0;
  7253. entity.AfterSaleReason = "";
  7254. entity.AfterSaleMethod = "";
  7255. entity.AfterSaleMemo = "";
  7256. entity.AfterSaleResponsible = "";
  7257. entity.ResponsibleUserId = "";
  7258. entity.DeductFee = 0;
  7259. entity.RefundFee = 0;
  7260. entity.IsArbitrate = 0;
  7261. CeErpTradeResponsible.DelByTid(eid, -1);
  7262. entity.Update();
  7263. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7264. if (after != null)
  7265. {
  7266. if (after.OrderState < 5)
  7267. CeErpTradeCell.DelByCtid("S_" + eid);
  7268. }
  7269. returnSuccessMsg("操作成功!");
  7270. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7271. return;
  7272. }
  7273. returnErrorMsg("找不到订单记录");
  7274. }
  7275. }
  7276. public void get_erp_aftersale_pregather()
  7277. {
  7278. List<string> lw = new List<string>();
  7279. int st = GetInt("st");
  7280. string tid = GetPostString("ctid");
  7281. if (tid.Length > 0)
  7282. {
  7283. string select_tid = getTidByCtid(tid);
  7284. lw.Add(string.Format("tid='{0}'", select_tid));
  7285. }
  7286. string shopname = GetPostString("shopname");
  7287. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7288. string buyernick = GetPostString("buyer_nick");
  7289. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7290. string sellermemo = GetPostString("seller_memo");
  7291. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7292. string orderState = GetPostString("orderState");
  7293. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7294. string reason = GetPostString("reason");
  7295. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7296. string method = GetPostString("method");
  7297. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7298. string handler = GetPostString("handler");
  7299. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7300. string handledate1 = GetPostString("handledate1");
  7301. string handledate2 = GetPostString("handledate2");
  7302. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7303. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7304. string supplier = GetPostString("supplier");
  7305. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7306. string responsible = GetPostString("responsibleman");
  7307. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7308. string customer = GetPostString("customer");
  7309. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7310. string design = GetPostString("design");
  7311. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7312. string afterMemoType = GetPostString("aftermemotype");
  7313. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7314. string afterSaleMemo = GetPostString("afterSaleMemo");
  7315. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7316. string afterresult = GetPostString("afterresult");
  7317. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7318. string poscode = CurrentUser.UserPost.Post.Code;
  7319. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7320. {
  7321. string shopid = CurrentUser.User.pemShop;
  7322. lw.Add(string.Format("shopId in ({0})", shopid));
  7323. }
  7324. var mainwhere = string.Join(" and ", lw.ToArray());
  7325. string ro_json = "";
  7326. string type = GetPostString("gather_type");
  7327. int number = 0;
  7328. if (poscode == "AfterSale")
  7329. {
  7330. //处理中
  7331. if (type == "Handling")
  7332. {
  7333. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7334. DataTable dt = null;
  7335. try
  7336. {
  7337. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7338. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7339. }
  7340. catch (Exception e)
  7341. {
  7342. dt = new DataTable();
  7343. }
  7344. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7345. return;
  7346. }
  7347. if (type == "Wait")
  7348. {
  7349. //待处理
  7350. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7351. DataTable dt1 = null;
  7352. try
  7353. {
  7354. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7355. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7356. }
  7357. catch (Exception e)
  7358. {
  7359. dt1 = new DataTable();
  7360. }
  7361. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7362. return;
  7363. }
  7364. if (type == "back")
  7365. {
  7366. //打回
  7367. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7368. DataTable dt2 = null;
  7369. try
  7370. {
  7371. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7372. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7373. }
  7374. catch (Exception e)
  7375. {
  7376. dt2 = new DataTable();
  7377. }
  7378. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7379. return;
  7380. }
  7381. if (type == "preCompletion")
  7382. {
  7383. //预完成
  7384. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7385. DataTable dt3 = null;
  7386. try
  7387. {
  7388. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7389. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7390. }
  7391. catch (Exception e)
  7392. {
  7393. dt3 = new DataTable();
  7394. }
  7395. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7396. return;
  7397. }
  7398. if (type == "documentary")
  7399. {
  7400. //跟单中
  7401. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('重印-转设计师','重印-转下单员') " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7402. DataTable dt4 = null;
  7403. try
  7404. {
  7405. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7406. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7407. }
  7408. catch (Exception e)
  7409. {
  7410. dt4 = new DataTable();
  7411. }
  7412. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7413. return;
  7414. }
  7415. if (type == "reBack")
  7416. {
  7417. //被打回
  7418. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7419. DataTable dt1 = null;
  7420. try
  7421. {
  7422. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7423. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7424. }
  7425. catch (Exception e)
  7426. {
  7427. dt1 = new DataTable();
  7428. }
  7429. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7430. return;
  7431. }
  7432. }
  7433. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7434. {
  7435. if (type == "puBack")
  7436. {
  7437. //退回
  7438. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7439. DataTable dt = null;
  7440. try
  7441. {
  7442. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7443. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7444. }
  7445. catch (Exception e)
  7446. {
  7447. dt = new DataTable();
  7448. }
  7449. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7450. return;
  7451. }
  7452. if (type == "reBack")
  7453. {
  7454. //打回
  7455. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7456. DataTable dt1 = null;
  7457. try
  7458. {
  7459. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7460. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7461. }
  7462. catch (Exception e)
  7463. {
  7464. dt1 = new DataTable();
  7465. }
  7466. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7467. return;
  7468. }
  7469. if (type == "examEd")
  7470. {
  7471. //已审核
  7472. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7473. DataTable dt2 = null;
  7474. try
  7475. {
  7476. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7477. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7478. }
  7479. catch (Exception e)
  7480. {
  7481. dt2 = new DataTable();
  7482. }
  7483. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7484. return;
  7485. }
  7486. if (type == "waitExam")
  7487. {
  7488. //待审核
  7489. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7490. DataTable dt3 = null;
  7491. try
  7492. {
  7493. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7494. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7495. }
  7496. catch (Exception e)
  7497. {
  7498. dt3 = new DataTable();
  7499. }
  7500. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7501. return;
  7502. }
  7503. if (type == "Handling")
  7504. {
  7505. //处理中
  7506. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7507. DataTable dt4 = null;
  7508. try
  7509. {
  7510. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7511. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7512. }
  7513. catch (Exception e)
  7514. {
  7515. dt4 = new DataTable();
  7516. }
  7517. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7518. return;
  7519. }
  7520. if (type == "Wait")
  7521. {
  7522. //待处理
  7523. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7524. DataTable dt5 = null;
  7525. try
  7526. {
  7527. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7528. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7529. }
  7530. catch (Exception e)
  7531. {
  7532. dt5 = new DataTable();
  7533. }
  7534. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7535. return;
  7536. }
  7537. if (type == "documentary")
  7538. {
  7539. //跟单中
  7540. string sql6 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7541. DataTable dt6 = null;
  7542. try
  7543. {
  7544. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7545. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7546. }
  7547. catch (Exception e)
  7548. {
  7549. dt6 = new DataTable();
  7550. }
  7551. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7552. return;
  7553. }
  7554. }
  7555. returnSuccess(ro_json);
  7556. }
  7557. public void end_erp_aftersale()
  7558. {
  7559. if (UrlPostParmsCheck("ctid"))
  7560. {
  7561. string eid = GetPostString("ctid");
  7562. CeErpTradeCell entity = null;
  7563. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7564. if (entity != null)
  7565. {
  7566. string stype = GetPostString("stype");
  7567. string typeStr = stype;
  7568. entity.AfterSaleState = 4;
  7569. entity.FinishAfterSaleTime = DateTime.Now;
  7570. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7571. entity.Update();
  7572. ApiVo apiVo = new ApiVo();
  7573. apiVo.orderNumber = entity.ctid;
  7574. apiVo.actionName = "afterOver";
  7575. designHelper.API_WorkCore(apiVo); //afterOver
  7576. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7577. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7578. CeErpSukuraData.createInfo(entity.ctid, 8);
  7579. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7580. returnSuccessMsg("操作成功!");
  7581. return;
  7582. }
  7583. returnErrorMsg("找不到订单记录");
  7584. }
  7585. }
  7586. public void ins_erp_finishaftersale()
  7587. {
  7588. if (UrlPostParmsCheck("id"))
  7589. {
  7590. string eid = GetPostString("id");
  7591. CeErpTradeResponsible entity = null;
  7592. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7593. if (entity != null)
  7594. {
  7595. entity.VerifyState = 1;
  7596. entity.VerifyTime = DateTime.Now;
  7597. entity.Update();
  7598. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7599. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7600. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7601. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7602. if (dt.Rows.Count <= 0)
  7603. {
  7604. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7605. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7606. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7607. CeErpSukuraData.createInfo(entity.tid, 8);
  7608. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7609. {
  7610. CeErpDesignerBill.Del(entity.tid);
  7611. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7612. }
  7613. }
  7614. returnSuccessMsg("操作成功!");
  7615. return;
  7616. }
  7617. returnErrorMsg("找不到订单记录");
  7618. }
  7619. }
  7620. public void upd_erp_arbitrateaftersale()
  7621. {
  7622. if (UrlPostParmsCheck("id"))
  7623. {
  7624. string eid = GetPostString("id");
  7625. CeErpTradeResponsible entity = null;
  7626. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7627. if (entity != null)
  7628. {
  7629. entity.IsArbitrate = 1;
  7630. entity.ArbitradeMemo = GetPostString("reason");
  7631. entity.VerifyState = 2;
  7632. entity.Update();
  7633. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7634. if (tradecell != null)
  7635. {
  7636. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7637. tradecell.IsArbitrate = 1;
  7638. tradecell.Update();
  7639. }
  7640. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7641. returnSuccessMsg("操作成功!");
  7642. return;
  7643. }
  7644. returnErrorMsg("找不到订单记录");
  7645. }
  7646. }
  7647. public void upd_erp_backaftersale()
  7648. {
  7649. if (UrlPostParmsCheck("tid"))
  7650. {
  7651. string eid = GetPostString("tid");
  7652. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7653. int backNum = 0;
  7654. if (number != null)
  7655. {
  7656. backNum = number.BackNum;
  7657. }
  7658. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7659. CeErpTradeCell entity = null;
  7660. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7661. if (entity != null)
  7662. {
  7663. entity.AfterSaleBackReason = GetPostString("backreason");
  7664. entity.AfterSaleState = 1;
  7665. entity.AfterSaleSupplierState = 0;
  7666. entity.UpdateTime = DateTime.Now;
  7667. entity.Update();
  7668. returnSuccessMsg("操作成功!");
  7669. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7670. return;
  7671. }
  7672. returnErrorMsg("找不到订单记录");
  7673. }
  7674. }
  7675. public void get_erp_supplieraftersalelist()
  7676. {
  7677. DataStruct dStruct = GetPostStruct();
  7678. List<string> lw = new List<string>();
  7679. string tid = GetPostString("ctid");
  7680. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7681. string shopname = GetPostString("shopname");
  7682. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7683. string buyernick = GetPostString("buyer_nick");
  7684. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7685. string sellermemo = GetPostString("seller_memo");
  7686. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7687. string orderState = GetPostString("orderState");
  7688. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7689. string afterState = GetPostString("afterstate");
  7690. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7691. string date1 = GetPostString("date1");
  7692. string date2 = GetPostString("date2");
  7693. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7694. if (dw.Length > 0) lw.Add(dw);
  7695. string price1 = GetPostString("price1");
  7696. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7697. string price2 = GetPostString("price2");
  7698. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7699. string reason = GetPostString("reason");
  7700. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7701. string method = GetPostString("method");
  7702. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7703. string handledate1 = GetPostString("handledate1");
  7704. string handledate2 = GetPostString("handledate2");
  7705. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7706. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7707. string handler = GetPostString("handler");
  7708. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7709. string afterdate1 = GetPostString("afterdate1");
  7710. string afterdate2 = GetPostString("afterdate2");
  7711. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7712. if (afterDate.Length > 0) lw.Add(afterDate);
  7713. string customer = GetPostString("customer");
  7714. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7715. string design = GetPostString("design");
  7716. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7717. string afterMemoType = GetPostString("aftermemotype");
  7718. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7719. string vstate = GetPostString("vstate");
  7720. if (vstate.Length > 0)
  7721. {
  7722. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7723. }
  7724. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7725. string supplier = GetPostString("supplier");
  7726. int supid = commonHelper.getSupplierIDByName(supplier);
  7727. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7728. string posCode = CurrentUser.UserPost.Post.Code;
  7729. if (posCode == "Supplier")
  7730. {
  7731. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7732. }
  7733. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7734. {
  7735. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7736. }
  7737. else
  7738. {
  7739. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7740. }
  7741. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7742. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7743. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7744. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7745. writeGridDataTableJson(dStruct.TotalCount, dt);
  7746. }
  7747. public void upd_erp_supverifyaftersale()
  7748. {
  7749. if (UrlPostParmsCheck("id"))
  7750. {
  7751. string id = GetPostString("id");
  7752. int st = GetPostInt("afterstate");
  7753. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7754. CeErpTradeCell entity = null;
  7755. if (ceErpTradeResponsible != null)
  7756. {
  7757. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7758. }
  7759. string afmemo = GetPostString("supmemo");
  7760. string image = GetPostString("image");
  7761. if (entity != null)
  7762. {
  7763. entity.AfterSaleSupplierState = st;
  7764. entity.AfterSaleSupplierMemo = afmemo;
  7765. if (st == 1)
  7766. {
  7767. ceErpTradeResponsible.VerifyState = 1;
  7768. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7769. ceErpTradeResponsible.Update();
  7770. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7771. if (isAll)
  7772. {
  7773. entity.AfterSaleState = 4;
  7774. entity.FinishAfterSaleTime = DateTime.Now;
  7775. }
  7776. }
  7777. else
  7778. {
  7779. CeErpTradeResponsible.dateByTid(entity.ctid);
  7780. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7781. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7782. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7783. if (num <= 1)
  7784. {
  7785. entity.AfterSaleState = 1;
  7786. }
  7787. else
  7788. {
  7789. entity.AfterSaleState = 5;
  7790. }
  7791. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7792. if (ceErpTradeAfterSaleExtend != null)
  7793. {
  7794. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7795. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7796. ceErpTradeAfterSaleExtend.Update();
  7797. }
  7798. else
  7799. {
  7800. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7801. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7802. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7803. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7804. ceErpTradeAfterSaleExtend.Create();
  7805. }
  7806. }
  7807. if (entity.AfterSaleState == 4)
  7808. {
  7809. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7810. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7811. {
  7812. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7813. }
  7814. ApiVo apiVo = new ApiVo();
  7815. apiVo.orderNumber = entity.ctid;
  7816. apiVo.actionName = "afterOver";
  7817. designHelper.API_WorkCore(apiVo); //afterOver
  7818. }
  7819. entity.UpdateTime = DateTime.Now;
  7820. entity.Update();
  7821. returnSuccessMsg("操作成功!");
  7822. CeErpSukuraData.createInfo(entity.ctid, 8);
  7823. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7824. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7825. return;
  7826. }
  7827. returnErrorMsg("找不到订单记录");
  7828. }
  7829. }
  7830. public void upd_erp_masteraftersale()
  7831. {
  7832. if (UrlPostParmsCheck("id"))
  7833. {
  7834. string id = GetPostString("id");
  7835. int st = GetPostInt("afterstate");
  7836. string afmemo = GetPostString("supmemo");
  7837. string image = GetPostString("image");
  7838. string textResult = GetPostString("textResult");
  7839. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7840. if (ceErpTradeResponsible != null)
  7841. {
  7842. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7843. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7844. ceErpTradeResponsible.Update();
  7845. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7846. if (entity != null)
  7847. {
  7848. entity.AfterSaleSupplierState = st;
  7849. entity.AfterSaleSupplierMemo = afmemo;
  7850. if (st == 1)
  7851. {
  7852. }
  7853. else
  7854. {
  7855. CeErpTradeResponsible.dateByTid(entity.ctid);
  7856. //退回到售后
  7857. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7858. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7859. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7860. if (num <= 1)
  7861. {
  7862. entity.AfterSaleState = 1;
  7863. }
  7864. else
  7865. {
  7866. entity.AfterSaleState = 5;
  7867. }
  7868. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7869. if (ceErpTradeAfterSaleExtend != null)
  7870. {
  7871. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7872. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7873. ceErpTradeAfterSaleExtend.Update();
  7874. }
  7875. else
  7876. {
  7877. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7878. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7879. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7880. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7881. ceErpTradeAfterSaleExtend.Create();
  7882. }
  7883. }
  7884. entity.UpdateTime = DateTime.Now;
  7885. entity.Update();
  7886. returnSuccessMsg("操作成功!");
  7887. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7888. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7889. return;
  7890. }
  7891. }
  7892. returnErrorMsg("找不到订单记录");
  7893. }
  7894. }
  7895. public void upd_erp_personaftersale()
  7896. {
  7897. if (UrlPostParmsCheck("id"))
  7898. {
  7899. //林小连
  7900. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7901. {
  7902. upd_erp_masteraftersale();
  7903. return;
  7904. }
  7905. string id = GetPostString("id");
  7906. int st = GetPostInt("afterstate");
  7907. string afmemo = GetPostString("supmemo");
  7908. string image = GetPostString("image");
  7909. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7910. if (ceErpTradeResponsible != null)
  7911. {
  7912. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7913. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7914. ceErpTradeResponsible.Update();
  7915. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7916. if (entity != null)
  7917. {
  7918. entity.AfterSaleSupplierMemo = afmemo;
  7919. entity.AfterSaleSupplierState = st;
  7920. if (st == 1)
  7921. {
  7922. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7923. if (isAll)
  7924. {
  7925. entity.AfterSaleState = 4;
  7926. entity.FinishAfterSaleTime = DateTime.Now;
  7927. }
  7928. }
  7929. else
  7930. {
  7931. CeErpTradeResponsible.dateByTid(entity.ctid);
  7932. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7933. if (ceErpTradeAfterSaleExtend != null)
  7934. {
  7935. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7936. ceErpTradeAfterSaleExtend.Update();
  7937. }
  7938. else
  7939. {
  7940. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7941. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7942. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7943. ceErpTradeAfterSaleExtend.Create();
  7944. }
  7945. //退回到主管
  7946. //entity.AfterSaleState = 2;
  7947. }
  7948. if (entity.AfterSaleState == 4)
  7949. {
  7950. ApiVo apiVo = new ApiVo();
  7951. apiVo.orderNumber = entity.ctid;
  7952. apiVo.actionName = "afterOver";
  7953. designHelper.API_WorkCore(apiVo); //afterOver
  7954. }
  7955. entity.UpdateTime = DateTime.Now;
  7956. entity.Update();
  7957. returnSuccessMsg("操作成功!");
  7958. CeErpSukuraData.createInfo(entity.ctid, 8);
  7959. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7960. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7961. return;
  7962. }
  7963. }
  7964. returnErrorMsg("找不到订单记录");
  7965. }
  7966. }
  7967. public void set_erp_supplierrefundtag()
  7968. {
  7969. if (UrlPostParmsCheck("ctid"))
  7970. {
  7971. string eid = GetPostString("ctid");
  7972. CeErpTradeCell entity = null;
  7973. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7974. if (entity != null)
  7975. {
  7976. entity.IsSupplierRefund = GetPostInt("tag");
  7977. entity.Update();
  7978. returnSuccessMsg("操作成功!");
  7979. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7980. return;
  7981. }
  7982. returnErrorMsg("找不到订单记录");
  7983. }
  7984. }
  7985. public void get_erp_refundlist()
  7986. {
  7987. DataStruct dStruct = GetPostStruct();
  7988. List<string> lw = new List<string>();
  7989. string tid = GetPostString("tid");
  7990. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7991. //string rid = GetPostString("refund_id");
  7992. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7993. string shopname = GetPostString("shopname");
  7994. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7995. string buyernick = GetPostString("buyer_nick");
  7996. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7997. string customer = GetPostString("customer");
  7998. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7999. string design = GetPostString("design");
  8000. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8001. string sellermemo = GetPostString("seller_memo");
  8002. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8003. //string date1 = GetPostString("date1");
  8004. //string date2 = GetPostString("date2");
  8005. //string dateType = GetPostString("dateType");
  8006. //if (dateType.Length > 0)
  8007. //{
  8008. // if (dateType == "1001") dateType = "0";
  8009. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  8010. // if (searchDT.Count == 2)
  8011. // {
  8012. // date1 = searchDT[0].ToString();
  8013. // date2 = searchDT[1].ToString();
  8014. // }
  8015. //}
  8016. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8017. //if (dw.Length > 0) lw.Add(dw);
  8018. string redate1 = GetPostString("refunddate1");
  8019. string redate2 = GetPostString("refunddate2");
  8020. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8021. if (dwdate.Length > 0) lw.Add(dwdate);
  8022. string price1 = GetPostString("price1");
  8023. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8024. string price2 = GetPostString("price2");
  8025. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8026. string ispartrefund = GetPostString("ispartrefund");
  8027. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8028. string refundState = GetPostString("refundvstate");
  8029. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  8030. int st = GetInt("st");
  8031. if (st == 2) //待确认列表中,把state=3已确认的也显示
  8032. {
  8033. string responsible = GetPostString("responsibleman");
  8034. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8035. lw.Add(string.Format("RefundState>={0}", st));
  8036. string code = CurrentUser.UserPost.Post.Code;
  8037. if (code == "CustomerService")
  8038. {
  8039. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  8040. }
  8041. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  8042. {
  8043. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  8044. }
  8045. else if (code == "Place" || code == "PlaceMr")
  8046. {
  8047. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8048. }
  8049. dStruct.Order = "RefundState asc,created desc";
  8050. }
  8051. else if (st == 10)
  8052. {
  8053. string responsible = GetPostString("responsibleman");
  8054. if (responsible == "空白")
  8055. {
  8056. lw.Add(string.Format("ResponsibleUserName = ''"));
  8057. }
  8058. else if (responsible.Length > 0)
  8059. {
  8060. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8061. }
  8062. lw.Add(string.Format("RefundState>=0"));
  8063. dStruct.Order = "created desc";
  8064. }
  8065. else
  8066. {
  8067. string responsible = GetPostString("responsibleman");
  8068. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8069. lw.Add(string.Format("RefundState={0}", st));
  8070. dStruct.Order = "created desc";
  8071. }
  8072. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8073. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8074. dt.Columns.Add("refund_fees");
  8075. foreach (DataRow dr in dt.Rows)
  8076. {
  8077. String status = dr["status"].ToString();
  8078. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8079. {
  8080. dr["refund_fees"] = dr["refund_fee"];
  8081. }
  8082. else
  8083. {
  8084. dr["refund_fees"] = "0.0";
  8085. }
  8086. }
  8087. writeGridDataTableJson(dStruct.TotalCount, dt);
  8088. }
  8089. public void get_erp_refunddesignlist()
  8090. {
  8091. DataStruct dStruct = GetPostStruct();
  8092. List<string> lw = new List<string>();
  8093. string tid = GetPostString("tid");
  8094. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8095. string shopname = GetPostString("shopname");
  8096. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8097. string buyernick = GetPostString("buyer_nick");
  8098. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8099. string customer = GetPostString("customer");
  8100. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8101. string design = GetPostString("design");
  8102. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8103. string sellermemo = GetPostString("seller_memo");
  8104. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8105. string redate1 = GetPostString("refunddate1");
  8106. string redate2 = GetPostString("refunddate2");
  8107. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8108. if (dwdate.Length > 0) lw.Add(dwdate);
  8109. string price1 = GetPostString("price1");
  8110. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8111. string price2 = GetPostString("price2");
  8112. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8113. string ispartrefund = GetPostString("ispartrefund");
  8114. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8115. string designerorg = GetPostString("designerorg");
  8116. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8117. string refundState = GetPostString("refundState");
  8118. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8119. int myOrgid = CurrentUser.UserPost.OrgID;
  8120. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8121. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8122. {
  8123. if (CurrentUser.User.TeamIds.Length > 0)
  8124. {
  8125. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8126. }
  8127. else
  8128. {
  8129. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8130. }
  8131. }
  8132. else if ("SysAdmin".Equals(myOrgCode))
  8133. {
  8134. }
  8135. else
  8136. {
  8137. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8138. {
  8139. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8140. }
  8141. else
  8142. {
  8143. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8144. }
  8145. }
  8146. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8147. dStruct.Order = "created desc";
  8148. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8149. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8150. dt.Columns.Add("refund_fees");
  8151. foreach (DataRow dr in dt.Rows)
  8152. {
  8153. String status = dr["status"].ToString();
  8154. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8155. {
  8156. dr["refund_fees"] = dr["refund_fee"];
  8157. }
  8158. else
  8159. {
  8160. dr["refund_fees"] = "0.0";
  8161. }
  8162. }
  8163. writeGridDataTableJson(dStruct.TotalCount, dt);
  8164. }
  8165. public void handle_erp_refundtag()
  8166. {
  8167. if (UrlPostParmsCheck("refund_id"))
  8168. {
  8169. string eid = GetPostString("refund_id");
  8170. string respMan = GetPostString("ResponsibleName");
  8171. if (respMan.Length <= 0)
  8172. {
  8173. returnErrorMsg("责任人不能为空");
  8174. return;
  8175. }
  8176. CeErpTradeRefund entity = null;
  8177. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8178. if (entity != null)
  8179. {
  8180. entity.ResponsibleUserName = respMan;
  8181. string userid = GetPostString("ResponsibleUserId");
  8182. if (userid.Length > 0)
  8183. {
  8184. entity.ResponsibleUserId = userid;
  8185. }
  8186. entity.Memo = GetPostString("Memo");
  8187. if (respMan.IndexOf("客服") != -1 ||
  8188. respMan.IndexOf("设计师") != -1 ||
  8189. respMan.IndexOf("下单员") != -1)
  8190. {
  8191. entity.RefundState = 2;
  8192. }
  8193. else
  8194. {
  8195. entity.RefundState = 3;
  8196. }
  8197. entity.modified = DateTime.Now;
  8198. entity.Update();
  8199. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8200. returnSuccessMsg("操作成功!");
  8201. return;
  8202. }
  8203. returnErrorMsg("找不到订单记录");
  8204. }
  8205. }
  8206. public void handle_erp_designrefundtag()
  8207. {
  8208. if (UrlPostParmsCheck("refund_id"))
  8209. {
  8210. string eid = GetPostString("refund_id");
  8211. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8212. if (ceErpTradeCellExtend == null)
  8213. {
  8214. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8215. ceErpTradeCellExtend.ctid = eid;
  8216. }
  8217. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8218. if (ceErpTradeCellExtend.ID > 0)
  8219. {
  8220. ceErpTradeCellExtend.Update();
  8221. }
  8222. else
  8223. {
  8224. ceErpTradeCellExtend.Create();
  8225. }
  8226. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8227. returnSuccessMsg("操作成功!");
  8228. return;
  8229. }
  8230. returnErrorMsg("找不到订单记录");
  8231. }
  8232. public void upd_erp_refundverify()
  8233. {
  8234. if (UrlPostParmsCheck("refund_id"))
  8235. {
  8236. string eid = GetPostString("refund_id");
  8237. CeErpTradeRefund entity = null;
  8238. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8239. if (entity != null)
  8240. {
  8241. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8242. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8243. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8244. {
  8245. entity.RefundState = 2;
  8246. }
  8247. else
  8248. {
  8249. entity.RefundState = 3;
  8250. }
  8251. entity.Update();
  8252. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8253. returnSuccessMsg("操作成功!");
  8254. return;
  8255. }
  8256. returnErrorMsg("找不到订单记录");
  8257. }
  8258. }
  8259. public void upd_erp_refundapprove()
  8260. {
  8261. if (UrlPostParmsCheck("refund_id"))
  8262. {
  8263. string eid = GetPostString("refund_id");
  8264. CeErpTradeRefund entity = null;
  8265. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8266. if (entity != null)
  8267. {
  8268. int apr = GetPostInt("approve");
  8269. if (apr == 0)
  8270. {
  8271. entity.RefundState = 1;
  8272. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8273. }
  8274. else if (apr == 1)
  8275. {
  8276. entity.RefundState = 3;
  8277. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8278. }
  8279. entity.modified = DateTime.Now;
  8280. entity.Update();
  8281. returnSuccessMsg("操作成功!");
  8282. return;
  8283. }
  8284. returnErrorMsg("找不到订单记录");
  8285. }
  8286. }
  8287. public void get_erp_billlist()
  8288. {
  8289. DataStruct dStruct = GetPostStruct();
  8290. List<string> lw = new List<string>();
  8291. string title = GetPostString("title");
  8292. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8293. string tid = GetPostString("tid");
  8294. string tids = GetPostString("tids");
  8295. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8296. if (tids.Length > 0)
  8297. {
  8298. tids = "'" + tids + "'";
  8299. tids = tids.Replace(",", "','");
  8300. lw.Add(string.Format("tid in ({0})", tids));
  8301. }
  8302. string shopname = GetPostString("shopname");
  8303. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8304. string buyernick = GetPostString("buyer_nick");
  8305. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8306. string customer = GetPostString("customer");
  8307. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8308. string date1 = GetPostString("date1");
  8309. string date2 = GetPostString("date2");
  8310. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8311. if (dw.Length > 0) lw.Add(dw);
  8312. string price1 = GetPostString("price1");
  8313. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8314. string price2 = GetPostString("price2");
  8315. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8316. string returndate1 = GetPostString("returndate1");
  8317. string returndate2 = GetPostString("returndate2");
  8318. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8319. if (dw1.Length > 0) lw.Add(dw1);
  8320. string billtype = GetPostString("billtype");
  8321. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8322. string billstate = GetPostString("billstate");
  8323. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8324. string usershop = CurrentUser.User.pemShop;
  8325. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8326. dStruct.Order = "createTime desc";
  8327. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8328. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8329. //foreach (DataRow dr in dt.Rows)
  8330. //{
  8331. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8332. //}
  8333. writeGridDataTableJson(dStruct.TotalCount, dt);
  8334. }
  8335. public void modify_erp_billinfo()
  8336. {
  8337. if (UrlPostParmsCheck("ID"))
  8338. {
  8339. string eid = GetPostString("ID");
  8340. CeErpBill bill_entity = null;
  8341. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8342. if (bill_entity != null)
  8343. {
  8344. bill_entity.tid = GetPostString("tid");
  8345. bill_entity.title = GetPostString("title");
  8346. bill_entity.tax = GetPostString("tax");
  8347. bill_entity.bank = GetPostString("bank");
  8348. bill_entity.bankac = GetPostString("bankac");
  8349. bill_entity.address = GetPostString("address");
  8350. bill_entity.phone = GetPostString("phone");
  8351. bill_entity.price = GetPostString("price");
  8352. bill_entity.productId = GetPostInt("ProductName");
  8353. bill_entity.num = GetPostInt("num");
  8354. bill_entity.unit = GetPostString("unit");
  8355. bill_entity.type = GetPostString("type");
  8356. bill_entity.sendType = GetPostString("SendType");
  8357. bill_entity.email = GetPostString("email");
  8358. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8359. bill_entity.shopName = GetPostString("ShopName");
  8360. bill_entity.applymemo = GetPostString("applymemo");
  8361. bill_entity.modifyTime = DateTime.Now;
  8362. bill_entity.createTime = DateTime.Now;
  8363. bill_entity.state = 0;
  8364. bill_entity.Update();
  8365. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8366. returnSuccessMsg("发票修改成功!");
  8367. return;
  8368. }
  8369. returnErrorMsg("找不到对应记录");
  8370. }
  8371. }
  8372. public void set_erp_invoicing()
  8373. {
  8374. if (UrlPostParmsCheck("id"))
  8375. {
  8376. try
  8377. {
  8378. string eid = GetPostString("id");
  8379. CeErpBill bill_entity = null;
  8380. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8381. if (bill_entity != null)
  8382. {
  8383. int ComId = GetPostInt("ComId");
  8384. //string memo = GetPostString("Memo");
  8385. int allInfo = GetPostInt("allinfo");
  8386. string clert = CurrentUser.User.Name;
  8387. //string detailValue = GetPostString("detailvalue");
  8388. string billId = bill_entity.billOrderId;
  8389. string[] billIdList = billId.Split(',');
  8390. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8391. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8392. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8393. {
  8394. billCount += 1;
  8395. }
  8396. if (billId.Length <= 0 || billIdList.Length != billCount)
  8397. {
  8398. bill_entity.billOrderId = "";
  8399. string prebill = "ltb";
  8400. for (int idx = 1; idx <= billCount; idx++)
  8401. {
  8402. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8403. string billoid = prebill + idx + dtstr;
  8404. bill_entity.billOrderId += billoid;
  8405. if (idx < billCount)
  8406. {
  8407. bill_entity.billOrderId += ",";
  8408. }
  8409. }
  8410. }
  8411. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8412. if (bill_entity.state == 5)
  8413. {
  8414. string errMsg = bill_entity.failerror;
  8415. string[] errlist = errMsg.Split('|');
  8416. string[] errTags = new string[errlist.Length];
  8417. for (int itag = 0; itag < errlist.Length; itag++)
  8418. {
  8419. if (errlist[itag].Length <= 0) continue;
  8420. errTags[itag] = errlist[itag].Split('&')[0];
  8421. }
  8422. for (int iii = 0; iii < errTags.Length; iii++)
  8423. {
  8424. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8425. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8426. if (billOrderList.Length >= erroBillOrderTag)
  8427. {
  8428. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8429. if (needModifyBillId.Length <= 19)
  8430. {
  8431. needModifyBillId = needModifyBillId + "1";
  8432. }
  8433. else
  8434. {
  8435. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8436. last = last + 1;
  8437. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8438. }
  8439. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8440. }
  8441. }
  8442. }
  8443. bool isHaveBillSucces = false;
  8444. string totalRes = "";
  8445. bill_entity.failerror = "";
  8446. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8447. {
  8448. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8449. totalRes += res;
  8450. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8451. {
  8452. isHaveBillSucces = true;
  8453. bill_entity.comId = ComId;
  8454. bill_entity.state = 1;
  8455. bill_entity.executeTime = DateTime.Now;
  8456. bill_entity.executeUser = clert;
  8457. }
  8458. else
  8459. {
  8460. bill_entity.state = 5;
  8461. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8462. }
  8463. }
  8464. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8465. bill_entity.Update();
  8466. if (isHaveBillSucces)
  8467. {
  8468. StringBuilder sql = new StringBuilder();
  8469. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8470. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8471. }
  8472. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8473. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8474. {
  8475. returnErrorMsg("开票失败");
  8476. }
  8477. else
  8478. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8479. return;
  8480. }
  8481. returnErrorMsg("找不到对应记录");
  8482. }
  8483. catch (Exception ex)
  8484. {
  8485. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8486. returnErrorMsg("操作失败");
  8487. }
  8488. }
  8489. }
  8490. public void get_erp_invoicing_back()
  8491. {
  8492. if (UrlPostParmsCheck("id"))
  8493. {
  8494. try
  8495. {
  8496. string id = GetPostString("id");
  8497. CeErpBill entiy = CeErpBill.Get(id);
  8498. if (entiy != null)
  8499. {
  8500. if (entiy.state == 0)
  8501. {
  8502. returnErrorMsg("发票还未开具");
  8503. return;
  8504. }
  8505. string[] billOrderList = entiy.billOrderId.Split(',');
  8506. int iTag = 0;
  8507. entiy.fplsh = "";
  8508. entiy.fpdm = "";
  8509. entiy.fphm = "";
  8510. foreach (string billOrderId in billOrderList)
  8511. {
  8512. iTag++;
  8513. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8514. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8515. {
  8516. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8517. try
  8518. {
  8519. Invoicing_get_response_Obj iObj = null;
  8520. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8521. if (iObj != null)
  8522. {
  8523. entiy.state = 2;
  8524. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8525. entiy.fpdm += iObj.list[0].c_fpdm;
  8526. entiy.fphm += iObj.list[0].c_fphm;
  8527. if (iTag < billOrderList.Length)
  8528. {
  8529. entiy.fplsh += ",";
  8530. entiy.fpdm += ",";
  8531. entiy.fphm += ",";
  8532. }
  8533. entiy.Update();
  8534. }
  8535. StringBuilder sql = new StringBuilder();
  8536. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8537. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8538. returnSuccessMsg("开票成功");
  8539. }
  8540. catch (Exception ex)
  8541. {
  8542. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8543. }
  8544. return;
  8545. }
  8546. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8547. {
  8548. var res_obj = new
  8549. {
  8550. data = "开票中"
  8551. };
  8552. string ro_json = JsonConvert.SerializeObject(res_obj);
  8553. returnSuccess(ro_json);
  8554. return;
  8555. }
  8556. else
  8557. {
  8558. int eidx = res.IndexOf("c_resultmsg");
  8559. int lidx = res.IndexOf("c_status");
  8560. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8561. entiy.state = 5;
  8562. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8563. entiy.Update();
  8564. returnErrorMsg("开票失败");
  8565. return;
  8566. }
  8567. }
  8568. }
  8569. }
  8570. catch (Exception ex)
  8571. {
  8572. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8573. }
  8574. return;
  8575. }
  8576. }
  8577. public void get_erp_invoicing()
  8578. {
  8579. if (UrlPostParmsCheck("id"))
  8580. {
  8581. try
  8582. {
  8583. string id = GetPostString("id");
  8584. CeErpBill entiy = CeErpBill.Get(id);
  8585. if (entiy != null)
  8586. {
  8587. if (entiy.state == 0)
  8588. {
  8589. returnErrorMsg("发票还未开具");
  8590. return;
  8591. }
  8592. if (entiy.sendType == "纸质发票")
  8593. {
  8594. if (entiy.img.Length <= 0)
  8595. {
  8596. returnErrorMsg("查无纸质发票");
  8597. return;
  8598. }
  8599. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8600. returnSuccess(returnres);
  8601. return;
  8602. }
  8603. string[] billOrderList = entiy.billOrderId.Split(',');
  8604. int iTag = 0;
  8605. string fpUrl = "";
  8606. entiy.fplsh = "";
  8607. entiy.fpdm = "";
  8608. entiy.fphm = "";
  8609. foreach (string billOrderId in billOrderList)
  8610. {
  8611. iTag++;
  8612. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8613. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8614. {
  8615. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8616. Invoicing_get_response_Obj iObj = null;
  8617. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8618. if (iObj != null)
  8619. {
  8620. //entiy.state = 2;
  8621. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8622. entiy.fpdm += iObj.list[0].c_fpdm;
  8623. entiy.fphm += iObj.list[0].c_fphm;
  8624. if (iTag < billOrderList.Length)
  8625. {
  8626. entiy.fplsh += ",";
  8627. entiy.fpdm += ",";
  8628. entiy.fphm += ",";
  8629. }
  8630. entiy.Update();
  8631. fpUrl += iObj.list[0].c_url + ",";
  8632. }
  8633. //returnSuccess(res);
  8634. StringBuilder sql = new StringBuilder();
  8635. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8636. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8637. }
  8638. else
  8639. {
  8640. int eidx = res.IndexOf("c_resultmsg");
  8641. //int lidx = res.IndexOf("c_status");
  8642. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8643. //开票失败
  8644. entiy.state = 5;
  8645. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8646. entiy.Update();
  8647. returnErrorMsg("开票失败");
  8648. return;
  8649. }
  8650. }
  8651. var returnObj = new
  8652. {
  8653. data = fpUrl
  8654. };
  8655. string ro_json = JsonConvert.SerializeObject(returnObj);
  8656. returnSuccess(ro_json);
  8657. }
  8658. }
  8659. catch (Exception ex)
  8660. {
  8661. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8662. }
  8663. return;
  8664. }
  8665. }
  8666. public void save_erp_billimg()
  8667. {
  8668. if (UrlPostParmsCheck("id"))
  8669. {
  8670. string eid = GetPostString("id");
  8671. CeErpBill bill_entity = null;
  8672. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8673. if (bill_entity != null)
  8674. {
  8675. bill_entity.img = GetPostString("img");
  8676. bill_entity.executeTime = DateTime.Now;
  8677. bill_entity.state = 2;
  8678. bill_entity.Update();
  8679. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8680. returnSuccessMsg("保存成功");
  8681. }
  8682. return;
  8683. }
  8684. }
  8685. public void upd_erp_billreturnback()
  8686. {
  8687. if (UrlPostParmsCheck("id"))
  8688. {
  8689. int eid = GetPostInt("id");
  8690. CeErpBill bill_entity = null;
  8691. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8692. if (bill_entity != null)
  8693. {
  8694. bill_entity.state = 3;
  8695. bill_entity.returnReason = GetPostString("reason");
  8696. bill_entity.Update();
  8697. returnSuccessMsg("驳回成功!");
  8698. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8699. }
  8700. return;
  8701. }
  8702. }
  8703. public void cancel_erp_bill()
  8704. {
  8705. if (UrlPostParmsCheck("id"))
  8706. {
  8707. int eid = GetPostInt("id");
  8708. int detailValue = GetPostInt("detailvalue");
  8709. CeErpBill bill_entity = null;
  8710. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8711. string cres = "";
  8712. string gres = "";
  8713. if (bill_entity != null)
  8714. {
  8715. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8716. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8717. {
  8718. int iTag = 0;
  8719. bill_entity.fplsh = "";
  8720. bill_entity.fpdm = "";
  8721. bill_entity.fphm = "";
  8722. foreach (string billOrderId in billOrderList)
  8723. {
  8724. iTag++;
  8725. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8726. if (gres.IndexOf("success") != -1)
  8727. {
  8728. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8729. Invoicing_get_response_Obj iObj = null;
  8730. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8731. if (iObj != null)
  8732. {
  8733. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8734. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8735. bill_entity.fphm += iObj.list[0].c_fphm;
  8736. if (iTag < billOrderList.Length)
  8737. {
  8738. bill_entity.fplsh += ",";
  8739. bill_entity.fpdm += ",";
  8740. bill_entity.fphm += ",";
  8741. }
  8742. bill_entity.Update();
  8743. }
  8744. }
  8745. else
  8746. {
  8747. returnErrorMsg(gres);
  8748. return;
  8749. }
  8750. }
  8751. }
  8752. if (bill_entity.sendType == "纸质发票")
  8753. {
  8754. //作废
  8755. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8756. //if (DateTime.Now.Month == extime.Month)
  8757. //{
  8758. //cres = taobaoHelper.cancel_invoicing(eid);
  8759. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8760. //{
  8761. bill_entity.state = 4;//已作废
  8762. bill_entity.Update();
  8763. returnSuccessMsg("发票已作废");
  8764. return;
  8765. //}
  8766. //else
  8767. //{
  8768. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8769. // bill_entity.Update();
  8770. // returnErrorMsg(cres);
  8771. // return;
  8772. //}
  8773. //}
  8774. //else
  8775. //{
  8776. // returnErrorMsg("纸质发票只能作废本月的发票");
  8777. // return;
  8778. //}
  8779. }
  8780. //红冲
  8781. int redTag = 0;
  8782. string[] fpdmList = bill_entity.fpdm.Split(',');
  8783. string[] fphmList = bill_entity.fphm.Split(',');
  8784. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8785. {
  8786. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8787. return;
  8788. }
  8789. foreach (string billOrderId in billOrderList)
  8790. {
  8791. redTag++;
  8792. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8793. cres += onecres;
  8794. cres += ",";
  8795. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8796. {
  8797. bill_entity.state = 4;//已作废
  8798. //bill_entity.Update();
  8799. //returnSuccessMsg("发票已红冲");
  8800. }
  8801. else if (onecres.IndexOf("重复冲红") != -1)
  8802. {
  8803. bill_entity.state = 4;//已作废
  8804. //bill_entity.Update();
  8805. //returnSuccessMsg("发票已红冲");
  8806. }
  8807. else
  8808. {
  8809. string errmsg = commonHelper.KeepChinese(onecres);
  8810. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8811. }
  8812. }
  8813. bill_entity.Update();
  8814. if (cres.IndexOf("失败") != -1)
  8815. returnErrorMsg("红冲失败");
  8816. else
  8817. returnSuccessMsg("发票已红冲");
  8818. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8819. return;
  8820. }
  8821. return;
  8822. }
  8823. }
  8824. public void del_erp_billorder()
  8825. {
  8826. if (UrlPostParmsCheck("id"))
  8827. {
  8828. string eid = GetPostString("id");
  8829. CeErpBill.Del(eid);
  8830. CeErpBill bill = CeErpBill.Get(eid);
  8831. if (bill != null)
  8832. {
  8833. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8834. }
  8835. returnSuccessMsg("删除成功");
  8836. }
  8837. }
  8838. public void finish_erp_bill()
  8839. {
  8840. if (UrlPostParmsCheck("ids"))
  8841. {
  8842. string eids = GetPostString("ids");
  8843. string[] list = eids.Split(',');
  8844. foreach (string eid in list)
  8845. {
  8846. CeErpBill bill = CeErpBill.Get(eid);
  8847. if (bill != null)
  8848. {
  8849. bill.state = 2;
  8850. bill.Update();
  8851. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8852. }
  8853. }
  8854. returnSuccessMsg("操作成功");
  8855. }
  8856. }
  8857. public void get_erp_returncash()
  8858. {
  8859. DataStruct dStruct = GetPostStruct();
  8860. List<string> lw = new List<string>();
  8861. string tid = GetPostString("tid");
  8862. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8863. string shopname = GetPostString("shopname");
  8864. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8865. string buyernick = GetPostString("buyer_nick");
  8866. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8867. string customer = GetPostString("customer");
  8868. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8869. string returndate1 = GetPostString("returndate1");
  8870. string returndate2 = GetPostString("returndate2");
  8871. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8872. if (dw.Length > 0) lw.Add(dw);
  8873. string finishDate1 = GetPostString("finishdate1");
  8874. string finishDate2 = GetPostString("finishdate2");
  8875. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8876. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8877. string returntype = GetPostString("returntype");
  8878. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8879. string returnvstate = GetPostString("returnvstate");
  8880. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8881. dStruct.Order = "created desc";
  8882. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8883. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8884. writeGridDataTableJson(dStruct.TotalCount, dt);
  8885. }
  8886. public void get_erp_staygoods()
  8887. {
  8888. DataStruct dStruct = GetPostStruct();
  8889. List<string> lw = new List<string>();
  8890. string tid = GetPostString("tid");
  8891. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8892. string shopname = GetPostString("shopname");
  8893. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8894. string wangwang = GetPostString("wangwang");
  8895. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8896. string customer = GetPostString("customer");
  8897. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8898. string returndate1 = GetPostString("returndate1");
  8899. string returndate2 = GetPostString("returndate2");
  8900. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8901. if (dw.Length > 0) lw.Add(dw);
  8902. string finishDate1 = GetPostString("finishdate1");
  8903. string finishDate2 = GetPostString("finishdate2");
  8904. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8905. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8906. string returnvstate = GetPostString("returnvstate");
  8907. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8908. string persuadetype = GetPostString("persuadetype");
  8909. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8910. string customerOrg = GetPostString("customerOrg");
  8911. if (customerOrg.Length > 0)
  8912. {
  8913. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8914. }
  8915. string designerorg = GetPostString("designerorg");
  8916. if (designerorg.Length > 0)
  8917. {
  8918. lw.Add(string.Format("OrgID = {0}", designerorg));
  8919. }
  8920. dStruct.Order = "creata_time desc";
  8921. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8922. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8923. writeGridDataTableJson(dStruct.TotalCount, dt);
  8924. }
  8925. public void upd_erp_staygoods()
  8926. {
  8927. if (UrlPostParmsCheck("id"))
  8928. {
  8929. int eid = GetPostInt("id");
  8930. CeErpStayGoods entity = null;
  8931. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8932. if (entity != null)
  8933. {
  8934. entity.audit_type = 1;
  8935. entity.audit_time = DateTime.Now;
  8936. entity.audit_u_id = CurrentUser.UserID;
  8937. entity.audit_u_name = CurrentUser.UserName;
  8938. entity.Update();
  8939. returnSuccessMsg("审核成功!");
  8940. return;
  8941. }
  8942. returnErrorMsg("找不到订单记录");
  8943. }
  8944. }
  8945. public void upd_erp_stayGoodsback()
  8946. {
  8947. if (UrlPostParmsCheck("id"))
  8948. {
  8949. int eid = GetPostInt("id");
  8950. CeErpStayGoods entity = null;
  8951. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8952. if (entity != null)
  8953. {
  8954. entity.audit_text = GetPostString("reason");
  8955. entity.audit_type = 2;
  8956. entity.audit_time = DateTime.Now;
  8957. entity.audit_u_id = CurrentUser.UserID;
  8958. entity.audit_u_name = CurrentUser.UserName;
  8959. entity.Update();
  8960. returnSuccessMsg("退回成功!");
  8961. return;
  8962. }
  8963. returnErrorMsg("找不到订单记录");
  8964. }
  8965. }
  8966. public void upd_erp_returncashverify()
  8967. {
  8968. if (UrlPostParmsCheck("ID"))
  8969. {
  8970. int eid = GetPostInt("ID");
  8971. CeErpReturnCash entity = null;
  8972. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8973. if (entity != null)
  8974. {
  8975. entity.cashstate = 1;
  8976. entity.verifytime = DateTime.Now;
  8977. entity.verifyuserid = CurrentUser.UserID;
  8978. entity.Update();
  8979. returnSuccessMsg("审核成功!");
  8980. return;
  8981. }
  8982. returnErrorMsg("找不到订单记录");
  8983. }
  8984. }
  8985. public void upd_all_erp_returncashverify()
  8986. {
  8987. if (UrlPostParmsCheck("ID"))
  8988. {
  8989. String[] list = GetPostString("ID").Split(',');
  8990. CeErpReturnCash entity = null;
  8991. for (int i = 0; i < list.Length; i++)
  8992. {
  8993. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8994. if (entity != null)
  8995. {
  8996. if (entity.cashstate == 1)
  8997. {
  8998. returnErrorMsg("已审核过的订单不需要在审核!");
  8999. return;
  9000. }
  9001. entity.cashstate = 1;
  9002. entity.verifytime = DateTime.Now;
  9003. entity.verifyuserid = CurrentUser.UserID;
  9004. entity.Update();
  9005. }
  9006. }
  9007. returnSuccessMsg("审核成功!");
  9008. return;
  9009. }
  9010. }
  9011. public void upd_erp_returncashback()
  9012. {
  9013. if (UrlPostParmsCheck("ID"))
  9014. {
  9015. int eid = GetPostInt("ID");
  9016. CeErpReturnCash entity = null;
  9017. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9018. if (entity != null)
  9019. {
  9020. entity.backreason = GetPostString("reason");
  9021. entity.cashstate = 2;
  9022. entity.verifytime = DateTime.Now;
  9023. entity.verifyuserid = CurrentUser.UserID;
  9024. entity.Update();
  9025. returnSuccessMsg("退回成功!");
  9026. return;
  9027. }
  9028. returnErrorMsg("找不到订单记录");
  9029. }
  9030. }
  9031. public void upd_erp_returnprice()
  9032. {
  9033. if (UrlPostParmsCheck("ID"))
  9034. {
  9035. int eid = GetPostInt("ID");
  9036. CeErpReturnCash entity = null;
  9037. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9038. if (entity != null)
  9039. {
  9040. if (entity.cashstate == 1)
  9041. {
  9042. returnErrorMsg("审核通过了不能改");
  9043. return;
  9044. }
  9045. entity.returnprice = GetPostDouble("returnprice");
  9046. entity.Update();
  9047. returnSuccessMsg("修改成功!");
  9048. return;
  9049. }
  9050. returnErrorMsg("找不到订单记录");
  9051. }
  9052. }
  9053. public void del_erp_returncash()
  9054. {
  9055. if (UrlPostParmsCheck("ID"))
  9056. {
  9057. int eid = GetPostInt("ID");
  9058. CeErpReturnCash.Del(eid);
  9059. returnSuccessMsg("操作成功");
  9060. return;
  9061. }
  9062. }
  9063. public void test_for_do_sql()
  9064. {
  9065. string sql = GetPostString("sqlstr");
  9066. if (sql.Length > 0)
  9067. {
  9068. try
  9069. {
  9070. DbHelper.DbConn.ExecuteNonQuery(sql);
  9071. var res_obj = new
  9072. {
  9073. data = "成功",
  9074. };
  9075. string ro_json = JsonConvert.SerializeObject(res_obj);
  9076. returnSuccess(ro_json);
  9077. }
  9078. catch (Exception ex)
  9079. {
  9080. var res_obj = new
  9081. {
  9082. data = ex.Message,
  9083. };
  9084. string ro_json = JsonConvert.SerializeObject(res_obj);
  9085. returnSuccess(ro_json);
  9086. }
  9087. }
  9088. }
  9089. public void get_user_info()
  9090. {
  9091. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9092. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9093. }
  9094. public void get_total_data()
  9095. {
  9096. int userId = CurrentUser.UserID;
  9097. string sql = "";
  9098. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9099. {
  9100. 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);
  9101. }
  9102. else
  9103. {
  9104. 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 " +
  9105. "(select ID from CE_ErpUser where ID = {0}) d " +
  9106. "left join " +
  9107. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9108. ") a on d.ID = a.id left join " +
  9109. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9110. ") b on a.id = b.id1 left join" +
  9111. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9112. ") c on a.id = c.id2;", userId);
  9113. }
  9114. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9115. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9116. }
  9117. public void get_date_area_total_data2()
  9118. {
  9119. int userId = CurrentUser.UserID;
  9120. string date_type = GetPostString("timetype");
  9121. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9122. string sql = "";
  9123. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9124. {
  9125. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9126. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9127. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9128. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9129. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9130. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9131. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9132. ") a on e.ID = a.id left join " +
  9133. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9134. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9135. ") b on a.id = b.id1 " +
  9136. "left join " +
  9137. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9138. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9139. ") c on a.id = c.id2 " +
  9140. "left join " +
  9141. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9142. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9143. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9144. }
  9145. else
  9146. {
  9147. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9148. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9149. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9150. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9151. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9152. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9153. ") a on e.ID = a.id left join " +
  9154. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9155. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9156. ") c on a.id = c.id2 " +
  9157. "left join " +
  9158. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9159. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9160. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9161. }
  9162. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9163. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9164. }
  9165. public void get_date_area_total_data()
  9166. {
  9167. int userId = CurrentUser.UserID;
  9168. string date_type = GetPostString("timetype");
  9169. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9170. string date1 = searchDT[0].ToString();
  9171. string date2 = searchDT[1].ToString();
  9172. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9173. {
  9174. SqlParameter[] sqlParameter ={
  9175. new SqlParameter("@userId", SqlDbType.Int,4),
  9176. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9177. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9178. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9179. };
  9180. sqlParameter[0].Value = userId;
  9181. sqlParameter[1].Value = date1;
  9182. sqlParameter[2].Value = date2;
  9183. sqlParameter[3].Direction = ParameterDirection.Output;
  9184. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9185. string res = sqlParameter[3].Value.ToString();
  9186. var res_obj = new
  9187. {
  9188. data = res
  9189. };
  9190. string ro_json = JsonConvert.SerializeObject(res_obj);
  9191. returnSuccess(ro_json);
  9192. }
  9193. else
  9194. {
  9195. SqlParameter[] sqlParameter ={
  9196. new SqlParameter("@userId", SqlDbType.Int,4),
  9197. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9198. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9199. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9200. };
  9201. sqlParameter[0].Value = userId;
  9202. sqlParameter[1].Value = date1;
  9203. sqlParameter[2].Value = date2;
  9204. sqlParameter[3].Direction = ParameterDirection.Output;
  9205. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9206. string res = sqlParameter[3].Value.ToString();
  9207. var res_obj = new
  9208. {
  9209. data = res
  9210. };
  9211. string ro_json = JsonConvert.SerializeObject(res_obj);
  9212. returnSuccess(ro_json);
  9213. }
  9214. //writeGridDataViewJson(dt.Rows.Count, dv);
  9215. }
  9216. public void get_order_list()
  9217. {
  9218. string strFields = GetPostString("paraFields");
  9219. string strOrder = GetPostString("paraOrder");
  9220. string strWhere = GetPostString("paraWhere");
  9221. string strPageSize = GetPostString("paraPageSize");
  9222. DataStruct dStruct = GetPostStruct();
  9223. dStruct.PageSize = int.Parse(strPageSize);
  9224. dStruct.Fileds = strFields;
  9225. dStruct.Order = strOrder;
  9226. dStruct.MainWhere = strWhere;
  9227. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9228. writeGridDataTableJson(dStruct.TotalCount, dt);
  9229. }
  9230. ////获取待开始订单列表
  9231. //public void get_wait_design_order_list()
  9232. //{
  9233. // string date_type = GetPostString("date_type");
  9234. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9235. // DataStruct dStruct = GetPostStruct();
  9236. // dStruct.PageSize = 1000;
  9237. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9238. // List<string> lw = new List<string>();
  9239. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9240. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9241. // dStruct.Order = "WaitDesignTime asc";
  9242. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9243. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9244. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9245. //}
  9246. //获取完成单量排名
  9247. public void get_finish_order_count_ranking()
  9248. {
  9249. /* string date_type = GetPostString("date_type");
  9250. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9251. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9252. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9253. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9254. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9255. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9256. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9257. writeGridDataTableJson(0, new DataTable());
  9258. }
  9259. public void get_finish_order_amount_ranking()
  9260. {
  9261. /*string date_type = GetPostString("date_type");
  9262. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9263. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9264. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9265. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9266. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9267. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9268. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9269. writeGridDataTableJson(0, new DataTable());
  9270. }
  9271. public void get_finish_refund_count_ranking()
  9272. {
  9273. string date_type = GetPostString("date_type");
  9274. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9275. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9276. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9277. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9278. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9279. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9280. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9281. writeGridDataTableJson(dt.Rows.Count, dt);
  9282. }
  9283. public void get_finish_refund_amount_ranking()
  9284. {
  9285. string date_type = GetPostString("date_type");
  9286. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9287. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9288. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9289. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9290. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9291. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9292. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9293. writeGridDataTableJson(dt.Rows.Count, dt);
  9294. }
  9295. public void set_erp_finishorder_director()
  9296. {
  9297. if (UrlPostParmsCheck("ctid"))
  9298. {
  9299. string eid = GetPostString("ctid");
  9300. CeErpTradeCell entity = null;
  9301. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9302. if (entity != null)
  9303. {
  9304. entity.OrderState = 8;
  9305. entity.Update();
  9306. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9307. returnSuccessMsg("操作成功!");
  9308. return;
  9309. }
  9310. returnErrorMsg("找不到记录");
  9311. }
  9312. }
  9313. public void get_erp_placeregistlist()
  9314. {
  9315. DataStruct dStruct = GetPostStruct();
  9316. List<string> lw = new List<string>();
  9317. string outsid = GetPostString("outsid");
  9318. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9319. string memo = GetPostString("memo");
  9320. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9321. string filename = GetPostString("filename");
  9322. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9323. string islate = GetPostString("islate");
  9324. if (islate.Length > 0)
  9325. {
  9326. if (islate == "1")
  9327. lw.Add(string.Format("OutLate>0"));
  9328. else
  9329. lw.Add(string.Format("OutLate=0"));
  9330. }
  9331. string placedate1 = GetPostString("placedate1");
  9332. string placedate2 = GetPostString("placedate2");
  9333. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9334. if (dw.Length > 0) lw.Add(dw);
  9335. string deliveryDate1 = GetPostString("deliverydate1");
  9336. string deliveryDate2 = GetPostString("deliverydate2");
  9337. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9338. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9339. dStruct.Order = "ID desc";
  9340. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9341. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9342. writeGridDataTableJson(dStruct.TotalCount, dt);
  9343. }
  9344. public void ins_erp_placeregist()
  9345. {
  9346. if (UrlPostParmsCheck("id"))
  9347. {
  9348. string eid = GetPostString("id");
  9349. CeErpPlaceRegister entity = null;
  9350. if (eid == "0")//新增
  9351. {
  9352. entity = new CeErpPlaceRegister();
  9353. string xdTime = GetPostString("placeTime");
  9354. if (xdTime.Length > 0)
  9355. {
  9356. entity.PlactTime = Convert.ToDateTime(xdTime);
  9357. }
  9358. string fhTime = GetPostString("deliveryTime");
  9359. if (fhTime.Length > 0)
  9360. {
  9361. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9362. }
  9363. string preTime = GetPostString("preOutTime");
  9364. if (preTime.Length > 0)
  9365. {
  9366. entity.PreOutTime = Convert.ToDateTime(preTime);
  9367. }
  9368. entity.DeliveryCount = GetPostInt("deliveryCount");
  9369. entity.ReceiveCount = GetPostInt("receiveCount");
  9370. entity.OutSid = GetPostString("outSid");
  9371. entity.FileName = GetPostString("fileName");
  9372. entity.Memo = GetPostString("memo");
  9373. entity.AddUserId = CurrentUser.UserID;
  9374. entity.CreateTime = DateTime.Now;
  9375. entity.Img = GetPostString("img");
  9376. entity.Supplier = GetPostInt("supplier");
  9377. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9378. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9379. {
  9380. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9381. DateTime dt2 = (DateTime)entity.PreOutTime;
  9382. TimeSpan span = dt1.Subtract(dt2);
  9383. if (span.Days > 0)
  9384. {
  9385. entity.OutLate = span.Days;
  9386. }
  9387. }
  9388. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9389. entity.Create();
  9390. returnSuccessMsg("添加成功!");
  9391. return;
  9392. }
  9393. else //修改
  9394. {
  9395. entity = CeErpPlaceRegister.Get(eid);
  9396. if (entity != null)
  9397. {
  9398. string xdTime = GetPostString("placeTime");
  9399. if (xdTime.Length > 0)
  9400. {
  9401. entity.PlactTime = Convert.ToDateTime(xdTime);
  9402. }
  9403. string fhTime = GetPostString("deliveryTime");
  9404. if (fhTime.Length > 0)
  9405. {
  9406. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9407. }
  9408. string preTime = GetPostString("preOutTime");
  9409. if (preTime.Length > 0)
  9410. {
  9411. entity.PreOutTime = Convert.ToDateTime(preTime);
  9412. }
  9413. entity.DeliveryCount = GetPostInt("deliveryCount");
  9414. entity.ReceiveCount = GetPostInt("receiveCount");
  9415. if (entity.DeliveryCount == entity.ReceiveCount)
  9416. {
  9417. entity.CurState = "已完成";
  9418. }
  9419. else
  9420. {
  9421. entity.CurState = "未完成";
  9422. }
  9423. entity.OutSid = GetPostString("outSid");
  9424. entity.FileName = GetPostString("fileName");
  9425. entity.Memo = GetPostString("memo");
  9426. entity.Img = GetPostString("img");
  9427. entity.Supplier = GetPostInt("supplier");
  9428. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9429. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9430. {
  9431. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9432. DateTime dt2 = (DateTime)entity.PreOutTime;
  9433. TimeSpan span = dt1.Subtract(dt2);
  9434. if (span.Days > 0)
  9435. {
  9436. entity.OutLate = span.Days;
  9437. }
  9438. }
  9439. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9440. entity.Update();
  9441. returnSuccessMsg("修改成功");
  9442. return;
  9443. }
  9444. returnErrorMsg("找不到对应的记录");
  9445. return;
  9446. }
  9447. }
  9448. returnErrorMsg("缺少必要参数");
  9449. }
  9450. public void del_erp_placeregist()
  9451. {
  9452. string eid = GetPostString("id");
  9453. CeErpPlaceRegister.Del(eid);
  9454. returnSuccessMsg("删除成功!");
  9455. return;
  9456. }
  9457. public void ins_erp_placeregistbyorder()
  9458. {
  9459. string ctid = GetPostString("ctid");
  9460. if (ctid.Length > 0)
  9461. {
  9462. StringBuilder sql = new StringBuilder();
  9463. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9464. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9465. if (dt.Rows.Count > 0)
  9466. {
  9467. foreach (DataRow dr in dt.Rows)
  9468. {
  9469. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9470. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9471. entity.AddUserId = CurrentUser.UserID;
  9472. entity.tid = dr["tid"].ToString();
  9473. entity.Did = Convert.ToString(dr["ctid"]);
  9474. entity.splitTag = dr["SplitTag"].ToString();
  9475. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9476. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9477. if (pre_ctid.Length > 0)
  9478. {
  9479. sellmemo = sellmemo.Replace(pre_ctid, "");
  9480. }
  9481. sellmemo = sellmemo.Replace("[", "");
  9482. sellmemo = sellmemo.Replace("]", "");
  9483. entity.FileName = sellmemo;
  9484. string count = dr["ProductCount"].ToString();
  9485. int usecount = commonHelper.getIntCountFromString(count);
  9486. entity.DeliveryCount = usecount;
  9487. entity.CurState = "未完成";
  9488. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9489. {
  9490. entity.Supplier = 24;//dl手提袋定制
  9491. }
  9492. else
  9493. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9494. entity.CreateTime = DateTime.Now;
  9495. entity.Create();
  9496. }
  9497. returnSuccessMsg("操作成功");
  9498. return;
  9499. }
  9500. returnErrorMsg("没有找到对应订单");
  9501. return;
  9502. }
  9503. returnErrorMsg("缺少订单编号");
  9504. return;
  9505. }
  9506. public void get_erp_persuadelist()
  9507. {
  9508. DataStruct dStruct = GetPostStruct();
  9509. List<string> lw = new List<string>();
  9510. string ctid = GetPostString("ctid");
  9511. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9512. string shopname = GetPostString("shopname");
  9513. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9514. string buyernick = GetPostString("buyer_nick");
  9515. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9516. string customer = GetPostString("customer");
  9517. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9518. string returndate1 = GetPostString("returndate1");
  9519. string returndate2 = GetPostString("returndate2");
  9520. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9521. if (dw.Length > 0) lw.Add(dw);
  9522. string finishDate1 = GetPostString("finishdate1");
  9523. string finishDate2 = GetPostString("finishdate2");
  9524. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9525. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9526. string persuadetype = GetPostString("persuadetype");
  9527. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9528. string returnvstate = GetPostString("returnvstate");
  9529. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9530. dStruct.Order = "created desc";
  9531. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9532. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9533. writeGridDataTableJson(dStruct.TotalCount, dt);
  9534. }
  9535. public void upd_erp_returnpersuadeback()
  9536. {
  9537. if (UrlPostParmsCheck("ID"))
  9538. {
  9539. int eid = GetPostInt("ID");
  9540. CeErpPersuade entity = null;
  9541. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9542. if (entity != null)
  9543. {
  9544. entity.backreason = GetPostString("reason");
  9545. entity.pstate = 2;
  9546. entity.verifytime = DateTime.Now;
  9547. entity.verifyuserid = CurrentUser.UserID;
  9548. entity.Update();
  9549. returnSuccessMsg("退回成功!");
  9550. return;
  9551. }
  9552. returnErrorMsg("找不到订单记录");
  9553. }
  9554. }
  9555. public void upd_erp_returnpersuadeverify()
  9556. {
  9557. if (UrlPostParmsCheck("ID"))
  9558. {
  9559. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9560. {
  9561. returnErrorMsg("暂无权限审核");
  9562. return;
  9563. }
  9564. int eid = GetPostInt("ID");
  9565. CeErpPersuade entity = null;
  9566. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9567. if (entity != null)
  9568. {
  9569. entity.pstate = 1;
  9570. entity.verifytime = DateTime.Now;
  9571. entity.verifyuserid = CurrentUser.UserID;
  9572. entity.Update();
  9573. returnSuccessMsg("审核成功!");
  9574. return;
  9575. }
  9576. returnErrorMsg("找不到订单记录");
  9577. }
  9578. }
  9579. public void del_erp_persuade()
  9580. {
  9581. if (UrlPostParmsCheck("ID"))
  9582. {
  9583. int eid = GetPostInt("ID");
  9584. CeErpPersuade.Del(eid);
  9585. returnSuccessMsg("操作成功");
  9586. return;
  9587. }
  9588. }
  9589. public void get_erp_oldcustoupload()
  9590. {
  9591. DataStruct dStruct = GetPostStruct();
  9592. List<string> lw = new List<string>();
  9593. string buyernick = GetPostString("buyer_nick");
  9594. if (buyernick.Length > 0)
  9595. {
  9596. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9597. }
  9598. else
  9599. return;
  9600. dStruct.Order = "pay_time desc";
  9601. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9602. DataTable dt = null;
  9603. dt = WebCache.GetData("view_erptradecell", dStruct);
  9604. writeGridDataTableJson(dStruct.TotalCount, dt);
  9605. }
  9606. public void get_erp_checkorderlist()
  9607. {
  9608. DataStruct dStruct = GetPostStruct();
  9609. List<string> lw = new List<string>();
  9610. string tid = GetPostString("ctid");
  9611. if (tid.Length > 0)
  9612. {
  9613. string select_tid = getTidByCtid(tid);
  9614. lw.Add(string.Format("tid='{0}'", select_tid));
  9615. }
  9616. string shopname = GetPostString("shopname");
  9617. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9618. string buyernick = GetPostString("buyer_nick");
  9619. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9620. string customer = GetPostString("customer");
  9621. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9622. string design = GetPostString("design");
  9623. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9624. string orderState = GetPostString("orderState");
  9625. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9626. string address = GetPostString("address");
  9627. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9628. string sellermemo = GetPostString("seller_memo");
  9629. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9630. string supplier = GetPostString("supplier");
  9631. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9632. {
  9633. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9634. }
  9635. else
  9636. {
  9637. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9638. }
  9639. string date1 = GetPostString("date1");
  9640. string date2 = GetPostString("date2");
  9641. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9642. if (dw.Length > 0) lw.Add(dw);
  9643. string placedate1 = GetPostString("placedate1");
  9644. string placedate2 = GetPostString("placedate2");
  9645. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9646. if (fdw.Length > 0) lw.Add(fdw);
  9647. string price1 = GetPostString("price1");
  9648. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9649. string price2 = GetPostString("price2");
  9650. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9651. string checkst = GetPostString("checkstate");
  9652. if (checkst.Length > 0 && "10".Equals(checkst))
  9653. {
  9654. lw.Add(string.Format("CheckOut>0"));
  9655. }
  9656. else
  9657. {
  9658. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9659. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9660. }
  9661. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9662. {
  9663. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9664. }
  9665. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9666. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9667. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9668. writeGridDataTableJson(dStruct.TotalCount, dt);
  9669. }
  9670. public void ins_erp_startCheck()
  9671. {
  9672. if (UrlPostParmsCheck("ctid"))
  9673. {
  9674. string eid = GetPostString("ctid");
  9675. CeErpTradeCell entity = null;
  9676. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9677. if (entity != null)
  9678. {
  9679. entity.MemoOpt = 4;
  9680. entity.UpdateTime = DateTime.Now;
  9681. entity.Update();
  9682. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9683. CeErpSukuraData.createInfo(entity.ctid, 6);
  9684. returnSuccessMsg("操作成功!");
  9685. return;
  9686. }
  9687. returnErrorMsg("找不到记录");
  9688. }
  9689. }
  9690. public void upd_erp_sendXlw()
  9691. {
  9692. if (UrlPostParmsCheck("ctid"))
  9693. {
  9694. string eid = GetPostString("ctid");
  9695. CeErpTradeCell entity = null;
  9696. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9697. if (entity != null)
  9698. {
  9699. if (entity.IsSendGift == 1)
  9700. {
  9701. returnErrorMsg("请勿重复标记");
  9702. return;
  9703. }
  9704. entity.IsSendGift = 1;
  9705. entity.Update();
  9706. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9707. returnSuccessMsg("操作成功!");
  9708. return;
  9709. }
  9710. returnErrorMsg("找不到记录");
  9711. }
  9712. }
  9713. public void cancel_sendXlw()
  9714. {
  9715. if (UrlPostParmsCheck("ctid"))
  9716. {
  9717. string eid = GetPostString("ctid");
  9718. CeErpTradeCell entity = null;
  9719. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9720. if (entity != null)
  9721. {
  9722. if (entity.IsSendGift == 0)
  9723. {
  9724. returnErrorMsg("未标记小礼物");
  9725. return;
  9726. }
  9727. entity.IsSendGift = 0;
  9728. entity.Update();
  9729. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9730. returnSuccessMsg("操作成功!");
  9731. return;
  9732. }
  9733. returnErrorMsg("找不到记录");
  9734. }
  9735. }
  9736. public void get_erp_designbill()
  9737. {
  9738. DataStruct dStruct = GetPostStruct();
  9739. List<string> lw = new List<string>();
  9740. int isMy = GetInt("my");
  9741. if (isMy == 1)
  9742. {
  9743. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9744. }
  9745. string tid = GetPostString("tid");
  9746. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9747. string userName = GetPostString("design");
  9748. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9749. string price1 = GetPostString("price1");
  9750. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9751. string price2 = GetPostString("price2");
  9752. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9753. string rePrice1 = GetPostString("rePrice1");
  9754. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9755. string rePrice2 = GetPostString("rePrice2");
  9756. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9757. string designerType = GetPostString("designerType");
  9758. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9759. string orderState = GetPostString("orderState");
  9760. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9761. string endTime1 = GetPostString("endTime1");
  9762. string endTime2 = GetPostString("endTime2");
  9763. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9764. if (dw.Length > 0) lw.Add(dw);
  9765. string isDk = GetPostString("isDk");
  9766. if (isDk == "1")
  9767. {
  9768. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9769. }
  9770. else if (isDk == "0")
  9771. {
  9772. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9773. }
  9774. dStruct.Order = "oid, create_time desc";
  9775. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9776. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9777. writeGridDataTableJson(dStruct.TotalCount, dt);
  9778. }
  9779. public void upd_erp_designerbill()
  9780. {
  9781. if (UrlPostParmsCheck("ID"))
  9782. {
  9783. string eid = GetPostString("ID");
  9784. CeErpDesignerBill entity = null;
  9785. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9786. if (entity != null)
  9787. {
  9788. if (GetPostDouble("designerpirce") > 0)
  9789. {
  9790. entity.realPrice = GetPostDouble("designerpirce");
  9791. entity.update_time = DateTime.Now;
  9792. entity.update_u_id = CurrentUser.UserID;
  9793. entity.update_u_name = CurrentUser.UserName;
  9794. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9795. entity.Update();
  9796. returnSuccessMsg("操作成功!");
  9797. return;
  9798. }
  9799. else
  9800. {
  9801. entity.price = GetPostDouble("price");
  9802. entity.update_time = DateTime.Now;
  9803. entity.update_u_id = CurrentUser.UserID;
  9804. entity.update_u_name = CurrentUser.UserName;
  9805. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9806. entity.Update();
  9807. returnSuccessMsg("操作成功!");
  9808. return;
  9809. }
  9810. }
  9811. returnErrorMsg("找不到记录");
  9812. }
  9813. }
  9814. public void audit_erp_designerbill()
  9815. {
  9816. if (UrlPostParmsCheck("ID"))
  9817. {
  9818. string eid = GetPostString("ID");
  9819. CeErpDesignerBill entity = null;
  9820. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9821. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9822. if (entity != null)
  9823. {
  9824. entity.realPrice = GetPostDouble("designerpirce");
  9825. entity.update_time = DateTime.Now;
  9826. entity.update_u_id = CurrentUser.UserID;
  9827. entity.update_u_name = CurrentUser.UserName;
  9828. entity.isAudit = 1;
  9829. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9830. entity.Update();
  9831. if (orderEntity != null)
  9832. {
  9833. orderEntity.IsReadTag = 3;
  9834. orderEntity.Update();
  9835. }
  9836. returnSuccessMsg("操作成功!");
  9837. return;
  9838. }
  9839. returnErrorMsg("找不到记录");
  9840. }
  9841. }
  9842. public void all_audit_erp_designerbill()
  9843. {
  9844. if (UrlPostParmsCheck("idList"))
  9845. {
  9846. string[] list = GetPostString("idList").Split(',');
  9847. CeErpDesignerBill entity = null;
  9848. for (int i = 0; i < list.Length; i++)
  9849. {
  9850. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9851. if (entity == null) return;
  9852. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9853. if (orderEntity == null) return;
  9854. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9855. entity.update_time = DateTime.Now;
  9856. entity.update_u_id = CurrentUser.UserID;
  9857. entity.update_u_name = CurrentUser.UserName;
  9858. entity.isAudit = 1;
  9859. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9860. entity.Update();
  9861. orderEntity.IsReadTag = 3;
  9862. orderEntity.Update();
  9863. }
  9864. returnSuccessMsg("操作成功!");
  9865. return;
  9866. }
  9867. }
  9868. public void get_erp_sameorders()
  9869. {
  9870. if (UrlPostParmsCheck("ctid"))
  9871. {
  9872. string eid = GetPostString("ctid");
  9873. CeErpTradeCell entity = null;
  9874. entity = CeErpTradeCell.GetByCtid(eid);
  9875. if (entity != null)
  9876. {
  9877. StringBuilder sql = new StringBuilder();
  9878. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9879. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9880. var res = new
  9881. {
  9882. data = dt.Rows.Count
  9883. };
  9884. string ro_jsond = JsonConvert.SerializeObject(res);
  9885. returnSuccess(ro_jsond);
  9886. return;
  9887. }
  9888. returnErrorMsg("未找到订单");
  9889. return;
  9890. }
  9891. returnErrorMsg("缺少必要的参数");
  9892. }
  9893. public void get_erp_islasthavesameorder()
  9894. {
  9895. if (UrlPostParmsCheck("ctid"))
  9896. {
  9897. string eid = GetPostString("ctid");
  9898. string[] ctidList = eid.Split(',');
  9899. StringBuilder sql = new StringBuilder();
  9900. string tisCtid = "";
  9901. foreach (string ctid in ctidList)
  9902. {
  9903. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9904. if (entity != null)
  9905. {
  9906. sql = new StringBuilder();
  9907. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9908. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9909. if (dth.Rows.Count > 0)
  9910. {
  9911. tisCtid += entity.ctid;
  9912. tisCtid += ",";
  9913. }
  9914. }
  9915. }
  9916. if (tisCtid.Length > 0)
  9917. {
  9918. var res = new
  9919. {
  9920. data = tisCtid
  9921. };
  9922. string ro_jsond = JsonConvert.SerializeObject(res);
  9923. returnSuccess(ro_jsond);
  9924. }
  9925. else
  9926. {
  9927. var res = new
  9928. {
  9929. data = ""
  9930. };
  9931. string ro_jsond = JsonConvert.SerializeObject(res);
  9932. returnSuccess(ro_jsond);
  9933. }
  9934. return;
  9935. }
  9936. returnErrorMsg("缺少必要的参数");
  9937. }
  9938. public void file_client_down_url()
  9939. {
  9940. if (!UrlPostParmsCheck("userId"))
  9941. {
  9942. returnErrorMsg("缺少必要的参数");
  9943. }
  9944. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9945. }
  9946. public void checkout_form_data()
  9947. {
  9948. if (!UrlPostParmsCheck("tid"))
  9949. {
  9950. returnErrorMsg("缺少必要的参数");
  9951. }
  9952. string tid = GetPostString("tid");
  9953. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9954. if (ceErpOrderFormData != null)
  9955. {
  9956. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9957. returnSuccess(ro_jsond);
  9958. return;
  9959. }
  9960. returnErrorMsg("尚未有文件!");
  9961. }
  9962. public void back_supplier_audit()
  9963. {
  9964. int userId = CurrentUser.UserID;
  9965. StringBuilder sql = new StringBuilder();
  9966. 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);
  9967. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9968. if (dt.Rows.Count > 0)
  9969. {
  9970. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9971. }
  9972. else
  9973. {
  9974. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9975. }
  9976. }
  9977. public void back_supplier_query()
  9978. {
  9979. string eid = GetPostString("ctid");
  9980. if (eid != "")
  9981. {
  9982. StringBuilder sql = new StringBuilder();
  9983. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9984. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9985. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9986. }
  9987. else
  9988. {
  9989. returnErrorMsg("找不到订单记录");
  9990. return;
  9991. }
  9992. }
  9993. public void verified_to_order()
  9994. {
  9995. int userId = CurrentUser.UserID;
  9996. StringBuilder sql = new StringBuilder();
  9997. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9998. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9999. if (dt.Rows.Count > 0)
  10000. {
  10001. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10002. }
  10003. else
  10004. {
  10005. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10006. }
  10007. }
  10008. public void upd_supplier_audit()
  10009. {
  10010. if (UrlPostParmsCheck("ctid"))
  10011. {
  10012. string eid = GetPostString("ctid");
  10013. string reason = GetPostString("returnreason");
  10014. CeErpTradeCell entity = null;
  10015. CeWithdraw withdraw = null;
  10016. withdraw = CeWithdraw.GetByTid(eid);
  10017. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  10018. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  10019. {
  10020. if (withdraw != null)
  10021. {
  10022. if (!withdraw.userid.Equals(CurrentUser.UserID))
  10023. {
  10024. returnSuccessMsg("您没有权限操作!");
  10025. return;
  10026. }
  10027. else
  10028. {
  10029. if (reason.Equals("1"))
  10030. {
  10031. if (entity.OrderState == -1)
  10032. {
  10033. if (entity.FinishPlaceTime == null)
  10034. {
  10035. entity.OrderState = 2;
  10036. }
  10037. else
  10038. {
  10039. entity.OrderState = 6;
  10040. }
  10041. }
  10042. entity.Update();
  10043. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10044. if (withdraw != null)
  10045. {
  10046. withdraw.status = int.Parse(reason);
  10047. withdraw.Update();
  10048. }
  10049. returnSuccessMsg("操作成功!");
  10050. return;
  10051. }
  10052. else
  10053. {
  10054. withdraw.status = int.Parse(reason);
  10055. withdraw.acknowledgingtime = DateTime.Now;
  10056. withdraw.Update();
  10057. returnSuccessMsg("查看详细请点击线下订单查询");
  10058. return;
  10059. }
  10060. }
  10061. }
  10062. // 第一个字符是 'N'
  10063. }
  10064. if (eid[0] != 'N')
  10065. {
  10066. }
  10067. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10068. {
  10069. entity.IsVerifyToSupplier = false;
  10070. entity.IsReturn = 1;
  10071. entity.ReturnTime = DateTime.Now;
  10072. entity.ReturnReason = reason;
  10073. if (entity.OrderState == 6)
  10074. {
  10075. entity.OrderState = 5;
  10076. }
  10077. entity.Update();
  10078. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10079. if (withdraw != null)
  10080. {
  10081. withdraw.status = int.Parse(reason);
  10082. withdraw.Update();
  10083. }
  10084. returnSuccessMsg("操作成功!");
  10085. return;
  10086. }
  10087. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10088. {
  10089. ;
  10090. if (withdraw != null)
  10091. {
  10092. withdraw.status = int.Parse(reason);
  10093. withdraw.acknowledgingtime = DateTime.Now;
  10094. withdraw.Update();
  10095. returnSuccessMsg("供应商取消撤回!");
  10096. return;
  10097. }
  10098. }
  10099. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10100. {
  10101. if (entity.OrderState == -1)
  10102. {
  10103. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10104. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10105. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10106. {
  10107. returnErrorMsg("台湾客户需填写身份证!");
  10108. return;
  10109. }
  10110. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10111. {
  10112. returnErrorMsg("偏远地区需要填写物流费!");
  10113. return;
  10114. }
  10115. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10116. {
  10117. returnErrorMsg("订单spu没有确认无法通过审核!");
  10118. return;
  10119. }
  10120. if (entity.FinishPlaceTime == null)
  10121. {
  10122. entity.OrderState = 2;
  10123. }
  10124. else
  10125. {
  10126. entity.OrderState = 3;
  10127. }
  10128. commonHelper.getCytPrice(entity);
  10129. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10130. {
  10131. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10132. }
  10133. if (entity.IsSample > 1 || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物"))
  10134. {
  10135. entity.OrderState = 6;
  10136. }
  10137. }
  10138. entity.Update();
  10139. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10140. if (withdraw != null)
  10141. {
  10142. withdraw.status = int.Parse(reason);
  10143. withdraw.Update();
  10144. }
  10145. returnSuccessMsg("操作成功!");
  10146. return;
  10147. }
  10148. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10149. {
  10150. if (withdraw == null)
  10151. {
  10152. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10153. return;
  10154. }
  10155. }
  10156. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10157. {
  10158. if (withdraw != null)
  10159. {
  10160. withdraw.status = int.Parse(reason);
  10161. withdraw.acknowledgingtime = DateTime.Now;
  10162. withdraw.Update();
  10163. returnSuccessMsg("查看详细请点击线下订单查询");
  10164. return;
  10165. }
  10166. }
  10167. return;
  10168. }
  10169. }
  10170. //校验报价
  10171. public void refund_order_tip()
  10172. {
  10173. int userid = CurrentUser.UserID;
  10174. int sectionId = CurrentUser.UserPost.OrgID;
  10175. StringBuilder sql = new StringBuilder();
  10176. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10177. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10178. List<string> ids = new List<string>();
  10179. if (dth.Rows.Count > 0)
  10180. {
  10181. foreach (DataRow dr in dth.Rows)
  10182. {
  10183. ids.Add(dr["ID"].ToString());
  10184. }
  10185. try
  10186. {
  10187. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10188. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10189. }
  10190. catch (Exception ex)
  10191. {
  10192. }
  10193. }
  10194. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10195. }
  10196. public void refund_order_Design()
  10197. {
  10198. int userid = CurrentUser.UserID;
  10199. int sectionId = CurrentUser.UserPost.OrgID;
  10200. StringBuilder sql = new StringBuilder();
  10201. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10202. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10203. List<string> ids = new List<string>();
  10204. if (dth.Rows.Count > 0)
  10205. {
  10206. foreach (DataRow dr in dth.Rows)
  10207. {
  10208. ids.Add(dr["ID"].ToString());
  10209. }
  10210. try
  10211. {
  10212. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10213. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10214. }
  10215. catch (Exception ex)
  10216. {
  10217. }
  10218. }
  10219. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10220. }
  10221. public void change_order_info()
  10222. {
  10223. int userid = CurrentUser.UserID;
  10224. StringBuilder sql = new StringBuilder();
  10225. 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);
  10226. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10227. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10228. }
  10229. public void change_win_mome()
  10230. {
  10231. if (UrlPostParmsCheck("id,ctid"))
  10232. {
  10233. string id = GetPostString("id");
  10234. string ctid = GetPostString("ctid");
  10235. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10236. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10237. if (ce == null || ceErpMessageTip == null)
  10238. {
  10239. returnSuccessMsg("未找到对应的订单!");
  10240. return;
  10241. }
  10242. if (ce.OrderState >= 5)
  10243. {
  10244. ceErpMessageTip.isVisit = true;
  10245. ceErpMessageTip.Update();
  10246. returnSuccessMsg("已上传文件无法修改!");
  10247. return;
  10248. }
  10249. int type = GetPostInt("type");
  10250. string content = GetPostString("content");
  10251. if (type == 0)
  10252. {
  10253. content = content.Replace("(", "(");
  10254. content = content.Replace(")", ")");
  10255. string check = MidStrEx(content, "(", ")").Trim();
  10256. if (string.IsNullOrEmpty(check))
  10257. {
  10258. returnSuccessMsg("文件名格式不正确");
  10259. return;
  10260. }
  10261. }
  10262. ce.seller_memo = content;
  10263. ce.Update();
  10264. ceErpMessageTip.isVisit = true;
  10265. ceErpMessageTip.Update();
  10266. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10267. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10268. ApiVo apiVo = new ApiVo();
  10269. apiVo.orderNumber = ce.ctid;
  10270. apiVo.actionName = "demandDesign";
  10271. apiVo.orderRemarks = content;
  10272. apiVo.demandExamine = type + 1;
  10273. designHelper.API_WorkCore(apiVo);//demandDesign
  10274. returnSuccessMsg("修改成功!");
  10275. }
  10276. }
  10277. public static string MidStrEx(string sourse, string startstr, string endstr)
  10278. {
  10279. string result = string.Empty;
  10280. int startindex, endindex;
  10281. try
  10282. {
  10283. startindex = sourse.IndexOf(startstr);
  10284. if (startindex == -1)
  10285. return result;
  10286. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10287. endindex = tmpstr.IndexOf(endstr);
  10288. if (endindex == -1)
  10289. return result;
  10290. result = tmpstr.Remove(endindex);
  10291. }
  10292. catch (Exception ex)
  10293. {
  10294. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10295. }
  10296. return result;
  10297. }
  10298. public void refund_order_list()
  10299. {
  10300. int userid = CurrentUser.UserID;
  10301. int sectionId = CurrentUser.UserPost.OrgID;
  10302. StringBuilder sql = new StringBuilder();
  10303. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10304. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10305. DataStruct dStruct = GetPostStruct();
  10306. DataTable dt = null;
  10307. List<string> ids = new List<string>();
  10308. List<string> tids = new List<string>();
  10309. if (dth.Rows.Count > 0)
  10310. {
  10311. foreach (DataRow dr in dth.Rows)
  10312. {
  10313. tids.Add("'" + dr["tid"].ToString() + "'");
  10314. ids.Add(dr["id"].ToString());
  10315. }
  10316. try
  10317. {
  10318. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10319. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10320. List<string> lw = new List<string>();
  10321. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10322. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10323. dt = WebCache.GetData("view_orderlist", dStruct);
  10324. }
  10325. catch (Exception ex)
  10326. {
  10327. }
  10328. }
  10329. writeGridDataTableJson(dStruct.TotalCount, dt);
  10330. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10331. }
  10332. //新增
  10333. public void order_batch_downloads()
  10334. {
  10335. string ceid = GetPostString("tid");
  10336. String[] tid = ceid.Split(',');
  10337. order_batch_caiyingtong(tid);
  10338. /* (string success, string errors) = UploadFiles(tid);
  10339. returnSuccessMsg(success + errors);*/
  10340. return;
  10341. }
  10342. //报价接口
  10343. public void Get_To_Quote()
  10344. {
  10345. string ceid = GetPostString("ctid");
  10346. if (ceid != null)
  10347. {
  10348. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10349. if (entity != null)
  10350. {
  10351. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10352. {
  10353. return;
  10354. }
  10355. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10356. double price = 0;
  10357. if (cp == null)
  10358. {
  10359. JObject jsonObject12 = new JObject
  10360. {
  10361. { "UserId", "77886" },
  10362. { "Pwd", "lt666888" },
  10363. { "Filename", entity.seller_memo }
  10364. };
  10365. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10366. JObject jsonObjects1 = JObject.Parse(response1);
  10367. string ms1g = (string)jsonObjects1["msg"];
  10368. if (ms1g == "报价成功")
  10369. {
  10370. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10371. string data = (string)jsonObject1["price"];
  10372. 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 + "');";
  10373. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10374. returnSuccessMsg("获取报价成功:" + data);
  10375. price = Convert.ToDouble(data);
  10376. }
  10377. else
  10378. {
  10379. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10380. return;
  10381. }
  10382. }
  10383. String[] beizhu = entity.seller_memo.Split('-');
  10384. String chanp = "";
  10385. if (beizhu.Length > 0)
  10386. {
  10387. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10388. }
  10389. else
  10390. {
  10391. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10392. }
  10393. JObject jsonObject = new JObject
  10394. {
  10395. { "UserId", "77886" },
  10396. { "Pwd", "lt666888" },
  10397. { "Filename", chanp }
  10398. };
  10399. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10400. JObject jsonObjects = JObject.Parse(response);
  10401. string msg = (string)jsonObjects["msg"];
  10402. if (msg == "报价成功")
  10403. {
  10404. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10405. string data = (string)jsonObject1["price"];
  10406. 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 + "');";
  10407. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10408. returnSuccessMsg("获取报价成功:" + data);
  10409. price = Convert.ToDouble(data);
  10410. }
  10411. else
  10412. {
  10413. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10414. return;
  10415. }
  10416. if (price > 0)
  10417. {
  10418. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10419. if (ceErpTradeCellExtend == null)
  10420. {
  10421. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10422. ceErpTradeCellExtend.ctid = entity.ctid;
  10423. ceErpTradeCellExtend.payment_cyt = price;
  10424. ceErpTradeCellExtend.Create();
  10425. }
  10426. else
  10427. {
  10428. ceErpTradeCellExtend.payment_cyt = price;
  10429. ceErpTradeCellExtend.Update();
  10430. }
  10431. }
  10432. return;
  10433. }
  10434. }
  10435. else
  10436. {
  10437. returnErrorMsg("请至少选择一条数据");
  10438. return;
  10439. }
  10440. }
  10441. //新增
  10442. public void order_To_Supplier()
  10443. {
  10444. string ceid = GetPostString("tid");
  10445. String[] tid = ceid.Split(',');
  10446. if (tid.Length > 0)
  10447. {
  10448. try
  10449. {
  10450. for (int i = 0; i < tid.Length; i++)
  10451. {
  10452. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10453. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10454. entity.SupplierId = suid;
  10455. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10456. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10457. entity.Update();
  10458. }
  10459. }
  10460. catch (Exception ex)
  10461. {
  10462. returnErrorMsg("自动匹配供应商失败");
  10463. return;
  10464. }
  10465. }
  10466. else
  10467. {
  10468. returnErrorMsg("请至少选择一条数据");
  10469. return;
  10470. }
  10471. returnSuccessMsg("自动匹配供应商成功");
  10472. return;
  10473. }
  10474. public (string, string) UploadFiles(string[] urls)
  10475. {
  10476. string success = "";
  10477. string errors = "";
  10478. int userid = CurrentUser.UserID;
  10479. foreach (string url in urls)
  10480. {
  10481. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10482. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10483. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10484. {
  10485. JObject jsonObject = new JObject
  10486. {
  10487. { "Userid", "77886" },
  10488. { "pwd", "cyt86435015" },
  10489. { "content", base64FileContent },
  10490. { "ext", Path.GetExtension(fileName) }
  10491. };
  10492. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10493. JObject jsonObjects = JObject.Parse(response);
  10494. string msg = (string)jsonObjects["msg"];
  10495. if (msg.Equals("上传成功"))
  10496. {
  10497. success += url + " 上传成功";
  10498. }
  10499. else
  10500. {
  10501. errors += url + " 上传失败";
  10502. }
  10503. }
  10504. else
  10505. {
  10506. errors += url + " 格式出现问题";
  10507. }
  10508. }
  10509. if (urls.Length == 0)
  10510. {
  10511. return (success, errors);
  10512. }
  10513. return (success, errors);
  10514. }
  10515. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10516. {
  10517. return true; //总是接受
  10518. }
  10519. public static string HttpPost(string url, string param = null)
  10520. {
  10521. HttpWebRequest request;
  10522. //如果是发送HTTPS请求
  10523. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10524. {
  10525. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10526. request = WebRequest.Create(url) as HttpWebRequest;
  10527. request.ProtocolVersion = HttpVersion.Version10;
  10528. }
  10529. else
  10530. {
  10531. request = WebRequest.Create(url) as HttpWebRequest;
  10532. }
  10533. request.Method = "POST";
  10534. request.ContentType = "application/json";
  10535. request.Accept = "*/*";
  10536. request.Timeout = 120000;
  10537. request.AllowAutoRedirect = false;
  10538. StreamWriter requestStream = null;
  10539. WebResponse response = null;
  10540. string responseStr = null;
  10541. try
  10542. {
  10543. requestStream = new StreamWriter(request.GetRequestStream());
  10544. requestStream.Write(param);
  10545. requestStream.Close();
  10546. response = request.GetResponse();
  10547. if (response != null)
  10548. {
  10549. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10550. responseStr = reader.ReadToEnd();
  10551. reader.Close();
  10552. }
  10553. }
  10554. catch (Exception ex)
  10555. {
  10556. return ex.Message;
  10557. }
  10558. finally
  10559. {
  10560. request = null;
  10561. requestStream = null;
  10562. response = null;
  10563. }
  10564. return responseStr;
  10565. }
  10566. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10567. {
  10568. string base64FileContent;
  10569. string fileName;
  10570. using (WebClient webClient = new WebClient())
  10571. {
  10572. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10573. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10574. {
  10575. using (Stream stream = response.GetResponseStream())
  10576. {
  10577. using (MemoryStream memoryStream = new MemoryStream())
  10578. {
  10579. stream.CopyTo(memoryStream);
  10580. byte[] fileBytes = memoryStream.ToArray();
  10581. base64FileContent = Convert.ToBase64String(fileBytes);
  10582. fileName = response.Headers["Content-Disposition"];
  10583. if (!string.IsNullOrEmpty(fileName))
  10584. {
  10585. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10586. if (index >= 0)
  10587. {
  10588. fileName = fileName.Substring(index + 9).Trim('\"');
  10589. }
  10590. }
  10591. else
  10592. {
  10593. fileName = Path.GetFileName(downloadUrl);
  10594. }
  10595. }
  10596. }
  10597. }
  10598. }
  10599. return (fileName, base64FileContent);
  10600. }
  10601. //新增
  10602. public void order_batch_caiyingtong(string[] downloadUrls)
  10603. {
  10604. try
  10605. {
  10606. //遍历文件
  10607. DataStruct dStruct = GetPostStruct();
  10608. DataTable dt = null;
  10609. int userid = CurrentUser.UserID;
  10610. List<string> ids = new List<string>();//失败组
  10611. List<string> tids = new List<string>();
  10612. using (WebClient webClient = new WebClient())
  10613. {
  10614. foreach (var url in downloadUrls)
  10615. {
  10616. try
  10617. {
  10618. tids.Add("'" + url + "'");
  10619. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10620. if (entity != null)
  10621. {
  10622. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10623. if (cp == null)
  10624. {
  10625. JObject jsonObject = new JObject
  10626. {
  10627. { "Userid", "77886" },
  10628. { "pwd", "lt666888" },
  10629. { "Filename",entity.seller_memo }
  10630. };
  10631. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10632. JObject jsonObjects = JObject.Parse(response);
  10633. string msg = (string)jsonObjects["msg"];
  10634. if (msg == "报价成功")
  10635. {
  10636. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10637. DownloadAndConvertToBase64(url1);
  10638. }
  10639. else
  10640. {
  10641. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10642. }
  10643. }
  10644. else
  10645. {
  10646. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10647. JObject jsonObject = new JObject
  10648. {
  10649. { "Userid", "77886" },
  10650. { "pwd", "lt666888" },
  10651. { "Filename",chanp }
  10652. };
  10653. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10654. JObject jsonObjects = JObject.Parse(response);
  10655. string msg = (string)jsonObjects["msg"];
  10656. if (msg == "报价成功")
  10657. {
  10658. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10659. DownloadAndConvertToBase64(url1);
  10660. }
  10661. else
  10662. {
  10663. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10664. }
  10665. }
  10666. }
  10667. // 上传文件到FTP
  10668. }
  10669. catch (Exception ex)
  10670. {
  10671. Console.WriteLine($"An error occurred: {ex.Message}");
  10672. }
  10673. }
  10674. List<string> lw = new List<string>();
  10675. lw.Add(string.Format("( OrderState < 6 )"));
  10676. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10677. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10678. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10679. if (dt.Rows.Count > 0)
  10680. {
  10681. foreach (DataRow dr in dt.Rows)
  10682. {
  10683. ids.Add(dr["ctid"].ToString());
  10684. }
  10685. }
  10686. String ErrorMsgs = "";
  10687. foreach (String id in ids)
  10688. {
  10689. ErrorMsgs += id + ",";
  10690. }
  10691. if (ErrorMsgs.Length > 1)
  10692. {
  10693. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10694. }
  10695. if (ErrorMsgs.Length < 1)
  10696. {
  10697. ErrorMsgs = "上传成功";
  10698. returnSuccessMsg(ErrorMsgs);
  10699. }
  10700. else
  10701. {
  10702. returnErrorMsg("以下订单" + ErrorMsgs);
  10703. }
  10704. }
  10705. // 删除文件夹及其内容
  10706. /* Directory.Delete(localDirectory, true);*/
  10707. }
  10708. catch { }
  10709. }
  10710. public void get_center_data()
  10711. {
  10712. int userId = CurrentUser.UserID;
  10713. string postCode = CurrentUser.UserPost.Post.Code;
  10714. List<string> lw = new List<string>();
  10715. List<string> ww = new List<string>();
  10716. DateTime currentTime = DateTime.Now;
  10717. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10718. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10719. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10720. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10721. string sql = " SELECT ";
  10722. string startTime = "2023-10-01 11:22:31";
  10723. //设计
  10724. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10725. {
  10726. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10727. 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));
  10728. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10729. 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));
  10730. }
  10731. //客服
  10732. else if (postCode == "CustomerService" || postCode == "Director")
  10733. {
  10734. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10735. 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));
  10736. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10737. 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));
  10738. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10739. 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));
  10740. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10741. 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));
  10742. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10743. 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));
  10744. }
  10745. //售后
  10746. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10747. {
  10748. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10749. 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));
  10750. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10751. 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));
  10752. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10753. 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));
  10754. }
  10755. //下单部
  10756. else if (postCode == "Place" || postCode == "PlaceMr")
  10757. {
  10758. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10759. 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));
  10760. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10761. 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));
  10762. }
  10763. //车间
  10764. else if (postCode == "Supplier")
  10765. {
  10766. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10767. 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));
  10768. }
  10769. DataTable dt = new DataTable();
  10770. if (lw.Count > 0)
  10771. {
  10772. sql += string.Join(" , ", lw);
  10773. sql += " FROM ";
  10774. sql += string.Join(" , ", ww);
  10775. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10776. }
  10777. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10778. }
  10779. public void get_center_data_list()
  10780. {
  10781. int userId = CurrentUser.UserID;
  10782. string postCode = CurrentUser.UserPost.Post.Code;
  10783. string shopIds = CurrentUser.User.pemShop;
  10784. DataStruct dStruct = GetPostStruct();
  10785. List<string> lw = new List<string>();
  10786. DateTime currentTime = DateTime.Now;
  10787. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10788. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10789. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10790. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10791. string startTime = "2023-10-01 11:22:31";
  10792. int order_type = GetPostInt("order_type");
  10793. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10794. {
  10795. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10796. if (order_type == 0)
  10797. {
  10798. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10799. }
  10800. else if (order_type == 3)
  10801. {
  10802. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10803. }
  10804. else
  10805. {
  10806. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10807. }
  10808. }
  10809. //客服
  10810. if (postCode == "CustomerService" || postCode == "Director")
  10811. {
  10812. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10813. if (order_type == 0)
  10814. {
  10815. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10816. }
  10817. else if (order_type == 1)
  10818. {
  10819. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10820. }
  10821. else if (order_type == 2)
  10822. {
  10823. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10824. }
  10825. else if (order_type == 3)
  10826. {
  10827. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10828. }
  10829. else if (order_type == 4)
  10830. {
  10831. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10832. }
  10833. else
  10834. {
  10835. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10836. }
  10837. }
  10838. //售后
  10839. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10840. {
  10841. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10842. if (shopIds != "")
  10843. {
  10844. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10845. }
  10846. if (order_type == 2)
  10847. {
  10848. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10849. }
  10850. else if (order_type == 4)
  10851. {
  10852. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10853. }
  10854. else if (order_type == 5)
  10855. {
  10856. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10857. }
  10858. else
  10859. {
  10860. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10861. }
  10862. }
  10863. //下单部
  10864. if (postCode == "Place" || postCode == "PlaceMr")
  10865. {
  10866. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10867. if (shopIds != "")
  10868. {
  10869. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10870. }
  10871. else if (order_type == 1)
  10872. {
  10873. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10874. }
  10875. else if (order_type == 2)
  10876. {
  10877. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10878. }
  10879. else
  10880. {
  10881. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10882. }
  10883. }
  10884. //车间
  10885. if (postCode == "Supplier")
  10886. {
  10887. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10888. if (order_type == 5)
  10889. {
  10890. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10891. }
  10892. else
  10893. {
  10894. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10895. }
  10896. }
  10897. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10898. dStruct.Fileds = "tid,ctid";
  10899. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10900. writeGridDataTableJson(dStruct.TotalCount, dt);
  10901. }
  10902. public void aftersale_audit_master()
  10903. {
  10904. if (UrlPostParmsCheck("ctid"))
  10905. {
  10906. string ctid = GetPostString("ctid");
  10907. if (ctid.Length > 0)
  10908. {
  10909. bool result = aftersale_data_change(ctid);
  10910. if (result)
  10911. {
  10912. returnSuccessMsg("修改成功!");
  10913. return;
  10914. }
  10915. }
  10916. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10917. }
  10918. }
  10919. public void aftersale_batch_audit_master()
  10920. {
  10921. if (UrlPostParmsCheck("ctids"))
  10922. {
  10923. string ctids = GetPostString("ctids");
  10924. if (ctids.Length > 0)
  10925. {
  10926. List<string> list = new List<string>();
  10927. string[] ctid_list = ctids.Split(',');
  10928. foreach (var item in ctid_list)
  10929. {
  10930. bool result = aftersale_data_change(item);
  10931. if (!result)
  10932. {
  10933. list.Add(item);
  10934. }
  10935. }
  10936. if (list.Count > 0)
  10937. {
  10938. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10939. return;
  10940. }
  10941. returnSuccessMsg("修改成功!");
  10942. return;
  10943. }
  10944. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10945. }
  10946. }
  10947. public bool aftersale_data_change(string ctid)
  10948. {
  10949. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10950. if (ceErpTradeCell != null)
  10951. {
  10952. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10953. ceErpTradeCell.AfterSaleSupplierState = 0;
  10954. StringBuilder sql = new StringBuilder();
  10955. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10956. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10957. CeErpTradeResponsible.DelByTid(ctid, 0);
  10958. 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 == "不理赔")
  10959. {
  10960. CeErpTradeResponsible.DelByTid(ctid, 1);
  10961. ceErpTradeCell.AfterSaleSupplierState = 1;
  10962. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10963. ceErpTradeCell.AfterSaleState = 4;
  10964. }
  10965. else
  10966. {
  10967. ceErpTradeCell.AfterSaleState = 3;
  10968. }
  10969. bool needCyt = false;
  10970. if (dt != null)
  10971. {
  10972. if (dt.Rows.Count == 1)
  10973. {
  10974. bool isEnd = false;
  10975. foreach (DataRow dr in dt.Rows)
  10976. {
  10977. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10978. {
  10979. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10980. isEnd = true;
  10981. }
  10982. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10983. {
  10984. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10985. isEnd = true;
  10986. }
  10987. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10988. {
  10989. needCyt = true;
  10990. }
  10991. }
  10992. if (isEnd)
  10993. {
  10994. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10995. ceErpTradeCell.AfterSaleState = 4;
  10996. ceErpTradeCell.AfterSaleSupplierState = 1;
  10997. }
  10998. }
  10999. else
  11000. {
  11001. bool isAll = true;
  11002. foreach (DataRow dr in dt.Rows)
  11003. {
  11004. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11005. {
  11006. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11007. continue;
  11008. }
  11009. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  11010. {
  11011. string path = "";
  11012. int OrgID = 0;
  11013. if (!Convert.IsDBNull(dr["OrgPath"]))
  11014. {
  11015. path = dr["OrgPath"].ToString();
  11016. }
  11017. if (!Convert.IsDBNull(dr["OrgID"]))
  11018. {
  11019. OrgID = Convert.ToInt32(dr["OrgID"]);
  11020. }
  11021. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  11022. {
  11023. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11024. continue;
  11025. }
  11026. }
  11027. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11028. {
  11029. needCyt = true;
  11030. }
  11031. isAll = false;
  11032. }
  11033. if (isAll)
  11034. {
  11035. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11036. ceErpTradeCell.AfterSaleState = 4;
  11037. ceErpTradeCell.AfterSaleSupplierState = 1;
  11038. }
  11039. }
  11040. }
  11041. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  11042. {
  11043. commonHelper.sendCytAfterSale(ceErpTradeCell);
  11044. }
  11045. if (ceErpTradeCell.AfterSaleState == 4)
  11046. {
  11047. ApiVo apiVo = new ApiVo();
  11048. apiVo.orderNumber = ceErpTradeCell.ctid;
  11049. apiVo.actionName = "afterOver";
  11050. designHelper.API_WorkCore(apiVo); //afterOver
  11051. }
  11052. ceErpTradeCell.Update();
  11053. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  11054. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  11055. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11056. return true;
  11057. }
  11058. return false;
  11059. }
  11060. public void get_erp_wechatorder()
  11061. {
  11062. DataStruct dStruct = GetPostStruct();
  11063. List<string> lw = new List<string>();
  11064. string tid = GetPostString("tid");
  11065. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11066. string shopname = GetPostString("shopname");
  11067. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11068. string buyernick = GetPostString("buyer_nick");
  11069. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11070. string customer = GetPostString("customer");
  11071. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11072. string returndate1 = GetPostString("returndate1");
  11073. string returndate2 = GetPostString("returndate2");
  11074. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11075. if (dw.Length > 0) lw.Add(dw);
  11076. string finishDate1 = GetPostString("finishdate1");
  11077. string finishDate2 = GetPostString("finishdate2");
  11078. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11079. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11080. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11081. dStruct.Order = "created desc";
  11082. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11083. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11084. writeGridDataTableJson(dStruct.TotalCount, dt);
  11085. }
  11086. public void get_erp_wechatlist_sumprice()
  11087. {
  11088. DataStruct dStruct = GetPostStruct();
  11089. List<string> lw = new List<string>();
  11090. string tid = GetPostString("tid");
  11091. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11092. string shopname = GetPostString("shopname");
  11093. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11094. string buyernick = GetPostString("buyer_nick");
  11095. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11096. string customer = GetPostString("customer");
  11097. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11098. string returndate1 = GetPostString("returndate1");
  11099. string returndate2 = GetPostString("returndate2");
  11100. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11101. if (dw.Length > 0) lw.Add(dw);
  11102. string finishDate1 = GetPostString("finishdate1");
  11103. string finishDate2 = GetPostString("finishdate2");
  11104. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11105. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11106. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11107. string mainWhere = string.Join(" and ", lw.ToArray());
  11108. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11109. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11110. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11111. decimal total = 0;
  11112. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11113. {
  11114. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11115. }
  11116. var res = new
  11117. {
  11118. data = total
  11119. };
  11120. string ro_jsond = JsonConvert.SerializeObject(res);
  11121. returnSuccess(ro_jsond);
  11122. return;
  11123. }
  11124. public void get_erp_qr_waitdeliverylist()
  11125. {
  11126. DataStruct dStruct = GetPostStruct();
  11127. List<string> lw = new List<string>();
  11128. string tid = GetPostString("ctid");
  11129. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11130. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11131. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11132. var res_objz = new
  11133. {
  11134. restype = 1,
  11135. data = dt
  11136. };
  11137. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11138. returnSuccess(ro_jsonz);
  11139. }
  11140. public void get_erp_yield_list()
  11141. {
  11142. DataStruct dStruct = GetPostStruct();
  11143. List<string> lw = new List<string>();
  11144. string tid = GetPostString("ctid");
  11145. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11146. string shopname = GetPostString("shopname");
  11147. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11148. string buyernick = GetPostString("buyer_nick");
  11149. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11150. //if (tid.Length == 0 && buyernick.Length == 0)
  11151. //{
  11152. // lw.Add(string.Format("IsRefund<={0}", 1));
  11153. //}
  11154. string customer = GetPostString("customer");
  11155. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11156. string design = GetPostString("design");
  11157. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11158. string orderState = GetPostString("orderState");
  11159. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11160. string address = GetPostString("address");
  11161. 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));
  11162. string sellermemo = GetPostString("seller_memo");
  11163. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11164. string supplier = GetPostString("supplier");
  11165. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11166. string OrderArea = GetPostString("order_area");
  11167. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11168. string placedate1 = GetPostString("placedate1");
  11169. string placedate2 = GetPostString("placedate2");
  11170. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11171. if (fdw.Length > 0) lw.Add(fdw);
  11172. string price1 = GetPostString("price1");
  11173. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11174. string price2 = GetPostString("price2");
  11175. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11176. string unusualCon = GetPostString("unusualcon");
  11177. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11178. string posTag = CurrentUser.UserPost.Post.Code;
  11179. if (posTag == "Supplier")
  11180. {
  11181. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11182. }
  11183. lw.Add(string.Format("OrderState = 6 "));
  11184. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11185. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11186. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11187. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11188. writeGridDataTableJson(dStruct.TotalCount, dt);
  11189. }
  11190. public void change_erp_sup_state()
  11191. {
  11192. if (UrlPostParmsCheck("ctid"))
  11193. {
  11194. string ctid = GetPostString("ctid");
  11195. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11196. if (ceErpTradeCell != null)
  11197. {
  11198. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11199. if (ceErpTradeCellExtend == null)
  11200. {
  11201. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11202. ceErpTradeCellExtend.ctid = ctid;
  11203. ceErpTradeCellExtend.SupState = 1;
  11204. ceErpTradeCellExtend.Create();
  11205. }
  11206. else
  11207. {
  11208. ceErpTradeCellExtend.SupState = 1;
  11209. ceErpTradeCellExtend.Update();
  11210. }
  11211. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11212. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11213. return;
  11214. }
  11215. returnErrorMsg("找不到订单");
  11216. }
  11217. }
  11218. public void supplier_all_downs()
  11219. {
  11220. if (UrlPostParmsCheck("tids"))
  11221. {
  11222. string tids = GetPostString("tids");
  11223. if (tids != null && tids.Length > 0)
  11224. {
  11225. StringBuilder sql = new StringBuilder();
  11226. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11227. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11228. sql = new StringBuilder();
  11229. 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, "下载设计文件");
  11230. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11231. string[] list = tids.Split(',');
  11232. foreach (string ctid in list)
  11233. {
  11234. CeErpSukuraData.createInfo(ctid, 3);
  11235. }
  11236. designHelper.api_approveDesign(tids); //approveDesign
  11237. returnSuccessMsg("下载成功!");
  11238. return;
  11239. }
  11240. returnErrorMsg("下载订单更新失败");
  11241. }
  11242. }
  11243. public void uploaderFileSuccess()
  11244. {
  11245. if (UrlPostParmsCheck("fileName"))
  11246. {
  11247. string fileName = GetPostString("fileName");
  11248. ApiVo apiVo = new ApiVo();
  11249. apiVo.orderNumber = fileName;
  11250. apiVo.actionName = "finishDesign";
  11251. designHelper.API_WorkCore(apiVo);//finishDesign
  11252. returnSuccessMsg("");
  11253. }
  11254. }
  11255. public void get_sample2_order()
  11256. {
  11257. if (UrlPostParmsCheck("ctid"))
  11258. {
  11259. string ctid = GetPostString("ctid");
  11260. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11261. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11262. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11263. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11264. double total = 0.0;
  11265. double order_price = 0.0;
  11266. if (dt_bu.Rows.Count > 0)
  11267. {
  11268. foreach (DataRow dr in dt_bu.Rows)
  11269. {
  11270. total += Convert.ToDouble(dr["payment"]);
  11271. }
  11272. }
  11273. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11274. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11275. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11276. string tid = ctid.Replace("S_", "");
  11277. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11278. double paymant = 0.0;
  11279. if (entity != null)
  11280. {
  11281. paymant = entity.payment;
  11282. }
  11283. string return_reason = "";
  11284. if (dt_after != null && dt_after.Rows.Count > 0)
  11285. {
  11286. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11287. }
  11288. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11289. }
  11290. }
  11291. public void get_erp_design_status()
  11292. {
  11293. string designName = GetPostString("designName");
  11294. DataStruct dStruct = GetPostStruct();
  11295. if (designName.Length > 0)
  11296. {
  11297. 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";
  11298. sql_user += " and Name like '%" + designName + "%'";
  11299. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11300. List<string> ids_list = new List<string>();
  11301. if (user_table.Rows.Count > 0)
  11302. {
  11303. foreach (DataRow item in user_table.Rows)
  11304. {
  11305. ids_list.Add(item["id"].ToString());
  11306. string ids_s = item["TeamIds"].ToString();
  11307. if (ids_s.Length > 0)
  11308. {
  11309. ids_list.AddRange(ids_s.Split(','));
  11310. }
  11311. }
  11312. }
  11313. HashSet<string> set = new HashSet<string>(ids_list);
  11314. ids_list = set.ToList();
  11315. if (ids_list.Count > 0)
  11316. {
  11317. 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));
  11318. dStruct.MainWhere = sql;
  11319. DataTable dt = null;
  11320. dt = WebCache.GetData("view_ErpUser", dStruct);
  11321. writeGridDataTableJson(dStruct.TotalCount, dt);
  11322. }
  11323. }
  11324. }
  11325. public void change_erp_order_price()
  11326. {
  11327. string ctid = GetPostString("ctid");
  11328. double price = GetPostDouble("price");
  11329. if (ctid.Length > 0)
  11330. {
  11331. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11332. if (ceErpTradeCellExtend == null)
  11333. {
  11334. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11335. ceErpTradeCellExtend.ctid = ctid;
  11336. ceErpTradeCellExtend.payment_cyt = price;
  11337. ceErpTradeCellExtend.Create();
  11338. }
  11339. else
  11340. {
  11341. ceErpTradeCellExtend.payment_cyt = price;
  11342. ceErpTradeCellExtend.Update();
  11343. }
  11344. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11345. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11346. {
  11347. ceErpDataSendOrderInfo.isSync = false;
  11348. ceErpDataSendOrderInfo.Update();
  11349. }
  11350. if (ceErpDataSendOrderInfo == null)
  11351. {
  11352. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11353. ceErpDataSendOrderInfo.isSync = false;
  11354. ceErpDataSendOrderInfo.ctid = ctid;
  11355. ceErpDataSendOrderInfo.Create();
  11356. }
  11357. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11358. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11359. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11360. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11361. {
  11362. dataSendOrderBean dataSendOrderBean = null;
  11363. foreach (DataRow item in dth.Rows)
  11364. {
  11365. try
  11366. {
  11367. dataSendOrderBean = new dataSendOrderBean();
  11368. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11369. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11370. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11371. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11372. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11373. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11374. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11375. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11376. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11377. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11378. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11379. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11380. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11381. if (result != null)
  11382. {
  11383. if ("0".Equals(result.errcode))
  11384. {
  11385. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11386. }
  11387. else
  11388. {
  11389. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11390. }
  11391. }
  11392. }
  11393. catch (Exception ex)
  11394. {
  11395. }
  11396. }
  11397. }
  11398. returnSuccessMsg("修改成功!");
  11399. return;
  11400. }
  11401. returnErrorMsg("找不到订单");
  11402. }
  11403. public void find_he_together()
  11404. {
  11405. string ctid = GetPostString("ctid");
  11406. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11407. List<string> list = new List<string>();
  11408. if (ceErpTradeCell != null)
  11409. {
  11410. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11411. {
  11412. 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);
  11413. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11414. if (table != null && table.Rows.Count > 0)
  11415. {
  11416. foreach (TableRow row in table.Rows)
  11417. {
  11418. }
  11419. }
  11420. }
  11421. }
  11422. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11423. }
  11424. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11425. {
  11426. //chy----19
  11427. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11428. //GD-CYT-----64
  11429. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11430. //ZHX----3
  11431. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11432. //JK----97
  11433. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11434. //ZT----70
  11435. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11436. //GD-CYTUV---126
  11437. {126, new Dictionary<string, string> {{"uv", "uv"}}},
  11438. //LHCY-----98
  11439. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11440. //XD-----90
  11441. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11442. //CYCY-----14
  11443. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11444. };
  11445. //其他改名
  11446. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11447. {
  11448. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11449. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11450. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11451. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11452. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11453. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11454. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11455. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11456. };
  11457. //不统计
  11458. List<int> no_suppliers = new List<int>()
  11459. {
  11460. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11461. };
  11462. //配件单
  11463. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11464. {
  11465. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11466. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11467. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11468. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11469. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11470. {"旗杆",new List<string>(){ "班旗" } },
  11471. {"牙签",new List<string>(){ "不干胶" } }
  11472. };
  11473. public void get_place_order_data()
  11474. {
  11475. string date1 = GetPostString("date1");
  11476. string date2 = GetPostString("date2");
  11477. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11478. DateTime start = DateTime.Parse(starttime);
  11479. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11480. DateTime end = DateTime.Parse(endtime);
  11481. if (date1 != null && date1.Length > 0)
  11482. {
  11483. DateTime dateTime = DateTime.Parse(date1);
  11484. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11485. start = DateTime.Parse(starttime);
  11486. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11487. end = DateTime.Parse(endtime);
  11488. }
  11489. if (date2 != null && date2.Length > 0)
  11490. {
  11491. DateTime dateTime = DateTime.Parse(date2);
  11492. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11493. end = DateTime.Parse(endtime);
  11494. }
  11495. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,UnusualTime,FinishPlaceTime,OrderState,FinishDeliveryTime from view_ErpTradeCell where ( ( FinishPlaceTime BETWEEN '{0}' AND '{1}' ) OR ( OrderState = 6 AND UnusualTag = 5 AND IsRefund <= 1 ) ) AND IsSample = 0 and SupplierName is not null ", starttime, endtime);
  11496. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11497. //不干胶-----1,卡片-----29
  11498. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11499. foreach (DataRow row in data.Rows)
  11500. {
  11501. int productId = Convert.ToInt32(row["ProductId"]);
  11502. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11503. if (no_suppliers.Contains(supplierId))
  11504. {
  11505. continue;
  11506. }
  11507. string seller_memo = row["seller_memo"].ToString();
  11508. bool ispj = false;//是否配件单
  11509. bool isfirst = true;//第一个配
  11510. maps.Keys.ForEach(key =>
  11511. {
  11512. //备注包含配件
  11513. if (seller_memo.Contains(key) && isfirst)
  11514. {
  11515. List<string> list = maps[key];
  11516. ispj = true;
  11517. isfirst = false;
  11518. for (int i = 0; i < list.Count; i++)
  11519. {
  11520. if (seller_memo.Contains(list[i]))
  11521. {
  11522. ispj = false;
  11523. break;
  11524. }
  11525. }
  11526. }
  11527. });
  11528. if (ispj)
  11529. {
  11530. continue;
  11531. }
  11532. seller_memo = seller_memo.Replace("UV", "uv");
  11533. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11534. //吊牌归到卡片
  11535. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11536. seller_memo = seller_memo.Replace("卡套", "卡片");
  11537. seller_memo = seller_memo.Replace("封套", "卡片");
  11538. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11539. seller_memo = seller_memo.Replace("腰封", "卡片");
  11540. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11541. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11542. seller_memo = seller_memo.Replace("横幅", "条幅");
  11543. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11544. string map_key = "";
  11545. string type = "";
  11546. if (supplierMap.ContainsKey(supplierId))
  11547. {
  11548. foreach (var kvp in supplierMap[supplierId])
  11549. {
  11550. if (seller_memo.Contains(kvp.Key))
  11551. {
  11552. map_key = kvp.Value;
  11553. type = kvp.Value;
  11554. break;
  11555. }
  11556. }
  11557. }
  11558. if (map_key == "")
  11559. {
  11560. type = "其他";
  11561. map_key = "其他";
  11562. }
  11563. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11564. {
  11565. map_key = suppliers[supplierId];
  11566. }
  11567. if (supplierId == 70)
  11568. {
  11569. supplierId = 70;
  11570. }
  11571. map_key += "_" + row["SupplierName"].ToString();
  11572. Dictionary<string, int> map = null;
  11573. if (other_map.ContainsKey(map_key))
  11574. {
  11575. other_map.TryGetValue(map_key, out map);
  11576. }
  11577. else
  11578. {
  11579. map = new Dictionary<string, int>();
  11580. map.Add("dayDev", 0);//当天出货
  11581. map.Add("dayTotal", 0);//下单总数
  11582. map.Add("payTotal", 0);//500以上
  11583. map.Add("today", 0);//当天出货数量
  11584. map.Add("unusua", 0);//异常数
  11585. other_map.Add(map_key, map);
  11586. other_map.TryGetValue(map_key, out map);
  11587. }
  11588. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11589. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11590. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11591. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11592. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11593. {
  11594. map["dayTotal"]++;
  11595. if (supplierId == 97)
  11596. {
  11597. supplierId = 97;
  11598. }
  11599. }
  11600. if (Convert.ToDecimal(row["payment"]) >= 500)
  11601. {
  11602. map["payTotal"]++;
  11603. }
  11604. bool istoday = false;
  11605. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11606. {
  11607. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11608. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11609. {
  11610. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11611. {
  11612. map["today"]++;
  11613. }
  11614. }
  11615. else
  11616. {
  11617. if (supplierId == 80)
  11618. {
  11619. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11620. {
  11621. map["today"]++;
  11622. }
  11623. }
  11624. else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11625. {
  11626. map["today"]++;
  11627. istoday = true;
  11628. }
  11629. }
  11630. }
  11631. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11632. {
  11633. map["unusua"]++;
  11634. }
  11635. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11636. //GD-CYT-----64
  11637. DateTime two = palceTimeStart.AddHours(14);
  11638. DateTime three = palceTimeStart.AddHours(15);
  11639. DateTime four = palceTimeStart.AddHours(16);
  11640. DateTime six = palceTimeStart.AddHours(18);
  11641. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11642. {
  11643. //下午四点前 500-1000
  11644. string count = row["ProductCount"].ToString();
  11645. if (count != null && count.Length > 0)
  11646. {
  11647. int productCount = commonHelper.getPlaceProductCount(count);
  11648. if (productCount >= 500 && productCount <= 1000)
  11649. {
  11650. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11651. {
  11652. map["dayDev"]++;
  11653. }
  11654. }
  11655. }
  11656. }
  11657. //UV
  11658. else if ("uv".Equals(type))
  11659. {
  11660. //ZT----70
  11661. //ZHX----3
  11662. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11663. {
  11664. map["dayDev"]++;
  11665. }
  11666. //JK----97
  11667. //HZX----105
  11668. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11669. {
  11670. map["dayDev"]++;
  11671. }
  11672. if (DateTime.Compare(FinishPlaceTime, six) < 0 && (supplierId == 126))
  11673. {
  11674. map["dayDev"]++;
  11675. }
  11676. }
  11677. //帆布---52|条幅---27
  11678. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11679. {
  11680. //LHCY-----98
  11681. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11682. {
  11683. map["dayDev"]++;
  11684. }
  11685. }
  11686. //条幅
  11687. else if ("条幅".Equals(type))
  11688. {
  11689. //XD-----90
  11690. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11691. {
  11692. map["dayDev"]++;
  11693. }
  11694. }
  11695. //桌布
  11696. else if ("桌布".Equals(type))
  11697. {
  11698. //XD-----90
  11699. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11700. {
  11701. map["dayDev"]++;
  11702. }
  11703. }
  11704. //DL---10
  11705. //AYTW---119
  11706. //FS-CYT-DY ----80
  11707. //JK----97
  11708. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11709. {
  11710. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11711. {
  11712. map["dayDev"]++;
  11713. if (supplierId == 80 && istoday)
  11714. {
  11715. Debug.WriteLine(seller_memo);
  11716. }
  11717. }
  11718. }
  11719. // QC---121
  11720. else if (supplierId == 121)
  11721. {
  11722. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11723. {
  11724. map["dayDev"]++;
  11725. }
  11726. }
  11727. }
  11728. DataTable dt = new DataTable();
  11729. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11730. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11731. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11732. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11733. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11734. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11735. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11736. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11737. other_map.Keys.ForEach(key =>
  11738. {
  11739. DataRow dr = dt.NewRow();
  11740. Dictionary<string, int> map = other_map[key];
  11741. string[] key_list = key.Split('_');
  11742. dr[0] = key_list[0];
  11743. dr[1] = key_list[1];
  11744. if (key_list.Length > 2)
  11745. {
  11746. dr[1] += "(" + key_list[2] + ")";
  11747. }
  11748. dr[2] = map["dayTotal"];
  11749. dr[3] = map["payTotal"];
  11750. dr[4] = map["today"];
  11751. dr[5] = map["unusua"];
  11752. dr[6] = map["dayDev"];
  11753. double rate = 0.00;
  11754. if (map["dayDev"] > 0)
  11755. {
  11756. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11757. }
  11758. dr[7] = rate.ToString();
  11759. dt.Rows.Add(dr);
  11760. });
  11761. DataView dv = new DataView(dt);
  11762. dv.Sort = "SupplierName";
  11763. //dv.Sort = "AllOrder desc";
  11764. DataTable dtNew = dv.ToTable();
  11765. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11766. }
  11767. public void check_order_desing_info()
  11768. {
  11769. string ctid = GetPostString("ctid");
  11770. if (!string.IsNullOrEmpty(ctid))
  11771. {
  11772. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11773. if (ceErpTradeCell != null)
  11774. {
  11775. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11776. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11777. return;
  11778. }
  11779. returnErrorMsg("找不到订单");
  11780. return;
  11781. }
  11782. returnErrorMsg("找不到订单");
  11783. }
  11784. public void get_timeout_detail()
  11785. {
  11786. string poscode = CurrentUser.UserPost.Post.Code;
  11787. DataStruct dStruct = GetPostStruct();
  11788. List<string> lw = new List<string>();
  11789. string id = GetPostString("id");
  11790. string pay_date1 = GetPostString("pay_date1");
  11791. string pay_date2 = GetPostString("pay_date2");
  11792. int type = GetPostInt("type");
  11793. if (type == 0)
  11794. {
  11795. if (pay_date1.Length > 0)
  11796. {
  11797. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11798. }
  11799. if (pay_date2.Length > 0)
  11800. {
  11801. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11802. }
  11803. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11804. }
  11805. if (type == 1)
  11806. {
  11807. if (pay_date1.Length > 0)
  11808. {
  11809. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11810. }
  11811. if (pay_date2.Length > 0)
  11812. {
  11813. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11814. }
  11815. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11816. }
  11817. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11818. DataTable dt = null;
  11819. dt = WebCache.GetData("view_orderlist", dStruct);
  11820. writeGridDataTableJson(dStruct.TotalCount, dt);
  11821. }
  11822. public void saveUrgentChargePrice()
  11823. {
  11824. string ctid = GetPostString("ctid");
  11825. if (!string.IsNullOrEmpty(ctid))
  11826. {
  11827. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11828. if (ceErpTradeCell != null)
  11829. {
  11830. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11831. if (prices <= 100)
  11832. {
  11833. returnErrorMsg("此订单金额不足100元,无法加急。");
  11834. return;
  11835. }
  11836. double price = GetPostDouble("price");
  11837. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11838. if (ceErpTradeCellExtend == null)
  11839. {
  11840. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11841. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11842. }
  11843. ceErpTradeCellExtend.urgentCharge = price;
  11844. if (ceErpTradeCellExtend.ID > 0)
  11845. {
  11846. ceErpTradeCellExtend.Update();
  11847. }
  11848. else
  11849. {
  11850. ceErpTradeCellExtend.Save();
  11851. }
  11852. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11853. returnSuccessMsg("修改成功!");
  11854. return;
  11855. }
  11856. returnErrorMsg("找不到订单");
  11857. return;
  11858. }
  11859. returnErrorMsg("找不到订单");
  11860. }
  11861. public void finish_erp_order()
  11862. {
  11863. string ctid = GetPostString("ctid");
  11864. if (!string.IsNullOrEmpty(ctid))
  11865. {
  11866. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11867. {
  11868. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11869. if (ceErpTradeCell != null)
  11870. {
  11871. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11872. ceErpTradeCell.Update();
  11873. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11874. returnSuccessMsg("修改成功!");
  11875. return;
  11876. }
  11877. }
  11878. }
  11879. returnErrorMsg("找不到订单");
  11880. }
  11881. public void get_trade_order_list()
  11882. {
  11883. string tid = GetPostString("tid");
  11884. if (!string.IsNullOrEmpty(tid))
  11885. {
  11886. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11887. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11888. writeGridDataTableJson(data.Rows.Count, data);
  11889. return;
  11890. }
  11891. returnErrorMsg("找不到订单");
  11892. }
  11893. public void save_cell_spu()
  11894. {
  11895. string ctid = GetPostString("ctid");
  11896. string spu_id = GetPostString("spu_id");
  11897. if (!string.IsNullOrEmpty(ctid))
  11898. {
  11899. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11900. if (ceErpTradeCellExtend == null)
  11901. {
  11902. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11903. ceErpTradeCellExtend.ctid = ctid;
  11904. }
  11905. ceErpTradeCellExtend.spu_id = spu_id;
  11906. if (!string.IsNullOrEmpty(spu_id))
  11907. {
  11908. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11909. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11910. }
  11911. if (ceErpTradeCellExtend.ID == 0)
  11912. {
  11913. ceErpTradeCellExtend.Create();
  11914. }
  11915. else
  11916. {
  11917. ceErpTradeCellExtend.Update();
  11918. }
  11919. returnSuccessMsg("修改成功!");
  11920. return;
  11921. }
  11922. returnErrorMsg("找不到订单");
  11923. }
  11924. public void change_express_info()
  11925. {
  11926. string ctid = GetPostString("ctid");
  11927. string transNo = GetPostString("transNo");
  11928. string transCom = GetPostString("transCom");
  11929. if (!string.IsNullOrEmpty(ctid))
  11930. {
  11931. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11932. if (ceErpTradeCellExtend == null)
  11933. {
  11934. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11935. ceErpTradeCellExtend.ctid = ctid;
  11936. }
  11937. ceErpTradeCellExtend.modExpressNo = transNo;
  11938. ceErpTradeCellExtend.modExpressCom = transCom;
  11939. ceErpTradeCellExtend.readMod = 2;
  11940. if (ceErpTradeCellExtend.ID == 0)
  11941. {
  11942. ceErpTradeCellExtend.Create();
  11943. }
  11944. else
  11945. {
  11946. ceErpTradeCellExtend.Update();
  11947. }
  11948. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11949. returnSuccessMsg("修改成功!");
  11950. return;
  11951. }
  11952. returnErrorMsg("找不到订单");
  11953. }
  11954. public void get_change_express_list()
  11955. {
  11956. DataStruct dStruct = GetPostStruct();
  11957. List<string> lw = new List<string>();
  11958. int st = 2;
  11959. string tid = GetPostString("ctid");
  11960. if (tid.Length > 0)
  11961. {
  11962. string select_tid = getTidByCtid(tid);
  11963. lw.Add(string.Format("tid='{0}'", select_tid));
  11964. }
  11965. string shopname = GetPostString("shopname");
  11966. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11967. string buyernick = GetPostString("buyer_nick");
  11968. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11969. string sellermemo = GetPostString("seller_memo");
  11970. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11971. string supplier = GetPostString("supplier");
  11972. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11973. string customer = GetPostString("customer");
  11974. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11975. string design = GetPostString("design");
  11976. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11977. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11978. string poscode = CurrentUser.UserPost.Post.Code;
  11979. if (poscode != "SysAdmin")
  11980. {
  11981. string shopid = CurrentUser.User.pemShop;
  11982. lw.Add(string.Format("shopId in ({0})", shopid));
  11983. }
  11984. lw.Add("readMod = 2");
  11985. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11986. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11987. writeGridDataTableJson(dStruct.TotalCount, dt);
  11988. }
  11989. public void deal_express_complete()
  11990. {
  11991. string ctid = GetPostString("ctid");
  11992. if (!string.IsNullOrEmpty(ctid))
  11993. {
  11994. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11995. if (ceErpTradeCellExtend == null)
  11996. {
  11997. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11998. ceErpTradeCellExtend.ctid = ctid;
  11999. }
  12000. ceErpTradeCellExtend.readMod = 1;
  12001. if (ceErpTradeCellExtend.ID == 0)
  12002. {
  12003. ceErpTradeCellExtend.Create();
  12004. }
  12005. else
  12006. {
  12007. ceErpTradeCellExtend.Update();
  12008. }
  12009. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  12010. returnSuccessMsg("修改成功!");
  12011. return;
  12012. }
  12013. returnErrorMsg("找不到订单");
  12014. }
  12015. public void aftersale_return_visit()
  12016. {
  12017. string ctid = GetPostString("ctid");
  12018. if (!string.IsNullOrEmpty(ctid))
  12019. {
  12020. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12021. if (ceErpTradeCellExtend == null)
  12022. {
  12023. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12024. ceErpTradeCellExtend.ctid = ctid;
  12025. }
  12026. ceErpTradeCellExtend.returnVisit = 1;
  12027. if (ceErpTradeCellExtend.ID == 0)
  12028. {
  12029. ceErpTradeCellExtend.Create();
  12030. }
  12031. else
  12032. {
  12033. ceErpTradeCellExtend.Update();
  12034. }
  12035. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12036. if (ceErpTradeAfterSaleExtend != null)
  12037. {
  12038. ceErpTradeAfterSaleExtend.TextResult = "";
  12039. ceErpTradeAfterSaleExtend.Update();
  12040. }
  12041. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  12042. returnSuccessMsg("修改成功!");
  12043. return;
  12044. }
  12045. returnErrorMsg("找不到订单");
  12046. }
  12047. public void orderPlaceInfo()
  12048. {
  12049. string ctids = GetPostString("ctids");
  12050. string[] list = ctids.Split(',');
  12051. foreach (string ctid in list)
  12052. {
  12053. CeErpSukuraData.createInfo(ctid, 3);
  12054. }
  12055. StringBuilder sql = new StringBuilder();
  12056. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  12057. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  12058. designHelper.api_approveDesign(ctids); //approveDesign
  12059. returnSuccessMsg("");
  12060. }
  12061. public void get_issue_list()
  12062. {
  12063. DataStruct dStruct = GetPostStruct();
  12064. List<string> lw = new List<string>();
  12065. int st = 2;
  12066. string tid = GetPostString("ctid");
  12067. if (tid.Length > 0)
  12068. {
  12069. string select_tid = getTidByCtid(tid);
  12070. lw.Add(string.Format("tid='{0}'", select_tid));
  12071. }
  12072. string shopname = GetPostString("shopname");
  12073. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12074. string buyernick = GetPostString("buyer_nick");
  12075. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12076. string sellermemo = GetPostString("seller_memo");
  12077. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12078. string supplier = GetPostString("supplier");
  12079. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12080. string customer = GetPostString("customer");
  12081. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12082. string design = GetPostString("design");
  12083. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12084. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12085. string poscode = CurrentUser.UserPost.Post.Code;
  12086. if (poscode != "SysAdmin")
  12087. {
  12088. string shopid = CurrentUser.User.pemShop;
  12089. lw.Add(string.Format("shopId in ({0})", shopid));
  12090. }
  12091. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12092. {
  12093. lw.Add("IssueState = 1");
  12094. }
  12095. else
  12096. {
  12097. string iisstate = GetPostString("iisstate");
  12098. if ("1".Equals(iisstate))
  12099. {
  12100. lw.Add("IssueState =1");
  12101. }
  12102. else if ("2".Equals(iisstate))
  12103. {
  12104. lw.Add("IssueState = 2");
  12105. }
  12106. else
  12107. {
  12108. lw.Add("IssueState > 0");
  12109. }
  12110. }
  12111. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12112. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12113. writeGridDataTableJson(dStruct.TotalCount, dt);
  12114. }
  12115. public void saveIssueContent()
  12116. {
  12117. string ctid = GetPostString("ctid");
  12118. if (!string.IsNullOrEmpty(ctid))
  12119. {
  12120. string content = GetPostString("content");
  12121. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12122. if (ceErpTradeAfterSaleExtend == null)
  12123. {
  12124. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12125. ceErpTradeAfterSaleExtend.tid = ctid;
  12126. }
  12127. ceErpTradeAfterSaleExtend.IssueContent = content;
  12128. ceErpTradeAfterSaleExtend.IssueState = 1;
  12129. if (ceErpTradeAfterSaleExtend.ID > 0)
  12130. {
  12131. ceErpTradeAfterSaleExtend.Update();
  12132. }
  12133. else
  12134. {
  12135. ceErpTradeAfterSaleExtend.Create();
  12136. }
  12137. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12138. returnSuccessMsg("添加成功!");
  12139. return;
  12140. }
  12141. returnErrorMsg("找不到订单");
  12142. }
  12143. public void dealIssueContent()
  12144. {
  12145. string ctid = GetPostString("ctid");
  12146. if (!string.IsNullOrEmpty(ctid))
  12147. {
  12148. string content = GetPostString("content");
  12149. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12150. if (ceErpTradeAfterSaleExtend != null)
  12151. {
  12152. ceErpTradeAfterSaleExtend.IssueState = 2;
  12153. ceErpTradeAfterSaleExtend.Update();
  12154. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12155. returnSuccessMsg("修改完成!");
  12156. return;
  12157. }
  12158. }
  12159. returnErrorMsg("找不到订单");
  12160. }
  12161. public void set_tid_attachments()
  12162. {
  12163. string tid = GetPostString("tid");
  12164. string atta = GetPostString("atta");
  12165. if (!string.IsNullOrEmpty(tid))
  12166. {
  12167. if (string.IsNullOrEmpty(atta))
  12168. {
  12169. returnErrorMsg("文件地址为空");
  12170. return;
  12171. }
  12172. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12173. if (ceErpTradeCell != null)
  12174. {
  12175. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12176. if (ceErpTrade == null)
  12177. {
  12178. returnErrorMsg("找不到订单");
  12179. return;
  12180. }
  12181. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12182. bool isSend = false;
  12183. if (dt != null && dt.Rows.Count > 0)
  12184. {
  12185. foreach (DataRow row in dt.Rows)
  12186. {
  12187. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12188. {
  12189. isSend = true;
  12190. }
  12191. }
  12192. if (isSend)
  12193. {
  12194. returnErrorMsg("已发货无法修改");
  12195. return;
  12196. }
  12197. ceErpTrade.Attachments = atta;
  12198. ceErpTrade.Update();
  12199. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12200. returnSuccessMsg("上传成功!");
  12201. return;
  12202. }
  12203. }
  12204. }
  12205. returnErrorMsg("找不到订单");
  12206. }
  12207. public void get_tid_attachments()
  12208. {
  12209. string tid = GetPostString("tid");
  12210. if (!string.IsNullOrEmpty(tid))
  12211. {
  12212. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12213. if (ceErpTradeCell != null)
  12214. {
  12215. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12216. if (ceErpTrade == null)
  12217. {
  12218. returnErrorMsg("找不到订单");
  12219. return;
  12220. }
  12221. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12222. return;
  12223. }
  12224. }
  12225. returnErrorMsg("找不到订单");
  12226. }
  12227. public void check_erp_sameorders()
  12228. {
  12229. if (UrlPostParmsCheck("ctid"))
  12230. {
  12231. string eid = GetPostString("ctid");
  12232. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12233. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12234. if (entity != null && ceErpTrade != null)
  12235. {
  12236. if (entity.OrderState > 6)
  12237. {
  12238. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12239. return;
  12240. }
  12241. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12242. List<string> ids = new List<string>();
  12243. if (dt != null && dt.Rows.Count > 1)
  12244. {
  12245. bool needhe = true;
  12246. foreach (DataRow dr in dt.Rows)
  12247. {
  12248. ids.Add("'" + dr["ctid"] + "'");
  12249. /* //备注有合包
  12250. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12251. {
  12252. needhe = true;
  12253. }
  12254. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12255. {
  12256. needhe = true;
  12257. }
  12258. //顺丰快递
  12259. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12260. {
  12261. needhe = true;
  12262. }*/
  12263. }
  12264. if (!needhe)
  12265. {
  12266. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12267. return;
  12268. }
  12269. StringBuilder sql = new StringBuilder();
  12270. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12271. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12272. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12273. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12274. foreach (DataRow dr in dt.Rows)
  12275. {
  12276. dr["dstate"] = 0;
  12277. dr["dnumber"] = 0;
  12278. foreach (DataRow row in dt1.Rows)
  12279. {
  12280. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12281. {
  12282. dr["dstate"] = 2;
  12283. dr["default"] = 1;
  12284. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12285. }
  12286. }
  12287. if (eid.Equals(dr["ctid"].ToString()))
  12288. {
  12289. dr["dstate"] = 1;
  12290. dr["default"] = 1;
  12291. }
  12292. }
  12293. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12294. return;
  12295. }
  12296. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12297. return;
  12298. }
  12299. returnErrorMsg("未找到订单");
  12300. return;
  12301. }
  12302. returnErrorMsg("缺少必要的参数");
  12303. }
  12304. public void get_mark_number()
  12305. {
  12306. string eid = GetPostString("ctid");
  12307. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12308. if (entity != null)
  12309. {
  12310. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12311. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12312. int current = 1;
  12313. if (ceErpDeliverMark == null)
  12314. {
  12315. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12316. List<string> ids = new List<string>();
  12317. if (dt != null && dt.Rows.Count > 1)
  12318. {
  12319. foreach (DataRow dr in dt.Rows)
  12320. {
  12321. ids.Add("'" + dr["ctid"] + "'");
  12322. }
  12323. //查询已有的编号
  12324. StringBuilder sql = new StringBuilder();
  12325. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12326. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12327. if (dt1 == null || dt1.Rows.Count == 0)
  12328. {
  12329. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12330. List<int> list_number = new List<int>();
  12331. foreach (DataRow row in numbers.Rows)
  12332. {
  12333. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12334. }
  12335. //查询空余编号
  12336. for (int i = 0; i < list_number.Count + 2; i++)
  12337. {
  12338. if (!list_number.Contains(current))
  12339. {
  12340. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12341. //防止查询过程中有新数据生成
  12342. if (ceErpDeliverMark1 == null)
  12343. {
  12344. break;
  12345. }
  12346. }
  12347. current++;
  12348. }
  12349. }
  12350. else
  12351. {
  12352. foreach (DataRow row in dt1.Rows)
  12353. {
  12354. current = Convert.ToInt32(row["markNumber"]);
  12355. }
  12356. }
  12357. ceErpDeliverMark = new CeErpDeliverMark();
  12358. ceErpDeliverMark.ctid = eid;
  12359. ceErpDeliverMark.createtime = DateTime.Now;
  12360. if (ceErpTrade != null)
  12361. {
  12362. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12363. }
  12364. ceErpDeliverMark.markNumber = current;
  12365. ceErpDeliverMark.Create();
  12366. }
  12367. }
  12368. else
  12369. {
  12370. current = ceErpDeliverMark.markNumber;
  12371. }
  12372. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12373. return;
  12374. }
  12375. }
  12376. public void aftersaleCytSend()
  12377. {
  12378. string ctid = GetPostString("ctid");
  12379. if (!string.IsNullOrEmpty(ctid))
  12380. {
  12381. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12382. if (ceErpTradeCell != null)
  12383. {
  12384. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12385. }
  12386. returnSuccessMsg("推送成功");
  12387. return;
  12388. }
  12389. returnErrorMsg("缺少必要的参数");
  12390. }
  12391. public void packOrderInfo()
  12392. {
  12393. string ctids = GetPostString("ctids");
  12394. if (!string.IsNullOrEmpty(ctids))
  12395. {
  12396. string[] ctid_list = ctids.Split(',');
  12397. if (ctid_list.Length > 20)
  12398. {
  12399. returnErrorMsg("单次下载次数不能超过20个");
  12400. return;
  12401. }
  12402. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12403. StringBuilder sql = new StringBuilder();
  12404. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12405. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12406. int supplierId = 0;
  12407. StringBuilder insterSql = new StringBuilder();
  12408. for (int i = 0; i < dt.Rows.Count; i++)
  12409. {
  12410. DataRow row = dt.Rows[i];
  12411. if (i == 0)
  12412. {
  12413. supplierId = Convert.ToInt32(row["SupplierId"]);
  12414. }
  12415. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12416. {
  12417. returnErrorMsg("同车间的订单才能一起打包");
  12418. return;
  12419. }
  12420. int orderState = Convert.ToInt32(row["OrderState"]);
  12421. if (orderState != 5)
  12422. {
  12423. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12424. return;
  12425. }
  12426. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12427. }
  12428. CeErpPackData ceErpPackData = new CeErpPackData();
  12429. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12430. ceErpPackData.supplierId = supplierId;
  12431. ceErpPackData.createtime = DateTime.Now;
  12432. ceErpPackData.createBy = CurrentUser.UserID;
  12433. ceErpPackData.createName = CurrentUser.UserName;
  12434. ceErpPackData.Create();
  12435. if (ceErpPackData.ID > 0)
  12436. {
  12437. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12438. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12439. }
  12440. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12441. returnSuccessMsg("打包成功");
  12442. return;
  12443. }
  12444. returnErrorMsg("缺少必要的参数");
  12445. }
  12446. public void rePackOrderInfo()
  12447. {
  12448. string id = GetPostString("id");
  12449. if (!string.IsNullOrEmpty(id))
  12450. {
  12451. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12452. if (ceErpPackData == null)
  12453. {
  12454. returnSuccessMsg("查无数据");
  12455. return;
  12456. }
  12457. ceErpPackData.upStatus = 0;
  12458. ceErpPackData.message = "";
  12459. ceErpPackData.Update();
  12460. returnSuccessMsg("打包成功");
  12461. return;
  12462. }
  12463. returnErrorMsg("缺少必要的参数");
  12464. }
  12465. public void backPackOrderInfo()
  12466. {
  12467. string id = GetPostString("id");
  12468. if (!string.IsNullOrEmpty(id))
  12469. {
  12470. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12471. if (ceErpPackData == null)
  12472. {
  12473. returnSuccessMsg("查无数据");
  12474. return;
  12475. }
  12476. ceErpPackData.upStatus = 4;
  12477. ceErpPackData.Update();
  12478. List<string> list = new List<string>();
  12479. StringBuilder sql = new StringBuilder();
  12480. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12481. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12482. for (int i = 0; i < dt.Rows.Count; i++)
  12483. {
  12484. DataRow row = dt.Rows[i];
  12485. list.Add("'" + row["ctid"].ToString() + "'");
  12486. }
  12487. string textCtids = string.Join(",", list);
  12488. 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));
  12489. 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, "无法打包退回"));
  12490. returnSuccessMsg("退回成功");
  12491. return;
  12492. }
  12493. returnErrorMsg("缺少必要的参数");
  12494. }
  12495. public void addPackDownNum()
  12496. {
  12497. string id = GetPostString("id");
  12498. if (!string.IsNullOrEmpty(id))
  12499. {
  12500. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12501. returnSuccessMsg("下载成功");
  12502. return;
  12503. }
  12504. returnErrorMsg("缺少必要的参数");
  12505. }
  12506. public void get_pack_list()
  12507. {
  12508. DataStruct dStruct = GetPostStruct();
  12509. List<string> lw = new List<string>();
  12510. string supplier = GetPostString("supplier");
  12511. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12512. string posTag = CurrentUser.UserPost.Post.Code;
  12513. if (posTag == "Supplier")
  12514. {
  12515. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12516. }
  12517. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12518. dStruct.Order = "createtime desc";
  12519. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12520. writeGridDataTableJson(dStruct.TotalCount, dt);
  12521. }
  12522. public void get_pack_order_list()
  12523. {
  12524. string packId = GetPostString("packId");
  12525. if (string.IsNullOrEmpty(packId))
  12526. {
  12527. returnErrorMsg("缺少必要的参数");
  12528. return;
  12529. }
  12530. StringBuilder sql = new StringBuilder();
  12531. 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);
  12532. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12533. if (dt == null || dt.Rows.Count == 0)
  12534. {
  12535. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12536. return;
  12537. }
  12538. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12539. return;
  12540. }
  12541. public void get_supplier_product_time_list()
  12542. {
  12543. DataStruct dStruct = GetPostStruct();
  12544. List<string> lw = new List<string>();
  12545. string supplier = GetPostString("supplier");
  12546. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12547. string posTag = CurrentUser.UserPost.Post.Code;
  12548. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12549. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12550. writeGridDataTableJson(dStruct.TotalCount, dt);
  12551. }
  12552. public void saveSupplierProductTime()
  12553. {
  12554. string productId = GetPostString("productId");
  12555. if (string.IsNullOrEmpty(productId))
  12556. {
  12557. returnErrorMsg("缺少必要的参数");
  12558. return;
  12559. }
  12560. string productName = GetPostString("productName");
  12561. int supplierId = GetPostInt("supplierId");
  12562. if (supplierId == 0)
  12563. {
  12564. returnErrorMsg("缺少必要的参数");
  12565. return;
  12566. }
  12567. int quantity = GetPostInt("quantity");
  12568. int sendDay = GetPostInt("sendTime");
  12569. string supplierName = GetPostString("supplierName");
  12570. string craft = GetPostString("craft");
  12571. string deadLine = GetPostString("deadLine");
  12572. string dayDeadLine = GetPostString("dayDeadLine");
  12573. try
  12574. {
  12575. int eid = GetPostInt("eid");
  12576. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12577. if (ceErpSupplierProductTime == null)
  12578. {
  12579. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12580. }
  12581. ceErpSupplierProductTime.productId = productId;
  12582. ceErpSupplierProductTime.productName = productName;
  12583. ceErpSupplierProductTime.supplierId = supplierId;
  12584. ceErpSupplierProductTime.supplierName = supplierName;
  12585. ceErpSupplierProductTime.craft = craft;
  12586. ceErpSupplierProductTime.sendDay = sendDay;
  12587. ceErpSupplierProductTime.quantity = quantity;
  12588. if (!string.IsNullOrEmpty(deadLine))
  12589. {
  12590. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12591. }
  12592. if (!string.IsNullOrEmpty(dayDeadLine))
  12593. {
  12594. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12595. }
  12596. if (ceErpSupplierProductTime.ID == 0)
  12597. {
  12598. ceErpSupplierProductTime.Save();
  12599. }
  12600. else
  12601. {
  12602. ceErpSupplierProductTime.Update();
  12603. }
  12604. }
  12605. catch (Exception e)
  12606. {
  12607. }
  12608. returnSuccessMsg("保存成功");
  12609. return;
  12610. }
  12611. public void delSupplierProductTime()
  12612. {
  12613. int eid = GetPostInt("eid");
  12614. if (eid > 0)
  12615. {
  12616. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12617. if (ceErpSupplierProductTime == null)
  12618. {
  12619. returnErrorMsg("查无数据");
  12620. return;
  12621. }
  12622. ceErpSupplierProductTime.Delete();
  12623. returnSuccessMsg("保存成功");
  12624. return;
  12625. }
  12626. returnErrorMsg("缺少必要的参数");
  12627. }
  12628. public void getExpressInfo()
  12629. {
  12630. string ctid = GetPostString("ctid");
  12631. if (!string.IsNullOrEmpty(ctid))
  12632. {
  12633. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12634. if (ceErpTradeCell != null)
  12635. {
  12636. string outSid = ceErpTradeCell.OutSid;
  12637. if (outSid.Length > 0)
  12638. {
  12639. 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);
  12640. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12641. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12642. return;
  12643. }
  12644. }
  12645. returnErrorMsg("查无记录");
  12646. return;
  12647. }
  12648. returnErrorMsg("缺少必要的参数");
  12649. }
  12650. public void getExpressPostData()
  12651. {
  12652. string express = GetPostString("express");
  12653. if (!string.IsNullOrEmpty(express))
  12654. {
  12655. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12656. if (ceErpExpressInfo != null)
  12657. {
  12658. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12659. return;
  12660. }
  12661. }
  12662. returnErrorMsg("缺少必要的参数");
  12663. }
  12664. public void checkSupplierOrder()
  12665. {
  12666. string ctids = GetPostString("ctids");
  12667. if (ctids != null)
  12668. {
  12669. List<string> list = new List<string>();
  12670. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12671. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12672. for (int i = 0; i < dt.Rows.Count; i++)
  12673. {
  12674. DataRow row = dt.Rows[i];
  12675. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12676. {
  12677. continue;
  12678. }
  12679. list.Add(row["seller_memo"].ToString());
  12680. }
  12681. if (list.Count > 0)
  12682. {
  12683. 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, "点击下载按钮"));
  12684. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12685. return;
  12686. }
  12687. }
  12688. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12689. return;
  12690. }
  12691. public void addPersonId()
  12692. {
  12693. string tid = GetPostString("tid");
  12694. string personId = GetPostString("personId");
  12695. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12696. if (ceErpTrade != null)
  12697. {
  12698. ceErpTrade.receiver_zip = personId;
  12699. ceErpTrade.Update();
  12700. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12701. returnSuccessMsg("保存成功");
  12702. return;
  12703. }
  12704. returnErrorMsg("缺少必要的参数");
  12705. }
  12706. public void addDeliveryPaymant()
  12707. {
  12708. string tid = GetPostString("tid");
  12709. string paymant = GetPostString("paymant");
  12710. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12711. if (ceErpTrade != null)
  12712. {
  12713. if (!string.IsNullOrEmpty(paymant))
  12714. {
  12715. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12716. }
  12717. ceErpTrade.Update();
  12718. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12719. returnSuccessMsg("保存成功");
  12720. return;
  12721. }
  12722. returnErrorMsg("缺少必要的参数");
  12723. }
  12724. public void saveCellFile()
  12725. {
  12726. string tid = GetPostString("tid");
  12727. string ctid = GetPostString("ctid");
  12728. string urls = GetPostString("urls");
  12729. string type = GetPostString("type");
  12730. string del = GetPostString("del");
  12731. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12732. {
  12733. if ("1".Equals(del))
  12734. {
  12735. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12736. }
  12737. string[] list = urls.Split(',');
  12738. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12739. {
  12740. foreach (string item in list)
  12741. {
  12742. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12743. ceErpTradeCellFile.Create();
  12744. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12745. }
  12746. }
  12747. returnSuccessMsg("保存成功");
  12748. return;
  12749. }
  12750. returnErrorMsg("缺少必要的参数");
  12751. }
  12752. public void getCellFile()
  12753. {
  12754. string tid = GetPostString("tid");
  12755. string ctid = GetPostString("ctid");
  12756. string type = GetPostString("type");
  12757. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12758. {
  12759. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12760. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12761. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12762. return;
  12763. }
  12764. returnErrorMsg("缺少必要的参数");
  12765. }
  12766. public void delCellFile()
  12767. {
  12768. string id = GetPostString("id");
  12769. if (string.IsNullOrEmpty(id))
  12770. {
  12771. returnErrorMsg("缺少必要的参数");
  12772. return;
  12773. }
  12774. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12775. CeErpTradeCellFile.delByID(id);
  12776. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12777. returnSuccessMsg("保存成功");
  12778. }
  12779. public void getInvoiceOrder()
  12780. {
  12781. string tid = GetPostString("tid");
  12782. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12783. List<string> tids = new List<string>();
  12784. if (!string.IsNullOrEmpty(ceErpTrade.buyer_nick) && !string.IsNullOrEmpty(ceErpTrade.buyer_id))
  12785. {
  12786. 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);
  12787. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12788. foreach (DataRow dr in dt.Rows)
  12789. {
  12790. tids.Add("'" + dr["tid"].ToString() + "'");
  12791. }
  12792. }
  12793. else
  12794. {
  12795. tids.Add("'" + ceErpTrade.tid + "'");
  12796. }
  12797. DataTable cell_dt = new DataTable();
  12798. if (tids.Count > 0)
  12799. {
  12800. cell_dt = DbHelper.DbConn.ExecuteDataset(string.Format("SELECT * FROM [dbo].[CE_ErpTradeCell] WHERE tid in ({0});", string.Join(",", tids))).Tables[0];
  12801. }
  12802. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(cell_dt));
  12803. return;
  12804. }
  12805. }
  12806. }