sync.order.cs 660 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128
  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\\(250924170328638492)-210x140mm-10个-UV转印贴彩色模切-GL-gzb520gzb-广东省-龙井《4765947843000325546-琳19890725》.ai");
  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)
  217. {
  218. CeErpShop ceErpShop = CeErpShop.GetShopIdByName(shopname);
  219. if(ceErpShop != null)
  220. {
  221. lw.Add(string.Format("shopId = {0}", ceErpShop.ID));
  222. }
  223. }
  224. string addwechat = GetPostString("addwechat");
  225. if (addwechat.Length > 0)
  226. {
  227. int addWt = Convert.ToInt32(addwechat);
  228. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  229. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  230. }
  231. string customer = GetPostString("customer");
  232. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  233. string design = GetPostString("design");
  234. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  235. string orderState = GetPostString("orderState");
  236. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  237. string address = GetPostString("address");
  238. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  239. string sellermemo = GetPostString("seller_memo");
  240. if (sellermemo.Length > 0)
  241. {
  242. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  243. }
  244. string otherMemo = GetPostString("otherMemo");
  245. if (otherMemo.Length > 0)
  246. {
  247. lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  248. }
  249. string backReason = GetPostString("backReason");
  250. if (backReason.Length > 0)
  251. {
  252. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  253. }
  254. string apdate1 = GetPostString("apdate1");
  255. string apdate2 = GetPostString("apdate2");
  256. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  257. if (dwap.Length > 0) lw.Add(dwap);
  258. string price1 = GetPostString("price1");
  259. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  260. string price2 = GetPostString("price2");
  261. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  262. string isoldcustomer = GetPostString("isoldcus");
  263. string spudata = GetPostString("spudata");
  264. if ("0".Equals(spudata))
  265. {
  266. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  267. }
  268. if ("1".Equals(spudata))
  269. {
  270. lw.Add(string.Format("spu_id <> ''"));
  271. }
  272. string finishdate1 = GetPostString("finishdate1");
  273. string finishdate2 = GetPostString("finishdate2");
  274. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  275. bool isFinish = false;
  276. if (finishdate.Length > 0)
  277. {
  278. lw.Add(finishdate);
  279. isFinish = true;
  280. paramsCount++;
  281. }
  282. if (isoldcustomer.Length > 0)
  283. {
  284. if ("2".Equals(isoldcustomer))
  285. {
  286. lw.Add(string.Format("VipCustomer=1"));
  287. }
  288. else
  289. {
  290. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  291. }
  292. }
  293. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  294. if (ex_psize > 0)
  295. {
  296. int UserID = CurrentUser.UserID;
  297. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  298. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  299. {
  300. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  301. }
  302. dStruct.Order = "pay_time desc";
  303. }
  304. string isNew = GetPostString("isNew");
  305. if (isNew == "true")
  306. {
  307. lw.Add(string.Format("IsNew = {0}", 1));
  308. }
  309. string overtime = GetPostString("overtime");
  310. if (overtime == "1")
  311. {
  312. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  313. }
  314. String usePost = CurrentUser.UserPost.Post.Code;
  315. if (usePost.Equals("Operation") == true)
  316. {
  317. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  318. }
  319. else
  320. {
  321. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  322. }
  323. //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";
  324. if (dStruct.PageSize == 100000)
  325. {
  326. dStruct.Order = "";
  327. }
  328. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  329. DataTable dt = null;
  330. string tablename = "view_orderlist";
  331. if (isFinish)
  332. {
  333. tablename = "view_orderlist_end";
  334. }
  335. dt = WebCache.GetData(tablename, dStruct);
  336. if (dt != null && dt.Rows.Count > 0)
  337. {
  338. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  339. foreach (DataRow dr in dt.Rows)
  340. {
  341. try
  342. {
  343. if (dr["refund_fees"] != null)
  344. {
  345. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  346. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  347. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  348. if (payment == refund_fees)
  349. {
  350. dr["refund_fees"] = Math.Round(refund_fees, 2);
  351. }
  352. else if (refund_fees == total_fee)
  353. {
  354. dr["refund_fees"] = payment;
  355. }
  356. else
  357. {
  358. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  359. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  360. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  361. }
  362. }
  363. // 对象操作
  364. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  365. ceErpTradeCell.ctid = dr["ctid"].ToString();
  366. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  367. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  368. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  369. if (dStruct.PageSize != 100000)
  370. {
  371. if (dr["DispatchSort"].ToString() == "2")
  372. {
  373. dr["gongchuang"] = 200;
  374. }
  375. else if ("外协".Equals(dr["ToType"].ToString()))
  376. {
  377. dr["gongchuang"] = 200;
  378. }
  379. else if ("内部".Equals(dr["ToType"].ToString()))
  380. {
  381. dr["gongchuang"] = -1;
  382. }
  383. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  384. {
  385. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  386. dr["gongchuang"] = response.code;
  387. }
  388. }
  389. }
  390. catch (NullReferenceException ex)
  391. {
  392. // 处理空引用异常
  393. dr["refund_fees"] = "0.00";
  394. }
  395. }
  396. }
  397. writeGridDataTableJson(dStruct.TotalCount, dt);
  398. }
  399. public void get_erp_orderlist_sumprice()
  400. {
  401. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  402. return;
  403. List<string> lw = new List<string>();
  404. string tid = GetPostString("ctid");
  405. string date1 = GetPostString("date1");
  406. string date2 = GetPostString("date2");
  407. if (tid.Length > 0 || date1.Length > 0)
  408. {
  409. lw.Add(string.Format("ctid like '%{0}%'", tid));
  410. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  411. if (dw.Length > 0) lw.Add(dw);
  412. }
  413. else
  414. {
  415. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  416. }
  417. string shopname = GetPostString("shopname");
  418. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  419. string buyernick = GetPostString("buyer_nick");
  420. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  421. string customer = GetPostString("customer");
  422. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  423. string design = GetPostString("design");
  424. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  425. string orderState = GetPostString("orderState");
  426. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  427. string address = GetPostString("address");
  428. 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));
  429. string sellermemo = GetPostString("seller_memo");
  430. if (sellermemo.Length > 0)
  431. {
  432. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  433. }
  434. string apdate1 = GetPostString("apdate1");
  435. string apdate2 = GetPostString("apdate2");
  436. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  437. if (dwap.Length > 0) lw.Add(dwap);
  438. string price1 = GetPostString("price1");
  439. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  440. string price2 = GetPostString("price2");
  441. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  442. string isoldcustomer = GetPostString("isoldcus");
  443. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  444. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  445. if (PKey != "admin")
  446. {
  447. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  448. lw.Add(string.Format("shopId in ({0})", usershop));
  449. }
  450. //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";
  451. string mainWhere = string.Join(" and ", lw.ToArray());
  452. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  453. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  454. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  455. decimal total = 0;
  456. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  457. {
  458. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  459. }
  460. var res = new
  461. {
  462. data = total
  463. };
  464. string ro_jsond = JsonConvert.SerializeObject(res);
  465. returnSuccess(ro_jsond);
  466. return;
  467. }
  468. public void get_erp_CustomerServiceGather()
  469. {
  470. string userWhere = "", orderWhere = "";
  471. List<string> lw = new List<string>();
  472. string customer = GetPostString("customer");
  473. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  474. string shopname = GetPostString("shopname");
  475. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  476. string date1 = GetPostString("date1");
  477. string date2 = GetPostString("date2");
  478. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  479. if (dw.Length > 0) lw.Add(dw);
  480. orderWhere = string.Join(" and ", lw.ToArray());
  481. 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 " +
  482. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  483. "left join " +
  484. "( " +
  485. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  486. ") as b on a.ID = b.CustomerUserId " +
  487. "left join " +
  488. "( " +
  489. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  490. ") as d on a.ID = d.CustomerUserId " +
  491. "left join " +
  492. "( " +
  493. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  494. ") as e on a.ID = e.CustomerUserId " +
  495. "left join " +
  496. "( " +
  497. " select CustomerUserId, RefundCount, RefundSum from " +
  498. " ( " +
  499. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  500. " from CE_ErpTradeRefund a " +
  501. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  502. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  503. " group by CustomerUserId " +
  504. " ) as a " +
  505. ") as f on a.ID = f.CustomerUserId " +
  506. "where a.PostCode = 'CustomerService'",
  507. userWhere, orderWhere);
  508. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  509. writeGridDataTableJson(dt.Rows.Count, dt);
  510. //writeGridDataTableJson(dt.Rows.Count, dt);
  511. }
  512. //设计汇总
  513. public void get_erp_DesignerGather()
  514. {
  515. string userWhere = "", orderWhere = "";
  516. List<string> lw = new List<string>();
  517. string Designer = GetPostString("designer");
  518. int org = GetPostInt("org");
  519. if (Designer.Length > 0)
  520. {
  521. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  522. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  523. }
  524. else if (org > 0)
  525. {
  526. userWhere = string.Format(" where OrgID ={0}", org);
  527. }
  528. string shopname = GetPostString("shopname");
  529. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  530. string state = GetPostString("state");
  531. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  532. string OrderArea = GetPostString("order_area");
  533. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  534. string date1 = GetPostString("date1");
  535. string date2 = GetPostString("date2");
  536. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  537. if (dw.Length > 0) lw.Add(dw);
  538. string UpDate1 = GetPostString("UpDate1");
  539. string UpDate2 = GetPostString("UpDate2");
  540. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  541. if (dw.Length > 0) lw.Add(dw);
  542. orderWhere = string.Join(" and ", lw.ToArray());
  543. 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 (" +
  544. "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 " +
  545. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  546. "left join " +
  547. "( " +
  548. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  549. ") as b on a.ID = b.DesignUserId " +
  550. "left join " +
  551. "( " +
  552. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  553. ") as d on a.ID = d.DesignUserId " +
  554. "left join " +
  555. "( " +
  556. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  557. ") as e on a.ID = e.DesignUserId " +
  558. "left join " +
  559. "( " +
  560. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  561. ") as g on a.ID = g.DesignUserId " +
  562. "left join " +
  563. "( " +
  564. " select CustomerUserId, RefundCount, RefundSum from " +
  565. " ( " +
  566. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  567. " from CE_ErpTradeRefund a " +
  568. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  569. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  570. " group by CustomerUserId " +
  571. " ) as a " +
  572. ") as f on a.ID = f.CustomerUserId " +
  573. "where a.PostCode = 'Designer') as z",
  574. userWhere, orderWhere);
  575. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  576. writeGridDataTableJson(dt.Rows.Count, dt);
  577. }
  578. //删除tradecell的订单
  579. public void del_erp_cellorder()
  580. {
  581. if (UrlPostParmsCheck("ctid"))
  582. {
  583. string eid = GetPostString("ctid");
  584. CeErpTradeCell.DelByCtid(eid);
  585. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  586. returnSuccessMsg("删除成功");
  587. }
  588. }
  589. public void clear_erp_refundstate()
  590. {
  591. if (UrlPostParmsCheck("ids"))
  592. {
  593. string eids = GetPostString("ids");
  594. string[] ctidList = eids.Split(',');
  595. foreach (string ctid in ctidList)
  596. {
  597. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  598. if (entity != null)
  599. {
  600. entity.IsRefund = 0;
  601. entity.Update();
  602. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  603. }
  604. else
  605. continue;
  606. }
  607. returnSuccessMsg("操作成功");
  608. return;
  609. }
  610. returnErrorMsg("缺少必要参数");
  611. }
  612. public void set_erp_urgency()
  613. {
  614. if (UrlPostParmsCheck("ctid"))
  615. {
  616. string eid = GetPostString("ctid");
  617. CeErpTradeCell entity = null;
  618. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  619. if (entity != null)
  620. {
  621. double prices = commonHelper.calculationPrice(entity);
  622. if (prices <= 100)
  623. {
  624. returnErrorMsg("此订单金额不足100元,无法加急。");
  625. return;
  626. }
  627. string utime = GetPostString("urgencytime");
  628. if (utime.Length > 0)
  629. {
  630. entity.UrgencyTime = Convert.ToDateTime(utime);
  631. }
  632. else
  633. {
  634. returnErrorMsg("请选择加急时间");
  635. return;
  636. }
  637. if (entity.OrderState <= 4)
  638. {
  639. //entity.seller_memo = entity.seller_memo + "-加急";
  640. string smemo = entity.seller_memo;
  641. int kindex = smemo.IndexOf(")");
  642. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  643. if (lastoneStr != "-")
  644. {
  645. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  646. }
  647. string prememo = smemo.Substring(0, kindex + 2);
  648. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  649. int lastkindex = lastmemo.IndexOf("(");
  650. DateTime urgtime = Convert.ToDateTime(utime);
  651. string newlastmemo = "";
  652. if (lastkindex == 0)
  653. {
  654. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  655. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  656. }
  657. else
  658. {
  659. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  660. }
  661. entity.seller_memo = prememo + newlastmemo;
  662. }
  663. entity.IsUrgency = true;
  664. entity.UpdateTime = DateTime.Now;
  665. entity.Update();
  666. ApiVo apiVo = new ApiVo();
  667. apiVo.orderNumber = entity.ctid;
  668. apiVo.actionName = "changeDesign";
  669. apiVo.orderRemarks = entity.seller_memo;
  670. apiVo.remarkSign = 3;
  671. designHelper.API_WorkCore(apiVo); //changeDesign
  672. CeErpSukuraData.createInfo(entity.ctid, 7);
  673. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  674. returnSuccessMsg("设置成功!");
  675. return;
  676. }
  677. returnErrorMsg("找不到记录");
  678. }
  679. }
  680. public void set_erp_reset()
  681. {
  682. if (UrlPostParmsCheck("ctid"))
  683. {
  684. string eid = GetPostString("ctid");
  685. CeErpTradeCell entity = null;
  686. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  687. if (entity != null)
  688. {
  689. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  690. {
  691. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  692. {
  693. returnErrorMsg("财务要求已下单已发货无法重置");
  694. return;
  695. }
  696. }
  697. entity.IsUrgency = false;
  698. entity.seller_memo = "";
  699. entity.OtherMemo = "";
  700. entity.OrderState = 0;
  701. entity.IsReturn = 0;
  702. //entity.IsRefund = 0;
  703. entity.MemoOpt = 0;
  704. entity.AfterSaleState = 0;
  705. entity.AfterSaleResponsible = "";
  706. entity.AfterSaleUserId = 0;
  707. entity.IsNeedBill = 0;
  708. entity.CustomerUserId = 0;
  709. entity.DesignUserId = 0;
  710. entity.SupplierId = 0;
  711. entity.PlaceUserId = 0;
  712. entity.ptid = "";
  713. entity.IsSample = 0;
  714. entity.IsXianHuo = 0;
  715. entity.isDianziOrder = 0;
  716. entity.DispatchSort = 0;
  717. entity.IsVerifyToSupplier = false;
  718. entity.FinishPlaceTime = null;
  719. entity.Update();
  720. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  721. if (trade != null)
  722. {
  723. trade.seller_memo = "";
  724. trade.Update();
  725. }
  726. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  727. returnSuccessMsg("重置成功!");
  728. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  729. if (desginBill != null)
  730. {
  731. desginBill.isDel = 1;
  732. desginBill.Update();
  733. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  734. }
  735. ApiVo apiVo = new ApiVo();
  736. apiVo.orderNumber = entity.ctid;
  737. apiVo.actionName = "resetDesign";
  738. designHelper.API_WorkCore(apiVo);//resetDesign
  739. return;
  740. }
  741. returnErrorMsg("找不到记录");
  742. }
  743. }
  744. public void save_erp_sellermemo()
  745. {
  746. if (UrlPostParmsCheck("ctid"))
  747. {
  748. string ctid = GetPostString("ctid");
  749. CeErpTradeCell entity = null;
  750. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  751. if (entity != null)
  752. {
  753. string memo = GetPostString("seller_memo");
  754. string qn_memo = GetPostString("qn_memo");
  755. memo = memo.Replace(" ", "");
  756. if (memo.Contains("补差"))
  757. {
  758. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  759. return;
  760. }
  761. List<string> bitList = new List<string>
  762. {
  763. "\\","/",":","*","?", "\"","<" ,">","|"
  764. };
  765. bool isIn = false;
  766. foreach (string bit in bitList)
  767. {
  768. if (memo.Contains(bit))
  769. {
  770. isIn = true;
  771. }
  772. }
  773. if (isIn)
  774. {
  775. returnErrorMsg("不能使用 一些符合作为文件名");
  776. return;
  777. }
  778. if (entity.seller_memo != memo)
  779. {
  780. if (entity.IsSample == 2)
  781. {
  782. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  783. return;
  784. }
  785. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  786. {
  787. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  788. {
  789. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  790. return;
  791. }
  792. /*if (CurrentUser.UserPost.Post.Code != "Place")
  793. {
  794. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  795. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  796. {
  797. returnErrorMsg("售前系统订单无法再此修改!");
  798. return;
  799. }
  800. }*/
  801. }
  802. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  803. }
  804. if (!string.IsNullOrEmpty(qn_memo) && !(entity.IsSample > 0 || entity.ctid.Contains("N_") || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物")))
  805. {
  806. if (entity.OrderState >= 5)
  807. {
  808. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  809. return;
  810. }
  811. string delMemo = commonHelper.convertQNMemo(qn_memo, ref entity);
  812. if (string.IsNullOrEmpty(delMemo))
  813. {
  814. returnErrorMsg("备注不规范,无法识别");
  815. return;
  816. }
  817. memo = delMemo;
  818. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统千牛修改为:" + memo, entity.OrderState, 1);
  819. }
  820. commonHelper.getCytPrice(entity);
  821. int memoopt = GetPostInt("MemoOpt");
  822. Boolean ismemoopt = false;
  823. if (memoopt > 0)
  824. {
  825. string stropt = "";
  826. if (memoopt == 1)
  827. {
  828. stropt = "“改稿”";
  829. ismemoopt = true;
  830. }
  831. else if (memoopt == 2)
  832. {
  833. stropt = "“定稿”";
  834. }
  835. else if (memoopt == 3)
  836. {
  837. stropt = "“查货”";
  838. CeErpSukuraData.createInfo(entity.ctid, 6);
  839. }
  840. entity.MemoOpt = Convert.ToInt32(memoopt);
  841. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  842. }
  843. if (entity.OrderState < 5)
  844. {
  845. memo = memo.Replace("(", "(");
  846. memo = memo.Replace(")", ")");
  847. }
  848. /* if (entity.OrderState < 3)
  849. {
  850. entity.DispatchSort = 0;
  851. }*/
  852. entity.seller_memo = memo;
  853. entity.UpdateTime = DateTime.Now;
  854. entity.Update();
  855. ApiVo apiVo = new ApiVo();
  856. apiVo.orderNumber = entity.ctid;
  857. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  858. apiVo.orderRemarks = memo;
  859. apiVo.remarkSign = memoopt;
  860. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  861. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  862. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  863. {
  864. dataHelper.api_orderBack(entity.ctid, "0", "");
  865. }
  866. if (entity.seller_memo.Contains("改稿"))
  867. {
  868. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  869. }
  870. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  871. returnSuccessMsg("保存成功!");
  872. return;
  873. }
  874. returnErrorMsg("找不到记录");
  875. }
  876. }
  877. public void ins_erp_checkorder()
  878. {
  879. if (UrlPostParmsCheck("ctid"))
  880. {
  881. string ctid = GetPostString("ctid");
  882. CeErpTradeCell entity = null;
  883. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  884. if (entity != null)
  885. {
  886. if (entity.OrderState < 6)
  887. {
  888. returnErrorMsg("下单完成后才可查货");
  889. return;
  890. }
  891. /*if (entity.OrderState > 6)
  892. {
  893. returnErrorMsg("订单已发货");
  894. return;
  895. }*/
  896. if (entity.FinishPlaceTime != null)
  897. {
  898. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  899. {
  900. returnErrorMsg("下单时间不足,无法查货");
  901. return;
  902. }
  903. }
  904. entity.MemoOpt = 3;
  905. entity.CheckOrderTime = DateTime.Now;
  906. entity.UpdateTime = DateTime.Now;
  907. entity.Update();
  908. CeErpSukuraData.createInfo(entity.ctid, 6);
  909. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  910. returnSuccessMsg("操作成功!");
  911. return;
  912. }
  913. returnErrorMsg("找不到记录");
  914. }
  915. }
  916. public void save_erp_othermemo()
  917. {
  918. if (UrlPostParmsCheck("ctid"))
  919. {
  920. string ctid = GetPostString("ctid");
  921. CeErpTradeCell entity = null;
  922. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  923. if (entity != null)
  924. {
  925. entity.OtherMemo = GetPostString("otherMemo");
  926. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  927. {
  928. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  929. StringBuilder sql = new StringBuilder();
  930. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  931. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  932. if (dt != null && dt.Rows.Count > 0)
  933. {
  934. foreach (DataRow dr in dt.Rows)
  935. {
  936. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  937. {
  938. //品类一直
  939. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  940. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  941. if (ceErpSampleCustomer == null)
  942. {
  943. ceErpSampleCustomer = new CeErpSampleCustomer();
  944. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  945. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  946. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  947. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  948. ceErpSampleCustomer.shopId = entity.ShopId;
  949. }
  950. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  951. ceErpSampleCustomer.lastTid = entity.tid;
  952. if (ceErpSampleCustomer.ID > 0)
  953. {
  954. ceErpSampleCustomer.Update();
  955. }
  956. else
  957. {
  958. ceErpSampleCustomer.Create();
  959. }
  960. }
  961. }
  962. }
  963. }
  964. //if (entity.IsOldCustomer == 1)
  965. //{
  966. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  967. //{
  968. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  969. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  970. //}
  971. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  972. //{
  973. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  974. // {
  975. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  976. // {
  977. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  978. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  979. // }
  980. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  981. // {
  982. // entity.OrderState = 2;
  983. // entity.DesignUserId = 0;
  984. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  985. // }
  986. // else
  987. // {
  988. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  989. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  990. // }
  991. // }
  992. //}
  993. //}
  994. entity.UpdateTime = DateTime.Now;
  995. entity.Update();
  996. returnSuccessMsg("保存成功!");
  997. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  998. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  999. if (entity.OtherMemo.Contains("改稿"))
  1000. {
  1001. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  1002. }
  1003. return;
  1004. }
  1005. returnErrorMsg("找不到记录");
  1006. }
  1007. }
  1008. public void save_erp_customermemo()
  1009. {
  1010. if (UrlPostParmsCheck("ctid"))
  1011. {
  1012. string ctid = GetPostString("ctid");
  1013. CeErpTradeCell entity = null;
  1014. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  1015. if (entity != null)
  1016. {
  1017. entity.UpdateTime = DateTime.Now;
  1018. entity.CustomerMemo = GetPostString("CustomerMemo");
  1019. entity.Update();
  1020. ApiVo apiVo = new ApiVo();
  1021. apiVo.orderNumber = entity.ctid;
  1022. apiVo.actionName = "followRemarks";
  1023. apiVo.orderRemarks = entity.CustomerMemo;
  1024. designHelper.API_WorkCore(apiVo);//followRemarks
  1025. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1026. returnSuccessMsg("保存成功!");
  1027. return;
  1028. }
  1029. returnErrorMsg("找不到记录");
  1030. }
  1031. }
  1032. public void upd_erp_addmemotag()
  1033. {
  1034. if (UrlPostParmsCheck("ctid"))
  1035. {
  1036. ;
  1037. string eid = GetPostString("ctid");
  1038. string sfTagstr = GetPostString("memotag");
  1039. CeErpTradeCell entity = null;
  1040. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1041. if (entity != null)
  1042. {
  1043. ApiVo apiVo = new ApiVo();
  1044. if (entity.OrderState == 0)
  1045. {
  1046. returnErrorMsg("请先领单");
  1047. return;
  1048. }
  1049. //撤销顺丰
  1050. if (sfTagstr == "撤销顺丰")
  1051. {
  1052. entity.IsSF = 0;
  1053. string reMsg = "";
  1054. string oldmemo = entity.seller_memo;
  1055. if (entity.OrderState < 5)
  1056. {
  1057. oldmemo = oldmemo.Replace("顺丰到付", "");
  1058. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1059. entity.seller_memo = oldmemo;
  1060. }
  1061. else
  1062. {
  1063. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1064. {
  1065. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1066. }
  1067. }
  1068. entity.Update();
  1069. apiVo.orderNumber = entity.ctid;
  1070. apiVo.actionName = "orderRemarks";
  1071. apiVo.orderRemarks = entity.seller_memo;
  1072. apiVo.isSf = entity.IsSF.ToString();
  1073. designHelper.API_WorkCore(apiVo);//orderRemarks
  1074. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1075. returnSuccessMsg("撤销成功!" + reMsg);
  1076. return;
  1077. }
  1078. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1079. {
  1080. //string oldmemo = entity.seller_memo;
  1081. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1082. string sfStr = GetPostString("memotag");
  1083. string smemo = entity.seller_memo;
  1084. int kindex = smemo.IndexOf(")");
  1085. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1086. if (lastoneStr != "-")
  1087. {
  1088. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1089. }
  1090. string prememo = smemo.Substring(0, kindex + 2);
  1091. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1092. int lastkindex = lastmemo.IndexOf("(");
  1093. string newlastmemo = "";
  1094. if (lastkindex == 0)
  1095. {
  1096. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1097. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1098. }
  1099. else
  1100. {
  1101. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1102. }
  1103. entity.seller_memo = prememo + newlastmemo;
  1104. }
  1105. string sfTagMSg = "";
  1106. if (sfTagstr == "顺丰寄付")
  1107. {
  1108. entity.IsSF = 1;
  1109. sfTagMSg = "顺丰寄付";
  1110. }
  1111. else if (sfTagstr == "顺丰到付")
  1112. {
  1113. entity.IsSF = 2;
  1114. sfTagMSg = "顺丰到付";
  1115. }
  1116. if (entity.SupplierId == 19 && entity.OrderState == 6)
  1117. {
  1118. string deliveryWayName = "";
  1119. if (sfTagstr == "撤销顺丰")
  1120. {
  1121. sfTagstr = "普通快递";
  1122. }
  1123. if (sfTagstr == "顺丰寄付")
  1124. {
  1125. sfTagstr = "顺丰特快寄付";
  1126. }
  1127. if (sfTagstr == "顺丰到付")
  1128. {
  1129. sfTagstr = "顺丰特快到付";
  1130. }
  1131. string result = apichyHelper.updateExpressMark(entity.tid, sfTagstr);
  1132. if ("修改失败".Equals(result))
  1133. {
  1134. returnErrorMsg("修改失败");
  1135. return;
  1136. }
  1137. }
  1138. entity.Update();
  1139. apiVo = new ApiVo();
  1140. apiVo.orderNumber = entity.ctid;
  1141. apiVo.actionName = "orderRemarks";
  1142. apiVo.orderRemarks = entity.seller_memo;
  1143. apiVo.isSf = entity.IsSF.ToString();
  1144. designHelper.API_WorkCore(apiVo);//orderRemarks
  1145. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1146. returnSuccessMsg("标记成功!");
  1147. return;
  1148. }
  1149. returnErrorMsg("找不到记录");
  1150. }
  1151. }
  1152. public void upd_erp_ordertag()
  1153. {
  1154. if (UrlPostParmsCheck("ctid"))
  1155. {
  1156. string eid = GetPostString("ctid");
  1157. CeErpTradeCell entity = null;
  1158. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1159. if (entity != null)
  1160. {
  1161. int tag = GetPostInt("wechattag");
  1162. //if(tag==4 && entity.IsSample == 2)
  1163. //{
  1164. // returnErrorMsg("补差价单不能标记微信单");
  1165. // return;
  1166. //}
  1167. entity.wechatTag = tag;
  1168. entity.Update();
  1169. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1170. if (tag == 1)
  1171. {
  1172. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1173. if (cash == null)
  1174. {
  1175. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1176. cash = new CeErpReturnCash();
  1177. cash.tid = entity.tid;
  1178. cash.seller_nick = main.seller_nick;
  1179. cash.payment = trade.payment;
  1180. cash.buyer_nick = main.buyer_nick;
  1181. cash.cashstate = 0;
  1182. cash.rtype = "微信返现";
  1183. cash.returnprice = 0;
  1184. cash.created = DateTime.Now;
  1185. cash.con = "订单标记微信单";
  1186. cash.img = "";
  1187. cash.applyuserid = CurrentUser.UserID;
  1188. cash.Create();
  1189. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1190. }
  1191. else
  1192. {
  1193. cash.cashstate = 0;
  1194. cash.Update();
  1195. }
  1196. CeErpSukuraData.createInfo(entity.ctid, 9);
  1197. }
  1198. else if (tag == 2)
  1199. {
  1200. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1201. if (cash == null)
  1202. {
  1203. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1204. cash = new CeErpReturnCash();
  1205. cash.tid = entity.tid;
  1206. cash.seller_nick = main.seller_nick;
  1207. cash.payment = trade.payment;
  1208. cash.buyer_nick = main.buyer_nick;
  1209. cash.cashstate = 0;
  1210. cash.rtype = "推购返现";
  1211. cash.returnprice = 5;
  1212. cash.created = DateTime.Now;
  1213. cash.con = "订单标记推购单";
  1214. cash.img = "";
  1215. cash.applyuserid = CurrentUser.UserID;
  1216. cash.Create();
  1217. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1218. }
  1219. else
  1220. {
  1221. cash.cashstate = 0;
  1222. cash.Update();
  1223. }
  1224. CeErpSukuraData.createInfo(entity.ctid, 9);
  1225. }
  1226. else if (tag == 3)
  1227. {
  1228. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1229. if (pers == null)
  1230. {
  1231. pers = new CeErpPersuade();
  1232. pers.ctid = entity.ctid;
  1233. pers.pstate = 0;
  1234. pers.created = DateTime.Now;
  1235. pers.applyuserid = CurrentUser.UserID;
  1236. pers.Create();
  1237. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1238. }
  1239. else
  1240. {
  1241. pers.pstate = 0;
  1242. pers.Update();
  1243. }
  1244. }
  1245. else if (tag == 4 || tag == 5)
  1246. {
  1247. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1248. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1249. if (pers == null)
  1250. {
  1251. pers = CeErpStayGoods.GetByTid(entity.tid);
  1252. }
  1253. if (pers == null)
  1254. {
  1255. pers = new CeErpStayGoods();
  1256. pers.t_id = entity.tid;
  1257. pers.ctid = entity.ctid;
  1258. pers.status = "待审核";
  1259. pers.audit_type = 0;
  1260. if (tag == 4)
  1261. {
  1262. pers.stay_type = "微信推购";
  1263. }
  1264. else
  1265. {
  1266. pers.stay_type = "旺旺推购";
  1267. }
  1268. if (entity.IsXianHuo == 0)
  1269. {
  1270. pers.product_id = entity.ProductId;
  1271. }
  1272. pers.wangwang = main.buyer_nick;
  1273. pers.shop_name = main.seller_nick;
  1274. pers.creata_time = DateTime.Now;
  1275. pers.create_u_id = CurrentUser.UserID;
  1276. pers.create_u_name = CurrentUser.UserName;
  1277. pers.Create();
  1278. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1279. }
  1280. else
  1281. {
  1282. pers.ctid = entity.ctid;
  1283. pers.audit_type = 0;
  1284. pers.Update();
  1285. }
  1286. CeErpSukuraData.createInfo(entity.ctid, 10);
  1287. }
  1288. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1289. returnSuccessMsg("标记成功!");
  1290. return;
  1291. }
  1292. returnErrorMsg("找不到记录");
  1293. }
  1294. }
  1295. public void upd_erp_ordertag_cancel()
  1296. {
  1297. if (UrlPostParmsCheck("ctid"))
  1298. {
  1299. string eid = GetPostString("ctid");
  1300. CeErpTradeCell entity = null;
  1301. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1302. if (entity != null)
  1303. {
  1304. entity.wechatTag = 0;
  1305. entity.Update();
  1306. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1307. if (pers != null)
  1308. {
  1309. pers.status = "取消推购";
  1310. pers.audit_type = 3;
  1311. pers.Update();
  1312. }
  1313. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1314. returnSuccessMsg("标记成功!");
  1315. return;
  1316. }
  1317. returnErrorMsg("找不到记录");
  1318. }
  1319. }
  1320. public void upd_erp_addweichattag()
  1321. {
  1322. if (UrlPostParmsCheck("ctid"))
  1323. {
  1324. ;
  1325. string eid = GetPostString("ctid");
  1326. CeErpTradeCell entity = null;
  1327. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1328. if (entity != null)
  1329. {
  1330. if (entity.IsAddWechat > 0)
  1331. {
  1332. returnErrorMsg("此单已经标记过了");
  1333. return;
  1334. }
  1335. 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);
  1336. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1337. if (dt.Rows.Count > 0)
  1338. {
  1339. entity.IsAddWechat = 2;
  1340. }
  1341. else
  1342. {
  1343. entity.IsAddWechat = 1;
  1344. }
  1345. entity.Update();
  1346. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1347. returnSuccessMsg("标记成功!");
  1348. return;
  1349. }
  1350. returnErrorMsg("找不到记录");
  1351. }
  1352. }
  1353. public void upd_erp_getmyorder()
  1354. {
  1355. if (UrlPostParmsCheck("ctid"))
  1356. {
  1357. string eid = GetPostString("ctid");
  1358. CeErpTradeCell entity = null;
  1359. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1360. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1361. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1362. {
  1363. returnErrorMsg("台湾客户需填写身份证号!");
  1364. return;
  1365. }
  1366. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1367. {
  1368. returnErrorMsg("偏远地区需要填写物流费!");
  1369. return;
  1370. }
  1371. if (entity != null)
  1372. {
  1373. if (entity.ctid.IndexOf("C") != -1)
  1374. {
  1375. StringBuilder sql = new StringBuilder();
  1376. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1377. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1378. if (dt.Rows.Count > 0)
  1379. {
  1380. decimal total = 0;
  1381. foreach (DataRow dr in dt.Rows)
  1382. {
  1383. total += Convert.ToDecimal(dr["payment"]);
  1384. }
  1385. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1386. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1387. {
  1388. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1389. return;
  1390. }
  1391. }
  1392. }
  1393. if (entity.OrderState == -1)
  1394. {
  1395. returnErrorMsg("待审核订单无法领取!");
  1396. return;
  1397. }
  1398. entity.CustomerUserId = CurrentUser.UserID;
  1399. if (entity.OrderState < 2)
  1400. {
  1401. entity.OrderState = 2;
  1402. if (entity.ShopId != 0)
  1403. {
  1404. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1405. }
  1406. }
  1407. entity.UpdateTime = DateTime.Now;
  1408. entity.Update();
  1409. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1410. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1411. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1412. {
  1413. dataHelper.api_orderBack(entity.ctid, "0", "");
  1414. }
  1415. returnSuccessMsg("领单成功!");
  1416. return;
  1417. }
  1418. returnErrorMsg("找不到记录");
  1419. }
  1420. }
  1421. public void getmyorder_from_init()
  1422. {
  1423. if (UrlPostParmsCheck("ctid"))
  1424. {
  1425. string eid = GetPostString("ctid");
  1426. CeErpTradeCell entity = null;
  1427. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1428. if (entity != null)
  1429. {
  1430. string sellerMemo = GetPostString("sellerMemo");
  1431. if (sellerMemo.Length > 0)
  1432. {
  1433. entity.seller_memo = sellerMemo;
  1434. }
  1435. string oterhMemo = GetPostString("otherMemo");
  1436. if (oterhMemo.Length > 0)
  1437. {
  1438. entity.OtherMemo = oterhMemo;
  1439. }
  1440. int urg = GetPostInt("urgency");
  1441. entity.IsUrgency = (urg == 1 ? true : false);
  1442. int wechat = GetPostInt("wechat");
  1443. int command = GetPostInt("command");
  1444. if (wechat == 1)
  1445. {
  1446. entity.wechatTag = 1;
  1447. }
  1448. if (command == 1)
  1449. {
  1450. entity.wechatTag = 2;
  1451. }
  1452. string pPro = GetPostString("pprofession");
  1453. if (pPro.Length > 0)
  1454. {
  1455. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1456. string spro = GetPostString("profession");
  1457. if (spro.Length > 0)
  1458. {
  1459. entity.ProfessionId = Convert.ToInt32(spro);
  1460. }
  1461. }
  1462. string proId = GetPostString("productId");
  1463. if (proId.Length > 0)
  1464. {
  1465. entity.ProductId = Convert.ToInt32(proId);
  1466. }
  1467. entity.Material = GetPostString("material");
  1468. entity.Craft = GetPostString("craft");
  1469. entity.CustomerUserId = CurrentUser.UserID;
  1470. if (entity.OrderState < 2)
  1471. {
  1472. entity.OrderState = 2;
  1473. if (entity.ShopId != 0)
  1474. {
  1475. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1476. }
  1477. }
  1478. entity.Update();
  1479. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1480. returnSuccessMsg("领单成功!");
  1481. return;
  1482. }
  1483. returnErrorMsg("找不到记录");
  1484. }
  1485. }
  1486. public void upd_erp_setrelationorder()
  1487. {
  1488. if (UrlPostParmsCheck("ctid"))
  1489. {
  1490. ;
  1491. string eid = GetPostString("ctid");
  1492. string ftid = GetPostString("ftid");
  1493. CeErpTradeCell entity = null;
  1494. CeErpTradeCell fentity = null;
  1495. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1496. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1497. if (fentity == null)
  1498. {
  1499. returnErrorMsg("找不到关联的主订单");
  1500. return;
  1501. }
  1502. if (entity != null)
  1503. {
  1504. if (entity.OrderState >= 5)
  1505. {
  1506. returnErrorMsg("本单已经设计完成无法关联");
  1507. return;
  1508. }
  1509. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1510. {
  1511. returnErrorMsg("线下单续审核后才能关联!");
  1512. return;
  1513. }
  1514. entity.ptid = ftid;
  1515. entity.OrderState = fentity.OrderState;
  1516. //entity.status = fentity.status;
  1517. entity.CustomerUserId = fentity.CustomerUserId;
  1518. entity.DesignUserId = fentity.DesignUserId;
  1519. entity.seller_memo = "补差价单:" + ftid;
  1520. entity.IsSample = 2;
  1521. entity.Update();
  1522. ApiVo apiVo = new ApiVo();
  1523. apiVo.orderNumber = ftid;
  1524. apiVo.payment = entity.payment;
  1525. apiVo.actionName = "repairDesign";
  1526. designHelper.API_WorkCore(apiVo);//repairDesign
  1527. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1528. returnSuccessMsg("关联成功!");
  1529. return;
  1530. }
  1531. else
  1532. returnErrorMsg("找不到记录");
  1533. }
  1534. }
  1535. public void download_erp_neworder()
  1536. {
  1537. string seller = GetPostString("seller_nick");
  1538. string tid = GetPostString("tid");
  1539. if (seller.Length <= 0 || tid.Length <= 0)
  1540. {
  1541. returnErrorMsg("数据错误");
  1542. }
  1543. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1544. //{
  1545. // returnErrorMsg("找不到店铺Sessionkey");
  1546. //}
  1547. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1548. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1549. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1550. if (res.IndexOf("refOid") == -1)
  1551. {
  1552. returnErrorMsg("下载订单数据失败");
  1553. return;
  1554. }
  1555. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1556. returnSuccessMsg("下载完成");
  1557. //tmcHelper.createNewOrder(res);
  1558. //CeErpTrade entr = null;
  1559. //entr = CeErpTrade.Get(tid);
  1560. //if (entr != null)
  1561. //{
  1562. // returnSuccess("下载成功");
  1563. // //下载成功之后,Cell表生成对应的订单;
  1564. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1565. //}
  1566. //else
  1567. //{
  1568. // returnErrorMsg("下载失败或者创建订单失败");
  1569. //}
  1570. }
  1571. public void set_erp_atersale()
  1572. {
  1573. if (UrlPostParmsCheck("ctid"))
  1574. {
  1575. string eid = GetPostString("ctid");
  1576. string reason = GetPostString("AfterSaleReason");
  1577. CeErpTradeCell entity = null;
  1578. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1579. if (entity != null)
  1580. {
  1581. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1582. {
  1583. returnErrorMsg("此订单已经在售后");
  1584. return;
  1585. }*/
  1586. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1587. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1588. entity.AfterSaleTime = DateTime.Now;
  1589. entity.HandleTime = null;
  1590. entity.Update();
  1591. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1592. returnSuccessMsg("转售后成功!");
  1593. return;
  1594. }
  1595. returnErrorMsg("找不到记录");
  1596. }
  1597. }
  1598. public void set_erp_withdraw()
  1599. {
  1600. if (UrlPostParmsCheck("ctid"))
  1601. {
  1602. try
  1603. {
  1604. string eid = GetPostString("ctid");//商品id
  1605. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1606. CeWithdraw ceWithdrawSelect = null;
  1607. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1608. if (ceWithdrawSelect != null)
  1609. {
  1610. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1611. {
  1612. ceWithdrawSelect.status = -1;
  1613. ceWithdrawSelect.Update();
  1614. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1615. returnSuccessMsg("重新发起审核成功");
  1616. return;
  1617. }
  1618. else
  1619. {
  1620. returnSuccessMsg("请勿重复申请!");
  1621. return;
  1622. }
  1623. }
  1624. else
  1625. {
  1626. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1627. if (string.IsNullOrEmpty(CustomerUserId))
  1628. {
  1629. CustomerUserId = "-1";
  1630. }
  1631. int Userid = CurrentUser.UserID;//用户id
  1632. CeWithdraw ceWithdraw = new CeWithdraw();
  1633. ceWithdraw.tid = eid;
  1634. ceWithdraw.userid = Userid;
  1635. ceWithdraw.providerid = CustomerUserId;
  1636. ceWithdraw.status = 3;
  1637. ceWithdraw.creationtime = DateTime.Now;
  1638. ceWithdraw.Create();
  1639. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1640. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1641. return;
  1642. }
  1643. }
  1644. catch
  1645. {
  1646. returnErrorMsg("申请撤回订单失败");
  1647. return;
  1648. }
  1649. }
  1650. }
  1651. public void ins_erp_billinfo()
  1652. {
  1653. if (UrlPostParmsCheck("ctid"))
  1654. {
  1655. string eid = GetPostString("ctid");
  1656. CeErpTradeCell entity = null;
  1657. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1658. if (entity != null)
  1659. {
  1660. CeErpBill bill = CeErpBill.GetByTid(eid);
  1661. bool isHave = false;
  1662. if (bill != null)
  1663. {
  1664. isHave = true;
  1665. if (bill.state != 4)
  1666. {
  1667. returnErrorMsg("此单已经申请过发票了");
  1668. return;
  1669. }
  1670. }
  1671. if (entity.IsNeedBill == 0)
  1672. {
  1673. entity.IsNeedBill = 1;
  1674. }
  1675. entity.Update();
  1676. string errjson = "";
  1677. try
  1678. {
  1679. CeErpBill bill_entity = new CeErpBill();
  1680. bill_entity.tid = entity.tid;
  1681. bill_entity.title = GetPostString("title");
  1682. string taxstr = GetPostString("tax");
  1683. taxstr = taxstr.Replace(" ", "");
  1684. bill_entity.tax = taxstr;
  1685. bill_entity.bank = GetPostString("bank");
  1686. string bankacstr = GetPostString("bankac");
  1687. bankacstr = bankacstr.Replace(" ", "");
  1688. bill_entity.bankac = bankacstr;
  1689. bill_entity.address = GetPostString("address");
  1690. bill_entity.phone = GetPostString("phone");
  1691. bill_entity.price = GetPostString("price");
  1692. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1693. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1694. {
  1695. billCount += 1;
  1696. }
  1697. string prebill = "ltb";
  1698. for (int idx = 1; idx <= billCount; idx++)
  1699. {
  1700. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1701. string billoid = prebill + idx + dtstr;
  1702. bill_entity.billOrderId += billoid;
  1703. if (idx < billCount)
  1704. {
  1705. bill_entity.billOrderId += ",";
  1706. }
  1707. }
  1708. bill_entity.productId = GetPostInt("ProductName");
  1709. bill_entity.num = GetPostInt("num");
  1710. bill_entity.unit = GetPostString("unit");
  1711. bill_entity.type = GetPostString("type");
  1712. bill_entity.sendType = GetPostString("SendType");
  1713. bill_entity.email = GetPostString("email");
  1714. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1715. bill_entity.shopName = GetPostString("ShopName");
  1716. bill_entity.applymemo = GetPostString("applyMemo");
  1717. bill_entity.createTime = DateTime.Now;
  1718. bill_entity.state = 0;
  1719. bill_entity.userId = CurrentUser.UserID;
  1720. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1721. bill_entity.Create();
  1722. }
  1723. catch (Exception ex)
  1724. {
  1725. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1726. returnErrorMsg("创建发票出错!");
  1727. return;
  1728. }
  1729. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1730. returnSuccessMsg("发票申请成功!");
  1731. return;
  1732. }
  1733. returnErrorMsg("找不到记录");
  1734. }
  1735. }
  1736. public void ins_erp_neworder()
  1737. {
  1738. if (UrlPostParmsCheck("receiver_name"))
  1739. {
  1740. CeErpTrade entity = new CeErpTrade();
  1741. string plat_form = GetPostString("platform");
  1742. string preStr = "N_";
  1743. if (plat_form == "拼多多")
  1744. {
  1745. preStr = "P_";
  1746. }
  1747. else if (plat_form == "阿里巴巴")
  1748. {
  1749. preStr = "A_";
  1750. }
  1751. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1752. entity.seller_nick = GetPostString("seller_nick");
  1753. entity.buyer_nick = GetPostString("buyer_nick");
  1754. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1755. entity.total_fee = entity.payment;
  1756. entity.pay_time = DateTime.Now;
  1757. entity.status = "NOT_SHIPPED";
  1758. entity.receiver_name = GetPostString("receiver_name");
  1759. entity.receiver_mobile = GetPostString("receiver_mobile");
  1760. entity.receiver_state = GetPostString("receiver_state");
  1761. entity.receiver_city = GetPostString("receiver_city");
  1762. entity.receiver_district = GetPostString("receiver_district");
  1763. entity.receiver_address = GetPostString("receiver_address");
  1764. if (entity.receiver_state == "" || entity.receiver_city == "")
  1765. {
  1766. returnErrorMsg("收件地址不能为空");
  1767. return;
  1768. }
  1769. int shopId = 0;
  1770. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1771. if (nShop != null)
  1772. {
  1773. shopId = nShop.ID;
  1774. }
  1775. if (shopId != 34 && entity.payment == 0)
  1776. {
  1777. returnErrorMsg("公司自用的单金额才能为0");
  1778. return;
  1779. }
  1780. entity.Create();
  1781. CeErpTradeCell entitycell = new CeErpTradeCell();
  1782. entitycell.ctid = entity.tid;
  1783. entitycell.tid = entity.tid;
  1784. entitycell.ShopId = shopId;
  1785. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1786. entitycell.OrderState = 0;
  1787. entitycell.pay_time = entity.pay_time;
  1788. entitycell.IsOffLineOrder = 1;
  1789. entitycell.Create();
  1790. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1791. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1792. return;
  1793. }
  1794. }
  1795. public void ins_erp_neworder2()
  1796. {
  1797. if (UrlPostParmsCheck("receiver_name"))
  1798. {
  1799. //string plat_form = GetPostString("platform");
  1800. string preStr = "X_";
  1801. string memo = GetPostString("memo");
  1802. string productId = GetPostString("productId");
  1803. string primg = GetPostString("proofimg");
  1804. string sellerNick = GetPostString("seller_nick");
  1805. string addFrom = GetPostString("addfrom");
  1806. if (addFrom == "1")
  1807. {
  1808. preStr = "N_";
  1809. }
  1810. int shopId = 0;
  1811. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1812. if (nShop != null)
  1813. {
  1814. shopId = nShop.ID;
  1815. }
  1816. else
  1817. {
  1818. returnErrorMsg("找不到对应店铺");
  1819. return;
  1820. }
  1821. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1822. {
  1823. returnErrorMsg("必须上传付款凭证");
  1824. return;
  1825. }
  1826. CeErpTrade entity = new CeErpTrade();
  1827. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1828. entity.seller_nick = sellerNick;
  1829. entity.buyer_nick = GetPostString("buyer_nick");
  1830. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1831. entity.total_fee = entity.payment;
  1832. entity.pay_time = DateTime.Now;
  1833. entity.status = "NOT_SHIPPED";
  1834. entity.receiver_name = GetPostString("receiver_name");
  1835. entity.receiver_mobile = GetPostString("receiver_mobile");
  1836. entity.receiver_state = GetPostString("receiver_state");
  1837. entity.receiver_city = GetPostString("receiver_city");
  1838. entity.receiver_district = GetPostString("receiver_district");
  1839. entity.receiver_address = GetPostString("receiver_address");
  1840. entity.seller_memo = memo;
  1841. entity.orderFrom = 20;
  1842. entity.orderType = 15;
  1843. if (entity.receiver_state == "" || entity.receiver_city == "")
  1844. {
  1845. returnErrorMsg("收件地址不能为空");
  1846. return;
  1847. }
  1848. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1849. {
  1850. returnErrorMsg("公司自用的单金额才能为0");
  1851. return;
  1852. }
  1853. entity.Create();
  1854. string toWhere = GetPostString("towhere");
  1855. CeErpTradeCell entitycell = new CeErpTradeCell();
  1856. entitycell.ctid = entity.tid;
  1857. //唯一标识
  1858. entitycell.OrderSn = entity.tid;
  1859. string orderSn = dataHelper.getSaleOrderSn();
  1860. if (orderSn != "")
  1861. {
  1862. entitycell.OrderSn = orderSn;
  1863. }
  1864. entitycell.tid = entity.tid;
  1865. //if (preStr == "X_")
  1866. //{
  1867. entitycell.IsOffLineOrder = 1;
  1868. //}
  1869. entitycell.CustomerUserId = CurrentUser.UserID;
  1870. entitycell.PayProofImg = primg;
  1871. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1872. entitycell.ProductId = Convert.ToInt32(productId);
  1873. entitycell.ShopId = shopId;
  1874. entitycell.UpdateTime = DateTime.Now;
  1875. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1876. if (entitycell.ProductId > 0)
  1877. {
  1878. CeErpProduct ceErpProduct = CeErpProduct.GetById(entitycell.ProductId);
  1879. if (ceErpProduct.CreateTime != null && DateTime.Compare(ceErpProduct.CreateTime, DateTime.Now.AddDays(-90)) > 0)
  1880. {
  1881. entitycell.NewProduct = 1;
  1882. }
  1883. }
  1884. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1885. {
  1886. entitycell.IsXianHuo = 1;
  1887. }
  1888. entitycell.pay_time = entity.pay_time;
  1889. if (toWhere == "1")
  1890. {
  1891. entitycell.OrderState = 2;
  1892. }
  1893. else
  1894. {
  1895. entitycell.OrderState = 6;
  1896. entitycell.FinishPlaceTime = entitycell.pay_time;
  1897. }
  1898. if (shopId == 94)
  1899. {
  1900. entitycell.OrderState = 4;
  1901. entitycell.WaitDesignTime = entitycell.pay_time;
  1902. entitycell.StartDesignTime = entitycell.pay_time;
  1903. entitycell.DesignUserId = 218;
  1904. }
  1905. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1906. {
  1907. entitycell.OrderState = -1;//修改12-5
  1908. CeWithdraw ceWithdraw = new CeWithdraw();
  1909. ceWithdraw.tid = entity.tid;
  1910. ceWithdraw.providerid = "-1";
  1911. ceWithdraw.status = -1;
  1912. ceWithdraw.creationtime = DateTime.Now;
  1913. ceWithdraw.userid = 4634;
  1914. ceWithdraw.Create();
  1915. }
  1916. entitycell.Create();
  1917. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1918. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1919. {
  1920. addPlaceRegist(entitycell, CurrentUser.UserID);
  1921. }
  1922. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1923. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1924. return;
  1925. }
  1926. }
  1927. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1928. {
  1929. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1930. entity.PlactTime = tradecell.pay_time;
  1931. entity.AddUserId = userid;
  1932. entity.FileName = tradecell.seller_memo;
  1933. entity.Supplier = 24;
  1934. entity.CreateTime = DateTime.Now;
  1935. entity.Did = tradecell.ctid;
  1936. entity.tid = tradecell.tid;
  1937. entity.splitTag = tradecell.SplitTag;
  1938. entity.CurState = "未完成";
  1939. entity.Create();
  1940. }
  1941. public void get_erp_offlinelist()
  1942. {
  1943. DataStruct dStruct = GetPostStruct();
  1944. List<string> lw = new List<string>();
  1945. string tid = GetPostString("ctid");
  1946. string date1 = GetPostString("date1");
  1947. string date2 = GetPostString("date2");
  1948. if (tid.Length > 0 || date1.Length > 0)
  1949. {
  1950. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1951. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1952. if (dw.Length > 0) lw.Add(dw);
  1953. }
  1954. else
  1955. {
  1956. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1957. }
  1958. string shopname = GetPostString("shopname");
  1959. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1960. string buyernick = GetPostString("buyer_nick");
  1961. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1962. string customer = GetPostString("customer");
  1963. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1964. string design = GetPostString("design");
  1965. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1966. string orderState = GetPostString("orderState");
  1967. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1968. string address = GetPostString("address");
  1969. 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));
  1970. string sellermemo = GetPostString("seller_memo");
  1971. if (sellermemo.Length > 0)
  1972. {
  1973. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1974. }
  1975. string price1 = GetPostString("price1");
  1976. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1977. string price2 = GetPostString("price2");
  1978. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1979. //if (PKey != "admin")
  1980. //{
  1981. // string usershop = CurrentUser.User.pemShop;
  1982. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1983. //}
  1984. //if (ex_psize > 0)
  1985. //{
  1986. dStruct.Order = "pay_time desc";
  1987. //}
  1988. //else
  1989. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1990. lw.Add(string.Format("IsOffLineOrder=1"));
  1991. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1992. DataTable dt = null;
  1993. dt = WebCache.GetData("view_erptradecell", dStruct);
  1994. writeGridDataTableJson(dStruct.TotalCount, dt);
  1995. }
  1996. public void get_erp_returncashrecord()
  1997. {
  1998. DataStruct dStruct = GetPostStruct();
  1999. List<string> lw = new List<string>();
  2000. string tid = GetPostString("ctid");
  2001. if (tid.Length > 0)
  2002. {
  2003. lw.Add(string.Format("tid like '%{0}%'", tid));
  2004. dStruct.Order = "id desc";
  2005. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2006. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  2007. //writeGridDataTableJson(dStruct.TotalCount, dt);
  2008. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2009. return;
  2010. }
  2011. returnErrorMsg("id数据错误!");
  2012. }
  2013. public void ins_erp_returncashrecord()
  2014. {
  2015. if (UrlPostParmsCheck("tid"))
  2016. {
  2017. string tid = GetPostString("tid");
  2018. string retype = GetPostString("type");
  2019. StringBuilder sql = new StringBuilder();
  2020. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  2021. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2022. if (dt.Rows.Count > 0)
  2023. {
  2024. returnErrorMsg("相同返现类型记录已存在");
  2025. return;
  2026. }
  2027. CeErpReturnCash entity = new CeErpReturnCash();
  2028. entity.tid = tid;
  2029. entity.seller_nick = GetPostString("seller_nick");
  2030. string pment = GetPostString("payment");
  2031. if (pment.Length > 0)
  2032. {
  2033. entity.payment = Convert.ToDouble(pment);
  2034. }
  2035. entity.buyer_nick = GetPostString("buyer_nick");
  2036. entity.cashstate = 0;
  2037. entity.rtype = retype;
  2038. string rPrice = GetPostString("returnprice");
  2039. if (rPrice.Length > 0)
  2040. {
  2041. entity.returnprice = Convert.ToDouble(rPrice);
  2042. }
  2043. entity.created = DateTime.Now;
  2044. entity.con = GetPostString("con");
  2045. entity.img = GetPostString("img");
  2046. entity.applyuserid = CurrentUser.UserID;
  2047. entity.Create();
  2048. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  2049. returnSuccessMsg("操作成功!");
  2050. return;
  2051. }
  2052. }
  2053. public void set_erp_predelivery()
  2054. {
  2055. if (UrlPostParmsCheck("ctid"))
  2056. {
  2057. string eid = GetPostString("ctid");
  2058. CeErpTradeCell entity = null;
  2059. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2060. if (entity != null)
  2061. {
  2062. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2063. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2064. //{
  2065. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2066. // return;
  2067. //}
  2068. entity.IsPreDelivery = 1;
  2069. entity.Update();
  2070. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2071. returnSuccessMsg("预发货成功!");
  2072. return;
  2073. //string shop = GetPostString("seller_nick");
  2074. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2075. //string comName = GetPostString("comName");
  2076. //string comCode = GetPostString("comCode");
  2077. //string outSid = GetPostString("outSid");//运单号
  2078. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2079. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2080. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2081. //string apires = "";
  2082. //if (deliveryType == "虚拟发货")
  2083. //{
  2084. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2085. //}
  2086. //else
  2087. //{
  2088. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2089. //}
  2090. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2091. ////{
  2092. //if (apires.IndexOf("发货成功") != -1)
  2093. //{
  2094. // if (deliveryType != "虚拟发货")
  2095. // {
  2096. // //还要插入快递信息到 快递信息表
  2097. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2098. // exinfo.tid = eid;
  2099. // exinfo.out_sid = outSid;
  2100. // exinfo.company_code = comCode;
  2101. // exinfo.company_name = comName;
  2102. // exinfo.delivery_memo = deliveryMemo;
  2103. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2104. // exinfo.deliveryType = deliveryType;
  2105. // exinfo.Create();
  2106. // }
  2107. // returnSuccessMsg("发货成功!");
  2108. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2109. //}
  2110. //else
  2111. //{
  2112. // returnErrorMsg("淘宝发货失败!!");
  2113. //}
  2114. //return;
  2115. }
  2116. returnErrorMsg("找不到订单记录");
  2117. }
  2118. }
  2119. public void get_erp_unusuallist()
  2120. {
  2121. DataStruct dStruct = GetPostStruct();
  2122. List<string> lw = new List<string>();
  2123. string tid = GetPostString("ctid");
  2124. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2125. string shopname = GetPostString("shopname");
  2126. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2127. string buyernick = GetPostString("buyer_nick");
  2128. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2129. string ResponsibleMan = GetPostString("responsible");
  2130. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2131. string date1 = GetPostString("date1");
  2132. string date2 = GetPostString("date2");
  2133. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2134. if (dw.Length > 0) lw.Add(dw);
  2135. string price1 = GetPostString("price1");
  2136. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2137. string price2 = GetPostString("price2");
  2138. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2139. string orderState = GetPostString("orderState");
  2140. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2141. string sellermemo = GetPostString("seller_memo");
  2142. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2143. lw.Add(string.Format("UnusualTag > 0"));
  2144. lw.Add(string.Format("IsRefund<={0}", 1));
  2145. dStruct.Order = "pay_time desc";
  2146. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2147. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2148. writeGridDataTableJson(dStruct.TotalCount, dt);
  2149. }
  2150. public void set_erp_unusualtonomal()
  2151. {
  2152. if (UrlPostParmsCheck("ctid"))
  2153. {
  2154. string eid = GetPostString("ctid");
  2155. CeErpTradeCell entity = null;
  2156. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2157. if (entity != null)
  2158. {
  2159. entity.UnusualTag = -1;
  2160. entity.Update();
  2161. returnSuccessMsg("忽略成功!");
  2162. return;
  2163. }
  2164. returnErrorMsg("找不到记录");
  2165. }
  2166. }
  2167. public void ins_erp_unusualreason()
  2168. {
  2169. if (UrlPostParmsCheck("ctid"))
  2170. {
  2171. string eid = GetPostString("ctid");
  2172. CeErpTradeCell entity = null;
  2173. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2174. if (entity != null)
  2175. {
  2176. entity.MemoOpt = 4;
  2177. entity.UnusualCon = GetPostString("con");
  2178. entity.Update();
  2179. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2180. if (trade != null)
  2181. {
  2182. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2183. }
  2184. //查货是否超时
  2185. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2186. if (ceErpTradeCellExtend == null)
  2187. {
  2188. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2189. ceErpTradeCellExtend.ctid = entity.ctid;
  2190. }
  2191. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2192. {
  2193. ceErpTradeCellExtend.CheckOut += 1;
  2194. }
  2195. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2196. if (ceErpTradeCellExtend.ID > 0)
  2197. {
  2198. ceErpTradeCellExtend.Update();
  2199. }
  2200. else
  2201. {
  2202. ceErpTradeCellExtend.Create();
  2203. }
  2204. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2205. returnSuccessMsg("操作成功!");
  2206. return;
  2207. }
  2208. returnErrorMsg("找不到记录");
  2209. }
  2210. }
  2211. public void upd_erp_sampleorder()
  2212. {
  2213. if (UrlPostParmsCheck("ctid"))
  2214. {
  2215. string eid = GetPostString("ctid");
  2216. string[] eArr = eid.Split(',');
  2217. if (eArr.Length > 1)
  2218. {
  2219. List<string> eLst = new List<string>();
  2220. for (int i = 0; i < eArr.Length; i++)
  2221. {
  2222. eLst.Add("'" + eArr[i] + "'");
  2223. }
  2224. eid = string.Join(",", eLst.ToArray());
  2225. }
  2226. else
  2227. {
  2228. eid = "'" + eid + "'";
  2229. }
  2230. StringBuilder sql = new StringBuilder();
  2231. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2232. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2233. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2234. if (dt.Rows.Count > 0)
  2235. {
  2236. string errmsg = "";
  2237. foreach (DataRow dr in dt.Rows)
  2238. {
  2239. StringBuilder sqlsb = new StringBuilder();
  2240. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2241. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2242. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2243. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2244. //string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2245. /*if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2246. {
  2247. continue;
  2248. }
  2249. else
  2250. {
  2251. string emsg = commonHelper.KeepChinese(apires);
  2252. errmsg += emsg;
  2253. }*/
  2254. }
  2255. if (errmsg.Length > 0)
  2256. {
  2257. returnErrorMsg(errmsg);
  2258. return;
  2259. }
  2260. returnSuccessMsg("操作成功");
  2261. return;
  2262. }
  2263. returnErrorMsg("找不到记录");
  2264. }
  2265. }
  2266. public void upd_erp_transcustomer()
  2267. {
  2268. if (UrlPostParmsCheck("ctid"))
  2269. {
  2270. string eid = GetPostString("ctid");
  2271. int userid = GetPostInt("CustomerUserId");
  2272. CeErpTradeCell entity = null;
  2273. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2274. if (entity != null)
  2275. {
  2276. //string[] mlist = entity.seller_memo.Split('-');
  2277. //string sql = "select * from view_erpuser where id=" + userid;
  2278. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2279. //if (dt != null && dt.Rows.Count > 0)
  2280. //{
  2281. // string nmemo = "";
  2282. // for(int i = 0; i < mlist.Length - 1; i++)
  2283. // {
  2284. // nmemo += mlist[i];
  2285. // nmemo += "-";
  2286. // }
  2287. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2288. // entity.seller_memo = nmemo;
  2289. //}
  2290. entity.CustomerUserId = userid;
  2291. entity.Update();
  2292. returnSuccessMsg("操作成功!");
  2293. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2294. return;
  2295. }
  2296. returnErrorMsg("找不到记录");
  2297. }
  2298. }
  2299. public void upd_erp_transdesigner()
  2300. {
  2301. if (UrlPostParmsCheck("ctid"))
  2302. {
  2303. string eids = GetPostString("ctid");
  2304. string[] ctidList = eids.Split(',');
  2305. int userid = GetPostInt("DesignUserId");
  2306. foreach (string ctid in ctidList)
  2307. {
  2308. CeErpTradeCell entity = null;
  2309. CeErpDesignerBill entitys = null;
  2310. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2311. entitys = CeErpDesignerBill.GetByTid(ctid);
  2312. if (entity != null)
  2313. {
  2314. if (entity.OrderState > 4)
  2315. {
  2316. continue;
  2317. }
  2318. //存在退款不能流转
  2319. if (entity.IsRefund > 0)
  2320. {
  2321. continue;
  2322. }
  2323. entity.DesignUserId = userid;
  2324. entity.WaitDesignTime = DateTime.Now;
  2325. entity.Update();
  2326. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2327. }
  2328. }
  2329. returnSuccessMsg("操作成功!");
  2330. }
  2331. }
  2332. public void upd_erp_distributedesigner()
  2333. {
  2334. if (UrlPostParmsCheck("ctid"))
  2335. {
  2336. string eid = GetPostString("ctid");
  2337. int userid = GetPostInt("DesignUserId");
  2338. string[] idlist = eid.Split(',');
  2339. if (idlist.Length <= 0)
  2340. {
  2341. returnErrorMsg("订单不能为空");
  2342. return;
  2343. }
  2344. foreach (string ctid in idlist)
  2345. {
  2346. CeErpTradeCell entity = null;
  2347. CeErpDesignerBill entitys = null;
  2348. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2349. else continue;
  2350. if (entity != null)
  2351. {
  2352. if (userid == 2125 || userid == 3542)
  2353. { }
  2354. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2355. {
  2356. returnErrorMsg("金额错误的订单无法指派");
  2357. return;
  2358. }
  2359. if (entity.OrderState >= 5)
  2360. {
  2361. returnErrorMsg("已经设计完成无法指派");
  2362. return;
  2363. }
  2364. if (entity.OrderState == -1)
  2365. {
  2366. returnErrorMsg("审核中的订单无法指派");
  2367. return;
  2368. }
  2369. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2370. {
  2371. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2372. return;
  2373. }
  2374. //157赖橙帆 159林晨 73 静之颖
  2375. 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)
  2376. {
  2377. returnErrorMsg("指派设计共创无法再次指派!");
  2378. return;
  2379. }
  2380. entity.OrderState = 3;
  2381. if (entity.SupplierId == 0)
  2382. {
  2383. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2384. entity.SupplierId = suid;
  2385. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2386. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2387. }
  2388. if (userid == 2125 && entity.seller_memo != "")
  2389. {
  2390. apiDesign.API_GetPrintData_CreateOrder(entity);
  2391. }
  2392. if (userid == 3542 && entity.seller_memo != "")
  2393. {
  2394. string userPost = CurrentUser.UserPost.Post.Code;
  2395. if (CurrentUser.UserID == 73)
  2396. {
  2397. userPost = "SysAdmin";
  2398. }
  2399. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2400. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2401. if (response.msg != "设计共创:成功")
  2402. {
  2403. returnErrorMsg(response.msg);
  2404. return;
  2405. }
  2406. entity.DispatchSort = 2;
  2407. }
  2408. else
  2409. {
  2410. if (entity.DispatchSort == 2)
  2411. {
  2412. ApiVo apiVo = new ApiVo();
  2413. apiVo.actionName = "closeDesign";
  2414. apiVo.orderNumber = entity.ctid;
  2415. designHelper.API_WorkCore(apiVo);//closeDesign
  2416. }
  2417. entity.DispatchSort = 0;
  2418. }
  2419. entity.DesignUserId = userid;
  2420. entity.WaitDesignTime = DateTime.Now;
  2421. entity.UpdateTime = DateTime.Now;
  2422. entity.Update();
  2423. string name = commonHelper.getUserNameById(userid);
  2424. commonHelper.UpdateRelationOrder(entity.ctid);
  2425. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2426. }
  2427. }
  2428. returnSuccessMsg("操作成功!");
  2429. return;
  2430. }
  2431. }
  2432. public string getTidByCtid(string ctid)
  2433. {
  2434. string tid = "";
  2435. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2436. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2437. if (dataTable != null && dataTable.Rows.Count > 0)
  2438. {
  2439. tid = dataTable.Rows[0]["tid"].ToString();
  2440. }
  2441. return tid;
  2442. }
  2443. public List<string> getTidByCtidMore(string ctid)
  2444. {
  2445. 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);
  2446. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2447. List<string> list = new List<string>();
  2448. if (dataTable != null && dataTable.Rows.Count > 0)
  2449. {
  2450. foreach (DataRow item in dataTable.Rows)
  2451. {
  2452. list.Add("'" + item["tid"].ToString() + "'");
  2453. }
  2454. }
  2455. return list;
  2456. }
  2457. public List<string> getTidByCtidLike(string ctid)
  2458. {
  2459. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2460. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2461. List<string> list = new List<string>();
  2462. if (dataTable != null && dataTable.Rows.Count > 0)
  2463. {
  2464. foreach (DataRow item in dataTable.Rows)
  2465. {
  2466. list.Add("'" + item["tid"].ToString() + "'");
  2467. }
  2468. }
  2469. return list;
  2470. }
  2471. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2472. {
  2473. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2474. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2475. List<string> list = new List<string>();
  2476. if (dataTable != null && dataTable.Rows.Count > 0)
  2477. {
  2478. foreach (DataRow item in dataTable.Rows)
  2479. {
  2480. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2481. {
  2482. continue;
  2483. }
  2484. list.Add("'" + item["receiverId"].ToString() + "'");
  2485. }
  2486. }
  2487. return list;
  2488. }
  2489. public void get_erp_myorderlist()
  2490. {
  2491. DataStruct dStruct = GetPostStruct();
  2492. List<string> lw = new List<string>();
  2493. string tid = GetPostString("ctid");
  2494. if (tid.Length > 0)
  2495. {
  2496. string select_tid = getTidByCtid(tid);
  2497. lw.Add(string.Format("tid='{0}'", select_tid));
  2498. }
  2499. else
  2500. {
  2501. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2502. }
  2503. //12-1 修改
  2504. string urgent = GetPostString("urgent");
  2505. string back = GetPostString("back");
  2506. string offlineSearch = GetPostString("offlineSearch");
  2507. if (!string.IsNullOrWhiteSpace(urgent))
  2508. {
  2509. if (urgent.Equals("true"))
  2510. {
  2511. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2512. }
  2513. }
  2514. if (!string.IsNullOrWhiteSpace(back))
  2515. {
  2516. if (back.Equals("true"))
  2517. {
  2518. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2519. }
  2520. }
  2521. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2522. {
  2523. if (offlineSearch.Equals("true"))
  2524. {
  2525. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2526. }
  2527. }
  2528. //end
  2529. string shopname = GetPostString("shopname");
  2530. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2531. string buyernick = GetPostString("buyer_nick");
  2532. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2533. string design = GetPostString("design");
  2534. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2535. string orderState = GetPostString("orderState");
  2536. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2537. string sellermemo = GetPostString("seller_memo");
  2538. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2539. string date1 = GetPostString("date1");
  2540. string date2 = GetPostString("date2");
  2541. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2542. if (dw.Length > 0) lw.Add(dw);
  2543. string price1 = GetPostString("price1");
  2544. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2545. string price2 = GetPostString("price2");
  2546. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2547. string urgency = GetPostString("urgency");
  2548. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2549. string after = GetPostString("after");
  2550. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2551. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2552. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2553. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2554. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2555. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2556. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2557. if (dt != null && dt.Rows.Count > 0)
  2558. {
  2559. foreach (DataRow dr in dt.Rows)
  2560. {
  2561. try
  2562. {
  2563. // 对象操作
  2564. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2565. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2566. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2567. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2568. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2569. if (dStruct.PageSize != 100000)
  2570. {
  2571. if (dr["DispatchSort"].ToString() == "2")
  2572. {
  2573. dr["gongchuang"] = 200;
  2574. }
  2575. else if ("外协".Equals(dr["ToType"].ToString()))
  2576. {
  2577. dr["gongchuang"] = 200;
  2578. }
  2579. else if ("内部".Equals(dr["ToType"].ToString()))
  2580. {
  2581. dr["gongchuang"] = -1;
  2582. }
  2583. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2584. {
  2585. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2586. dr["gongchuang"] = response.code;
  2587. }
  2588. }
  2589. }
  2590. catch (NullReferenceException ex)
  2591. {
  2592. }
  2593. }
  2594. }
  2595. writeGridDataTableJson(dStruct.TotalCount, dt);
  2596. }
  2597. public void get_erp_myreturnorderlist()
  2598. {
  2599. DataStruct dStruct = GetPostStruct();
  2600. List<string> lw = new List<string>();
  2601. string tid = GetPostString("ctid");
  2602. if (tid.Length > 0)
  2603. {
  2604. string select_tid = getTidByCtid(tid);
  2605. lw.Add(string.Format("tid='{0}'", select_tid));
  2606. }
  2607. else
  2608. {
  2609. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2610. }
  2611. string shopname = GetPostString("shopname");
  2612. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2613. string buyernick = GetPostString("buyer_nick");
  2614. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2615. string design = GetPostString("design");
  2616. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2617. string orderState = GetPostString("orderState");
  2618. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2619. string sellermemo = GetPostString("seller_memo");
  2620. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2621. string date1 = GetPostString("date1");
  2622. string date2 = GetPostString("date2");
  2623. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2624. if (dw.Length > 0) lw.Add(dw);
  2625. string price1 = GetPostString("price1");
  2626. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2627. string price2 = GetPostString("price2");
  2628. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2629. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2630. {
  2631. lw.Add(string.Format("CusOrgID = 94"));
  2632. }
  2633. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2634. {
  2635. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2636. }
  2637. else
  2638. {
  2639. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2640. }
  2641. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2642. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2643. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2644. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2645. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2646. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2647. if (dt != null && dt.Rows.Count > 0)
  2648. {
  2649. foreach (DataRow dr in dt.Rows)
  2650. {
  2651. try
  2652. {
  2653. // 对象操作
  2654. if (dStruct.PageSize != 100000)
  2655. {
  2656. if (dr["DispatchSort"].ToString() == "2")
  2657. {
  2658. dr["gongchuang"] = 200;
  2659. }
  2660. else if ("外协".Equals(dr["ToType"].ToString()))
  2661. {
  2662. dr["gongchuang"] = 200;
  2663. }
  2664. else if ("内部".Equals(dr["ToType"].ToString()))
  2665. {
  2666. dr["gongchuang"] = -1;
  2667. }
  2668. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2669. {
  2670. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2671. dr["gongchuang"] = response.code;
  2672. }
  2673. }
  2674. }
  2675. catch (NullReferenceException ex)
  2676. {
  2677. // 处理空引用异常
  2678. }
  2679. }
  2680. }
  2681. writeGridDataTableJson(dStruct.TotalCount, dt);
  2682. }
  2683. public void get_erp_myorderlist_pregather()
  2684. {
  2685. string date1 = GetPostString("date1");
  2686. string date2 = GetPostString("date2");
  2687. int userId = CurrentUser.UserID; //客服id
  2688. string orderWhere = "";
  2689. List<string> lw = new List<string>();
  2690. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2691. if (dw.Length > 0) lw.Add(dw);
  2692. lw.Add(string.Format("CustomerUserId={0}", userId));
  2693. lw.Add(string.Format("OrderState<9"));
  2694. orderWhere = string.Join(" and ", lw.ToArray());
  2695. string orderWhere2 = "";
  2696. List<string> lw2 = new List<string>();
  2697. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2698. if (dw2.Length > 0) lw2.Add(dw2);
  2699. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2700. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2701. string sql = string.Format("select *" +
  2702. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2703. "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 " +
  2704. "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 " +
  2705. "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");
  2706. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2707. //writeGridDataTableJson(dt.Rows.Count, dt);
  2708. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2709. }
  2710. public void upd_erp_publishorder()
  2711. {
  2712. if (UrlPostParmsCheck("ctid"))
  2713. {
  2714. string eid = GetPostString("ctid");
  2715. CeErpTradeCell entity = null;
  2716. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2717. if (entity != null)
  2718. {
  2719. entity.OrderState = 0; //发布后,变为待抢单
  2720. entity.Update();
  2721. commonHelper.UpdateRelationOrder(entity.ctid);
  2722. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2723. returnSuccessMsg("发布成功!");
  2724. return;
  2725. }
  2726. returnErrorMsg("找不到记录");
  2727. }
  2728. }
  2729. public void get_erp_my_tiporder()
  2730. {
  2731. StringBuilder sql = new StringBuilder();
  2732. int userId = 0;
  2733. if (CurrentUser != null) userId = CurrentUser.UserID;
  2734. string posCode = CurrentUser.UserPost.Post.Code;
  2735. string isTipedAfterSaleVerify = GetPostString("af");
  2736. DataTable dt = new DataTable();
  2737. if (posCode != "Supplier")
  2738. {
  2739. if (posCode == "CustomerService" || posCode == "Director")
  2740. {
  2741. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2742. }
  2743. else if (posCode == "Place" || posCode == "PlaceMr")
  2744. {
  2745. }
  2746. else
  2747. {
  2748. string teamIds = CurrentUser.User.TeamIds;
  2749. if (teamIds == "")
  2750. {
  2751. teamIds = "0";
  2752. }
  2753. 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);
  2754. }
  2755. if (sql.Length > 0)
  2756. {
  2757. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2758. }
  2759. }
  2760. if (dt.Rows.Count <= 0)
  2761. {
  2762. string key = "aftersale_order_" + userId;
  2763. if (RedisHelper.HasKey(key))
  2764. {
  2765. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2766. dt.Columns.Add("ctid", typeof(string));
  2767. dt.Columns.Add("IsReadTag", typeof(int));
  2768. foreach (var i in list)
  2769. {
  2770. DataRow data = dt.NewRow();
  2771. data["ctid"] = i;
  2772. data["IsReadTag"] = 4;
  2773. dt.Rows.Add(data);
  2774. }
  2775. RedisHelper.StringDelete(key);
  2776. }
  2777. }
  2778. if (dt.Rows.Count <= 0)
  2779. {
  2780. sql = new StringBuilder();
  2781. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2782. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2783. }
  2784. if (posCode == "Supplier")
  2785. {
  2786. string ids = CurrentUser.User.pemVend;
  2787. if (ids != null && ids.Length > 0)
  2788. {
  2789. string[] ids_list = ids.Split(',');
  2790. foreach (var item in ids_list)
  2791. {
  2792. string key = "return_order_" + item;
  2793. if (RedisHelper.HasKey(key))
  2794. {
  2795. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2796. dt.Columns.Add("ctid", typeof(string));
  2797. dt.Columns.Add("IsReadTag", typeof(int));
  2798. foreach (var i in list)
  2799. {
  2800. DataRow data = dt.NewRow();
  2801. data["ctid"] = i;
  2802. data["IsReadTag"] = 1;
  2803. dt.Rows.Add(data);
  2804. }
  2805. RedisHelper.StringDelete(key);
  2806. }
  2807. }
  2808. }
  2809. if (dt.Rows.Count <= 0)
  2810. {
  2811. sql = new StringBuilder();
  2812. 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);
  2813. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2814. }
  2815. }
  2816. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2817. }
  2818. public void reset_erp_tiporder()
  2819. {
  2820. string ids = GetPostString("ids");
  2821. string[] ctidList = ids.Split(',');
  2822. foreach (string ctid in ctidList)
  2823. {
  2824. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2825. if (enty != null)
  2826. {
  2827. enty.IsReadTag = 0;
  2828. enty.Update();
  2829. }
  2830. }
  2831. returnSuccessMsg("成功!");
  2832. return;
  2833. }
  2834. public void get_erp_designlist()
  2835. {
  2836. DataStruct dStruct = GetPostStruct();
  2837. List<string> lw = new List<string>();
  2838. string tid = GetPostString("ctid");
  2839. if (tid.Length > 0)
  2840. {
  2841. string select_tid = getTidByCtid(tid);
  2842. lw.Add(string.Format("tid='{0}'", select_tid));
  2843. }
  2844. string shopname = GetPostString("shopname");
  2845. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2846. string buyernick = GetPostString("buyer_nick");
  2847. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2848. string customer = GetPostString("customer");
  2849. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2850. string design = GetPostString("design");
  2851. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2852. string orderState = GetPostString("orderState");
  2853. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2854. lw.Add(string.Format("OrderState<6"));
  2855. string address = GetPostString("address");
  2856. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2857. string sellermemo = GetPostString("seller_memo");
  2858. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2859. string date1 = GetPostString("date1");
  2860. string date2 = GetPostString("date2");
  2861. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2862. if (dw.Length > 0) lw.Add(dw);
  2863. string apdate1 = GetPostString("apdate1");
  2864. string apdate2 = GetPostString("apdate2");
  2865. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2866. if (dwap.Length > 0) lw.Add(dwap);
  2867. string price1 = GetPostString("price1");
  2868. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2869. string price2 = GetPostString("price2");
  2870. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2871. string designTime = GetPostString("designtime");
  2872. if (designTime.Length > 0)
  2873. {
  2874. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2875. }
  2876. string usershop = CurrentUser.User.pemShop;
  2877. if (usershop.Length > 0)
  2878. {
  2879. lw.Add(string.Format("shopId in ({0})", usershop));
  2880. }
  2881. int myOrgid = CurrentUser.UserPost.OrgID;
  2882. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2883. if (myOrgCode.IndexOf("Designer") != -1)
  2884. {
  2885. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2886. {
  2887. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2888. }
  2889. else
  2890. {
  2891. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2892. }
  2893. }
  2894. else
  2895. {
  2896. string orgId = GetPostString("designerhd");
  2897. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2898. }
  2899. if (tid.Length > 0 || buyernick.Length > 0)
  2900. {
  2901. lw.Add(string.Format("OrderState >= 3"));
  2902. }
  2903. else
  2904. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2905. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2906. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2907. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2908. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2909. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2910. if (dt != null && dt.Rows.Count > 0)
  2911. {
  2912. foreach (DataRow dr in dt.Rows)
  2913. {
  2914. try
  2915. {
  2916. // 对象操作
  2917. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2918. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2919. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2920. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2921. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2922. if (dStruct.PageSize != 100000)
  2923. {
  2924. if (dr["DispatchSort"].ToString() == "2")
  2925. {
  2926. dr["gongchuang"] = 200;
  2927. }
  2928. else if ("外协".Equals(dr["ToType"].ToString()))
  2929. {
  2930. dr["gongchuang"] = 200;
  2931. }
  2932. else if ("内部".Equals(dr["ToType"].ToString()))
  2933. {
  2934. dr["gongchuang"] = -1;
  2935. }
  2936. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2937. {
  2938. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2939. dr["gongchuang"] = response.code;
  2940. }
  2941. }
  2942. }
  2943. catch (NullReferenceException ex)
  2944. {
  2945. }
  2946. }
  2947. }
  2948. writeGridDataTableJson(dStruct.TotalCount, dt);
  2949. }
  2950. public void get_erp_mydesignlist()
  2951. {
  2952. DataStruct dStruct = GetPostStruct();
  2953. List<string> lw = new List<string>();
  2954. string tid = GetPostString("ctid");
  2955. if (tid.Length > 0)
  2956. {
  2957. string select_tid = getTidByCtid(tid);
  2958. lw.Add(string.Format("tid='{0}'", select_tid));
  2959. }
  2960. string shopname = GetPostString("shopname");
  2961. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2962. string buyernick = GetPostString("buyer_nick");
  2963. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2964. string customer = GetPostString("customer");
  2965. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2966. string orderState = GetPostString("orderState");
  2967. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2968. //lw.Add(string.Format("OrderState<6"));
  2969. string date1 = GetPostString("date1");
  2970. string date2 = GetPostString("date2");
  2971. string dw = GetDateWhere("pay_time", date1, date2);
  2972. if (dw.Length > 0) lw.Add(dw);
  2973. string apdate1 = GetPostString("apdate1");
  2974. string apdate2 = GetPostString("apdate2");
  2975. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2976. if (dwap.Length > 0) lw.Add(dwap);
  2977. string price1 = GetPostString("price1");
  2978. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2979. string price2 = GetPostString("price2");
  2980. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2981. string olddownload = GetPostString("olddown");
  2982. if (olddownload == "1")
  2983. {
  2984. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2985. }
  2986. else if (olddownload == "2")
  2987. {
  2988. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2989. }
  2990. string sellermemo = GetPostString("seller_memo");
  2991. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2992. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2993. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2994. {
  2995. if (CurrentUser.User.TeamIds.Length > 0)
  2996. {
  2997. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2998. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2999. else
  3000. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3001. }
  3002. else
  3003. {
  3004. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  3005. }
  3006. }
  3007. if (tid.Length <= 0)
  3008. {
  3009. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  3010. }
  3011. lw.Add(string.Format("IsReturn!=3"));
  3012. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  3013. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3014. string teamids = CurrentUser.User.TeamIds.ToString();
  3015. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3016. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  3017. if (dt != null && dt.Rows.Count > 0)
  3018. {
  3019. foreach (DataRow dr in dt.Rows)
  3020. {
  3021. try
  3022. {
  3023. // 对象操作
  3024. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  3025. ceErpTradeCell.ctid = dr["ctid"].ToString();
  3026. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  3027. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  3028. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  3029. if (dStruct.PageSize != 100000)
  3030. {
  3031. if (dr["DispatchSort"].ToString() == "2")
  3032. {
  3033. dr["gongchuang"] = 200;
  3034. }
  3035. else if ("外协".Equals(dr["ToType"].ToString()))
  3036. {
  3037. dr["gongchuang"] = 200;
  3038. }
  3039. else if ("内部".Equals(dr["ToType"].ToString()))
  3040. {
  3041. dr["gongchuang"] = -1;
  3042. }
  3043. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  3044. {
  3045. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  3046. dr["gongchuang"] = response.code;
  3047. }
  3048. }
  3049. }
  3050. catch (NullReferenceException ex)
  3051. {
  3052. }
  3053. }
  3054. }
  3055. writeGridDataTableJson(dStruct.TotalCount, dt);
  3056. }
  3057. public void set_erp_startdesign()
  3058. {
  3059. if (UrlPostParmsCheck("ctid"))
  3060. {
  3061. string eid = GetPostString("ctid");
  3062. CeErpTradeCell entity = null;
  3063. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3064. if (entity != null)
  3065. {
  3066. if (entity.OrderState != 3)
  3067. {
  3068. returnErrorMsg("请刷新,订单已经设计了");
  3069. return;
  3070. }
  3071. entity.StartDesignTime = DateTime.Now;
  3072. entity.OrderState = 4;
  3073. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3074. {
  3075. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3076. entity.SupplierId = suid;
  3077. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3078. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3079. }
  3080. entity.UpdateTime = DateTime.Now;
  3081. //entity.MakeSupplier = suname;
  3082. entity.Update();
  3083. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3084. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3085. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3086. commonHelper.getCytPrice(entity);
  3087. returnSuccessMsg("操作成功!");
  3088. return;
  3089. }
  3090. returnErrorMsg("找不到记录");
  3091. }
  3092. }
  3093. public void ins_erp_designselfmemo()
  3094. {
  3095. if (UrlPostParmsCheck("ctid"))
  3096. {
  3097. string eid = GetPostString("ctid");
  3098. string con = GetPostString("con");
  3099. CeErpTradeCell entity = null;
  3100. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3101. if (entity != null)
  3102. {
  3103. entity.DesignSelfMemo = con;
  3104. entity.Update();
  3105. returnSuccessMsg("操作成功!");
  3106. return;
  3107. }
  3108. returnErrorMsg("找不到记录");
  3109. }
  3110. }
  3111. public void ins_erp_designprice()
  3112. {
  3113. if (UrlPostParmsCheck("ctid"))
  3114. {
  3115. string eid = GetPostString("ctid");
  3116. int uid = CurrentUser.UserID;
  3117. string userName = CurrentUser.UserName;
  3118. CeErpTradeCell entity = null;
  3119. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3120. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3121. if (entitys == null)
  3122. {
  3123. entitys = new CeErpDesignerBill();
  3124. }
  3125. if (entity != null)
  3126. {
  3127. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3128. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3129. entity.StartDesignTime = DateTime.Now;
  3130. entity.OrderState = 4;
  3131. string suname = "";
  3132. if (entity.SupplierId == 0)
  3133. {
  3134. int sid = commonHelper.autoDistributeToSupplier(entity);
  3135. entity.SupplierId = sid;
  3136. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3137. }
  3138. entity.Update();
  3139. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3140. if (ceErpUserPost != null)
  3141. {
  3142. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3143. if (ceErpPost != null)
  3144. {
  3145. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3146. {
  3147. entitys.tid = entity.ctid;
  3148. entitys.oid = entity.tid;
  3149. entitys.uid = uid;
  3150. entitys.userName = userName;
  3151. entitys.designerType = 1;
  3152. entitys.designerTypeText = "内部设计师";
  3153. entitys.price = Convert.ToDouble(GetPostString("price"));
  3154. entitys.designNum = GetPostInt("designNum");
  3155. entitys.modifyNum = GetPostInt("modifyNum");
  3156. entitys.designSize = GetPostString("designSize");
  3157. entitys.modifySize = GetPostString("modifySize");
  3158. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3159. {
  3160. entitys.create_time = DateTime.Now;
  3161. entitys.create_u_id = uid;
  3162. entitys.create_u_name = userName;
  3163. entitys.Save();
  3164. }
  3165. else
  3166. {
  3167. entitys.update_time = DateTime.Now;
  3168. entitys.update_u_id = uid;
  3169. entitys.update_u_name = userName;
  3170. entitys.Update();
  3171. }
  3172. }
  3173. }
  3174. }
  3175. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3176. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3177. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3178. if (suname != "")
  3179. {
  3180. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3181. }
  3182. commonHelper.getCytPrice(entity);
  3183. returnSuccessMsg("操作成功!");
  3184. return;
  3185. }
  3186. returnErrorMsg("找不到记录");
  3187. }
  3188. }
  3189. public void upload_erp_filecomplete()
  3190. {
  3191. if (UrlPostParmsCheck("ctid"))
  3192. {
  3193. string eid = GetPostString("ctid");
  3194. CeErpTradeCell entity = null;
  3195. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3196. if (entity != null)
  3197. {
  3198. entity.OrderState = 5; //设计完成
  3199. entity.Update();
  3200. returnSuccessMsg(eid + "上传成功,设计完成!");
  3201. return;
  3202. }
  3203. returnErrorMsg("找不到订单记录");
  3204. }
  3205. }
  3206. public void get_erp_designovertimelist()
  3207. {
  3208. DataStruct dStruct = GetPostStruct();
  3209. List<string> lw = new List<string>();
  3210. string tid = GetPostString("ctid");
  3211. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3212. string shopname = GetPostString("shopname");
  3213. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3214. string buyernick = GetPostString("buyer_nick");
  3215. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3216. string ResponsibleMan = GetPostString("responsible");
  3217. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3218. string date1 = GetPostString("date1");
  3219. string date2 = GetPostString("date2");
  3220. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3221. if (dw.Length > 0) lw.Add(dw);
  3222. string price1 = GetPostString("price1");
  3223. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3224. string price2 = GetPostString("price2");
  3225. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3226. string orderState = GetPostString("orderState");
  3227. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3228. string sellermemo = GetPostString("seller_memo");
  3229. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3230. lw.Add(string.Format("UnusualTag=3"));
  3231. lw.Add(string.Format("IsRefund<={0}", 1));
  3232. dStruct.Order = "WaitDesignTime desc";
  3233. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3234. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3235. writeGridDataTableJson(dStruct.TotalCount, dt);
  3236. }
  3237. //设计管理 获取抢单大厅列表
  3238. public void get_erp_grabinglist()
  3239. {
  3240. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3241. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3242. bool oldOrder = false;
  3243. if (org != null)
  3244. {
  3245. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3246. }
  3247. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3248. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3249. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3250. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3251. //先处理订单数据
  3252. if (dt.Rows.Count > 0)
  3253. {
  3254. Dictionary<string, int> design = null;
  3255. int count = 0;
  3256. foreach (DataRow row in dt.Rows)
  3257. {
  3258. if (map.ContainsKey(row["ShopId"].ToString()))
  3259. {
  3260. map.TryGetValue(row["ShopId"].ToString(), out design);
  3261. }
  3262. else
  3263. {
  3264. design = new Dictionary<string, int>();
  3265. }
  3266. if (design.ContainsKey(row["ProductId"].ToString()))
  3267. {
  3268. design.TryGetValue(row["ProductId"].ToString(), out count);
  3269. }
  3270. count++;
  3271. design[row["ProductId"].ToString()] = count;
  3272. map[row["ShopId"].ToString()] = design;
  3273. }
  3274. }
  3275. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3276. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3277. //把店铺排序和技能排序分类
  3278. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3279. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3280. if (design_dt.Rows.Count > 0)
  3281. {
  3282. Dictionary<string, string> design = null;
  3283. List<string> shopIds = null;
  3284. foreach (DataRow row in design_dt.Rows)
  3285. {
  3286. if ("0".Equals(row["designId"].ToString()))
  3287. {
  3288. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3289. {
  3290. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3291. }
  3292. else
  3293. {
  3294. shopIds = new List<string>();
  3295. }
  3296. shopIds.Add(row["shopId"].ToString());
  3297. shop_orders[row["orders"].ToString()] = shopIds;
  3298. }
  3299. else
  3300. {
  3301. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3302. {
  3303. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3304. }
  3305. else
  3306. {
  3307. design = new Dictionary<string, string>();
  3308. }
  3309. design[row["orders"].ToString()] = row["designId"].ToString();
  3310. design_orders[row["shopId"].ToString()] = design;
  3311. }
  3312. }
  3313. //处理成key value后根据key排序
  3314. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3315. foreach (List<string> val in shop_orders.Values)
  3316. {
  3317. if (val != null)
  3318. {
  3319. foreach (string key in val)
  3320. {
  3321. if (design_orders.ContainsKey(key.ToString()))
  3322. {
  3323. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3324. }
  3325. }
  3326. }
  3327. }
  3328. }
  3329. //校验哪个优先级有订单
  3330. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3331. foreach (string key in shop_orders.Keys)
  3332. {
  3333. List<string> ids = null;
  3334. shop_orders.TryGetValue(key, out ids);
  3335. //id为shopid
  3336. foreach (string id in ids)
  3337. {
  3338. Dictionary<string, int> list = null;
  3339. Dictionary<string, string> desing = null;
  3340. map.TryGetValue(id, out list);
  3341. design_orders.TryGetValue(id, out desing);
  3342. if (list != null && desing != null)
  3343. {
  3344. foreach (var item in desing)
  3345. {
  3346. int count = 0;
  3347. if (list.ContainsKey(item.Value))
  3348. {
  3349. list.TryGetValue(item.Value, out count);
  3350. if (count > 0)
  3351. {
  3352. designIds[id] = item.Value;
  3353. break;
  3354. }
  3355. }
  3356. }
  3357. }
  3358. }
  3359. if (designIds.Count > 0)
  3360. {
  3361. break;
  3362. }
  3363. }
  3364. DataTable table = new DataTable();
  3365. table.Columns.Add("tid", typeof(string));
  3366. table.Columns.Add("ctid", typeof(string));
  3367. table.Columns.Add("seller_nick", typeof(string));
  3368. table.Columns.Add("productName", typeof(string));
  3369. table.Columns.Add("pay_time", typeof(string));
  3370. table.Columns.Add("seller_memo", typeof(string));
  3371. if (designIds.Count > 0)
  3372. {
  3373. string shopId = "";
  3374. string productId = "";
  3375. foreach (var designInfo in designIds)
  3376. {
  3377. shopId = designInfo.Key;
  3378. productId = designInfo.Value;
  3379. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3380. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3381. if (dt.Rows.Count > 0)
  3382. {
  3383. foreach (DataRow row in dt.Rows)
  3384. {
  3385. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3386. {
  3387. DataRow data = table.NewRow();
  3388. data["ctid"] = row["ctid"].ToString();
  3389. data["tid"] = row["tid"].ToString();
  3390. data["seller_nick"] = ceErpShop.ShopName;
  3391. data["pay_time"] = row["pay_time"].ToString();
  3392. data["seller_memo"] = row["seller_memo"].ToString();
  3393. data["productName"] = ceErpProduct.PType;
  3394. table.Rows.Add(data);
  3395. }
  3396. }
  3397. }
  3398. }
  3399. }
  3400. writeGridDataTableJson(table.Rows.Count, table);
  3401. }
  3402. private object rushLockObject = new object();
  3403. public void set_erp_grabingorder()
  3404. {
  3405. if (UrlPostParmsCheck("ctid"))
  3406. {
  3407. int total = CurrentUser.User.Person.Total;
  3408. int userId = CurrentUser.User.ID;
  3409. int noFinish = CurrentUser.User.Person.NoFinish;
  3410. int finalization = CurrentUser.User.Person.Finalization;
  3411. string eids = GetPostString("ctid");
  3412. string key = "RushKey_" + userId;
  3413. int count = 0;
  3414. if (erpRedis.RedisHelper.KeyExists(key))
  3415. {
  3416. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3417. if (redisCount != null)
  3418. {
  3419. count = Convert.ToInt32(redisCount);
  3420. }
  3421. }
  3422. if (count >= total)
  3423. {
  3424. returnErrorMsg("半小时内已经抢" + total + "单");
  3425. return;
  3426. }
  3427. string[] ctidlist = eids.Split(',');
  3428. if (count + ctidlist.Length > total)
  3429. {
  3430. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3431. return;
  3432. }
  3433. int itag = 0;
  3434. lock (rushLockObject)
  3435. {
  3436. if (ctidlist.Length > 0)
  3437. {
  3438. string[] dtList = new string[ctidlist.Length];
  3439. for (int i = 0; i < ctidlist.Length; i++)
  3440. {
  3441. dtList[i] = "'" + ctidlist[i] + "'";
  3442. }
  3443. 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"));
  3444. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3445. if (dt_user.Rows.Count > 0)
  3446. {
  3447. int doing = 0;//未定稿
  3448. int finish = 0;//已完成
  3449. foreach (DataRow dr in dt_user.Rows)
  3450. {
  3451. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3452. {
  3453. doing++;
  3454. }
  3455. else
  3456. {
  3457. finish++;
  3458. }
  3459. }
  3460. if (doing >= noFinish)
  3461. {
  3462. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3463. return;
  3464. }
  3465. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3466. {
  3467. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3468. return;
  3469. }
  3470. }
  3471. //校验选择单子状态
  3472. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3473. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3474. if (dt.Rows.Count > 0)
  3475. {
  3476. List<string> list = new List<string>();
  3477. foreach (DataRow dr in dt.Rows)
  3478. {
  3479. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3480. {
  3481. list.Add(dr["ctid"].ToString());
  3482. }
  3483. }
  3484. if (list.Count > 0)
  3485. {
  3486. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3487. return;
  3488. }
  3489. }
  3490. foreach (string ctid in ctidlist)
  3491. {
  3492. CeErpTradeCell entity = null;
  3493. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3494. if (entity != null)
  3495. {
  3496. entity.OrderState = 3;
  3497. entity.DesignUserId = CurrentUser.UserID;
  3498. entity.WaitDesignTime = DateTime.Now;
  3499. entity.StartDesignTime = DateTime.Now;
  3500. entity.Update();
  3501. commonHelper.UpdateRelationOrder(entity.ctid);
  3502. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3503. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3504. itag++;
  3505. }
  3506. }
  3507. }
  3508. }
  3509. count += ctidlist.Length;
  3510. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3511. if (itag == 0)
  3512. returnErrorMsg("没有找到相关订单");
  3513. else
  3514. returnSuccessMsg("抢单成功!");
  3515. return;
  3516. }
  3517. }
  3518. public void get_erp_waitorderlist()
  3519. {
  3520. DataStruct dStruct = GetPostStruct();
  3521. List<string> lw = new List<string>();
  3522. string tid = GetPostString("ctid");
  3523. if (tid.Length > 0)
  3524. {
  3525. string select_tid = getTidByCtid(tid);
  3526. lw.Add(string.Format("tid='{0}'", select_tid));
  3527. }
  3528. string shopname = GetPostString("shopname");
  3529. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3530. string buyernick = GetPostString("buyer_nick");
  3531. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3532. string customer = GetPostString("customer");
  3533. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3534. string design = GetPostString("design");
  3535. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3536. string orderState = GetPostString("orderState");
  3537. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3538. string supplier = GetPostString("supplier");
  3539. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3540. string sellermemo = GetPostString("seller_memo");
  3541. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3542. string otherMemo = GetPostString("otherMemo");
  3543. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3544. string address = GetPostString("address");
  3545. 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));
  3546. string date1 = GetPostString("date1");
  3547. string date2 = GetPostString("date2");
  3548. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3549. if (dw.Length > 0) lw.Add(dw);
  3550. string price1 = GetPostString("price1");
  3551. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3552. string price2 = GetPostString("price2");
  3553. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3554. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3555. lw.Add(string.Format("IsSample != 2 "));
  3556. lw.Add(string.Format("OrderState = 5 "));
  3557. lw.Add(string.Format("IsRefund<={0}", 1));
  3558. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3559. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3560. string pagesize = GetPostString("pagesize");
  3561. if (pagesize != null)
  3562. {
  3563. dStruct.PageSize = 200;
  3564. }
  3565. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3566. List<string> tids = new List<string>();
  3567. if (dt != null)
  3568. {
  3569. dt.Columns.Add("compenPrice", typeof(double));
  3570. foreach (DataRow dr in dt.Rows)
  3571. {
  3572. if (Convert.IsDBNull(dr["compenPrice"]))
  3573. {
  3574. dr["compenPrice"] = 0;
  3575. }
  3576. tids.Add("'" + dr["tid"].ToString() + "'");
  3577. 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();
  3578. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3579. {
  3580. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3581. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3582. entity.SupplierId = suid;
  3583. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3584. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3585. entity.Update();
  3586. }
  3587. }
  3588. }
  3589. if (tids.Count > 0)
  3590. {
  3591. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3592. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3593. if (dt_price != null && dt_price.Rows.Count > 0)
  3594. {
  3595. foreach (DataRow dr in dt_price.Rows)
  3596. {
  3597. foreach (DataRow row in dt.Rows)
  3598. {
  3599. if (row["tid"].Equals(dr["ptid"]))
  3600. {
  3601. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3602. break;
  3603. }
  3604. }
  3605. }
  3606. }
  3607. }
  3608. writeGridDataTableJson(dStruct.TotalCount, dt);
  3609. }
  3610. public void get_erp_supplierwaitorderlist()
  3611. {
  3612. DataStruct dStruct = GetPostStruct();
  3613. List<string> lw = new List<string>();
  3614. string tid = GetPostString("ctid");
  3615. if (tid.Length > 0)
  3616. {
  3617. string select_tid = getTidByCtid(tid);
  3618. lw.Add(string.Format("tid='{0}'", select_tid));
  3619. }
  3620. string shopname = GetPostString("shopname");
  3621. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3622. string sellermemo = GetPostString("seller_memo");
  3623. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3624. string date1 = GetPostString("date1");
  3625. string date2 = GetPostString("date2");
  3626. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3627. if (dw.Length > 0) lw.Add(dw);
  3628. lw.Add(string.Format("OrderState = 5 "));
  3629. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3630. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3631. {
  3632. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3633. }
  3634. string supplier = GetPostString("supplier");
  3635. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3636. {
  3637. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3638. }
  3639. lw.Add(string.Format("IsRefund<={0}", 1));
  3640. dStruct.Order = "FinishDesignTime desc";
  3641. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3642. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3643. if (dt != null)
  3644. {
  3645. foreach (DataRow dr in dt.Rows)
  3646. {
  3647. 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();
  3648. }
  3649. }
  3650. writeGridDataTableJson(dStruct.TotalCount, dt);
  3651. }
  3652. public void upd_erp_verifytosupplier()
  3653. {
  3654. if (UrlPostParmsCheck("ctid"))
  3655. {
  3656. string eids = GetPostString("ctid");
  3657. CeErpTradeCell entity = null;
  3658. string[] eidsList = eids.Split(',');
  3659. if (eidsList.Length <= 0)
  3660. {
  3661. returnErrorMsg("订单号不能空");
  3662. return;
  3663. }
  3664. List<string> tLst = new List<string>();
  3665. foreach (string ctidstr in eidsList)
  3666. {
  3667. tLst.Add("'" + ctidstr + "'");
  3668. CeErpDataSendOrderInfo.createObject(ctidstr);
  3669. }
  3670. string needtids = string.Join(",", tLst.ToArray());
  3671. StringBuilder sql = new StringBuilder();
  3672. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3673. 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);
  3674. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3675. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3676. returnSuccessMsg("操作成功!");
  3677. return;
  3678. /**foreach (string ctidstr in eidsList)
  3679. {
  3680. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3681. if (entity != null)
  3682. {
  3683. if (entity.SupplierId == 0)
  3684. {
  3685. continue;
  3686. }
  3687. entity.IsVerifyToSupplier = true;
  3688. if (entity.IsReturn == 1) //1是供应商打回
  3689. {
  3690. entity.IsReturn = 0;
  3691. }
  3692. entity.FinishPlaceTime = DateTime.Now;
  3693. entity.PlaceUserId = CurrentUser.UserID;
  3694. entity.Update();
  3695. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3696. }
  3697. }
  3698. returnSuccessMsg("操作成功!");
  3699. return;**/
  3700. }
  3701. }
  3702. public void upd_erp_supplierback()
  3703. {
  3704. if (UrlPostParmsCheck("ctid"))
  3705. {
  3706. string eid = GetPostString("ctid");
  3707. string reason = GetPostString("returnreason");
  3708. CeErpTradeCell entity = null;
  3709. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3710. if (entity != null)
  3711. {
  3712. string message = "操作成功!";
  3713. string isDown = "";
  3714. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3715. {
  3716. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3717. isDown = "被点击下载";
  3718. }
  3719. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3720. {
  3721. string key = "return_order_" + entity.SupplierId;
  3722. List<string> list = new List<string>();
  3723. if (RedisHelper.HasKey(key))
  3724. {
  3725. object data = RedisHelper.StringGet(key);
  3726. list = Convert.ToString(data).Split(',').ToList();
  3727. }
  3728. list.Add(eid);
  3729. RedisHelper.StringSet(key, string.Join(",", list));
  3730. }
  3731. entity.IsVerifyToSupplier = false;
  3732. entity.IsReturn = 1;
  3733. entity.IsHaveNewOrder = 0;
  3734. entity.ReturnTime = DateTime.Now;
  3735. entity.ReturnReason = reason;
  3736. if (entity.OrderState == 6)
  3737. {
  3738. entity.OrderState = 5;
  3739. }
  3740. entity.Update();
  3741. CeErpSukuraData.createInfo(entity.ctid, 5);
  3742. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3743. returnSuccessMsg(message);
  3744. return;
  3745. }
  3746. returnErrorMsg("找不到订单记录");
  3747. }
  3748. }
  3749. public void upd_erp_toaftersaleorder()
  3750. {
  3751. if (UrlPostParmsCheck("ctid"))
  3752. {
  3753. string eid = GetPostString("ctid");
  3754. string reason = GetPostString("returnreason");
  3755. CeErpTradeCell entity = null;
  3756. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3757. if (entity != null)
  3758. {
  3759. if (entity.isAfterSaleOrder != 1)
  3760. {
  3761. returnErrorMsg("带S的售后单才能打回给售后");
  3762. return;
  3763. }
  3764. if (entity.OrderState >= 5)
  3765. {
  3766. returnErrorMsg("已经设计完成了不能打回给售后");
  3767. return;
  3768. }
  3769. entity.OrderState = 0;
  3770. entity.IsReturn = 3;
  3771. entity.ReturnTime = DateTime.Now;
  3772. entity.UpdateTime = DateTime.Now;
  3773. entity.ReturnReason = reason;
  3774. entity.Update();
  3775. CeErpSukuraData.createInfo(entity.ctid, 5);
  3776. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3777. returnSuccessMsg("操作成功!");
  3778. return;
  3779. }
  3780. returnErrorMsg("找不到订单记录");
  3781. }
  3782. }
  3783. public void upd_erp_aftersaletodesign()
  3784. {
  3785. if (UrlPostParmsCheck("ctid"))
  3786. {
  3787. string eid = GetPostString("ctid");
  3788. CeErpTradeCell entity = null;
  3789. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3790. if (entity != null)
  3791. {
  3792. entity.OrderState = 3;
  3793. entity.IsReturn = 0;
  3794. entity.UpdateTime = DateTime.Now;
  3795. entity.Update();
  3796. CeErpSukuraData.createInfo(entity.ctid, 5);
  3797. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3798. returnSuccessMsg("操作成功!");
  3799. return;
  3800. }
  3801. returnErrorMsg("找不到订单记录");
  3802. }
  3803. }
  3804. public void assign_erp_supplier()
  3805. {
  3806. if (UrlPostParmsCheck("ctid"))
  3807. {
  3808. string eids = GetPostString("ctid");
  3809. int sid = GetPostInt("SupplierName");
  3810. string fromTag = GetPostString("tag");
  3811. string[] eidList = eids.Split(',');
  3812. if (eidList.Length <= 0)
  3813. {
  3814. returnErrorMsg("指派不能为空");
  3815. return;
  3816. }
  3817. string errMsg = "";
  3818. string suname = commonHelper.getSupplierNameById(sid);
  3819. foreach (string ctid in eidList)
  3820. {
  3821. CeErpTradeCell entity = null;
  3822. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3823. if (entity != null)
  3824. {
  3825. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3826. {
  3827. errMsg += (ctid + "指派失败!!!");
  3828. continue;
  3829. }
  3830. entity.SupplierId = sid;
  3831. entity.Update();
  3832. commonHelper.UpdateRelationOrder(entity.ctid);
  3833. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3834. if (entity.OrderState >= 6)
  3835. {
  3836. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3837. //{
  3838. // string msl = entity.MakeSupplier;
  3839. // string[] mslist = msl.Split(',');
  3840. // 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);
  3841. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3842. //}
  3843. //else
  3844. //{
  3845. StringBuilder sql = new StringBuilder();
  3846. 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);
  3847. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3848. //}
  3849. }
  3850. }
  3851. else
  3852. {
  3853. continue;
  3854. }
  3855. }
  3856. if (errMsg.Length > 0)
  3857. {
  3858. returnErrorMsg(errMsg);
  3859. return;
  3860. }
  3861. returnSuccessMsg("操作成功!");
  3862. return;
  3863. }
  3864. }
  3865. public void assign_erp_makesupplier()
  3866. {
  3867. if (UrlPostParmsCheck("ctid"))
  3868. {
  3869. string eids = GetPostString("ctid");
  3870. string sname = GetPostString("SupplierName");
  3871. string[] eidList = eids.Split(',');
  3872. if (eidList.Length <= 0)
  3873. {
  3874. returnErrorMsg("指派不能为空");
  3875. return;
  3876. }
  3877. List<string> tLst = new List<string>();
  3878. foreach (string ctid in eidList)
  3879. {
  3880. CeErpTradeCell entity = null;
  3881. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3882. if (entity != null)
  3883. {
  3884. entity.MakeSupplier = sname;
  3885. entity.Update();
  3886. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3887. tLst.Add("'" + ctid + "'");
  3888. }
  3889. else
  3890. {
  3891. continue;
  3892. }
  3893. }
  3894. string ctids = string.Join(",", tLst.ToArray());
  3895. StringBuilder sql2 = new StringBuilder();
  3896. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3897. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3898. returnSuccessMsg("操作成功!");
  3899. return;
  3900. }
  3901. }
  3902. public void ins_erp_returnreason()
  3903. {
  3904. if (UrlPostParmsCheck("ctid"))
  3905. {
  3906. string eid = GetPostString("ctid");
  3907. CeErpTradeCell entity = null;
  3908. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3909. string userpost = CurrentUser.UserPost.Post.Code;
  3910. if (entity != null)
  3911. {
  3912. bool isPlace = false;
  3913. if (entity.OrderState > 6)
  3914. {
  3915. returnErrorMsg("已发货无法打回!");
  3916. return;
  3917. }
  3918. if (entity.OrderState == 6)
  3919. {
  3920. isPlace = true;
  3921. }
  3922. bool isNeedUpdateCell2 = false;
  3923. if (entity.OrderState >= 6)
  3924. {
  3925. isNeedUpdateCell2 = true;
  3926. }
  3927. int returnTag = 2;
  3928. if (userpost == "Supplier")
  3929. {
  3930. returnTag = 1;
  3931. }
  3932. int toType = GetPostInt("totype");
  3933. string fromType = "3";
  3934. if (entity.OrderState < 5)
  3935. {
  3936. fromType = "3";
  3937. }
  3938. else
  3939. {
  3940. fromType = "4";
  3941. }
  3942. if (entity.IsXianHuo == 0)
  3943. {
  3944. if (returnTag == 2)
  3945. {
  3946. if (toType == 1)
  3947. {
  3948. entity.OrderState = 0;
  3949. entity.ReturnUserType = 1;
  3950. string clearman = GetPostString("clearman");
  3951. if (!string.IsNullOrEmpty(clearman))
  3952. {
  3953. entity.DesignUserId = 0;
  3954. }
  3955. }
  3956. else
  3957. {
  3958. entity.OrderState = 3;
  3959. entity.ReturnUserType = 2;
  3960. }
  3961. entity.IsReadTag = 1;
  3962. }
  3963. else if (returnTag == 1)
  3964. {
  3965. entity.OrderState = 5;
  3966. }
  3967. entity.IsVerifyToSupplier = false;
  3968. }
  3969. if (entity.IsXianHuo == 1)
  3970. {
  3971. entity.OrderState = 5;
  3972. }
  3973. entity.UnusualTag = 0;
  3974. entity.UnusualTime = null;
  3975. entity.UnusualCon = "";
  3976. entity.IsReturn = returnTag;
  3977. entity.ReturnTime = DateTime.Now;
  3978. entity.UpdateTime = DateTime.Now;
  3979. entity.ReturnReason = GetPostString("returnreason");
  3980. entity.Update();
  3981. if (entity.OrderState == 3)
  3982. {
  3983. ApiVo apiVo = new ApiVo();
  3984. apiVo.orderNumber = entity.ctid;
  3985. apiVo.actionName = "rebutDesign";
  3986. apiVo.orderRemarks = entity.ReturnReason;
  3987. designHelper.API_WorkCore(apiVo);//rebutDesign
  3988. }
  3989. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3990. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3991. {
  3992. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3993. }
  3994. CeErpSukuraData.createInfo(entity.ctid, 5);
  3995. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3996. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3997. if (isPlace)
  3998. {
  3999. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  4000. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4001. if (dth != null && dth.Rows.Count > 0)
  4002. {
  4003. dataSendOrderBean dataSendOrderBean = null;
  4004. foreach (DataRow item in dth.Rows)
  4005. {
  4006. try
  4007. {
  4008. dataSendOrderBean = new dataSendOrderBean();
  4009. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  4010. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  4011. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  4012. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  4013. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  4014. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  4015. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  4016. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  4017. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  4018. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  4019. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  4020. dataSendOrderBean.Radio1723534706288 = "打回";
  4021. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  4022. if (result != null)
  4023. {
  4024. if ("0".Equals(result.errcode))
  4025. {
  4026. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  4027. }
  4028. else
  4029. {
  4030. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  4031. }
  4032. }
  4033. }
  4034. catch (Exception ex)
  4035. {
  4036. }
  4037. }
  4038. }
  4039. }
  4040. if (isNeedUpdateCell2)
  4041. {
  4042. if (entity.MakeSupplier.IndexOf(",") != -1)
  4043. {
  4044. StringBuilder sql2 = new StringBuilder();
  4045. 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);
  4046. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4047. }
  4048. else
  4049. {
  4050. StringBuilder sql2 = new StringBuilder();
  4051. 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);
  4052. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4053. }
  4054. }
  4055. returnSuccessMsg("操作成功!");
  4056. return;
  4057. }
  4058. returnErrorMsg("找不到订单记录");
  4059. }
  4060. }
  4061. public void cyt_erp_returnreason()
  4062. {
  4063. if (UrlPostParmsCheck("ctid"))
  4064. {
  4065. string eid = GetPostString("ctid");
  4066. CeErpTradeCell entity = null;
  4067. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4068. string userpost = CurrentUser.UserPost.Post.Code;
  4069. if (entity != null)
  4070. {
  4071. if (entity.OrderState > 6)
  4072. {
  4073. returnErrorMsg("已发货无法打回!");
  4074. return;
  4075. }
  4076. JObject jsonObject = new JObject
  4077. {
  4078. { "Userid", "77886" },
  4079. { "Pwd", "lt666888" },
  4080. { "LTOrderId",eid }
  4081. };
  4082. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4083. JObject jsonObjects = JObject.Parse(response);
  4084. string msg = (string)jsonObjects["msg"];
  4085. if (msg != "取消成功")
  4086. {
  4087. returnErrorMsg(msg);
  4088. return;
  4089. }
  4090. bool isNeedUpdateCell2 = false;
  4091. if (entity.OrderState >= 6)
  4092. {
  4093. isNeedUpdateCell2 = true;
  4094. }
  4095. int returnTag = 2;
  4096. if (userpost == "Supplier")
  4097. {
  4098. returnTag = 1;
  4099. }
  4100. if (entity.IsXianHuo == 0)
  4101. {
  4102. if (returnTag == 2)
  4103. {
  4104. int toType = GetPostInt("totype");
  4105. if (toType == 1)
  4106. {
  4107. entity.OrderState = 0;
  4108. entity.ReturnUserType = 1;
  4109. }
  4110. else
  4111. {
  4112. entity.OrderState = 4;
  4113. entity.ReturnUserType = 2;
  4114. }
  4115. entity.IsReadTag = 1;
  4116. }
  4117. else if (returnTag == 1)
  4118. {
  4119. entity.OrderState = 5;
  4120. }
  4121. entity.IsVerifyToSupplier = false;
  4122. }
  4123. entity.UnusualTag = 0;
  4124. entity.UnusualTime = null;
  4125. entity.UnusualCon = "";
  4126. entity.IsReturn = returnTag;
  4127. entity.ReturnTime = DateTime.Now;
  4128. entity.ReturnReason = GetPostString("returnreason");
  4129. entity.Update();
  4130. if (entity.OrderState == 4)
  4131. {
  4132. ApiVo apiVo = new ApiVo();
  4133. apiVo.orderNumber = entity.ctid;
  4134. apiVo.actionName = "rebutDesign";
  4135. apiVo.orderRemarks = entity.ReturnReason;
  4136. designHelper.API_WorkCore(apiVo);//rebutDesign
  4137. }
  4138. CeErpSukuraData.createInfo(entity.ctid, 5);
  4139. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4140. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4141. if (isNeedUpdateCell2)
  4142. {
  4143. if (entity.MakeSupplier.IndexOf(",") != -1)
  4144. {
  4145. StringBuilder sql2 = new StringBuilder();
  4146. 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);
  4147. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4148. }
  4149. else
  4150. {
  4151. StringBuilder sql2 = new StringBuilder();
  4152. 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);
  4153. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4154. }
  4155. }
  4156. returnSuccessMsg("操作成功!");
  4157. return;
  4158. }
  4159. returnErrorMsg("找不到订单记录");
  4160. }
  4161. }
  4162. public void upd_erp_xianhuoreturntag()
  4163. {
  4164. if (UrlPostParmsCheck("ctid"))
  4165. {
  4166. string eids = GetPostString("ctid");
  4167. string[] ctids = eids.Split(',');
  4168. foreach (string ctid in ctids)
  4169. {
  4170. CeErpTradeCell entity = null;
  4171. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4172. if (entity != null)
  4173. {
  4174. entity.IsReturn = 0;
  4175. entity.Update();
  4176. CeErpSukuraData.createInfo(entity.ctid, 5);
  4177. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4178. }
  4179. }
  4180. returnSuccessMsg("操作成功!");
  4181. return;
  4182. }
  4183. }
  4184. public void get_erp_waitdeliverylist()
  4185. {
  4186. DataStruct dStruct = GetPostStruct();
  4187. List<string> lw = new List<string>();
  4188. string tid = GetPostString("ctid");
  4189. if (tid.Length > 0)
  4190. {
  4191. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4192. if (tid.Length > 5)
  4193. {
  4194. List<string> tids = getTidByCtidLike(tid);
  4195. if (tids.Count > 0 && tids.Count < 10)
  4196. {
  4197. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4198. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4199. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4200. {
  4201. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4202. }*/
  4203. }
  4204. }
  4205. lw.Add(tid_sql);
  4206. }
  4207. string shopname = GetPostString("shopname");
  4208. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4209. string buyernick = GetPostString("buyer_nick");
  4210. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4211. //if (tid.Length == 0 && buyernick.Length == 0)
  4212. //{
  4213. // lw.Add(string.Format("IsRefund<={0}", 1));
  4214. //}
  4215. string customer = GetPostString("customer");
  4216. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4217. string design = GetPostString("design");
  4218. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4219. string orderState = GetPostString("orderState");
  4220. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4221. string address = GetPostString("address");
  4222. 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));
  4223. string sellermemo = GetPostString("seller_memo");
  4224. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4225. string supplier = GetPostString("supplier");
  4226. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4227. string OrderArea = GetPostString("order_area");
  4228. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4229. string placedate1 = GetPostString("placedate1");
  4230. string placedate2 = GetPostString("placedate2");
  4231. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4232. if (fdw.Length > 0) lw.Add(fdw);
  4233. string price1 = GetPostString("price1");
  4234. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4235. string price2 = GetPostString("price2");
  4236. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4237. string unusualCon = GetPostString("unusualcon");
  4238. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4239. string otherMemo = GetPostString("otherMemo");
  4240. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4241. string posTag = CurrentUser.UserPost.Post.Code;
  4242. if (posTag == "Supplier")
  4243. {
  4244. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4245. }
  4246. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4247. lw.Add(string.Format("type != 'PDD' "));
  4248. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4249. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4250. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4251. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4252. writeGridDataTableJson(dStruct.TotalCount, dt);
  4253. }
  4254. public void get_erp_changedeliverylist()
  4255. {
  4256. DataStruct dStruct = GetPostStruct();
  4257. List<string> lw = new List<string>();
  4258. string tid = GetPostString("ctid");
  4259. if (tid.Length > 0)
  4260. {
  4261. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4262. if (tid.Length > 5)
  4263. {
  4264. List<string> tids = getTidByCtidLike(tid);
  4265. if (tids.Count > 0 && tids.Count < 10)
  4266. {
  4267. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4268. }
  4269. }
  4270. lw.Add(tid_sql);
  4271. }
  4272. string shopname = GetPostString("shopname");
  4273. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4274. string buyernick = GetPostString("buyer_nick");
  4275. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4276. //if (tid.Length == 0 && buyernick.Length == 0)
  4277. //{
  4278. // lw.Add(string.Format("IsRefund<={0}", 1));
  4279. //}
  4280. string customer = GetPostString("customer");
  4281. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4282. string design = GetPostString("design");
  4283. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4284. string orderState = GetPostString("orderState");
  4285. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4286. string address = GetPostString("address");
  4287. 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));
  4288. string sellermemo = GetPostString("seller_memo");
  4289. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4290. string supplier = GetPostString("supplier");
  4291. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4292. string OrderArea = GetPostString("order_area");
  4293. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4294. string placedate1 = GetPostString("placedate1");
  4295. string placedate2 = GetPostString("placedate2");
  4296. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4297. if (fdw.Length > 0) lw.Add(fdw);
  4298. string price1 = GetPostString("price1");
  4299. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4300. string price2 = GetPostString("price2");
  4301. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4302. string unusualCon = GetPostString("unusualcon");
  4303. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4304. string otherMemo = GetPostString("otherMemo");
  4305. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4306. string posTag = CurrentUser.UserPost.Post.Code;
  4307. if (posTag == "Supplier")
  4308. {
  4309. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4310. }
  4311. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4312. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4313. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4314. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4315. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4316. /*if (tid.Length > 0)
  4317. {
  4318. List<string> tids = new List<string>();
  4319. if (dt != null && dt.Rows.Count > 0)
  4320. {
  4321. foreach (DataRow item in dt.Rows)
  4322. {
  4323. tids.Add("'" + item["tid"] + "'");
  4324. }
  4325. }
  4326. if (tids.Count > 0)
  4327. {
  4328. lw.RemoveAt(0);
  4329. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4330. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4331. dt = WebCache.GetData("view_erptradecell", dStruct);
  4332. }
  4333. }*/
  4334. writeGridDataTableJson(dStruct.TotalCount, dt);
  4335. }
  4336. public void get_erp_pddderiving()
  4337. {
  4338. DataStruct dStruct = GetPostStruct();
  4339. List<string> lw = new List<string>();
  4340. string tid = GetPostString("ctid");
  4341. if (tid.Length > 0)
  4342. {
  4343. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4344. if (tid.Length > 5)
  4345. {
  4346. List<string> tids = getTidByCtidLike(tid);
  4347. if (tids.Count > 0 && tids.Count < 10)
  4348. {
  4349. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4350. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4351. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4352. {
  4353. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4354. }*/
  4355. }
  4356. }
  4357. lw.Add(tid_sql);
  4358. }
  4359. string shopname = GetPostString("shopname");
  4360. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4361. string buyernick = GetPostString("buyer_nick");
  4362. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4363. //if (tid.Length == 0 && buyernick.Length == 0)
  4364. //{
  4365. // lw.Add(string.Format("IsRefund<={0}", 1));
  4366. //}
  4367. string customer = GetPostString("customer");
  4368. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4369. string design = GetPostString("design");
  4370. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4371. string orderState = GetPostString("orderState");
  4372. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4373. string address = GetPostString("address");
  4374. 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));
  4375. string sellermemo = GetPostString("seller_memo");
  4376. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4377. string supplier = GetPostString("supplier");
  4378. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4379. string OrderArea = GetPostString("order_area");
  4380. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4381. string placedate1 = GetPostString("placedate1");
  4382. string placedate2 = GetPostString("placedate2");
  4383. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4384. if (fdw.Length > 0) lw.Add(fdw);
  4385. string price1 = GetPostString("price1");
  4386. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4387. string price2 = GetPostString("price2");
  4388. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4389. string unusualCon = GetPostString("unusualcon");
  4390. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4391. string posTag = CurrentUser.UserPost.Post.Code;
  4392. if (posTag == "Supplier")
  4393. {
  4394. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4395. }
  4396. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4397. lw.Add(string.Format("type = 'PDD' "));
  4398. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4399. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4400. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4401. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4402. /*if (tid.Length > 0)
  4403. {
  4404. List<string> tids = new List<string>();
  4405. if (dt != null && dt.Rows.Count > 0)
  4406. {
  4407. foreach (DataRow item in dt.Rows)
  4408. {
  4409. tids.Add("'" + item["tid"] + "'");
  4410. }
  4411. }
  4412. if (tids.Count > 0)
  4413. {
  4414. lw.RemoveAt(0);
  4415. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4416. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4417. dt = WebCache.GetData("view_erptradecell", dStruct);
  4418. }
  4419. }*/
  4420. writeGridDataTableJson(dStruct.TotalCount, dt);
  4421. }
  4422. public void get_erp_jdderiving()
  4423. {
  4424. DataStruct dStruct = GetPostStruct();
  4425. List<string> lw = new List<string>();
  4426. string tid = GetPostString("ctid");
  4427. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4428. string shopname = GetPostString("shopname");
  4429. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4430. string buyernick = GetPostString("buyer_nick");
  4431. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4432. //if (tid.Length == 0 && buyernick.Length == 0)
  4433. //{
  4434. // lw.Add(string.Format("IsRefund<={0}", 1));
  4435. //}
  4436. string customer = GetPostString("customer");
  4437. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4438. string design = GetPostString("design");
  4439. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4440. string orderState = GetPostString("orderState");
  4441. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4442. string address = GetPostString("address");
  4443. 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));
  4444. string sellermemo = GetPostString("seller_memo");
  4445. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4446. string supplier = GetPostString("supplier");
  4447. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4448. string OrderArea = GetPostString("order_area");
  4449. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4450. string placedate1 = GetPostString("placedate1");
  4451. string placedate2 = GetPostString("placedate2");
  4452. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4453. if (fdw.Length > 0) lw.Add(fdw);
  4454. string price1 = GetPostString("price1");
  4455. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4456. string price2 = GetPostString("price2");
  4457. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4458. string unusualCon = GetPostString("unusualcon");
  4459. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4460. string posTag = CurrentUser.UserPost.Post.Code;
  4461. if (posTag == "Supplier")
  4462. {
  4463. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4464. }
  4465. lw.Add(string.Format("OrderState = 6 "));
  4466. lw.Add(string.Format("type = 'JD' "));
  4467. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4468. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4469. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4470. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4471. writeGridDataTableJson(dStruct.TotalCount, dt);
  4472. }
  4473. public void get_erp_demoorderlist()
  4474. {
  4475. DataStruct dStruct = GetPostStruct();
  4476. List<string> lw = new List<string>();
  4477. string tid = GetPostString("ctid");
  4478. if (tid.Length > 0)
  4479. {
  4480. string select_tid = getTidByCtid(tid);
  4481. lw.Add(string.Format("tid='{0}'", select_tid));
  4482. }
  4483. string shopname = GetPostString("shopname");
  4484. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4485. string buyernick = GetPostString("buyer_nick");
  4486. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4487. string customer = GetPostString("customer");
  4488. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4489. string design = GetPostString("design");
  4490. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4491. string orderState = GetPostString("orderState");
  4492. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4493. string address = GetPostString("address");
  4494. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4495. string sellermemo = GetPostString("seller_memo");
  4496. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4497. string supplier = GetPostString("supplier");
  4498. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4499. string OrderArea = GetPostString("order_area");
  4500. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4501. string date1 = GetPostString("date1");
  4502. string date2 = GetPostString("date2");
  4503. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4504. if (dw.Length > 0) lw.Add(dw);
  4505. string price1 = GetPostString("price1");
  4506. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4507. string price2 = GetPostString("price2");
  4508. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4509. string posTag = CurrentUser.UserPost.Post.Code;
  4510. if (posTag == "Supplier")
  4511. {
  4512. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4513. }
  4514. //lw.Add(string.Format("OrderState = 6 "));
  4515. lw.Add(string.Format("IsSample={0}", 3));
  4516. lw.Add(string.Format("IsRefund<={0}", 1));
  4517. dStruct.Order = "pay_time desc";
  4518. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4519. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4520. writeGridDataTableJson(dStruct.TotalCount, dt);
  4521. }
  4522. public void save_erp_checkmemo()
  4523. {
  4524. if (UrlPostParmsCheck("ctid"))
  4525. {
  4526. string ctid = GetPostString("ctid");
  4527. CeErpTradeCell entity = null;
  4528. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4529. if (entity != null)
  4530. {
  4531. entity.CheckMemo = GetPostString("CheckMemo");
  4532. entity.Update();
  4533. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4534. if (trade != null)
  4535. {
  4536. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4537. }
  4538. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4539. returnSuccessMsg("保存成功!");
  4540. return;
  4541. }
  4542. returnErrorMsg("找不到记录");
  4543. }
  4544. }
  4545. public void get_erp_returnlist()
  4546. {
  4547. DataStruct dStruct = GetPostStruct();
  4548. List<string> lw = new List<string>();
  4549. string tid = GetPostString("ctid");
  4550. if (tid.Length > 0)
  4551. {
  4552. string select_tid = getTidByCtid(tid);
  4553. lw.Add(string.Format("tid='{0}'", select_tid));
  4554. }
  4555. string shopname = GetPostString("shopname");
  4556. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4557. string buyernick = GetPostString("buyer_nick");
  4558. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4559. string customer = GetPostString("customer");
  4560. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4561. string design = GetPostString("design");
  4562. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4563. string orderState = GetPostString("orderState");
  4564. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4565. string address = GetPostString("address");
  4566. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4567. string sellermemo = GetPostString("seller_memo");
  4568. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4569. string supplier = GetPostString("supplier");
  4570. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4571. string date1 = GetPostString("date1");
  4572. string date2 = GetPostString("date2");
  4573. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4574. if (dw.Length > 0) lw.Add(dw);
  4575. string bdate1 = GetPostString("backdate1");
  4576. string bdate2 = GetPostString("backdate2");
  4577. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4578. if (dw_back.Length > 0) lw.Add(dw_back);
  4579. string price1 = GetPostString("price1");
  4580. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4581. string price2 = GetPostString("price2");
  4582. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4583. lw.Add(string.Format("IsReturn>0"));
  4584. lw.Add(string.Format("IsXianHuo=0"));
  4585. lw.Add(string.Format("IsReturn!=3"));
  4586. string backtype = GetPostString("backtype");
  4587. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4588. dStruct.Order = "FinishDesignTime desc";
  4589. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4590. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4591. writeGridDataTableJson(dStruct.TotalCount, dt);
  4592. }
  4593. public void get_erp_today_sumreturn()
  4594. {
  4595. DataStruct dStruct = GetPostStruct();
  4596. List<string> lw = new List<string>();
  4597. string bdate1 = GetPostString("returnTimeS");
  4598. string bdate2 = GetPostString("returnTimeE");
  4599. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4600. if (dw_back.Length > 0) lw.Add(dw_back);
  4601. lw.Add(string.Format("IsReturn=0"));
  4602. lw.Add(string.Format("IsXianHuo=0"));
  4603. string mainWhere = string.Join(" and ", lw.ToArray());
  4604. string sql = "";
  4605. if (dw_back.Length > 0)
  4606. {
  4607. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4608. }
  4609. else
  4610. {
  4611. 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 + "'";
  4612. }
  4613. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4614. decimal total = 0, today_finish = 0;
  4615. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4616. {
  4617. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4618. }
  4619. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4620. {
  4621. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4622. }
  4623. var res = new
  4624. {
  4625. data = total,
  4626. data1 = today_finish,
  4627. };
  4628. string ro_jsond = JsonConvert.SerializeObject(res);
  4629. returnSuccess(ro_jsond);
  4630. return;
  4631. }
  4632. public void get_erp_allreturnlist()
  4633. {
  4634. DataStruct dStruct = GetPostStruct();
  4635. List<string> lw = new List<string>();
  4636. string tid = GetPostString("ctid");
  4637. if (tid.Length > 0)
  4638. {
  4639. string select_tid = getTidByCtid(tid);
  4640. lw.Add(string.Format("tid='{0}'", select_tid));
  4641. }
  4642. string shopname = GetPostString("shopname");
  4643. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4644. string buyernick = GetPostString("buyer_nick");
  4645. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4646. string customer = GetPostString("customer");
  4647. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4648. string design = GetPostString("design");
  4649. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4650. string orderState = GetPostString("orderState");
  4651. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4652. string address = GetPostString("address");
  4653. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4654. string sellermemo = GetPostString("seller_memo");
  4655. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4656. string supplier = GetPostString("supplier");
  4657. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4658. string date1 = GetPostString("date1");
  4659. string date2 = GetPostString("date2");
  4660. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4661. if (dw.Length > 0) lw.Add(dw);
  4662. string bdate1 = GetPostString("backdate1");
  4663. string bdate2 = GetPostString("backdate2");
  4664. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4665. if (dw_back.Length > 0) lw.Add(dw_back);
  4666. string price1 = GetPostString("price1");
  4667. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4668. string price2 = GetPostString("price2");
  4669. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4670. string backreason = GetPostString("backreason");
  4671. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4672. lw.Add(string.Format("IsXianHuo=0"));
  4673. lw.Add(string.Format("ReturnTime != ''"));
  4674. string backtype = GetPostString("backtype");
  4675. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4676. dStruct.Order = "FinishDesignTime desc";
  4677. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4678. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4679. writeGridDataTableJson(dStruct.TotalCount, dt);
  4680. }
  4681. public void get_erp_aftersalereturnlist()
  4682. {
  4683. DataStruct dStruct = GetPostStruct();
  4684. List<string> lw = new List<string>();
  4685. string tid = GetPostString("ctid");
  4686. if (tid.Length > 0)
  4687. {
  4688. string select_tid = getTidByCtid(tid);
  4689. lw.Add(string.Format("tid='{0}'", select_tid));
  4690. }
  4691. string shopname = GetPostString("shopname");
  4692. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4693. string buyernick = GetPostString("buyer_nick");
  4694. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4695. string customer = GetPostString("customer");
  4696. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4697. string design = GetPostString("design");
  4698. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4699. string orderState = GetPostString("orderState");
  4700. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4701. string address = GetPostString("address");
  4702. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4703. string sellermemo = GetPostString("seller_memo");
  4704. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4705. string supplier = GetPostString("supplier");
  4706. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4707. string date1 = GetPostString("date1");
  4708. string date2 = GetPostString("date2");
  4709. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4710. if (dw.Length > 0) lw.Add(dw);
  4711. string bdate1 = GetPostString("backdate1");
  4712. string bdate2 = GetPostString("backdate2");
  4713. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4714. if (dw_back.Length > 0) lw.Add(dw_back);
  4715. string price1 = GetPostString("price1");
  4716. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4717. string price2 = GetPostString("price2");
  4718. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4719. lw.Add(string.Format("IsReturn=3"));
  4720. string backtype = GetPostString("backtype");
  4721. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4722. string backreason = GetPostString("backreason");
  4723. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4724. dStruct.Order = "ReturnTime desc";
  4725. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4726. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4727. writeGridDataTableJson(dStruct.TotalCount, dt);
  4728. }
  4729. public void get_erp_xianhuoreturnlist()
  4730. {
  4731. DataStruct dStruct = GetPostStruct();
  4732. List<string> lw = new List<string>();
  4733. string tid = GetPostString("ctid");
  4734. if (tid.Length > 0)
  4735. {
  4736. string select_tid = getTidByCtid(tid);
  4737. lw.Add(string.Format("tid='{0}'", select_tid));
  4738. }
  4739. string shopname = GetPostString("shopname");
  4740. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4741. string buyernick = GetPostString("buyer_nick");
  4742. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4743. string customer = GetPostString("customer");
  4744. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4745. string design = GetPostString("design");
  4746. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4747. string orderState = GetPostString("orderState");
  4748. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4749. string address = GetPostString("address");
  4750. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4751. string sellermemo = GetPostString("seller_memo");
  4752. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4753. string supplier = GetPostString("supplier");
  4754. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4755. string OrderArea = GetPostString("order_area");
  4756. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4757. string date1 = GetPostString("date1");
  4758. string date2 = GetPostString("date2");
  4759. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4760. if (dw.Length > 0) lw.Add(dw);
  4761. string price1 = GetPostString("price1");
  4762. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4763. string price2 = GetPostString("price2");
  4764. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4765. string posTag = CurrentUser.UserPost.Post.Code;
  4766. if (posTag == "Supplier")
  4767. {
  4768. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4769. }
  4770. lw.Add(string.Format("OrderState=6 "));
  4771. lw.Add(string.Format("IsXianHuo=1 "));
  4772. lw.Add(string.Format("IsReturn>0 "));
  4773. lw.Add(string.Format("IsReturn!=3"));
  4774. lw.Add(string.Format("IsRefund<={0}", 1));
  4775. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4776. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4777. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4778. writeGridDataTableJson(dStruct.TotalCount, dt);
  4779. }
  4780. public void set_erp_orderdelivery()
  4781. {
  4782. if (UrlPostParmsCheck("ctid"))
  4783. {
  4784. string eid = GetPostString("ctid");
  4785. CeErpTradeCell entity = null;
  4786. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4787. if (entity != null)
  4788. {
  4789. if (entity.OrderState >= 7)
  4790. {
  4791. returnErrorMsg("此单已发货,无需重复发货");
  4792. return;
  4793. }
  4794. if (entity.OrderState != 6)
  4795. {
  4796. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4797. return;
  4798. }
  4799. string shop = GetPostString("seller_nick");
  4800. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4801. string comName = GetPostString("comName");
  4802. string comCode = GetPostString("comCode");
  4803. string outSid = GetPostString("outSid");
  4804. string deliveryType = GetPostString("deliveryType");
  4805. string deliveryMemo = GetPostString("deliveryMemo");
  4806. outSid = outSid.Trim();
  4807. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4808. if (mainEn == null)
  4809. {
  4810. returnErrorMsg("找不到原始订单记录");
  4811. return;
  4812. }
  4813. bool isInitOrderDeliv = false;
  4814. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4815. {
  4816. isInitOrderDeliv = true;
  4817. }
  4818. string apires = "";
  4819. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4820. 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)
  4821. {
  4822. apires = "发货成功true";
  4823. }
  4824. else
  4825. {
  4826. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4827. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4828. }
  4829. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4830. {
  4831. entity.OrderState = 7;//发货后订单已发货
  4832. entity.OutSid = outSid;
  4833. entity.MemoOpt = 0;
  4834. entity.UpdateTime = DateTime.Now;
  4835. entity.FinishDeliveryTime = DateTime.Now;
  4836. entity.Update();
  4837. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4838. commonHelper.UpdateRelationOrder(entity.ctid);
  4839. //还要插入快递信息到 快递信息表
  4840. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4841. exinfo.tid = eid;
  4842. exinfo.out_sid = outSid;
  4843. exinfo.company_code = comCode;
  4844. exinfo.company_name = comName;
  4845. exinfo.delivery_memo = deliveryMemo;
  4846. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4847. exinfo.deliveryType = deliveryType;
  4848. exinfo.Create();
  4849. returnSuccessMsg("发货操作成功!");
  4850. commonHelper.UpdateRelationOrder(entity.ctid);
  4851. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4852. CeErpSukuraData.createInfo(entity.ctid, 4);
  4853. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  4854. {
  4855. commonHelper.sendCytExpress(exinfo);
  4856. }
  4857. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4858. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid + ",备注:" + deliveryMemo, entity.OrderState);
  4859. }
  4860. else
  4861. {
  4862. string errmsg = commonHelper.KeepChinese(apires);
  4863. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4864. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4865. }
  4866. return;
  4867. }
  4868. returnErrorMsg("找不到订单记录");
  4869. }
  4870. }
  4871. public void set_erp_multidelivery()
  4872. {
  4873. string eids = GetPostString("tids");
  4874. string[] eidList = eids.Split(',');
  4875. if (eidList.Length <= 0)
  4876. {
  4877. returnErrorMsg("发货不能为空");
  4878. return;
  4879. }
  4880. foreach (string ctid in eidList)
  4881. {
  4882. if (ctid.Length <= 0) continue;
  4883. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4884. if (expInfo != null)
  4885. {
  4886. StringBuilder sql = new StringBuilder();
  4887. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4888. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4889. if (dt.Rows.Count > 0)
  4890. {
  4891. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4892. {
  4893. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4894. expInfo.state = "异常";
  4895. expInfo.isMultiDelivery = 1;
  4896. expInfo.Update();
  4897. continue;
  4898. }
  4899. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4900. {
  4901. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4902. expInfo.state = "异常";
  4903. expInfo.Update();
  4904. continue;
  4905. }
  4906. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4907. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4908. bool isInitOrderDeliv = false;
  4909. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4910. {
  4911. isInitOrderDeliv = true;
  4912. expInfo.isMultiDelivery = 1;
  4913. }
  4914. if (ctid.IndexOf("N") != -1)
  4915. {
  4916. StringBuilder sqlbucha = new StringBuilder();
  4917. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4918. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4919. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4920. commonHelper.UpdateRelationOrder(ctid);
  4921. expInfo.delivery_memo = "发货成功";
  4922. expInfo.state = "发货成功";
  4923. expInfo.isMultiDelivery = 1;
  4924. expInfo.Update();
  4925. }
  4926. else
  4927. {
  4928. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4929. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4930. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4931. {
  4932. expInfo.delivery_memo = "发货成功";
  4933. expInfo.state = "发货成功";
  4934. expInfo.isMultiDelivery = 1;
  4935. expInfo.Update();
  4936. commonHelper.UpdateRelationOrder(ctid);
  4937. CeErpSukuraData.createInfo(ctid, 4);
  4938. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4939. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4940. }
  4941. else
  4942. {
  4943. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4944. expInfo.state = "异常";
  4945. expInfo.Update();
  4946. }
  4947. }
  4948. }
  4949. }
  4950. }
  4951. returnSuccessMsg("操作完成");
  4952. }
  4953. public void reset_erp_memoopt()
  4954. {
  4955. if (UrlPostParmsCheck("ctid"))
  4956. {
  4957. string eid = GetPostString("ctid");
  4958. CeErpTradeCell entity = null;
  4959. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4960. if (entity != null)
  4961. {
  4962. string stropt = "";
  4963. if (entity.MemoOpt == 1)
  4964. {
  4965. stropt = "“改稿”";
  4966. }
  4967. else if (entity.MemoOpt == 2)
  4968. {
  4969. stropt = "“定稿”";
  4970. }
  4971. else if (entity.MemoOpt == 3)
  4972. {
  4973. stropt = "“完成查货”";
  4974. CeErpSukuraData.createInfo(entity.ctid, 6);
  4975. }
  4976. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4977. entity.UpdateTime = DateTime.Now;
  4978. entity.MemoOpt = 0;
  4979. entity.Update();
  4980. returnSuccessMsg("操作成功!");
  4981. return;
  4982. }
  4983. returnErrorMsg("找不到记录");
  4984. }
  4985. }
  4986. public void get_erp_deliveryunusual()
  4987. {
  4988. DataStruct dStruct = GetPostStruct();
  4989. List<string> lw = new List<string>();
  4990. string tid = GetPostString("ctid");
  4991. if (tid.Length > 0)
  4992. {
  4993. string select_tid = getTidByCtid(tid);
  4994. lw.Add(string.Format("tid='{0}'", select_tid));
  4995. }
  4996. string shopname = GetPostString("shopname");
  4997. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4998. string buyernick = GetPostString("buyer_nick");
  4999. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5000. string customer = GetPostString("customer");
  5001. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5002. string design = GetPostString("design");
  5003. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5004. string sellermemo = GetPostString("seller_memo");
  5005. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5006. string supplier = GetPostString("supplier");
  5007. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5008. string date1 = GetPostString("date1");
  5009. string date2 = GetPostString("date2");
  5010. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5011. if (dw.Length > 0) lw.Add(dw);
  5012. string placedate1 = GetPostString("placedate1");
  5013. string placedate2 = GetPostString("placedate2");
  5014. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5015. if (dw_place.Length > 0) lw.Add(dw_place);
  5016. string price1 = GetPostString("price1");
  5017. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5018. string price2 = GetPostString("price2");
  5019. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5020. string unusualCon = GetPostString("unusualcon");
  5021. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  5022. string posTag = CurrentUser.UserPost.Post.Code;
  5023. if (posTag == "Supplier")
  5024. {
  5025. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5026. }
  5027. lw.Add(string.Format("OrderState = 6"));
  5028. lw.Add(string.Format("UnusualTag = 5"));
  5029. lw.Add(string.Format("IsRefund<={0}", 1));
  5030. dStruct.Order = "FinishPlaceTime desc";
  5031. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5032. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5033. writeGridDataTableJson(dStruct.TotalCount, dt);
  5034. }
  5035. public void get_erp_deliveryedlist()
  5036. {
  5037. DataStruct dStruct = GetPostStruct();
  5038. List<string> lw = new List<string>();
  5039. string tid = GetPostString("ctid");
  5040. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5041. string shopname = GetPostString("shopname");
  5042. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5043. string buyernick = GetPostString("buyer_nick");
  5044. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5045. string customer = GetPostString("customer");
  5046. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5047. string design = GetPostString("design");
  5048. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5049. string sellermemo = GetPostString("seller_memo");
  5050. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5051. string logistics = GetPostString("logistics");
  5052. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5053. string date1 = GetPostString("date1");
  5054. string date2 = GetPostString("date2");
  5055. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5056. //if (dw.Length > 0) lw.Add(dw);
  5057. string placedate1 = GetPostString("placedate1");
  5058. string placedate2 = GetPostString("placedate2");
  5059. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5060. if (fdw.Length > 0) lw.Add(fdw);
  5061. string devdate1 = GetPostString("deliverydate1");
  5062. string devdate2 = GetPostString("deliverydate2");
  5063. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5064. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5065. string price1 = GetPostString("price1");
  5066. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5067. string price2 = GetPostString("price2");
  5068. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5069. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5070. {
  5071. if (tid.Length > 0)
  5072. {
  5073. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5074. if (tid.Length > 5)
  5075. {
  5076. List<string> tids = getTidByCtidLike(tid);
  5077. if (tids.Count > 0 && tids.Count < 10)
  5078. {
  5079. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5080. }
  5081. }
  5082. lw.Add(tid_sql);
  5083. }
  5084. if (buyernick.Length > 0)
  5085. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5086. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5087. if (dw.Length > 0) lw.Add(dw);
  5088. }
  5089. else
  5090. {
  5091. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5092. }
  5093. string posTag = CurrentUser.UserPost.Post.Code;
  5094. if (posTag == "Supplier")
  5095. {
  5096. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5097. }
  5098. else
  5099. {
  5100. string supplier = GetPostString("supplier");
  5101. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5102. }
  5103. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5104. lw.Add(string.Format("type != 'PDD' "));
  5105. lw.Add(string.Format("IsRefund!={0}", 2));
  5106. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5107. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5108. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5109. /*if (tid.Length > 0)
  5110. {
  5111. List<string> tids = new List<string>();
  5112. if (dt != null && dt.Rows.Count > 0)
  5113. {
  5114. foreach (DataRow item in dt.Rows)
  5115. {
  5116. tids.Add("'" + item["tid"] + "'");
  5117. }
  5118. }
  5119. if (tids.Count > 0)
  5120. {
  5121. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5122. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5123. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5124. dt = WebCache.GetData("view_erptradecell", dStruct);
  5125. }
  5126. }*/
  5127. if (dt != null)
  5128. {
  5129. foreach (DataRow dr in dt.Rows)
  5130. {
  5131. 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();
  5132. }
  5133. }
  5134. writeGridDataTableJson(dStruct.TotalCount, dt);
  5135. }
  5136. public void get_erp_pdddeliveryed()
  5137. {
  5138. DataStruct dStruct = GetPostStruct();
  5139. List<string> lw = new List<string>();
  5140. string tid = GetPostString("ctid");
  5141. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5142. string shopname = GetPostString("shopname");
  5143. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5144. string buyernick = GetPostString("buyer_nick");
  5145. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5146. string customer = GetPostString("customer");
  5147. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5148. string design = GetPostString("design");
  5149. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5150. string sellermemo = GetPostString("seller_memo");
  5151. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5152. string logistics = GetPostString("logistics");
  5153. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5154. string date1 = GetPostString("date1");
  5155. string date2 = GetPostString("date2");
  5156. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5157. //if (dw.Length > 0) lw.Add(dw);
  5158. string placedate1 = GetPostString("placedate1");
  5159. string placedate2 = GetPostString("placedate2");
  5160. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5161. if (fdw.Length > 0) lw.Add(fdw);
  5162. string devdate1 = GetPostString("deliverydate1");
  5163. string devdate2 = GetPostString("deliverydate2");
  5164. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5165. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5166. string price1 = GetPostString("price1");
  5167. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5168. string price2 = GetPostString("price2");
  5169. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5170. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5171. {
  5172. if (tid.Length > 0)
  5173. {
  5174. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5175. if (tid.Length > 5)
  5176. {
  5177. List<string> tids = getTidByCtidLike(tid);
  5178. if (tids.Count > 0 && tids.Count < 10)
  5179. {
  5180. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5181. }
  5182. }
  5183. lw.Add(tid_sql);
  5184. }
  5185. if (buyernick.Length > 0)
  5186. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5187. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5188. if (dw.Length > 0) lw.Add(dw);
  5189. }
  5190. else
  5191. {
  5192. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5193. }
  5194. string posTag = CurrentUser.UserPost.Post.Code;
  5195. if (posTag == "Supplier")
  5196. {
  5197. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5198. }
  5199. else
  5200. {
  5201. string supplier = GetPostString("supplier");
  5202. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5203. }
  5204. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5205. lw.Add(string.Format("type = 'PDD' "));
  5206. lw.Add(string.Format("IsRefund!={0}", 2));
  5207. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5208. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5209. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5210. /* if (tid.Length > 0)
  5211. {
  5212. List<string> tids = new List<string>();
  5213. if (dt != null && dt.Rows.Count > 0)
  5214. {
  5215. foreach (DataRow item in dt.Rows)
  5216. {
  5217. tids.Add("'" + item["tid"] + "'");
  5218. }
  5219. }
  5220. if (tids.Count > 0)
  5221. {
  5222. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5223. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5224. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5225. dt = WebCache.GetData("view_erptradecell", dStruct);
  5226. }
  5227. }*/
  5228. foreach (DataRow dr in dt.Rows)
  5229. {
  5230. 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();
  5231. }
  5232. writeGridDataTableJson(dStruct.TotalCount, dt);
  5233. }
  5234. public void get_erp_jddeliveryed()
  5235. {
  5236. DataStruct dStruct = GetPostStruct();
  5237. List<string> lw = new List<string>();
  5238. string tid = GetPostString("ctid");
  5239. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5240. string shopname = GetPostString("shopname");
  5241. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5242. string buyernick = GetPostString("buyer_nick");
  5243. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5244. string customer = GetPostString("customer");
  5245. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5246. string design = GetPostString("design");
  5247. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5248. string sellermemo = GetPostString("seller_memo");
  5249. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5250. string date1 = GetPostString("date1");
  5251. string date2 = GetPostString("date2");
  5252. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5253. //if (dw.Length > 0) lw.Add(dw);
  5254. string placedate1 = GetPostString("placedate1");
  5255. string placedate2 = GetPostString("placedate2");
  5256. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5257. if (fdw.Length > 0) lw.Add(fdw);
  5258. string devdate1 = GetPostString("deliverydate1");
  5259. string devdate2 = GetPostString("deliverydate2");
  5260. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5261. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5262. string price1 = GetPostString("price1");
  5263. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5264. string price2 = GetPostString("price2");
  5265. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5266. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5267. {
  5268. if (tid.Length > 0)
  5269. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5270. if (buyernick.Length > 0)
  5271. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5272. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5273. if (dw.Length > 0) lw.Add(dw);
  5274. }
  5275. else
  5276. {
  5277. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5278. }
  5279. string posTag = CurrentUser.UserPost.Post.Code;
  5280. if (posTag == "Supplier")
  5281. {
  5282. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5283. }
  5284. else
  5285. {
  5286. string supplier = GetPostString("supplier");
  5287. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5288. }
  5289. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5290. lw.Add(string.Format("type = 'JD' "));
  5291. lw.Add(string.Format("IsRefund!={0}", 2));
  5292. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5293. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5294. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5295. foreach (DataRow dr in dt.Rows)
  5296. {
  5297. 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();
  5298. }
  5299. writeGridDataTableJson(dStruct.TotalCount, dt);
  5300. }
  5301. public void get_erp_allplacelist()
  5302. {
  5303. DataStruct dStruct = GetPostStruct();
  5304. List<string> lw = new List<string>();
  5305. string tid = GetPostString("ctid");
  5306. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5307. string shopname = GetPostString("shopname");
  5308. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5309. string buyernick = GetPostString("buyer_nick");
  5310. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5311. string customer = GetPostString("customer");
  5312. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5313. string design = GetPostString("design");
  5314. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5315. string sellermemo = GetPostString("seller_memo");
  5316. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5317. string supplier = GetPostString("supplier");
  5318. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5319. string date1 = GetPostString("date1");
  5320. string date2 = GetPostString("date2");
  5321. string pldate1 = GetPostString("placedate1");
  5322. string pldate2 = GetPostString("placedate2");
  5323. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5324. //if (dw.Length > 0) lw.Add(dw);
  5325. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5326. {
  5327. if (tid.Length > 0)
  5328. {
  5329. string select_tid = getTidByCtid(tid);
  5330. lw.Add(string.Format("tid='{0}'", select_tid));
  5331. }
  5332. if (buyernick.Length > 0)
  5333. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5334. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5335. if (dw.Length > 0) lw.Add(dw);
  5336. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5337. if (dw_place.Length > 0) lw.Add(dw_place);
  5338. }
  5339. else
  5340. {
  5341. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5342. {
  5343. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5344. }
  5345. }
  5346. string price1 = GetPostString("price1");
  5347. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5348. string price2 = GetPostString("price2");
  5349. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5350. string posTag = CurrentUser.UserPost.Post.Code;
  5351. if (posTag == "Supplier")
  5352. {
  5353. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5354. }
  5355. lw.Add(string.Format("OrderState >= 6"));
  5356. lw.Add(string.Format("IsSample != 2 "));
  5357. //lw.Add(string.Format("isDianziOrder = 0 "));
  5358. lw.Add(string.Format("SupplierId > 0 "));
  5359. //lw.Add(string.Format("IsRefund<={0}", 1));
  5360. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5361. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5362. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5363. foreach (DataRow dr in dt.Rows)
  5364. {
  5365. 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();
  5366. }
  5367. writeGridDataTableJson(dStruct.TotalCount, dt);
  5368. }
  5369. public void get_erp_financeallplacelist()
  5370. {
  5371. DataStruct dStruct = GetPostStruct();
  5372. List<string> lw = new List<string>();
  5373. string tid = GetPostString("ctid");
  5374. string shopname = GetPostString("shopname");
  5375. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5376. string buyernick = GetPostString("buyer_nick");
  5377. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5378. string customer = GetPostString("customer");
  5379. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5380. string design = GetPostString("design");
  5381. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5382. string sellermemo = GetPostString("seller_memo");
  5383. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5384. string supplier = GetPostString("supplier");
  5385. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5386. string date1 = GetPostString("date1");
  5387. string date2 = GetPostString("date2");
  5388. string pldate1 = GetPostString("placedate1");
  5389. string pldate2 = GetPostString("placedate2");
  5390. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5391. {
  5392. if (tid.Length > 0)
  5393. {
  5394. string select_tid = getTidByCtid(tid);
  5395. lw.Add(string.Format("tid='{0}'", select_tid));
  5396. }
  5397. if (buyernick.Length > 0)
  5398. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5399. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5400. if (dw.Length > 0) lw.Add(dw);
  5401. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5402. if (dw_place.Length > 0) lw.Add(dw_place);
  5403. }
  5404. else
  5405. {
  5406. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5407. {
  5408. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5409. }
  5410. }
  5411. string price1 = GetPostString("price1");
  5412. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5413. string price2 = GetPostString("price2");
  5414. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5415. string posTag = CurrentUser.UserPost.Post.Code;
  5416. if (posTag == "Supplier")
  5417. {
  5418. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5419. }
  5420. //lw.Add(string.Format("OrderState >= 6"));
  5421. lw.Add(string.Format("IsSample != 2 "));
  5422. lw.Add(string.Format("isDianziOrder = 0 "));
  5423. //lw.Add(string.Format("IsRefund<={0}", 1));
  5424. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5425. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5426. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5427. foreach (DataRow dr in dt.Rows)
  5428. {
  5429. 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();
  5430. }
  5431. writeGridDataTableJson(dStruct.TotalCount, dt);
  5432. }
  5433. public void get_erp_expresslist()
  5434. {
  5435. int listtype = GetInt("ltype");
  5436. DataStruct dStruct = GetPostStruct();
  5437. List<string> lw = new List<string>();
  5438. string tid = GetPostString("tid");
  5439. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5440. string outsid = GetPostString("out_sid");
  5441. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5442. string importer = GetPostString("ImportUserName");
  5443. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5444. string file = GetPostString("import_file");
  5445. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5446. string printman = GetPostString("printman");
  5447. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5448. string date1 = GetPostString("date1");
  5449. string date2 = GetPostString("date2");
  5450. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5451. if (dw.Length > 0) lw.Add(dw);
  5452. string fdate1 = GetPostString("finishdate1");
  5453. string fdate2 = GetPostString("finishdate2");
  5454. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5455. if (fdw.Length > 0) lw.Add(fdw);
  5456. string supplierId = GetPostString("supplierId");
  5457. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5458. if (listtype == 1)
  5459. {
  5460. lw.Add(string.Format("importUserId !=0"));
  5461. }
  5462. string posTag = CurrentUser.UserPost.Post.Code;
  5463. if (posTag == "Supplier")
  5464. {
  5465. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5466. }
  5467. if (dStruct.PageSize != 100000)
  5468. {
  5469. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5470. }
  5471. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5472. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5473. writeGridDataTableJson(dStruct.TotalCount, dt);
  5474. }
  5475. public void set_erp_buchaorderdelivery()
  5476. {
  5477. if (UrlPostParmsCheck("ctid"))
  5478. {
  5479. string eid = GetPostString("ctid");
  5480. CeErpTradeCell entity = null;
  5481. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5482. if (entity != null)
  5483. {
  5484. if (entity.IsSample != 2)
  5485. {
  5486. returnErrorMsg("补差价单才能标记为已发货");
  5487. return;
  5488. }
  5489. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5490. entity.OrderState = 7;
  5491. entity.Update();
  5492. returnSuccessMsg("操作成功!");
  5493. return;
  5494. }
  5495. returnErrorMsg("找不到记录");
  5496. }
  5497. }
  5498. public void get_stdtemplates()
  5499. {
  5500. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5501. //string res = taobaoHelper.test();
  5502. string res = apiHelper.API_PrintTemplate();
  5503. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5504. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5505. {
  5506. int sidx = res.IndexOf("error_code");
  5507. int eidx = res.IndexOf("success");
  5508. string msg = res.Substring(sidx, eidx - sidx);
  5509. returnErrorMsg(msg);
  5510. return;
  5511. }
  5512. if (res.Length <= 0)
  5513. {
  5514. returnErrorMsg("模板数据为空!");
  5515. return;
  5516. }
  5517. ReturnSuccess(res);
  5518. }
  5519. public void cancel_print_order()
  5520. {
  5521. if (UrlPostParmsCheck("ctid"))
  5522. {
  5523. string ctid = GetPostString("ctid");
  5524. CeErpTradeCell entity = null;
  5525. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5526. if (entity != null)
  5527. {
  5528. string res = "";
  5529. string code = entity.LastBillWaybillCode;
  5530. if (code == "")
  5531. {
  5532. code = entity.OutSid;
  5533. }
  5534. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5535. XLog.SaveLog(0, "取消面单" + res);
  5536. }
  5537. }
  5538. }
  5539. public void set_erp_printwaybill()
  5540. {
  5541. if (UrlPostParmsCheck("ctid"))
  5542. {
  5543. string ctid = GetPostString("ctid");
  5544. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5545. string cpName = GetPostString("cpname");
  5546. string isTogether = GetPostString("together");
  5547. string printType = GetPostString("printType");
  5548. //var res_obj = new
  5549. //{
  5550. // restype = 1,
  5551. // 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\"}"
  5552. //};
  5553. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5554. //ReturnSuccess(ro_json);
  5555. //return;
  5556. bool isUseLastWayBillCode = false;
  5557. CeErpTradeCell entity = null;
  5558. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5559. if (entity != null)
  5560. {
  5561. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5562. {
  5563. isUseLastWayBillCode = true;
  5564. }
  5565. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5566. {
  5567. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5568. return;
  5569. }
  5570. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5571. {
  5572. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5573. return;
  5574. }
  5575. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5576. {
  5577. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5578. return;
  5579. }
  5580. }
  5581. string res = "";
  5582. Api_waybill_code_response_Obj fullObj = null;
  5583. string pData_str = "";
  5584. string curUseWayBillCode = "";
  5585. if (isUseLastWayBillCode == false)
  5586. {
  5587. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5588. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5589. if (res.IndexOf("failure") != -1)
  5590. {
  5591. //int idx = res.IndexOf("sub_message");
  5592. //int idx2 = res.IndexOf("flag");
  5593. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5594. string errMsgNeed = commonHelper.KeepChinese(res);
  5595. var res_objd = new
  5596. {
  5597. restype = 0,
  5598. data = "获取面单失败" + errMsgNeed
  5599. };
  5600. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5601. returnSuccess(ro_jsond);
  5602. if (res.IndexOf("停发") != -1)
  5603. {
  5604. entity.UnusualCon = "物流停发";
  5605. entity.Update();
  5606. }
  5607. //returnErrorMsg("获取面单失败,"+emsg);
  5608. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5609. return;
  5610. }
  5611. else if (res.IndexOf("errorMsg") != -1)
  5612. {
  5613. //int idx = res.IndexOf("errorMsg");
  5614. //int idx2 = res.IndexOf("}]}");
  5615. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5616. string errMsgNeed = commonHelper.KeepChinese(res);
  5617. var res_objf = new
  5618. {
  5619. restype = 0,
  5620. data = "获取面单失败2" + errMsgNeed
  5621. };
  5622. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5623. if (res.IndexOf("停发") != -1)
  5624. {
  5625. entity.UnusualCon = "物流停发";
  5626. entity.Update();
  5627. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5628. if (trade != null)
  5629. {
  5630. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5631. }
  5632. }
  5633. returnSuccess(ro_jsonf);
  5634. //returnErrorMsg("获取面单失败," + emsg);
  5635. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5636. return;
  5637. }
  5638. try
  5639. {
  5640. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5641. //res = res.Replace(" ", "");
  5642. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5643. }
  5644. catch (Exception ex)
  5645. {
  5646. XLog.SaveLog(0, "生成fullObj" + res);
  5647. var res_objf = new
  5648. {
  5649. restype = 0,
  5650. data = "生成fullObj发生错误" + ex.Message
  5651. };
  5652. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5653. returnSuccess(ro_jsonf);
  5654. return;
  5655. }
  5656. if (fullObj.response.data.content.Count > 0)
  5657. {
  5658. ContentItem codeObj = fullObj.response.data.content[0];
  5659. if (cpCode.IndexOf("SFFQ-") != -1)
  5660. {
  5661. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5662. }
  5663. else
  5664. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5665. curUseWayBillCode = codeObj.waybillCode;
  5666. }
  5667. else
  5668. {
  5669. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5670. var res_objf = new
  5671. {
  5672. restype = 0,
  5673. data = "生成fullObj找不到快递单号waybillCode"
  5674. };
  5675. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5676. returnSuccess(ro_jsonf);
  5677. return;
  5678. }
  5679. }
  5680. else
  5681. {
  5682. //使用上次打印的快递单号
  5683. if (cpCode == "SFFQ-LY")
  5684. {
  5685. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5686. }
  5687. else
  5688. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5689. curUseWayBillCode = entity.LastBillWaybillCode;
  5690. }
  5691. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5692. {
  5693. var res_obje = new
  5694. {
  5695. restype = 0,
  5696. data = "获取加密打印数据失败"
  5697. };
  5698. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5699. returnSuccess(ro_jsone);
  5700. entity.LastBillCpCode = cpCode;
  5701. entity.LastBillWaybillCode = curUseWayBillCode;
  5702. entity.Update();
  5703. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5704. //returnErrorMsg("获取加密打印数据失败");
  5705. return;
  5706. }
  5707. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5708. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5709. string btnType = "";
  5710. string errorMsg = "";
  5711. if (entity != null)
  5712. {
  5713. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5714. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5715. //cpcode是 YTO-CAINIAO
  5716. //string comCode = cpCode.Split('-')[0].ToString();
  5717. string apires = "";
  5718. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5719. //isTogether=2是新的合包弹窗
  5720. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5721. {
  5722. if (ctid.IndexOf("N") != -1)
  5723. {
  5724. apires = "发货成功";
  5725. }
  5726. else
  5727. {
  5728. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5729. }
  5730. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5731. //打单后发货
  5732. StringBuilder sql = new StringBuilder();
  5733. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5734. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5735. {
  5736. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5737. }
  5738. else
  5739. {
  5740. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5741. }
  5742. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5743. foreach (DataRow row in dt.Rows)
  5744. {
  5745. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5746. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5747. {
  5748. try
  5749. {
  5750. btnType = "待发货";
  5751. entity.OutSid = curUseWayBillCode;
  5752. entity.OrderState = 7;
  5753. entity.IsUrgency = false;
  5754. entity.LastBillCpCode = "";
  5755. entity.LastBillWaybillCode = "";
  5756. entity.FinishDeliveryTime = DateTime.Now;
  5757. entity.IsReturn = 0;
  5758. entity.MemoOpt = 0;
  5759. entity.UpdateTime = DateTime.Now;
  5760. entity.Update();
  5761. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5762. //还要插入快递信息到 快递信息表
  5763. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5764. exinfo.tid = entity.ctid;
  5765. exinfo.out_sid = curUseWayBillCode;
  5766. exinfo.company_code = cpCode;
  5767. exinfo.company_name = cpName;
  5768. exinfo.supplierUserName = supplierName;
  5769. exinfo.deliveryType = "发货成功";
  5770. exinfo.print_time = DateTime.Now;
  5771. exinfo.printUser = CurrentUser.UserName;
  5772. exinfo.postData = pData_str;
  5773. exinfo.Create();
  5774. commonHelper.UpdateRelationOrder(entity.ctid);
  5775. CeErpSukuraData.createInfo(ctid, 4);
  5776. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5777. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5778. {
  5779. commonHelper.sendCytExpress(exinfo);
  5780. }
  5781. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5782. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5783. }
  5784. catch (Exception ex)
  5785. {
  5786. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5787. }
  5788. }
  5789. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5790. {
  5791. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5792. if (entity.OrderState == 6)
  5793. {
  5794. entity.OrderState = 7;
  5795. }
  5796. entity.UpdateTime = DateTime.Now;
  5797. entity.FinishDeliveryTime = DateTime.Now;
  5798. btnType = "已发货";
  5799. entity.Update();
  5800. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5801. exinfo.tid = entity.ctid;
  5802. exinfo.out_sid = curUseWayBillCode;
  5803. exinfo.company_code = cpCode;
  5804. exinfo.company_name = cpName;
  5805. exinfo.supplierUserName = supplierName;
  5806. exinfo.deliveryType = "发货成功";
  5807. exinfo.print_time = DateTime.Now;
  5808. exinfo.printUser = CurrentUser.UserName;
  5809. exinfo.postData = pData_str;
  5810. exinfo.Create();
  5811. commonHelper.UpdateRelationOrder(entity.ctid);
  5812. CeErpSukuraData.createInfo(entity.ctid, 4);
  5813. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5814. {
  5815. commonHelper.sendCytExpress(exinfo);
  5816. }
  5817. //不处理
  5818. }
  5819. else
  5820. {
  5821. entity.UpdateTime = DateTime.Now;
  5822. entity.LastBillCpCode = cpCode;
  5823. entity.LastBillWaybillCode = curUseWayBillCode;
  5824. entity.Update();
  5825. string errmsg = commonHelper.KeepChinese(apires);
  5826. var res_objz = new
  5827. {
  5828. restype = 0,
  5829. data = "打单后发货失败"
  5830. };
  5831. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5832. returnSuccess(ro_jsonz);
  5833. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5834. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5835. return;
  5836. }
  5837. }
  5838. }
  5839. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5840. {
  5841. string ctids = GetPostString("ctids");
  5842. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5843. List<string> list = new List<string>();
  5844. List<string> send_list = new List<string>();
  5845. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5846. CeErpTrade ceErpTrade = new CeErpTrade();
  5847. //可合包的合并一起发货
  5848. if (dt == null && string.IsNullOrEmpty(ctids))
  5849. {
  5850. var res_objz = new
  5851. {
  5852. restype = 0,
  5853. data = "打单后发货失败"
  5854. };
  5855. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5856. returnSuccess(ro_jsonz);
  5857. return;
  5858. }
  5859. if (!string.IsNullOrEmpty(ctids))
  5860. {
  5861. StringBuilder sql = new StringBuilder();
  5862. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5863. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5864. }
  5865. foreach (DataRow row in dt.Rows)
  5866. {
  5867. list.Add("'" + row["ctid"] + "'");
  5868. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5869. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5870. if (ctid.IndexOf("N") != -1)
  5871. {
  5872. apires = "发货成功";
  5873. }
  5874. else
  5875. {
  5876. if (!send_list.Contains(ceErpTrade.tid))
  5877. {
  5878. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5879. }
  5880. else
  5881. {
  5882. apires = "发货成功";
  5883. }
  5884. }
  5885. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5886. {
  5887. send_list.Add(ceErpTrade.tid);
  5888. try
  5889. {
  5890. btnType = "待发货";
  5891. ceErpTradeCell.OutSid = curUseWayBillCode;
  5892. ceErpTradeCell.OrderState = 7;
  5893. ceErpTradeCell.IsUrgency = false;
  5894. ceErpTradeCell.LastBillCpCode = "";
  5895. ceErpTradeCell.LastBillWaybillCode = "";
  5896. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5897. ceErpTradeCell.IsReturn = 0;
  5898. ceErpTradeCell.MemoOpt = 0;
  5899. ceErpTradeCell.UpdateTime = DateTime.Now;
  5900. ceErpTradeCell.Update();
  5901. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5902. //还要插入快递信息到 快递信息表
  5903. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5904. exinfo.tid = ceErpTradeCell.ctid;
  5905. exinfo.out_sid = curUseWayBillCode;
  5906. exinfo.company_code = cpCode;
  5907. exinfo.company_name = cpName;
  5908. exinfo.supplierUserName = supplierName;
  5909. exinfo.deliveryType = "发货成功";
  5910. exinfo.print_time = DateTime.Now;
  5911. exinfo.printUser = CurrentUser.UserName;
  5912. exinfo.postData = pData_str;
  5913. exinfo.Create();
  5914. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5915. CeErpSukuraData.createInfo(ctid, 4);
  5916. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5917. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80 || entity.SupplierId == 126)
  5918. {
  5919. commonHelper.sendCytExpress(exinfo);
  5920. }
  5921. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5922. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5923. }
  5924. catch (Exception ex)
  5925. {
  5926. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5927. }
  5928. }
  5929. else
  5930. {
  5931. ceErpTradeCell.UpdateTime = DateTime.Now;
  5932. ceErpTradeCell.LastBillCpCode = cpCode;
  5933. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5934. ceErpTradeCell.Update();
  5935. string errmsg = commonHelper.KeepChinese(apires);
  5936. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5937. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5938. }
  5939. }
  5940. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5941. }
  5942. }
  5943. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5944. var res_obj = new
  5945. {
  5946. restype = 1,
  5947. data = pData_str,
  5948. errorMsg
  5949. };
  5950. string ro_json = JsonConvert.SerializeObject(res_obj);
  5951. ReturnSuccess(ro_json);
  5952. return;
  5953. }
  5954. }
  5955. private string GetUTF8String(byte[] vs)
  5956. {
  5957. throw new NotImplementedException();
  5958. }
  5959. public void set_erp_printwaybill_cn()
  5960. {
  5961. if (UrlPostParmsCheck("ctid"))
  5962. {
  5963. string ctid = GetPostString("ctid");
  5964. string cpCode = GetPostString("cpcode");
  5965. string cpName = GetPostString("cpname");
  5966. string tempUrl = GetPostString("tempurl");
  5967. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5968. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5969. //string res = taobaoHelper.test();
  5970. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5971. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5972. {
  5973. int sidx = res.IndexOf("errorMsg");
  5974. int eidx = res.IndexOf("}");
  5975. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5976. var res_objzxx = new
  5977. {
  5978. restype = 0,
  5979. data = msg
  5980. };
  5981. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5982. returnSuccess(ro_jsonzxx);
  5983. //returnErrorMsg(msg);
  5984. return;
  5985. }
  5986. int idx = res.IndexOf("waybillCode");
  5987. int idx2 = res.IndexOf("printData");
  5988. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5989. string eid = GetPostString("ctid");
  5990. CeErpTradeCell entity = null;
  5991. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5992. if (entity != null)
  5993. {
  5994. string osid = entity.OutSid;
  5995. entity.OutSid = osid + "," + outsid;
  5996. entity.FinishDeliveryTime = DateTime.Now;
  5997. entity.OrderState = 7;
  5998. entity.UpdateTime = DateTime.Now;
  5999. entity.IsReturn = 0;
  6000. entity.Update();
  6001. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  6002. exinfo.tid = entity.ctid;
  6003. exinfo.out_sid = outsid;
  6004. exinfo.company_code = cpCode;
  6005. exinfo.company_name = cpName;
  6006. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  6007. exinfo.deliveryType = "发货成功";
  6008. exinfo.print_time = DateTime.Now;
  6009. exinfo.printUser = CurrentUser.UserName;
  6010. exinfo.Create();
  6011. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  6012. {
  6013. commonHelper.sendCytExpress(exinfo);
  6014. }
  6015. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  6016. }
  6017. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  6018. var res_objz = new
  6019. {
  6020. restype = 1,
  6021. data = res
  6022. };
  6023. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6024. returnSuccess(ro_jsonz);
  6025. //ReturnSuccess(res);
  6026. }
  6027. }
  6028. ////打单,打印面单 获取面单号
  6029. //public void set_erp_printwaybill()
  6030. //{
  6031. // if (UrlPostParmsCheck("ctid"))
  6032. // {
  6033. // string ctid = GetPostString("ctid");
  6034. // string cpCode = GetPostString("cpcode");
  6035. // string tempUrl = GetPostString("tempurl");
  6036. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6037. // //string res = taobaoHelper.test();
  6038. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6039. // if (res.IndexOf("error_response") != -1)
  6040. // {
  6041. // int sidx = res.IndexOf("sub_msg");
  6042. // int eidx = res.IndexOf("request_id");
  6043. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  6044. // returnErrorMsg(msg);
  6045. // return;
  6046. // }
  6047. // int idx = res.IndexOf("waybill_code");
  6048. // int idx2 = res.IndexOf("}]}");
  6049. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  6050. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  6051. // ReturnSuccess(res);
  6052. // }
  6053. //}
  6054. public void cancel_erp_aftersale()
  6055. {
  6056. if (UrlPostParmsCheck("ctid"))
  6057. {
  6058. string eid = GetPostString("ctid");
  6059. CeErpTradeCell entity = null;
  6060. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6061. if (entity != null)
  6062. {
  6063. //有过处理的售后,取消也不能删除 售 字,保留
  6064. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6065. {
  6066. entity.AfterSaleState = 4;
  6067. }
  6068. else
  6069. entity.AfterSaleState = 0;
  6070. entity.UpdateTime = DateTime.Now;
  6071. entity.Update();
  6072. returnSuccessMsg("操作成功!");
  6073. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6074. return;
  6075. }
  6076. returnErrorMsg("找不到订单记录");
  6077. }
  6078. }
  6079. public void get_erp_aftersalelist()
  6080. {
  6081. DataStruct dStruct = GetPostStruct();
  6082. List<string> lw = new List<string>();
  6083. int st = GetInt("st");
  6084. string tid = GetPostString("ctid");
  6085. if (st == 3)
  6086. {
  6087. if (tid.Length > 0)
  6088. {
  6089. string select_tid = getTidByCtid(tid);
  6090. lw.Add(string.Format("tid='{0}'", select_tid));
  6091. }
  6092. }
  6093. else
  6094. {
  6095. if (tid.Length > 0)
  6096. {
  6097. string select_tid = getTidByCtid(tid);
  6098. lw.Add(string.Format("tid='{0}'", select_tid));
  6099. }
  6100. }
  6101. string shopname = GetPostString("shopname");
  6102. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6103. string buyernick = GetPostString("buyer_nick");
  6104. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6105. string sellermemo = GetPostString("seller_memo");
  6106. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6107. string orderState = GetPostString("orderState");
  6108. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6109. string afterState = GetPostString("afterstate");
  6110. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6111. string date1 = GetPostString("date1");
  6112. string date2 = GetPostString("date2");
  6113. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6114. if (dw.Length > 0) lw.Add(dw);
  6115. string price1 = GetPostString("price1");
  6116. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6117. string price2 = GetPostString("price2");
  6118. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6119. //lw.Add(string.Format("IsRefund!={0}", 1));
  6120. string reason = GetPostString("reason");
  6121. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6122. string method = GetPostString("method");
  6123. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6124. string handler = GetPostString("handler");
  6125. if (handler.Length > 0)
  6126. {
  6127. lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6128. }
  6129. string handledate1 = GetPostString("handledate1");
  6130. string handledate2 = GetPostString("handledate2");
  6131. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6132. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6133. string finish1 = GetPostString("finishdate1");
  6134. string finish2 = GetPostString("finishdate2");
  6135. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6136. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6137. string afterdate1 = GetPostString("afterdate1");
  6138. string afterdate2 = GetPostString("afterdate2");
  6139. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6140. if (afterDate.Length > 0) lw.Add(afterDate);
  6141. string supplier = GetPostString("supplier");
  6142. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6143. string responsible = GetPostString("responsibleman");
  6144. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6145. string customer = GetPostString("customer");
  6146. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6147. string design = GetPostString("design");
  6148. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6149. string afterMemoType = GetPostString("aftermemotype");
  6150. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6151. string posCode = CurrentUser.UserPost.Post.Code;
  6152. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6153. //{
  6154. // string vstate = GetPostString("vstate");
  6155. // if (vstate.Length > 0)
  6156. // {
  6157. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6158. // }
  6159. // if (posCode == "Supplier")
  6160. // {
  6161. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6162. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6163. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6164. // }
  6165. // else
  6166. // {
  6167. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6168. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6169. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6170. // {
  6171. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6172. // }
  6173. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6174. // {
  6175. // int orgid = CurrentUser.UserPost.OrgID;
  6176. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6177. // }
  6178. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6179. // {
  6180. // string shopid = CurrentUser.User.pemShop;
  6181. // lw.Add(string.Format("shopId in ({0})", shopid));
  6182. // }
  6183. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6184. // //{
  6185. // // int org_id = CurrentUser.UserPost.OrgID;
  6186. // // lw.Add(string.Format("OrgID={0}", org_id));
  6187. // //}
  6188. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6189. // }
  6190. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6191. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6192. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6193. //}
  6194. if (st == 5)
  6195. {
  6196. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6197. {
  6198. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6199. {
  6200. string shopid = CurrentUser.User.pemShop;
  6201. lw.Add(string.Format("shopId in ({0})", shopid));
  6202. }
  6203. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6204. {
  6205. int mrOrgid = CurrentUser.UserPost.OrgID;
  6206. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6207. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6208. }
  6209. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6210. //{
  6211. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6212. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6213. //}
  6214. else
  6215. {
  6216. string userIdStr = "";
  6217. if (posCode == "CustomerService")
  6218. {
  6219. userIdStr = CurrentUser.UserID + "_k";
  6220. }
  6221. else if (posCode == "Designer" || posCode == "wxDesigner")
  6222. {
  6223. userIdStr = CurrentUser.UserID + "_s";
  6224. }
  6225. else if (posCode == "Place")
  6226. {
  6227. userIdStr = CurrentUser.UserID + "_x";
  6228. }
  6229. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6230. }
  6231. }
  6232. string placedate1 = GetPostString("placedate1");
  6233. string placedate2 = GetPostString("placedate2");
  6234. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6235. if (dwplace.Length > 0) lw.Add(dwplace);
  6236. string supState = GetPostString("supState");
  6237. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6238. string searchType = GetPostString("searchType");
  6239. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6240. {
  6241. lw.Add(string.Format("BackNum>1"));
  6242. }
  6243. lw.Add(string.Format("AfterSaleState>0"));
  6244. if (ex_psize > 0)
  6245. {
  6246. if (CurrentUser.UserPost.Post.Code == "Finance")
  6247. dStruct.Order = "pay_time desc";
  6248. else
  6249. dStruct.Order = "HandleTime desc";
  6250. }
  6251. else
  6252. dStruct.Order = "HandleTime desc";
  6253. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6254. DataTable dt = WebCache.GetData("view_test", dStruct);
  6255. writeGridDataTableJson(dStruct.TotalCount, dt);
  6256. }
  6257. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6258. //{
  6259. // lw.Add(string.Format("AfterSaleState=4"));
  6260. // string code = CurrentUser.UserPost.Post.Code;
  6261. // if (code == "CustomerService")
  6262. // {
  6263. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6264. // }
  6265. // else if (code == "Designer" || code == "DesignerMr")
  6266. // {
  6267. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6268. // }
  6269. // else if (code == "Place" || code == "PlaceMr")
  6270. // {
  6271. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6272. // }
  6273. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6274. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6275. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6276. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6277. //}
  6278. //else //处理中的售后,待处理和处理中合并
  6279. //{
  6280. // if (afterState.Length <= 0)
  6281. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6282. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6283. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6284. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6285. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6286. //}
  6287. }
  6288. public void get_erp_disagreeftersalelist()
  6289. {
  6290. DataStruct dStruct = GetPostStruct();
  6291. List<string> lw = new List<string>();
  6292. int st = 2;
  6293. string tid = GetPostString("ctid");
  6294. if (tid.Length > 0)
  6295. {
  6296. string select_tid = getTidByCtid(tid);
  6297. lw.Add(string.Format("tid='{0}'", select_tid));
  6298. }
  6299. string shopname = GetPostString("shopname");
  6300. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6301. string buyernick = GetPostString("buyer_nick");
  6302. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6303. string sellermemo = GetPostString("seller_memo");
  6304. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6305. string orderState = GetPostString("orderState");
  6306. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6307. string afterState = GetPostString("afterstate");
  6308. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6309. string date1 = GetPostString("date1");
  6310. string date2 = GetPostString("date2");
  6311. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6312. if (dw.Length > 0) lw.Add(dw);
  6313. string price1 = GetPostString("price1");
  6314. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6315. string price2 = GetPostString("price2");
  6316. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6317. //lw.Add(string.Format("IsRefund!={0}", 1));
  6318. string reason = GetPostString("reason");
  6319. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6320. string method = GetPostString("method");
  6321. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6322. string handler = GetPostString("handler");
  6323. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6324. string handledate1 = GetPostString("handledate1");
  6325. string handledate2 = GetPostString("handledate2");
  6326. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6327. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6328. string afterdate1 = GetPostString("afterdate1");
  6329. string afterdate2 = GetPostString("afterdate2");
  6330. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6331. if (afterDate.Length > 0) lw.Add(afterDate);
  6332. string backdate1 = GetPostString("backdate1");
  6333. string backdate2 = GetPostString("backdate2");
  6334. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6335. if (backDate.Length > 0) lw.Add(backDate);
  6336. string supplier = GetPostString("supplier");
  6337. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6338. string responsible = GetPostString("responsibleman");
  6339. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6340. string customer = GetPostString("customer");
  6341. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6342. string design = GetPostString("design");
  6343. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6344. string afterSaleMemo = GetPostString("afterSaleMemo");
  6345. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6346. string afterMemoType = GetPostString("aftermemotype");
  6347. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6348. string aftersakereason = GetPostString("aftersakereason");
  6349. if (aftersakereason.Length > 0)
  6350. {
  6351. if (aftersakereason == "1")
  6352. {
  6353. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6354. }
  6355. if (aftersakereason == "2")
  6356. {
  6357. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6358. }
  6359. }
  6360. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6361. string poscode = CurrentUser.UserPost.Post.Code;
  6362. if (poscode != "SysAdmin")
  6363. {
  6364. string shopid = CurrentUser.User.pemShop;
  6365. lw.Add(string.Format("shopId in ({0})", shopid));
  6366. }
  6367. string searchType = GetPostString("searchType");
  6368. if (searchType == "wait")
  6369. {
  6370. lw.Add(string.Format("HandleTime is null"));
  6371. }
  6372. if (searchType == "handling")
  6373. {
  6374. lw.Add(string.Format("HandleTime is not null "));
  6375. }
  6376. if (searchType == "back" || searchType == "puBack")
  6377. {
  6378. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6379. }
  6380. if (searchType == "reBack")
  6381. {
  6382. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6383. }
  6384. if (searchType == "moreBack")
  6385. {
  6386. lw.Add(string.Format("backNum > 1"));
  6387. }
  6388. lw.Add(string.Format("(AfterSaleState=5)"));
  6389. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6390. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6391. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6392. writeGridDataTableJson(dStruct.TotalCount, dt);
  6393. }
  6394. public void get_erp_handlingaftersalelist()
  6395. {
  6396. DataStruct dStruct = GetPostStruct();
  6397. List<string> lw = new List<string>();
  6398. int st = 2;
  6399. string tid = GetPostString("ctid");
  6400. if (tid.Length > 0)
  6401. {
  6402. string select_tid = getTidByCtid(tid);
  6403. lw.Add(string.Format("tid='{0}'", select_tid));
  6404. }
  6405. string shopname = GetPostString("shopname");
  6406. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6407. string buyernick = GetPostString("buyer_nick");
  6408. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6409. string sellermemo = GetPostString("seller_memo");
  6410. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6411. string orderState = GetPostString("orderState");
  6412. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6413. string afterState = GetPostString("afterstate");
  6414. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6415. string date1 = GetPostString("date1");
  6416. string date2 = GetPostString("date2");
  6417. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6418. if (dw.Length > 0) lw.Add(dw);
  6419. string price1 = GetPostString("price1");
  6420. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6421. string price2 = GetPostString("price2");
  6422. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6423. //lw.Add(string.Format("IsRefund!={0}", 1));
  6424. string reason = GetPostString("reason");
  6425. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6426. string method = GetPostString("method");
  6427. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6428. string handler = GetPostString("handler");
  6429. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6430. string handledate1 = GetPostString("handledate1");
  6431. string handledate2 = GetPostString("handledate2");
  6432. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6433. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6434. string afterdate1 = GetPostString("afterdate1");
  6435. string afterdate2 = GetPostString("afterdate2");
  6436. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6437. if (afterDate.Length > 0) lw.Add(afterDate);
  6438. string supplier = GetPostString("supplier");
  6439. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6440. string responsible = GetPostString("responsibleman");
  6441. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6442. string customer = GetPostString("customer");
  6443. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6444. string design = GetPostString("design");
  6445. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6446. string afterSaleMemo = GetPostString("afterSaleMemo");
  6447. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6448. string afterMemoType = GetPostString("aftermemotype");
  6449. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6450. string afterresult = GetPostString("afterresult");
  6451. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6452. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6453. string poscode = CurrentUser.UserPost.Post.Code;
  6454. if (poscode != "SysAdmin")
  6455. {
  6456. string shopid = CurrentUser.User.pemShop;
  6457. lw.Add(string.Format("shopId in ({0})", shopid));
  6458. }
  6459. string searchType = GetPostString("searchType");
  6460. if (searchType == "wait")
  6461. {
  6462. lw.Add(string.Format("HandleTime is null"));
  6463. }
  6464. if (searchType == "documentary")
  6465. {
  6466. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6467. }
  6468. if (searchType == "handling")
  6469. {
  6470. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6471. }
  6472. if (searchType == "back" || searchType == "puBack")
  6473. {
  6474. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6475. }
  6476. if (searchType == "reBack")
  6477. {
  6478. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6479. }
  6480. if (afterState.Length <= 0)
  6481. {
  6482. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6483. }
  6484. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6485. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6486. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6487. writeGridDataTableJson(dStruct.TotalCount, dt);
  6488. }
  6489. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6490. //public void get_erp_back_handlingaftersalelist()
  6491. //{
  6492. // DataStruct dStruct = GetPostStruct();
  6493. // List<string> lw = new List<string>();
  6494. // string tid = GetPostString("ctid");
  6495. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6496. // string shopname = GetPostString("shopname");
  6497. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6498. // string buyernick = GetPostString("buyer_nick");
  6499. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6500. // string sellermemo = GetPostString("seller_memo");
  6501. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6502. // string orderState = GetPostString("orderState");
  6503. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6504. // string afterState = GetPostString("afterstate");
  6505. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6506. // string date1 = GetPostString("date1");
  6507. // string date2 = GetPostString("date2");
  6508. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6509. // if (dw.Length > 0) lw.Add(dw);
  6510. // string price1 = GetPostString("price1");
  6511. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6512. // string price2 = GetPostString("price2");
  6513. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6514. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6515. // string reason = GetPostString("reason");
  6516. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6517. // string method = GetPostString("method");
  6518. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6519. // string handler = GetPostString("handler");
  6520. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6521. // string handledate1 = GetPostString("handledate1");
  6522. // string handledate2 = GetPostString("handledate2");
  6523. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6524. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6525. // string afterdate1 = GetPostString("afterdate1");
  6526. // string afterdate2 = GetPostString("afterdate2");
  6527. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6528. // if (afterDate.Length > 0) lw.Add(afterDate);
  6529. // string supplier = GetPostString("supplier");
  6530. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6531. // string responsible = GetPostString("responsibleman");
  6532. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6533. // string customer = GetPostString("customer");
  6534. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6535. // string design = GetPostString("design");
  6536. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6537. // string afterMemoType = GetPostString("aftermemotype");
  6538. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6539. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6540. // if (afterState.Length <= 0)
  6541. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6542. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6543. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6544. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6545. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6546. //}
  6547. public void get_erp_aftersaleverifylist()
  6548. {
  6549. DataStruct dStruct = GetPostStruct();
  6550. List<string> lw = new List<string>();
  6551. string tid = GetPostString("ctid");
  6552. if (tid.Length > 0)
  6553. {
  6554. string select_tid = getTidByCtid(tid);
  6555. lw.Add(string.Format("otid='{0}'", select_tid));
  6556. }
  6557. string shopname = GetPostString("shopname");
  6558. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6559. string buyernick = GetPostString("buyer_nick");
  6560. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6561. string sellermemo = GetPostString("seller_memo");
  6562. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6563. string orderState = GetPostString("orderState");
  6564. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6565. //lw.Add(string.Format("IsRefund!={0}", 1));
  6566. string reason = GetPostString("reason");
  6567. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6568. string method = GetPostString("method");
  6569. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6570. string handler = GetPostString("handler");
  6571. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6572. string handledate1 = GetPostString("handledate1");
  6573. string handledate2 = GetPostString("handledate2");
  6574. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6575. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6576. string finish1 = GetPostString("finishdate1");
  6577. string finish2 = GetPostString("finishdate2");
  6578. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6579. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6580. string supplier = GetPostString("supplier");
  6581. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6582. string responsible = GetPostString("responsibleman");
  6583. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6584. string posCode = CurrentUser.UserPost.Post.Code;
  6585. string vstate = GetPostString("vstate");
  6586. if (vstate.Length > 0)
  6587. {
  6588. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6589. }
  6590. if (posCode == "Supplier")
  6591. {
  6592. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6593. lw.Add(string.Format("VerifyState = 0"));
  6594. lw.Add("type = 1");
  6595. lw.Add(string.Format("AfterSaleState={0}", 3));
  6596. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6597. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6598. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6599. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6600. writeGridDataTableJson(dStruct.TotalCount, dt);
  6601. }
  6602. else if (posCode == "logistics")
  6603. {
  6604. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6605. lw.Add(string.Format("VerifyState = 0"));
  6606. lw.Add("type = 2");
  6607. lw.Add(string.Format("AfterSaleState={0}", 3));
  6608. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6609. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6610. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6611. writeGridDataTableJson(dStruct.TotalCount, dt);
  6612. }
  6613. else
  6614. {
  6615. lw.Add(string.Format("(AfterSaleState = 3)"));
  6616. lw.Add("type = 0");
  6617. string reasonState = GetPostString("reasonState");
  6618. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6619. {
  6620. if (reasonState == "2")
  6621. {
  6622. lw.Add("VerifyState = 3");
  6623. }
  6624. else if (reasonState == "1")
  6625. {
  6626. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6627. }
  6628. else
  6629. {
  6630. lw.Add("VerifyState in (0,3)");
  6631. }
  6632. //不加条件,可以看全部
  6633. }
  6634. 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")
  6635. {
  6636. int orgid = CurrentUser.UserPost.OrgID;
  6637. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6638. if (string.IsNullOrEmpty(manageOrgId))
  6639. {
  6640. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6641. }
  6642. else
  6643. {
  6644. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6645. }
  6646. if (reasonState == "1")
  6647. {
  6648. lw.Add("VerifyState = 3");
  6649. }
  6650. else if (reasonState == "2")
  6651. {
  6652. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6653. }
  6654. else
  6655. {
  6656. }
  6657. }
  6658. else
  6659. {
  6660. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6661. }
  6662. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6663. //{
  6664. // int org_id = CurrentUser.UserPost.OrgID;
  6665. // lw.Add(string.Format("OrgID={0}", org_id));
  6666. //}
  6667. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6668. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6669. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6670. writeGridDataTableJson(dStruct.TotalCount, dt);
  6671. }
  6672. }
  6673. public void get_erp_finishaftersalelist()
  6674. {
  6675. DataStruct dStruct = GetPostStruct();
  6676. List<string> lw = new List<string>();
  6677. int st = 4;
  6678. string tid = GetPostString("ctid");
  6679. if (tid.Length > 0)
  6680. {
  6681. string select_tid = getTidByCtid(tid);
  6682. lw.Add(string.Format("otid='{0}'", select_tid));
  6683. }
  6684. string shopname = GetPostString("shopname");
  6685. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6686. //lw.Add(string.Format("IsRefund!={0}", 1));
  6687. string reason = GetPostString("reason");
  6688. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6689. string method = GetPostString("method");
  6690. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6691. string buyernick = GetPostString("buyer_nick");
  6692. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6693. string handler = GetPostString("handler");
  6694. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6695. string handledate1 = GetPostString("handledate1");
  6696. string handledate2 = GetPostString("handledate2");
  6697. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6698. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6699. string finish1 = GetPostString("finishdate1");
  6700. string finish2 = GetPostString("finishdate2");
  6701. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6702. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6703. string supplier = GetPostString("supplier");
  6704. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6705. string responsible = GetPostString("responsibleman");
  6706. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6707. string vstate = GetPostString("vstate");
  6708. if (vstate.Length > 0)
  6709. {
  6710. if ("3".Equals(vstate))
  6711. {
  6712. lw.Add(string.Format("IsTem=1"));
  6713. }
  6714. else
  6715. {
  6716. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6717. }
  6718. }
  6719. lw.Add(string.Format("AfterSaleState=4"));
  6720. string code = CurrentUser.UserPost.Post.Code;
  6721. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6722. {
  6723. //不加条件,可以看全部
  6724. }
  6725. else if (code == "Supplier")
  6726. {
  6727. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6728. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6729. lw.Add("type = 1");
  6730. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6731. }
  6732. else if (code == "logistics")
  6733. {
  6734. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6735. lw.Add("type = 2");
  6736. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6737. }
  6738. 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")
  6739. {
  6740. lw.Add("type = 0");
  6741. int orgid = CurrentUser.UserPost.OrgID;
  6742. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6743. if (string.IsNullOrEmpty(manageOrgIds))
  6744. {
  6745. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6746. }
  6747. else
  6748. {
  6749. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6750. }
  6751. }
  6752. else
  6753. {
  6754. lw.Add("type = 0");
  6755. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6756. }
  6757. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6758. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6759. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6760. writeGridDataTableJson(dStruct.TotalCount, dt);
  6761. }
  6762. public void handle_erp_aftersale()
  6763. {
  6764. if (UrlPostParmsCheck("ctid"))
  6765. {
  6766. string eid = GetPostString("ctid");
  6767. string responStr = GetPostString("AfterSaleResponsible");
  6768. if (responStr.Length <= 0)
  6769. {
  6770. returnErrorMsg("售后责任人不能为空");
  6771. return;
  6772. }
  6773. bool isDesign = false;
  6774. double designFree = 0.00;
  6775. int responsibleId = 0;
  6776. CeErpTradeCell entity = null;
  6777. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6778. if (entity != null)
  6779. {
  6780. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6781. string afterMethod = GetPostString("AfterSaleMethod");
  6782. if (isNeedNewOrder == 1)
  6783. {
  6784. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6785. bool ishav = true;
  6786. if (newentity == null)
  6787. {
  6788. newentity = entity.Clone() as CeErpTradeCell;
  6789. ishav = false;
  6790. newentity.ctid = "S_" + entity.ctid;
  6791. newentity.OrderState = 0;
  6792. //唯一标识
  6793. newentity.OrderSn = newentity.ctid;
  6794. string orderSn = dataHelper.getSaleOrderSn();
  6795. if (orderSn != "")
  6796. {
  6797. newentity.OrderSn = orderSn;
  6798. }
  6799. }
  6800. newentity.UpdateTime = DateTime.Now;
  6801. newentity.AfterSaleState = 0;
  6802. newentity.AfterSaleMethod = afterMethod;
  6803. if (!ishav)
  6804. {
  6805. string memo_str = newentity.seller_memo;
  6806. memo_str = memo_str.Replace("(", "(");
  6807. memo_str = memo_str.Replace(")", ")");
  6808. int sIndex = memo_str.IndexOf("(");
  6809. int eIndex = memo_str.IndexOf(")");
  6810. if (sIndex == -1 || eIndex == -1)
  6811. {
  6812. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6813. return;
  6814. }
  6815. string first = memo_str.Substring(0, sIndex + 1);
  6816. string memoCtid = newentity.OrderSn;
  6817. //if (memoCtid.IndexOf("C") != -1)
  6818. //{
  6819. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6820. //if (CIdx.IndexOf("+") != -1)
  6821. //{
  6822. //CIdx = "C" + CIdx.Split('+')[1];
  6823. //}
  6824. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6825. //}
  6826. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6827. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6828. string newMemo = first + memoCtid + last;
  6829. newentity.seller_memo = newMemo;
  6830. newentity.FinishPlaceTime = null;
  6831. newentity.UnusualTag = 0;
  6832. newentity.UnusualCon = "";
  6833. newentity.UnusualTime = null;
  6834. newentity.AfterSaleMemo = "";
  6835. newentity.AfterSaleMethod = afterMethod;
  6836. newentity.AfterSalePreTime = null;
  6837. newentity.AfterSaleReason = "";
  6838. newentity.AfterSaleResponsible = "";
  6839. newentity.AfterSaleState = 0;
  6840. newentity.AfterSaleTime = null;
  6841. newentity.AfterSaleUserId = 0;
  6842. newentity.AfterSaleSupplierState = 0;
  6843. newentity.LastBillWaybillCode = "";
  6844. newentity.LastBillCpCode = "";
  6845. newentity.FinishAfterSaleTime = null;
  6846. newentity.HandleTime = null;
  6847. newentity.IsSF = 0;
  6848. newentity.IsOldCustomer = 0;
  6849. newentity.UrgencyTime = null;
  6850. newentity.ResponsibleUserId = "";
  6851. newentity.IsVerifyToSupplier = false;
  6852. newentity.payment = 0;
  6853. newentity.CheckMemo = "";
  6854. newentity.OutSid = "";
  6855. newentity.CheckOrderTime = null;
  6856. newentity.MemoOpt = 0;
  6857. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6858. }
  6859. newentity.isAfterSaleOrder = 1;
  6860. newentity.IsRefund = 0;
  6861. string receiveMobile = GetPostString("receiver_mobile");
  6862. if (receiveMobile.Length > 0)
  6863. {
  6864. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6865. if (trade != null)
  6866. {
  6867. trade.receiver_name = GetPostString("receiver_name");
  6868. trade.receiver_mobile = receiveMobile;
  6869. trade.receiver_state = GetPostString("receiver_state");
  6870. trade.receiver_city = GetPostString("receiver_city");
  6871. trade.receiver_district = GetPostString("receiver_district");
  6872. trade.receiver_address = GetPostString("receiver_address");
  6873. newentity.IsOffLineOrder = 1;
  6874. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6875. }
  6876. }
  6877. string st = GetPostString("ToState");
  6878. if (st.Length > 0)
  6879. {
  6880. if (newentity.OrderState <= 3)
  6881. {
  6882. newentity.WaitDesignTime = DateTime.Now;
  6883. newentity.StartDesignTime = null;
  6884. newentity.FinishDesignTime = null;
  6885. newentity.OrderState = 3;
  6886. if (st == "下单员")
  6887. {
  6888. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6889. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6890. {
  6891. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6892. }
  6893. }
  6894. else
  6895. {
  6896. newentity.WaitDesignTime = DateTime.Now;
  6897. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6898. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6899. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6900. {
  6901. DataRow user = dt1.Rows[0];
  6902. //找主管
  6903. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6904. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6905. if (dt != null && dt.Rows.Count > 0)
  6906. {
  6907. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6908. newentity.DesignUserId = designMr;
  6909. string key = "aftersale_order_" + designMr;
  6910. if (RedisHelper.HasKey(key))
  6911. {
  6912. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6913. list.Add(newentity.ctid);
  6914. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6915. }
  6916. }
  6917. //账号正常
  6918. if (user["State"].ToString() == "0")
  6919. {
  6920. newentity.DesignUserId = entity.DesignUserId;
  6921. string key = "aftersale_order_" + entity.DesignUserId;
  6922. if (RedisHelper.HasKey(key))
  6923. {
  6924. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6925. list.Add(newentity.ctid);
  6926. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6927. }
  6928. }
  6929. }
  6930. }
  6931. }
  6932. if (entity.IsXianHuo == 1)
  6933. {
  6934. newentity.OrderState = 6;
  6935. entity.FinishPlaceTime = DateTime.Now;
  6936. }
  6937. }
  6938. if (ishav)
  6939. {
  6940. newentity.Update();
  6941. }
  6942. else
  6943. {
  6944. newentity.Create();
  6945. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6946. newCellExtend.ctid = newentity.ctid;
  6947. newCellExtend.orderFrom = 20;
  6948. newCellExtend.orderType = 30;
  6949. if (st == "下单员")
  6950. {
  6951. }
  6952. else
  6953. {
  6954. newCellExtend.ReprintTime = DateTime.Now;
  6955. }
  6956. newCellExtend.Create();
  6957. }
  6958. if (st != "下单员")
  6959. {
  6960. if (entity.DispatchSort == 2)
  6961. {
  6962. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6963. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6964. }
  6965. }
  6966. }
  6967. //处理售后扩展
  6968. string resIdStr = GetPostString("ResponsibleUserId");
  6969. string refundFees = GetPostString("refundFrees");
  6970. int IsComplain = GetPostInt("isComplain");
  6971. int IsBad = GetPostInt("isBad");
  6972. string IsOriginal = GetPostString("isOriginal");
  6973. double diffResultPrice = GetPostDouble("diffResultPrice");
  6974. string textResult = GetPostString("textResult");
  6975. string supplierResponsible = GetPostString("supplierResponsible");
  6976. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6977. if (ceErpTradeAfterSaleExtend == null)
  6978. {
  6979. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6980. ceErpTradeAfterSaleExtend.tid = eid;
  6981. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6982. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6983. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6984. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6985. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6986. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6987. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6988. ceErpTradeAfterSaleExtend.Create();
  6989. }
  6990. else
  6991. {
  6992. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6993. {
  6994. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6995. }
  6996. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6997. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6998. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6999. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7000. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7001. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7002. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7003. ceErpTradeAfterSaleExtend.Update();
  7004. }
  7005. int gysid = GetPostInt("ResponsibleSupId");
  7006. if (entity.AfterSaleUserId == 0)
  7007. {
  7008. entity.AfterSaleUserId = CurrentUser.UserID;
  7009. }
  7010. entity.ResponsibleUserId = resIdStr;
  7011. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  7012. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  7013. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  7014. {
  7015. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7016. int backNum = 0;
  7017. if (number != null)
  7018. {
  7019. backNum = number.BackNum;
  7020. }
  7021. char[] separator = { ',' };
  7022. string[] sArray = resIdStr.Split(separator);
  7023. string[] refundFreeList = { };
  7024. if (refundFees.Length > 0)
  7025. {
  7026. refundFreeList = refundFees.Split(separator);
  7027. }
  7028. int index = -1;
  7029. List<int> responsibleIds = new List<int>();
  7030. foreach (string i in sArray)
  7031. {
  7032. index++;
  7033. if (i.Length <= 0) continue;
  7034. char[] separator2 = { '_' };
  7035. string idstr = i.Split(separator2)[0];
  7036. string idtype = i.Split(separator2)[1];
  7037. double refudFree = 0;
  7038. if (refundFreeList.Length > 0)
  7039. {
  7040. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  7041. }
  7042. if (idtype == "s")
  7043. {
  7044. isDesign = true;
  7045. designFree = refudFree;
  7046. }
  7047. int userId = Convert.ToInt32(idstr);
  7048. int type = 0;
  7049. if (idtype == "g")
  7050. {
  7051. type = 1;
  7052. }
  7053. if (idtype == "w")
  7054. {
  7055. type = 2;
  7056. }
  7057. if (idtype == "t")
  7058. {
  7059. type = 3;
  7060. }
  7061. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7062. if (ceErpTradeResponsible == null)
  7063. {
  7064. ceErpTradeResponsible = new CeErpTradeResponsible();
  7065. ceErpTradeResponsible.tid = eid;
  7066. ceErpTradeResponsible.UserId = userId;
  7067. ceErpTradeResponsible.createdTime = DateTime.Now;
  7068. ceErpTradeResponsible.type = type;
  7069. if (type == 1)
  7070. {
  7071. ceErpTradeResponsible.IsSup = 1;
  7072. }
  7073. if (type == 2)
  7074. {
  7075. ceErpTradeResponsible.IsFlow = 1;
  7076. }
  7077. }
  7078. int state = 0;
  7079. //已认可的不需要再次认可
  7080. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7081. {
  7082. state = 1;
  7083. }
  7084. ceErpTradeResponsible.RefundFee = refudFree;
  7085. ceErpTradeResponsible.VerifyState = state;
  7086. if (userId == 2125 || idtype == "w")
  7087. {
  7088. ceErpTradeResponsible.VerifyState = 1;
  7089. }
  7090. if (idtype == "w" && userId == 101)
  7091. {
  7092. ceErpTradeResponsible.VerifyState = state;
  7093. }
  7094. if (ceErpTradeResponsible.ID > 0)
  7095. {
  7096. ceErpTradeResponsible.Update();
  7097. }
  7098. else
  7099. {
  7100. ceErpTradeResponsible.Create();
  7101. }
  7102. if (isDesign)
  7103. {
  7104. responsibleId = ceErpTradeResponsible.ID;
  7105. }
  7106. responsibleIds.Add(ceErpTradeResponsible.ID);
  7107. }
  7108. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7109. CeErpTradeResponsible.NumByTid(backNum, eid);
  7110. }
  7111. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7112. if (ceErpTradeCellExtend != null)
  7113. {
  7114. ceErpTradeCellExtend.returnVisit = 0;
  7115. ceErpTradeCellExtend.Update();
  7116. }
  7117. if (entity.HandleTime != null)
  7118. {
  7119. if (entity.AfterSaleState == 1)
  7120. {
  7121. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7122. }
  7123. else
  7124. {
  7125. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7126. }
  7127. }
  7128. else
  7129. {
  7130. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7131. entity.HandleTime = DateTime.Now;
  7132. }
  7133. bool isCompale = false;
  7134. if (entity.AfterSaleState == 5)
  7135. {
  7136. isCompale = true;
  7137. entity.AfterSaleState = 3;
  7138. }
  7139. entity.AfterSaleSupplierState = 0;
  7140. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7141. {
  7142. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7143. }
  7144. string sImgs = GetPostString("img");
  7145. entity.AfterSaleSupplierImg = sImgs;
  7146. entity.supRefundType = GetPostString("supRefundType");
  7147. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7148. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7149. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7150. entity.AfterSaleMemoType = GetPostString("MemoType");
  7151. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7152. {
  7153. //entity.AfterSaleSupplierState = 2;
  7154. }
  7155. string df = GetPostString("DeductFee");
  7156. if (df == "")
  7157. {
  7158. df = "0";
  7159. }
  7160. string rf = GetPostString("RefundFee");
  7161. if (rf == "")
  7162. {
  7163. rf = "0";
  7164. }
  7165. string pm = GetPostString("AfterSalePayment");
  7166. if (pm == "")
  7167. {
  7168. pm = "0";
  7169. }
  7170. entity.AfterSalePayment = Convert.ToDouble(pm);
  7171. entity.DeductFee = Convert.ToDouble(df);
  7172. entity.RefundFee = Convert.ToDouble(rf);
  7173. entity.UpdateTime = DateTime.Now;
  7174. entity.Update();
  7175. string toState = GetPostString("ToState");
  7176. string original = GetPostString("isOriginal");
  7177. ApiVo apiVo = new ApiVo();
  7178. apiVo.orderNumber = entity.ctid;
  7179. apiVo.actionName = "afterDesign";
  7180. apiVo.orderRemarks = entity.AfterSaleMethod;
  7181. apiVo.reasonRemarks = entity.AfterSaleReason;
  7182. apiVo.isDesign = isDesign;
  7183. apiVo.designFree = designFree;
  7184. apiVo.responsibleId = responsibleId;
  7185. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7186. if (toState == "设计师")
  7187. {
  7188. apiVo.isOriginal = Convert.ToBoolean(original);
  7189. }
  7190. designHelper.API_WorkCore(apiVo);//afterDesign
  7191. CeErpMethod methodSql = new CeErpMethod();
  7192. methodSql.con = entity.AfterSaleMethod;
  7193. methodSql.addTime = DateTime.Now;
  7194. methodSql.Create();
  7195. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7196. CeErpMethod.ExecuteNonQuery(delsql);
  7197. if (isCompale)
  7198. {
  7199. aftersale_data_change(entity.ctid);
  7200. }
  7201. returnSuccessMsg("操作成功!");
  7202. return;
  7203. }
  7204. returnErrorMsg("找不到订单记录");
  7205. }
  7206. }
  7207. public void ins_erp_toresponsible()
  7208. {
  7209. if (UrlPostParmsCheck("ctid"))
  7210. {
  7211. string eid = GetPostString("ctid");
  7212. CeErpTradeCell entity = null;
  7213. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7214. if (entity != null)
  7215. {
  7216. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7217. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7218. {
  7219. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7220. return;
  7221. }
  7222. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7223. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7224. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7225. if (entity.AfterSalePreTime == null)
  7226. {
  7227. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7228. {
  7229. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7230. }
  7231. }
  7232. entity.AfterSalePreTime = DateTime.Now;
  7233. //预完成给售后主管审核客户问题直接完成
  7234. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7235. {
  7236. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7237. {
  7238. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7239. }
  7240. }
  7241. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  7242. ceErpTradeAfterSaleExtend.Update();
  7243. entity.AfterSaleState = 2;
  7244. entity.UpdateTime = DateTime.Now;
  7245. entity.Update();
  7246. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7247. aftersale_data_change(entity.ctid);
  7248. returnSuccessMsg("操作成功!");
  7249. return;
  7250. }
  7251. returnErrorMsg("找不到订单记录");
  7252. }
  7253. }
  7254. public void cancel_erp_aftersaleanddelnew()
  7255. {
  7256. if (UrlPostParmsCheck("ctid"))
  7257. {
  7258. string eid = GetPostString("ctid");
  7259. CeErpTradeCell entity = null;
  7260. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7261. if (entity != null)
  7262. {
  7263. entity.AfterSaleState = 0;
  7264. entity.AfterSaleReason = "";
  7265. entity.AfterSaleMethod = "";
  7266. entity.AfterSaleMemo = "";
  7267. entity.AfterSaleResponsible = "";
  7268. entity.ResponsibleUserId = "";
  7269. entity.DeductFee = 0;
  7270. entity.RefundFee = 0;
  7271. entity.IsArbitrate = 0;
  7272. CeErpTradeResponsible.DelByTid(eid, -1);
  7273. entity.Update();
  7274. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7275. if (after != null)
  7276. {
  7277. if (after.OrderState < 5)
  7278. CeErpTradeCell.DelByCtid("S_" + eid);
  7279. }
  7280. returnSuccessMsg("操作成功!");
  7281. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7282. return;
  7283. }
  7284. returnErrorMsg("找不到订单记录");
  7285. }
  7286. }
  7287. public void get_erp_aftersale_pregather()
  7288. {
  7289. List<string> lw = new List<string>();
  7290. int st = GetInt("st");
  7291. string tid = GetPostString("ctid");
  7292. if (tid.Length > 0)
  7293. {
  7294. string select_tid = getTidByCtid(tid);
  7295. lw.Add(string.Format("tid='{0}'", select_tid));
  7296. }
  7297. string shopname = GetPostString("shopname");
  7298. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7299. string buyernick = GetPostString("buyer_nick");
  7300. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7301. string sellermemo = GetPostString("seller_memo");
  7302. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7303. string orderState = GetPostString("orderState");
  7304. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7305. string reason = GetPostString("reason");
  7306. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7307. string method = GetPostString("method");
  7308. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7309. string handler = GetPostString("handler");
  7310. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7311. string handledate1 = GetPostString("handledate1");
  7312. string handledate2 = GetPostString("handledate2");
  7313. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7314. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7315. string supplier = GetPostString("supplier");
  7316. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7317. string responsible = GetPostString("responsibleman");
  7318. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7319. string customer = GetPostString("customer");
  7320. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7321. string design = GetPostString("design");
  7322. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7323. string afterMemoType = GetPostString("aftermemotype");
  7324. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7325. string afterSaleMemo = GetPostString("afterSaleMemo");
  7326. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7327. string afterresult = GetPostString("afterresult");
  7328. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7329. string poscode = CurrentUser.UserPost.Post.Code;
  7330. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7331. {
  7332. string shopid = CurrentUser.User.pemShop;
  7333. lw.Add(string.Format("shopId in ({0})", shopid));
  7334. }
  7335. var mainwhere = string.Join(" and ", lw.ToArray());
  7336. string ro_json = "";
  7337. string type = GetPostString("gather_type");
  7338. int number = 0;
  7339. if (poscode == "AfterSale")
  7340. {
  7341. //处理中
  7342. if (type == "Handling")
  7343. {
  7344. 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) : ""));
  7345. DataTable dt = null;
  7346. try
  7347. {
  7348. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7349. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7350. }
  7351. catch (Exception e)
  7352. {
  7353. dt = new DataTable();
  7354. }
  7355. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7356. return;
  7357. }
  7358. if (type == "Wait")
  7359. {
  7360. //待处理
  7361. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7362. DataTable dt1 = null;
  7363. try
  7364. {
  7365. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7366. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7367. }
  7368. catch (Exception e)
  7369. {
  7370. dt1 = new DataTable();
  7371. }
  7372. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7373. return;
  7374. }
  7375. if (type == "back")
  7376. {
  7377. //打回
  7378. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7379. DataTable dt2 = null;
  7380. try
  7381. {
  7382. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7383. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7384. }
  7385. catch (Exception e)
  7386. {
  7387. dt2 = new DataTable();
  7388. }
  7389. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7390. return;
  7391. }
  7392. if (type == "preCompletion")
  7393. {
  7394. //预完成
  7395. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7396. DataTable dt3 = null;
  7397. try
  7398. {
  7399. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7400. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7401. }
  7402. catch (Exception e)
  7403. {
  7404. dt3 = new DataTable();
  7405. }
  7406. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7407. return;
  7408. }
  7409. if (type == "documentary")
  7410. {
  7411. //跟单中
  7412. 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) : ""));
  7413. DataTable dt4 = null;
  7414. try
  7415. {
  7416. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7417. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7418. }
  7419. catch (Exception e)
  7420. {
  7421. dt4 = new DataTable();
  7422. }
  7423. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7424. return;
  7425. }
  7426. if (type == "reBack")
  7427. {
  7428. //被打回
  7429. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7430. DataTable dt1 = null;
  7431. try
  7432. {
  7433. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7434. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7435. }
  7436. catch (Exception e)
  7437. {
  7438. dt1 = new DataTable();
  7439. }
  7440. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7441. return;
  7442. }
  7443. }
  7444. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7445. {
  7446. if (type == "puBack")
  7447. {
  7448. //退回
  7449. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7450. DataTable dt = null;
  7451. try
  7452. {
  7453. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7454. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7455. }
  7456. catch (Exception e)
  7457. {
  7458. dt = new DataTable();
  7459. }
  7460. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7461. return;
  7462. }
  7463. if (type == "reBack")
  7464. {
  7465. //打回
  7466. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7467. DataTable dt1 = null;
  7468. try
  7469. {
  7470. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7471. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7472. }
  7473. catch (Exception e)
  7474. {
  7475. dt1 = new DataTable();
  7476. }
  7477. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7478. return;
  7479. }
  7480. if (type == "examEd")
  7481. {
  7482. //已审核
  7483. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7484. DataTable dt2 = null;
  7485. try
  7486. {
  7487. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7488. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7489. }
  7490. catch (Exception e)
  7491. {
  7492. dt2 = new DataTable();
  7493. }
  7494. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7495. return;
  7496. }
  7497. if (type == "waitExam")
  7498. {
  7499. //待审核
  7500. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7501. DataTable dt3 = null;
  7502. try
  7503. {
  7504. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7505. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7506. }
  7507. catch (Exception e)
  7508. {
  7509. dt3 = new DataTable();
  7510. }
  7511. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7512. return;
  7513. }
  7514. if (type == "Handling")
  7515. {
  7516. //处理中
  7517. 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) : ""));
  7518. DataTable dt4 = null;
  7519. try
  7520. {
  7521. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7522. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7523. }
  7524. catch (Exception e)
  7525. {
  7526. dt4 = new DataTable();
  7527. }
  7528. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7529. return;
  7530. }
  7531. if (type == "Wait")
  7532. {
  7533. //待处理
  7534. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7535. DataTable dt5 = null;
  7536. try
  7537. {
  7538. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7539. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7540. }
  7541. catch (Exception e)
  7542. {
  7543. dt5 = new DataTable();
  7544. }
  7545. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7546. return;
  7547. }
  7548. if (type == "documentary")
  7549. {
  7550. //跟单中
  7551. 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) : ""));
  7552. DataTable dt6 = null;
  7553. try
  7554. {
  7555. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7556. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7557. }
  7558. catch (Exception e)
  7559. {
  7560. dt6 = new DataTable();
  7561. }
  7562. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7563. return;
  7564. }
  7565. }
  7566. returnSuccess(ro_json);
  7567. }
  7568. public void end_erp_aftersale()
  7569. {
  7570. if (UrlPostParmsCheck("ctid"))
  7571. {
  7572. string eid = GetPostString("ctid");
  7573. CeErpTradeCell entity = null;
  7574. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7575. if (entity != null)
  7576. {
  7577. string stype = GetPostString("stype");
  7578. string typeStr = stype;
  7579. entity.AfterSaleState = 4;
  7580. entity.FinishAfterSaleTime = DateTime.Now;
  7581. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7582. entity.Update();
  7583. ApiVo apiVo = new ApiVo();
  7584. apiVo.orderNumber = entity.ctid;
  7585. apiVo.actionName = "afterOver";
  7586. designHelper.API_WorkCore(apiVo); //afterOver
  7587. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7588. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7589. CeErpSukuraData.createInfo(entity.ctid, 8);
  7590. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7591. returnSuccessMsg("操作成功!");
  7592. return;
  7593. }
  7594. returnErrorMsg("找不到订单记录");
  7595. }
  7596. }
  7597. public void ins_erp_finishaftersale()
  7598. {
  7599. if (UrlPostParmsCheck("id"))
  7600. {
  7601. string eid = GetPostString("id");
  7602. CeErpTradeResponsible entity = null;
  7603. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7604. if (entity != null)
  7605. {
  7606. entity.VerifyState = 1;
  7607. entity.VerifyTime = DateTime.Now;
  7608. entity.Update();
  7609. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7610. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7611. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7612. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7613. if (dt.Rows.Count <= 0)
  7614. {
  7615. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7616. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7617. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7618. CeErpSukuraData.createInfo(entity.tid, 8);
  7619. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7620. {
  7621. CeErpDesignerBill.Del(entity.tid);
  7622. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7623. }
  7624. }
  7625. returnSuccessMsg("操作成功!");
  7626. return;
  7627. }
  7628. returnErrorMsg("找不到订单记录");
  7629. }
  7630. }
  7631. public void upd_erp_arbitrateaftersale()
  7632. {
  7633. if (UrlPostParmsCheck("id"))
  7634. {
  7635. string eid = GetPostString("id");
  7636. CeErpTradeResponsible entity = null;
  7637. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7638. if (entity != null)
  7639. {
  7640. entity.IsArbitrate = 1;
  7641. entity.ArbitradeMemo = GetPostString("reason");
  7642. entity.VerifyState = 2;
  7643. entity.Update();
  7644. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7645. if (tradecell != null)
  7646. {
  7647. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7648. tradecell.IsArbitrate = 1;
  7649. tradecell.Update();
  7650. }
  7651. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7652. returnSuccessMsg("操作成功!");
  7653. return;
  7654. }
  7655. returnErrorMsg("找不到订单记录");
  7656. }
  7657. }
  7658. public void upd_erp_backaftersale()
  7659. {
  7660. if (UrlPostParmsCheck("tid"))
  7661. {
  7662. string eid = GetPostString("tid");
  7663. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7664. int backNum = 0;
  7665. if (number != null)
  7666. {
  7667. backNum = number.BackNum;
  7668. }
  7669. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7670. CeErpTradeCell entity = null;
  7671. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7672. if (entity != null)
  7673. {
  7674. entity.AfterSaleBackReason = GetPostString("backreason");
  7675. entity.AfterSaleState = 1;
  7676. entity.AfterSaleSupplierState = 0;
  7677. entity.UpdateTime = DateTime.Now;
  7678. entity.Update();
  7679. returnSuccessMsg("操作成功!");
  7680. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7681. return;
  7682. }
  7683. returnErrorMsg("找不到订单记录");
  7684. }
  7685. }
  7686. public void get_erp_supplieraftersalelist()
  7687. {
  7688. DataStruct dStruct = GetPostStruct();
  7689. List<string> lw = new List<string>();
  7690. string tid = GetPostString("ctid");
  7691. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7692. string shopname = GetPostString("shopname");
  7693. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7694. string buyernick = GetPostString("buyer_nick");
  7695. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7696. string sellermemo = GetPostString("seller_memo");
  7697. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7698. string orderState = GetPostString("orderState");
  7699. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7700. string afterState = GetPostString("afterstate");
  7701. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7702. string date1 = GetPostString("date1");
  7703. string date2 = GetPostString("date2");
  7704. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7705. if (dw.Length > 0) lw.Add(dw);
  7706. string price1 = GetPostString("price1");
  7707. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7708. string price2 = GetPostString("price2");
  7709. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7710. string reason = GetPostString("reason");
  7711. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7712. string method = GetPostString("method");
  7713. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7714. string handledate1 = GetPostString("handledate1");
  7715. string handledate2 = GetPostString("handledate2");
  7716. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7717. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7718. string handler = GetPostString("handler");
  7719. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7720. string afterdate1 = GetPostString("afterdate1");
  7721. string afterdate2 = GetPostString("afterdate2");
  7722. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7723. if (afterDate.Length > 0) lw.Add(afterDate);
  7724. string customer = GetPostString("customer");
  7725. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7726. string design = GetPostString("design");
  7727. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7728. string afterMemoType = GetPostString("aftermemotype");
  7729. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7730. string vstate = GetPostString("vstate");
  7731. if (vstate.Length > 0)
  7732. {
  7733. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7734. }
  7735. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7736. string supplier = GetPostString("supplier");
  7737. int supid = commonHelper.getSupplierIDByName(supplier);
  7738. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7739. string posCode = CurrentUser.UserPost.Post.Code;
  7740. if (posCode == "Supplier")
  7741. {
  7742. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7743. }
  7744. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7745. {
  7746. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7747. }
  7748. else
  7749. {
  7750. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7751. }
  7752. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7753. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7754. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7755. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7756. writeGridDataTableJson(dStruct.TotalCount, dt);
  7757. }
  7758. public void upd_erp_supverifyaftersale()
  7759. {
  7760. if (UrlPostParmsCheck("id"))
  7761. {
  7762. string id = GetPostString("id");
  7763. int st = GetPostInt("afterstate");
  7764. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7765. CeErpTradeCell entity = null;
  7766. if (ceErpTradeResponsible != null)
  7767. {
  7768. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7769. }
  7770. string afmemo = GetPostString("supmemo");
  7771. string image = GetPostString("image");
  7772. if (entity != null)
  7773. {
  7774. entity.AfterSaleSupplierState = st;
  7775. entity.AfterSaleSupplierMemo = afmemo;
  7776. if (st == 1)
  7777. {
  7778. ceErpTradeResponsible.VerifyState = 1;
  7779. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7780. ceErpTradeResponsible.Update();
  7781. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7782. if (isAll)
  7783. {
  7784. entity.AfterSaleState = 4;
  7785. entity.FinishAfterSaleTime = DateTime.Now;
  7786. }
  7787. }
  7788. else
  7789. {
  7790. CeErpTradeResponsible.dateByTid(entity.ctid);
  7791. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7792. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7793. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7794. if (num <= 1)
  7795. {
  7796. entity.AfterSaleState = 1;
  7797. }
  7798. else
  7799. {
  7800. entity.AfterSaleState = 5;
  7801. }
  7802. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7803. if (ceErpTradeAfterSaleExtend != null)
  7804. {
  7805. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7806. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7807. ceErpTradeAfterSaleExtend.Update();
  7808. }
  7809. else
  7810. {
  7811. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7812. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7813. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7814. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7815. ceErpTradeAfterSaleExtend.Create();
  7816. }
  7817. }
  7818. if (entity.AfterSaleState == 4)
  7819. {
  7820. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7821. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7822. {
  7823. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7824. }
  7825. ApiVo apiVo = new ApiVo();
  7826. apiVo.orderNumber = entity.ctid;
  7827. apiVo.actionName = "afterOver";
  7828. designHelper.API_WorkCore(apiVo); //afterOver
  7829. }
  7830. entity.UpdateTime = DateTime.Now;
  7831. entity.Update();
  7832. returnSuccessMsg("操作成功!");
  7833. CeErpSukuraData.createInfo(entity.ctid, 8);
  7834. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7835. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7836. return;
  7837. }
  7838. returnErrorMsg("找不到订单记录");
  7839. }
  7840. }
  7841. public void upd_erp_masteraftersale()
  7842. {
  7843. if (UrlPostParmsCheck("id"))
  7844. {
  7845. string id = GetPostString("id");
  7846. int st = GetPostInt("afterstate");
  7847. string afmemo = GetPostString("supmemo");
  7848. string image = GetPostString("image");
  7849. string textResult = GetPostString("textResult");
  7850. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7851. if (ceErpTradeResponsible != null)
  7852. {
  7853. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7854. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7855. ceErpTradeResponsible.Update();
  7856. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7857. if (entity != null)
  7858. {
  7859. entity.AfterSaleSupplierState = st;
  7860. entity.AfterSaleSupplierMemo = afmemo;
  7861. if (st == 1)
  7862. {
  7863. }
  7864. else
  7865. {
  7866. CeErpTradeResponsible.dateByTid(entity.ctid);
  7867. //退回到售后
  7868. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7869. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7870. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7871. if (num <= 1)
  7872. {
  7873. entity.AfterSaleState = 1;
  7874. }
  7875. else
  7876. {
  7877. entity.AfterSaleState = 5;
  7878. }
  7879. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7880. if (ceErpTradeAfterSaleExtend != null)
  7881. {
  7882. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7883. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7884. ceErpTradeAfterSaleExtend.Update();
  7885. }
  7886. else
  7887. {
  7888. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7889. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7890. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7891. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7892. ceErpTradeAfterSaleExtend.Create();
  7893. }
  7894. }
  7895. entity.UpdateTime = DateTime.Now;
  7896. entity.Update();
  7897. returnSuccessMsg("操作成功!");
  7898. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7899. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7900. return;
  7901. }
  7902. }
  7903. returnErrorMsg("找不到订单记录");
  7904. }
  7905. }
  7906. public void upd_erp_personaftersale()
  7907. {
  7908. if (UrlPostParmsCheck("id"))
  7909. {
  7910. //林小连
  7911. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7912. {
  7913. upd_erp_masteraftersale();
  7914. return;
  7915. }
  7916. string id = GetPostString("id");
  7917. int st = GetPostInt("afterstate");
  7918. string afmemo = GetPostString("supmemo");
  7919. string image = GetPostString("image");
  7920. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7921. if (ceErpTradeResponsible != null)
  7922. {
  7923. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7924. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7925. ceErpTradeResponsible.Update();
  7926. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7927. if (entity != null)
  7928. {
  7929. entity.AfterSaleSupplierMemo = afmemo;
  7930. entity.AfterSaleSupplierState = st;
  7931. if (st == 1)
  7932. {
  7933. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7934. if (isAll)
  7935. {
  7936. entity.AfterSaleState = 4;
  7937. entity.FinishAfterSaleTime = DateTime.Now;
  7938. }
  7939. }
  7940. else
  7941. {
  7942. CeErpTradeResponsible.dateByTid(entity.ctid);
  7943. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7944. if (ceErpTradeAfterSaleExtend != null)
  7945. {
  7946. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7947. ceErpTradeAfterSaleExtend.Update();
  7948. }
  7949. else
  7950. {
  7951. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7952. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7953. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7954. ceErpTradeAfterSaleExtend.Create();
  7955. }
  7956. //退回到主管
  7957. //entity.AfterSaleState = 2;
  7958. }
  7959. if (entity.AfterSaleState == 4)
  7960. {
  7961. ApiVo apiVo = new ApiVo();
  7962. apiVo.orderNumber = entity.ctid;
  7963. apiVo.actionName = "afterOver";
  7964. designHelper.API_WorkCore(apiVo); //afterOver
  7965. }
  7966. entity.UpdateTime = DateTime.Now;
  7967. entity.Update();
  7968. returnSuccessMsg("操作成功!");
  7969. CeErpSukuraData.createInfo(entity.ctid, 8);
  7970. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7971. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7972. return;
  7973. }
  7974. }
  7975. returnErrorMsg("找不到订单记录");
  7976. }
  7977. }
  7978. public void set_erp_supplierrefundtag()
  7979. {
  7980. if (UrlPostParmsCheck("ctid"))
  7981. {
  7982. string eid = GetPostString("ctid");
  7983. CeErpTradeCell entity = null;
  7984. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7985. if (entity != null)
  7986. {
  7987. entity.IsSupplierRefund = GetPostInt("tag");
  7988. entity.Update();
  7989. returnSuccessMsg("操作成功!");
  7990. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7991. return;
  7992. }
  7993. returnErrorMsg("找不到订单记录");
  7994. }
  7995. }
  7996. public void get_erp_refundlist()
  7997. {
  7998. DataStruct dStruct = GetPostStruct();
  7999. List<string> lw = new List<string>();
  8000. string tid = GetPostString("tid");
  8001. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8002. //string rid = GetPostString("refund_id");
  8003. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  8004. string shopname = GetPostString("shopname");
  8005. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8006. string buyernick = GetPostString("buyer_nick");
  8007. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8008. string customer = GetPostString("customer");
  8009. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8010. string design = GetPostString("design");
  8011. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8012. string sellermemo = GetPostString("seller_memo");
  8013. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8014. //string date1 = GetPostString("date1");
  8015. //string date2 = GetPostString("date2");
  8016. //string dateType = GetPostString("dateType");
  8017. //if (dateType.Length > 0)
  8018. //{
  8019. // if (dateType == "1001") dateType = "0";
  8020. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  8021. // if (searchDT.Count == 2)
  8022. // {
  8023. // date1 = searchDT[0].ToString();
  8024. // date2 = searchDT[1].ToString();
  8025. // }
  8026. //}
  8027. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8028. //if (dw.Length > 0) lw.Add(dw);
  8029. string redate1 = GetPostString("refunddate1");
  8030. string redate2 = GetPostString("refunddate2");
  8031. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8032. if (dwdate.Length > 0) lw.Add(dwdate);
  8033. string price1 = GetPostString("price1");
  8034. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8035. string price2 = GetPostString("price2");
  8036. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8037. string ispartrefund = GetPostString("ispartrefund");
  8038. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8039. string refundState = GetPostString("refundvstate");
  8040. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  8041. int st = GetInt("st");
  8042. if (st == 2) //待确认列表中,把state=3已确认的也显示
  8043. {
  8044. string responsible = GetPostString("responsibleman");
  8045. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8046. lw.Add(string.Format("RefundState>={0}", st));
  8047. string code = CurrentUser.UserPost.Post.Code;
  8048. if (code == "CustomerService")
  8049. {
  8050. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  8051. }
  8052. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  8053. {
  8054. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  8055. }
  8056. else if (code == "Place" || code == "PlaceMr")
  8057. {
  8058. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8059. }
  8060. dStruct.Order = "RefundState asc,created desc";
  8061. }
  8062. else if (st == 10)
  8063. {
  8064. string responsible = GetPostString("responsibleman");
  8065. if (responsible == "空白")
  8066. {
  8067. lw.Add(string.Format("ResponsibleUserName = ''"));
  8068. }
  8069. else if (responsible.Length > 0)
  8070. {
  8071. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8072. }
  8073. lw.Add(string.Format("RefundState>=0"));
  8074. dStruct.Order = "created desc";
  8075. }
  8076. else
  8077. {
  8078. string responsible = GetPostString("responsibleman");
  8079. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8080. lw.Add(string.Format("RefundState={0}", st));
  8081. dStruct.Order = "created desc";
  8082. }
  8083. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8084. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8085. dt.Columns.Add("refund_fees");
  8086. foreach (DataRow dr in dt.Rows)
  8087. {
  8088. String status = dr["status"].ToString();
  8089. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8090. {
  8091. dr["refund_fees"] = dr["refund_fee"];
  8092. }
  8093. else
  8094. {
  8095. dr["refund_fees"] = "0.0";
  8096. }
  8097. }
  8098. writeGridDataTableJson(dStruct.TotalCount, dt);
  8099. }
  8100. public void get_erp_refunddesignlist()
  8101. {
  8102. DataStruct dStruct = GetPostStruct();
  8103. List<string> lw = new List<string>();
  8104. string tid = GetPostString("tid");
  8105. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8106. string shopname = GetPostString("shopname");
  8107. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8108. string buyernick = GetPostString("buyer_nick");
  8109. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8110. string customer = GetPostString("customer");
  8111. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8112. string design = GetPostString("design");
  8113. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8114. string sellermemo = GetPostString("seller_memo");
  8115. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8116. string redate1 = GetPostString("refunddate1");
  8117. string redate2 = GetPostString("refunddate2");
  8118. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8119. if (dwdate.Length > 0) lw.Add(dwdate);
  8120. string price1 = GetPostString("price1");
  8121. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8122. string price2 = GetPostString("price2");
  8123. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8124. string ispartrefund = GetPostString("ispartrefund");
  8125. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8126. string designerorg = GetPostString("designerorg");
  8127. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8128. string refundState = GetPostString("refundState");
  8129. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8130. int myOrgid = CurrentUser.UserPost.OrgID;
  8131. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8132. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8133. {
  8134. if (CurrentUser.User.TeamIds.Length > 0)
  8135. {
  8136. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8137. }
  8138. else
  8139. {
  8140. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8141. }
  8142. }
  8143. else if ("SysAdmin".Equals(myOrgCode))
  8144. {
  8145. }
  8146. else
  8147. {
  8148. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8149. {
  8150. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8151. }
  8152. else
  8153. {
  8154. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8155. }
  8156. }
  8157. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8158. dStruct.Order = "created desc";
  8159. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8160. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8161. dt.Columns.Add("refund_fees");
  8162. foreach (DataRow dr in dt.Rows)
  8163. {
  8164. String status = dr["status"].ToString();
  8165. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8166. {
  8167. dr["refund_fees"] = dr["refund_fee"];
  8168. }
  8169. else
  8170. {
  8171. dr["refund_fees"] = "0.0";
  8172. }
  8173. }
  8174. writeGridDataTableJson(dStruct.TotalCount, dt);
  8175. }
  8176. public void handle_erp_refundtag()
  8177. {
  8178. if (UrlPostParmsCheck("refund_id"))
  8179. {
  8180. string eid = GetPostString("refund_id");
  8181. string respMan = GetPostString("ResponsibleName");
  8182. if (respMan.Length <= 0)
  8183. {
  8184. returnErrorMsg("责任人不能为空");
  8185. return;
  8186. }
  8187. CeErpTradeRefund entity = null;
  8188. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8189. if (entity != null)
  8190. {
  8191. entity.ResponsibleUserName = respMan;
  8192. string userid = GetPostString("ResponsibleUserId");
  8193. if (userid.Length > 0)
  8194. {
  8195. entity.ResponsibleUserId = userid;
  8196. }
  8197. entity.Memo = GetPostString("Memo");
  8198. if (respMan.IndexOf("客服") != -1 ||
  8199. respMan.IndexOf("设计师") != -1 ||
  8200. respMan.IndexOf("下单员") != -1)
  8201. {
  8202. entity.RefundState = 2;
  8203. }
  8204. else
  8205. {
  8206. entity.RefundState = 3;
  8207. }
  8208. entity.modified = DateTime.Now;
  8209. entity.Update();
  8210. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8211. returnSuccessMsg("操作成功!");
  8212. return;
  8213. }
  8214. returnErrorMsg("找不到订单记录");
  8215. }
  8216. }
  8217. public void handle_erp_designrefundtag()
  8218. {
  8219. if (UrlPostParmsCheck("refund_id"))
  8220. {
  8221. string eid = GetPostString("refund_id");
  8222. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8223. if (ceErpTradeCellExtend == null)
  8224. {
  8225. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8226. ceErpTradeCellExtend.ctid = eid;
  8227. }
  8228. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8229. if (ceErpTradeCellExtend.ID > 0)
  8230. {
  8231. ceErpTradeCellExtend.Update();
  8232. }
  8233. else
  8234. {
  8235. ceErpTradeCellExtend.Create();
  8236. }
  8237. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8238. returnSuccessMsg("操作成功!");
  8239. return;
  8240. }
  8241. returnErrorMsg("找不到订单记录");
  8242. }
  8243. public void upd_erp_refundverify()
  8244. {
  8245. if (UrlPostParmsCheck("refund_id"))
  8246. {
  8247. string eid = GetPostString("refund_id");
  8248. CeErpTradeRefund entity = null;
  8249. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8250. if (entity != null)
  8251. {
  8252. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8253. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8254. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8255. {
  8256. entity.RefundState = 2;
  8257. }
  8258. else
  8259. {
  8260. entity.RefundState = 3;
  8261. }
  8262. entity.Update();
  8263. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8264. returnSuccessMsg("操作成功!");
  8265. return;
  8266. }
  8267. returnErrorMsg("找不到订单记录");
  8268. }
  8269. }
  8270. public void upd_erp_refundapprove()
  8271. {
  8272. if (UrlPostParmsCheck("refund_id"))
  8273. {
  8274. string eid = GetPostString("refund_id");
  8275. CeErpTradeRefund entity = null;
  8276. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8277. if (entity != null)
  8278. {
  8279. int apr = GetPostInt("approve");
  8280. if (apr == 0)
  8281. {
  8282. entity.RefundState = 1;
  8283. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8284. }
  8285. else if (apr == 1)
  8286. {
  8287. entity.RefundState = 3;
  8288. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8289. }
  8290. entity.modified = DateTime.Now;
  8291. entity.Update();
  8292. returnSuccessMsg("操作成功!");
  8293. return;
  8294. }
  8295. returnErrorMsg("找不到订单记录");
  8296. }
  8297. }
  8298. public void get_erp_billlist()
  8299. {
  8300. DataStruct dStruct = GetPostStruct();
  8301. List<string> lw = new List<string>();
  8302. string title = GetPostString("title");
  8303. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8304. string tid = GetPostString("tid");
  8305. string tids = GetPostString("tids");
  8306. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8307. if (tids.Length > 0)
  8308. {
  8309. tids = "'" + tids + "'";
  8310. tids = tids.Replace(",", "','");
  8311. lw.Add(string.Format("tid in ({0})", tids));
  8312. }
  8313. string shopname = GetPostString("shopname");
  8314. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8315. string buyernick = GetPostString("buyer_nick");
  8316. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8317. string customer = GetPostString("customer");
  8318. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8319. string date1 = GetPostString("date1");
  8320. string date2 = GetPostString("date2");
  8321. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8322. if (dw.Length > 0) lw.Add(dw);
  8323. string price1 = GetPostString("price1");
  8324. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8325. string price2 = GetPostString("price2");
  8326. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8327. string returndate1 = GetPostString("returndate1");
  8328. string returndate2 = GetPostString("returndate2");
  8329. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8330. if (dw1.Length > 0) lw.Add(dw1);
  8331. string billtype = GetPostString("billtype");
  8332. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8333. string billstate = GetPostString("billstate");
  8334. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8335. string usershop = CurrentUser.User.pemShop;
  8336. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8337. dStruct.Order = "createTime desc";
  8338. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8339. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8340. //foreach (DataRow dr in dt.Rows)
  8341. //{
  8342. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8343. //}
  8344. writeGridDataTableJson(dStruct.TotalCount, dt);
  8345. }
  8346. public void modify_erp_billinfo()
  8347. {
  8348. if (UrlPostParmsCheck("ID"))
  8349. {
  8350. string eid = GetPostString("ID");
  8351. CeErpBill bill_entity = null;
  8352. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8353. if (bill_entity != null)
  8354. {
  8355. bill_entity.tid = GetPostString("tid");
  8356. bill_entity.title = GetPostString("title");
  8357. bill_entity.tax = GetPostString("tax");
  8358. bill_entity.bank = GetPostString("bank");
  8359. bill_entity.bankac = GetPostString("bankac");
  8360. bill_entity.address = GetPostString("address");
  8361. bill_entity.phone = GetPostString("phone");
  8362. bill_entity.price = GetPostString("price");
  8363. bill_entity.productId = GetPostInt("ProductName");
  8364. bill_entity.num = GetPostInt("num");
  8365. bill_entity.unit = GetPostString("unit");
  8366. bill_entity.type = GetPostString("type");
  8367. bill_entity.sendType = GetPostString("SendType");
  8368. bill_entity.email = GetPostString("email");
  8369. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8370. bill_entity.shopName = GetPostString("ShopName");
  8371. bill_entity.applymemo = GetPostString("applymemo");
  8372. bill_entity.modifyTime = DateTime.Now;
  8373. bill_entity.createTime = DateTime.Now;
  8374. bill_entity.state = 0;
  8375. bill_entity.Update();
  8376. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8377. returnSuccessMsg("发票修改成功!");
  8378. return;
  8379. }
  8380. returnErrorMsg("找不到对应记录");
  8381. }
  8382. }
  8383. public void set_erp_invoicing()
  8384. {
  8385. if (UrlPostParmsCheck("id"))
  8386. {
  8387. try
  8388. {
  8389. string eid = GetPostString("id");
  8390. CeErpBill bill_entity = null;
  8391. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8392. if (bill_entity != null)
  8393. {
  8394. int ComId = GetPostInt("ComId");
  8395. //string memo = GetPostString("Memo");
  8396. int allInfo = GetPostInt("allinfo");
  8397. string clert = CurrentUser.User.Name;
  8398. //string detailValue = GetPostString("detailvalue");
  8399. string billId = bill_entity.billOrderId;
  8400. string[] billIdList = billId.Split(',');
  8401. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8402. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8403. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8404. {
  8405. billCount += 1;
  8406. }
  8407. if (billId.Length <= 0 || billIdList.Length != billCount)
  8408. {
  8409. bill_entity.billOrderId = "";
  8410. string prebill = "ltb";
  8411. for (int idx = 1; idx <= billCount; idx++)
  8412. {
  8413. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8414. string billoid = prebill + idx + dtstr;
  8415. bill_entity.billOrderId += billoid;
  8416. if (idx < billCount)
  8417. {
  8418. bill_entity.billOrderId += ",";
  8419. }
  8420. }
  8421. }
  8422. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8423. if (bill_entity.state == 5)
  8424. {
  8425. string errMsg = bill_entity.failerror;
  8426. string[] errlist = errMsg.Split('|');
  8427. string[] errTags = new string[errlist.Length];
  8428. for (int itag = 0; itag < errlist.Length; itag++)
  8429. {
  8430. if (errlist[itag].Length <= 0) continue;
  8431. errTags[itag] = errlist[itag].Split('&')[0];
  8432. }
  8433. for (int iii = 0; iii < errTags.Length; iii++)
  8434. {
  8435. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8436. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8437. if (billOrderList.Length >= erroBillOrderTag)
  8438. {
  8439. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8440. if (needModifyBillId.Length <= 19)
  8441. {
  8442. needModifyBillId = needModifyBillId + "1";
  8443. }
  8444. else
  8445. {
  8446. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8447. last = last + 1;
  8448. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8449. }
  8450. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8451. }
  8452. }
  8453. }
  8454. bool isHaveBillSucces = false;
  8455. string totalRes = "";
  8456. bill_entity.failerror = "";
  8457. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8458. {
  8459. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8460. totalRes += res;
  8461. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8462. {
  8463. isHaveBillSucces = true;
  8464. bill_entity.comId = ComId;
  8465. bill_entity.state = 1;
  8466. bill_entity.executeTime = DateTime.Now;
  8467. bill_entity.executeUser = clert;
  8468. }
  8469. else
  8470. {
  8471. bill_entity.state = 5;
  8472. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8473. }
  8474. }
  8475. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8476. bill_entity.Update();
  8477. if (isHaveBillSucces)
  8478. {
  8479. StringBuilder sql = new StringBuilder();
  8480. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8481. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8482. }
  8483. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8484. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8485. {
  8486. returnErrorMsg("开票失败");
  8487. }
  8488. else
  8489. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8490. return;
  8491. }
  8492. returnErrorMsg("找不到对应记录");
  8493. }
  8494. catch (Exception ex)
  8495. {
  8496. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8497. returnErrorMsg("操作失败");
  8498. }
  8499. }
  8500. }
  8501. public void get_erp_invoicing_back()
  8502. {
  8503. if (UrlPostParmsCheck("id"))
  8504. {
  8505. try
  8506. {
  8507. string id = GetPostString("id");
  8508. CeErpBill entiy = CeErpBill.Get(id);
  8509. if (entiy != null)
  8510. {
  8511. if (entiy.state == 0)
  8512. {
  8513. returnErrorMsg("发票还未开具");
  8514. return;
  8515. }
  8516. string[] billOrderList = entiy.billOrderId.Split(',');
  8517. int iTag = 0;
  8518. entiy.fplsh = "";
  8519. entiy.fpdm = "";
  8520. entiy.fphm = "";
  8521. foreach (string billOrderId in billOrderList)
  8522. {
  8523. iTag++;
  8524. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8525. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8526. {
  8527. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8528. try
  8529. {
  8530. Invoicing_get_response_Obj iObj = null;
  8531. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8532. if (iObj != null)
  8533. {
  8534. entiy.state = 2;
  8535. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8536. entiy.fpdm += iObj.list[0].c_fpdm;
  8537. entiy.fphm += iObj.list[0].c_fphm;
  8538. if (iTag < billOrderList.Length)
  8539. {
  8540. entiy.fplsh += ",";
  8541. entiy.fpdm += ",";
  8542. entiy.fphm += ",";
  8543. }
  8544. entiy.Update();
  8545. }
  8546. StringBuilder sql = new StringBuilder();
  8547. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8548. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8549. returnSuccessMsg("开票成功");
  8550. }
  8551. catch (Exception ex)
  8552. {
  8553. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8554. }
  8555. return;
  8556. }
  8557. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8558. {
  8559. var res_obj = new
  8560. {
  8561. data = "开票中"
  8562. };
  8563. string ro_json = JsonConvert.SerializeObject(res_obj);
  8564. returnSuccess(ro_json);
  8565. return;
  8566. }
  8567. else
  8568. {
  8569. int eidx = res.IndexOf("c_resultmsg");
  8570. int lidx = res.IndexOf("c_status");
  8571. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8572. entiy.state = 5;
  8573. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8574. entiy.Update();
  8575. returnErrorMsg("开票失败");
  8576. return;
  8577. }
  8578. }
  8579. }
  8580. }
  8581. catch (Exception ex)
  8582. {
  8583. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8584. }
  8585. return;
  8586. }
  8587. }
  8588. public void get_erp_invoicing()
  8589. {
  8590. if (UrlPostParmsCheck("id"))
  8591. {
  8592. try
  8593. {
  8594. string id = GetPostString("id");
  8595. CeErpBill entiy = CeErpBill.Get(id);
  8596. if (entiy != null)
  8597. {
  8598. if (entiy.state == 0)
  8599. {
  8600. returnErrorMsg("发票还未开具");
  8601. return;
  8602. }
  8603. if (entiy.sendType == "纸质发票")
  8604. {
  8605. if (entiy.img.Length <= 0)
  8606. {
  8607. returnErrorMsg("查无纸质发票");
  8608. return;
  8609. }
  8610. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8611. returnSuccess(returnres);
  8612. return;
  8613. }
  8614. string[] billOrderList = entiy.billOrderId.Split(',');
  8615. int iTag = 0;
  8616. string fpUrl = "";
  8617. entiy.fplsh = "";
  8618. entiy.fpdm = "";
  8619. entiy.fphm = "";
  8620. foreach (string billOrderId in billOrderList)
  8621. {
  8622. iTag++;
  8623. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8624. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8625. {
  8626. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8627. Invoicing_get_response_Obj iObj = null;
  8628. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8629. if (iObj != null)
  8630. {
  8631. //entiy.state = 2;
  8632. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8633. entiy.fpdm += iObj.list[0].c_fpdm;
  8634. entiy.fphm += iObj.list[0].c_fphm;
  8635. if (iTag < billOrderList.Length)
  8636. {
  8637. entiy.fplsh += ",";
  8638. entiy.fpdm += ",";
  8639. entiy.fphm += ",";
  8640. }
  8641. entiy.Update();
  8642. fpUrl += iObj.list[0].c_url + ",";
  8643. }
  8644. //returnSuccess(res);
  8645. StringBuilder sql = new StringBuilder();
  8646. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8647. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8648. }
  8649. else
  8650. {
  8651. int eidx = res.IndexOf("c_resultmsg");
  8652. //int lidx = res.IndexOf("c_status");
  8653. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8654. //开票失败
  8655. entiy.state = 5;
  8656. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8657. entiy.Update();
  8658. returnErrorMsg("开票失败");
  8659. return;
  8660. }
  8661. }
  8662. var returnObj = new
  8663. {
  8664. data = fpUrl
  8665. };
  8666. string ro_json = JsonConvert.SerializeObject(returnObj);
  8667. returnSuccess(ro_json);
  8668. }
  8669. }
  8670. catch (Exception ex)
  8671. {
  8672. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8673. }
  8674. return;
  8675. }
  8676. }
  8677. public void save_erp_billimg()
  8678. {
  8679. if (UrlPostParmsCheck("id"))
  8680. {
  8681. string eid = GetPostString("id");
  8682. CeErpBill bill_entity = null;
  8683. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8684. if (bill_entity != null)
  8685. {
  8686. bill_entity.img = GetPostString("img");
  8687. bill_entity.executeTime = DateTime.Now;
  8688. bill_entity.state = 2;
  8689. bill_entity.Update();
  8690. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8691. returnSuccessMsg("保存成功");
  8692. }
  8693. return;
  8694. }
  8695. }
  8696. public void upd_erp_billreturnback()
  8697. {
  8698. if (UrlPostParmsCheck("id"))
  8699. {
  8700. int eid = GetPostInt("id");
  8701. CeErpBill bill_entity = null;
  8702. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8703. if (bill_entity != null)
  8704. {
  8705. bill_entity.state = 3;
  8706. bill_entity.returnReason = GetPostString("reason");
  8707. bill_entity.Update();
  8708. returnSuccessMsg("驳回成功!");
  8709. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8710. }
  8711. return;
  8712. }
  8713. }
  8714. public void cancel_erp_bill()
  8715. {
  8716. if (UrlPostParmsCheck("id"))
  8717. {
  8718. int eid = GetPostInt("id");
  8719. int detailValue = GetPostInt("detailvalue");
  8720. CeErpBill bill_entity = null;
  8721. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8722. string cres = "";
  8723. string gres = "";
  8724. if (bill_entity != null)
  8725. {
  8726. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8727. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8728. {
  8729. int iTag = 0;
  8730. bill_entity.fplsh = "";
  8731. bill_entity.fpdm = "";
  8732. bill_entity.fphm = "";
  8733. foreach (string billOrderId in billOrderList)
  8734. {
  8735. iTag++;
  8736. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8737. if (gres.IndexOf("success") != -1)
  8738. {
  8739. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8740. Invoicing_get_response_Obj iObj = null;
  8741. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8742. if (iObj != null)
  8743. {
  8744. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8745. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8746. bill_entity.fphm += iObj.list[0].c_fphm;
  8747. if (iTag < billOrderList.Length)
  8748. {
  8749. bill_entity.fplsh += ",";
  8750. bill_entity.fpdm += ",";
  8751. bill_entity.fphm += ",";
  8752. }
  8753. bill_entity.Update();
  8754. }
  8755. }
  8756. else
  8757. {
  8758. returnErrorMsg(gres);
  8759. return;
  8760. }
  8761. }
  8762. }
  8763. if (bill_entity.sendType == "纸质发票")
  8764. {
  8765. //作废
  8766. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8767. //if (DateTime.Now.Month == extime.Month)
  8768. //{
  8769. //cres = taobaoHelper.cancel_invoicing(eid);
  8770. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8771. //{
  8772. bill_entity.state = 4;//已作废
  8773. bill_entity.Update();
  8774. returnSuccessMsg("发票已作废");
  8775. return;
  8776. //}
  8777. //else
  8778. //{
  8779. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8780. // bill_entity.Update();
  8781. // returnErrorMsg(cres);
  8782. // return;
  8783. //}
  8784. //}
  8785. //else
  8786. //{
  8787. // returnErrorMsg("纸质发票只能作废本月的发票");
  8788. // return;
  8789. //}
  8790. }
  8791. //红冲
  8792. int redTag = 0;
  8793. string[] fpdmList = bill_entity.fpdm.Split(',');
  8794. string[] fphmList = bill_entity.fphm.Split(',');
  8795. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8796. {
  8797. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8798. return;
  8799. }
  8800. foreach (string billOrderId in billOrderList)
  8801. {
  8802. redTag++;
  8803. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8804. cres += onecres;
  8805. cres += ",";
  8806. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8807. {
  8808. bill_entity.state = 4;//已作废
  8809. //bill_entity.Update();
  8810. //returnSuccessMsg("发票已红冲");
  8811. }
  8812. else if (onecres.IndexOf("重复冲红") != -1)
  8813. {
  8814. bill_entity.state = 4;//已作废
  8815. //bill_entity.Update();
  8816. //returnSuccessMsg("发票已红冲");
  8817. }
  8818. else
  8819. {
  8820. string errmsg = commonHelper.KeepChinese(onecres);
  8821. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8822. }
  8823. }
  8824. bill_entity.Update();
  8825. if (cres.IndexOf("失败") != -1)
  8826. returnErrorMsg("红冲失败");
  8827. else
  8828. returnSuccessMsg("发票已红冲");
  8829. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8830. return;
  8831. }
  8832. return;
  8833. }
  8834. }
  8835. public void del_erp_billorder()
  8836. {
  8837. if (UrlPostParmsCheck("id"))
  8838. {
  8839. string eid = GetPostString("id");
  8840. CeErpBill.Del(eid);
  8841. CeErpBill bill = CeErpBill.Get(eid);
  8842. if (bill != null)
  8843. {
  8844. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8845. }
  8846. returnSuccessMsg("删除成功");
  8847. }
  8848. }
  8849. public void finish_erp_bill()
  8850. {
  8851. if (UrlPostParmsCheck("ids"))
  8852. {
  8853. string eids = GetPostString("ids");
  8854. string[] list = eids.Split(',');
  8855. foreach (string eid in list)
  8856. {
  8857. CeErpBill bill = CeErpBill.Get(eid);
  8858. if (bill != null)
  8859. {
  8860. bill.state = 2;
  8861. bill.Update();
  8862. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8863. }
  8864. }
  8865. returnSuccessMsg("操作成功");
  8866. }
  8867. }
  8868. public void get_erp_returncash()
  8869. {
  8870. DataStruct dStruct = GetPostStruct();
  8871. List<string> lw = new List<string>();
  8872. string tid = GetPostString("tid");
  8873. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8874. string shopname = GetPostString("shopname");
  8875. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8876. string buyernick = GetPostString("buyer_nick");
  8877. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8878. string customer = GetPostString("customer");
  8879. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8880. string returndate1 = GetPostString("returndate1");
  8881. string returndate2 = GetPostString("returndate2");
  8882. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8883. if (dw.Length > 0) lw.Add(dw);
  8884. string finishDate1 = GetPostString("finishdate1");
  8885. string finishDate2 = GetPostString("finishdate2");
  8886. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8887. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8888. string returntype = GetPostString("returntype");
  8889. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8890. string returnvstate = GetPostString("returnvstate");
  8891. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8892. dStruct.Order = "created desc";
  8893. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8894. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8895. writeGridDataTableJson(dStruct.TotalCount, dt);
  8896. }
  8897. public void get_erp_staygoods()
  8898. {
  8899. DataStruct dStruct = GetPostStruct();
  8900. List<string> lw = new List<string>();
  8901. string tid = GetPostString("tid");
  8902. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8903. string shopname = GetPostString("shopname");
  8904. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8905. string wangwang = GetPostString("wangwang");
  8906. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8907. string customer = GetPostString("customer");
  8908. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8909. string returndate1 = GetPostString("returndate1");
  8910. string returndate2 = GetPostString("returndate2");
  8911. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8912. if (dw.Length > 0) lw.Add(dw);
  8913. string finishDate1 = GetPostString("finishdate1");
  8914. string finishDate2 = GetPostString("finishdate2");
  8915. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8916. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8917. string returnvstate = GetPostString("returnvstate");
  8918. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8919. string persuadetype = GetPostString("persuadetype");
  8920. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8921. string customerOrg = GetPostString("customerOrg");
  8922. if (customerOrg.Length > 0)
  8923. {
  8924. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8925. }
  8926. string designerorg = GetPostString("designerorg");
  8927. if (designerorg.Length > 0)
  8928. {
  8929. lw.Add(string.Format("OrgID = {0}", designerorg));
  8930. }
  8931. dStruct.Order = "creata_time desc";
  8932. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8933. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8934. writeGridDataTableJson(dStruct.TotalCount, dt);
  8935. }
  8936. public void upd_erp_staygoods()
  8937. {
  8938. if (UrlPostParmsCheck("id"))
  8939. {
  8940. int eid = GetPostInt("id");
  8941. CeErpStayGoods entity = null;
  8942. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8943. if (entity != null)
  8944. {
  8945. entity.audit_type = 1;
  8946. entity.audit_time = DateTime.Now;
  8947. entity.audit_u_id = CurrentUser.UserID;
  8948. entity.audit_u_name = CurrentUser.UserName;
  8949. entity.Update();
  8950. returnSuccessMsg("审核成功!");
  8951. return;
  8952. }
  8953. returnErrorMsg("找不到订单记录");
  8954. }
  8955. }
  8956. public void upd_erp_stayGoodsback()
  8957. {
  8958. if (UrlPostParmsCheck("id"))
  8959. {
  8960. int eid = GetPostInt("id");
  8961. CeErpStayGoods entity = null;
  8962. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8963. if (entity != null)
  8964. {
  8965. entity.audit_text = GetPostString("reason");
  8966. entity.audit_type = 2;
  8967. entity.audit_time = DateTime.Now;
  8968. entity.audit_u_id = CurrentUser.UserID;
  8969. entity.audit_u_name = CurrentUser.UserName;
  8970. entity.Update();
  8971. returnSuccessMsg("退回成功!");
  8972. return;
  8973. }
  8974. returnErrorMsg("找不到订单记录");
  8975. }
  8976. }
  8977. public void upd_erp_returncashverify()
  8978. {
  8979. if (UrlPostParmsCheck("ID"))
  8980. {
  8981. int eid = GetPostInt("ID");
  8982. CeErpReturnCash entity = null;
  8983. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8984. if (entity != null)
  8985. {
  8986. entity.cashstate = 1;
  8987. entity.verifytime = DateTime.Now;
  8988. entity.verifyuserid = CurrentUser.UserID;
  8989. entity.Update();
  8990. returnSuccessMsg("审核成功!");
  8991. return;
  8992. }
  8993. returnErrorMsg("找不到订单记录");
  8994. }
  8995. }
  8996. public void upd_all_erp_returncashverify()
  8997. {
  8998. if (UrlPostParmsCheck("ID"))
  8999. {
  9000. String[] list = GetPostString("ID").Split(',');
  9001. CeErpReturnCash entity = null;
  9002. for (int i = 0; i < list.Length; i++)
  9003. {
  9004. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  9005. if (entity != null)
  9006. {
  9007. if (entity.cashstate == 1)
  9008. {
  9009. returnErrorMsg("已审核过的订单不需要在审核!");
  9010. return;
  9011. }
  9012. entity.cashstate = 1;
  9013. entity.verifytime = DateTime.Now;
  9014. entity.verifyuserid = CurrentUser.UserID;
  9015. entity.Update();
  9016. }
  9017. }
  9018. returnSuccessMsg("审核成功!");
  9019. return;
  9020. }
  9021. }
  9022. public void upd_erp_returncashback()
  9023. {
  9024. if (UrlPostParmsCheck("ID"))
  9025. {
  9026. int eid = GetPostInt("ID");
  9027. CeErpReturnCash entity = null;
  9028. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9029. if (entity != null)
  9030. {
  9031. entity.backreason = GetPostString("reason");
  9032. entity.cashstate = 2;
  9033. entity.verifytime = DateTime.Now;
  9034. entity.verifyuserid = CurrentUser.UserID;
  9035. entity.Update();
  9036. returnSuccessMsg("退回成功!");
  9037. return;
  9038. }
  9039. returnErrorMsg("找不到订单记录");
  9040. }
  9041. }
  9042. public void upd_erp_returnprice()
  9043. {
  9044. if (UrlPostParmsCheck("ID"))
  9045. {
  9046. int eid = GetPostInt("ID");
  9047. CeErpReturnCash entity = null;
  9048. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9049. if (entity != null)
  9050. {
  9051. if (entity.cashstate == 1)
  9052. {
  9053. returnErrorMsg("审核通过了不能改");
  9054. return;
  9055. }
  9056. entity.returnprice = GetPostDouble("returnprice");
  9057. entity.Update();
  9058. returnSuccessMsg("修改成功!");
  9059. return;
  9060. }
  9061. returnErrorMsg("找不到订单记录");
  9062. }
  9063. }
  9064. public void del_erp_returncash()
  9065. {
  9066. if (UrlPostParmsCheck("ID"))
  9067. {
  9068. int eid = GetPostInt("ID");
  9069. CeErpReturnCash.Del(eid);
  9070. returnSuccessMsg("操作成功");
  9071. return;
  9072. }
  9073. }
  9074. public void test_for_do_sql()
  9075. {
  9076. string sql = GetPostString("sqlstr");
  9077. if (sql.Length > 0)
  9078. {
  9079. try
  9080. {
  9081. DbHelper.DbConn.ExecuteNonQuery(sql);
  9082. var res_obj = new
  9083. {
  9084. data = "成功",
  9085. };
  9086. string ro_json = JsonConvert.SerializeObject(res_obj);
  9087. returnSuccess(ro_json);
  9088. }
  9089. catch (Exception ex)
  9090. {
  9091. var res_obj = new
  9092. {
  9093. data = ex.Message,
  9094. };
  9095. string ro_json = JsonConvert.SerializeObject(res_obj);
  9096. returnSuccess(ro_json);
  9097. }
  9098. }
  9099. }
  9100. public void get_user_info()
  9101. {
  9102. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9103. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9104. }
  9105. public void get_total_data()
  9106. {
  9107. int userId = CurrentUser.UserID;
  9108. string sql = "";
  9109. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9110. {
  9111. 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);
  9112. }
  9113. else
  9114. {
  9115. 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 " +
  9116. "(select ID from CE_ErpUser where ID = {0}) d " +
  9117. "left join " +
  9118. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9119. ") a on d.ID = a.id left join " +
  9120. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9121. ") b on a.id = b.id1 left join" +
  9122. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9123. ") c on a.id = c.id2;", userId);
  9124. }
  9125. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9126. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9127. }
  9128. public void get_date_area_total_data2()
  9129. {
  9130. int userId = CurrentUser.UserID;
  9131. string date_type = GetPostString("timetype");
  9132. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9133. string sql = "";
  9134. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9135. {
  9136. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9137. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9138. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9139. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9140. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9141. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9142. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9143. ") a on e.ID = a.id left join " +
  9144. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9145. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9146. ") b on a.id = b.id1 " +
  9147. "left join " +
  9148. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9149. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9150. ") c on a.id = c.id2 " +
  9151. "left join " +
  9152. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9153. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9154. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9155. }
  9156. else
  9157. {
  9158. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9159. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9160. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9161. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9162. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9163. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9164. ") a on e.ID = a.id left join " +
  9165. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9166. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9167. ") c on a.id = c.id2 " +
  9168. "left join " +
  9169. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9170. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9171. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9172. }
  9173. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9174. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9175. }
  9176. public void get_date_area_total_data()
  9177. {
  9178. int userId = CurrentUser.UserID;
  9179. string date_type = GetPostString("timetype");
  9180. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9181. string date1 = searchDT[0].ToString();
  9182. string date2 = searchDT[1].ToString();
  9183. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9184. {
  9185. SqlParameter[] sqlParameter ={
  9186. new SqlParameter("@userId", SqlDbType.Int,4),
  9187. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9188. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9189. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9190. };
  9191. sqlParameter[0].Value = userId;
  9192. sqlParameter[1].Value = date1;
  9193. sqlParameter[2].Value = date2;
  9194. sqlParameter[3].Direction = ParameterDirection.Output;
  9195. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9196. string res = sqlParameter[3].Value.ToString();
  9197. var res_obj = new
  9198. {
  9199. data = res
  9200. };
  9201. string ro_json = JsonConvert.SerializeObject(res_obj);
  9202. returnSuccess(ro_json);
  9203. }
  9204. else
  9205. {
  9206. SqlParameter[] sqlParameter ={
  9207. new SqlParameter("@userId", SqlDbType.Int,4),
  9208. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9209. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9210. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9211. };
  9212. sqlParameter[0].Value = userId;
  9213. sqlParameter[1].Value = date1;
  9214. sqlParameter[2].Value = date2;
  9215. sqlParameter[3].Direction = ParameterDirection.Output;
  9216. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9217. string res = sqlParameter[3].Value.ToString();
  9218. var res_obj = new
  9219. {
  9220. data = res
  9221. };
  9222. string ro_json = JsonConvert.SerializeObject(res_obj);
  9223. returnSuccess(ro_json);
  9224. }
  9225. //writeGridDataViewJson(dt.Rows.Count, dv);
  9226. }
  9227. public void get_order_list()
  9228. {
  9229. string strFields = GetPostString("paraFields");
  9230. string strOrder = GetPostString("paraOrder");
  9231. string strWhere = GetPostString("paraWhere");
  9232. string strPageSize = GetPostString("paraPageSize");
  9233. DataStruct dStruct = GetPostStruct();
  9234. dStruct.PageSize = int.Parse(strPageSize);
  9235. dStruct.Fileds = strFields;
  9236. dStruct.Order = strOrder;
  9237. dStruct.MainWhere = strWhere;
  9238. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9239. writeGridDataTableJson(dStruct.TotalCount, dt);
  9240. }
  9241. ////获取待开始订单列表
  9242. //public void get_wait_design_order_list()
  9243. //{
  9244. // string date_type = GetPostString("date_type");
  9245. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9246. // DataStruct dStruct = GetPostStruct();
  9247. // dStruct.PageSize = 1000;
  9248. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9249. // List<string> lw = new List<string>();
  9250. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9251. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9252. // dStruct.Order = "WaitDesignTime asc";
  9253. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9254. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9255. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9256. //}
  9257. //获取完成单量排名
  9258. public void get_finish_order_count_ranking()
  9259. {
  9260. /* string date_type = GetPostString("date_type");
  9261. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9262. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9263. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9264. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9265. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9266. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9267. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9268. writeGridDataTableJson(0, new DataTable());
  9269. }
  9270. public void get_finish_order_amount_ranking()
  9271. {
  9272. /*string date_type = GetPostString("date_type");
  9273. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9274. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9275. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9276. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9277. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9278. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9279. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9280. writeGridDataTableJson(0, new DataTable());
  9281. }
  9282. public void get_finish_refund_count_ranking()
  9283. {
  9284. string date_type = GetPostString("date_type");
  9285. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9286. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9287. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9288. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9289. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9290. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9291. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9292. writeGridDataTableJson(dt.Rows.Count, dt);
  9293. }
  9294. public void get_finish_refund_amount_ranking()
  9295. {
  9296. string date_type = GetPostString("date_type");
  9297. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9298. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9299. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9300. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9301. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9302. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9303. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9304. writeGridDataTableJson(dt.Rows.Count, dt);
  9305. }
  9306. public void set_erp_finishorder_director()
  9307. {
  9308. if (UrlPostParmsCheck("ctid"))
  9309. {
  9310. string eid = GetPostString("ctid");
  9311. CeErpTradeCell entity = null;
  9312. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9313. if (entity != null)
  9314. {
  9315. entity.OrderState = 8;
  9316. entity.Update();
  9317. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9318. returnSuccessMsg("操作成功!");
  9319. return;
  9320. }
  9321. returnErrorMsg("找不到记录");
  9322. }
  9323. }
  9324. public void get_erp_placeregistlist()
  9325. {
  9326. DataStruct dStruct = GetPostStruct();
  9327. List<string> lw = new List<string>();
  9328. string outsid = GetPostString("outsid");
  9329. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9330. string memo = GetPostString("memo");
  9331. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9332. string filename = GetPostString("filename");
  9333. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9334. string islate = GetPostString("islate");
  9335. if (islate.Length > 0)
  9336. {
  9337. if (islate == "1")
  9338. lw.Add(string.Format("OutLate>0"));
  9339. else
  9340. lw.Add(string.Format("OutLate=0"));
  9341. }
  9342. string placedate1 = GetPostString("placedate1");
  9343. string placedate2 = GetPostString("placedate2");
  9344. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9345. if (dw.Length > 0) lw.Add(dw);
  9346. string deliveryDate1 = GetPostString("deliverydate1");
  9347. string deliveryDate2 = GetPostString("deliverydate2");
  9348. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9349. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9350. dStruct.Order = "ID desc";
  9351. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9352. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9353. writeGridDataTableJson(dStruct.TotalCount, dt);
  9354. }
  9355. public void ins_erp_placeregist()
  9356. {
  9357. if (UrlPostParmsCheck("id"))
  9358. {
  9359. string eid = GetPostString("id");
  9360. CeErpPlaceRegister entity = null;
  9361. if (eid == "0")//新增
  9362. {
  9363. entity = new CeErpPlaceRegister();
  9364. string xdTime = GetPostString("placeTime");
  9365. if (xdTime.Length > 0)
  9366. {
  9367. entity.PlactTime = Convert.ToDateTime(xdTime);
  9368. }
  9369. string fhTime = GetPostString("deliveryTime");
  9370. if (fhTime.Length > 0)
  9371. {
  9372. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9373. }
  9374. string preTime = GetPostString("preOutTime");
  9375. if (preTime.Length > 0)
  9376. {
  9377. entity.PreOutTime = Convert.ToDateTime(preTime);
  9378. }
  9379. entity.DeliveryCount = GetPostInt("deliveryCount");
  9380. entity.ReceiveCount = GetPostInt("receiveCount");
  9381. entity.OutSid = GetPostString("outSid");
  9382. entity.FileName = GetPostString("fileName");
  9383. entity.Memo = GetPostString("memo");
  9384. entity.AddUserId = CurrentUser.UserID;
  9385. entity.CreateTime = DateTime.Now;
  9386. entity.Img = GetPostString("img");
  9387. entity.Supplier = GetPostInt("supplier");
  9388. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9389. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9390. {
  9391. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9392. DateTime dt2 = (DateTime)entity.PreOutTime;
  9393. TimeSpan span = dt1.Subtract(dt2);
  9394. if (span.Days > 0)
  9395. {
  9396. entity.OutLate = span.Days;
  9397. }
  9398. }
  9399. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9400. entity.Create();
  9401. returnSuccessMsg("添加成功!");
  9402. return;
  9403. }
  9404. else //修改
  9405. {
  9406. entity = CeErpPlaceRegister.Get(eid);
  9407. if (entity != null)
  9408. {
  9409. string xdTime = GetPostString("placeTime");
  9410. if (xdTime.Length > 0)
  9411. {
  9412. entity.PlactTime = Convert.ToDateTime(xdTime);
  9413. }
  9414. string fhTime = GetPostString("deliveryTime");
  9415. if (fhTime.Length > 0)
  9416. {
  9417. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9418. }
  9419. string preTime = GetPostString("preOutTime");
  9420. if (preTime.Length > 0)
  9421. {
  9422. entity.PreOutTime = Convert.ToDateTime(preTime);
  9423. }
  9424. entity.DeliveryCount = GetPostInt("deliveryCount");
  9425. entity.ReceiveCount = GetPostInt("receiveCount");
  9426. if (entity.DeliveryCount == entity.ReceiveCount)
  9427. {
  9428. entity.CurState = "已完成";
  9429. }
  9430. else
  9431. {
  9432. entity.CurState = "未完成";
  9433. }
  9434. entity.OutSid = GetPostString("outSid");
  9435. entity.FileName = GetPostString("fileName");
  9436. entity.Memo = GetPostString("memo");
  9437. entity.Img = GetPostString("img");
  9438. entity.Supplier = GetPostInt("supplier");
  9439. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9440. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9441. {
  9442. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9443. DateTime dt2 = (DateTime)entity.PreOutTime;
  9444. TimeSpan span = dt1.Subtract(dt2);
  9445. if (span.Days > 0)
  9446. {
  9447. entity.OutLate = span.Days;
  9448. }
  9449. }
  9450. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9451. entity.Update();
  9452. returnSuccessMsg("修改成功");
  9453. return;
  9454. }
  9455. returnErrorMsg("找不到对应的记录");
  9456. return;
  9457. }
  9458. }
  9459. returnErrorMsg("缺少必要参数");
  9460. }
  9461. public void del_erp_placeregist()
  9462. {
  9463. string eid = GetPostString("id");
  9464. CeErpPlaceRegister.Del(eid);
  9465. returnSuccessMsg("删除成功!");
  9466. return;
  9467. }
  9468. public void ins_erp_placeregistbyorder()
  9469. {
  9470. string ctid = GetPostString("ctid");
  9471. if (ctid.Length > 0)
  9472. {
  9473. StringBuilder sql = new StringBuilder();
  9474. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9475. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9476. if (dt.Rows.Count > 0)
  9477. {
  9478. foreach (DataRow dr in dt.Rows)
  9479. {
  9480. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9481. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9482. entity.AddUserId = CurrentUser.UserID;
  9483. entity.tid = dr["tid"].ToString();
  9484. entity.Did = Convert.ToString(dr["ctid"]);
  9485. entity.splitTag = dr["SplitTag"].ToString();
  9486. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9487. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9488. if (pre_ctid.Length > 0)
  9489. {
  9490. sellmemo = sellmemo.Replace(pre_ctid, "");
  9491. }
  9492. sellmemo = sellmemo.Replace("[", "");
  9493. sellmemo = sellmemo.Replace("]", "");
  9494. entity.FileName = sellmemo;
  9495. string count = dr["ProductCount"].ToString();
  9496. int usecount = commonHelper.getIntCountFromString(count);
  9497. entity.DeliveryCount = usecount;
  9498. entity.CurState = "未完成";
  9499. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9500. {
  9501. entity.Supplier = 24;//dl手提袋定制
  9502. }
  9503. else
  9504. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9505. entity.CreateTime = DateTime.Now;
  9506. entity.Create();
  9507. }
  9508. returnSuccessMsg("操作成功");
  9509. return;
  9510. }
  9511. returnErrorMsg("没有找到对应订单");
  9512. return;
  9513. }
  9514. returnErrorMsg("缺少订单编号");
  9515. return;
  9516. }
  9517. public void get_erp_persuadelist()
  9518. {
  9519. DataStruct dStruct = GetPostStruct();
  9520. List<string> lw = new List<string>();
  9521. string ctid = GetPostString("ctid");
  9522. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9523. string shopname = GetPostString("shopname");
  9524. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9525. string buyernick = GetPostString("buyer_nick");
  9526. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9527. string customer = GetPostString("customer");
  9528. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9529. string returndate1 = GetPostString("returndate1");
  9530. string returndate2 = GetPostString("returndate2");
  9531. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9532. if (dw.Length > 0) lw.Add(dw);
  9533. string finishDate1 = GetPostString("finishdate1");
  9534. string finishDate2 = GetPostString("finishdate2");
  9535. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9536. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9537. string persuadetype = GetPostString("persuadetype");
  9538. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9539. string returnvstate = GetPostString("returnvstate");
  9540. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9541. dStruct.Order = "created desc";
  9542. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9543. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9544. writeGridDataTableJson(dStruct.TotalCount, dt);
  9545. }
  9546. public void upd_erp_returnpersuadeback()
  9547. {
  9548. if (UrlPostParmsCheck("ID"))
  9549. {
  9550. int eid = GetPostInt("ID");
  9551. CeErpPersuade entity = null;
  9552. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9553. if (entity != null)
  9554. {
  9555. entity.backreason = GetPostString("reason");
  9556. entity.pstate = 2;
  9557. entity.verifytime = DateTime.Now;
  9558. entity.verifyuserid = CurrentUser.UserID;
  9559. entity.Update();
  9560. returnSuccessMsg("退回成功!");
  9561. return;
  9562. }
  9563. returnErrorMsg("找不到订单记录");
  9564. }
  9565. }
  9566. public void upd_erp_returnpersuadeverify()
  9567. {
  9568. if (UrlPostParmsCheck("ID"))
  9569. {
  9570. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9571. {
  9572. returnErrorMsg("暂无权限审核");
  9573. return;
  9574. }
  9575. int eid = GetPostInt("ID");
  9576. CeErpPersuade entity = null;
  9577. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9578. if (entity != null)
  9579. {
  9580. entity.pstate = 1;
  9581. entity.verifytime = DateTime.Now;
  9582. entity.verifyuserid = CurrentUser.UserID;
  9583. entity.Update();
  9584. returnSuccessMsg("审核成功!");
  9585. return;
  9586. }
  9587. returnErrorMsg("找不到订单记录");
  9588. }
  9589. }
  9590. public void del_erp_persuade()
  9591. {
  9592. if (UrlPostParmsCheck("ID"))
  9593. {
  9594. int eid = GetPostInt("ID");
  9595. CeErpPersuade.Del(eid);
  9596. returnSuccessMsg("操作成功");
  9597. return;
  9598. }
  9599. }
  9600. public void get_erp_oldcustoupload()
  9601. {
  9602. DataStruct dStruct = GetPostStruct();
  9603. List<string> lw = new List<string>();
  9604. string buyernick = GetPostString("buyer_nick");
  9605. if (buyernick.Length > 0)
  9606. {
  9607. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9608. }
  9609. else
  9610. return;
  9611. dStruct.Order = "pay_time desc";
  9612. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9613. DataTable dt = null;
  9614. dt = WebCache.GetData("view_erptradecell", dStruct);
  9615. writeGridDataTableJson(dStruct.TotalCount, dt);
  9616. }
  9617. public void get_erp_checkorderlist()
  9618. {
  9619. DataStruct dStruct = GetPostStruct();
  9620. List<string> lw = new List<string>();
  9621. string tid = GetPostString("ctid");
  9622. if (tid.Length > 0)
  9623. {
  9624. string select_tid = getTidByCtid(tid);
  9625. lw.Add(string.Format("tid='{0}'", select_tid));
  9626. }
  9627. string shopname = GetPostString("shopname");
  9628. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9629. string buyernick = GetPostString("buyer_nick");
  9630. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9631. string customer = GetPostString("customer");
  9632. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9633. string design = GetPostString("design");
  9634. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9635. string orderState = GetPostString("orderState");
  9636. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9637. string address = GetPostString("address");
  9638. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9639. string sellermemo = GetPostString("seller_memo");
  9640. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9641. string supplier = GetPostString("supplier");
  9642. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9643. {
  9644. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9645. }
  9646. else
  9647. {
  9648. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9649. }
  9650. string date1 = GetPostString("date1");
  9651. string date2 = GetPostString("date2");
  9652. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9653. if (dw.Length > 0) lw.Add(dw);
  9654. string placedate1 = GetPostString("placedate1");
  9655. string placedate2 = GetPostString("placedate2");
  9656. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9657. if (fdw.Length > 0) lw.Add(fdw);
  9658. string price1 = GetPostString("price1");
  9659. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9660. string price2 = GetPostString("price2");
  9661. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9662. string checkst = GetPostString("checkstate");
  9663. if (checkst.Length > 0 && "10".Equals(checkst))
  9664. {
  9665. lw.Add(string.Format("CheckOut>0"));
  9666. }
  9667. else
  9668. {
  9669. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9670. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9671. }
  9672. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9673. {
  9674. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9675. }
  9676. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9677. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9678. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9679. writeGridDataTableJson(dStruct.TotalCount, dt);
  9680. }
  9681. public void ins_erp_startCheck()
  9682. {
  9683. if (UrlPostParmsCheck("ctid"))
  9684. {
  9685. string eid = GetPostString("ctid");
  9686. CeErpTradeCell entity = null;
  9687. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9688. if (entity != null)
  9689. {
  9690. entity.MemoOpt = 4;
  9691. entity.UpdateTime = DateTime.Now;
  9692. entity.Update();
  9693. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9694. CeErpSukuraData.createInfo(entity.ctid, 6);
  9695. returnSuccessMsg("操作成功!");
  9696. return;
  9697. }
  9698. returnErrorMsg("找不到记录");
  9699. }
  9700. }
  9701. public void upd_erp_sendXlw()
  9702. {
  9703. if (UrlPostParmsCheck("ctid"))
  9704. {
  9705. string eid = GetPostString("ctid");
  9706. CeErpTradeCell entity = null;
  9707. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9708. if (entity != null)
  9709. {
  9710. if (entity.IsSendGift == 1)
  9711. {
  9712. returnErrorMsg("请勿重复标记");
  9713. return;
  9714. }
  9715. entity.IsSendGift = 1;
  9716. entity.Update();
  9717. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9718. returnSuccessMsg("操作成功!");
  9719. return;
  9720. }
  9721. returnErrorMsg("找不到记录");
  9722. }
  9723. }
  9724. public void cancel_sendXlw()
  9725. {
  9726. if (UrlPostParmsCheck("ctid"))
  9727. {
  9728. string eid = GetPostString("ctid");
  9729. CeErpTradeCell entity = null;
  9730. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9731. if (entity != null)
  9732. {
  9733. if (entity.IsSendGift == 0)
  9734. {
  9735. returnErrorMsg("未标记小礼物");
  9736. return;
  9737. }
  9738. entity.IsSendGift = 0;
  9739. entity.Update();
  9740. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9741. returnSuccessMsg("操作成功!");
  9742. return;
  9743. }
  9744. returnErrorMsg("找不到记录");
  9745. }
  9746. }
  9747. public void get_erp_designbill()
  9748. {
  9749. DataStruct dStruct = GetPostStruct();
  9750. List<string> lw = new List<string>();
  9751. int isMy = GetInt("my");
  9752. if (isMy == 1)
  9753. {
  9754. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9755. }
  9756. string tid = GetPostString("tid");
  9757. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9758. string userName = GetPostString("design");
  9759. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9760. string price1 = GetPostString("price1");
  9761. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9762. string price2 = GetPostString("price2");
  9763. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9764. string rePrice1 = GetPostString("rePrice1");
  9765. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9766. string rePrice2 = GetPostString("rePrice2");
  9767. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9768. string designerType = GetPostString("designerType");
  9769. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9770. string orderState = GetPostString("orderState");
  9771. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9772. string endTime1 = GetPostString("endTime1");
  9773. string endTime2 = GetPostString("endTime2");
  9774. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9775. if (dw.Length > 0) lw.Add(dw);
  9776. string isDk = GetPostString("isDk");
  9777. if (isDk == "1")
  9778. {
  9779. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9780. }
  9781. else if (isDk == "0")
  9782. {
  9783. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9784. }
  9785. dStruct.Order = "oid, create_time desc";
  9786. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9787. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9788. writeGridDataTableJson(dStruct.TotalCount, dt);
  9789. }
  9790. public void upd_erp_designerbill()
  9791. {
  9792. if (UrlPostParmsCheck("ID"))
  9793. {
  9794. string eid = GetPostString("ID");
  9795. CeErpDesignerBill entity = null;
  9796. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9797. if (entity != null)
  9798. {
  9799. if (GetPostDouble("designerpirce") > 0)
  9800. {
  9801. entity.realPrice = GetPostDouble("designerpirce");
  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. else
  9811. {
  9812. entity.price = GetPostDouble("price");
  9813. entity.update_time = DateTime.Now;
  9814. entity.update_u_id = CurrentUser.UserID;
  9815. entity.update_u_name = CurrentUser.UserName;
  9816. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9817. entity.Update();
  9818. returnSuccessMsg("操作成功!");
  9819. return;
  9820. }
  9821. }
  9822. returnErrorMsg("找不到记录");
  9823. }
  9824. }
  9825. public void audit_erp_designerbill()
  9826. {
  9827. if (UrlPostParmsCheck("ID"))
  9828. {
  9829. string eid = GetPostString("ID");
  9830. CeErpDesignerBill entity = null;
  9831. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9832. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9833. if (entity != null)
  9834. {
  9835. entity.realPrice = GetPostDouble("designerpirce");
  9836. entity.update_time = DateTime.Now;
  9837. entity.update_u_id = CurrentUser.UserID;
  9838. entity.update_u_name = CurrentUser.UserName;
  9839. entity.isAudit = 1;
  9840. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9841. entity.Update();
  9842. if (orderEntity != null)
  9843. {
  9844. orderEntity.IsReadTag = 3;
  9845. orderEntity.Update();
  9846. }
  9847. returnSuccessMsg("操作成功!");
  9848. return;
  9849. }
  9850. returnErrorMsg("找不到记录");
  9851. }
  9852. }
  9853. public void all_audit_erp_designerbill()
  9854. {
  9855. if (UrlPostParmsCheck("idList"))
  9856. {
  9857. string[] list = GetPostString("idList").Split(',');
  9858. CeErpDesignerBill entity = null;
  9859. for (int i = 0; i < list.Length; i++)
  9860. {
  9861. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9862. if (entity == null) return;
  9863. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9864. if (orderEntity == null) return;
  9865. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9866. entity.update_time = DateTime.Now;
  9867. entity.update_u_id = CurrentUser.UserID;
  9868. entity.update_u_name = CurrentUser.UserName;
  9869. entity.isAudit = 1;
  9870. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9871. entity.Update();
  9872. orderEntity.IsReadTag = 3;
  9873. orderEntity.Update();
  9874. }
  9875. returnSuccessMsg("操作成功!");
  9876. return;
  9877. }
  9878. }
  9879. public void get_erp_sameorders()
  9880. {
  9881. if (UrlPostParmsCheck("ctid"))
  9882. {
  9883. string eid = GetPostString("ctid");
  9884. CeErpTradeCell entity = null;
  9885. entity = CeErpTradeCell.GetByCtid(eid);
  9886. if (entity != null)
  9887. {
  9888. StringBuilder sql = new StringBuilder();
  9889. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9890. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9891. var res = new
  9892. {
  9893. data = dt.Rows.Count
  9894. };
  9895. string ro_jsond = JsonConvert.SerializeObject(res);
  9896. returnSuccess(ro_jsond);
  9897. return;
  9898. }
  9899. returnErrorMsg("未找到订单");
  9900. return;
  9901. }
  9902. returnErrorMsg("缺少必要的参数");
  9903. }
  9904. public void get_erp_islasthavesameorder()
  9905. {
  9906. if (UrlPostParmsCheck("ctid"))
  9907. {
  9908. string eid = GetPostString("ctid");
  9909. string[] ctidList = eid.Split(',');
  9910. StringBuilder sql = new StringBuilder();
  9911. string tisCtid = "";
  9912. foreach (string ctid in ctidList)
  9913. {
  9914. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9915. if (entity != null)
  9916. {
  9917. sql = new StringBuilder();
  9918. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9919. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9920. if (dth.Rows.Count > 0)
  9921. {
  9922. tisCtid += entity.ctid;
  9923. tisCtid += ",";
  9924. }
  9925. }
  9926. }
  9927. if (tisCtid.Length > 0)
  9928. {
  9929. var res = new
  9930. {
  9931. data = tisCtid
  9932. };
  9933. string ro_jsond = JsonConvert.SerializeObject(res);
  9934. returnSuccess(ro_jsond);
  9935. }
  9936. else
  9937. {
  9938. var res = new
  9939. {
  9940. data = ""
  9941. };
  9942. string ro_jsond = JsonConvert.SerializeObject(res);
  9943. returnSuccess(ro_jsond);
  9944. }
  9945. return;
  9946. }
  9947. returnErrorMsg("缺少必要的参数");
  9948. }
  9949. public void file_client_down_url()
  9950. {
  9951. if (!UrlPostParmsCheck("userId"))
  9952. {
  9953. returnErrorMsg("缺少必要的参数");
  9954. }
  9955. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9956. }
  9957. public void checkout_form_data()
  9958. {
  9959. if (!UrlPostParmsCheck("tid"))
  9960. {
  9961. returnErrorMsg("缺少必要的参数");
  9962. }
  9963. string tid = GetPostString("tid");
  9964. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9965. if (ceErpOrderFormData != null)
  9966. {
  9967. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9968. returnSuccess(ro_jsond);
  9969. return;
  9970. }
  9971. returnErrorMsg("尚未有文件!");
  9972. }
  9973. public void back_supplier_audit()
  9974. {
  9975. int userId = CurrentUser.UserID;
  9976. StringBuilder sql = new StringBuilder();
  9977. 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);
  9978. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9979. if (dt.Rows.Count > 0)
  9980. {
  9981. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9982. }
  9983. else
  9984. {
  9985. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9986. }
  9987. }
  9988. public void back_supplier_query()
  9989. {
  9990. string eid = GetPostString("ctid");
  9991. if (eid != "")
  9992. {
  9993. StringBuilder sql = new StringBuilder();
  9994. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9995. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9996. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9997. }
  9998. else
  9999. {
  10000. returnErrorMsg("找不到订单记录");
  10001. return;
  10002. }
  10003. }
  10004. public void verified_to_order()
  10005. {
  10006. int userId = CurrentUser.UserID;
  10007. StringBuilder sql = new StringBuilder();
  10008. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  10009. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10010. if (dt.Rows.Count > 0)
  10011. {
  10012. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10013. }
  10014. else
  10015. {
  10016. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10017. }
  10018. }
  10019. public void upd_supplier_audit()
  10020. {
  10021. if (UrlPostParmsCheck("ctid"))
  10022. {
  10023. string eid = GetPostString("ctid");
  10024. string reason = GetPostString("returnreason");
  10025. CeErpTradeCell entity = null;
  10026. CeWithdraw withdraw = null;
  10027. withdraw = CeWithdraw.GetByTid(eid);
  10028. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  10029. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  10030. {
  10031. if (withdraw != null)
  10032. {
  10033. if (!withdraw.userid.Equals(CurrentUser.UserID))
  10034. {
  10035. returnSuccessMsg("您没有权限操作!");
  10036. return;
  10037. }
  10038. else
  10039. {
  10040. if (reason.Equals("1"))
  10041. {
  10042. if (entity.OrderState == -1)
  10043. {
  10044. if (entity.FinishPlaceTime == null)
  10045. {
  10046. entity.OrderState = 2;
  10047. }
  10048. else
  10049. {
  10050. entity.OrderState = 6;
  10051. }
  10052. }
  10053. entity.Update();
  10054. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10055. if (withdraw != null)
  10056. {
  10057. withdraw.status = int.Parse(reason);
  10058. withdraw.Update();
  10059. }
  10060. returnSuccessMsg("操作成功!");
  10061. return;
  10062. }
  10063. else
  10064. {
  10065. withdraw.status = int.Parse(reason);
  10066. withdraw.acknowledgingtime = DateTime.Now;
  10067. withdraw.Update();
  10068. returnSuccessMsg("查看详细请点击线下订单查询");
  10069. return;
  10070. }
  10071. }
  10072. }
  10073. // 第一个字符是 'N'
  10074. }
  10075. if (eid[0] != 'N')
  10076. {
  10077. }
  10078. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10079. {
  10080. entity.IsVerifyToSupplier = false;
  10081. entity.IsReturn = 1;
  10082. entity.ReturnTime = DateTime.Now;
  10083. entity.ReturnReason = reason;
  10084. if (entity.OrderState == 6)
  10085. {
  10086. entity.OrderState = 5;
  10087. }
  10088. entity.Update();
  10089. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10090. if (withdraw != null)
  10091. {
  10092. withdraw.status = int.Parse(reason);
  10093. withdraw.Update();
  10094. }
  10095. returnSuccessMsg("操作成功!");
  10096. return;
  10097. }
  10098. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10099. {
  10100. ;
  10101. if (withdraw != null)
  10102. {
  10103. withdraw.status = int.Parse(reason);
  10104. withdraw.acknowledgingtime = DateTime.Now;
  10105. withdraw.Update();
  10106. returnSuccessMsg("供应商取消撤回!");
  10107. return;
  10108. }
  10109. }
  10110. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10111. {
  10112. if (entity.OrderState == -1)
  10113. {
  10114. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10115. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10116. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10117. {
  10118. returnErrorMsg("台湾客户需填写身份证!");
  10119. return;
  10120. }
  10121. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10122. {
  10123. returnErrorMsg("偏远地区需要填写物流费!");
  10124. return;
  10125. }
  10126. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10127. {
  10128. returnErrorMsg("订单spu没有确认无法通过审核!");
  10129. return;
  10130. }
  10131. if (entity.FinishPlaceTime == null)
  10132. {
  10133. entity.OrderState = 2;
  10134. }
  10135. else
  10136. {
  10137. entity.OrderState = 3;
  10138. }
  10139. commonHelper.getCytPrice(entity);
  10140. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10141. {
  10142. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10143. }
  10144. if (entity.IsSample > 1 || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物"))
  10145. {
  10146. entity.OrderState = 6;
  10147. }
  10148. }
  10149. entity.Update();
  10150. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10151. if (withdraw != null)
  10152. {
  10153. withdraw.status = int.Parse(reason);
  10154. withdraw.Update();
  10155. }
  10156. returnSuccessMsg("操作成功!");
  10157. return;
  10158. }
  10159. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10160. {
  10161. if (withdraw == null)
  10162. {
  10163. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10164. return;
  10165. }
  10166. }
  10167. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10168. {
  10169. if (withdraw != null)
  10170. {
  10171. withdraw.status = int.Parse(reason);
  10172. withdraw.acknowledgingtime = DateTime.Now;
  10173. withdraw.Update();
  10174. returnSuccessMsg("查看详细请点击线下订单查询");
  10175. return;
  10176. }
  10177. }
  10178. return;
  10179. }
  10180. }
  10181. //校验报价
  10182. public void refund_order_tip()
  10183. {
  10184. int userid = CurrentUser.UserID;
  10185. int sectionId = CurrentUser.UserPost.OrgID;
  10186. StringBuilder sql = new StringBuilder();
  10187. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10188. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10189. List<string> ids = new List<string>();
  10190. if (dth.Rows.Count > 0)
  10191. {
  10192. foreach (DataRow dr in dth.Rows)
  10193. {
  10194. ids.Add(dr["ID"].ToString());
  10195. }
  10196. try
  10197. {
  10198. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10199. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10200. }
  10201. catch (Exception ex)
  10202. {
  10203. }
  10204. }
  10205. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10206. }
  10207. public void refund_order_Design()
  10208. {
  10209. int userid = CurrentUser.UserID;
  10210. int sectionId = CurrentUser.UserPost.OrgID;
  10211. StringBuilder sql = new StringBuilder();
  10212. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10213. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10214. List<string> ids = new List<string>();
  10215. if (dth.Rows.Count > 0)
  10216. {
  10217. foreach (DataRow dr in dth.Rows)
  10218. {
  10219. ids.Add(dr["ID"].ToString());
  10220. }
  10221. try
  10222. {
  10223. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10224. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10225. }
  10226. catch (Exception ex)
  10227. {
  10228. }
  10229. }
  10230. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10231. }
  10232. public void change_order_info()
  10233. {
  10234. int userid = CurrentUser.UserID;
  10235. StringBuilder sql = new StringBuilder();
  10236. 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);
  10237. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10238. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10239. }
  10240. public void change_win_mome()
  10241. {
  10242. if (UrlPostParmsCheck("id,ctid"))
  10243. {
  10244. string id = GetPostString("id");
  10245. string ctid = GetPostString("ctid");
  10246. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10247. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10248. if (ce == null || ceErpMessageTip == null)
  10249. {
  10250. returnSuccessMsg("未找到对应的订单!");
  10251. return;
  10252. }
  10253. if (ce.OrderState >= 5)
  10254. {
  10255. ceErpMessageTip.isVisit = true;
  10256. ceErpMessageTip.Update();
  10257. returnSuccessMsg("已上传文件无法修改!");
  10258. return;
  10259. }
  10260. int type = GetPostInt("type");
  10261. string content = GetPostString("content");
  10262. if (type == 0)
  10263. {
  10264. content = content.Replace("(", "(");
  10265. content = content.Replace(")", ")");
  10266. string check = MidStrEx(content, "(", ")").Trim();
  10267. if (string.IsNullOrEmpty(check))
  10268. {
  10269. returnSuccessMsg("文件名格式不正确");
  10270. return;
  10271. }
  10272. }
  10273. ce.seller_memo = content;
  10274. ce.Update();
  10275. ceErpMessageTip.isVisit = true;
  10276. ceErpMessageTip.Update();
  10277. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10278. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10279. ApiVo apiVo = new ApiVo();
  10280. apiVo.orderNumber = ce.ctid;
  10281. apiVo.actionName = "demandDesign";
  10282. apiVo.orderRemarks = content;
  10283. apiVo.demandExamine = type + 1;
  10284. designHelper.API_WorkCore(apiVo);//demandDesign
  10285. returnSuccessMsg("修改成功!");
  10286. }
  10287. }
  10288. public static string MidStrEx(string sourse, string startstr, string endstr)
  10289. {
  10290. string result = string.Empty;
  10291. int startindex, endindex;
  10292. try
  10293. {
  10294. startindex = sourse.IndexOf(startstr);
  10295. if (startindex == -1)
  10296. return result;
  10297. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10298. endindex = tmpstr.IndexOf(endstr);
  10299. if (endindex == -1)
  10300. return result;
  10301. result = tmpstr.Remove(endindex);
  10302. }
  10303. catch (Exception ex)
  10304. {
  10305. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10306. }
  10307. return result;
  10308. }
  10309. public void refund_order_list()
  10310. {
  10311. int userid = CurrentUser.UserID;
  10312. int sectionId = CurrentUser.UserPost.OrgID;
  10313. StringBuilder sql = new StringBuilder();
  10314. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10315. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10316. DataStruct dStruct = GetPostStruct();
  10317. DataTable dt = null;
  10318. List<string> ids = new List<string>();
  10319. List<string> tids = new List<string>();
  10320. if (dth.Rows.Count > 0)
  10321. {
  10322. foreach (DataRow dr in dth.Rows)
  10323. {
  10324. tids.Add("'" + dr["tid"].ToString() + "'");
  10325. ids.Add(dr["id"].ToString());
  10326. }
  10327. try
  10328. {
  10329. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10330. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10331. List<string> lw = new List<string>();
  10332. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10333. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10334. dt = WebCache.GetData("view_orderlist", dStruct);
  10335. }
  10336. catch (Exception ex)
  10337. {
  10338. }
  10339. }
  10340. writeGridDataTableJson(dStruct.TotalCount, dt);
  10341. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10342. }
  10343. //新增
  10344. public void order_batch_downloads()
  10345. {
  10346. string ceid = GetPostString("tid");
  10347. String[] tid = ceid.Split(',');
  10348. order_batch_caiyingtong(tid);
  10349. /* (string success, string errors) = UploadFiles(tid);
  10350. returnSuccessMsg(success + errors);*/
  10351. return;
  10352. }
  10353. //报价接口
  10354. public void Get_To_Quote()
  10355. {
  10356. string ceid = GetPostString("ctid");
  10357. if (ceid != null)
  10358. {
  10359. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10360. if (entity != null)
  10361. {
  10362. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10363. {
  10364. return;
  10365. }
  10366. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10367. double price = 0;
  10368. if (cp == null)
  10369. {
  10370. JObject jsonObject12 = new JObject
  10371. {
  10372. { "UserId", "77886" },
  10373. { "Pwd", "lt666888" },
  10374. { "Filename", entity.seller_memo }
  10375. };
  10376. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10377. JObject jsonObjects1 = JObject.Parse(response1);
  10378. string ms1g = (string)jsonObjects1["msg"];
  10379. if (ms1g == "报价成功")
  10380. {
  10381. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10382. string data = (string)jsonObject1["price"];
  10383. 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 + "');";
  10384. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10385. returnSuccessMsg("获取报价成功:" + data);
  10386. price = Convert.ToDouble(data);
  10387. }
  10388. else
  10389. {
  10390. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10391. return;
  10392. }
  10393. }
  10394. String[] beizhu = entity.seller_memo.Split('-');
  10395. String chanp = "";
  10396. if (beizhu.Length > 0)
  10397. {
  10398. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10399. }
  10400. else
  10401. {
  10402. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10403. }
  10404. JObject jsonObject = new JObject
  10405. {
  10406. { "UserId", "77886" },
  10407. { "Pwd", "lt666888" },
  10408. { "Filename", chanp }
  10409. };
  10410. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10411. JObject jsonObjects = JObject.Parse(response);
  10412. string msg = (string)jsonObjects["msg"];
  10413. if (msg == "报价成功")
  10414. {
  10415. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10416. string data = (string)jsonObject1["price"];
  10417. 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 + "');";
  10418. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10419. returnSuccessMsg("获取报价成功:" + data);
  10420. price = Convert.ToDouble(data);
  10421. }
  10422. else
  10423. {
  10424. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10425. return;
  10426. }
  10427. if (price > 0)
  10428. {
  10429. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10430. if (ceErpTradeCellExtend == null)
  10431. {
  10432. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10433. ceErpTradeCellExtend.ctid = entity.ctid;
  10434. ceErpTradeCellExtend.payment_cyt = price;
  10435. ceErpTradeCellExtend.Create();
  10436. }
  10437. else
  10438. {
  10439. ceErpTradeCellExtend.payment_cyt = price;
  10440. ceErpTradeCellExtend.Update();
  10441. }
  10442. }
  10443. return;
  10444. }
  10445. }
  10446. else
  10447. {
  10448. returnErrorMsg("请至少选择一条数据");
  10449. return;
  10450. }
  10451. }
  10452. //新增
  10453. public void order_To_Supplier()
  10454. {
  10455. string ceid = GetPostString("tid");
  10456. String[] tid = ceid.Split(',');
  10457. if (tid.Length > 0)
  10458. {
  10459. try
  10460. {
  10461. for (int i = 0; i < tid.Length; i++)
  10462. {
  10463. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10464. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10465. entity.SupplierId = suid;
  10466. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10467. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10468. entity.Update();
  10469. }
  10470. }
  10471. catch (Exception ex)
  10472. {
  10473. returnErrorMsg("自动匹配供应商失败");
  10474. return;
  10475. }
  10476. }
  10477. else
  10478. {
  10479. returnErrorMsg("请至少选择一条数据");
  10480. return;
  10481. }
  10482. returnSuccessMsg("自动匹配供应商成功");
  10483. return;
  10484. }
  10485. public (string, string) UploadFiles(string[] urls)
  10486. {
  10487. string success = "";
  10488. string errors = "";
  10489. int userid = CurrentUser.UserID;
  10490. foreach (string url in urls)
  10491. {
  10492. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10493. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10494. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10495. {
  10496. JObject jsonObject = new JObject
  10497. {
  10498. { "Userid", "77886" },
  10499. { "pwd", "cyt86435015" },
  10500. { "content", base64FileContent },
  10501. { "ext", Path.GetExtension(fileName) }
  10502. };
  10503. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10504. JObject jsonObjects = JObject.Parse(response);
  10505. string msg = (string)jsonObjects["msg"];
  10506. if (msg.Equals("上传成功"))
  10507. {
  10508. success += url + " 上传成功";
  10509. }
  10510. else
  10511. {
  10512. errors += url + " 上传失败";
  10513. }
  10514. }
  10515. else
  10516. {
  10517. errors += url + " 格式出现问题";
  10518. }
  10519. }
  10520. if (urls.Length == 0)
  10521. {
  10522. return (success, errors);
  10523. }
  10524. return (success, errors);
  10525. }
  10526. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10527. {
  10528. return true; //总是接受
  10529. }
  10530. public static string HttpPost(string url, string param = null)
  10531. {
  10532. HttpWebRequest request;
  10533. //如果是发送HTTPS请求
  10534. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10535. {
  10536. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10537. request = WebRequest.Create(url) as HttpWebRequest;
  10538. request.ProtocolVersion = HttpVersion.Version10;
  10539. }
  10540. else
  10541. {
  10542. request = WebRequest.Create(url) as HttpWebRequest;
  10543. }
  10544. request.Method = "POST";
  10545. request.ContentType = "application/json";
  10546. request.Accept = "*/*";
  10547. request.Timeout = 120000;
  10548. request.AllowAutoRedirect = false;
  10549. StreamWriter requestStream = null;
  10550. WebResponse response = null;
  10551. string responseStr = null;
  10552. try
  10553. {
  10554. requestStream = new StreamWriter(request.GetRequestStream());
  10555. requestStream.Write(param);
  10556. requestStream.Close();
  10557. response = request.GetResponse();
  10558. if (response != null)
  10559. {
  10560. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10561. responseStr = reader.ReadToEnd();
  10562. reader.Close();
  10563. }
  10564. }
  10565. catch (Exception ex)
  10566. {
  10567. return ex.Message;
  10568. }
  10569. finally
  10570. {
  10571. request = null;
  10572. requestStream = null;
  10573. response = null;
  10574. }
  10575. return responseStr;
  10576. }
  10577. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10578. {
  10579. string base64FileContent;
  10580. string fileName;
  10581. using (WebClient webClient = new WebClient())
  10582. {
  10583. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10584. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10585. {
  10586. using (Stream stream = response.GetResponseStream())
  10587. {
  10588. using (MemoryStream memoryStream = new MemoryStream())
  10589. {
  10590. stream.CopyTo(memoryStream);
  10591. byte[] fileBytes = memoryStream.ToArray();
  10592. base64FileContent = Convert.ToBase64String(fileBytes);
  10593. fileName = response.Headers["Content-Disposition"];
  10594. if (!string.IsNullOrEmpty(fileName))
  10595. {
  10596. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10597. if (index >= 0)
  10598. {
  10599. fileName = fileName.Substring(index + 9).Trim('\"');
  10600. }
  10601. }
  10602. else
  10603. {
  10604. fileName = Path.GetFileName(downloadUrl);
  10605. }
  10606. }
  10607. }
  10608. }
  10609. }
  10610. return (fileName, base64FileContent);
  10611. }
  10612. //新增
  10613. public void order_batch_caiyingtong(string[] downloadUrls)
  10614. {
  10615. try
  10616. {
  10617. //遍历文件
  10618. DataStruct dStruct = GetPostStruct();
  10619. DataTable dt = null;
  10620. int userid = CurrentUser.UserID;
  10621. List<string> ids = new List<string>();//失败组
  10622. List<string> tids = new List<string>();
  10623. using (WebClient webClient = new WebClient())
  10624. {
  10625. foreach (var url in downloadUrls)
  10626. {
  10627. try
  10628. {
  10629. tids.Add("'" + url + "'");
  10630. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10631. if (entity != null)
  10632. {
  10633. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10634. if (cp == null)
  10635. {
  10636. JObject jsonObject = new JObject
  10637. {
  10638. { "Userid", "77886" },
  10639. { "pwd", "lt666888" },
  10640. { "Filename",entity.seller_memo }
  10641. };
  10642. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10643. JObject jsonObjects = JObject.Parse(response);
  10644. string msg = (string)jsonObjects["msg"];
  10645. if (msg == "报价成功")
  10646. {
  10647. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10648. DownloadAndConvertToBase64(url1);
  10649. }
  10650. else
  10651. {
  10652. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10653. }
  10654. }
  10655. else
  10656. {
  10657. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10658. JObject jsonObject = new JObject
  10659. {
  10660. { "Userid", "77886" },
  10661. { "pwd", "lt666888" },
  10662. { "Filename",chanp }
  10663. };
  10664. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10665. JObject jsonObjects = JObject.Parse(response);
  10666. string msg = (string)jsonObjects["msg"];
  10667. if (msg == "报价成功")
  10668. {
  10669. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10670. DownloadAndConvertToBase64(url1);
  10671. }
  10672. else
  10673. {
  10674. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10675. }
  10676. }
  10677. }
  10678. // 上传文件到FTP
  10679. }
  10680. catch (Exception ex)
  10681. {
  10682. Console.WriteLine($"An error occurred: {ex.Message}");
  10683. }
  10684. }
  10685. List<string> lw = new List<string>();
  10686. lw.Add(string.Format("( OrderState < 6 )"));
  10687. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10688. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10689. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10690. if (dt.Rows.Count > 0)
  10691. {
  10692. foreach (DataRow dr in dt.Rows)
  10693. {
  10694. ids.Add(dr["ctid"].ToString());
  10695. }
  10696. }
  10697. String ErrorMsgs = "";
  10698. foreach (String id in ids)
  10699. {
  10700. ErrorMsgs += id + ",";
  10701. }
  10702. if (ErrorMsgs.Length > 1)
  10703. {
  10704. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10705. }
  10706. if (ErrorMsgs.Length < 1)
  10707. {
  10708. ErrorMsgs = "上传成功";
  10709. returnSuccessMsg(ErrorMsgs);
  10710. }
  10711. else
  10712. {
  10713. returnErrorMsg("以下订单" + ErrorMsgs);
  10714. }
  10715. }
  10716. // 删除文件夹及其内容
  10717. /* Directory.Delete(localDirectory, true);*/
  10718. }
  10719. catch { }
  10720. }
  10721. public void get_center_data()
  10722. {
  10723. int userId = CurrentUser.UserID;
  10724. string postCode = CurrentUser.UserPost.Post.Code;
  10725. List<string> lw = new List<string>();
  10726. List<string> ww = new List<string>();
  10727. DateTime currentTime = DateTime.Now;
  10728. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10729. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10730. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10731. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10732. string sql = " SELECT ";
  10733. string startTime = "2023-10-01 11:22:31";
  10734. //设计
  10735. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10736. {
  10737. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10738. 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));
  10739. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10740. 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));
  10741. }
  10742. //客服
  10743. else if (postCode == "CustomerService" || postCode == "Director")
  10744. {
  10745. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10746. 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));
  10747. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10748. 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));
  10749. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10750. 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));
  10751. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10752. 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));
  10753. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10754. 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));
  10755. }
  10756. //售后
  10757. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10758. {
  10759. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10760. 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));
  10761. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10762. 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));
  10763. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10764. 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));
  10765. }
  10766. //下单部
  10767. else if (postCode == "Place" || postCode == "PlaceMr")
  10768. {
  10769. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10770. 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));
  10771. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10772. 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));
  10773. }
  10774. //车间
  10775. else if (postCode == "Supplier")
  10776. {
  10777. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10778. 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));
  10779. }
  10780. DataTable dt = new DataTable();
  10781. if (lw.Count > 0)
  10782. {
  10783. sql += string.Join(" , ", lw);
  10784. sql += " FROM ";
  10785. sql += string.Join(" , ", ww);
  10786. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10787. }
  10788. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10789. }
  10790. public void get_center_data_list()
  10791. {
  10792. int userId = CurrentUser.UserID;
  10793. string postCode = CurrentUser.UserPost.Post.Code;
  10794. string shopIds = CurrentUser.User.pemShop;
  10795. DataStruct dStruct = GetPostStruct();
  10796. List<string> lw = new List<string>();
  10797. DateTime currentTime = DateTime.Now;
  10798. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10799. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10800. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10801. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10802. string startTime = "2023-10-01 11:22:31";
  10803. int order_type = GetPostInt("order_type");
  10804. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10805. {
  10806. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10807. if (order_type == 0)
  10808. {
  10809. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10810. }
  10811. else if (order_type == 3)
  10812. {
  10813. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10814. }
  10815. else
  10816. {
  10817. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10818. }
  10819. }
  10820. //客服
  10821. if (postCode == "CustomerService" || postCode == "Director")
  10822. {
  10823. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10824. if (order_type == 0)
  10825. {
  10826. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10827. }
  10828. else if (order_type == 1)
  10829. {
  10830. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10831. }
  10832. else if (order_type == 2)
  10833. {
  10834. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10835. }
  10836. else if (order_type == 3)
  10837. {
  10838. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10839. }
  10840. else if (order_type == 4)
  10841. {
  10842. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10843. }
  10844. else
  10845. {
  10846. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10847. }
  10848. }
  10849. //售后
  10850. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10851. {
  10852. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10853. if (shopIds != "")
  10854. {
  10855. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10856. }
  10857. if (order_type == 2)
  10858. {
  10859. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10860. }
  10861. else if (order_type == 4)
  10862. {
  10863. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10864. }
  10865. else if (order_type == 5)
  10866. {
  10867. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10868. }
  10869. else
  10870. {
  10871. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10872. }
  10873. }
  10874. //下单部
  10875. if (postCode == "Place" || postCode == "PlaceMr")
  10876. {
  10877. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10878. if (shopIds != "")
  10879. {
  10880. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10881. }
  10882. else if (order_type == 1)
  10883. {
  10884. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10885. }
  10886. else if (order_type == 2)
  10887. {
  10888. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10889. }
  10890. else
  10891. {
  10892. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10893. }
  10894. }
  10895. //车间
  10896. if (postCode == "Supplier")
  10897. {
  10898. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10899. if (order_type == 5)
  10900. {
  10901. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10902. }
  10903. else
  10904. {
  10905. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10906. }
  10907. }
  10908. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10909. dStruct.Fileds = "tid,ctid";
  10910. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10911. writeGridDataTableJson(dStruct.TotalCount, dt);
  10912. }
  10913. public void aftersale_audit_master()
  10914. {
  10915. if (UrlPostParmsCheck("ctid"))
  10916. {
  10917. string ctid = GetPostString("ctid");
  10918. if (ctid.Length > 0)
  10919. {
  10920. bool result = aftersale_data_change(ctid);
  10921. if (result)
  10922. {
  10923. returnSuccessMsg("修改成功!");
  10924. return;
  10925. }
  10926. }
  10927. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10928. }
  10929. }
  10930. public void aftersale_batch_audit_master()
  10931. {
  10932. if (UrlPostParmsCheck("ctids"))
  10933. {
  10934. string ctids = GetPostString("ctids");
  10935. if (ctids.Length > 0)
  10936. {
  10937. List<string> list = new List<string>();
  10938. string[] ctid_list = ctids.Split(',');
  10939. foreach (var item in ctid_list)
  10940. {
  10941. bool result = aftersale_data_change(item);
  10942. if (!result)
  10943. {
  10944. list.Add(item);
  10945. }
  10946. }
  10947. if (list.Count > 0)
  10948. {
  10949. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10950. return;
  10951. }
  10952. returnSuccessMsg("修改成功!");
  10953. return;
  10954. }
  10955. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10956. }
  10957. }
  10958. public bool aftersale_data_change(string ctid)
  10959. {
  10960. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10961. if (ceErpTradeCell != null)
  10962. {
  10963. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10964. ceErpTradeCell.AfterSaleSupplierState = 0;
  10965. StringBuilder sql = new StringBuilder();
  10966. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10967. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10968. CeErpTradeResponsible.DelByTid(ctid, 0);
  10969. 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 == "不理赔")
  10970. {
  10971. CeErpTradeResponsible.DelByTid(ctid, 1);
  10972. ceErpTradeCell.AfterSaleSupplierState = 1;
  10973. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10974. ceErpTradeCell.AfterSaleState = 4;
  10975. }
  10976. else
  10977. {
  10978. ceErpTradeCell.AfterSaleState = 3;
  10979. }
  10980. bool needCyt = false;
  10981. if (dt != null)
  10982. {
  10983. if (dt.Rows.Count == 1)
  10984. {
  10985. bool isEnd = false;
  10986. foreach (DataRow dr in dt.Rows)
  10987. {
  10988. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10989. {
  10990. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10991. isEnd = true;
  10992. }
  10993. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10994. {
  10995. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10996. isEnd = true;
  10997. }
  10998. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10999. {
  11000. needCyt = true;
  11001. }
  11002. }
  11003. if (isEnd)
  11004. {
  11005. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11006. ceErpTradeCell.AfterSaleState = 4;
  11007. ceErpTradeCell.AfterSaleSupplierState = 1;
  11008. }
  11009. }
  11010. else
  11011. {
  11012. bool isAll = true;
  11013. foreach (DataRow dr in dt.Rows)
  11014. {
  11015. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11016. {
  11017. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11018. continue;
  11019. }
  11020. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  11021. {
  11022. string path = "";
  11023. int OrgID = 0;
  11024. if (!Convert.IsDBNull(dr["OrgPath"]))
  11025. {
  11026. path = dr["OrgPath"].ToString();
  11027. }
  11028. if (!Convert.IsDBNull(dr["OrgID"]))
  11029. {
  11030. OrgID = Convert.ToInt32(dr["OrgID"]);
  11031. }
  11032. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  11033. {
  11034. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11035. continue;
  11036. }
  11037. }
  11038. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11039. {
  11040. needCyt = true;
  11041. }
  11042. isAll = false;
  11043. }
  11044. if (isAll)
  11045. {
  11046. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11047. ceErpTradeCell.AfterSaleState = 4;
  11048. ceErpTradeCell.AfterSaleSupplierState = 1;
  11049. }
  11050. }
  11051. }
  11052. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  11053. {
  11054. commonHelper.sendCytAfterSale(ceErpTradeCell);
  11055. }
  11056. if (ceErpTradeCell.AfterSaleState == 4)
  11057. {
  11058. ApiVo apiVo = new ApiVo();
  11059. apiVo.orderNumber = ceErpTradeCell.ctid;
  11060. apiVo.actionName = "afterOver";
  11061. designHelper.API_WorkCore(apiVo); //afterOver
  11062. }
  11063. ceErpTradeCell.Update();
  11064. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  11065. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  11066. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11067. return true;
  11068. }
  11069. return false;
  11070. }
  11071. public void get_erp_wechatorder()
  11072. {
  11073. DataStruct dStruct = GetPostStruct();
  11074. List<string> lw = new List<string>();
  11075. string tid = GetPostString("tid");
  11076. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11077. string shopname = GetPostString("shopname");
  11078. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11079. string buyernick = GetPostString("buyer_nick");
  11080. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11081. string customer = GetPostString("customer");
  11082. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11083. string returndate1 = GetPostString("returndate1");
  11084. string returndate2 = GetPostString("returndate2");
  11085. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11086. if (dw.Length > 0) lw.Add(dw);
  11087. string finishDate1 = GetPostString("finishdate1");
  11088. string finishDate2 = GetPostString("finishdate2");
  11089. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11090. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11091. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11092. dStruct.Order = "created desc";
  11093. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11094. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11095. writeGridDataTableJson(dStruct.TotalCount, dt);
  11096. }
  11097. public void get_erp_wechatlist_sumprice()
  11098. {
  11099. DataStruct dStruct = GetPostStruct();
  11100. List<string> lw = new List<string>();
  11101. string tid = GetPostString("tid");
  11102. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11103. string shopname = GetPostString("shopname");
  11104. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11105. string buyernick = GetPostString("buyer_nick");
  11106. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11107. string customer = GetPostString("customer");
  11108. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11109. string returndate1 = GetPostString("returndate1");
  11110. string returndate2 = GetPostString("returndate2");
  11111. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11112. if (dw.Length > 0) lw.Add(dw);
  11113. string finishDate1 = GetPostString("finishdate1");
  11114. string finishDate2 = GetPostString("finishdate2");
  11115. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11116. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11117. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11118. string mainWhere = string.Join(" and ", lw.ToArray());
  11119. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11120. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11121. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11122. decimal total = 0;
  11123. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11124. {
  11125. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11126. }
  11127. var res = new
  11128. {
  11129. data = total
  11130. };
  11131. string ro_jsond = JsonConvert.SerializeObject(res);
  11132. returnSuccess(ro_jsond);
  11133. return;
  11134. }
  11135. public void get_erp_qr_waitdeliverylist()
  11136. {
  11137. DataStruct dStruct = GetPostStruct();
  11138. List<string> lw = new List<string>();
  11139. string tid = GetPostString("ctid");
  11140. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11141. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11142. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11143. var res_objz = new
  11144. {
  11145. restype = 1,
  11146. data = dt
  11147. };
  11148. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11149. returnSuccess(ro_jsonz);
  11150. }
  11151. public void get_erp_yield_list()
  11152. {
  11153. DataStruct dStruct = GetPostStruct();
  11154. List<string> lw = new List<string>();
  11155. string tid = GetPostString("ctid");
  11156. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11157. string shopname = GetPostString("shopname");
  11158. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11159. string buyernick = GetPostString("buyer_nick");
  11160. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11161. //if (tid.Length == 0 && buyernick.Length == 0)
  11162. //{
  11163. // lw.Add(string.Format("IsRefund<={0}", 1));
  11164. //}
  11165. string customer = GetPostString("customer");
  11166. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11167. string design = GetPostString("design");
  11168. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11169. string orderState = GetPostString("orderState");
  11170. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11171. string address = GetPostString("address");
  11172. 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));
  11173. string sellermemo = GetPostString("seller_memo");
  11174. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11175. string supplier = GetPostString("supplier");
  11176. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11177. string OrderArea = GetPostString("order_area");
  11178. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11179. string placedate1 = GetPostString("placedate1");
  11180. string placedate2 = GetPostString("placedate2");
  11181. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11182. if (fdw.Length > 0) lw.Add(fdw);
  11183. string price1 = GetPostString("price1");
  11184. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11185. string price2 = GetPostString("price2");
  11186. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11187. string unusualCon = GetPostString("unusualcon");
  11188. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11189. string posTag = CurrentUser.UserPost.Post.Code;
  11190. if (posTag == "Supplier")
  11191. {
  11192. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11193. }
  11194. lw.Add(string.Format("OrderState = 6 "));
  11195. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11196. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11197. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11198. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11199. writeGridDataTableJson(dStruct.TotalCount, dt);
  11200. }
  11201. public void change_erp_sup_state()
  11202. {
  11203. if (UrlPostParmsCheck("ctid"))
  11204. {
  11205. string ctid = GetPostString("ctid");
  11206. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11207. if (ceErpTradeCell != null)
  11208. {
  11209. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11210. if (ceErpTradeCellExtend == null)
  11211. {
  11212. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11213. ceErpTradeCellExtend.ctid = ctid;
  11214. ceErpTradeCellExtend.SupState = 1;
  11215. ceErpTradeCellExtend.Create();
  11216. }
  11217. else
  11218. {
  11219. ceErpTradeCellExtend.SupState = 1;
  11220. ceErpTradeCellExtend.Update();
  11221. }
  11222. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11223. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11224. return;
  11225. }
  11226. returnErrorMsg("找不到订单");
  11227. }
  11228. }
  11229. public void supplier_all_downs()
  11230. {
  11231. if (UrlPostParmsCheck("tids"))
  11232. {
  11233. string tids = GetPostString("tids");
  11234. if (tids != null && tids.Length > 0)
  11235. {
  11236. StringBuilder sql = new StringBuilder();
  11237. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11238. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11239. sql = new StringBuilder();
  11240. 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, "下载设计文件");
  11241. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11242. string[] list = tids.Split(',');
  11243. foreach (string ctid in list)
  11244. {
  11245. CeErpSukuraData.createInfo(ctid, 3);
  11246. }
  11247. designHelper.api_approveDesign(tids); //approveDesign
  11248. returnSuccessMsg("下载成功!");
  11249. return;
  11250. }
  11251. returnErrorMsg("下载订单更新失败");
  11252. }
  11253. }
  11254. public void uploaderFileSuccess()
  11255. {
  11256. if (UrlPostParmsCheck("fileName"))
  11257. {
  11258. string fileName = GetPostString("fileName");
  11259. ApiVo apiVo = new ApiVo();
  11260. apiVo.orderNumber = fileName;
  11261. apiVo.actionName = "finishDesign";
  11262. designHelper.API_WorkCore(apiVo);//finishDesign
  11263. returnSuccessMsg("");
  11264. }
  11265. }
  11266. public void get_sample2_order()
  11267. {
  11268. if (UrlPostParmsCheck("ctid"))
  11269. {
  11270. string ctid = GetPostString("ctid");
  11271. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11272. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11273. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11274. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11275. double total = 0.0;
  11276. double order_price = 0.0;
  11277. if (dt_bu.Rows.Count > 0)
  11278. {
  11279. foreach (DataRow dr in dt_bu.Rows)
  11280. {
  11281. total += Convert.ToDouble(dr["payment"]);
  11282. }
  11283. }
  11284. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11285. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11286. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11287. string tid = ctid.Replace("S_", "");
  11288. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11289. double paymant = 0.0;
  11290. if (entity != null)
  11291. {
  11292. paymant = entity.payment;
  11293. }
  11294. string return_reason = "";
  11295. if (dt_after != null && dt_after.Rows.Count > 0)
  11296. {
  11297. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11298. }
  11299. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11300. }
  11301. }
  11302. public void get_erp_design_status()
  11303. {
  11304. string designName = GetPostString("designName");
  11305. DataStruct dStruct = GetPostStruct();
  11306. if (designName.Length > 0)
  11307. {
  11308. 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";
  11309. sql_user += " and Name like '%" + designName + "%'";
  11310. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11311. List<string> ids_list = new List<string>();
  11312. if (user_table.Rows.Count > 0)
  11313. {
  11314. foreach (DataRow item in user_table.Rows)
  11315. {
  11316. ids_list.Add(item["id"].ToString());
  11317. string ids_s = item["TeamIds"].ToString();
  11318. if (ids_s.Length > 0)
  11319. {
  11320. ids_list.AddRange(ids_s.Split(','));
  11321. }
  11322. }
  11323. }
  11324. HashSet<string> set = new HashSet<string>(ids_list);
  11325. ids_list = set.ToList();
  11326. if (ids_list.Count > 0)
  11327. {
  11328. 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));
  11329. dStruct.MainWhere = sql;
  11330. DataTable dt = null;
  11331. dt = WebCache.GetData("view_ErpUser", dStruct);
  11332. writeGridDataTableJson(dStruct.TotalCount, dt);
  11333. }
  11334. }
  11335. }
  11336. public void change_erp_order_price()
  11337. {
  11338. string ctid = GetPostString("ctid");
  11339. double price = GetPostDouble("price");
  11340. if (ctid.Length > 0)
  11341. {
  11342. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11343. if (ceErpTradeCellExtend == null)
  11344. {
  11345. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11346. ceErpTradeCellExtend.ctid = ctid;
  11347. ceErpTradeCellExtend.payment_cyt = price;
  11348. ceErpTradeCellExtend.Create();
  11349. }
  11350. else
  11351. {
  11352. ceErpTradeCellExtend.payment_cyt = price;
  11353. ceErpTradeCellExtend.Update();
  11354. }
  11355. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11356. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11357. {
  11358. ceErpDataSendOrderInfo.isSync = false;
  11359. ceErpDataSendOrderInfo.Update();
  11360. }
  11361. if (ceErpDataSendOrderInfo == null)
  11362. {
  11363. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11364. ceErpDataSendOrderInfo.isSync = false;
  11365. ceErpDataSendOrderInfo.ctid = ctid;
  11366. ceErpDataSendOrderInfo.Create();
  11367. }
  11368. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11369. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11370. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11371. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11372. {
  11373. dataSendOrderBean dataSendOrderBean = null;
  11374. foreach (DataRow item in dth.Rows)
  11375. {
  11376. try
  11377. {
  11378. dataSendOrderBean = new dataSendOrderBean();
  11379. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11380. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11381. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11382. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11383. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11384. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11385. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11386. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11387. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11388. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11389. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11390. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11391. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11392. if (result != null)
  11393. {
  11394. if ("0".Equals(result.errcode))
  11395. {
  11396. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11397. }
  11398. else
  11399. {
  11400. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11401. }
  11402. }
  11403. }
  11404. catch (Exception ex)
  11405. {
  11406. }
  11407. }
  11408. }
  11409. returnSuccessMsg("修改成功!");
  11410. return;
  11411. }
  11412. returnErrorMsg("找不到订单");
  11413. }
  11414. public void find_he_together()
  11415. {
  11416. string ctid = GetPostString("ctid");
  11417. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11418. List<string> list = new List<string>();
  11419. if (ceErpTradeCell != null)
  11420. {
  11421. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11422. {
  11423. 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);
  11424. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11425. if (table != null && table.Rows.Count > 0)
  11426. {
  11427. foreach (TableRow row in table.Rows)
  11428. {
  11429. }
  11430. }
  11431. }
  11432. }
  11433. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11434. }
  11435. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11436. {
  11437. //chy----19
  11438. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11439. //GD-CYT-----64
  11440. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11441. //ZHX----3
  11442. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11443. //JK----97
  11444. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11445. //ZT----70
  11446. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11447. //GD-CYTUV---126
  11448. {126, new Dictionary<string, string> {{"uv", "uv"}}},
  11449. //LHCY-----98
  11450. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11451. //XD-----90
  11452. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11453. //CYCY-----14
  11454. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11455. };
  11456. //其他改名
  11457. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11458. {
  11459. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11460. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11461. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11462. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11463. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11464. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11465. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11466. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11467. };
  11468. //不统计
  11469. List<int> no_suppliers = new List<int>()
  11470. {
  11471. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11472. };
  11473. //配件单
  11474. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11475. {
  11476. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11477. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11478. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11479. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11480. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11481. {"旗杆",new List<string>(){ "班旗" } },
  11482. {"牙签",new List<string>(){ "不干胶" } }
  11483. };
  11484. public void get_place_order_data()
  11485. {
  11486. string date1 = GetPostString("date1");
  11487. string date2 = GetPostString("date2");
  11488. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11489. DateTime start = DateTime.Parse(starttime);
  11490. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11491. DateTime end = DateTime.Parse(endtime);
  11492. if (date1 != null && date1.Length > 0)
  11493. {
  11494. DateTime dateTime = DateTime.Parse(date1);
  11495. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11496. start = DateTime.Parse(starttime);
  11497. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11498. end = DateTime.Parse(endtime);
  11499. }
  11500. if (date2 != null && date2.Length > 0)
  11501. {
  11502. DateTime dateTime = DateTime.Parse(date2);
  11503. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11504. end = DateTime.Parse(endtime);
  11505. }
  11506. 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);
  11507. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11508. //不干胶-----1,卡片-----29
  11509. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11510. foreach (DataRow row in data.Rows)
  11511. {
  11512. int productId = Convert.ToInt32(row["ProductId"]);
  11513. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11514. if (no_suppliers.Contains(supplierId))
  11515. {
  11516. continue;
  11517. }
  11518. string seller_memo = row["seller_memo"].ToString();
  11519. bool ispj = false;//是否配件单
  11520. bool isfirst = true;//第一个配
  11521. maps.Keys.ForEach(key =>
  11522. {
  11523. //备注包含配件
  11524. if (seller_memo.Contains(key) && isfirst)
  11525. {
  11526. List<string> list = maps[key];
  11527. ispj = true;
  11528. isfirst = false;
  11529. for (int i = 0; i < list.Count; i++)
  11530. {
  11531. if (seller_memo.Contains(list[i]))
  11532. {
  11533. ispj = false;
  11534. break;
  11535. }
  11536. }
  11537. }
  11538. });
  11539. if (ispj)
  11540. {
  11541. continue;
  11542. }
  11543. seller_memo = seller_memo.Replace("UV", "uv");
  11544. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11545. //吊牌归到卡片
  11546. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11547. seller_memo = seller_memo.Replace("卡套", "卡片");
  11548. seller_memo = seller_memo.Replace("封套", "卡片");
  11549. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11550. seller_memo = seller_memo.Replace("腰封", "卡片");
  11551. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11552. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11553. seller_memo = seller_memo.Replace("横幅", "条幅");
  11554. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11555. string map_key = "";
  11556. string type = "";
  11557. if (supplierMap.ContainsKey(supplierId))
  11558. {
  11559. foreach (var kvp in supplierMap[supplierId])
  11560. {
  11561. if (seller_memo.Contains(kvp.Key))
  11562. {
  11563. map_key = kvp.Value;
  11564. type = kvp.Value;
  11565. break;
  11566. }
  11567. }
  11568. }
  11569. if (map_key == "")
  11570. {
  11571. type = "其他";
  11572. map_key = "其他";
  11573. }
  11574. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11575. {
  11576. map_key = suppliers[supplierId];
  11577. }
  11578. if (supplierId == 70)
  11579. {
  11580. supplierId = 70;
  11581. }
  11582. map_key += "_" + row["SupplierName"].ToString();
  11583. Dictionary<string, int> map = null;
  11584. if (other_map.ContainsKey(map_key))
  11585. {
  11586. other_map.TryGetValue(map_key, out map);
  11587. }
  11588. else
  11589. {
  11590. map = new Dictionary<string, int>();
  11591. map.Add("dayDev", 0);//当天出货
  11592. map.Add("dayTotal", 0);//下单总数
  11593. map.Add("payTotal", 0);//500以上
  11594. map.Add("today", 0);//当天出货数量
  11595. map.Add("unusua", 0);//异常数
  11596. other_map.Add(map_key, map);
  11597. other_map.TryGetValue(map_key, out map);
  11598. }
  11599. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11600. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11601. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11602. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11603. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11604. {
  11605. map["dayTotal"]++;
  11606. if (supplierId == 97)
  11607. {
  11608. supplierId = 97;
  11609. }
  11610. }
  11611. if (Convert.ToDecimal(row["payment"]) >= 500)
  11612. {
  11613. map["payTotal"]++;
  11614. }
  11615. bool istoday = false;
  11616. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11617. {
  11618. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11619. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11620. {
  11621. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11622. {
  11623. map["today"]++;
  11624. }
  11625. }
  11626. else
  11627. {
  11628. if (supplierId == 80)
  11629. {
  11630. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11631. {
  11632. map["today"]++;
  11633. }
  11634. }
  11635. else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11636. {
  11637. map["today"]++;
  11638. istoday = true;
  11639. }
  11640. }
  11641. }
  11642. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11643. {
  11644. map["unusua"]++;
  11645. }
  11646. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11647. //GD-CYT-----64
  11648. DateTime two = palceTimeStart.AddHours(14);
  11649. DateTime three = palceTimeStart.AddHours(15);
  11650. DateTime four = palceTimeStart.AddHours(16);
  11651. DateTime six = palceTimeStart.AddHours(18);
  11652. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11653. {
  11654. //下午四点前 500-1000
  11655. string count = row["ProductCount"].ToString();
  11656. if (count != null && count.Length > 0)
  11657. {
  11658. int productCount = commonHelper.getPlaceProductCount(count);
  11659. if (productCount >= 500 && productCount <= 1000)
  11660. {
  11661. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11662. {
  11663. map["dayDev"]++;
  11664. }
  11665. }
  11666. }
  11667. }
  11668. //UV
  11669. else if ("uv".Equals(type))
  11670. {
  11671. //ZT----70
  11672. //ZHX----3
  11673. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11674. {
  11675. map["dayDev"]++;
  11676. }
  11677. //JK----97
  11678. //HZX----105
  11679. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11680. {
  11681. map["dayDev"]++;
  11682. }
  11683. if (DateTime.Compare(FinishPlaceTime, six) < 0 && (supplierId == 126))
  11684. {
  11685. map["dayDev"]++;
  11686. }
  11687. }
  11688. //帆布---52|条幅---27
  11689. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11690. {
  11691. //LHCY-----98
  11692. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11693. {
  11694. map["dayDev"]++;
  11695. }
  11696. }
  11697. //条幅
  11698. else if ("条幅".Equals(type))
  11699. {
  11700. //XD-----90
  11701. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11702. {
  11703. map["dayDev"]++;
  11704. }
  11705. }
  11706. //桌布
  11707. else if ("桌布".Equals(type))
  11708. {
  11709. //XD-----90
  11710. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11711. {
  11712. map["dayDev"]++;
  11713. }
  11714. }
  11715. //DL---10
  11716. //AYTW---119
  11717. //FS-CYT-DY ----80
  11718. //JK----97
  11719. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11720. {
  11721. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11722. {
  11723. map["dayDev"]++;
  11724. if (supplierId == 80 && istoday)
  11725. {
  11726. Debug.WriteLine(seller_memo);
  11727. }
  11728. }
  11729. }
  11730. // QC---121
  11731. else if (supplierId == 121)
  11732. {
  11733. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11734. {
  11735. map["dayDev"]++;
  11736. }
  11737. }
  11738. }
  11739. DataTable dt = new DataTable();
  11740. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11741. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11742. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11743. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11744. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11745. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11746. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11747. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11748. other_map.Keys.ForEach(key =>
  11749. {
  11750. DataRow dr = dt.NewRow();
  11751. Dictionary<string, int> map = other_map[key];
  11752. string[] key_list = key.Split('_');
  11753. dr[0] = key_list[0];
  11754. dr[1] = key_list[1];
  11755. if (key_list.Length > 2)
  11756. {
  11757. dr[1] += "(" + key_list[2] + ")";
  11758. }
  11759. dr[2] = map["dayTotal"];
  11760. dr[3] = map["payTotal"];
  11761. dr[4] = map["today"];
  11762. dr[5] = map["unusua"];
  11763. dr[6] = map["dayDev"];
  11764. double rate = 0.00;
  11765. if (map["dayDev"] > 0)
  11766. {
  11767. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11768. }
  11769. dr[7] = rate.ToString();
  11770. dt.Rows.Add(dr);
  11771. });
  11772. DataView dv = new DataView(dt);
  11773. dv.Sort = "SupplierName";
  11774. //dv.Sort = "AllOrder desc";
  11775. DataTable dtNew = dv.ToTable();
  11776. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11777. }
  11778. public void check_order_desing_info()
  11779. {
  11780. string ctid = GetPostString("ctid");
  11781. if (!string.IsNullOrEmpty(ctid))
  11782. {
  11783. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11784. if (ceErpTradeCell != null)
  11785. {
  11786. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11787. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11788. return;
  11789. }
  11790. returnErrorMsg("找不到订单");
  11791. return;
  11792. }
  11793. returnErrorMsg("找不到订单");
  11794. }
  11795. public void get_timeout_detail()
  11796. {
  11797. string poscode = CurrentUser.UserPost.Post.Code;
  11798. DataStruct dStruct = GetPostStruct();
  11799. List<string> lw = new List<string>();
  11800. string id = GetPostString("id");
  11801. string pay_date1 = GetPostString("pay_date1");
  11802. string pay_date2 = GetPostString("pay_date2");
  11803. int type = GetPostInt("type");
  11804. if (type == 0)
  11805. {
  11806. if (pay_date1.Length > 0)
  11807. {
  11808. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11809. }
  11810. if (pay_date2.Length > 0)
  11811. {
  11812. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11813. }
  11814. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11815. }
  11816. if (type == 1)
  11817. {
  11818. if (pay_date1.Length > 0)
  11819. {
  11820. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11821. }
  11822. if (pay_date2.Length > 0)
  11823. {
  11824. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11825. }
  11826. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11827. }
  11828. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11829. DataTable dt = null;
  11830. dt = WebCache.GetData("view_orderlist", dStruct);
  11831. writeGridDataTableJson(dStruct.TotalCount, dt);
  11832. }
  11833. public void saveUrgentChargePrice()
  11834. {
  11835. string ctid = GetPostString("ctid");
  11836. if (!string.IsNullOrEmpty(ctid))
  11837. {
  11838. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11839. if (ceErpTradeCell != null)
  11840. {
  11841. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11842. if (prices <= 100)
  11843. {
  11844. returnErrorMsg("此订单金额不足100元,无法加急。");
  11845. return;
  11846. }
  11847. double price = GetPostDouble("price");
  11848. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11849. if (ceErpTradeCellExtend == null)
  11850. {
  11851. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11852. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11853. }
  11854. ceErpTradeCellExtend.urgentCharge = price;
  11855. if (ceErpTradeCellExtend.ID > 0)
  11856. {
  11857. ceErpTradeCellExtend.Update();
  11858. }
  11859. else
  11860. {
  11861. ceErpTradeCellExtend.Save();
  11862. }
  11863. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11864. returnSuccessMsg("修改成功!");
  11865. return;
  11866. }
  11867. returnErrorMsg("找不到订单");
  11868. return;
  11869. }
  11870. returnErrorMsg("找不到订单");
  11871. }
  11872. public void finish_erp_order()
  11873. {
  11874. string ctid = GetPostString("ctid");
  11875. if (!string.IsNullOrEmpty(ctid))
  11876. {
  11877. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11878. {
  11879. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11880. if (ceErpTradeCell != null)
  11881. {
  11882. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11883. ceErpTradeCell.Update();
  11884. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11885. returnSuccessMsg("修改成功!");
  11886. return;
  11887. }
  11888. }
  11889. }
  11890. returnErrorMsg("找不到订单");
  11891. }
  11892. public void get_trade_order_list()
  11893. {
  11894. string tid = GetPostString("tid");
  11895. if (!string.IsNullOrEmpty(tid))
  11896. {
  11897. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11898. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11899. writeGridDataTableJson(data.Rows.Count, data);
  11900. return;
  11901. }
  11902. returnErrorMsg("找不到订单");
  11903. }
  11904. public void save_cell_spu()
  11905. {
  11906. string ctid = GetPostString("ctid");
  11907. string spu_id = GetPostString("spu_id");
  11908. if (!string.IsNullOrEmpty(ctid))
  11909. {
  11910. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11911. if (ceErpTradeCellExtend == null)
  11912. {
  11913. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11914. ceErpTradeCellExtend.ctid = ctid;
  11915. }
  11916. ceErpTradeCellExtend.spu_id = spu_id;
  11917. if (!string.IsNullOrEmpty(spu_id))
  11918. {
  11919. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11920. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11921. }
  11922. if (ceErpTradeCellExtend.ID == 0)
  11923. {
  11924. ceErpTradeCellExtend.Create();
  11925. }
  11926. else
  11927. {
  11928. ceErpTradeCellExtend.Update();
  11929. }
  11930. returnSuccessMsg("修改成功!");
  11931. return;
  11932. }
  11933. returnErrorMsg("找不到订单");
  11934. }
  11935. public void change_express_info()
  11936. {
  11937. string ctid = GetPostString("ctid");
  11938. string transNo = GetPostString("transNo");
  11939. string transCom = GetPostString("transCom");
  11940. if (!string.IsNullOrEmpty(ctid))
  11941. {
  11942. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11943. if (ceErpTradeCellExtend == null)
  11944. {
  11945. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11946. ceErpTradeCellExtend.ctid = ctid;
  11947. }
  11948. ceErpTradeCellExtend.modExpressNo = transNo;
  11949. ceErpTradeCellExtend.modExpressCom = transCom;
  11950. ceErpTradeCellExtend.readMod = 2;
  11951. if (ceErpTradeCellExtend.ID == 0)
  11952. {
  11953. ceErpTradeCellExtend.Create();
  11954. }
  11955. else
  11956. {
  11957. ceErpTradeCellExtend.Update();
  11958. }
  11959. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11960. returnSuccessMsg("修改成功!");
  11961. return;
  11962. }
  11963. returnErrorMsg("找不到订单");
  11964. }
  11965. public void get_change_express_list()
  11966. {
  11967. DataStruct dStruct = GetPostStruct();
  11968. List<string> lw = new List<string>();
  11969. int st = 2;
  11970. string tid = GetPostString("ctid");
  11971. if (tid.Length > 0)
  11972. {
  11973. string select_tid = getTidByCtid(tid);
  11974. lw.Add(string.Format("tid='{0}'", select_tid));
  11975. }
  11976. string shopname = GetPostString("shopname");
  11977. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11978. string buyernick = GetPostString("buyer_nick");
  11979. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11980. string sellermemo = GetPostString("seller_memo");
  11981. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11982. string supplier = GetPostString("supplier");
  11983. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11984. string customer = GetPostString("customer");
  11985. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11986. string design = GetPostString("design");
  11987. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11988. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11989. string poscode = CurrentUser.UserPost.Post.Code;
  11990. if (poscode != "SysAdmin")
  11991. {
  11992. string shopid = CurrentUser.User.pemShop;
  11993. lw.Add(string.Format("shopId in ({0})", shopid));
  11994. }
  11995. lw.Add("readMod = 2");
  11996. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11997. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11998. writeGridDataTableJson(dStruct.TotalCount, dt);
  11999. }
  12000. public void deal_express_complete()
  12001. {
  12002. string ctid = GetPostString("ctid");
  12003. if (!string.IsNullOrEmpty(ctid))
  12004. {
  12005. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12006. if (ceErpTradeCellExtend == null)
  12007. {
  12008. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12009. ceErpTradeCellExtend.ctid = ctid;
  12010. }
  12011. ceErpTradeCellExtend.readMod = 1;
  12012. if (ceErpTradeCellExtend.ID == 0)
  12013. {
  12014. ceErpTradeCellExtend.Create();
  12015. }
  12016. else
  12017. {
  12018. ceErpTradeCellExtend.Update();
  12019. }
  12020. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  12021. returnSuccessMsg("修改成功!");
  12022. return;
  12023. }
  12024. returnErrorMsg("找不到订单");
  12025. }
  12026. public void aftersale_return_visit()
  12027. {
  12028. string ctid = GetPostString("ctid");
  12029. if (!string.IsNullOrEmpty(ctid))
  12030. {
  12031. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12032. if (ceErpTradeCellExtend == null)
  12033. {
  12034. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12035. ceErpTradeCellExtend.ctid = ctid;
  12036. }
  12037. ceErpTradeCellExtend.returnVisit = 1;
  12038. if (ceErpTradeCellExtend.ID == 0)
  12039. {
  12040. ceErpTradeCellExtend.Create();
  12041. }
  12042. else
  12043. {
  12044. ceErpTradeCellExtend.Update();
  12045. }
  12046. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12047. if (ceErpTradeAfterSaleExtend != null)
  12048. {
  12049. ceErpTradeAfterSaleExtend.TextResult = "";
  12050. ceErpTradeAfterSaleExtend.Update();
  12051. }
  12052. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  12053. returnSuccessMsg("修改成功!");
  12054. return;
  12055. }
  12056. returnErrorMsg("找不到订单");
  12057. }
  12058. public void orderPlaceInfo()
  12059. {
  12060. string ctids = GetPostString("ctids");
  12061. string[] list = ctids.Split(',');
  12062. foreach (string ctid in list)
  12063. {
  12064. CeErpSukuraData.createInfo(ctid, 3);
  12065. }
  12066. StringBuilder sql = new StringBuilder();
  12067. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  12068. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  12069. designHelper.api_approveDesign(ctids); //approveDesign
  12070. returnSuccessMsg("");
  12071. }
  12072. public void get_issue_list()
  12073. {
  12074. DataStruct dStruct = GetPostStruct();
  12075. List<string> lw = new List<string>();
  12076. int st = 2;
  12077. string tid = GetPostString("ctid");
  12078. if (tid.Length > 0)
  12079. {
  12080. string select_tid = getTidByCtid(tid);
  12081. lw.Add(string.Format("tid='{0}'", select_tid));
  12082. }
  12083. string shopname = GetPostString("shopname");
  12084. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12085. string buyernick = GetPostString("buyer_nick");
  12086. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12087. string sellermemo = GetPostString("seller_memo");
  12088. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12089. string supplier = GetPostString("supplier");
  12090. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12091. string customer = GetPostString("customer");
  12092. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12093. string design = GetPostString("design");
  12094. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12095. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12096. string poscode = CurrentUser.UserPost.Post.Code;
  12097. if (poscode != "SysAdmin")
  12098. {
  12099. string shopid = CurrentUser.User.pemShop;
  12100. lw.Add(string.Format("shopId in ({0})", shopid));
  12101. }
  12102. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12103. {
  12104. lw.Add("IssueState = 1");
  12105. }
  12106. else
  12107. {
  12108. string iisstate = GetPostString("iisstate");
  12109. if ("1".Equals(iisstate))
  12110. {
  12111. lw.Add("IssueState =1");
  12112. }
  12113. else if ("2".Equals(iisstate))
  12114. {
  12115. lw.Add("IssueState = 2");
  12116. }
  12117. else
  12118. {
  12119. lw.Add("IssueState > 0");
  12120. }
  12121. }
  12122. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12123. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12124. writeGridDataTableJson(dStruct.TotalCount, dt);
  12125. }
  12126. public void saveIssueContent()
  12127. {
  12128. string ctid = GetPostString("ctid");
  12129. if (!string.IsNullOrEmpty(ctid))
  12130. {
  12131. string content = GetPostString("content");
  12132. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12133. if (ceErpTradeAfterSaleExtend == null)
  12134. {
  12135. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12136. ceErpTradeAfterSaleExtend.tid = ctid;
  12137. }
  12138. ceErpTradeAfterSaleExtend.IssueContent = content;
  12139. ceErpTradeAfterSaleExtend.IssueState = 1;
  12140. if (ceErpTradeAfterSaleExtend.ID > 0)
  12141. {
  12142. ceErpTradeAfterSaleExtend.Update();
  12143. }
  12144. else
  12145. {
  12146. ceErpTradeAfterSaleExtend.Create();
  12147. }
  12148. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12149. returnSuccessMsg("添加成功!");
  12150. return;
  12151. }
  12152. returnErrorMsg("找不到订单");
  12153. }
  12154. public void dealIssueContent()
  12155. {
  12156. string ctid = GetPostString("ctid");
  12157. if (!string.IsNullOrEmpty(ctid))
  12158. {
  12159. string content = GetPostString("content");
  12160. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12161. if (ceErpTradeAfterSaleExtend != null)
  12162. {
  12163. ceErpTradeAfterSaleExtend.IssueState = 2;
  12164. ceErpTradeAfterSaleExtend.Update();
  12165. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12166. returnSuccessMsg("修改完成!");
  12167. return;
  12168. }
  12169. }
  12170. returnErrorMsg("找不到订单");
  12171. }
  12172. public void set_tid_attachments()
  12173. {
  12174. string tid = GetPostString("tid");
  12175. string atta = GetPostString("atta");
  12176. if (!string.IsNullOrEmpty(tid))
  12177. {
  12178. if (string.IsNullOrEmpty(atta))
  12179. {
  12180. returnErrorMsg("文件地址为空");
  12181. return;
  12182. }
  12183. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12184. if (ceErpTradeCell != null)
  12185. {
  12186. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12187. if (ceErpTrade == null)
  12188. {
  12189. returnErrorMsg("找不到订单");
  12190. return;
  12191. }
  12192. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12193. bool isSend = false;
  12194. if (dt != null && dt.Rows.Count > 0)
  12195. {
  12196. foreach (DataRow row in dt.Rows)
  12197. {
  12198. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12199. {
  12200. isSend = true;
  12201. }
  12202. }
  12203. if (isSend)
  12204. {
  12205. returnErrorMsg("已发货无法修改");
  12206. return;
  12207. }
  12208. ceErpTrade.Attachments = atta;
  12209. ceErpTrade.Update();
  12210. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12211. returnSuccessMsg("上传成功!");
  12212. return;
  12213. }
  12214. }
  12215. }
  12216. returnErrorMsg("找不到订单");
  12217. }
  12218. public void get_tid_attachments()
  12219. {
  12220. string tid = GetPostString("tid");
  12221. if (!string.IsNullOrEmpty(tid))
  12222. {
  12223. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12224. if (ceErpTradeCell != null)
  12225. {
  12226. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12227. if (ceErpTrade == null)
  12228. {
  12229. returnErrorMsg("找不到订单");
  12230. return;
  12231. }
  12232. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12233. return;
  12234. }
  12235. }
  12236. returnErrorMsg("找不到订单");
  12237. }
  12238. public void check_erp_sameorders()
  12239. {
  12240. if (UrlPostParmsCheck("ctid"))
  12241. {
  12242. string eid = GetPostString("ctid");
  12243. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12244. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12245. if (entity != null && ceErpTrade != null)
  12246. {
  12247. if (entity.OrderState > 6)
  12248. {
  12249. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12250. return;
  12251. }
  12252. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12253. List<string> ids = new List<string>();
  12254. if (dt != null && dt.Rows.Count > 1)
  12255. {
  12256. bool needhe = true;
  12257. foreach (DataRow dr in dt.Rows)
  12258. {
  12259. ids.Add("'" + dr["ctid"] + "'");
  12260. /* //备注有合包
  12261. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12262. {
  12263. needhe = true;
  12264. }
  12265. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12266. {
  12267. needhe = true;
  12268. }
  12269. //顺丰快递
  12270. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12271. {
  12272. needhe = true;
  12273. }*/
  12274. }
  12275. if (!needhe)
  12276. {
  12277. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12278. return;
  12279. }
  12280. StringBuilder sql = new StringBuilder();
  12281. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12282. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12283. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12284. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12285. foreach (DataRow dr in dt.Rows)
  12286. {
  12287. dr["dstate"] = 0;
  12288. dr["dnumber"] = 0;
  12289. foreach (DataRow row in dt1.Rows)
  12290. {
  12291. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12292. {
  12293. dr["dstate"] = 2;
  12294. dr["default"] = 1;
  12295. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12296. }
  12297. }
  12298. if (eid.Equals(dr["ctid"].ToString()))
  12299. {
  12300. dr["dstate"] = 1;
  12301. dr["default"] = 1;
  12302. }
  12303. }
  12304. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12305. return;
  12306. }
  12307. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12308. return;
  12309. }
  12310. returnErrorMsg("未找到订单");
  12311. return;
  12312. }
  12313. returnErrorMsg("缺少必要的参数");
  12314. }
  12315. public void get_mark_number()
  12316. {
  12317. string eid = GetPostString("ctid");
  12318. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12319. if (entity != null)
  12320. {
  12321. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12322. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12323. int current = 1;
  12324. if (ceErpDeliverMark == null)
  12325. {
  12326. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12327. List<string> ids = new List<string>();
  12328. if (dt != null && dt.Rows.Count > 1)
  12329. {
  12330. foreach (DataRow dr in dt.Rows)
  12331. {
  12332. ids.Add("'" + dr["ctid"] + "'");
  12333. }
  12334. //查询已有的编号
  12335. StringBuilder sql = new StringBuilder();
  12336. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12337. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12338. if (dt1 == null || dt1.Rows.Count == 0)
  12339. {
  12340. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12341. List<int> list_number = new List<int>();
  12342. foreach (DataRow row in numbers.Rows)
  12343. {
  12344. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12345. }
  12346. //查询空余编号
  12347. for (int i = 0; i < list_number.Count + 2; i++)
  12348. {
  12349. if (!list_number.Contains(current))
  12350. {
  12351. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12352. //防止查询过程中有新数据生成
  12353. if (ceErpDeliverMark1 == null)
  12354. {
  12355. break;
  12356. }
  12357. }
  12358. current++;
  12359. }
  12360. }
  12361. else
  12362. {
  12363. foreach (DataRow row in dt1.Rows)
  12364. {
  12365. current = Convert.ToInt32(row["markNumber"]);
  12366. }
  12367. }
  12368. ceErpDeliverMark = new CeErpDeliverMark();
  12369. ceErpDeliverMark.ctid = eid;
  12370. ceErpDeliverMark.createtime = DateTime.Now;
  12371. if (ceErpTrade != null)
  12372. {
  12373. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12374. }
  12375. ceErpDeliverMark.markNumber = current;
  12376. ceErpDeliverMark.Create();
  12377. }
  12378. }
  12379. else
  12380. {
  12381. current = ceErpDeliverMark.markNumber;
  12382. }
  12383. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12384. return;
  12385. }
  12386. }
  12387. public void aftersaleCytSend()
  12388. {
  12389. string ctid = GetPostString("ctid");
  12390. if (!string.IsNullOrEmpty(ctid))
  12391. {
  12392. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12393. if (ceErpTradeCell != null)
  12394. {
  12395. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12396. }
  12397. returnSuccessMsg("推送成功");
  12398. return;
  12399. }
  12400. returnErrorMsg("缺少必要的参数");
  12401. }
  12402. public void packOrderInfo()
  12403. {
  12404. string ctids = GetPostString("ctids");
  12405. if (!string.IsNullOrEmpty(ctids))
  12406. {
  12407. string[] ctid_list = ctids.Split(',');
  12408. if (ctid_list.Length > 20)
  12409. {
  12410. returnErrorMsg("单次下载次数不能超过20个");
  12411. return;
  12412. }
  12413. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12414. StringBuilder sql = new StringBuilder();
  12415. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12416. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12417. int supplierId = 0;
  12418. StringBuilder insterSql = new StringBuilder();
  12419. for (int i = 0; i < dt.Rows.Count; i++)
  12420. {
  12421. DataRow row = dt.Rows[i];
  12422. if (i == 0)
  12423. {
  12424. supplierId = Convert.ToInt32(row["SupplierId"]);
  12425. }
  12426. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12427. {
  12428. returnErrorMsg("同车间的订单才能一起打包");
  12429. return;
  12430. }
  12431. int orderState = Convert.ToInt32(row["OrderState"]);
  12432. if (orderState != 5)
  12433. {
  12434. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12435. return;
  12436. }
  12437. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12438. }
  12439. CeErpPackData ceErpPackData = new CeErpPackData();
  12440. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12441. ceErpPackData.supplierId = supplierId;
  12442. ceErpPackData.createtime = DateTime.Now;
  12443. ceErpPackData.createBy = CurrentUser.UserID;
  12444. ceErpPackData.createName = CurrentUser.UserName;
  12445. ceErpPackData.Create();
  12446. if (ceErpPackData.ID > 0)
  12447. {
  12448. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12449. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12450. }
  12451. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12452. returnSuccessMsg("打包成功");
  12453. return;
  12454. }
  12455. returnErrorMsg("缺少必要的参数");
  12456. }
  12457. public void rePackOrderInfo()
  12458. {
  12459. string id = GetPostString("id");
  12460. if (!string.IsNullOrEmpty(id))
  12461. {
  12462. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12463. if (ceErpPackData == null)
  12464. {
  12465. returnSuccessMsg("查无数据");
  12466. return;
  12467. }
  12468. ceErpPackData.upStatus = 0;
  12469. ceErpPackData.message = "";
  12470. ceErpPackData.Update();
  12471. returnSuccessMsg("打包成功");
  12472. return;
  12473. }
  12474. returnErrorMsg("缺少必要的参数");
  12475. }
  12476. public void backPackOrderInfo()
  12477. {
  12478. string id = GetPostString("id");
  12479. if (!string.IsNullOrEmpty(id))
  12480. {
  12481. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12482. if (ceErpPackData == null)
  12483. {
  12484. returnSuccessMsg("查无数据");
  12485. return;
  12486. }
  12487. ceErpPackData.upStatus = 4;
  12488. ceErpPackData.Update();
  12489. List<string> list = new List<string>();
  12490. StringBuilder sql = new StringBuilder();
  12491. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12492. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12493. for (int i = 0; i < dt.Rows.Count; i++)
  12494. {
  12495. DataRow row = dt.Rows[i];
  12496. list.Add("'" + row["ctid"].ToString() + "'");
  12497. }
  12498. string textCtids = string.Join(",", list);
  12499. 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));
  12500. 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, "无法打包退回"));
  12501. returnSuccessMsg("退回成功");
  12502. return;
  12503. }
  12504. returnErrorMsg("缺少必要的参数");
  12505. }
  12506. public void addPackDownNum()
  12507. {
  12508. string id = GetPostString("id");
  12509. if (!string.IsNullOrEmpty(id))
  12510. {
  12511. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12512. returnSuccessMsg("下载成功");
  12513. return;
  12514. }
  12515. returnErrorMsg("缺少必要的参数");
  12516. }
  12517. public void get_pack_list()
  12518. {
  12519. DataStruct dStruct = GetPostStruct();
  12520. List<string> lw = new List<string>();
  12521. string supplier = GetPostString("supplier");
  12522. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12523. string posTag = CurrentUser.UserPost.Post.Code;
  12524. if (posTag == "Supplier")
  12525. {
  12526. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12527. }
  12528. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12529. dStruct.Order = "createtime desc";
  12530. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12531. writeGridDataTableJson(dStruct.TotalCount, dt);
  12532. }
  12533. public void get_pack_order_list()
  12534. {
  12535. string packId = GetPostString("packId");
  12536. if (string.IsNullOrEmpty(packId))
  12537. {
  12538. returnErrorMsg("缺少必要的参数");
  12539. return;
  12540. }
  12541. StringBuilder sql = new StringBuilder();
  12542. 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);
  12543. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12544. if (dt == null || dt.Rows.Count == 0)
  12545. {
  12546. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12547. return;
  12548. }
  12549. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12550. return;
  12551. }
  12552. public void get_supplier_product_time_list()
  12553. {
  12554. DataStruct dStruct = GetPostStruct();
  12555. List<string> lw = new List<string>();
  12556. string supplier = GetPostString("supplier");
  12557. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12558. string posTag = CurrentUser.UserPost.Post.Code;
  12559. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12560. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12561. writeGridDataTableJson(dStruct.TotalCount, dt);
  12562. }
  12563. public void saveSupplierProductTime()
  12564. {
  12565. string productId = GetPostString("productId");
  12566. if (string.IsNullOrEmpty(productId))
  12567. {
  12568. returnErrorMsg("缺少必要的参数");
  12569. return;
  12570. }
  12571. string productName = GetPostString("productName");
  12572. int supplierId = GetPostInt("supplierId");
  12573. if (supplierId == 0)
  12574. {
  12575. returnErrorMsg("缺少必要的参数");
  12576. return;
  12577. }
  12578. int quantity = GetPostInt("quantity");
  12579. int sendDay = GetPostInt("sendTime");
  12580. string supplierName = GetPostString("supplierName");
  12581. string craft = GetPostString("craft");
  12582. string deadLine = GetPostString("deadLine");
  12583. string dayDeadLine = GetPostString("dayDeadLine");
  12584. try
  12585. {
  12586. int eid = GetPostInt("eid");
  12587. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12588. if (ceErpSupplierProductTime == null)
  12589. {
  12590. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12591. }
  12592. ceErpSupplierProductTime.productId = productId;
  12593. ceErpSupplierProductTime.productName = productName;
  12594. ceErpSupplierProductTime.supplierId = supplierId;
  12595. ceErpSupplierProductTime.supplierName = supplierName;
  12596. ceErpSupplierProductTime.craft = craft;
  12597. ceErpSupplierProductTime.sendDay = sendDay;
  12598. ceErpSupplierProductTime.quantity = quantity;
  12599. if (!string.IsNullOrEmpty(deadLine))
  12600. {
  12601. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12602. }
  12603. if (!string.IsNullOrEmpty(dayDeadLine))
  12604. {
  12605. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12606. }
  12607. if (ceErpSupplierProductTime.ID == 0)
  12608. {
  12609. ceErpSupplierProductTime.Save();
  12610. }
  12611. else
  12612. {
  12613. ceErpSupplierProductTime.Update();
  12614. }
  12615. }
  12616. catch (Exception e)
  12617. {
  12618. }
  12619. returnSuccessMsg("保存成功");
  12620. return;
  12621. }
  12622. public void delSupplierProductTime()
  12623. {
  12624. int eid = GetPostInt("eid");
  12625. if (eid > 0)
  12626. {
  12627. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12628. if (ceErpSupplierProductTime == null)
  12629. {
  12630. returnErrorMsg("查无数据");
  12631. return;
  12632. }
  12633. ceErpSupplierProductTime.Delete();
  12634. returnSuccessMsg("保存成功");
  12635. return;
  12636. }
  12637. returnErrorMsg("缺少必要的参数");
  12638. }
  12639. public void getExpressInfo()
  12640. {
  12641. string ctid = GetPostString("ctid");
  12642. if (!string.IsNullOrEmpty(ctid))
  12643. {
  12644. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12645. if (ceErpTradeCell != null)
  12646. {
  12647. string outSid = ceErpTradeCell.OutSid;
  12648. if (outSid.Length > 0)
  12649. {
  12650. 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);
  12651. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12652. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12653. return;
  12654. }
  12655. }
  12656. returnErrorMsg("查无记录");
  12657. return;
  12658. }
  12659. returnErrorMsg("缺少必要的参数");
  12660. }
  12661. public void getExpressPostData()
  12662. {
  12663. string express = GetPostString("express");
  12664. if (!string.IsNullOrEmpty(express))
  12665. {
  12666. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12667. if (ceErpExpressInfo != null)
  12668. {
  12669. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12670. return;
  12671. }
  12672. }
  12673. returnErrorMsg("缺少必要的参数");
  12674. }
  12675. public void checkSupplierOrder()
  12676. {
  12677. string ctids = GetPostString("ctids");
  12678. if (ctids != null)
  12679. {
  12680. List<string> list = new List<string>();
  12681. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12682. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12683. for (int i = 0; i < dt.Rows.Count; i++)
  12684. {
  12685. DataRow row = dt.Rows[i];
  12686. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12687. {
  12688. continue;
  12689. }
  12690. list.Add(row["seller_memo"].ToString());
  12691. }
  12692. if (list.Count > 0)
  12693. {
  12694. 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, "点击下载按钮"));
  12695. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12696. return;
  12697. }
  12698. }
  12699. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12700. return;
  12701. }
  12702. public void addPersonId()
  12703. {
  12704. string tid = GetPostString("tid");
  12705. string personId = GetPostString("personId");
  12706. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12707. if (ceErpTrade != null)
  12708. {
  12709. ceErpTrade.receiver_zip = personId;
  12710. ceErpTrade.Update();
  12711. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12712. returnSuccessMsg("保存成功");
  12713. return;
  12714. }
  12715. returnErrorMsg("缺少必要的参数");
  12716. }
  12717. public void addDeliveryPaymant()
  12718. {
  12719. string tid = GetPostString("tid");
  12720. string paymant = GetPostString("paymant");
  12721. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12722. if (ceErpTrade != null)
  12723. {
  12724. if (!string.IsNullOrEmpty(paymant))
  12725. {
  12726. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12727. }
  12728. ceErpTrade.Update();
  12729. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12730. returnSuccessMsg("保存成功");
  12731. return;
  12732. }
  12733. returnErrorMsg("缺少必要的参数");
  12734. }
  12735. public void saveCellFile()
  12736. {
  12737. string tid = GetPostString("tid");
  12738. string ctid = GetPostString("ctid");
  12739. string urls = GetPostString("urls");
  12740. string type = GetPostString("type");
  12741. string del = GetPostString("del");
  12742. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12743. {
  12744. if ("1".Equals(del))
  12745. {
  12746. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12747. }
  12748. string[] list = urls.Split(',');
  12749. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12750. {
  12751. foreach (string item in list)
  12752. {
  12753. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12754. ceErpTradeCellFile.Create();
  12755. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12756. }
  12757. }
  12758. returnSuccessMsg("保存成功");
  12759. return;
  12760. }
  12761. returnErrorMsg("缺少必要的参数");
  12762. }
  12763. public void getCellFile()
  12764. {
  12765. string tid = GetPostString("tid");
  12766. string ctid = GetPostString("ctid");
  12767. string type = GetPostString("type");
  12768. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12769. {
  12770. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12771. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12772. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12773. return;
  12774. }
  12775. returnErrorMsg("缺少必要的参数");
  12776. }
  12777. public void delCellFile()
  12778. {
  12779. string id = GetPostString("id");
  12780. if (string.IsNullOrEmpty(id))
  12781. {
  12782. returnErrorMsg("缺少必要的参数");
  12783. return;
  12784. }
  12785. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12786. CeErpTradeCellFile.delByID(id);
  12787. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12788. returnSuccessMsg("保存成功");
  12789. }
  12790. public void getInvoiceOrder()
  12791. {
  12792. string tid = GetPostString("tid");
  12793. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12794. List<string> tids = new List<string>();
  12795. if (!string.IsNullOrEmpty(ceErpTrade.buyer_nick) && !string.IsNullOrEmpty(ceErpTrade.buyer_id))
  12796. {
  12797. 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);
  12798. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12799. foreach (DataRow dr in dt.Rows)
  12800. {
  12801. tids.Add("'" + dr["tid"].ToString() + "'");
  12802. }
  12803. }
  12804. else
  12805. {
  12806. tids.Add("'" + ceErpTrade.tid + "'");
  12807. }
  12808. DataTable cell_dt = new DataTable();
  12809. if (tids.Count > 0)
  12810. {
  12811. cell_dt = DbHelper.DbConn.ExecuteDataset(string.Format("SELECT * FROM [dbo].[CE_ErpTradeCell] WHERE tid in ({0});", string.Join(",", tids))).Tables[0];
  12812. }
  12813. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(cell_dt));
  12814. return;
  12815. }
  12816. }
  12817. }