sync.order.cs 654 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017
  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("YDaPXIhsKgw=");
  62. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\opp袋.xlsx");
  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\":\"RECEIPT\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1754976830000,\"deliveryType\":\"DUMMY\",\"discountFee\":0.0,\"flag\":\"YELLOW\",\"lines\":[{ \"mark2\":[\"DELIVERED\"],\"num\":1900,\"outerId\":\"\",\"payment\":19.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded///gw.alicdn.com/imgextra/i2/O1CN01MkKGcP1DAC83Qzv0g_!!6000000000175-2-tps-664-664.png\",\"platServiceFee\":0.0,\"price\":0.01,\"refOlId\":\"4680447879925908321\",\"refSkuId\":\"0\",\"refSpuId\":\"718974148282\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":0.01,\"singleFee\":0.01,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"SHIPPED\",\"title\":\"补差价专用\",\"totalFee\":19.0,\"totalPrice\":19.0,\"totalSellPrice\":19.0}],\"logisticsOrderNo\":\"0000\",\"mark2\":[],\"modifyTime\":1754979750000,\"openBuyerId\":\"AAH5RHraABkUZRPgSx37tfjU\",\"openBuyerNick\":\"w**\",\"openSellerNick\":\"琳19890725\",\"orderSource\":\"SYNC\",\"orderTime\":1754976823000,\"payTime\":1754976826000,\"payment\":19.0,\"platServiceFee\":0.0,\"posCode\":\"guliang\",\"posId\":598696,\"postFee\":0.0,\"props\":{ \"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0,\"logisticList\":[{ \"logisticNo\":\"0000\",\"logisticName\":\"VIRTUAL\"}]},\"receivedPayment\":0.0,\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"09ab2cbe3d9209cfa8b5e0c4727a01cf\",\"receiverState\":\"\",\"receiverTown\":\"\",\"refOid\":\"4680447879925908321\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"补差价:4680342074074908321-wangjie7409\",\"serviceFee\":0.0,\"shippingTime\":1754976827000,\"status\":\"SHIPPED\",\"totalFee\":19.0,\"totalPrice\":19.0,\"totalSellPrice\":19.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. List<string> lw = new List<string>();
  125. string tid = GetPostString("ctid");
  126. string date1 = GetPostString("date1");
  127. //12-1 修改
  128. string urgent = GetPostString("urgent");
  129. string back = GetPostString("back");
  130. string offlineSearch = GetPostString("offlineSearch");
  131. int paramsCount = 0;
  132. if (!string.IsNullOrWhiteSpace(urgent))
  133. {
  134. if (urgent.Equals("true"))
  135. {
  136. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  137. }
  138. }
  139. if (!string.IsNullOrWhiteSpace(back))
  140. {
  141. if (back.Equals("true"))
  142. {
  143. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  144. }
  145. }
  146. if (!string.IsNullOrWhiteSpace(offlineSearch))
  147. {
  148. if (offlineSearch.Equals("true"))
  149. {
  150. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  151. }
  152. }
  153. //end
  154. string date2 = GetPostString("date2");
  155. string buyernick = GetPostString("buyer_nick");
  156. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  157. {
  158. if (tid.Length <= 0 && buyernick.Length <= 0)
  159. {
  160. return;
  161. }
  162. }
  163. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  164. {
  165. if (tid.Length > 0)
  166. {
  167. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  168. if (ceErpTradeCell != null)
  169. {
  170. tid = ceErpTradeCell.tid;
  171. }
  172. List<string> select_tid = getTidByCtidMore(tid);
  173. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  174. }
  175. if (buyernick.Length > 0)
  176. {
  177. CeErpTrade ceErpTrade = CeErpTrade.GetByName(buyernick);
  178. if (ceErpTrade == null)
  179. {
  180. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  181. }
  182. else
  183. {
  184. lw.Add(string.Format("(buyer_id='{0}' or buyer_nick='{0}')", ceErpTrade.buyer_id, buyernick));
  185. }
  186. }
  187. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  188. if (dw.Length > 0)
  189. {
  190. lw.Add(dw);
  191. }
  192. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  193. {
  194. string usershop = CurrentUser.User.pemShop;
  195. lw.Add(string.Format("ShopId in ({0})", usershop));
  196. }
  197. }
  198. else
  199. {
  200. if (ex_psize == 0)
  201. {
  202. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  203. }
  204. if (PKey != "admin" && poscode != "SysAdmin")
  205. {
  206. string usershop = CurrentUser.User.pemShop;
  207. lw.Add(string.Format("ShopId in ({0})", usershop));
  208. paramsCount++;
  209. }
  210. }
  211. string uploaddate1 = GetPostString("uploaddate1");
  212. string uploaddate2 = GetPostString("uploaddate2");
  213. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  214. if (update.Length > 0) lw.Add(update);
  215. string deliverydate1 = GetPostString("deliverydate1");
  216. string deliverydate2 = GetPostString("deliverydate2");
  217. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  218. if (deliverydate.Length > 0)
  219. {
  220. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  221. };
  222. string shopname = GetPostString("shopname");
  223. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  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 backReason = GetPostString("backReason");
  245. if (backReason.Length > 0)
  246. {
  247. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  248. }
  249. string apdate1 = GetPostString("apdate1");
  250. string apdate2 = GetPostString("apdate2");
  251. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  252. if (dwap.Length > 0) lw.Add(dwap);
  253. string price1 = GetPostString("price1");
  254. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  255. string price2 = GetPostString("price2");
  256. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  257. string isoldcustomer = GetPostString("isoldcus");
  258. string spudata = GetPostString("spudata");
  259. if ("0".Equals(spudata))
  260. {
  261. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  262. }
  263. if ("1".Equals(spudata))
  264. {
  265. lw.Add(string.Format("spu_id <> ''"));
  266. }
  267. string finishdate1 = GetPostString("finishdate1");
  268. string finishdate2 = GetPostString("finishdate2");
  269. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  270. bool isFinish = false;
  271. if (finishdate.Length > 0)
  272. {
  273. lw.Add(finishdate);
  274. isFinish = true;
  275. paramsCount++;
  276. }
  277. if (isoldcustomer.Length > 0)
  278. {
  279. if ("2".Equals(isoldcustomer))
  280. {
  281. lw.Add(string.Format("VipCustomer=1"));
  282. }
  283. else
  284. {
  285. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  286. }
  287. }
  288. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  289. if (ex_psize > 0)
  290. {
  291. int UserID = CurrentUser.UserID;
  292. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  293. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  294. {
  295. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  296. }
  297. dStruct.Order = "pay_time desc";
  298. }
  299. string isNew = GetPostString("isNew");
  300. if (isNew == "true")
  301. {
  302. lw.Add(string.Format("IsNew = {0}", 1));
  303. }
  304. string overtime = GetPostString("overtime");
  305. if (overtime == "1")
  306. {
  307. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  308. }
  309. String usePost = CurrentUser.UserPost.Post.Code;
  310. if (usePost.Equals("Operation") == true)
  311. {
  312. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  313. }
  314. else
  315. {
  316. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  317. }
  318. //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";
  319. if (dStruct.PageSize == 100000)
  320. {
  321. dStruct.Order = "";
  322. }
  323. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  324. DataTable dt = null;
  325. string tablename = "view_orderlist";
  326. if (isFinish)
  327. {
  328. tablename = "view_orderlist_end";
  329. }
  330. dt = WebCache.GetData(tablename, dStruct);
  331. if (dt != null && dt.Rows.Count > 0)
  332. {
  333. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  334. foreach (DataRow dr in dt.Rows)
  335. {
  336. try
  337. {
  338. if (dr["refund_fees"] != null)
  339. {
  340. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  341. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  342. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  343. if (payment == refund_fees)
  344. {
  345. dr["refund_fees"] = Math.Round(refund_fees, 2);
  346. }
  347. else if (refund_fees == total_fee)
  348. {
  349. dr["refund_fees"] = payment;
  350. }
  351. else
  352. {
  353. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  354. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  355. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  356. }
  357. }
  358. // 对象操作
  359. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  360. ceErpTradeCell.ctid = dr["ctid"].ToString();
  361. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  362. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  363. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  364. if (dStruct.PageSize != 100000)
  365. {
  366. if (dr["DispatchSort"].ToString() == "2")
  367. {
  368. dr["gongchuang"] = 200;
  369. }
  370. else if ("外协".Equals(dr["ToType"].ToString()))
  371. {
  372. dr["gongchuang"] = 200;
  373. }
  374. else if ("内部".Equals(dr["ToType"].ToString()))
  375. {
  376. dr["gongchuang"] = -1;
  377. }
  378. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  379. {
  380. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  381. dr["gongchuang"] = response.code;
  382. }
  383. }
  384. }
  385. catch (NullReferenceException ex)
  386. {
  387. // 处理空引用异常
  388. dr["refund_fees"] = "0.00";
  389. }
  390. }
  391. }
  392. writeGridDataTableJson(dStruct.TotalCount, dt);
  393. }
  394. public void get_erp_orderlist_sumprice()
  395. {
  396. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  397. return;
  398. List<string> lw = new List<string>();
  399. string tid = GetPostString("ctid");
  400. string date1 = GetPostString("date1");
  401. string date2 = GetPostString("date2");
  402. if (tid.Length > 0 || date1.Length > 0)
  403. {
  404. lw.Add(string.Format("ctid like '%{0}%'", tid));
  405. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  406. if (dw.Length > 0) lw.Add(dw);
  407. }
  408. else
  409. {
  410. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  411. }
  412. string shopname = GetPostString("shopname");
  413. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  414. string buyernick = GetPostString("buyer_nick");
  415. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  416. string customer = GetPostString("customer");
  417. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  418. string design = GetPostString("design");
  419. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  420. string orderState = GetPostString("orderState");
  421. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  422. string address = GetPostString("address");
  423. 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));
  424. string sellermemo = GetPostString("seller_memo");
  425. if (sellermemo.Length > 0)
  426. {
  427. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  428. }
  429. string apdate1 = GetPostString("apdate1");
  430. string apdate2 = GetPostString("apdate2");
  431. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  432. if (dwap.Length > 0) lw.Add(dwap);
  433. string price1 = GetPostString("price1");
  434. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  435. string price2 = GetPostString("price2");
  436. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  437. string isoldcustomer = GetPostString("isoldcus");
  438. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  439. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  440. if (PKey != "admin")
  441. {
  442. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  443. lw.Add(string.Format("shopId in ({0})", usershop));
  444. }
  445. //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";
  446. string mainWhere = string.Join(" and ", lw.ToArray());
  447. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  448. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  449. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  450. decimal total = 0;
  451. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  452. {
  453. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  454. }
  455. var res = new
  456. {
  457. data = total
  458. };
  459. string ro_jsond = JsonConvert.SerializeObject(res);
  460. returnSuccess(ro_jsond);
  461. return;
  462. }
  463. public void get_erp_CustomerServiceGather()
  464. {
  465. string userWhere = "", orderWhere = "";
  466. List<string> lw = new List<string>();
  467. string customer = GetPostString("customer");
  468. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  469. string shopname = GetPostString("shopname");
  470. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  471. string date1 = GetPostString("date1");
  472. string date2 = GetPostString("date2");
  473. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  474. if (dw.Length > 0) lw.Add(dw);
  475. orderWhere = string.Join(" and ", lw.ToArray());
  476. 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 " +
  477. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  478. "left join " +
  479. "( " +
  480. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  481. ") as b on a.ID = b.CustomerUserId " +
  482. "left join " +
  483. "( " +
  484. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  485. ") as d on a.ID = d.CustomerUserId " +
  486. "left join " +
  487. "( " +
  488. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  489. ") as e on a.ID = e.CustomerUserId " +
  490. "left join " +
  491. "( " +
  492. " select CustomerUserId, RefundCount, RefundSum from " +
  493. " ( " +
  494. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  495. " from CE_ErpTradeRefund a " +
  496. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  497. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  498. " group by CustomerUserId " +
  499. " ) as a " +
  500. ") as f on a.ID = f.CustomerUserId " +
  501. "where a.PostCode = 'CustomerService'",
  502. userWhere, orderWhere);
  503. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  504. writeGridDataTableJson(dt.Rows.Count, dt);
  505. //writeGridDataTableJson(dt.Rows.Count, dt);
  506. }
  507. //设计汇总
  508. public void get_erp_DesignerGather()
  509. {
  510. string userWhere = "", orderWhere = "";
  511. List<string> lw = new List<string>();
  512. string Designer = GetPostString("designer");
  513. int org = GetPostInt("org");
  514. if (Designer.Length > 0)
  515. {
  516. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  517. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  518. }
  519. else if (org > 0)
  520. {
  521. userWhere = string.Format(" where OrgID ={0}", org);
  522. }
  523. string shopname = GetPostString("shopname");
  524. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  525. string state = GetPostString("state");
  526. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  527. string OrderArea = GetPostString("order_area");
  528. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  529. string date1 = GetPostString("date1");
  530. string date2 = GetPostString("date2");
  531. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  532. if (dw.Length > 0) lw.Add(dw);
  533. string UpDate1 = GetPostString("UpDate1");
  534. string UpDate2 = GetPostString("UpDate2");
  535. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  536. if (dw.Length > 0) lw.Add(dw);
  537. orderWhere = string.Join(" and ", lw.ToArray());
  538. 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 (" +
  539. "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 " +
  540. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  541. "left join " +
  542. "( " +
  543. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  544. ") as b on a.ID = b.DesignUserId " +
  545. "left join " +
  546. "( " +
  547. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  548. ") as d on a.ID = d.DesignUserId " +
  549. "left join " +
  550. "( " +
  551. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  552. ") as e on a.ID = e.DesignUserId " +
  553. "left join " +
  554. "( " +
  555. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  556. ") as g on a.ID = g.DesignUserId " +
  557. "left join " +
  558. "( " +
  559. " select CustomerUserId, RefundCount, RefundSum from " +
  560. " ( " +
  561. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  562. " from CE_ErpTradeRefund a " +
  563. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  564. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  565. " group by CustomerUserId " +
  566. " ) as a " +
  567. ") as f on a.ID = f.CustomerUserId " +
  568. "where a.PostCode = 'Designer') as z",
  569. userWhere, orderWhere);
  570. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  571. writeGridDataTableJson(dt.Rows.Count, dt);
  572. }
  573. //删除tradecell的订单
  574. public void del_erp_cellorder()
  575. {
  576. if (UrlPostParmsCheck("ctid"))
  577. {
  578. string eid = GetPostString("ctid");
  579. CeErpTradeCell.DelByCtid(eid);
  580. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  581. returnSuccessMsg("删除成功");
  582. }
  583. }
  584. public void clear_erp_refundstate()
  585. {
  586. if (UrlPostParmsCheck("ids"))
  587. {
  588. string eids = GetPostString("ids");
  589. string[] ctidList = eids.Split(',');
  590. foreach (string ctid in ctidList)
  591. {
  592. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  593. if (entity != null)
  594. {
  595. entity.IsRefund = 0;
  596. entity.Update();
  597. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  598. }
  599. else
  600. continue;
  601. }
  602. returnSuccessMsg("操作成功");
  603. return;
  604. }
  605. returnErrorMsg("缺少必要参数");
  606. }
  607. public void set_erp_urgency()
  608. {
  609. if (UrlPostParmsCheck("ctid"))
  610. {
  611. string eid = GetPostString("ctid");
  612. CeErpTradeCell entity = null;
  613. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  614. if (entity != null)
  615. {
  616. double prices = commonHelper.calculationPrice(entity);
  617. if (prices <= 100)
  618. {
  619. returnErrorMsg("此订单金额不足100元,无法加急。");
  620. return;
  621. }
  622. string utime = GetPostString("urgencytime");
  623. if (utime.Length > 0)
  624. {
  625. entity.UrgencyTime = Convert.ToDateTime(utime);
  626. }
  627. else
  628. {
  629. returnErrorMsg("请选择加急时间");
  630. return;
  631. }
  632. if (entity.OrderState <= 4)
  633. {
  634. //entity.seller_memo = entity.seller_memo + "-加急";
  635. string smemo = entity.seller_memo;
  636. int kindex = smemo.IndexOf(")");
  637. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  638. if (lastoneStr != "-")
  639. {
  640. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  641. }
  642. string prememo = smemo.Substring(0, kindex + 2);
  643. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  644. int lastkindex = lastmemo.IndexOf("(");
  645. DateTime urgtime = Convert.ToDateTime(utime);
  646. string newlastmemo = "";
  647. if (lastkindex == 0)
  648. {
  649. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  650. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  651. }
  652. else
  653. {
  654. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  655. }
  656. entity.seller_memo = prememo + newlastmemo;
  657. }
  658. entity.IsUrgency = true;
  659. entity.UpdateTime = DateTime.Now;
  660. entity.Update();
  661. ApiVo apiVo = new ApiVo();
  662. apiVo.orderNumber = entity.ctid;
  663. apiVo.actionName = "changeDesign";
  664. apiVo.orderRemarks = entity.seller_memo;
  665. apiVo.remarkSign = 3;
  666. designHelper.API_WorkCore(apiVo); //changeDesign
  667. CeErpSukuraData.createInfo(entity.ctid, 7);
  668. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  669. returnSuccessMsg("设置成功!");
  670. return;
  671. }
  672. returnErrorMsg("找不到记录");
  673. }
  674. }
  675. public void set_erp_reset()
  676. {
  677. if (UrlPostParmsCheck("ctid"))
  678. {
  679. string eid = GetPostString("ctid");
  680. CeErpTradeCell entity = null;
  681. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  682. if (entity != null)
  683. {
  684. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  685. {
  686. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  687. {
  688. returnErrorMsg("财务要求已下单已发货无法重置");
  689. return;
  690. }
  691. }
  692. entity.IsUrgency = false;
  693. entity.seller_memo = "";
  694. entity.OtherMemo = "";
  695. entity.OrderState = 0;
  696. entity.IsReturn = 0;
  697. //entity.IsRefund = 0;
  698. entity.MemoOpt = 0;
  699. entity.AfterSaleState = 0;
  700. entity.AfterSaleResponsible = "";
  701. entity.AfterSaleUserId = 0;
  702. entity.IsNeedBill = 0;
  703. entity.CustomerUserId = 0;
  704. entity.DesignUserId = 0;
  705. entity.SupplierId = 0;
  706. entity.PlaceUserId = 0;
  707. entity.ptid = "";
  708. entity.IsSample = 0;
  709. entity.IsXianHuo = 0;
  710. entity.isDianziOrder = 0;
  711. entity.DispatchSort = 0;
  712. entity.IsVerifyToSupplier = false;
  713. entity.FinishPlaceTime = null;
  714. entity.Update();
  715. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  716. if (trade != null)
  717. {
  718. trade.seller_memo = "";
  719. trade.Update();
  720. }
  721. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  722. returnSuccessMsg("重置成功!");
  723. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  724. if (desginBill != null)
  725. {
  726. desginBill.isDel = 1;
  727. desginBill.Update();
  728. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  729. }
  730. ApiVo apiVo = new ApiVo();
  731. apiVo.orderNumber = entity.ctid;
  732. apiVo.actionName = "resetDesign";
  733. designHelper.API_WorkCore(apiVo);//resetDesign
  734. return;
  735. }
  736. returnErrorMsg("找不到记录");
  737. }
  738. }
  739. public void save_erp_sellermemo()
  740. {
  741. if (UrlPostParmsCheck("ctid"))
  742. {
  743. string ctid = GetPostString("ctid");
  744. CeErpTradeCell entity = null;
  745. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  746. if (entity != null)
  747. {
  748. string memo = GetPostString("seller_memo");
  749. memo = memo.Replace(" ", "");
  750. if (memo.Contains("补差"))
  751. {
  752. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  753. return;
  754. }
  755. List<string> bitList = new List<string>
  756. {
  757. "\\","/",":","*","?", "\"","<" ,">","|"
  758. };
  759. bool isIn = false;
  760. foreach (string bit in bitList)
  761. {
  762. if (memo.Contains(bit))
  763. {
  764. isIn = true;
  765. }
  766. }
  767. if (isIn)
  768. {
  769. returnErrorMsg("不能使用 一些符合作为文件名");
  770. return;
  771. }
  772. if (entity.seller_memo != memo)
  773. {
  774. if (entity.IsSample == 2)
  775. {
  776. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  777. return;
  778. }
  779. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  780. {
  781. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  782. {
  783. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  784. return;
  785. }
  786. /*if (CurrentUser.UserPost.Post.Code != "Place")
  787. {
  788. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  789. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  790. {
  791. returnErrorMsg("售前系统订单无法再此修改!");
  792. return;
  793. }
  794. }*/
  795. }
  796. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  797. }
  798. commonHelper.getCytPrice(entity);
  799. int memoopt = GetPostInt("MemoOpt");
  800. Boolean ismemoopt = false;
  801. if (memoopt > 0)
  802. {
  803. string stropt = "";
  804. if (memoopt == 1)
  805. {
  806. stropt = "“改稿”";
  807. ismemoopt = true;
  808. }
  809. else if (memoopt == 2)
  810. {
  811. stropt = "“定稿”";
  812. }
  813. else if (memoopt == 3)
  814. {
  815. stropt = "“查货”";
  816. CeErpSukuraData.createInfo(entity.ctid, 6);
  817. }
  818. entity.MemoOpt = Convert.ToInt32(memoopt);
  819. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  820. }
  821. if (entity.OrderState < 5)
  822. {
  823. memo = memo.Replace("(", "(");
  824. memo = memo.Replace(")", ")");
  825. }
  826. /* if (entity.OrderState < 3)
  827. {
  828. entity.DispatchSort = 0;
  829. }*/
  830. entity.seller_memo = memo;
  831. entity.UpdateTime = DateTime.Now;
  832. entity.Update();
  833. ApiVo apiVo = new ApiVo();
  834. apiVo.orderNumber = entity.ctid;
  835. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  836. apiVo.orderRemarks = memo;
  837. apiVo.remarkSign = memoopt;
  838. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  839. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  840. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  841. {
  842. dataHelper.api_orderBack(entity.ctid, "0", "");
  843. }
  844. if (entity.seller_memo.Contains("改稿"))
  845. {
  846. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  847. }
  848. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  849. returnSuccessMsg("保存成功!");
  850. return;
  851. }
  852. returnErrorMsg("找不到记录");
  853. }
  854. }
  855. public void ins_erp_checkorder()
  856. {
  857. if (UrlPostParmsCheck("ctid"))
  858. {
  859. string ctid = GetPostString("ctid");
  860. CeErpTradeCell entity = null;
  861. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  862. if (entity != null)
  863. {
  864. if (entity.OrderState < 6)
  865. {
  866. returnErrorMsg("下单完成后才可查货");
  867. return;
  868. }
  869. /*if (entity.OrderState > 6)
  870. {
  871. returnErrorMsg("订单已发货");
  872. return;
  873. }*/
  874. if (entity.FinishPlaceTime != null)
  875. {
  876. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  877. {
  878. returnErrorMsg("下单时间不足,无法查货");
  879. return;
  880. }
  881. }
  882. entity.MemoOpt = 3;
  883. entity.CheckOrderTime = DateTime.Now;
  884. entity.UpdateTime = DateTime.Now;
  885. entity.Update();
  886. CeErpSukuraData.createInfo(entity.ctid, 6);
  887. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  888. returnSuccessMsg("操作成功!");
  889. return;
  890. }
  891. returnErrorMsg("找不到记录");
  892. }
  893. }
  894. public void save_erp_othermemo()
  895. {
  896. if (UrlPostParmsCheck("ctid"))
  897. {
  898. string ctid = GetPostString("ctid");
  899. CeErpTradeCell entity = null;
  900. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  901. if (entity != null)
  902. {
  903. entity.OtherMemo = GetPostString("otherMemo");
  904. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  905. {
  906. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  907. StringBuilder sql = new StringBuilder();
  908. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  909. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  910. if (dt != null && dt.Rows.Count > 0)
  911. {
  912. foreach (DataRow dr in dt.Rows)
  913. {
  914. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  915. {
  916. //品类一直
  917. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  918. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  919. if (ceErpSampleCustomer == null)
  920. {
  921. ceErpSampleCustomer = new CeErpSampleCustomer();
  922. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  923. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  924. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  925. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  926. ceErpSampleCustomer.shopId = entity.ShopId;
  927. }
  928. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  929. ceErpSampleCustomer.lastTid = entity.tid;
  930. if (ceErpSampleCustomer.ID > 0)
  931. {
  932. ceErpSampleCustomer.Update();
  933. }
  934. else
  935. {
  936. ceErpSampleCustomer.Create();
  937. }
  938. }
  939. }
  940. }
  941. }
  942. //if (entity.IsOldCustomer == 1)
  943. //{
  944. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  945. //{
  946. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  947. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  948. //}
  949. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  950. //{
  951. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  952. // {
  953. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  954. // {
  955. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  956. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  957. // }
  958. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  959. // {
  960. // entity.OrderState = 2;
  961. // entity.DesignUserId = 0;
  962. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  963. // }
  964. // else
  965. // {
  966. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  967. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  968. // }
  969. // }
  970. //}
  971. //}
  972. entity.UpdateTime = DateTime.Now;
  973. entity.Update();
  974. returnSuccessMsg("保存成功!");
  975. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  976. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  977. if (entity.OtherMemo.Contains("改稿"))
  978. {
  979. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  980. }
  981. return;
  982. }
  983. returnErrorMsg("找不到记录");
  984. }
  985. }
  986. public void save_erp_customermemo()
  987. {
  988. if (UrlPostParmsCheck("ctid"))
  989. {
  990. string ctid = GetPostString("ctid");
  991. CeErpTradeCell entity = null;
  992. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  993. if (entity != null)
  994. {
  995. entity.UpdateTime = DateTime.Now;
  996. entity.CustomerMemo = GetPostString("CustomerMemo");
  997. entity.Update();
  998. ApiVo apiVo = new ApiVo();
  999. apiVo.orderNumber = entity.ctid;
  1000. apiVo.actionName = "followRemarks";
  1001. apiVo.orderRemarks = entity.CustomerMemo;
  1002. designHelper.API_WorkCore(apiVo);//followRemarks
  1003. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1004. returnSuccessMsg("保存成功!");
  1005. return;
  1006. }
  1007. returnErrorMsg("找不到记录");
  1008. }
  1009. }
  1010. public void upd_erp_addmemotag()
  1011. {
  1012. if (UrlPostParmsCheck("ctid"))
  1013. {
  1014. ;
  1015. string eid = GetPostString("ctid");
  1016. string sfTagstr = GetPostString("memotag");
  1017. CeErpTradeCell entity = null;
  1018. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1019. if (entity != null)
  1020. {
  1021. ApiVo apiVo = new ApiVo();
  1022. if (entity.OrderState == 0)
  1023. {
  1024. returnErrorMsg("请先领单");
  1025. return;
  1026. }
  1027. //撤销顺丰
  1028. if (sfTagstr == "撤销顺丰")
  1029. {
  1030. entity.IsSF = 0;
  1031. string reMsg = "";
  1032. string oldmemo = entity.seller_memo;
  1033. if (entity.OrderState < 5)
  1034. {
  1035. oldmemo = oldmemo.Replace("顺丰到付", "");
  1036. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1037. entity.seller_memo = oldmemo;
  1038. }
  1039. else
  1040. {
  1041. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1042. {
  1043. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1044. }
  1045. }
  1046. entity.Update();
  1047. apiVo.orderNumber = entity.ctid;
  1048. apiVo.actionName = "orderRemarks";
  1049. apiVo.orderRemarks = entity.seller_memo;
  1050. apiVo.isSf = entity.IsSF.ToString();
  1051. designHelper.API_WorkCore(apiVo);//orderRemarks
  1052. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1053. returnSuccessMsg("撤销成功!" + reMsg);
  1054. return;
  1055. }
  1056. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1057. {
  1058. //string oldmemo = entity.seller_memo;
  1059. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1060. string sfStr = GetPostString("memotag");
  1061. string smemo = entity.seller_memo;
  1062. int kindex = smemo.IndexOf(")");
  1063. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1064. if (lastoneStr != "-")
  1065. {
  1066. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1067. }
  1068. string prememo = smemo.Substring(0, kindex + 2);
  1069. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1070. int lastkindex = lastmemo.IndexOf("(");
  1071. string newlastmemo = "";
  1072. if (lastkindex == 0)
  1073. {
  1074. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1075. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1076. }
  1077. else
  1078. {
  1079. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1080. }
  1081. entity.seller_memo = prememo + newlastmemo;
  1082. }
  1083. string sfTagMSg = "";
  1084. if (sfTagstr == "顺丰寄付")
  1085. {
  1086. entity.IsSF = 1;
  1087. sfTagMSg = "顺丰寄付";
  1088. }
  1089. else if (sfTagstr == "顺丰到付")
  1090. {
  1091. entity.IsSF = 2;
  1092. sfTagMSg = "顺丰到付";
  1093. }
  1094. entity.Update();
  1095. apiVo = new ApiVo();
  1096. apiVo.orderNumber = entity.ctid;
  1097. apiVo.actionName = "orderRemarks";
  1098. apiVo.orderRemarks = entity.seller_memo;
  1099. apiVo.isSf = entity.IsSF.ToString();
  1100. designHelper.API_WorkCore(apiVo);//orderRemarks
  1101. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1102. returnSuccessMsg("标记成功!");
  1103. return;
  1104. }
  1105. returnErrorMsg("找不到记录");
  1106. }
  1107. }
  1108. public void upd_erp_ordertag()
  1109. {
  1110. if (UrlPostParmsCheck("ctid"))
  1111. {
  1112. string eid = GetPostString("ctid");
  1113. CeErpTradeCell entity = null;
  1114. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1115. if (entity != null)
  1116. {
  1117. int tag = GetPostInt("wechattag");
  1118. //if(tag==4 && entity.IsSample == 2)
  1119. //{
  1120. // returnErrorMsg("补差价单不能标记微信单");
  1121. // return;
  1122. //}
  1123. entity.wechatTag = tag;
  1124. entity.Update();
  1125. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1126. if (tag == 1)
  1127. {
  1128. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1129. if (cash == null)
  1130. {
  1131. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1132. cash = new CeErpReturnCash();
  1133. cash.tid = entity.tid;
  1134. cash.seller_nick = main.seller_nick;
  1135. cash.payment = trade.payment;
  1136. cash.buyer_nick = main.buyer_nick;
  1137. cash.cashstate = 0;
  1138. cash.rtype = "微信返现";
  1139. cash.returnprice = 0;
  1140. cash.created = DateTime.Now;
  1141. cash.con = "订单标记微信单";
  1142. cash.img = "";
  1143. cash.applyuserid = CurrentUser.UserID;
  1144. cash.Create();
  1145. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1146. }
  1147. else
  1148. {
  1149. cash.cashstate = 0;
  1150. cash.Update();
  1151. }
  1152. CeErpSukuraData.createInfo(entity.ctid, 9);
  1153. }
  1154. else if (tag == 2)
  1155. {
  1156. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1157. if (cash == null)
  1158. {
  1159. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1160. cash = new CeErpReturnCash();
  1161. cash.tid = entity.tid;
  1162. cash.seller_nick = main.seller_nick;
  1163. cash.payment = trade.payment;
  1164. cash.buyer_nick = main.buyer_nick;
  1165. cash.cashstate = 0;
  1166. cash.rtype = "推购返现";
  1167. cash.returnprice = 5;
  1168. cash.created = DateTime.Now;
  1169. cash.con = "订单标记推购单";
  1170. cash.img = "";
  1171. cash.applyuserid = CurrentUser.UserID;
  1172. cash.Create();
  1173. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1174. }
  1175. else
  1176. {
  1177. cash.cashstate = 0;
  1178. cash.Update();
  1179. }
  1180. CeErpSukuraData.createInfo(entity.ctid, 9);
  1181. }
  1182. else if (tag == 3)
  1183. {
  1184. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1185. if (pers == null)
  1186. {
  1187. pers = new CeErpPersuade();
  1188. pers.ctid = entity.ctid;
  1189. pers.pstate = 0;
  1190. pers.created = DateTime.Now;
  1191. pers.applyuserid = CurrentUser.UserID;
  1192. pers.Create();
  1193. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1194. }
  1195. else
  1196. {
  1197. pers.pstate = 0;
  1198. pers.Update();
  1199. }
  1200. }
  1201. else if (tag == 4 || tag == 5)
  1202. {
  1203. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1204. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1205. if (pers == null)
  1206. {
  1207. pers = CeErpStayGoods.GetByTid(entity.tid);
  1208. }
  1209. if (pers == null)
  1210. {
  1211. pers = new CeErpStayGoods();
  1212. pers.t_id = entity.tid;
  1213. pers.ctid = entity.ctid;
  1214. pers.status = "待审核";
  1215. pers.audit_type = 0;
  1216. if (tag == 4)
  1217. {
  1218. pers.stay_type = "微信推购";
  1219. }
  1220. else
  1221. {
  1222. pers.stay_type = "旺旺推购";
  1223. }
  1224. if (entity.IsXianHuo == 0)
  1225. {
  1226. pers.product_id = entity.ProductId;
  1227. }
  1228. pers.wangwang = main.buyer_nick;
  1229. pers.shop_name = main.seller_nick;
  1230. pers.creata_time = DateTime.Now;
  1231. pers.create_u_id = CurrentUser.UserID;
  1232. pers.create_u_name = CurrentUser.UserName;
  1233. pers.Create();
  1234. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1235. }
  1236. else
  1237. {
  1238. pers.ctid = entity.ctid;
  1239. pers.audit_type = 0;
  1240. pers.Update();
  1241. }
  1242. CeErpSukuraData.createInfo(entity.ctid, 10);
  1243. }
  1244. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1245. returnSuccessMsg("标记成功!");
  1246. return;
  1247. }
  1248. returnErrorMsg("找不到记录");
  1249. }
  1250. }
  1251. public void upd_erp_ordertag_cancel()
  1252. {
  1253. if (UrlPostParmsCheck("ctid"))
  1254. {
  1255. string eid = GetPostString("ctid");
  1256. CeErpTradeCell entity = null;
  1257. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1258. if (entity != null)
  1259. {
  1260. entity.wechatTag = 0;
  1261. entity.Update();
  1262. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1263. if (pers != null)
  1264. {
  1265. pers.status = "取消推购";
  1266. pers.audit_type = 3;
  1267. pers.Update();
  1268. }
  1269. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1270. returnSuccessMsg("标记成功!");
  1271. return;
  1272. }
  1273. returnErrorMsg("找不到记录");
  1274. }
  1275. }
  1276. public void upd_erp_addweichattag()
  1277. {
  1278. if (UrlPostParmsCheck("ctid"))
  1279. {
  1280. ;
  1281. string eid = GetPostString("ctid");
  1282. CeErpTradeCell entity = null;
  1283. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1284. if (entity != null)
  1285. {
  1286. if (entity.IsAddWechat > 0)
  1287. {
  1288. returnErrorMsg("此单已经标记过了");
  1289. return;
  1290. }
  1291. 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);
  1292. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1293. if (dt.Rows.Count > 0)
  1294. {
  1295. entity.IsAddWechat = 2;
  1296. }
  1297. else
  1298. {
  1299. entity.IsAddWechat = 1;
  1300. }
  1301. entity.Update();
  1302. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1303. returnSuccessMsg("标记成功!");
  1304. return;
  1305. }
  1306. returnErrorMsg("找不到记录");
  1307. }
  1308. }
  1309. public void upd_erp_getmyorder()
  1310. {
  1311. if (UrlPostParmsCheck("ctid"))
  1312. {
  1313. string eid = GetPostString("ctid");
  1314. CeErpTradeCell entity = null;
  1315. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1316. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1317. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1318. {
  1319. returnErrorMsg("台湾客户需填写身份证号!");
  1320. return;
  1321. }
  1322. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1323. {
  1324. returnErrorMsg("偏远地区需要填写物流费!");
  1325. return;
  1326. }
  1327. if (entity != null)
  1328. {
  1329. if (entity.ctid.IndexOf("C") != -1)
  1330. {
  1331. StringBuilder sql = new StringBuilder();
  1332. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1333. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1334. if (dt.Rows.Count > 0)
  1335. {
  1336. decimal total = 0;
  1337. foreach (DataRow dr in dt.Rows)
  1338. {
  1339. total += Convert.ToDecimal(dr["payment"]);
  1340. }
  1341. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1342. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1343. {
  1344. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1345. return;
  1346. }
  1347. }
  1348. }
  1349. if (entity.OrderState == -1)
  1350. {
  1351. returnErrorMsg("待审核订单无法领取!");
  1352. return;
  1353. }
  1354. entity.CustomerUserId = CurrentUser.UserID;
  1355. if (entity.OrderState < 2)
  1356. {
  1357. entity.OrderState = 2;
  1358. if (entity.ShopId != 0)
  1359. {
  1360. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1361. }
  1362. }
  1363. entity.UpdateTime = DateTime.Now;
  1364. entity.Update();
  1365. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1366. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1367. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1368. {
  1369. dataHelper.api_orderBack(entity.ctid, "0", "");
  1370. }
  1371. returnSuccessMsg("领单成功!");
  1372. return;
  1373. }
  1374. returnErrorMsg("找不到记录");
  1375. }
  1376. }
  1377. public void getmyorder_from_init()
  1378. {
  1379. if (UrlPostParmsCheck("ctid"))
  1380. {
  1381. string eid = GetPostString("ctid");
  1382. CeErpTradeCell entity = null;
  1383. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1384. if (entity != null)
  1385. {
  1386. string sellerMemo = GetPostString("sellerMemo");
  1387. if (sellerMemo.Length > 0)
  1388. {
  1389. entity.seller_memo = sellerMemo;
  1390. }
  1391. string oterhMemo = GetPostString("otherMemo");
  1392. if (oterhMemo.Length > 0)
  1393. {
  1394. entity.OtherMemo = oterhMemo;
  1395. }
  1396. int urg = GetPostInt("urgency");
  1397. entity.IsUrgency = (urg == 1 ? true : false);
  1398. int wechat = GetPostInt("wechat");
  1399. int command = GetPostInt("command");
  1400. if (wechat == 1)
  1401. {
  1402. entity.wechatTag = 1;
  1403. }
  1404. if (command == 1)
  1405. {
  1406. entity.wechatTag = 2;
  1407. }
  1408. string pPro = GetPostString("pprofession");
  1409. if (pPro.Length > 0)
  1410. {
  1411. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1412. string spro = GetPostString("profession");
  1413. if (spro.Length > 0)
  1414. {
  1415. entity.ProfessionId = Convert.ToInt32(spro);
  1416. }
  1417. }
  1418. string proId = GetPostString("productId");
  1419. if (proId.Length > 0)
  1420. {
  1421. entity.ProductId = Convert.ToInt32(proId);
  1422. }
  1423. entity.Material = GetPostString("material");
  1424. entity.Craft = GetPostString("craft");
  1425. entity.CustomerUserId = CurrentUser.UserID;
  1426. if (entity.OrderState < 2)
  1427. {
  1428. entity.OrderState = 2;
  1429. if (entity.ShopId != 0)
  1430. {
  1431. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1432. }
  1433. }
  1434. entity.Update();
  1435. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1436. returnSuccessMsg("领单成功!");
  1437. return;
  1438. }
  1439. returnErrorMsg("找不到记录");
  1440. }
  1441. }
  1442. public void upd_erp_setrelationorder()
  1443. {
  1444. if (UrlPostParmsCheck("ctid"))
  1445. {
  1446. ;
  1447. string eid = GetPostString("ctid");
  1448. string ftid = GetPostString("ftid");
  1449. CeErpTradeCell entity = null;
  1450. CeErpTradeCell fentity = null;
  1451. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1452. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1453. if (fentity == null)
  1454. {
  1455. returnErrorMsg("找不到关联的主订单");
  1456. return;
  1457. }
  1458. if (entity != null)
  1459. {
  1460. if (entity.OrderState >= 5)
  1461. {
  1462. returnErrorMsg("本单已经设计完成无法关联");
  1463. return;
  1464. }
  1465. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1466. {
  1467. returnErrorMsg("线下单续审核后才能关联!");
  1468. return;
  1469. }
  1470. entity.ptid = ftid;
  1471. entity.OrderState = fentity.OrderState;
  1472. //entity.status = fentity.status;
  1473. entity.CustomerUserId = fentity.CustomerUserId;
  1474. entity.DesignUserId = fentity.DesignUserId;
  1475. entity.seller_memo = "补差价单:" + ftid;
  1476. entity.IsSample = 2;
  1477. entity.Update();
  1478. ApiVo apiVo = new ApiVo();
  1479. apiVo.orderNumber = ftid;
  1480. apiVo.payment = entity.payment;
  1481. apiVo.actionName = "repairDesign";
  1482. designHelper.API_WorkCore(apiVo);//repairDesign
  1483. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1484. returnSuccessMsg("关联成功!");
  1485. return;
  1486. }
  1487. else
  1488. returnErrorMsg("找不到记录");
  1489. }
  1490. }
  1491. public void download_erp_neworder()
  1492. {
  1493. string seller = GetPostString("seller_nick");
  1494. string tid = GetPostString("tid");
  1495. if (seller.Length <= 0 || tid.Length <= 0)
  1496. {
  1497. returnErrorMsg("数据错误");
  1498. }
  1499. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1500. //{
  1501. // returnErrorMsg("找不到店铺Sessionkey");
  1502. //}
  1503. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1504. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1505. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1506. if (res.IndexOf("refOid") == -1)
  1507. {
  1508. returnErrorMsg("下载订单数据失败");
  1509. return;
  1510. }
  1511. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1512. returnSuccessMsg("下载完成");
  1513. //tmcHelper.createNewOrder(res);
  1514. //CeErpTrade entr = null;
  1515. //entr = CeErpTrade.Get(tid);
  1516. //if (entr != null)
  1517. //{
  1518. // returnSuccess("下载成功");
  1519. // //下载成功之后,Cell表生成对应的订单;
  1520. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1521. //}
  1522. //else
  1523. //{
  1524. // returnErrorMsg("下载失败或者创建订单失败");
  1525. //}
  1526. }
  1527. public void set_erp_atersale()
  1528. {
  1529. if (UrlPostParmsCheck("ctid"))
  1530. {
  1531. string eid = GetPostString("ctid");
  1532. string reason = GetPostString("AfterSaleReason");
  1533. CeErpTradeCell entity = null;
  1534. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1535. if (entity != null)
  1536. {
  1537. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1538. {
  1539. returnErrorMsg("此订单已经在售后");
  1540. return;
  1541. }*/
  1542. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1543. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1544. entity.AfterSaleTime = DateTime.Now;
  1545. entity.HandleTime = null;
  1546. entity.Update();
  1547. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1548. returnSuccessMsg("转售后成功!");
  1549. return;
  1550. }
  1551. returnErrorMsg("找不到记录");
  1552. }
  1553. }
  1554. public void set_erp_withdraw()
  1555. {
  1556. if (UrlPostParmsCheck("ctid"))
  1557. {
  1558. try
  1559. {
  1560. string eid = GetPostString("ctid");//商品id
  1561. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1562. CeWithdraw ceWithdrawSelect = null;
  1563. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1564. if (ceWithdrawSelect != null)
  1565. {
  1566. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1567. {
  1568. ceWithdrawSelect.status = -1;
  1569. ceWithdrawSelect.Update();
  1570. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1571. returnSuccessMsg("重新发起审核成功");
  1572. return;
  1573. }
  1574. else
  1575. {
  1576. returnSuccessMsg("请勿重复申请!");
  1577. return;
  1578. }
  1579. }
  1580. else
  1581. {
  1582. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1583. if (string.IsNullOrEmpty(CustomerUserId))
  1584. {
  1585. CustomerUserId = "-1";
  1586. }
  1587. int Userid = CurrentUser.UserID;//用户id
  1588. CeWithdraw ceWithdraw = new CeWithdraw();
  1589. ceWithdraw.tid = eid;
  1590. ceWithdraw.userid = Userid;
  1591. ceWithdraw.providerid = CustomerUserId;
  1592. ceWithdraw.status = 3;
  1593. ceWithdraw.creationtime = DateTime.Now;
  1594. ceWithdraw.Create();
  1595. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1596. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1597. return;
  1598. }
  1599. }
  1600. catch
  1601. {
  1602. returnErrorMsg("申请撤回订单失败");
  1603. return;
  1604. }
  1605. }
  1606. }
  1607. public void ins_erp_billinfo()
  1608. {
  1609. if (UrlPostParmsCheck("ctid"))
  1610. {
  1611. string eid = GetPostString("ctid");
  1612. CeErpTradeCell entity = null;
  1613. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1614. if (entity != null)
  1615. {
  1616. CeErpBill bill = CeErpBill.GetByTid(eid);
  1617. bool isHave = false;
  1618. if (bill != null)
  1619. {
  1620. isHave = true;
  1621. if (bill.state != 4)
  1622. {
  1623. returnErrorMsg("此单已经申请过发票了");
  1624. return;
  1625. }
  1626. }
  1627. if (entity.IsNeedBill == 0)
  1628. {
  1629. entity.IsNeedBill = 1;
  1630. }
  1631. entity.Update();
  1632. string errjson = "";
  1633. try
  1634. {
  1635. CeErpBill bill_entity = new CeErpBill();
  1636. bill_entity.tid = entity.tid;
  1637. bill_entity.title = GetPostString("title");
  1638. string taxstr = GetPostString("tax");
  1639. taxstr = taxstr.Replace(" ", "");
  1640. bill_entity.tax = taxstr;
  1641. bill_entity.bank = GetPostString("bank");
  1642. string bankacstr = GetPostString("bankac");
  1643. bankacstr = bankacstr.Replace(" ", "");
  1644. bill_entity.bankac = bankacstr;
  1645. bill_entity.address = GetPostString("address");
  1646. bill_entity.phone = GetPostString("phone");
  1647. bill_entity.price = GetPostString("price");
  1648. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1649. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1650. {
  1651. billCount += 1;
  1652. }
  1653. string prebill = "ltb";
  1654. for (int idx = 1; idx <= billCount; idx++)
  1655. {
  1656. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1657. string billoid = prebill + idx + dtstr;
  1658. bill_entity.billOrderId += billoid;
  1659. if (idx < billCount)
  1660. {
  1661. bill_entity.billOrderId += ",";
  1662. }
  1663. }
  1664. bill_entity.productId = GetPostInt("ProductName");
  1665. bill_entity.num = GetPostInt("num");
  1666. bill_entity.unit = GetPostString("unit");
  1667. bill_entity.type = GetPostString("type");
  1668. bill_entity.sendType = GetPostString("SendType");
  1669. bill_entity.email = GetPostString("email");
  1670. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1671. bill_entity.shopName = GetPostString("ShopName");
  1672. bill_entity.applymemo = GetPostString("applyMemo");
  1673. bill_entity.createTime = DateTime.Now;
  1674. bill_entity.state = 0;
  1675. bill_entity.userId = CurrentUser.UserID;
  1676. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1677. bill_entity.Create();
  1678. }
  1679. catch (Exception ex)
  1680. {
  1681. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1682. returnErrorMsg("创建发票出错!");
  1683. return;
  1684. }
  1685. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1686. returnSuccessMsg("发票申请成功!");
  1687. return;
  1688. }
  1689. returnErrorMsg("找不到记录");
  1690. }
  1691. }
  1692. public void ins_erp_neworder()
  1693. {
  1694. if (UrlPostParmsCheck("receiver_name"))
  1695. {
  1696. CeErpTrade entity = new CeErpTrade();
  1697. string plat_form = GetPostString("platform");
  1698. string preStr = "N_";
  1699. if (plat_form == "拼多多")
  1700. {
  1701. preStr = "P_";
  1702. }
  1703. else if (plat_form == "阿里巴巴")
  1704. {
  1705. preStr = "A_";
  1706. }
  1707. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1708. entity.seller_nick = GetPostString("seller_nick");
  1709. entity.buyer_nick = GetPostString("buyer_nick");
  1710. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1711. entity.total_fee = entity.payment;
  1712. entity.pay_time = DateTime.Now;
  1713. entity.status = "NOT_SHIPPED";
  1714. entity.receiver_name = GetPostString("receiver_name");
  1715. entity.receiver_mobile = GetPostString("receiver_mobile");
  1716. entity.receiver_state = GetPostString("receiver_state");
  1717. entity.receiver_city = GetPostString("receiver_city");
  1718. entity.receiver_district = GetPostString("receiver_district");
  1719. entity.receiver_address = GetPostString("receiver_address");
  1720. if (entity.receiver_state == "" || entity.receiver_city == "")
  1721. {
  1722. returnErrorMsg("收件地址不能为空");
  1723. return;
  1724. }
  1725. int shopId = 0;
  1726. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1727. if (nShop != null)
  1728. {
  1729. shopId = nShop.ID;
  1730. }
  1731. if (shopId != 34 && entity.payment == 0)
  1732. {
  1733. returnErrorMsg("公司自用的单金额才能为0");
  1734. return;
  1735. }
  1736. entity.Create();
  1737. CeErpTradeCell entitycell = new CeErpTradeCell();
  1738. entitycell.ctid = entity.tid;
  1739. entitycell.tid = entity.tid;
  1740. entitycell.ShopId = shopId;
  1741. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1742. entitycell.OrderState = 0;
  1743. entitycell.pay_time = entity.pay_time;
  1744. entitycell.IsOffLineOrder = 1;
  1745. entitycell.Create();
  1746. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1747. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1748. return;
  1749. }
  1750. }
  1751. public void ins_erp_neworder2()
  1752. {
  1753. if (UrlPostParmsCheck("receiver_name"))
  1754. {
  1755. //string plat_form = GetPostString("platform");
  1756. string preStr = "X_";
  1757. string memo = GetPostString("memo");
  1758. string productId = GetPostString("productId");
  1759. string primg = GetPostString("proofimg");
  1760. string sellerNick = GetPostString("seller_nick");
  1761. string addFrom = GetPostString("addfrom");
  1762. if (addFrom == "1")
  1763. {
  1764. preStr = "N_";
  1765. }
  1766. int shopId = 0;
  1767. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1768. if (nShop != null)
  1769. {
  1770. shopId = nShop.ID;
  1771. }
  1772. else
  1773. {
  1774. returnErrorMsg("找不到对应店铺");
  1775. return;
  1776. }
  1777. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1778. {
  1779. returnErrorMsg("必须上传付款凭证");
  1780. return;
  1781. }
  1782. CeErpTrade entity = new CeErpTrade();
  1783. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1784. entity.seller_nick = sellerNick;
  1785. entity.buyer_nick = GetPostString("buyer_nick");
  1786. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1787. entity.total_fee = entity.payment;
  1788. entity.pay_time = DateTime.Now;
  1789. entity.status = "NOT_SHIPPED";
  1790. entity.receiver_name = GetPostString("receiver_name");
  1791. entity.receiver_mobile = GetPostString("receiver_mobile");
  1792. entity.receiver_state = GetPostString("receiver_state");
  1793. entity.receiver_city = GetPostString("receiver_city");
  1794. entity.receiver_district = GetPostString("receiver_district");
  1795. entity.receiver_address = GetPostString("receiver_address");
  1796. entity.seller_memo = memo;
  1797. entity.orderFrom = 20;
  1798. entity.orderType = 15;
  1799. if (entity.receiver_state == "" || entity.receiver_city == "")
  1800. {
  1801. returnErrorMsg("收件地址不能为空");
  1802. return;
  1803. }
  1804. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1805. {
  1806. returnErrorMsg("公司自用的单金额才能为0");
  1807. return;
  1808. }
  1809. entity.Create();
  1810. string toWhere = GetPostString("towhere");
  1811. CeErpTradeCell entitycell = new CeErpTradeCell();
  1812. entitycell.ctid = entity.tid;
  1813. //唯一标识
  1814. entitycell.OrderSn = entity.tid;
  1815. string orderSn = dataHelper.getSaleOrderSn();
  1816. if (orderSn != "")
  1817. {
  1818. entitycell.OrderSn = orderSn;
  1819. }
  1820. entitycell.tid = entity.tid;
  1821. //if (preStr == "X_")
  1822. //{
  1823. entitycell.IsOffLineOrder = 1;
  1824. //}
  1825. entitycell.CustomerUserId = CurrentUser.UserID;
  1826. entitycell.PayProofImg = primg;
  1827. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1828. entitycell.ProductId = Convert.ToInt32(productId);
  1829. entitycell.ShopId = shopId;
  1830. entitycell.UpdateTime = DateTime.Now;
  1831. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1832. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1833. {
  1834. entitycell.IsXianHuo = 1;
  1835. }
  1836. entitycell.pay_time = entity.pay_time;
  1837. if (toWhere == "1")
  1838. {
  1839. entitycell.OrderState = 2;
  1840. }
  1841. else
  1842. {
  1843. entitycell.OrderState = 6;
  1844. entitycell.FinishPlaceTime = entitycell.pay_time;
  1845. }
  1846. if (shopId == 94)
  1847. {
  1848. entitycell.OrderState = 4;
  1849. entitycell.WaitDesignTime = entitycell.pay_time;
  1850. entitycell.StartDesignTime = entitycell.pay_time;
  1851. entitycell.DesignUserId = 218;
  1852. }
  1853. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1854. {
  1855. entitycell.OrderState = -1;//修改12-5
  1856. CeWithdraw ceWithdraw = new CeWithdraw();
  1857. ceWithdraw.tid = entity.tid;
  1858. ceWithdraw.providerid = "-1";
  1859. ceWithdraw.status = -1;
  1860. ceWithdraw.creationtime = DateTime.Now;
  1861. ceWithdraw.userid = 742;
  1862. ceWithdraw.Create();
  1863. }
  1864. entitycell.Create();
  1865. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1866. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1867. {
  1868. addPlaceRegist(entitycell, CurrentUser.UserID);
  1869. }
  1870. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1871. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1872. return;
  1873. }
  1874. }
  1875. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1876. {
  1877. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1878. entity.PlactTime = tradecell.pay_time;
  1879. entity.AddUserId = userid;
  1880. entity.FileName = tradecell.seller_memo;
  1881. entity.Supplier = 24;
  1882. entity.CreateTime = DateTime.Now;
  1883. entity.Did = tradecell.ctid;
  1884. entity.tid = tradecell.tid;
  1885. entity.splitTag = tradecell.SplitTag;
  1886. entity.CurState = "未完成";
  1887. entity.Create();
  1888. }
  1889. public void get_erp_offlinelist()
  1890. {
  1891. DataStruct dStruct = GetPostStruct();
  1892. List<string> lw = new List<string>();
  1893. string tid = GetPostString("ctid");
  1894. string date1 = GetPostString("date1");
  1895. string date2 = GetPostString("date2");
  1896. if (tid.Length > 0 || date1.Length > 0)
  1897. {
  1898. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1899. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1900. if (dw.Length > 0) lw.Add(dw);
  1901. }
  1902. else
  1903. {
  1904. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1905. }
  1906. string shopname = GetPostString("shopname");
  1907. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1908. string buyernick = GetPostString("buyer_nick");
  1909. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1910. string customer = GetPostString("customer");
  1911. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1912. string design = GetPostString("design");
  1913. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1914. string orderState = GetPostString("orderState");
  1915. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1916. string address = GetPostString("address");
  1917. 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));
  1918. string sellermemo = GetPostString("seller_memo");
  1919. if (sellermemo.Length > 0)
  1920. {
  1921. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1922. }
  1923. string price1 = GetPostString("price1");
  1924. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1925. string price2 = GetPostString("price2");
  1926. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1927. //if (PKey != "admin")
  1928. //{
  1929. // string usershop = CurrentUser.User.pemShop;
  1930. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1931. //}
  1932. //if (ex_psize > 0)
  1933. //{
  1934. dStruct.Order = "pay_time desc";
  1935. //}
  1936. //else
  1937. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1938. lw.Add(string.Format("IsOffLineOrder=1"));
  1939. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1940. DataTable dt = null;
  1941. dt = WebCache.GetData("view_erptradecell", dStruct);
  1942. writeGridDataTableJson(dStruct.TotalCount, dt);
  1943. }
  1944. public void get_erp_returncashrecord()
  1945. {
  1946. DataStruct dStruct = GetPostStruct();
  1947. List<string> lw = new List<string>();
  1948. string tid = GetPostString("ctid");
  1949. if (tid.Length > 0)
  1950. {
  1951. lw.Add(string.Format("tid like '%{0}%'", tid));
  1952. dStruct.Order = "id desc";
  1953. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1954. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1955. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1956. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1957. return;
  1958. }
  1959. returnErrorMsg("id数据错误!");
  1960. }
  1961. public void ins_erp_returncashrecord()
  1962. {
  1963. if (UrlPostParmsCheck("tid"))
  1964. {
  1965. string tid = GetPostString("tid");
  1966. string retype = GetPostString("type");
  1967. StringBuilder sql = new StringBuilder();
  1968. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1969. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1970. if (dt.Rows.Count > 0)
  1971. {
  1972. returnErrorMsg("相同返现类型记录已存在");
  1973. return;
  1974. }
  1975. CeErpReturnCash entity = new CeErpReturnCash();
  1976. entity.tid = tid;
  1977. entity.seller_nick = GetPostString("seller_nick");
  1978. string pment = GetPostString("payment");
  1979. if (pment.Length > 0)
  1980. {
  1981. entity.payment = Convert.ToDouble(pment);
  1982. }
  1983. entity.buyer_nick = GetPostString("buyer_nick");
  1984. entity.cashstate = 0;
  1985. entity.rtype = retype;
  1986. string rPrice = GetPostString("returnprice");
  1987. if (rPrice.Length > 0)
  1988. {
  1989. entity.returnprice = Convert.ToDouble(rPrice);
  1990. }
  1991. entity.created = DateTime.Now;
  1992. entity.con = GetPostString("con");
  1993. entity.img = GetPostString("img");
  1994. entity.applyuserid = CurrentUser.UserID;
  1995. entity.Create();
  1996. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1997. returnSuccessMsg("操作成功!");
  1998. return;
  1999. }
  2000. }
  2001. public void set_erp_predelivery()
  2002. {
  2003. if (UrlPostParmsCheck("ctid"))
  2004. {
  2005. string eid = GetPostString("ctid");
  2006. CeErpTradeCell entity = null;
  2007. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2008. if (entity != null)
  2009. {
  2010. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2011. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2012. //{
  2013. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2014. // return;
  2015. //}
  2016. entity.IsPreDelivery = 1;
  2017. entity.Update();
  2018. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2019. returnSuccessMsg("预发货成功!");
  2020. return;
  2021. //string shop = GetPostString("seller_nick");
  2022. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2023. //string comName = GetPostString("comName");
  2024. //string comCode = GetPostString("comCode");
  2025. //string outSid = GetPostString("outSid");//运单号
  2026. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2027. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2028. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2029. //string apires = "";
  2030. //if (deliveryType == "虚拟发货")
  2031. //{
  2032. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2033. //}
  2034. //else
  2035. //{
  2036. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2037. //}
  2038. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2039. ////{
  2040. //if (apires.IndexOf("发货成功") != -1)
  2041. //{
  2042. // if (deliveryType != "虚拟发货")
  2043. // {
  2044. // //还要插入快递信息到 快递信息表
  2045. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2046. // exinfo.tid = eid;
  2047. // exinfo.out_sid = outSid;
  2048. // exinfo.company_code = comCode;
  2049. // exinfo.company_name = comName;
  2050. // exinfo.delivery_memo = deliveryMemo;
  2051. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2052. // exinfo.deliveryType = deliveryType;
  2053. // exinfo.Create();
  2054. // }
  2055. // returnSuccessMsg("发货成功!");
  2056. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2057. //}
  2058. //else
  2059. //{
  2060. // returnErrorMsg("淘宝发货失败!!");
  2061. //}
  2062. //return;
  2063. }
  2064. returnErrorMsg("找不到订单记录");
  2065. }
  2066. }
  2067. public void get_erp_unusuallist()
  2068. {
  2069. DataStruct dStruct = GetPostStruct();
  2070. List<string> lw = new List<string>();
  2071. string tid = GetPostString("ctid");
  2072. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2073. string shopname = GetPostString("shopname");
  2074. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2075. string buyernick = GetPostString("buyer_nick");
  2076. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2077. string ResponsibleMan = GetPostString("responsible");
  2078. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2079. string date1 = GetPostString("date1");
  2080. string date2 = GetPostString("date2");
  2081. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2082. if (dw.Length > 0) lw.Add(dw);
  2083. string price1 = GetPostString("price1");
  2084. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2085. string price2 = GetPostString("price2");
  2086. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2087. string orderState = GetPostString("orderState");
  2088. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2089. string sellermemo = GetPostString("seller_memo");
  2090. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2091. lw.Add(string.Format("UnusualTag > 0"));
  2092. lw.Add(string.Format("IsRefund<={0}", 1));
  2093. dStruct.Order = "pay_time desc";
  2094. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2095. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2096. writeGridDataTableJson(dStruct.TotalCount, dt);
  2097. }
  2098. public void set_erp_unusualtonomal()
  2099. {
  2100. if (UrlPostParmsCheck("ctid"))
  2101. {
  2102. string eid = GetPostString("ctid");
  2103. CeErpTradeCell entity = null;
  2104. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2105. if (entity != null)
  2106. {
  2107. entity.UnusualTag = -1;
  2108. entity.Update();
  2109. returnSuccessMsg("忽略成功!");
  2110. return;
  2111. }
  2112. returnErrorMsg("找不到记录");
  2113. }
  2114. }
  2115. public void ins_erp_unusualreason()
  2116. {
  2117. if (UrlPostParmsCheck("ctid"))
  2118. {
  2119. string eid = GetPostString("ctid");
  2120. CeErpTradeCell entity = null;
  2121. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2122. if (entity != null)
  2123. {
  2124. entity.MemoOpt = 4;
  2125. entity.UnusualCon = GetPostString("con");
  2126. entity.Update();
  2127. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2128. if (trade != null)
  2129. {
  2130. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2131. }
  2132. //查货是否超时
  2133. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2134. if (ceErpTradeCellExtend == null)
  2135. {
  2136. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2137. ceErpTradeCellExtend.ctid = entity.ctid;
  2138. }
  2139. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2140. {
  2141. ceErpTradeCellExtend.CheckOut += 1;
  2142. }
  2143. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2144. if (ceErpTradeCellExtend.ID > 0)
  2145. {
  2146. ceErpTradeCellExtend.Update();
  2147. }
  2148. else
  2149. {
  2150. ceErpTradeCellExtend.Create();
  2151. }
  2152. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2153. returnSuccessMsg("操作成功!");
  2154. return;
  2155. }
  2156. returnErrorMsg("找不到记录");
  2157. }
  2158. }
  2159. public void upd_erp_sampleorder()
  2160. {
  2161. if (UrlPostParmsCheck("ctid"))
  2162. {
  2163. string eid = GetPostString("ctid");
  2164. string[] eArr = eid.Split(',');
  2165. if (eArr.Length > 1)
  2166. {
  2167. List<string> eLst = new List<string>();
  2168. for (int i = 0; i < eArr.Length; i++)
  2169. {
  2170. eLst.Add("'" + eArr[i] + "'");
  2171. }
  2172. eid = string.Join(",", eLst.ToArray());
  2173. }
  2174. else
  2175. {
  2176. eid = "'" + eid + "'";
  2177. }
  2178. StringBuilder sql = new StringBuilder();
  2179. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2180. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2181. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2182. if (dt.Rows.Count > 0)
  2183. {
  2184. string errmsg = "";
  2185. foreach (DataRow dr in dt.Rows)
  2186. {
  2187. StringBuilder sqlsb = new StringBuilder();
  2188. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2189. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2190. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2191. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2192. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2193. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2194. {
  2195. continue;
  2196. }
  2197. else
  2198. {
  2199. string emsg = commonHelper.KeepChinese(apires);
  2200. errmsg += emsg;
  2201. }
  2202. }
  2203. if (errmsg.Length > 0)
  2204. {
  2205. returnErrorMsg(errmsg);
  2206. return;
  2207. }
  2208. returnSuccessMsg("操作成功");
  2209. return;
  2210. }
  2211. returnErrorMsg("找不到记录");
  2212. }
  2213. }
  2214. public void upd_erp_transcustomer()
  2215. {
  2216. if (UrlPostParmsCheck("ctid"))
  2217. {
  2218. string eid = GetPostString("ctid");
  2219. int userid = GetPostInt("CustomerUserId");
  2220. CeErpTradeCell entity = null;
  2221. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2222. if (entity != null)
  2223. {
  2224. //string[] mlist = entity.seller_memo.Split('-');
  2225. //string sql = "select * from view_erpuser where id=" + userid;
  2226. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2227. //if (dt != null && dt.Rows.Count > 0)
  2228. //{
  2229. // string nmemo = "";
  2230. // for(int i = 0; i < mlist.Length - 1; i++)
  2231. // {
  2232. // nmemo += mlist[i];
  2233. // nmemo += "-";
  2234. // }
  2235. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2236. // entity.seller_memo = nmemo;
  2237. //}
  2238. entity.CustomerUserId = userid;
  2239. entity.Update();
  2240. returnSuccessMsg("操作成功!");
  2241. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2242. return;
  2243. }
  2244. returnErrorMsg("找不到记录");
  2245. }
  2246. }
  2247. public void upd_erp_transdesigner()
  2248. {
  2249. if (UrlPostParmsCheck("ctid"))
  2250. {
  2251. string eids = GetPostString("ctid");
  2252. string[] ctidList = eids.Split(',');
  2253. int userid = GetPostInt("DesignUserId");
  2254. foreach (string ctid in ctidList)
  2255. {
  2256. CeErpTradeCell entity = null;
  2257. CeErpDesignerBill entitys = null;
  2258. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2259. entitys = CeErpDesignerBill.GetByTid(ctid);
  2260. if (entity != null)
  2261. {
  2262. if (entity.OrderState > 4)
  2263. {
  2264. continue;
  2265. }
  2266. //存在退款不能流转
  2267. if (entity.IsRefund > 0)
  2268. {
  2269. continue;
  2270. }
  2271. entity.DesignUserId = userid;
  2272. entity.WaitDesignTime = DateTime.Now;
  2273. entity.Update();
  2274. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2275. }
  2276. }
  2277. returnSuccessMsg("操作成功!");
  2278. }
  2279. }
  2280. public void upd_erp_distributedesigner()
  2281. {
  2282. if (UrlPostParmsCheck("ctid"))
  2283. {
  2284. string eid = GetPostString("ctid");
  2285. int userid = GetPostInt("DesignUserId");
  2286. string[] idlist = eid.Split(',');
  2287. if (idlist.Length <= 0)
  2288. {
  2289. returnErrorMsg("订单不能为空");
  2290. return;
  2291. }
  2292. foreach (string ctid in idlist)
  2293. {
  2294. CeErpTradeCell entity = null;
  2295. CeErpDesignerBill entitys = null;
  2296. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2297. else continue;
  2298. if (entity != null)
  2299. {
  2300. if (userid == 2125 || userid == 3542)
  2301. { }
  2302. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2303. {
  2304. returnErrorMsg("金额错误的订单无法指派");
  2305. return;
  2306. }
  2307. if (entity.OrderState >= 5)
  2308. {
  2309. returnErrorMsg("已经设计完成无法指派");
  2310. return;
  2311. }
  2312. if (entity.OrderState == -1)
  2313. {
  2314. returnErrorMsg("审核中的订单无法指派");
  2315. return;
  2316. }
  2317. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2318. {
  2319. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2320. return;
  2321. }
  2322. //157赖橙帆 159林晨 73 静之颖
  2323. 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)
  2324. {
  2325. returnErrorMsg("指派设计共创无法再次指派!");
  2326. return;
  2327. }
  2328. entity.OrderState = 3;
  2329. if (entity.SupplierId == 0)
  2330. {
  2331. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2332. entity.SupplierId = suid;
  2333. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2334. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2335. }
  2336. if (userid == 2125 && entity.seller_memo != "")
  2337. {
  2338. apiDesign.API_GetPrintData_CreateOrder(entity);
  2339. }
  2340. if (userid == 3542 && entity.seller_memo != "")
  2341. {
  2342. string userPost = CurrentUser.UserPost.Post.Code;
  2343. if (CurrentUser.UserID == 73)
  2344. {
  2345. userPost = "SysAdmin";
  2346. }
  2347. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2348. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2349. if (response.msg != "设计共创:成功")
  2350. {
  2351. returnErrorMsg(response.msg);
  2352. return;
  2353. }
  2354. entity.DispatchSort = 2;
  2355. }
  2356. else
  2357. {
  2358. if (entity.DispatchSort == 2)
  2359. {
  2360. ApiVo apiVo = new ApiVo();
  2361. apiVo.actionName = "closeDesign";
  2362. apiVo.orderNumber = entity.ctid;
  2363. designHelper.API_WorkCore(apiVo);//closeDesign
  2364. }
  2365. entity.DispatchSort = 0;
  2366. }
  2367. entity.DesignUserId = userid;
  2368. entity.WaitDesignTime = DateTime.Now;
  2369. entity.UpdateTime = DateTime.Now;
  2370. entity.Update();
  2371. string name = commonHelper.getUserNameById(userid);
  2372. commonHelper.UpdateRelationOrder(entity.ctid);
  2373. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2374. }
  2375. }
  2376. returnSuccessMsg("操作成功!");
  2377. return;
  2378. }
  2379. }
  2380. public string getTidByCtid(string ctid)
  2381. {
  2382. string tid = "";
  2383. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2384. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2385. if (dataTable != null && dataTable.Rows.Count > 0)
  2386. {
  2387. tid = dataTable.Rows[0]["tid"].ToString();
  2388. }
  2389. return tid;
  2390. }
  2391. public List<string> getTidByCtidMore(string ctid)
  2392. {
  2393. 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);
  2394. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2395. List<string> list = new List<string>();
  2396. if (dataTable != null && dataTable.Rows.Count > 0)
  2397. {
  2398. foreach (DataRow item in dataTable.Rows)
  2399. {
  2400. list.Add("'" + item["tid"].ToString() + "'");
  2401. }
  2402. }
  2403. return list;
  2404. }
  2405. public List<string> getTidByCtidLike(string ctid)
  2406. {
  2407. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2408. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2409. List<string> list = new List<string>();
  2410. if (dataTable != null && dataTable.Rows.Count > 0)
  2411. {
  2412. foreach (DataRow item in dataTable.Rows)
  2413. {
  2414. list.Add("'" + item["tid"].ToString() + "'");
  2415. }
  2416. }
  2417. return list;
  2418. }
  2419. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2420. {
  2421. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2422. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2423. List<string> list = new List<string>();
  2424. if (dataTable != null && dataTable.Rows.Count > 0)
  2425. {
  2426. foreach (DataRow item in dataTable.Rows)
  2427. {
  2428. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2429. {
  2430. continue;
  2431. }
  2432. list.Add("'" + item["receiverId"].ToString() + "'");
  2433. }
  2434. }
  2435. return list;
  2436. }
  2437. public void get_erp_myorderlist()
  2438. {
  2439. DataStruct dStruct = GetPostStruct();
  2440. List<string> lw = new List<string>();
  2441. string tid = GetPostString("ctid");
  2442. if (tid.Length > 0)
  2443. {
  2444. string select_tid = getTidByCtid(tid);
  2445. lw.Add(string.Format("tid='{0}'", select_tid));
  2446. }
  2447. else
  2448. {
  2449. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2450. }
  2451. //12-1 修改
  2452. string urgent = GetPostString("urgent");
  2453. string back = GetPostString("back");
  2454. string offlineSearch = GetPostString("offlineSearch");
  2455. if (!string.IsNullOrWhiteSpace(urgent))
  2456. {
  2457. if (urgent.Equals("true"))
  2458. {
  2459. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2460. }
  2461. }
  2462. if (!string.IsNullOrWhiteSpace(back))
  2463. {
  2464. if (back.Equals("true"))
  2465. {
  2466. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2467. }
  2468. }
  2469. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2470. {
  2471. if (offlineSearch.Equals("true"))
  2472. {
  2473. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2474. }
  2475. }
  2476. //end
  2477. string shopname = GetPostString("shopname");
  2478. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2479. string buyernick = GetPostString("buyer_nick");
  2480. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2481. string design = GetPostString("design");
  2482. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2483. string orderState = GetPostString("orderState");
  2484. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2485. string sellermemo = GetPostString("seller_memo");
  2486. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2487. string date1 = GetPostString("date1");
  2488. string date2 = GetPostString("date2");
  2489. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2490. if (dw.Length > 0) lw.Add(dw);
  2491. string price1 = GetPostString("price1");
  2492. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2493. string price2 = GetPostString("price2");
  2494. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2495. string urgency = GetPostString("urgency");
  2496. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2497. string after = GetPostString("after");
  2498. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2499. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2500. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2501. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2502. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2503. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2504. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2505. if (dt != null && dt.Rows.Count > 0)
  2506. {
  2507. foreach (DataRow dr in dt.Rows)
  2508. {
  2509. try
  2510. {
  2511. // 对象操作
  2512. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2513. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2514. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2515. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2516. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2517. if (dStruct.PageSize != 100000)
  2518. {
  2519. if (dr["DispatchSort"].ToString() == "2")
  2520. {
  2521. dr["gongchuang"] = 200;
  2522. }
  2523. else if ("外协".Equals(dr["ToType"].ToString()))
  2524. {
  2525. dr["gongchuang"] = 200;
  2526. }
  2527. else if ("内部".Equals(dr["ToType"].ToString()))
  2528. {
  2529. dr["gongchuang"] = -1;
  2530. }
  2531. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2532. {
  2533. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2534. dr["gongchuang"] = response.code;
  2535. }
  2536. }
  2537. }
  2538. catch (NullReferenceException ex)
  2539. {
  2540. }
  2541. }
  2542. }
  2543. writeGridDataTableJson(dStruct.TotalCount, dt);
  2544. }
  2545. public void get_erp_myreturnorderlist()
  2546. {
  2547. DataStruct dStruct = GetPostStruct();
  2548. List<string> lw = new List<string>();
  2549. string tid = GetPostString("ctid");
  2550. if (tid.Length > 0)
  2551. {
  2552. string select_tid = getTidByCtid(tid);
  2553. lw.Add(string.Format("tid='{0}'", select_tid));
  2554. }
  2555. else
  2556. {
  2557. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2558. }
  2559. string shopname = GetPostString("shopname");
  2560. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2561. string buyernick = GetPostString("buyer_nick");
  2562. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2563. string design = GetPostString("design");
  2564. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2565. string orderState = GetPostString("orderState");
  2566. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2567. string sellermemo = GetPostString("seller_memo");
  2568. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2569. string date1 = GetPostString("date1");
  2570. string date2 = GetPostString("date2");
  2571. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2572. if (dw.Length > 0) lw.Add(dw);
  2573. string price1 = GetPostString("price1");
  2574. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2575. string price2 = GetPostString("price2");
  2576. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2577. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2578. {
  2579. lw.Add(string.Format("CusOrgID = 94"));
  2580. }
  2581. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2582. {
  2583. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2584. }
  2585. else
  2586. {
  2587. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2588. }
  2589. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2590. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2591. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2592. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2593. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2594. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2595. if (dt != null && dt.Rows.Count > 0)
  2596. {
  2597. foreach (DataRow dr in dt.Rows)
  2598. {
  2599. try
  2600. {
  2601. // 对象操作
  2602. if (dStruct.PageSize != 100000)
  2603. {
  2604. if (dr["DispatchSort"].ToString() == "2")
  2605. {
  2606. dr["gongchuang"] = 200;
  2607. }
  2608. else if ("外协".Equals(dr["ToType"].ToString()))
  2609. {
  2610. dr["gongchuang"] = 200;
  2611. }
  2612. else if ("内部".Equals(dr["ToType"].ToString()))
  2613. {
  2614. dr["gongchuang"] = -1;
  2615. }
  2616. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2617. {
  2618. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2619. dr["gongchuang"] = response.code;
  2620. }
  2621. }
  2622. }
  2623. catch (NullReferenceException ex)
  2624. {
  2625. // 处理空引用异常
  2626. }
  2627. }
  2628. }
  2629. writeGridDataTableJson(dStruct.TotalCount, dt);
  2630. }
  2631. public void get_erp_myorderlist_pregather()
  2632. {
  2633. string date1 = GetPostString("date1");
  2634. string date2 = GetPostString("date2");
  2635. int userId = CurrentUser.UserID; //客服id
  2636. string orderWhere = "";
  2637. List<string> lw = new List<string>();
  2638. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2639. if (dw.Length > 0) lw.Add(dw);
  2640. lw.Add(string.Format("CustomerUserId={0}", userId));
  2641. lw.Add(string.Format("OrderState<9"));
  2642. orderWhere = string.Join(" and ", lw.ToArray());
  2643. string orderWhere2 = "";
  2644. List<string> lw2 = new List<string>();
  2645. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2646. if (dw2.Length > 0) lw2.Add(dw2);
  2647. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2648. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2649. string sql = string.Format("select *" +
  2650. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2651. "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 " +
  2652. "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 " +
  2653. "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");
  2654. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2655. //writeGridDataTableJson(dt.Rows.Count, dt);
  2656. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2657. }
  2658. public void upd_erp_publishorder()
  2659. {
  2660. if (UrlPostParmsCheck("ctid"))
  2661. {
  2662. string eid = GetPostString("ctid");
  2663. CeErpTradeCell entity = null;
  2664. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2665. if (entity != null)
  2666. {
  2667. entity.OrderState = 0; //发布后,变为待抢单
  2668. entity.Update();
  2669. commonHelper.UpdateRelationOrder(entity.ctid);
  2670. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2671. returnSuccessMsg("发布成功!");
  2672. return;
  2673. }
  2674. returnErrorMsg("找不到记录");
  2675. }
  2676. }
  2677. public void get_erp_my_tiporder()
  2678. {
  2679. StringBuilder sql = new StringBuilder();
  2680. int userId = 0;
  2681. if (CurrentUser != null) userId = CurrentUser.UserID;
  2682. string posCode = CurrentUser.UserPost.Post.Code;
  2683. string isTipedAfterSaleVerify = GetPostString("af");
  2684. DataTable dt = new DataTable();
  2685. if (posCode != "Supplier")
  2686. {
  2687. if (posCode == "CustomerService" || posCode == "Director")
  2688. {
  2689. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2690. }
  2691. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2692. {
  2693. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2694. }
  2695. else
  2696. {
  2697. string teamIds = CurrentUser.User.TeamIds;
  2698. if (teamIds == "")
  2699. {
  2700. teamIds = "0";
  2701. }
  2702. 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);
  2703. }
  2704. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2705. }
  2706. if (dt.Rows.Count <= 0)
  2707. {
  2708. string key = "aftersale_order_" + userId;
  2709. if (RedisHelper.HasKey(key))
  2710. {
  2711. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2712. dt.Columns.Add("ctid", typeof(string));
  2713. dt.Columns.Add("IsReadTag", typeof(int));
  2714. foreach (var i in list)
  2715. {
  2716. DataRow data = dt.NewRow();
  2717. data["ctid"] = i;
  2718. data["IsReadTag"] = 4;
  2719. dt.Rows.Add(data);
  2720. }
  2721. RedisHelper.StringDelete(key);
  2722. }
  2723. }
  2724. if (dt.Rows.Count <= 0)
  2725. {
  2726. sql = new StringBuilder();
  2727. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2728. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2729. }
  2730. if (posCode == "Supplier")
  2731. {
  2732. string ids = CurrentUser.User.pemVend;
  2733. if (ids != null && ids.Length > 0)
  2734. {
  2735. string[] ids_list = ids.Split(',');
  2736. foreach (var item in ids_list)
  2737. {
  2738. string key = "return_order_" + item;
  2739. if (RedisHelper.HasKey(key))
  2740. {
  2741. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2742. dt.Columns.Add("ctid", typeof(string));
  2743. dt.Columns.Add("IsReadTag", typeof(int));
  2744. foreach (var i in list)
  2745. {
  2746. DataRow data = dt.NewRow();
  2747. data["ctid"] = i;
  2748. data["IsReadTag"] = 1;
  2749. dt.Rows.Add(data);
  2750. }
  2751. RedisHelper.StringDelete(key);
  2752. }
  2753. }
  2754. }
  2755. if (dt.Rows.Count <= 0)
  2756. {
  2757. sql = new StringBuilder();
  2758. 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);
  2759. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2760. }
  2761. }
  2762. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2763. }
  2764. public void reset_erp_tiporder()
  2765. {
  2766. string ids = GetPostString("ids");
  2767. string[] ctidList = ids.Split(',');
  2768. foreach (string ctid in ctidList)
  2769. {
  2770. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2771. if (enty != null)
  2772. {
  2773. enty.IsReadTag = 0;
  2774. enty.Update();
  2775. }
  2776. }
  2777. returnSuccessMsg("成功!");
  2778. return;
  2779. }
  2780. public void get_erp_designlist()
  2781. {
  2782. DataStruct dStruct = GetPostStruct();
  2783. List<string> lw = new List<string>();
  2784. string tid = GetPostString("ctid");
  2785. if (tid.Length > 0)
  2786. {
  2787. string select_tid = getTidByCtid(tid);
  2788. lw.Add(string.Format("tid='{0}'", select_tid));
  2789. }
  2790. string shopname = GetPostString("shopname");
  2791. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2792. string buyernick = GetPostString("buyer_nick");
  2793. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2794. string customer = GetPostString("customer");
  2795. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2796. string design = GetPostString("design");
  2797. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2798. string orderState = GetPostString("orderState");
  2799. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2800. lw.Add(string.Format("OrderState<6"));
  2801. string address = GetPostString("address");
  2802. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2803. string sellermemo = GetPostString("seller_memo");
  2804. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2805. string date1 = GetPostString("date1");
  2806. string date2 = GetPostString("date2");
  2807. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2808. if (dw.Length > 0) lw.Add(dw);
  2809. string apdate1 = GetPostString("apdate1");
  2810. string apdate2 = GetPostString("apdate2");
  2811. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2812. if (dwap.Length > 0) lw.Add(dwap);
  2813. string price1 = GetPostString("price1");
  2814. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2815. string price2 = GetPostString("price2");
  2816. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2817. string designTime = GetPostString("designtime");
  2818. if (designTime.Length > 0)
  2819. {
  2820. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2821. }
  2822. string usershop = CurrentUser.User.pemShop;
  2823. if (usershop.Length > 0)
  2824. {
  2825. lw.Add(string.Format("shopId in ({0})", usershop));
  2826. }
  2827. int myOrgid = CurrentUser.UserPost.OrgID;
  2828. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2829. if (myOrgCode.IndexOf("Designer") != -1)
  2830. {
  2831. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2832. {
  2833. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2834. }
  2835. else
  2836. {
  2837. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2838. }
  2839. }
  2840. else
  2841. {
  2842. string orgId = GetPostString("designerhd");
  2843. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2844. }
  2845. if (tid.Length > 0 || buyernick.Length > 0)
  2846. {
  2847. lw.Add(string.Format("OrderState >= 3"));
  2848. }
  2849. else
  2850. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2851. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2852. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2853. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2854. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2855. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2856. if (dt != null && dt.Rows.Count > 0)
  2857. {
  2858. foreach (DataRow dr in dt.Rows)
  2859. {
  2860. try
  2861. {
  2862. // 对象操作
  2863. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2864. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2865. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2866. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2867. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2868. if (dStruct.PageSize != 100000)
  2869. {
  2870. if (dr["DispatchSort"].ToString() == "2")
  2871. {
  2872. dr["gongchuang"] = 200;
  2873. }
  2874. else if ("外协".Equals(dr["ToType"].ToString()))
  2875. {
  2876. dr["gongchuang"] = 200;
  2877. }
  2878. else if ("内部".Equals(dr["ToType"].ToString()))
  2879. {
  2880. dr["gongchuang"] = -1;
  2881. }
  2882. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2883. {
  2884. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2885. dr["gongchuang"] = response.code;
  2886. }
  2887. }
  2888. }
  2889. catch (NullReferenceException ex)
  2890. {
  2891. }
  2892. }
  2893. }
  2894. writeGridDataTableJson(dStruct.TotalCount, dt);
  2895. }
  2896. public void get_erp_mydesignlist()
  2897. {
  2898. DataStruct dStruct = GetPostStruct();
  2899. List<string> lw = new List<string>();
  2900. string tid = GetPostString("ctid");
  2901. if (tid.Length > 0)
  2902. {
  2903. string select_tid = getTidByCtid(tid);
  2904. lw.Add(string.Format("tid='{0}'", select_tid));
  2905. }
  2906. string shopname = GetPostString("shopname");
  2907. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2908. string buyernick = GetPostString("buyer_nick");
  2909. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2910. string customer = GetPostString("customer");
  2911. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2912. string orderState = GetPostString("orderState");
  2913. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2914. //lw.Add(string.Format("OrderState<6"));
  2915. string date1 = GetPostString("date1");
  2916. string date2 = GetPostString("date2");
  2917. string dw = GetDateWhere("pay_time", date1, date2);
  2918. if (dw.Length > 0) lw.Add(dw);
  2919. string apdate1 = GetPostString("apdate1");
  2920. string apdate2 = GetPostString("apdate2");
  2921. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2922. if (dwap.Length > 0) lw.Add(dwap);
  2923. string price1 = GetPostString("price1");
  2924. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2925. string price2 = GetPostString("price2");
  2926. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2927. string olddownload = GetPostString("olddown");
  2928. if (olddownload == "1")
  2929. {
  2930. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2931. }
  2932. else if (olddownload == "2")
  2933. {
  2934. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2935. }
  2936. string sellermemo = GetPostString("seller_memo");
  2937. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2938. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2939. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2940. {
  2941. if (CurrentUser.User.TeamIds.Length > 0)
  2942. {
  2943. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2944. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2945. else
  2946. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2947. }
  2948. else
  2949. {
  2950. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2951. }
  2952. }
  2953. if (tid.Length <= 0)
  2954. {
  2955. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2956. }
  2957. lw.Add(string.Format("IsReturn!=3"));
  2958. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2959. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2960. string teamids = CurrentUser.User.TeamIds.ToString();
  2961. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2962. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2963. if (dt != null && dt.Rows.Count > 0)
  2964. {
  2965. foreach (DataRow dr in dt.Rows)
  2966. {
  2967. try
  2968. {
  2969. // 对象操作
  2970. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2971. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2972. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2973. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2974. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2975. if (dStruct.PageSize != 100000)
  2976. {
  2977. if (dr["DispatchSort"].ToString() == "2")
  2978. {
  2979. dr["gongchuang"] = 200;
  2980. }
  2981. else if ("外协".Equals(dr["ToType"].ToString()))
  2982. {
  2983. dr["gongchuang"] = 200;
  2984. }
  2985. else if ("内部".Equals(dr["ToType"].ToString()))
  2986. {
  2987. dr["gongchuang"] = -1;
  2988. }
  2989. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2990. {
  2991. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2992. dr["gongchuang"] = response.code;
  2993. }
  2994. }
  2995. }
  2996. catch (NullReferenceException ex)
  2997. {
  2998. }
  2999. }
  3000. }
  3001. writeGridDataTableJson(dStruct.TotalCount, dt);
  3002. }
  3003. public void set_erp_startdesign()
  3004. {
  3005. if (UrlPostParmsCheck("ctid"))
  3006. {
  3007. string eid = GetPostString("ctid");
  3008. CeErpTradeCell entity = null;
  3009. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3010. if (entity != null)
  3011. {
  3012. if (entity.OrderState != 3)
  3013. {
  3014. returnErrorMsg("请刷新,订单已经设计了");
  3015. return;
  3016. }
  3017. entity.StartDesignTime = DateTime.Now;
  3018. entity.OrderState = 4;
  3019. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3020. {
  3021. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3022. entity.SupplierId = suid;
  3023. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3024. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3025. }
  3026. entity.UpdateTime = DateTime.Now;
  3027. //entity.MakeSupplier = suname;
  3028. entity.Update();
  3029. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3030. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3031. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3032. commonHelper.getCytPrice(entity);
  3033. returnSuccessMsg("操作成功!");
  3034. return;
  3035. }
  3036. returnErrorMsg("找不到记录");
  3037. }
  3038. }
  3039. public void ins_erp_designselfmemo()
  3040. {
  3041. if (UrlPostParmsCheck("ctid"))
  3042. {
  3043. string eid = GetPostString("ctid");
  3044. string con = GetPostString("con");
  3045. CeErpTradeCell entity = null;
  3046. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3047. if (entity != null)
  3048. {
  3049. entity.DesignSelfMemo = con;
  3050. entity.Update();
  3051. returnSuccessMsg("操作成功!");
  3052. return;
  3053. }
  3054. returnErrorMsg("找不到记录");
  3055. }
  3056. }
  3057. public void ins_erp_designprice()
  3058. {
  3059. if (UrlPostParmsCheck("ctid"))
  3060. {
  3061. string eid = GetPostString("ctid");
  3062. int uid = CurrentUser.UserID;
  3063. string userName = CurrentUser.UserName;
  3064. CeErpTradeCell entity = null;
  3065. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3066. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3067. if (entitys == null)
  3068. {
  3069. entitys = new CeErpDesignerBill();
  3070. }
  3071. if (entity != null)
  3072. {
  3073. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3074. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3075. entity.StartDesignTime = DateTime.Now;
  3076. entity.OrderState = 4;
  3077. string suname = "";
  3078. if (entity.SupplierId == 0)
  3079. {
  3080. int sid = commonHelper.autoDistributeToSupplier(entity);
  3081. entity.SupplierId = sid;
  3082. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3083. }
  3084. entity.Update();
  3085. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3086. if (ceErpUserPost != null)
  3087. {
  3088. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3089. if (ceErpPost != null)
  3090. {
  3091. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3092. {
  3093. entitys.tid = entity.ctid;
  3094. entitys.oid = entity.tid;
  3095. entitys.uid = uid;
  3096. entitys.userName = userName;
  3097. entitys.designerType = 1;
  3098. entitys.designerTypeText = "内部设计师";
  3099. entitys.price = Convert.ToDouble(GetPostString("price"));
  3100. entitys.designNum = GetPostInt("designNum");
  3101. entitys.modifyNum = GetPostInt("modifyNum");
  3102. entitys.designSize = GetPostString("designSize");
  3103. entitys.modifySize = GetPostString("modifySize");
  3104. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3105. {
  3106. entitys.create_time = DateTime.Now;
  3107. entitys.create_u_id = uid;
  3108. entitys.create_u_name = userName;
  3109. entitys.Save();
  3110. }
  3111. else
  3112. {
  3113. entitys.update_time = DateTime.Now;
  3114. entitys.update_u_id = uid;
  3115. entitys.update_u_name = userName;
  3116. entitys.Update();
  3117. }
  3118. }
  3119. }
  3120. }
  3121. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3122. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3123. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3124. if (suname != "")
  3125. {
  3126. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3127. }
  3128. commonHelper.getCytPrice(entity);
  3129. returnSuccessMsg("操作成功!");
  3130. return;
  3131. }
  3132. returnErrorMsg("找不到记录");
  3133. }
  3134. }
  3135. public void upload_erp_filecomplete()
  3136. {
  3137. if (UrlPostParmsCheck("ctid"))
  3138. {
  3139. string eid = GetPostString("ctid");
  3140. CeErpTradeCell entity = null;
  3141. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3142. if (entity != null)
  3143. {
  3144. entity.OrderState = 5; //设计完成
  3145. entity.Update();
  3146. returnSuccessMsg(eid + "上传成功,设计完成!");
  3147. return;
  3148. }
  3149. returnErrorMsg("找不到订单记录");
  3150. }
  3151. }
  3152. public void get_erp_designovertimelist()
  3153. {
  3154. DataStruct dStruct = GetPostStruct();
  3155. List<string> lw = new List<string>();
  3156. string tid = GetPostString("ctid");
  3157. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3158. string shopname = GetPostString("shopname");
  3159. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3160. string buyernick = GetPostString("buyer_nick");
  3161. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3162. string ResponsibleMan = GetPostString("responsible");
  3163. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3164. string date1 = GetPostString("date1");
  3165. string date2 = GetPostString("date2");
  3166. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3167. if (dw.Length > 0) lw.Add(dw);
  3168. string price1 = GetPostString("price1");
  3169. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3170. string price2 = GetPostString("price2");
  3171. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3172. string orderState = GetPostString("orderState");
  3173. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3174. string sellermemo = GetPostString("seller_memo");
  3175. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3176. lw.Add(string.Format("UnusualTag=3"));
  3177. lw.Add(string.Format("IsRefund<={0}", 1));
  3178. dStruct.Order = "WaitDesignTime desc";
  3179. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3180. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3181. writeGridDataTableJson(dStruct.TotalCount, dt);
  3182. }
  3183. //设计管理 获取抢单大厅列表
  3184. public void get_erp_grabinglist()
  3185. {
  3186. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3187. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3188. bool oldOrder = false;
  3189. if (org != null)
  3190. {
  3191. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3192. }
  3193. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3194. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3195. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3196. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3197. //先处理订单数据
  3198. if (dt.Rows.Count > 0)
  3199. {
  3200. Dictionary<string, int> design = null;
  3201. int count = 0;
  3202. foreach (DataRow row in dt.Rows)
  3203. {
  3204. if (map.ContainsKey(row["ShopId"].ToString()))
  3205. {
  3206. map.TryGetValue(row["ShopId"].ToString(), out design);
  3207. }
  3208. else
  3209. {
  3210. design = new Dictionary<string, int>();
  3211. }
  3212. if (design.ContainsKey(row["ProductId"].ToString()))
  3213. {
  3214. design.TryGetValue(row["ProductId"].ToString(), out count);
  3215. }
  3216. count++;
  3217. design[row["ProductId"].ToString()] = count;
  3218. map[row["ShopId"].ToString()] = design;
  3219. }
  3220. }
  3221. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3222. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3223. //把店铺排序和技能排序分类
  3224. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3225. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3226. if (design_dt.Rows.Count > 0)
  3227. {
  3228. Dictionary<string, string> design = null;
  3229. List<string> shopIds = null;
  3230. foreach (DataRow row in design_dt.Rows)
  3231. {
  3232. if ("0".Equals(row["designId"].ToString()))
  3233. {
  3234. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3235. {
  3236. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3237. }
  3238. else
  3239. {
  3240. shopIds = new List<string>();
  3241. }
  3242. shopIds.Add(row["shopId"].ToString());
  3243. shop_orders[row["orders"].ToString()] = shopIds;
  3244. }
  3245. else
  3246. {
  3247. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3248. {
  3249. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3250. }
  3251. else
  3252. {
  3253. design = new Dictionary<string, string>();
  3254. }
  3255. design[row["orders"].ToString()] = row["designId"].ToString();
  3256. design_orders[row["shopId"].ToString()] = design;
  3257. }
  3258. }
  3259. //处理成key value后根据key排序
  3260. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3261. foreach (List<string> val in shop_orders.Values)
  3262. {
  3263. if (val != null)
  3264. {
  3265. foreach (string key in val)
  3266. {
  3267. if (design_orders.ContainsKey(key.ToString()))
  3268. {
  3269. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3270. }
  3271. }
  3272. }
  3273. }
  3274. }
  3275. //校验哪个优先级有订单
  3276. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3277. foreach (string key in shop_orders.Keys)
  3278. {
  3279. List<string> ids = null;
  3280. shop_orders.TryGetValue(key, out ids);
  3281. //id为shopid
  3282. foreach (string id in ids)
  3283. {
  3284. Dictionary<string, int> list = null;
  3285. Dictionary<string, string> desing = null;
  3286. map.TryGetValue(id, out list);
  3287. design_orders.TryGetValue(id, out desing);
  3288. if (list != null && desing != null)
  3289. {
  3290. foreach (var item in desing)
  3291. {
  3292. int count = 0;
  3293. if (list.ContainsKey(item.Value))
  3294. {
  3295. list.TryGetValue(item.Value, out count);
  3296. if (count > 0)
  3297. {
  3298. designIds[id] = item.Value;
  3299. break;
  3300. }
  3301. }
  3302. }
  3303. }
  3304. }
  3305. if (designIds.Count > 0)
  3306. {
  3307. break;
  3308. }
  3309. }
  3310. DataTable table = new DataTable();
  3311. table.Columns.Add("tid", typeof(string));
  3312. table.Columns.Add("ctid", typeof(string));
  3313. table.Columns.Add("seller_nick", typeof(string));
  3314. table.Columns.Add("productName", typeof(string));
  3315. table.Columns.Add("pay_time", typeof(string));
  3316. table.Columns.Add("seller_memo", typeof(string));
  3317. if (designIds.Count > 0)
  3318. {
  3319. string shopId = "";
  3320. string productId = "";
  3321. foreach (var designInfo in designIds)
  3322. {
  3323. shopId = designInfo.Key;
  3324. productId = designInfo.Value;
  3325. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3326. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3327. if (dt.Rows.Count > 0)
  3328. {
  3329. foreach (DataRow row in dt.Rows)
  3330. {
  3331. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3332. {
  3333. DataRow data = table.NewRow();
  3334. data["ctid"] = row["ctid"].ToString();
  3335. data["tid"] = row["tid"].ToString();
  3336. data["seller_nick"] = ceErpShop.ShopName;
  3337. data["pay_time"] = row["pay_time"].ToString();
  3338. data["seller_memo"] = row["seller_memo"].ToString();
  3339. data["productName"] = ceErpProduct.PType;
  3340. table.Rows.Add(data);
  3341. }
  3342. }
  3343. }
  3344. }
  3345. }
  3346. writeGridDataTableJson(table.Rows.Count, table);
  3347. }
  3348. private object rushLockObject = new object();
  3349. public void set_erp_grabingorder()
  3350. {
  3351. if (UrlPostParmsCheck("ctid"))
  3352. {
  3353. int total = CurrentUser.User.Person.Total;
  3354. int userId = CurrentUser.User.ID;
  3355. int noFinish = CurrentUser.User.Person.NoFinish;
  3356. int finalization = CurrentUser.User.Person.Finalization;
  3357. string eids = GetPostString("ctid");
  3358. string key = "RushKey_" + userId;
  3359. int count = 0;
  3360. if (erpRedis.RedisHelper.KeyExists(key))
  3361. {
  3362. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3363. if (redisCount != null)
  3364. {
  3365. count = Convert.ToInt32(redisCount);
  3366. }
  3367. }
  3368. if (count >= total)
  3369. {
  3370. returnErrorMsg("半小时内已经抢" + total + "单");
  3371. return;
  3372. }
  3373. string[] ctidlist = eids.Split(',');
  3374. if (count + ctidlist.Length > total)
  3375. {
  3376. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3377. return;
  3378. }
  3379. int itag = 0;
  3380. lock (rushLockObject)
  3381. {
  3382. if (ctidlist.Length > 0)
  3383. {
  3384. string[] dtList = new string[ctidlist.Length];
  3385. for (int i = 0; i < ctidlist.Length; i++)
  3386. {
  3387. dtList[i] = "'" + ctidlist[i] + "'";
  3388. }
  3389. 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"));
  3390. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3391. if (dt_user.Rows.Count > 0)
  3392. {
  3393. int doing = 0;//未定稿
  3394. int finish = 0;//已完成
  3395. foreach (DataRow dr in dt_user.Rows)
  3396. {
  3397. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3398. {
  3399. doing++;
  3400. }
  3401. else
  3402. {
  3403. finish++;
  3404. }
  3405. }
  3406. if (doing >= noFinish)
  3407. {
  3408. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3409. return;
  3410. }
  3411. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3412. {
  3413. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3414. return;
  3415. }
  3416. }
  3417. //校验选择单子状态
  3418. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3419. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3420. if (dt.Rows.Count > 0)
  3421. {
  3422. List<string> list = new List<string>();
  3423. foreach (DataRow dr in dt.Rows)
  3424. {
  3425. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3426. {
  3427. list.Add(dr["ctid"].ToString());
  3428. }
  3429. }
  3430. if (list.Count > 0)
  3431. {
  3432. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3433. return;
  3434. }
  3435. }
  3436. foreach (string ctid in ctidlist)
  3437. {
  3438. CeErpTradeCell entity = null;
  3439. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3440. if (entity != null)
  3441. {
  3442. entity.OrderState = 3;
  3443. entity.DesignUserId = CurrentUser.UserID;
  3444. entity.WaitDesignTime = DateTime.Now;
  3445. entity.StartDesignTime = DateTime.Now;
  3446. entity.Update();
  3447. commonHelper.UpdateRelationOrder(entity.ctid);
  3448. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3449. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3450. itag++;
  3451. }
  3452. }
  3453. }
  3454. }
  3455. count += ctidlist.Length;
  3456. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3457. if (itag == 0)
  3458. returnErrorMsg("没有找到相关订单");
  3459. else
  3460. returnSuccessMsg("抢单成功!");
  3461. return;
  3462. }
  3463. }
  3464. public void get_erp_waitorderlist()
  3465. {
  3466. DataStruct dStruct = GetPostStruct();
  3467. List<string> lw = new List<string>();
  3468. string tid = GetPostString("ctid");
  3469. if (tid.Length > 0)
  3470. {
  3471. string select_tid = getTidByCtid(tid);
  3472. lw.Add(string.Format("tid='{0}'", select_tid));
  3473. }
  3474. string shopname = GetPostString("shopname");
  3475. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3476. string buyernick = GetPostString("buyer_nick");
  3477. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3478. string customer = GetPostString("customer");
  3479. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3480. string design = GetPostString("design");
  3481. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3482. string orderState = GetPostString("orderState");
  3483. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3484. string supplier = GetPostString("supplier");
  3485. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3486. string sellermemo = GetPostString("seller_memo");
  3487. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3488. string otherMemo = GetPostString("otherMemo");
  3489. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3490. string address = GetPostString("address");
  3491. 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));
  3492. string date1 = GetPostString("date1");
  3493. string date2 = GetPostString("date2");
  3494. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3495. if (dw.Length > 0) lw.Add(dw);
  3496. string price1 = GetPostString("price1");
  3497. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3498. string price2 = GetPostString("price2");
  3499. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3500. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3501. lw.Add(string.Format("IsSample != 2 "));
  3502. lw.Add(string.Format("OrderState = 5 "));
  3503. lw.Add(string.Format("IsRefund<={0}", 1));
  3504. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3505. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3506. string pagesize = GetPostString("pagesize");
  3507. if (pagesize != null)
  3508. {
  3509. dStruct.PageSize = 200;
  3510. }
  3511. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3512. List<string> tids = new List<string>();
  3513. if (dt != null)
  3514. {
  3515. dt.Columns.Add("compenPrice", typeof(double));
  3516. foreach (DataRow dr in dt.Rows)
  3517. {
  3518. if (Convert.IsDBNull(dr["compenPrice"]))
  3519. {
  3520. dr["compenPrice"] = 0;
  3521. }
  3522. tids.Add("'" + dr["tid"].ToString() + "'");
  3523. 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();
  3524. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3525. {
  3526. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3527. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3528. entity.SupplierId = suid;
  3529. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3530. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3531. entity.Update();
  3532. }
  3533. }
  3534. }
  3535. if (tids.Count > 0)
  3536. {
  3537. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3538. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3539. if (dt_price != null && dt_price.Rows.Count > 0)
  3540. {
  3541. foreach (DataRow dr in dt_price.Rows)
  3542. {
  3543. foreach (DataRow row in dt.Rows)
  3544. {
  3545. if (row["tid"].Equals(dr["ptid"]))
  3546. {
  3547. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3548. break;
  3549. }
  3550. }
  3551. }
  3552. }
  3553. }
  3554. writeGridDataTableJson(dStruct.TotalCount, dt);
  3555. }
  3556. public void get_erp_supplierwaitorderlist()
  3557. {
  3558. DataStruct dStruct = GetPostStruct();
  3559. List<string> lw = new List<string>();
  3560. string tid = GetPostString("ctid");
  3561. if (tid.Length > 0)
  3562. {
  3563. string select_tid = getTidByCtid(tid);
  3564. lw.Add(string.Format("tid='{0}'", select_tid));
  3565. }
  3566. string shopname = GetPostString("shopname");
  3567. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3568. string sellermemo = GetPostString("seller_memo");
  3569. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3570. string date1 = GetPostString("date1");
  3571. string date2 = GetPostString("date2");
  3572. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3573. if (dw.Length > 0) lw.Add(dw);
  3574. lw.Add(string.Format("OrderState = 5 "));
  3575. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3576. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3577. {
  3578. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3579. }
  3580. string supplier = GetPostString("supplier");
  3581. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3582. {
  3583. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3584. }
  3585. lw.Add(string.Format("IsRefund<={0}", 1));
  3586. dStruct.Order = "FinishDesignTime desc";
  3587. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3588. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3589. if (dt != null)
  3590. {
  3591. foreach (DataRow dr in dt.Rows)
  3592. {
  3593. 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();
  3594. }
  3595. }
  3596. writeGridDataTableJson(dStruct.TotalCount, dt);
  3597. }
  3598. public void upd_erp_verifytosupplier()
  3599. {
  3600. if (UrlPostParmsCheck("ctid"))
  3601. {
  3602. string eids = GetPostString("ctid");
  3603. CeErpTradeCell entity = null;
  3604. string[] eidsList = eids.Split(',');
  3605. if (eidsList.Length <= 0)
  3606. {
  3607. returnErrorMsg("订单号不能空");
  3608. return;
  3609. }
  3610. List<string> tLst = new List<string>();
  3611. foreach (string ctidstr in eidsList)
  3612. {
  3613. tLst.Add("'" + ctidstr + "'");
  3614. CeErpDataSendOrderInfo.createObject(ctidstr);
  3615. }
  3616. string needtids = string.Join(",", tLst.ToArray());
  3617. StringBuilder sql = new StringBuilder();
  3618. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3619. 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);
  3620. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3621. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3622. returnSuccessMsg("操作成功!");
  3623. return;
  3624. /**foreach (string ctidstr in eidsList)
  3625. {
  3626. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3627. if (entity != null)
  3628. {
  3629. if (entity.SupplierId == 0)
  3630. {
  3631. continue;
  3632. }
  3633. entity.IsVerifyToSupplier = true;
  3634. if (entity.IsReturn == 1) //1是供应商打回
  3635. {
  3636. entity.IsReturn = 0;
  3637. }
  3638. entity.FinishPlaceTime = DateTime.Now;
  3639. entity.PlaceUserId = CurrentUser.UserID;
  3640. entity.Update();
  3641. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3642. }
  3643. }
  3644. returnSuccessMsg("操作成功!");
  3645. return;**/
  3646. }
  3647. }
  3648. public void upd_erp_supplierback()
  3649. {
  3650. if (UrlPostParmsCheck("ctid"))
  3651. {
  3652. string eid = GetPostString("ctid");
  3653. string reason = GetPostString("returnreason");
  3654. CeErpTradeCell entity = null;
  3655. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3656. if (entity != null)
  3657. {
  3658. string message = "操作成功!";
  3659. string isDown = "";
  3660. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3661. {
  3662. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3663. isDown = "被点击下载";
  3664. }
  3665. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3666. {
  3667. string key = "return_order_" + entity.SupplierId;
  3668. List<string> list = new List<string>();
  3669. if (RedisHelper.HasKey(key))
  3670. {
  3671. object data = RedisHelper.StringGet(key);
  3672. list = Convert.ToString(data).Split(',').ToList();
  3673. }
  3674. list.Add(eid);
  3675. RedisHelper.StringSet(key, string.Join(",", list));
  3676. }
  3677. entity.IsVerifyToSupplier = false;
  3678. entity.IsReturn = 1;
  3679. entity.IsHaveNewOrder = 0;
  3680. entity.ReturnTime = DateTime.Now;
  3681. entity.ReturnReason = reason;
  3682. if (entity.OrderState == 6)
  3683. {
  3684. entity.OrderState = 5;
  3685. }
  3686. entity.Update();
  3687. CeErpSukuraData.createInfo(entity.ctid, 5);
  3688. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3689. returnSuccessMsg(message);
  3690. return;
  3691. }
  3692. returnErrorMsg("找不到订单记录");
  3693. }
  3694. }
  3695. public void upd_erp_toaftersaleorder()
  3696. {
  3697. if (UrlPostParmsCheck("ctid"))
  3698. {
  3699. string eid = GetPostString("ctid");
  3700. string reason = GetPostString("returnreason");
  3701. CeErpTradeCell entity = null;
  3702. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3703. if (entity != null)
  3704. {
  3705. if (entity.isAfterSaleOrder != 1)
  3706. {
  3707. returnErrorMsg("带S的售后单才能打回给售后");
  3708. return;
  3709. }
  3710. if (entity.OrderState >= 5)
  3711. {
  3712. returnErrorMsg("已经设计完成了不能打回给售后");
  3713. return;
  3714. }
  3715. entity.OrderState = 0;
  3716. entity.IsReturn = 3;
  3717. entity.ReturnTime = DateTime.Now;
  3718. entity.UpdateTime = DateTime.Now;
  3719. entity.ReturnReason = reason;
  3720. entity.Update();
  3721. CeErpSukuraData.createInfo(entity.ctid, 5);
  3722. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3723. returnSuccessMsg("操作成功!");
  3724. return;
  3725. }
  3726. returnErrorMsg("找不到订单记录");
  3727. }
  3728. }
  3729. public void upd_erp_aftersaletodesign()
  3730. {
  3731. if (UrlPostParmsCheck("ctid"))
  3732. {
  3733. string eid = GetPostString("ctid");
  3734. CeErpTradeCell entity = null;
  3735. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3736. if (entity != null)
  3737. {
  3738. entity.OrderState = 3;
  3739. entity.IsReturn = 0;
  3740. entity.UpdateTime = DateTime.Now;
  3741. entity.Update();
  3742. CeErpSukuraData.createInfo(entity.ctid, 5);
  3743. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3744. returnSuccessMsg("操作成功!");
  3745. return;
  3746. }
  3747. returnErrorMsg("找不到订单记录");
  3748. }
  3749. }
  3750. public void assign_erp_supplier()
  3751. {
  3752. if (UrlPostParmsCheck("ctid"))
  3753. {
  3754. string eids = GetPostString("ctid");
  3755. int sid = GetPostInt("SupplierName");
  3756. string fromTag = GetPostString("tag");
  3757. string[] eidList = eids.Split(',');
  3758. if (eidList.Length <= 0)
  3759. {
  3760. returnErrorMsg("指派不能为空");
  3761. return;
  3762. }
  3763. string errMsg = "";
  3764. string suname = commonHelper.getSupplierNameById(sid);
  3765. foreach (string ctid in eidList)
  3766. {
  3767. CeErpTradeCell entity = null;
  3768. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3769. if (entity != null)
  3770. {
  3771. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3772. {
  3773. errMsg += (ctid + "指派失败!!!");
  3774. continue;
  3775. }
  3776. entity.SupplierId = sid;
  3777. entity.Update();
  3778. commonHelper.UpdateRelationOrder(entity.ctid);
  3779. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3780. if (entity.OrderState >= 6)
  3781. {
  3782. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3783. //{
  3784. // string msl = entity.MakeSupplier;
  3785. // string[] mslist = msl.Split(',');
  3786. // 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);
  3787. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3788. //}
  3789. //else
  3790. //{
  3791. StringBuilder sql = new StringBuilder();
  3792. 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);
  3793. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3794. //}
  3795. }
  3796. }
  3797. else
  3798. {
  3799. continue;
  3800. }
  3801. }
  3802. if (errMsg.Length > 0)
  3803. {
  3804. returnErrorMsg(errMsg);
  3805. return;
  3806. }
  3807. returnSuccessMsg("操作成功!");
  3808. return;
  3809. }
  3810. }
  3811. public void assign_erp_makesupplier()
  3812. {
  3813. if (UrlPostParmsCheck("ctid"))
  3814. {
  3815. string eids = GetPostString("ctid");
  3816. string sname = GetPostString("SupplierName");
  3817. string[] eidList = eids.Split(',');
  3818. if (eidList.Length <= 0)
  3819. {
  3820. returnErrorMsg("指派不能为空");
  3821. return;
  3822. }
  3823. List<string> tLst = new List<string>();
  3824. foreach (string ctid in eidList)
  3825. {
  3826. CeErpTradeCell entity = null;
  3827. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3828. if (entity != null)
  3829. {
  3830. entity.MakeSupplier = sname;
  3831. entity.Update();
  3832. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3833. tLst.Add("'" + ctid + "'");
  3834. }
  3835. else
  3836. {
  3837. continue;
  3838. }
  3839. }
  3840. string ctids = string.Join(",", tLst.ToArray());
  3841. StringBuilder sql2 = new StringBuilder();
  3842. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3843. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3844. returnSuccessMsg("操作成功!");
  3845. return;
  3846. }
  3847. }
  3848. public void ins_erp_returnreason()
  3849. {
  3850. if (UrlPostParmsCheck("ctid"))
  3851. {
  3852. string eid = GetPostString("ctid");
  3853. CeErpTradeCell entity = null;
  3854. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3855. string userpost = CurrentUser.UserPost.Post.Code;
  3856. if (entity != null)
  3857. {
  3858. bool isPlace = false;
  3859. if (entity.OrderState > 6)
  3860. {
  3861. returnErrorMsg("已发货无法打回!");
  3862. return;
  3863. }
  3864. if (entity.OrderState == 6)
  3865. {
  3866. isPlace = true;
  3867. }
  3868. bool isNeedUpdateCell2 = false;
  3869. if (entity.OrderState >= 6)
  3870. {
  3871. isNeedUpdateCell2 = true;
  3872. }
  3873. int returnTag = 2;
  3874. if (userpost == "Supplier")
  3875. {
  3876. returnTag = 1;
  3877. }
  3878. int toType = GetPostInt("totype");
  3879. string fromType = "3";
  3880. if (entity.OrderState < 5)
  3881. {
  3882. fromType = "3";
  3883. }
  3884. else
  3885. {
  3886. fromType = "4";
  3887. }
  3888. if (entity.IsXianHuo == 0)
  3889. {
  3890. if (returnTag == 2)
  3891. {
  3892. if (toType == 1)
  3893. {
  3894. entity.OrderState = 0;
  3895. entity.ReturnUserType = 1;
  3896. string clearman = GetPostString("clearman");
  3897. if (!string.IsNullOrEmpty(clearman))
  3898. {
  3899. entity.DesignUserId = 0;
  3900. }
  3901. }
  3902. else
  3903. {
  3904. entity.OrderState = 3;
  3905. entity.ReturnUserType = 2;
  3906. }
  3907. entity.IsReadTag = 1;
  3908. }
  3909. else if (returnTag == 1)
  3910. {
  3911. entity.OrderState = 5;
  3912. }
  3913. entity.IsVerifyToSupplier = false;
  3914. }
  3915. if (entity.IsXianHuo == 1)
  3916. {
  3917. entity.OrderState = 5;
  3918. }
  3919. entity.UnusualTag = 0;
  3920. entity.UnusualTime = null;
  3921. entity.UnusualCon = "";
  3922. entity.IsReturn = returnTag;
  3923. entity.ReturnTime = DateTime.Now;
  3924. entity.UpdateTime = DateTime.Now;
  3925. entity.ReturnReason = GetPostString("returnreason");
  3926. entity.Update();
  3927. if (entity.OrderState == 3)
  3928. {
  3929. ApiVo apiVo = new ApiVo();
  3930. apiVo.orderNumber = entity.ctid;
  3931. apiVo.actionName = "rebutDesign";
  3932. apiVo.orderRemarks = entity.ReturnReason;
  3933. designHelper.API_WorkCore(apiVo);//rebutDesign
  3934. }
  3935. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3936. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3937. {
  3938. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3939. }
  3940. CeErpSukuraData.createInfo(entity.ctid, 5);
  3941. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3942. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3943. if (isPlace)
  3944. {
  3945. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3946. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3947. if (dth != null && dth.Rows.Count > 0)
  3948. {
  3949. dataSendOrderBean dataSendOrderBean = null;
  3950. foreach (DataRow item in dth.Rows)
  3951. {
  3952. try
  3953. {
  3954. dataSendOrderBean = new dataSendOrderBean();
  3955. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3956. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3957. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3958. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3959. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3960. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3961. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3962. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3963. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3964. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3965. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3966. dataSendOrderBean.Radio1723534706288 = "打回";
  3967. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3968. if (result != null)
  3969. {
  3970. if ("0".Equals(result.errcode))
  3971. {
  3972. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3973. }
  3974. else
  3975. {
  3976. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3977. }
  3978. }
  3979. }
  3980. catch (Exception ex)
  3981. {
  3982. }
  3983. }
  3984. }
  3985. }
  3986. if (isNeedUpdateCell2)
  3987. {
  3988. if (entity.MakeSupplier.IndexOf(",") != -1)
  3989. {
  3990. StringBuilder sql2 = new StringBuilder();
  3991. 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);
  3992. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3993. }
  3994. else
  3995. {
  3996. StringBuilder sql2 = new StringBuilder();
  3997. 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);
  3998. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3999. }
  4000. }
  4001. returnSuccessMsg("操作成功!");
  4002. return;
  4003. }
  4004. returnErrorMsg("找不到订单记录");
  4005. }
  4006. }
  4007. public void cyt_erp_returnreason()
  4008. {
  4009. if (UrlPostParmsCheck("ctid"))
  4010. {
  4011. string eid = GetPostString("ctid");
  4012. CeErpTradeCell entity = null;
  4013. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4014. string userpost = CurrentUser.UserPost.Post.Code;
  4015. if (entity != null)
  4016. {
  4017. if (entity.OrderState > 6)
  4018. {
  4019. returnErrorMsg("已发货无法打回!");
  4020. return;
  4021. }
  4022. JObject jsonObject = new JObject
  4023. {
  4024. { "Userid", "77886" },
  4025. { "Pwd", "lt666888" },
  4026. { "LTOrderId",eid }
  4027. };
  4028. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4029. JObject jsonObjects = JObject.Parse(response);
  4030. string msg = (string)jsonObjects["msg"];
  4031. if (msg != "取消成功")
  4032. {
  4033. returnErrorMsg(msg);
  4034. return;
  4035. }
  4036. bool isNeedUpdateCell2 = false;
  4037. if (entity.OrderState >= 6)
  4038. {
  4039. isNeedUpdateCell2 = true;
  4040. }
  4041. int returnTag = 2;
  4042. if (userpost == "Supplier")
  4043. {
  4044. returnTag = 1;
  4045. }
  4046. if (entity.IsXianHuo == 0)
  4047. {
  4048. if (returnTag == 2)
  4049. {
  4050. int toType = GetPostInt("totype");
  4051. if (toType == 1)
  4052. {
  4053. entity.OrderState = 0;
  4054. entity.ReturnUserType = 1;
  4055. }
  4056. else
  4057. {
  4058. entity.OrderState = 4;
  4059. entity.ReturnUserType = 2;
  4060. }
  4061. entity.IsReadTag = 1;
  4062. }
  4063. else if (returnTag == 1)
  4064. {
  4065. entity.OrderState = 5;
  4066. }
  4067. entity.IsVerifyToSupplier = false;
  4068. }
  4069. entity.UnusualTag = 0;
  4070. entity.UnusualTime = null;
  4071. entity.UnusualCon = "";
  4072. entity.IsReturn = returnTag;
  4073. entity.ReturnTime = DateTime.Now;
  4074. entity.ReturnReason = GetPostString("returnreason");
  4075. entity.Update();
  4076. if (entity.OrderState == 4)
  4077. {
  4078. ApiVo apiVo = new ApiVo();
  4079. apiVo.orderNumber = entity.ctid;
  4080. apiVo.actionName = "rebutDesign";
  4081. apiVo.orderRemarks = entity.ReturnReason;
  4082. designHelper.API_WorkCore(apiVo);//rebutDesign
  4083. }
  4084. CeErpSukuraData.createInfo(entity.ctid, 5);
  4085. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4086. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4087. if (isNeedUpdateCell2)
  4088. {
  4089. if (entity.MakeSupplier.IndexOf(",") != -1)
  4090. {
  4091. StringBuilder sql2 = new StringBuilder();
  4092. 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);
  4093. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4094. }
  4095. else
  4096. {
  4097. StringBuilder sql2 = new StringBuilder();
  4098. 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);
  4099. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4100. }
  4101. }
  4102. returnSuccessMsg("操作成功!");
  4103. return;
  4104. }
  4105. returnErrorMsg("找不到订单记录");
  4106. }
  4107. }
  4108. public void upd_erp_xianhuoreturntag()
  4109. {
  4110. if (UrlPostParmsCheck("ctid"))
  4111. {
  4112. string eids = GetPostString("ctid");
  4113. string[] ctids = eids.Split(',');
  4114. foreach (string ctid in ctids)
  4115. {
  4116. CeErpTradeCell entity = null;
  4117. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4118. if (entity != null)
  4119. {
  4120. entity.IsReturn = 0;
  4121. entity.Update();
  4122. CeErpSukuraData.createInfo(entity.ctid, 5);
  4123. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4124. }
  4125. }
  4126. returnSuccessMsg("操作成功!");
  4127. return;
  4128. }
  4129. }
  4130. public void get_erp_waitdeliverylist()
  4131. {
  4132. DataStruct dStruct = GetPostStruct();
  4133. List<string> lw = new List<string>();
  4134. string tid = GetPostString("ctid");
  4135. if (tid.Length > 0)
  4136. {
  4137. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4138. if (tid.Length > 5)
  4139. {
  4140. List<string> tids = getTidByCtidLike(tid);
  4141. if (tids.Count > 0 && tids.Count < 10)
  4142. {
  4143. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4144. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4145. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4146. {
  4147. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4148. }*/
  4149. }
  4150. }
  4151. lw.Add(tid_sql);
  4152. }
  4153. string shopname = GetPostString("shopname");
  4154. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4155. string buyernick = GetPostString("buyer_nick");
  4156. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4157. //if (tid.Length == 0 && buyernick.Length == 0)
  4158. //{
  4159. // lw.Add(string.Format("IsRefund<={0}", 1));
  4160. //}
  4161. string customer = GetPostString("customer");
  4162. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4163. string design = GetPostString("design");
  4164. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4165. string orderState = GetPostString("orderState");
  4166. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4167. string address = GetPostString("address");
  4168. 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));
  4169. string sellermemo = GetPostString("seller_memo");
  4170. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4171. string supplier = GetPostString("supplier");
  4172. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4173. string OrderArea = GetPostString("order_area");
  4174. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4175. string placedate1 = GetPostString("placedate1");
  4176. string placedate2 = GetPostString("placedate2");
  4177. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4178. if (fdw.Length > 0) lw.Add(fdw);
  4179. string price1 = GetPostString("price1");
  4180. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4181. string price2 = GetPostString("price2");
  4182. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4183. string unusualCon = GetPostString("unusualcon");
  4184. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4185. string otherMemo = GetPostString("otherMemo");
  4186. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4187. string posTag = CurrentUser.UserPost.Post.Code;
  4188. if (posTag == "Supplier")
  4189. {
  4190. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4191. }
  4192. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4193. lw.Add(string.Format("type != 'PDD' "));
  4194. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4195. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4196. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4197. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4198. writeGridDataTableJson(dStruct.TotalCount, dt);
  4199. }
  4200. public void get_erp_changedeliverylist()
  4201. {
  4202. DataStruct dStruct = GetPostStruct();
  4203. List<string> lw = new List<string>();
  4204. string tid = GetPostString("ctid");
  4205. if (tid.Length > 0)
  4206. {
  4207. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4208. if (tid.Length > 5)
  4209. {
  4210. List<string> tids = getTidByCtidLike(tid);
  4211. if (tids.Count > 0 && tids.Count < 10)
  4212. {
  4213. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4214. }
  4215. }
  4216. lw.Add(tid_sql);
  4217. }
  4218. string shopname = GetPostString("shopname");
  4219. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4220. string buyernick = GetPostString("buyer_nick");
  4221. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4222. //if (tid.Length == 0 && buyernick.Length == 0)
  4223. //{
  4224. // lw.Add(string.Format("IsRefund<={0}", 1));
  4225. //}
  4226. string customer = GetPostString("customer");
  4227. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4228. string design = GetPostString("design");
  4229. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4230. string orderState = GetPostString("orderState");
  4231. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4232. string address = GetPostString("address");
  4233. 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));
  4234. string sellermemo = GetPostString("seller_memo");
  4235. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4236. string supplier = GetPostString("supplier");
  4237. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4238. string OrderArea = GetPostString("order_area");
  4239. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4240. string placedate1 = GetPostString("placedate1");
  4241. string placedate2 = GetPostString("placedate2");
  4242. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4243. if (fdw.Length > 0) lw.Add(fdw);
  4244. string price1 = GetPostString("price1");
  4245. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4246. string price2 = GetPostString("price2");
  4247. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4248. string unusualCon = GetPostString("unusualcon");
  4249. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4250. string otherMemo = GetPostString("otherMemo");
  4251. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4252. string posTag = CurrentUser.UserPost.Post.Code;
  4253. if (posTag == "Supplier")
  4254. {
  4255. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4256. }
  4257. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4258. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4259. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4260. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4261. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4262. /*if (tid.Length > 0)
  4263. {
  4264. List<string> tids = new List<string>();
  4265. if (dt != null && dt.Rows.Count > 0)
  4266. {
  4267. foreach (DataRow item in dt.Rows)
  4268. {
  4269. tids.Add("'" + item["tid"] + "'");
  4270. }
  4271. }
  4272. if (tids.Count > 0)
  4273. {
  4274. lw.RemoveAt(0);
  4275. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4276. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4277. dt = WebCache.GetData("view_erptradecell", dStruct);
  4278. }
  4279. }*/
  4280. writeGridDataTableJson(dStruct.TotalCount, dt);
  4281. }
  4282. public void get_erp_pddderiving()
  4283. {
  4284. DataStruct dStruct = GetPostStruct();
  4285. List<string> lw = new List<string>();
  4286. string tid = GetPostString("ctid");
  4287. if (tid.Length > 0)
  4288. {
  4289. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4290. if (tid.Length > 5)
  4291. {
  4292. List<string> tids = getTidByCtidLike(tid);
  4293. if (tids.Count > 0 && tids.Count < 10)
  4294. {
  4295. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4296. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4297. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4298. {
  4299. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4300. }*/
  4301. }
  4302. }
  4303. lw.Add(tid_sql);
  4304. }
  4305. string shopname = GetPostString("shopname");
  4306. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4307. string buyernick = GetPostString("buyer_nick");
  4308. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4309. //if (tid.Length == 0 && buyernick.Length == 0)
  4310. //{
  4311. // lw.Add(string.Format("IsRefund<={0}", 1));
  4312. //}
  4313. string customer = GetPostString("customer");
  4314. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4315. string design = GetPostString("design");
  4316. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4317. string orderState = GetPostString("orderState");
  4318. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4319. string address = GetPostString("address");
  4320. 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));
  4321. string sellermemo = GetPostString("seller_memo");
  4322. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4323. string supplier = GetPostString("supplier");
  4324. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4325. string OrderArea = GetPostString("order_area");
  4326. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4327. string placedate1 = GetPostString("placedate1");
  4328. string placedate2 = GetPostString("placedate2");
  4329. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4330. if (fdw.Length > 0) lw.Add(fdw);
  4331. string price1 = GetPostString("price1");
  4332. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4333. string price2 = GetPostString("price2");
  4334. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4335. string unusualCon = GetPostString("unusualcon");
  4336. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4337. string posTag = CurrentUser.UserPost.Post.Code;
  4338. if (posTag == "Supplier")
  4339. {
  4340. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4341. }
  4342. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4343. lw.Add(string.Format("type = 'PDD' "));
  4344. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4345. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4346. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4347. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4348. /*if (tid.Length > 0)
  4349. {
  4350. List<string> tids = new List<string>();
  4351. if (dt != null && dt.Rows.Count > 0)
  4352. {
  4353. foreach (DataRow item in dt.Rows)
  4354. {
  4355. tids.Add("'" + item["tid"] + "'");
  4356. }
  4357. }
  4358. if (tids.Count > 0)
  4359. {
  4360. lw.RemoveAt(0);
  4361. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4362. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4363. dt = WebCache.GetData("view_erptradecell", dStruct);
  4364. }
  4365. }*/
  4366. writeGridDataTableJson(dStruct.TotalCount, dt);
  4367. }
  4368. public void get_erp_jdderiving()
  4369. {
  4370. DataStruct dStruct = GetPostStruct();
  4371. List<string> lw = new List<string>();
  4372. string tid = GetPostString("ctid");
  4373. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4374. string shopname = GetPostString("shopname");
  4375. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4376. string buyernick = GetPostString("buyer_nick");
  4377. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4378. //if (tid.Length == 0 && buyernick.Length == 0)
  4379. //{
  4380. // lw.Add(string.Format("IsRefund<={0}", 1));
  4381. //}
  4382. string customer = GetPostString("customer");
  4383. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4384. string design = GetPostString("design");
  4385. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4386. string orderState = GetPostString("orderState");
  4387. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4388. string address = GetPostString("address");
  4389. 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));
  4390. string sellermemo = GetPostString("seller_memo");
  4391. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4392. string supplier = GetPostString("supplier");
  4393. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4394. string OrderArea = GetPostString("order_area");
  4395. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4396. string placedate1 = GetPostString("placedate1");
  4397. string placedate2 = GetPostString("placedate2");
  4398. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4399. if (fdw.Length > 0) lw.Add(fdw);
  4400. string price1 = GetPostString("price1");
  4401. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4402. string price2 = GetPostString("price2");
  4403. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4404. string unusualCon = GetPostString("unusualcon");
  4405. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4406. string posTag = CurrentUser.UserPost.Post.Code;
  4407. if (posTag == "Supplier")
  4408. {
  4409. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4410. }
  4411. lw.Add(string.Format("OrderState = 6 "));
  4412. lw.Add(string.Format("type = 'JD' "));
  4413. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4414. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4415. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4416. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4417. writeGridDataTableJson(dStruct.TotalCount, dt);
  4418. }
  4419. public void get_erp_demoorderlist()
  4420. {
  4421. DataStruct dStruct = GetPostStruct();
  4422. List<string> lw = new List<string>();
  4423. string tid = GetPostString("ctid");
  4424. if (tid.Length > 0)
  4425. {
  4426. string select_tid = getTidByCtid(tid);
  4427. lw.Add(string.Format("tid='{0}'", select_tid));
  4428. }
  4429. string shopname = GetPostString("shopname");
  4430. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4431. string buyernick = GetPostString("buyer_nick");
  4432. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4433. string customer = GetPostString("customer");
  4434. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4435. string design = GetPostString("design");
  4436. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4437. string orderState = GetPostString("orderState");
  4438. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4439. string address = GetPostString("address");
  4440. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4441. string sellermemo = GetPostString("seller_memo");
  4442. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4443. string supplier = GetPostString("supplier");
  4444. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4445. string OrderArea = GetPostString("order_area");
  4446. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4447. string date1 = GetPostString("date1");
  4448. string date2 = GetPostString("date2");
  4449. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4450. if (dw.Length > 0) lw.Add(dw);
  4451. string price1 = GetPostString("price1");
  4452. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4453. string price2 = GetPostString("price2");
  4454. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4455. string posTag = CurrentUser.UserPost.Post.Code;
  4456. if (posTag == "Supplier")
  4457. {
  4458. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4459. }
  4460. //lw.Add(string.Format("OrderState = 6 "));
  4461. lw.Add(string.Format("IsSample={0}", 3));
  4462. lw.Add(string.Format("IsRefund<={0}", 1));
  4463. dStruct.Order = "pay_time desc";
  4464. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4465. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4466. writeGridDataTableJson(dStruct.TotalCount, dt);
  4467. }
  4468. public void save_erp_checkmemo()
  4469. {
  4470. if (UrlPostParmsCheck("ctid"))
  4471. {
  4472. string ctid = GetPostString("ctid");
  4473. CeErpTradeCell entity = null;
  4474. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4475. if (entity != null)
  4476. {
  4477. entity.CheckMemo = GetPostString("CheckMemo");
  4478. entity.Update();
  4479. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4480. if (trade != null)
  4481. {
  4482. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4483. }
  4484. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4485. returnSuccessMsg("保存成功!");
  4486. return;
  4487. }
  4488. returnErrorMsg("找不到记录");
  4489. }
  4490. }
  4491. public void get_erp_returnlist()
  4492. {
  4493. DataStruct dStruct = GetPostStruct();
  4494. List<string> lw = new List<string>();
  4495. string tid = GetPostString("ctid");
  4496. if (tid.Length > 0)
  4497. {
  4498. string select_tid = getTidByCtid(tid);
  4499. lw.Add(string.Format("tid='{0}'", select_tid));
  4500. }
  4501. string shopname = GetPostString("shopname");
  4502. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4503. string buyernick = GetPostString("buyer_nick");
  4504. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4505. string customer = GetPostString("customer");
  4506. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4507. string design = GetPostString("design");
  4508. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4509. string orderState = GetPostString("orderState");
  4510. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4511. string address = GetPostString("address");
  4512. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4513. string sellermemo = GetPostString("seller_memo");
  4514. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4515. string supplier = GetPostString("supplier");
  4516. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4517. string date1 = GetPostString("date1");
  4518. string date2 = GetPostString("date2");
  4519. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4520. if (dw.Length > 0) lw.Add(dw);
  4521. string bdate1 = GetPostString("backdate1");
  4522. string bdate2 = GetPostString("backdate2");
  4523. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4524. if (dw_back.Length > 0) lw.Add(dw_back);
  4525. string price1 = GetPostString("price1");
  4526. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4527. string price2 = GetPostString("price2");
  4528. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4529. lw.Add(string.Format("IsReturn>0"));
  4530. lw.Add(string.Format("IsXianHuo=0"));
  4531. lw.Add(string.Format("IsReturn!=3"));
  4532. string backtype = GetPostString("backtype");
  4533. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4534. dStruct.Order = "FinishDesignTime desc";
  4535. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4536. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4537. writeGridDataTableJson(dStruct.TotalCount, dt);
  4538. }
  4539. public void get_erp_today_sumreturn()
  4540. {
  4541. DataStruct dStruct = GetPostStruct();
  4542. List<string> lw = new List<string>();
  4543. string bdate1 = GetPostString("returnTimeS");
  4544. string bdate2 = GetPostString("returnTimeE");
  4545. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4546. if (dw_back.Length > 0) lw.Add(dw_back);
  4547. lw.Add(string.Format("IsReturn=0"));
  4548. lw.Add(string.Format("IsXianHuo=0"));
  4549. string mainWhere = string.Join(" and ", lw.ToArray());
  4550. string sql = "";
  4551. if (dw_back.Length > 0)
  4552. {
  4553. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4554. }
  4555. else
  4556. {
  4557. 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 + "'";
  4558. }
  4559. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4560. decimal total = 0, today_finish = 0;
  4561. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4562. {
  4563. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4564. }
  4565. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4566. {
  4567. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4568. }
  4569. var res = new
  4570. {
  4571. data = total,
  4572. data1 = today_finish,
  4573. };
  4574. string ro_jsond = JsonConvert.SerializeObject(res);
  4575. returnSuccess(ro_jsond);
  4576. return;
  4577. }
  4578. public void get_erp_allreturnlist()
  4579. {
  4580. DataStruct dStruct = GetPostStruct();
  4581. List<string> lw = new List<string>();
  4582. string tid = GetPostString("ctid");
  4583. if (tid.Length > 0)
  4584. {
  4585. string select_tid = getTidByCtid(tid);
  4586. lw.Add(string.Format("tid='{0}'", select_tid));
  4587. }
  4588. string shopname = GetPostString("shopname");
  4589. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4590. string buyernick = GetPostString("buyer_nick");
  4591. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4592. string customer = GetPostString("customer");
  4593. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4594. string design = GetPostString("design");
  4595. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4596. string orderState = GetPostString("orderState");
  4597. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4598. string address = GetPostString("address");
  4599. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4600. string sellermemo = GetPostString("seller_memo");
  4601. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4602. string supplier = GetPostString("supplier");
  4603. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4604. string date1 = GetPostString("date1");
  4605. string date2 = GetPostString("date2");
  4606. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4607. if (dw.Length > 0) lw.Add(dw);
  4608. string bdate1 = GetPostString("backdate1");
  4609. string bdate2 = GetPostString("backdate2");
  4610. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4611. if (dw_back.Length > 0) lw.Add(dw_back);
  4612. string price1 = GetPostString("price1");
  4613. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4614. string price2 = GetPostString("price2");
  4615. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4616. string backreason = GetPostString("backreason");
  4617. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4618. lw.Add(string.Format("IsXianHuo=0"));
  4619. lw.Add(string.Format("ReturnTime != ''"));
  4620. string backtype = GetPostString("backtype");
  4621. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4622. dStruct.Order = "FinishDesignTime desc";
  4623. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4624. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4625. writeGridDataTableJson(dStruct.TotalCount, dt);
  4626. }
  4627. public void get_erp_aftersalereturnlist()
  4628. {
  4629. DataStruct dStruct = GetPostStruct();
  4630. List<string> lw = new List<string>();
  4631. string tid = GetPostString("ctid");
  4632. if (tid.Length > 0)
  4633. {
  4634. string select_tid = getTidByCtid(tid);
  4635. lw.Add(string.Format("tid='{0}'", select_tid));
  4636. }
  4637. string shopname = GetPostString("shopname");
  4638. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4639. string buyernick = GetPostString("buyer_nick");
  4640. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4641. string customer = GetPostString("customer");
  4642. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4643. string design = GetPostString("design");
  4644. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4645. string orderState = GetPostString("orderState");
  4646. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4647. string address = GetPostString("address");
  4648. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4649. string sellermemo = GetPostString("seller_memo");
  4650. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4651. string supplier = GetPostString("supplier");
  4652. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4653. string date1 = GetPostString("date1");
  4654. string date2 = GetPostString("date2");
  4655. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4656. if (dw.Length > 0) lw.Add(dw);
  4657. string bdate1 = GetPostString("backdate1");
  4658. string bdate2 = GetPostString("backdate2");
  4659. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4660. if (dw_back.Length > 0) lw.Add(dw_back);
  4661. string price1 = GetPostString("price1");
  4662. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4663. string price2 = GetPostString("price2");
  4664. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4665. lw.Add(string.Format("IsReturn=3"));
  4666. string backtype = GetPostString("backtype");
  4667. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4668. string backreason = GetPostString("backreason");
  4669. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4670. dStruct.Order = "ReturnTime desc";
  4671. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4672. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4673. writeGridDataTableJson(dStruct.TotalCount, dt);
  4674. }
  4675. public void get_erp_xianhuoreturnlist()
  4676. {
  4677. DataStruct dStruct = GetPostStruct();
  4678. List<string> lw = new List<string>();
  4679. string tid = GetPostString("ctid");
  4680. if (tid.Length > 0)
  4681. {
  4682. string select_tid = getTidByCtid(tid);
  4683. lw.Add(string.Format("tid='{0}'", select_tid));
  4684. }
  4685. string shopname = GetPostString("shopname");
  4686. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4687. string buyernick = GetPostString("buyer_nick");
  4688. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4689. string customer = GetPostString("customer");
  4690. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4691. string design = GetPostString("design");
  4692. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4693. string orderState = GetPostString("orderState");
  4694. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4695. string address = GetPostString("address");
  4696. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4697. string sellermemo = GetPostString("seller_memo");
  4698. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4699. string supplier = GetPostString("supplier");
  4700. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4701. string OrderArea = GetPostString("order_area");
  4702. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4703. string date1 = GetPostString("date1");
  4704. string date2 = GetPostString("date2");
  4705. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4706. if (dw.Length > 0) lw.Add(dw);
  4707. string price1 = GetPostString("price1");
  4708. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4709. string price2 = GetPostString("price2");
  4710. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4711. string posTag = CurrentUser.UserPost.Post.Code;
  4712. if (posTag == "Supplier")
  4713. {
  4714. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4715. }
  4716. lw.Add(string.Format("OrderState=6 "));
  4717. lw.Add(string.Format("IsXianHuo=1 "));
  4718. lw.Add(string.Format("IsReturn>0 "));
  4719. lw.Add(string.Format("IsReturn!=3"));
  4720. lw.Add(string.Format("IsRefund<={0}", 1));
  4721. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4722. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4723. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4724. writeGridDataTableJson(dStruct.TotalCount, dt);
  4725. }
  4726. public void set_erp_orderdelivery()
  4727. {
  4728. if (UrlPostParmsCheck("ctid"))
  4729. {
  4730. string eid = GetPostString("ctid");
  4731. CeErpTradeCell entity = null;
  4732. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4733. if (entity != null)
  4734. {
  4735. if (entity.OrderState >= 7)
  4736. {
  4737. returnErrorMsg("此单已发货,无需重复发货");
  4738. return;
  4739. }
  4740. if (entity.OrderState != 6)
  4741. {
  4742. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4743. return;
  4744. }
  4745. string shop = GetPostString("seller_nick");
  4746. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4747. string comName = GetPostString("comName");
  4748. string comCode = GetPostString("comCode");
  4749. string outSid = GetPostString("outSid");
  4750. string deliveryType = GetPostString("deliveryType");
  4751. string deliveryMemo = GetPostString("deliveryMemo");
  4752. outSid = outSid.Trim();
  4753. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4754. if (mainEn == null)
  4755. {
  4756. returnErrorMsg("找不到原始订单记录");
  4757. return;
  4758. }
  4759. bool isInitOrderDeliv = false;
  4760. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4761. {
  4762. isInitOrderDeliv = true;
  4763. }
  4764. string apires = "";
  4765. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4766. 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)
  4767. {
  4768. apires = "发货成功true";
  4769. }
  4770. else
  4771. {
  4772. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4773. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4774. }
  4775. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4776. {
  4777. entity.OrderState = 7;//发货后订单已发货
  4778. entity.OutSid = outSid;
  4779. entity.MemoOpt = 0;
  4780. entity.UpdateTime = DateTime.Now;
  4781. entity.FinishDeliveryTime = DateTime.Now;
  4782. entity.Update();
  4783. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4784. commonHelper.UpdateRelationOrder(entity.ctid);
  4785. //还要插入快递信息到 快递信息表
  4786. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4787. exinfo.tid = eid;
  4788. exinfo.out_sid = outSid;
  4789. exinfo.company_code = comCode;
  4790. exinfo.company_name = comName;
  4791. exinfo.delivery_memo = deliveryMemo;
  4792. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4793. exinfo.deliveryType = deliveryType;
  4794. exinfo.Create();
  4795. returnSuccessMsg("发货操作成功!");
  4796. commonHelper.UpdateRelationOrder(entity.ctid);
  4797. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4798. CeErpSukuraData.createInfo(entity.ctid, 4);
  4799. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4800. {
  4801. commonHelper.sendCytExpress(exinfo);
  4802. }
  4803. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4804. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4805. }
  4806. else
  4807. {
  4808. string errmsg = commonHelper.KeepChinese(apires);
  4809. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4810. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4811. }
  4812. return;
  4813. }
  4814. returnErrorMsg("找不到订单记录");
  4815. }
  4816. }
  4817. public void set_erp_multidelivery()
  4818. {
  4819. string eids = GetPostString("tids");
  4820. string[] eidList = eids.Split(',');
  4821. if (eidList.Length <= 0)
  4822. {
  4823. returnErrorMsg("发货不能为空");
  4824. return;
  4825. }
  4826. foreach (string ctid in eidList)
  4827. {
  4828. if (ctid.Length <= 0) continue;
  4829. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4830. if (expInfo != null)
  4831. {
  4832. StringBuilder sql = new StringBuilder();
  4833. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4834. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4835. if (dt.Rows.Count > 0)
  4836. {
  4837. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4838. {
  4839. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4840. expInfo.state = "异常";
  4841. expInfo.isMultiDelivery = 1;
  4842. expInfo.Update();
  4843. continue;
  4844. }
  4845. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4846. {
  4847. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4848. expInfo.state = "异常";
  4849. expInfo.Update();
  4850. continue;
  4851. }
  4852. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4853. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4854. bool isInitOrderDeliv = false;
  4855. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4856. {
  4857. isInitOrderDeliv = true;
  4858. expInfo.isMultiDelivery = 1;
  4859. }
  4860. if (ctid.IndexOf("N") != -1)
  4861. {
  4862. StringBuilder sqlbucha = new StringBuilder();
  4863. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4864. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4865. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4866. commonHelper.UpdateRelationOrder(ctid);
  4867. expInfo.delivery_memo = "发货成功";
  4868. expInfo.state = "发货成功";
  4869. expInfo.isMultiDelivery = 1;
  4870. expInfo.Update();
  4871. }
  4872. else
  4873. {
  4874. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4875. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4876. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4877. {
  4878. expInfo.delivery_memo = "发货成功";
  4879. expInfo.state = "发货成功";
  4880. expInfo.isMultiDelivery = 1;
  4881. expInfo.Update();
  4882. commonHelper.UpdateRelationOrder(ctid);
  4883. CeErpSukuraData.createInfo(ctid, 4);
  4884. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4885. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4886. }
  4887. else
  4888. {
  4889. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4890. expInfo.state = "异常";
  4891. expInfo.Update();
  4892. }
  4893. }
  4894. }
  4895. }
  4896. }
  4897. returnSuccessMsg("操作完成");
  4898. }
  4899. public void reset_erp_memoopt()
  4900. {
  4901. if (UrlPostParmsCheck("ctid"))
  4902. {
  4903. string eid = GetPostString("ctid");
  4904. CeErpTradeCell entity = null;
  4905. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4906. if (entity != null)
  4907. {
  4908. string stropt = "";
  4909. if (entity.MemoOpt == 1)
  4910. {
  4911. stropt = "“改稿”";
  4912. }
  4913. else if (entity.MemoOpt == 2)
  4914. {
  4915. stropt = "“定稿”";
  4916. }
  4917. else if (entity.MemoOpt == 3)
  4918. {
  4919. stropt = "“完成查货”";
  4920. CeErpSukuraData.createInfo(entity.ctid, 6);
  4921. }
  4922. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4923. entity.UpdateTime = DateTime.Now;
  4924. entity.MemoOpt = 0;
  4925. entity.Update();
  4926. returnSuccessMsg("操作成功!");
  4927. return;
  4928. }
  4929. returnErrorMsg("找不到记录");
  4930. }
  4931. }
  4932. public void get_erp_deliveryunusual()
  4933. {
  4934. DataStruct dStruct = GetPostStruct();
  4935. List<string> lw = new List<string>();
  4936. string tid = GetPostString("ctid");
  4937. if (tid.Length > 0)
  4938. {
  4939. string select_tid = getTidByCtid(tid);
  4940. lw.Add(string.Format("tid='{0}'", select_tid));
  4941. }
  4942. string shopname = GetPostString("shopname");
  4943. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4944. string buyernick = GetPostString("buyer_nick");
  4945. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4946. string customer = GetPostString("customer");
  4947. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4948. string design = GetPostString("design");
  4949. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4950. string sellermemo = GetPostString("seller_memo");
  4951. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4952. string supplier = GetPostString("supplier");
  4953. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4954. string date1 = GetPostString("date1");
  4955. string date2 = GetPostString("date2");
  4956. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4957. if (dw.Length > 0) lw.Add(dw);
  4958. string placedate1 = GetPostString("placedate1");
  4959. string placedate2 = GetPostString("placedate2");
  4960. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4961. if (dw_place.Length > 0) lw.Add(dw_place);
  4962. string price1 = GetPostString("price1");
  4963. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4964. string price2 = GetPostString("price2");
  4965. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4966. string unusualCon = GetPostString("unusualcon");
  4967. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4968. string posTag = CurrentUser.UserPost.Post.Code;
  4969. if (posTag == "Supplier")
  4970. {
  4971. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4972. }
  4973. lw.Add(string.Format("OrderState = 6"));
  4974. lw.Add(string.Format("UnusualTag = 5"));
  4975. lw.Add(string.Format("IsRefund<={0}", 1));
  4976. dStruct.Order = "FinishPlaceTime desc";
  4977. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4978. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4979. writeGridDataTableJson(dStruct.TotalCount, dt);
  4980. }
  4981. public void get_erp_deliveryedlist()
  4982. {
  4983. DataStruct dStruct = GetPostStruct();
  4984. List<string> lw = new List<string>();
  4985. string tid = GetPostString("ctid");
  4986. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4987. string shopname = GetPostString("shopname");
  4988. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4989. string buyernick = GetPostString("buyer_nick");
  4990. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4991. string customer = GetPostString("customer");
  4992. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4993. string design = GetPostString("design");
  4994. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4995. string sellermemo = GetPostString("seller_memo");
  4996. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4997. string logistics = GetPostString("logistics");
  4998. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4999. string date1 = GetPostString("date1");
  5000. string date2 = GetPostString("date2");
  5001. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5002. //if (dw.Length > 0) lw.Add(dw);
  5003. string placedate1 = GetPostString("placedate1");
  5004. string placedate2 = GetPostString("placedate2");
  5005. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5006. if (fdw.Length > 0) lw.Add(fdw);
  5007. string devdate1 = GetPostString("deliverydate1");
  5008. string devdate2 = GetPostString("deliverydate2");
  5009. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5010. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5011. string price1 = GetPostString("price1");
  5012. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5013. string price2 = GetPostString("price2");
  5014. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5015. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5016. {
  5017. if (tid.Length > 0)
  5018. {
  5019. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5020. if (tid.Length > 5)
  5021. {
  5022. List<string> tids = getTidByCtidLike(tid);
  5023. if (tids.Count > 0 && tids.Count < 10)
  5024. {
  5025. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5026. }
  5027. }
  5028. lw.Add(tid_sql);
  5029. }
  5030. if (buyernick.Length > 0)
  5031. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5032. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5033. if (dw.Length > 0) lw.Add(dw);
  5034. }
  5035. else
  5036. {
  5037. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5038. }
  5039. string posTag = CurrentUser.UserPost.Post.Code;
  5040. if (posTag == "Supplier")
  5041. {
  5042. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5043. }
  5044. else
  5045. {
  5046. string supplier = GetPostString("supplier");
  5047. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5048. }
  5049. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5050. lw.Add(string.Format("type != 'PDD' "));
  5051. lw.Add(string.Format("IsRefund!={0}", 2));
  5052. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5053. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5054. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5055. /*if (tid.Length > 0)
  5056. {
  5057. List<string> tids = new List<string>();
  5058. if (dt != null && dt.Rows.Count > 0)
  5059. {
  5060. foreach (DataRow item in dt.Rows)
  5061. {
  5062. tids.Add("'" + item["tid"] + "'");
  5063. }
  5064. }
  5065. if (tids.Count > 0)
  5066. {
  5067. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5068. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5069. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5070. dt = WebCache.GetData("view_erptradecell", dStruct);
  5071. }
  5072. }*/
  5073. if (dt != null)
  5074. {
  5075. foreach (DataRow dr in dt.Rows)
  5076. {
  5077. 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();
  5078. }
  5079. }
  5080. writeGridDataTableJson(dStruct.TotalCount, dt);
  5081. }
  5082. public void get_erp_pdddeliveryed()
  5083. {
  5084. DataStruct dStruct = GetPostStruct();
  5085. List<string> lw = new List<string>();
  5086. string tid = GetPostString("ctid");
  5087. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5088. string shopname = GetPostString("shopname");
  5089. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5090. string buyernick = GetPostString("buyer_nick");
  5091. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5092. string customer = GetPostString("customer");
  5093. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5094. string design = GetPostString("design");
  5095. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5096. string sellermemo = GetPostString("seller_memo");
  5097. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5098. string logistics = GetPostString("logistics");
  5099. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5100. string date1 = GetPostString("date1");
  5101. string date2 = GetPostString("date2");
  5102. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5103. //if (dw.Length > 0) lw.Add(dw);
  5104. string placedate1 = GetPostString("placedate1");
  5105. string placedate2 = GetPostString("placedate2");
  5106. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5107. if (fdw.Length > 0) lw.Add(fdw);
  5108. string devdate1 = GetPostString("deliverydate1");
  5109. string devdate2 = GetPostString("deliverydate2");
  5110. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5111. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5112. string price1 = GetPostString("price1");
  5113. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5114. string price2 = GetPostString("price2");
  5115. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5116. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5117. {
  5118. if (tid.Length > 0)
  5119. {
  5120. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5121. if (tid.Length > 5)
  5122. {
  5123. List<string> tids = getTidByCtidLike(tid);
  5124. if (tids.Count > 0 && tids.Count < 10)
  5125. {
  5126. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5127. }
  5128. }
  5129. lw.Add(tid_sql);
  5130. }
  5131. if (buyernick.Length > 0)
  5132. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5133. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5134. if (dw.Length > 0) lw.Add(dw);
  5135. }
  5136. else
  5137. {
  5138. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5139. }
  5140. string posTag = CurrentUser.UserPost.Post.Code;
  5141. if (posTag == "Supplier")
  5142. {
  5143. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5144. }
  5145. else
  5146. {
  5147. string supplier = GetPostString("supplier");
  5148. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5149. }
  5150. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5151. lw.Add(string.Format("type = 'PDD' "));
  5152. lw.Add(string.Format("IsRefund!={0}", 2));
  5153. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5154. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5155. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5156. /* if (tid.Length > 0)
  5157. {
  5158. List<string> tids = new List<string>();
  5159. if (dt != null && dt.Rows.Count > 0)
  5160. {
  5161. foreach (DataRow item in dt.Rows)
  5162. {
  5163. tids.Add("'" + item["tid"] + "'");
  5164. }
  5165. }
  5166. if (tids.Count > 0)
  5167. {
  5168. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5169. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5170. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5171. dt = WebCache.GetData("view_erptradecell", dStruct);
  5172. }
  5173. }*/
  5174. foreach (DataRow dr in dt.Rows)
  5175. {
  5176. 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();
  5177. }
  5178. writeGridDataTableJson(dStruct.TotalCount, dt);
  5179. }
  5180. public void get_erp_jddeliveryed()
  5181. {
  5182. DataStruct dStruct = GetPostStruct();
  5183. List<string> lw = new List<string>();
  5184. string tid = GetPostString("ctid");
  5185. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5186. string shopname = GetPostString("shopname");
  5187. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5188. string buyernick = GetPostString("buyer_nick");
  5189. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5190. string customer = GetPostString("customer");
  5191. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5192. string design = GetPostString("design");
  5193. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5194. string sellermemo = GetPostString("seller_memo");
  5195. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5196. string date1 = GetPostString("date1");
  5197. string date2 = GetPostString("date2");
  5198. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5199. //if (dw.Length > 0) lw.Add(dw);
  5200. string placedate1 = GetPostString("placedate1");
  5201. string placedate2 = GetPostString("placedate2");
  5202. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5203. if (fdw.Length > 0) lw.Add(fdw);
  5204. string devdate1 = GetPostString("deliverydate1");
  5205. string devdate2 = GetPostString("deliverydate2");
  5206. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5207. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5208. string price1 = GetPostString("price1");
  5209. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5210. string price2 = GetPostString("price2");
  5211. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5212. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5213. {
  5214. if (tid.Length > 0)
  5215. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5216. if (buyernick.Length > 0)
  5217. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5218. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5219. if (dw.Length > 0) lw.Add(dw);
  5220. }
  5221. else
  5222. {
  5223. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5224. }
  5225. string posTag = CurrentUser.UserPost.Post.Code;
  5226. if (posTag == "Supplier")
  5227. {
  5228. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5229. }
  5230. else
  5231. {
  5232. string supplier = GetPostString("supplier");
  5233. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5234. }
  5235. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5236. lw.Add(string.Format("type = 'JD' "));
  5237. lw.Add(string.Format("IsRefund!={0}", 2));
  5238. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5239. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5240. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5241. foreach (DataRow dr in dt.Rows)
  5242. {
  5243. 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();
  5244. }
  5245. writeGridDataTableJson(dStruct.TotalCount, dt);
  5246. }
  5247. public void get_erp_allplacelist()
  5248. {
  5249. DataStruct dStruct = GetPostStruct();
  5250. List<string> lw = new List<string>();
  5251. string tid = GetPostString("ctid");
  5252. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5253. string shopname = GetPostString("shopname");
  5254. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5255. string buyernick = GetPostString("buyer_nick");
  5256. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5257. string customer = GetPostString("customer");
  5258. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5259. string design = GetPostString("design");
  5260. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5261. string sellermemo = GetPostString("seller_memo");
  5262. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5263. string supplier = GetPostString("supplier");
  5264. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5265. string date1 = GetPostString("date1");
  5266. string date2 = GetPostString("date2");
  5267. string pldate1 = GetPostString("placedate1");
  5268. string pldate2 = GetPostString("placedate2");
  5269. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5270. //if (dw.Length > 0) lw.Add(dw);
  5271. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5272. {
  5273. if (tid.Length > 0)
  5274. {
  5275. string select_tid = getTidByCtid(tid);
  5276. lw.Add(string.Format("tid='{0}'", select_tid));
  5277. }
  5278. if (buyernick.Length > 0)
  5279. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5280. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5281. if (dw.Length > 0) lw.Add(dw);
  5282. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5283. if (dw_place.Length > 0) lw.Add(dw_place);
  5284. }
  5285. else
  5286. {
  5287. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5288. {
  5289. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5290. }
  5291. }
  5292. string price1 = GetPostString("price1");
  5293. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5294. string price2 = GetPostString("price2");
  5295. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5296. string posTag = CurrentUser.UserPost.Post.Code;
  5297. if (posTag == "Supplier")
  5298. {
  5299. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5300. }
  5301. lw.Add(string.Format("OrderState >= 6"));
  5302. lw.Add(string.Format("IsSample != 2 "));
  5303. //lw.Add(string.Format("isDianziOrder = 0 "));
  5304. lw.Add(string.Format("SupplierId > 0 "));
  5305. //lw.Add(string.Format("IsRefund<={0}", 1));
  5306. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5307. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5308. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5309. foreach (DataRow dr in dt.Rows)
  5310. {
  5311. 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();
  5312. }
  5313. writeGridDataTableJson(dStruct.TotalCount, dt);
  5314. }
  5315. public void get_erp_financeallplacelist()
  5316. {
  5317. DataStruct dStruct = GetPostStruct();
  5318. List<string> lw = new List<string>();
  5319. string tid = GetPostString("ctid");
  5320. string shopname = GetPostString("shopname");
  5321. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5322. string buyernick = GetPostString("buyer_nick");
  5323. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5324. string customer = GetPostString("customer");
  5325. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5326. string design = GetPostString("design");
  5327. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5328. string sellermemo = GetPostString("seller_memo");
  5329. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5330. string supplier = GetPostString("supplier");
  5331. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5332. string date1 = GetPostString("date1");
  5333. string date2 = GetPostString("date2");
  5334. string pldate1 = GetPostString("placedate1");
  5335. string pldate2 = GetPostString("placedate2");
  5336. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5337. {
  5338. if (tid.Length > 0)
  5339. {
  5340. string select_tid = getTidByCtid(tid);
  5341. lw.Add(string.Format("tid='{0}'", select_tid));
  5342. }
  5343. if (buyernick.Length > 0)
  5344. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5345. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5346. if (dw.Length > 0) lw.Add(dw);
  5347. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5348. if (dw_place.Length > 0) lw.Add(dw_place);
  5349. }
  5350. else
  5351. {
  5352. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5353. {
  5354. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5355. }
  5356. }
  5357. string price1 = GetPostString("price1");
  5358. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5359. string price2 = GetPostString("price2");
  5360. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5361. string posTag = CurrentUser.UserPost.Post.Code;
  5362. if (posTag == "Supplier")
  5363. {
  5364. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5365. }
  5366. //lw.Add(string.Format("OrderState >= 6"));
  5367. lw.Add(string.Format("IsSample != 2 "));
  5368. lw.Add(string.Format("isDianziOrder = 0 "));
  5369. //lw.Add(string.Format("IsRefund<={0}", 1));
  5370. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5371. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5372. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5373. foreach (DataRow dr in dt.Rows)
  5374. {
  5375. 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();
  5376. }
  5377. writeGridDataTableJson(dStruct.TotalCount, dt);
  5378. }
  5379. public void get_erp_expresslist()
  5380. {
  5381. int listtype = GetInt("ltype");
  5382. DataStruct dStruct = GetPostStruct();
  5383. List<string> lw = new List<string>();
  5384. string tid = GetPostString("tid");
  5385. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5386. string outsid = GetPostString("out_sid");
  5387. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5388. string importer = GetPostString("ImportUserName");
  5389. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5390. string file = GetPostString("import_file");
  5391. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5392. string printman = GetPostString("printman");
  5393. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5394. string date1 = GetPostString("date1");
  5395. string date2 = GetPostString("date2");
  5396. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5397. if (dw.Length > 0) lw.Add(dw);
  5398. string fdate1 = GetPostString("finishdate1");
  5399. string fdate2 = GetPostString("finishdate2");
  5400. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5401. if (fdw.Length > 0) lw.Add(fdw);
  5402. string supplierId = GetPostString("supplierId");
  5403. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5404. if (listtype == 1)
  5405. {
  5406. lw.Add(string.Format("importUserId !=0"));
  5407. }
  5408. string posTag = CurrentUser.UserPost.Post.Code;
  5409. if (posTag == "Supplier")
  5410. {
  5411. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5412. }
  5413. if (dStruct.PageSize != 100000)
  5414. {
  5415. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5416. }
  5417. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5418. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5419. writeGridDataTableJson(dStruct.TotalCount, dt);
  5420. }
  5421. public void set_erp_buchaorderdelivery()
  5422. {
  5423. if (UrlPostParmsCheck("ctid"))
  5424. {
  5425. string eid = GetPostString("ctid");
  5426. CeErpTradeCell entity = null;
  5427. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5428. if (entity != null)
  5429. {
  5430. if (entity.IsSample != 2)
  5431. {
  5432. returnErrorMsg("补差价单才能标记为已发货");
  5433. return;
  5434. }
  5435. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5436. entity.OrderState = 7;
  5437. entity.Update();
  5438. returnSuccessMsg("操作成功!");
  5439. return;
  5440. }
  5441. returnErrorMsg("找不到记录");
  5442. }
  5443. }
  5444. public void get_stdtemplates()
  5445. {
  5446. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5447. //string res = taobaoHelper.test();
  5448. string res = apiHelper.API_PrintTemplate();
  5449. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5450. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5451. {
  5452. int sidx = res.IndexOf("error_code");
  5453. int eidx = res.IndexOf("success");
  5454. string msg = res.Substring(sidx, eidx - sidx);
  5455. returnErrorMsg(msg);
  5456. return;
  5457. }
  5458. if (res.Length <= 0)
  5459. {
  5460. returnErrorMsg("模板数据为空!");
  5461. return;
  5462. }
  5463. ReturnSuccess(res);
  5464. }
  5465. public void cancel_print_order()
  5466. {
  5467. if (UrlPostParmsCheck("ctid"))
  5468. {
  5469. string ctid = GetPostString("ctid");
  5470. CeErpTradeCell entity = null;
  5471. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5472. if (entity != null)
  5473. {
  5474. string res = "";
  5475. string code = entity.LastBillWaybillCode;
  5476. if (code == "")
  5477. {
  5478. code = entity.OutSid;
  5479. }
  5480. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5481. XLog.SaveLog(0, "取消面单" + res);
  5482. }
  5483. }
  5484. }
  5485. public void set_erp_printwaybill()
  5486. {
  5487. if (UrlPostParmsCheck("ctid"))
  5488. {
  5489. string ctid = GetPostString("ctid");
  5490. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5491. string cpName = GetPostString("cpname");
  5492. string isTogether = GetPostString("together");
  5493. string printType = GetPostString("printType");
  5494. //var res_obj = new
  5495. //{
  5496. // restype = 1,
  5497. // 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\"}"
  5498. //};
  5499. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5500. //ReturnSuccess(ro_json);
  5501. //return;
  5502. bool isUseLastWayBillCode = false;
  5503. CeErpTradeCell entity = null;
  5504. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5505. if (entity != null)
  5506. {
  5507. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5508. {
  5509. isUseLastWayBillCode = true;
  5510. }
  5511. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5512. {
  5513. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5514. return;
  5515. }
  5516. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5517. {
  5518. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5519. return;
  5520. }
  5521. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5522. {
  5523. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5524. return;
  5525. }
  5526. }
  5527. string res = "";
  5528. Api_waybill_code_response_Obj fullObj = null;
  5529. string pData_str = "";
  5530. string curUseWayBillCode = "";
  5531. if (isUseLastWayBillCode == false)
  5532. {
  5533. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5534. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5535. if (res.IndexOf("failure") != -1)
  5536. {
  5537. //int idx = res.IndexOf("sub_message");
  5538. //int idx2 = res.IndexOf("flag");
  5539. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5540. string errMsgNeed = commonHelper.KeepChinese(res);
  5541. var res_objd = new
  5542. {
  5543. restype = 0,
  5544. data = "获取面单失败" + errMsgNeed
  5545. };
  5546. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5547. returnSuccess(ro_jsond);
  5548. if (res.IndexOf("停发") != -1)
  5549. {
  5550. entity.UnusualCon = "物流停发";
  5551. entity.Update();
  5552. }
  5553. //returnErrorMsg("获取面单失败,"+emsg);
  5554. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5555. return;
  5556. }
  5557. else if (res.IndexOf("errorMsg") != -1)
  5558. {
  5559. //int idx = res.IndexOf("errorMsg");
  5560. //int idx2 = res.IndexOf("}]}");
  5561. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5562. string errMsgNeed = commonHelper.KeepChinese(res);
  5563. var res_objf = new
  5564. {
  5565. restype = 0,
  5566. data = "获取面单失败2" + errMsgNeed
  5567. };
  5568. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5569. if (res.IndexOf("停发") != -1)
  5570. {
  5571. entity.UnusualCon = "物流停发";
  5572. entity.Update();
  5573. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5574. if (trade != null)
  5575. {
  5576. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5577. }
  5578. }
  5579. returnSuccess(ro_jsonf);
  5580. //returnErrorMsg("获取面单失败," + emsg);
  5581. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5582. return;
  5583. }
  5584. try
  5585. {
  5586. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5587. //res = res.Replace(" ", "");
  5588. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5589. }
  5590. catch (Exception ex)
  5591. {
  5592. XLog.SaveLog(0, "生成fullObj" + res);
  5593. var res_objf = new
  5594. {
  5595. restype = 0,
  5596. data = "生成fullObj发生错误" + ex.Message
  5597. };
  5598. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5599. returnSuccess(ro_jsonf);
  5600. return;
  5601. }
  5602. if (fullObj.response.data.content.Count > 0)
  5603. {
  5604. ContentItem codeObj = fullObj.response.data.content[0];
  5605. if (cpCode.IndexOf("SFFQ-") != -1)
  5606. {
  5607. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5608. }
  5609. else
  5610. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5611. curUseWayBillCode = codeObj.waybillCode;
  5612. }
  5613. else
  5614. {
  5615. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5616. var res_objf = new
  5617. {
  5618. restype = 0,
  5619. data = "生成fullObj找不到快递单号waybillCode"
  5620. };
  5621. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5622. returnSuccess(ro_jsonf);
  5623. return;
  5624. }
  5625. }
  5626. else
  5627. {
  5628. //使用上次打印的快递单号
  5629. if (cpCode == "SFFQ-LY")
  5630. {
  5631. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5632. }
  5633. else
  5634. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5635. curUseWayBillCode = entity.LastBillWaybillCode;
  5636. }
  5637. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5638. {
  5639. var res_obje = new
  5640. {
  5641. restype = 0,
  5642. data = "获取加密打印数据失败"
  5643. };
  5644. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5645. returnSuccess(ro_jsone);
  5646. entity.LastBillCpCode = cpCode;
  5647. entity.LastBillWaybillCode = curUseWayBillCode;
  5648. entity.Update();
  5649. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5650. //returnErrorMsg("获取加密打印数据失败");
  5651. return;
  5652. }
  5653. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5654. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5655. string btnType = "";
  5656. string errorMsg = "";
  5657. if (entity != null)
  5658. {
  5659. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5660. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5661. //cpcode是 YTO-CAINIAO
  5662. //string comCode = cpCode.Split('-')[0].ToString();
  5663. string apires = "";
  5664. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5665. //isTogether=2是新的合包弹窗
  5666. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5667. {
  5668. if (ctid.IndexOf("N") != -1)
  5669. {
  5670. apires = "发货成功";
  5671. }
  5672. else
  5673. {
  5674. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5675. }
  5676. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5677. //打单后发货
  5678. StringBuilder sql = new StringBuilder();
  5679. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5680. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5681. {
  5682. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5683. }
  5684. else
  5685. {
  5686. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5687. }
  5688. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5689. foreach (DataRow row in dt.Rows)
  5690. {
  5691. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5692. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5693. {
  5694. try
  5695. {
  5696. btnType = "待发货";
  5697. entity.OutSid = curUseWayBillCode;
  5698. entity.OrderState = 7;
  5699. entity.IsUrgency = false;
  5700. entity.LastBillCpCode = "";
  5701. entity.LastBillWaybillCode = "";
  5702. entity.FinishDeliveryTime = DateTime.Now;
  5703. entity.IsReturn = 0;
  5704. entity.MemoOpt = 0;
  5705. entity.UpdateTime = DateTime.Now;
  5706. entity.Update();
  5707. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5708. //还要插入快递信息到 快递信息表
  5709. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5710. exinfo.tid = entity.ctid;
  5711. exinfo.out_sid = curUseWayBillCode;
  5712. exinfo.company_code = cpCode;
  5713. exinfo.company_name = cpName;
  5714. exinfo.supplierUserName = supplierName;
  5715. exinfo.deliveryType = "发货成功";
  5716. exinfo.print_time = DateTime.Now;
  5717. exinfo.printUser = CurrentUser.UserName;
  5718. exinfo.postData = pData_str;
  5719. exinfo.Create();
  5720. commonHelper.UpdateRelationOrder(entity.ctid);
  5721. CeErpSukuraData.createInfo(ctid, 4);
  5722. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5723. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5724. {
  5725. commonHelper.sendCytExpress(exinfo);
  5726. }
  5727. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5728. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5729. }
  5730. catch (Exception ex)
  5731. {
  5732. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5733. }
  5734. }
  5735. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5736. {
  5737. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5738. if (entity.OrderState == 6)
  5739. {
  5740. entity.OrderState = 7;
  5741. }
  5742. entity.UpdateTime = DateTime.Now;
  5743. entity.FinishDeliveryTime = DateTime.Now;
  5744. btnType = "已发货";
  5745. entity.Update();
  5746. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5747. exinfo.tid = entity.ctid;
  5748. exinfo.out_sid = curUseWayBillCode;
  5749. exinfo.company_code = cpCode;
  5750. exinfo.company_name = cpName;
  5751. exinfo.supplierUserName = supplierName;
  5752. exinfo.deliveryType = "发货成功";
  5753. exinfo.print_time = DateTime.Now;
  5754. exinfo.printUser = CurrentUser.UserName;
  5755. exinfo.postData = pData_str;
  5756. exinfo.Create();
  5757. commonHelper.UpdateRelationOrder(entity.ctid);
  5758. CeErpSukuraData.createInfo(entity.ctid, 4);
  5759. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5760. {
  5761. commonHelper.sendCytExpress(exinfo);
  5762. }
  5763. //不处理
  5764. }
  5765. else
  5766. {
  5767. entity.UpdateTime = DateTime.Now;
  5768. entity.LastBillCpCode = cpCode;
  5769. entity.LastBillWaybillCode = curUseWayBillCode;
  5770. entity.Update();
  5771. string errmsg = commonHelper.KeepChinese(apires);
  5772. var res_objz = new
  5773. {
  5774. restype = 0,
  5775. data = "打单后发货失败"
  5776. };
  5777. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5778. returnSuccess(ro_jsonz);
  5779. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5780. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5781. return;
  5782. }
  5783. }
  5784. }
  5785. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5786. {
  5787. string ctids = GetPostString("ctids");
  5788. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5789. List<string> list = new List<string>();
  5790. List<string> send_list = new List<string>();
  5791. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5792. CeErpTrade ceErpTrade = new CeErpTrade();
  5793. //可合包的合并一起发货
  5794. if (dt == null && string.IsNullOrEmpty(ctids))
  5795. {
  5796. var res_objz = new
  5797. {
  5798. restype = 0,
  5799. data = "打单后发货失败"
  5800. };
  5801. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5802. returnSuccess(ro_jsonz);
  5803. return;
  5804. }
  5805. if (!string.IsNullOrEmpty(ctids))
  5806. {
  5807. StringBuilder sql = new StringBuilder();
  5808. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5809. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5810. }
  5811. foreach (DataRow row in dt.Rows)
  5812. {
  5813. list.Add("'" + row["ctid"] + "'");
  5814. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5815. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5816. if (ctid.IndexOf("N") != -1)
  5817. {
  5818. apires = "发货成功";
  5819. }
  5820. else
  5821. {
  5822. if (!send_list.Contains(ceErpTrade.tid))
  5823. {
  5824. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5825. }
  5826. else
  5827. {
  5828. apires = "发货成功";
  5829. }
  5830. }
  5831. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5832. {
  5833. send_list.Add(ceErpTrade.tid);
  5834. try
  5835. {
  5836. btnType = "待发货";
  5837. ceErpTradeCell.OutSid = curUseWayBillCode;
  5838. ceErpTradeCell.OrderState = 7;
  5839. ceErpTradeCell.IsUrgency = false;
  5840. ceErpTradeCell.LastBillCpCode = "";
  5841. ceErpTradeCell.LastBillWaybillCode = "";
  5842. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5843. ceErpTradeCell.IsReturn = 0;
  5844. ceErpTradeCell.MemoOpt = 0;
  5845. ceErpTradeCell.UpdateTime = DateTime.Now;
  5846. ceErpTradeCell.Update();
  5847. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5848. //还要插入快递信息到 快递信息表
  5849. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5850. exinfo.tid = ceErpTradeCell.ctid;
  5851. exinfo.out_sid = curUseWayBillCode;
  5852. exinfo.company_code = cpCode;
  5853. exinfo.company_name = cpName;
  5854. exinfo.supplierUserName = supplierName;
  5855. exinfo.deliveryType = "发货成功";
  5856. exinfo.print_time = DateTime.Now;
  5857. exinfo.printUser = CurrentUser.UserName;
  5858. exinfo.postData = pData_str;
  5859. exinfo.Create();
  5860. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5861. CeErpSukuraData.createInfo(ctid, 4);
  5862. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5863. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5864. {
  5865. commonHelper.sendCytExpress(exinfo);
  5866. }
  5867. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5868. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5869. }
  5870. catch (Exception ex)
  5871. {
  5872. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5873. }
  5874. }
  5875. else
  5876. {
  5877. ceErpTradeCell.UpdateTime = DateTime.Now;
  5878. ceErpTradeCell.LastBillCpCode = cpCode;
  5879. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5880. ceErpTradeCell.Update();
  5881. string errmsg = commonHelper.KeepChinese(apires);
  5882. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5883. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5884. }
  5885. }
  5886. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5887. }
  5888. }
  5889. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5890. var res_obj = new
  5891. {
  5892. restype = 1,
  5893. data = pData_str,
  5894. errorMsg
  5895. };
  5896. string ro_json = JsonConvert.SerializeObject(res_obj);
  5897. ReturnSuccess(ro_json);
  5898. return;
  5899. }
  5900. }
  5901. private string GetUTF8String(byte[] vs)
  5902. {
  5903. throw new NotImplementedException();
  5904. }
  5905. public void set_erp_printwaybill_cn()
  5906. {
  5907. if (UrlPostParmsCheck("ctid"))
  5908. {
  5909. string ctid = GetPostString("ctid");
  5910. string cpCode = GetPostString("cpcode");
  5911. string cpName = GetPostString("cpname");
  5912. string tempUrl = GetPostString("tempurl");
  5913. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5914. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5915. //string res = taobaoHelper.test();
  5916. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5917. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5918. {
  5919. int sidx = res.IndexOf("errorMsg");
  5920. int eidx = res.IndexOf("}");
  5921. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5922. var res_objzxx = new
  5923. {
  5924. restype = 0,
  5925. data = msg
  5926. };
  5927. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5928. returnSuccess(ro_jsonzxx);
  5929. //returnErrorMsg(msg);
  5930. return;
  5931. }
  5932. int idx = res.IndexOf("waybillCode");
  5933. int idx2 = res.IndexOf("printData");
  5934. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5935. string eid = GetPostString("ctid");
  5936. CeErpTradeCell entity = null;
  5937. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5938. if (entity != null)
  5939. {
  5940. string osid = entity.OutSid;
  5941. entity.OutSid = osid + "," + outsid;
  5942. entity.FinishDeliveryTime = DateTime.Now;
  5943. entity.OrderState = 7;
  5944. entity.UpdateTime = DateTime.Now;
  5945. entity.IsReturn = 0;
  5946. entity.Update();
  5947. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5948. exinfo.tid = entity.ctid;
  5949. exinfo.out_sid = outsid;
  5950. exinfo.company_code = cpCode;
  5951. exinfo.company_name = cpName;
  5952. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5953. exinfo.deliveryType = "发货成功";
  5954. exinfo.print_time = DateTime.Now;
  5955. exinfo.printUser = CurrentUser.UserName;
  5956. exinfo.Create();
  5957. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5958. {
  5959. commonHelper.sendCytExpress(exinfo);
  5960. }
  5961. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5962. }
  5963. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5964. var res_objz = new
  5965. {
  5966. restype = 1,
  5967. data = res
  5968. };
  5969. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5970. returnSuccess(ro_jsonz);
  5971. //ReturnSuccess(res);
  5972. }
  5973. }
  5974. ////打单,打印面单 获取面单号
  5975. //public void set_erp_printwaybill()
  5976. //{
  5977. // if (UrlPostParmsCheck("ctid"))
  5978. // {
  5979. // string ctid = GetPostString("ctid");
  5980. // string cpCode = GetPostString("cpcode");
  5981. // string tempUrl = GetPostString("tempurl");
  5982. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5983. // //string res = taobaoHelper.test();
  5984. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5985. // if (res.IndexOf("error_response") != -1)
  5986. // {
  5987. // int sidx = res.IndexOf("sub_msg");
  5988. // int eidx = res.IndexOf("request_id");
  5989. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5990. // returnErrorMsg(msg);
  5991. // return;
  5992. // }
  5993. // int idx = res.IndexOf("waybill_code");
  5994. // int idx2 = res.IndexOf("}]}");
  5995. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5996. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5997. // ReturnSuccess(res);
  5998. // }
  5999. //}
  6000. public void cancel_erp_aftersale()
  6001. {
  6002. if (UrlPostParmsCheck("ctid"))
  6003. {
  6004. string eid = GetPostString("ctid");
  6005. CeErpTradeCell entity = null;
  6006. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6007. if (entity != null)
  6008. {
  6009. //有过处理的售后,取消也不能删除 售 字,保留
  6010. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6011. {
  6012. entity.AfterSaleState = 4;
  6013. }
  6014. else
  6015. entity.AfterSaleState = 0;
  6016. entity.UpdateTime = DateTime.Now;
  6017. entity.Update();
  6018. returnSuccessMsg("操作成功!");
  6019. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6020. return;
  6021. }
  6022. returnErrorMsg("找不到订单记录");
  6023. }
  6024. }
  6025. public void get_erp_aftersalelist()
  6026. {
  6027. DataStruct dStruct = GetPostStruct();
  6028. List<string> lw = new List<string>();
  6029. int st = GetInt("st");
  6030. string tid = GetPostString("ctid");
  6031. if (st == 3)
  6032. {
  6033. if (tid.Length > 0)
  6034. {
  6035. string select_tid = getTidByCtid(tid);
  6036. lw.Add(string.Format("tid='{0}'", select_tid));
  6037. }
  6038. }
  6039. else
  6040. {
  6041. if (tid.Length > 0)
  6042. {
  6043. string select_tid = getTidByCtid(tid);
  6044. lw.Add(string.Format("tid='{0}'", select_tid));
  6045. }
  6046. }
  6047. string shopname = GetPostString("shopname");
  6048. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6049. string buyernick = GetPostString("buyer_nick");
  6050. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6051. string sellermemo = GetPostString("seller_memo");
  6052. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6053. string orderState = GetPostString("orderState");
  6054. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6055. string afterState = GetPostString("afterstate");
  6056. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6057. string date1 = GetPostString("date1");
  6058. string date2 = GetPostString("date2");
  6059. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6060. if (dw.Length > 0) lw.Add(dw);
  6061. string price1 = GetPostString("price1");
  6062. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6063. string price2 = GetPostString("price2");
  6064. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6065. //lw.Add(string.Format("IsRefund!={0}", 1));
  6066. string reason = GetPostString("reason");
  6067. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6068. string method = GetPostString("method");
  6069. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6070. string handler = GetPostString("handler");
  6071. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6072. string handledate1 = GetPostString("handledate1");
  6073. string handledate2 = GetPostString("handledate2");
  6074. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6075. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6076. string finish1 = GetPostString("finishdate1");
  6077. string finish2 = GetPostString("finishdate2");
  6078. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6079. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6080. string afterdate1 = GetPostString("afterdate1");
  6081. string afterdate2 = GetPostString("afterdate2");
  6082. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6083. if (afterDate.Length > 0) lw.Add(afterDate);
  6084. string supplier = GetPostString("supplier");
  6085. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6086. string responsible = GetPostString("responsibleman");
  6087. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6088. string customer = GetPostString("customer");
  6089. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6090. string design = GetPostString("design");
  6091. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6092. string afterMemoType = GetPostString("aftermemotype");
  6093. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6094. string posCode = CurrentUser.UserPost.Post.Code;
  6095. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6096. //{
  6097. // string vstate = GetPostString("vstate");
  6098. // if (vstate.Length > 0)
  6099. // {
  6100. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6101. // }
  6102. // if (posCode == "Supplier")
  6103. // {
  6104. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6105. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6106. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6107. // }
  6108. // else
  6109. // {
  6110. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6111. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6112. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6113. // {
  6114. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6115. // }
  6116. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6117. // {
  6118. // int orgid = CurrentUser.UserPost.OrgID;
  6119. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6120. // }
  6121. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6122. // {
  6123. // string shopid = CurrentUser.User.pemShop;
  6124. // lw.Add(string.Format("shopId in ({0})", shopid));
  6125. // }
  6126. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6127. // //{
  6128. // // int org_id = CurrentUser.UserPost.OrgID;
  6129. // // lw.Add(string.Format("OrgID={0}", org_id));
  6130. // //}
  6131. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6132. // }
  6133. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6134. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6135. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6136. //}
  6137. if (st == 5)
  6138. {
  6139. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6140. {
  6141. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6142. {
  6143. string shopid = CurrentUser.User.pemShop;
  6144. lw.Add(string.Format("shopId in ({0})", shopid));
  6145. }
  6146. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6147. {
  6148. int mrOrgid = CurrentUser.UserPost.OrgID;
  6149. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6150. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6151. }
  6152. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6153. //{
  6154. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6155. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6156. //}
  6157. else
  6158. {
  6159. string userIdStr = "";
  6160. if (posCode == "CustomerService")
  6161. {
  6162. userIdStr = CurrentUser.UserID + "_k";
  6163. }
  6164. else if (posCode == "Designer" || posCode == "wxDesigner")
  6165. {
  6166. userIdStr = CurrentUser.UserID + "_s";
  6167. }
  6168. else if (posCode == "Place")
  6169. {
  6170. userIdStr = CurrentUser.UserID + "_x";
  6171. }
  6172. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6173. }
  6174. }
  6175. string placedate1 = GetPostString("placedate1");
  6176. string placedate2 = GetPostString("placedate2");
  6177. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6178. if (dwplace.Length > 0) lw.Add(dwplace);
  6179. string supState = GetPostString("supState");
  6180. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6181. string searchType = GetPostString("searchType");
  6182. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6183. {
  6184. lw.Add(string.Format("BackNum>1"));
  6185. }
  6186. lw.Add(string.Format("AfterSaleState>0"));
  6187. if (ex_psize > 0)
  6188. {
  6189. if (CurrentUser.UserPost.Post.Code == "Finance")
  6190. dStruct.Order = "pay_time desc";
  6191. else
  6192. dStruct.Order = "HandleTime desc";
  6193. }
  6194. else
  6195. dStruct.Order = "HandleTime desc";
  6196. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6197. DataTable dt = WebCache.GetData("view_test", dStruct);
  6198. writeGridDataTableJson(dStruct.TotalCount, dt);
  6199. }
  6200. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6201. //{
  6202. // lw.Add(string.Format("AfterSaleState=4"));
  6203. // string code = CurrentUser.UserPost.Post.Code;
  6204. // if (code == "CustomerService")
  6205. // {
  6206. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6207. // }
  6208. // else if (code == "Designer" || code == "DesignerMr")
  6209. // {
  6210. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6211. // }
  6212. // else if (code == "Place" || code == "PlaceMr")
  6213. // {
  6214. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6215. // }
  6216. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6217. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6218. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6219. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6220. //}
  6221. //else //处理中的售后,待处理和处理中合并
  6222. //{
  6223. // if (afterState.Length <= 0)
  6224. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6225. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6226. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6227. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6228. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6229. //}
  6230. }
  6231. public void get_erp_disagreeftersalelist()
  6232. {
  6233. DataStruct dStruct = GetPostStruct();
  6234. List<string> lw = new List<string>();
  6235. int st = 2;
  6236. string tid = GetPostString("ctid");
  6237. if (tid.Length > 0)
  6238. {
  6239. string select_tid = getTidByCtid(tid);
  6240. lw.Add(string.Format("tid='{0}'", select_tid));
  6241. }
  6242. string shopname = GetPostString("shopname");
  6243. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6244. string buyernick = GetPostString("buyer_nick");
  6245. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6246. string sellermemo = GetPostString("seller_memo");
  6247. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6248. string orderState = GetPostString("orderState");
  6249. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6250. string afterState = GetPostString("afterstate");
  6251. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6252. string date1 = GetPostString("date1");
  6253. string date2 = GetPostString("date2");
  6254. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6255. if (dw.Length > 0) lw.Add(dw);
  6256. string price1 = GetPostString("price1");
  6257. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6258. string price2 = GetPostString("price2");
  6259. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6260. //lw.Add(string.Format("IsRefund!={0}", 1));
  6261. string reason = GetPostString("reason");
  6262. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6263. string method = GetPostString("method");
  6264. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6265. string handler = GetPostString("handler");
  6266. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6267. string handledate1 = GetPostString("handledate1");
  6268. string handledate2 = GetPostString("handledate2");
  6269. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6270. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6271. string afterdate1 = GetPostString("afterdate1");
  6272. string afterdate2 = GetPostString("afterdate2");
  6273. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6274. if (afterDate.Length > 0) lw.Add(afterDate);
  6275. string backdate1 = GetPostString("backdate1");
  6276. string backdate2 = GetPostString("backdate2");
  6277. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6278. if (backDate.Length > 0) lw.Add(backDate);
  6279. string supplier = GetPostString("supplier");
  6280. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6281. string responsible = GetPostString("responsibleman");
  6282. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6283. string customer = GetPostString("customer");
  6284. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6285. string design = GetPostString("design");
  6286. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6287. string afterSaleMemo = GetPostString("afterSaleMemo");
  6288. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6289. string afterMemoType = GetPostString("aftermemotype");
  6290. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6291. string aftersakereason = GetPostString("aftersakereason");
  6292. if (aftersakereason.Length > 0)
  6293. {
  6294. if (aftersakereason == "1")
  6295. {
  6296. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6297. }
  6298. if (aftersakereason == "2")
  6299. {
  6300. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6301. }
  6302. }
  6303. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6304. string poscode = CurrentUser.UserPost.Post.Code;
  6305. if (poscode != "SysAdmin")
  6306. {
  6307. string shopid = CurrentUser.User.pemShop;
  6308. lw.Add(string.Format("shopId in ({0})", shopid));
  6309. }
  6310. string searchType = GetPostString("searchType");
  6311. if (searchType == "wait")
  6312. {
  6313. lw.Add(string.Format("HandleTime is null"));
  6314. }
  6315. if (searchType == "handling")
  6316. {
  6317. lw.Add(string.Format("HandleTime is not null "));
  6318. }
  6319. if (searchType == "back" || searchType == "puBack")
  6320. {
  6321. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6322. }
  6323. if (searchType == "reBack")
  6324. {
  6325. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6326. }
  6327. if (searchType == "moreBack")
  6328. {
  6329. lw.Add(string.Format("backNum > 1"));
  6330. }
  6331. lw.Add(string.Format("(AfterSaleState=5)"));
  6332. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6333. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6334. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6335. writeGridDataTableJson(dStruct.TotalCount, dt);
  6336. }
  6337. public void get_erp_handlingaftersalelist()
  6338. {
  6339. DataStruct dStruct = GetPostStruct();
  6340. List<string> lw = new List<string>();
  6341. int st = 2;
  6342. string tid = GetPostString("ctid");
  6343. if (tid.Length > 0)
  6344. {
  6345. string select_tid = getTidByCtid(tid);
  6346. lw.Add(string.Format("tid='{0}'", select_tid));
  6347. }
  6348. string shopname = GetPostString("shopname");
  6349. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6350. string buyernick = GetPostString("buyer_nick");
  6351. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6352. string sellermemo = GetPostString("seller_memo");
  6353. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6354. string orderState = GetPostString("orderState");
  6355. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6356. string afterState = GetPostString("afterstate");
  6357. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6358. string date1 = GetPostString("date1");
  6359. string date2 = GetPostString("date2");
  6360. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6361. if (dw.Length > 0) lw.Add(dw);
  6362. string price1 = GetPostString("price1");
  6363. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6364. string price2 = GetPostString("price2");
  6365. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6366. //lw.Add(string.Format("IsRefund!={0}", 1));
  6367. string reason = GetPostString("reason");
  6368. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6369. string method = GetPostString("method");
  6370. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6371. string handler = GetPostString("handler");
  6372. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6373. string handledate1 = GetPostString("handledate1");
  6374. string handledate2 = GetPostString("handledate2");
  6375. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6376. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6377. string afterdate1 = GetPostString("afterdate1");
  6378. string afterdate2 = GetPostString("afterdate2");
  6379. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6380. if (afterDate.Length > 0) lw.Add(afterDate);
  6381. string supplier = GetPostString("supplier");
  6382. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6383. string responsible = GetPostString("responsibleman");
  6384. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6385. string customer = GetPostString("customer");
  6386. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6387. string design = GetPostString("design");
  6388. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6389. string afterSaleMemo = GetPostString("afterSaleMemo");
  6390. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6391. string afterMemoType = GetPostString("aftermemotype");
  6392. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6393. string afterresult = GetPostString("afterresult");
  6394. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6395. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6396. string poscode = CurrentUser.UserPost.Post.Code;
  6397. if (poscode != "SysAdmin")
  6398. {
  6399. string shopid = CurrentUser.User.pemShop;
  6400. lw.Add(string.Format("shopId in ({0})", shopid));
  6401. }
  6402. string searchType = GetPostString("searchType");
  6403. if (searchType == "wait")
  6404. {
  6405. lw.Add(string.Format("HandleTime is null"));
  6406. }
  6407. if (searchType == "documentary")
  6408. {
  6409. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6410. }
  6411. if (searchType == "handling")
  6412. {
  6413. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6414. }
  6415. if (searchType == "back" || searchType == "puBack")
  6416. {
  6417. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6418. }
  6419. if (searchType == "reBack")
  6420. {
  6421. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6422. }
  6423. if (afterState.Length <= 0)
  6424. {
  6425. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6426. }
  6427. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6428. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6429. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6430. writeGridDataTableJson(dStruct.TotalCount, dt);
  6431. }
  6432. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6433. //public void get_erp_back_handlingaftersalelist()
  6434. //{
  6435. // DataStruct dStruct = GetPostStruct();
  6436. // List<string> lw = new List<string>();
  6437. // string tid = GetPostString("ctid");
  6438. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6439. // string shopname = GetPostString("shopname");
  6440. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6441. // string buyernick = GetPostString("buyer_nick");
  6442. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6443. // string sellermemo = GetPostString("seller_memo");
  6444. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6445. // string orderState = GetPostString("orderState");
  6446. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6447. // string afterState = GetPostString("afterstate");
  6448. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6449. // string date1 = GetPostString("date1");
  6450. // string date2 = GetPostString("date2");
  6451. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6452. // if (dw.Length > 0) lw.Add(dw);
  6453. // string price1 = GetPostString("price1");
  6454. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6455. // string price2 = GetPostString("price2");
  6456. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6457. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6458. // string reason = GetPostString("reason");
  6459. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6460. // string method = GetPostString("method");
  6461. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6462. // string handler = GetPostString("handler");
  6463. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6464. // string handledate1 = GetPostString("handledate1");
  6465. // string handledate2 = GetPostString("handledate2");
  6466. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6467. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6468. // string afterdate1 = GetPostString("afterdate1");
  6469. // string afterdate2 = GetPostString("afterdate2");
  6470. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6471. // if (afterDate.Length > 0) lw.Add(afterDate);
  6472. // string supplier = GetPostString("supplier");
  6473. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6474. // string responsible = GetPostString("responsibleman");
  6475. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6476. // string customer = GetPostString("customer");
  6477. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6478. // string design = GetPostString("design");
  6479. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6480. // string afterMemoType = GetPostString("aftermemotype");
  6481. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6482. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6483. // if (afterState.Length <= 0)
  6484. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6485. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6486. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6487. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6488. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6489. //}
  6490. public void get_erp_aftersaleverifylist()
  6491. {
  6492. DataStruct dStruct = GetPostStruct();
  6493. List<string> lw = new List<string>();
  6494. string tid = GetPostString("ctid");
  6495. if (tid.Length > 0)
  6496. {
  6497. string select_tid = getTidByCtid(tid);
  6498. lw.Add(string.Format("otid='{0}'", select_tid));
  6499. }
  6500. string shopname = GetPostString("shopname");
  6501. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6502. string buyernick = GetPostString("buyer_nick");
  6503. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6504. string sellermemo = GetPostString("seller_memo");
  6505. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6506. string orderState = GetPostString("orderState");
  6507. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6508. //lw.Add(string.Format("IsRefund!={0}", 1));
  6509. string reason = GetPostString("reason");
  6510. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6511. string method = GetPostString("method");
  6512. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6513. string handler = GetPostString("handler");
  6514. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6515. string handledate1 = GetPostString("handledate1");
  6516. string handledate2 = GetPostString("handledate2");
  6517. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6518. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6519. string finish1 = GetPostString("finishdate1");
  6520. string finish2 = GetPostString("finishdate2");
  6521. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6522. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6523. string supplier = GetPostString("supplier");
  6524. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6525. string responsible = GetPostString("responsibleman");
  6526. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6527. string posCode = CurrentUser.UserPost.Post.Code;
  6528. string vstate = GetPostString("vstate");
  6529. if (vstate.Length > 0)
  6530. {
  6531. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6532. }
  6533. if (posCode == "Supplier")
  6534. {
  6535. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6536. lw.Add(string.Format("VerifyState = 0"));
  6537. lw.Add("type = 1");
  6538. lw.Add(string.Format("AfterSaleState={0}", 3));
  6539. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6540. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6541. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6542. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6543. writeGridDataTableJson(dStruct.TotalCount, dt);
  6544. }
  6545. else if (posCode == "logistics")
  6546. {
  6547. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6548. lw.Add(string.Format("VerifyState = 0"));
  6549. lw.Add("type = 2");
  6550. lw.Add(string.Format("AfterSaleState={0}", 3));
  6551. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6552. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6553. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6554. writeGridDataTableJson(dStruct.TotalCount, dt);
  6555. }
  6556. else
  6557. {
  6558. lw.Add(string.Format("(AfterSaleState = 3)"));
  6559. lw.Add("type = 0");
  6560. string reasonState = GetPostString("reasonState");
  6561. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6562. {
  6563. if (reasonState == "2")
  6564. {
  6565. lw.Add("VerifyState = 3");
  6566. }
  6567. else if (reasonState == "1")
  6568. {
  6569. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6570. }
  6571. else
  6572. {
  6573. lw.Add("VerifyState in (0,3)");
  6574. }
  6575. //不加条件,可以看全部
  6576. }
  6577. 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")
  6578. {
  6579. int orgid = CurrentUser.UserPost.OrgID;
  6580. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6581. if (string.IsNullOrEmpty(manageOrgId))
  6582. {
  6583. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6584. }
  6585. else
  6586. {
  6587. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6588. }
  6589. if (reasonState == "1")
  6590. {
  6591. lw.Add("VerifyState = 3");
  6592. }
  6593. else if (reasonState == "2")
  6594. {
  6595. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6596. }
  6597. else
  6598. {
  6599. }
  6600. }
  6601. else
  6602. {
  6603. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6604. }
  6605. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6606. //{
  6607. // int org_id = CurrentUser.UserPost.OrgID;
  6608. // lw.Add(string.Format("OrgID={0}", org_id));
  6609. //}
  6610. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6611. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6612. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6613. writeGridDataTableJson(dStruct.TotalCount, dt);
  6614. }
  6615. }
  6616. public void get_erp_finishaftersalelist()
  6617. {
  6618. DataStruct dStruct = GetPostStruct();
  6619. List<string> lw = new List<string>();
  6620. int st = 4;
  6621. string tid = GetPostString("ctid");
  6622. if (tid.Length > 0)
  6623. {
  6624. string select_tid = getTidByCtid(tid);
  6625. lw.Add(string.Format("otid='{0}'", select_tid));
  6626. }
  6627. string shopname = GetPostString("shopname");
  6628. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6629. //lw.Add(string.Format("IsRefund!={0}", 1));
  6630. string reason = GetPostString("reason");
  6631. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6632. string method = GetPostString("method");
  6633. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6634. string buyernick = GetPostString("buyer_nick");
  6635. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6636. string handler = GetPostString("handler");
  6637. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6638. string handledate1 = GetPostString("handledate1");
  6639. string handledate2 = GetPostString("handledate2");
  6640. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6641. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6642. string finish1 = GetPostString("finishdate1");
  6643. string finish2 = GetPostString("finishdate2");
  6644. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6645. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6646. string supplier = GetPostString("supplier");
  6647. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6648. string responsible = GetPostString("responsibleman");
  6649. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6650. string vstate = GetPostString("vstate");
  6651. if (vstate.Length > 0)
  6652. {
  6653. if ("3".Equals(vstate))
  6654. {
  6655. lw.Add(string.Format("IsTem=1"));
  6656. }
  6657. else
  6658. {
  6659. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6660. }
  6661. }
  6662. lw.Add(string.Format("AfterSaleState=4"));
  6663. string code = CurrentUser.UserPost.Post.Code;
  6664. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6665. {
  6666. //不加条件,可以看全部
  6667. }
  6668. else if (code == "Supplier")
  6669. {
  6670. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6671. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6672. lw.Add("type = 1");
  6673. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6674. }
  6675. else if (code == "logistics")
  6676. {
  6677. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6678. lw.Add("type = 2");
  6679. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6680. }
  6681. 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")
  6682. {
  6683. lw.Add("type = 0");
  6684. int orgid = CurrentUser.UserPost.OrgID;
  6685. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6686. if (string.IsNullOrEmpty(manageOrgIds))
  6687. {
  6688. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6689. }
  6690. else
  6691. {
  6692. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6693. }
  6694. }
  6695. else
  6696. {
  6697. lw.Add("type = 0");
  6698. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6699. }
  6700. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6701. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6702. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6703. writeGridDataTableJson(dStruct.TotalCount, dt);
  6704. }
  6705. public void handle_erp_aftersale()
  6706. {
  6707. if (UrlPostParmsCheck("ctid"))
  6708. {
  6709. string eid = GetPostString("ctid");
  6710. string responStr = GetPostString("AfterSaleResponsible");
  6711. if (responStr.Length <= 0)
  6712. {
  6713. returnErrorMsg("售后责任人不能为空");
  6714. return;
  6715. }
  6716. bool isDesign = false;
  6717. double designFree = 0.00;
  6718. int responsibleId = 0;
  6719. CeErpTradeCell entity = null;
  6720. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6721. if (entity != null)
  6722. {
  6723. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6724. string afterMethod = GetPostString("AfterSaleMethod");
  6725. if (isNeedNewOrder == 1)
  6726. {
  6727. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6728. bool ishav = true;
  6729. if (newentity == null)
  6730. {
  6731. newentity = entity.Clone() as CeErpTradeCell;
  6732. ishav = false;
  6733. newentity.ctid = "S_" + entity.ctid;
  6734. newentity.OrderState = 0;
  6735. //唯一标识
  6736. newentity.OrderSn = newentity.ctid;
  6737. string orderSn = dataHelper.getSaleOrderSn();
  6738. if (orderSn != "")
  6739. {
  6740. newentity.OrderSn = orderSn;
  6741. }
  6742. }
  6743. newentity.UpdateTime = DateTime.Now;
  6744. newentity.AfterSaleState = 0;
  6745. newentity.AfterSaleMethod = afterMethod;
  6746. if (!ishav)
  6747. {
  6748. string memo_str = newentity.seller_memo;
  6749. memo_str = memo_str.Replace("(", "(");
  6750. memo_str = memo_str.Replace(")", ")");
  6751. int sIndex = memo_str.IndexOf("(");
  6752. int eIndex = memo_str.IndexOf(")");
  6753. if (sIndex == -1 || eIndex == -1)
  6754. {
  6755. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6756. return;
  6757. }
  6758. string first = memo_str.Substring(0, sIndex + 1);
  6759. string memoCtid = newentity.OrderSn;
  6760. //if (memoCtid.IndexOf("C") != -1)
  6761. //{
  6762. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6763. //if (CIdx.IndexOf("+") != -1)
  6764. //{
  6765. //CIdx = "C" + CIdx.Split('+')[1];
  6766. //}
  6767. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6768. //}
  6769. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6770. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6771. string newMemo = first + memoCtid + last;
  6772. newentity.seller_memo = newMemo;
  6773. newentity.FinishPlaceTime = null;
  6774. newentity.UnusualTag = 0;
  6775. newentity.UnusualCon = "";
  6776. newentity.UnusualTime = null;
  6777. newentity.AfterSaleMemo = "";
  6778. newentity.AfterSaleMethod = afterMethod;
  6779. newentity.AfterSalePreTime = null;
  6780. newentity.AfterSaleReason = "";
  6781. newentity.AfterSaleResponsible = "";
  6782. newentity.AfterSaleState = 0;
  6783. newentity.AfterSaleTime = null;
  6784. newentity.AfterSaleUserId = 0;
  6785. newentity.AfterSaleSupplierState = 0;
  6786. newentity.LastBillWaybillCode = "";
  6787. newentity.LastBillCpCode = "";
  6788. newentity.FinishAfterSaleTime = null;
  6789. newentity.HandleTime = null;
  6790. newentity.IsSF = 0;
  6791. newentity.IsOldCustomer = 0;
  6792. newentity.UrgencyTime = null;
  6793. newentity.ResponsibleUserId = "";
  6794. newentity.IsVerifyToSupplier = false;
  6795. newentity.payment = 0;
  6796. newentity.CheckMemo = "";
  6797. newentity.OutSid = "";
  6798. newentity.CheckOrderTime = null;
  6799. newentity.MemoOpt = 0;
  6800. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6801. }
  6802. newentity.isAfterSaleOrder = 1;
  6803. newentity.IsRefund = 0;
  6804. string receiveMobile = GetPostString("receiver_mobile");
  6805. if (receiveMobile.Length > 0)
  6806. {
  6807. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6808. if (trade != null)
  6809. {
  6810. trade.receiver_name = GetPostString("receiver_name");
  6811. trade.receiver_mobile = receiveMobile;
  6812. trade.receiver_state = GetPostString("receiver_state");
  6813. trade.receiver_city = GetPostString("receiver_city");
  6814. trade.receiver_district = GetPostString("receiver_district");
  6815. trade.receiver_address = GetPostString("receiver_address");
  6816. newentity.IsOffLineOrder = 1;
  6817. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6818. }
  6819. }
  6820. string st = GetPostString("ToState");
  6821. if (st.Length > 0)
  6822. {
  6823. if (newentity.OrderState <= 3)
  6824. {
  6825. newentity.WaitDesignTime = DateTime.Now;
  6826. newentity.StartDesignTime = null;
  6827. newentity.FinishDesignTime = null;
  6828. newentity.OrderState = 3;
  6829. if (st == "下单员")
  6830. {
  6831. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6832. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6833. {
  6834. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6835. }
  6836. }
  6837. else
  6838. {
  6839. newentity.WaitDesignTime = DateTime.Now;
  6840. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6841. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6842. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6843. {
  6844. DataRow user = dt1.Rows[0];
  6845. //找主管
  6846. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6847. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6848. if (dt != null && dt.Rows.Count > 0)
  6849. {
  6850. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6851. newentity.DesignUserId = designMr;
  6852. string key = "aftersale_order_" + designMr;
  6853. if (RedisHelper.HasKey(key))
  6854. {
  6855. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6856. list.Add(newentity.ctid);
  6857. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6858. }
  6859. }
  6860. //账号正常
  6861. if (user["State"].ToString() == "0")
  6862. {
  6863. newentity.DesignUserId = entity.DesignUserId;
  6864. string key = "aftersale_order_" + entity.DesignUserId;
  6865. if (RedisHelper.HasKey(key))
  6866. {
  6867. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6868. list.Add(newentity.ctid);
  6869. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6870. }
  6871. }
  6872. }
  6873. }
  6874. }
  6875. if (entity.IsXianHuo == 1)
  6876. {
  6877. newentity.OrderState = 6;
  6878. entity.FinishPlaceTime = DateTime.Now;
  6879. }
  6880. }
  6881. if (ishav)
  6882. {
  6883. newentity.Update();
  6884. }
  6885. else
  6886. {
  6887. newentity.Create();
  6888. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6889. newCellExtend.ctid = newentity.ctid;
  6890. newCellExtend.orderFrom = 20;
  6891. newCellExtend.orderType = 30;
  6892. if (st == "下单员")
  6893. {
  6894. }
  6895. else
  6896. {
  6897. newCellExtend.ReprintTime = DateTime.Now;
  6898. }
  6899. newCellExtend.Create();
  6900. }
  6901. if (st != "下单员")
  6902. {
  6903. if (entity.DispatchSort == 2)
  6904. {
  6905. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6906. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6907. }
  6908. }
  6909. }
  6910. //处理售后扩展
  6911. string resIdStr = GetPostString("ResponsibleUserId");
  6912. string refundFees = GetPostString("refundFrees");
  6913. int IsComplain = GetPostInt("isComplain");
  6914. int IsBad = GetPostInt("isBad");
  6915. string IsOriginal = GetPostString("isOriginal");
  6916. double diffResultPrice = GetPostDouble("diffResultPrice");
  6917. string textResult = GetPostString("textResult");
  6918. string supplierResponsible = GetPostString("supplierResponsible");
  6919. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6920. if (ceErpTradeAfterSaleExtend == null)
  6921. {
  6922. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6923. ceErpTradeAfterSaleExtend.tid = eid;
  6924. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6925. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6926. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6927. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6928. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6929. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6930. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6931. ceErpTradeAfterSaleExtend.Create();
  6932. }
  6933. else
  6934. {
  6935. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6936. {
  6937. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6938. }
  6939. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6940. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6941. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6942. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6943. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6944. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6945. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6946. ceErpTradeAfterSaleExtend.Update();
  6947. }
  6948. int gysid = GetPostInt("ResponsibleSupId");
  6949. if (entity.AfterSaleUserId == 0)
  6950. {
  6951. entity.AfterSaleUserId = CurrentUser.UserID;
  6952. }
  6953. entity.ResponsibleUserId = resIdStr;
  6954. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6955. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6956. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6957. {
  6958. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6959. int backNum = 0;
  6960. if (number != null)
  6961. {
  6962. backNum = number.BackNum;
  6963. }
  6964. char[] separator = { ',' };
  6965. string[] sArray = resIdStr.Split(separator);
  6966. string[] refundFreeList = { };
  6967. if (refundFees.Length > 0)
  6968. {
  6969. refundFreeList = refundFees.Split(separator);
  6970. }
  6971. int index = -1;
  6972. List<int> responsibleIds = new List<int>();
  6973. foreach (string i in sArray)
  6974. {
  6975. index++;
  6976. if (i.Length <= 0) continue;
  6977. char[] separator2 = { '_' };
  6978. string idstr = i.Split(separator2)[0];
  6979. string idtype = i.Split(separator2)[1];
  6980. double refudFree = 0;
  6981. if (refundFreeList.Length > 0)
  6982. {
  6983. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6984. }
  6985. if (idtype == "s")
  6986. {
  6987. isDesign = true;
  6988. designFree = refudFree;
  6989. }
  6990. int userId = Convert.ToInt32(idstr);
  6991. int type = 0;
  6992. if (idtype == "g")
  6993. {
  6994. type = 1;
  6995. }
  6996. if (idtype == "w")
  6997. {
  6998. type = 2;
  6999. }
  7000. if (idtype == "t")
  7001. {
  7002. type = 3;
  7003. }
  7004. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7005. if (ceErpTradeResponsible == null)
  7006. {
  7007. ceErpTradeResponsible = new CeErpTradeResponsible();
  7008. ceErpTradeResponsible.tid = eid;
  7009. ceErpTradeResponsible.UserId = userId;
  7010. ceErpTradeResponsible.createdTime = DateTime.Now;
  7011. ceErpTradeResponsible.type = type;
  7012. if (type == 1)
  7013. {
  7014. ceErpTradeResponsible.IsSup = 1;
  7015. }
  7016. if (type == 2)
  7017. {
  7018. ceErpTradeResponsible.IsFlow = 1;
  7019. }
  7020. }
  7021. int state = 0;
  7022. //已认可的不需要再次认可
  7023. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7024. {
  7025. state = 1;
  7026. }
  7027. ceErpTradeResponsible.RefundFee = refudFree;
  7028. ceErpTradeResponsible.VerifyState = state;
  7029. if (userId == 2125 || idtype == "w")
  7030. {
  7031. ceErpTradeResponsible.VerifyState = 1;
  7032. }
  7033. if (idtype == "w" && userId == 101)
  7034. {
  7035. ceErpTradeResponsible.VerifyState = state;
  7036. }
  7037. if (ceErpTradeResponsible.ID > 0)
  7038. {
  7039. ceErpTradeResponsible.Update();
  7040. }
  7041. else
  7042. {
  7043. ceErpTradeResponsible.Create();
  7044. }
  7045. if (isDesign)
  7046. {
  7047. responsibleId = ceErpTradeResponsible.ID;
  7048. }
  7049. responsibleIds.Add(ceErpTradeResponsible.ID);
  7050. }
  7051. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7052. CeErpTradeResponsible.NumByTid(backNum, eid);
  7053. }
  7054. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7055. if (ceErpTradeCellExtend != null)
  7056. {
  7057. ceErpTradeCellExtend.returnVisit = 0;
  7058. ceErpTradeCellExtend.Update();
  7059. }
  7060. if (entity.HandleTime != null)
  7061. {
  7062. if (entity.AfterSaleState == 1)
  7063. {
  7064. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7065. }
  7066. else
  7067. {
  7068. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7069. }
  7070. }
  7071. else
  7072. {
  7073. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7074. entity.HandleTime = DateTime.Now;
  7075. }
  7076. bool isCompale = false;
  7077. if (entity.AfterSaleState == 5)
  7078. {
  7079. isCompale = true;
  7080. entity.AfterSaleState = 3;
  7081. }
  7082. entity.AfterSaleSupplierState = 0;
  7083. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7084. {
  7085. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7086. }
  7087. string sImgs = GetPostString("img");
  7088. entity.AfterSaleSupplierImg = sImgs;
  7089. entity.supRefundType = GetPostString("supRefundType");
  7090. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7091. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7092. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7093. entity.AfterSaleMemoType = GetPostString("MemoType");
  7094. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7095. {
  7096. //entity.AfterSaleSupplierState = 2;
  7097. }
  7098. string df = GetPostString("DeductFee");
  7099. if (df == "")
  7100. {
  7101. df = "0";
  7102. }
  7103. string rf = GetPostString("RefundFee");
  7104. if (rf == "")
  7105. {
  7106. rf = "0";
  7107. }
  7108. string pm = GetPostString("AfterSalePayment");
  7109. if (pm == "")
  7110. {
  7111. pm = "0";
  7112. }
  7113. entity.AfterSalePayment = Convert.ToDouble(pm);
  7114. entity.DeductFee = Convert.ToDouble(df);
  7115. entity.RefundFee = Convert.ToDouble(rf);
  7116. entity.UpdateTime = DateTime.Now;
  7117. entity.Update();
  7118. string toState = GetPostString("ToState");
  7119. string original = GetPostString("isOriginal");
  7120. ApiVo apiVo = new ApiVo();
  7121. apiVo.orderNumber = entity.ctid;
  7122. apiVo.actionName = "afterDesign";
  7123. apiVo.orderRemarks = entity.AfterSaleMethod;
  7124. apiVo.reasonRemarks = entity.AfterSaleReason;
  7125. apiVo.isDesign = isDesign;
  7126. apiVo.designFree = designFree;
  7127. apiVo.responsibleId = responsibleId;
  7128. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7129. if (toState == "设计师")
  7130. {
  7131. apiVo.isOriginal = Convert.ToBoolean(original);
  7132. }
  7133. designHelper.API_WorkCore(apiVo);//afterDesign
  7134. CeErpMethod methodSql = new CeErpMethod();
  7135. methodSql.con = entity.AfterSaleMethod;
  7136. methodSql.addTime = DateTime.Now;
  7137. methodSql.Create();
  7138. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7139. CeErpMethod.ExecuteNonQuery(delsql);
  7140. if (isCompale)
  7141. {
  7142. aftersale_data_change(entity.ctid);
  7143. }
  7144. returnSuccessMsg("操作成功!");
  7145. return;
  7146. }
  7147. returnErrorMsg("找不到订单记录");
  7148. }
  7149. }
  7150. public void ins_erp_toresponsible()
  7151. {
  7152. if (UrlPostParmsCheck("ctid"))
  7153. {
  7154. string eid = GetPostString("ctid");
  7155. CeErpTradeCell entity = null;
  7156. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7157. if (entity != null)
  7158. {
  7159. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7160. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7161. {
  7162. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7163. return;
  7164. }
  7165. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7166. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7167. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7168. if (entity.AfterSalePreTime == null)
  7169. {
  7170. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7171. {
  7172. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7173. }
  7174. }
  7175. entity.AfterSalePreTime = DateTime.Now;
  7176. //预完成给售后主管审核客户问题直接完成
  7177. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7178. {
  7179. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7180. {
  7181. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7182. }
  7183. }
  7184. ceErpTradeAfterSaleExtend.Update();
  7185. entity.AfterSaleState = 2;
  7186. entity.UpdateTime = DateTime.Now;
  7187. entity.Update();
  7188. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7189. aftersale_data_change(entity.ctid);
  7190. returnSuccessMsg("操作成功!");
  7191. return;
  7192. }
  7193. returnErrorMsg("找不到订单记录");
  7194. }
  7195. }
  7196. public void cancel_erp_aftersaleanddelnew()
  7197. {
  7198. if (UrlPostParmsCheck("ctid"))
  7199. {
  7200. string eid = GetPostString("ctid");
  7201. CeErpTradeCell entity = null;
  7202. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7203. if (entity != null)
  7204. {
  7205. entity.AfterSaleState = 0;
  7206. entity.AfterSaleReason = "";
  7207. entity.AfterSaleMethod = "";
  7208. entity.AfterSaleMemo = "";
  7209. entity.AfterSaleResponsible = "";
  7210. entity.ResponsibleUserId = "";
  7211. entity.DeductFee = 0;
  7212. entity.RefundFee = 0;
  7213. entity.IsArbitrate = 0;
  7214. CeErpTradeResponsible.DelByTid(eid, -1);
  7215. entity.Update();
  7216. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7217. if (after != null)
  7218. {
  7219. if (after.OrderState < 5)
  7220. CeErpTradeCell.DelByCtid("S_" + eid);
  7221. }
  7222. returnSuccessMsg("操作成功!");
  7223. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7224. return;
  7225. }
  7226. returnErrorMsg("找不到订单记录");
  7227. }
  7228. }
  7229. public void get_erp_aftersale_pregather()
  7230. {
  7231. List<string> lw = new List<string>();
  7232. int st = GetInt("st");
  7233. string tid = GetPostString("ctid");
  7234. if (tid.Length > 0)
  7235. {
  7236. string select_tid = getTidByCtid(tid);
  7237. lw.Add(string.Format("tid='{0}'", select_tid));
  7238. }
  7239. string shopname = GetPostString("shopname");
  7240. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7241. string buyernick = GetPostString("buyer_nick");
  7242. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7243. string sellermemo = GetPostString("seller_memo");
  7244. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7245. string orderState = GetPostString("orderState");
  7246. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7247. string reason = GetPostString("reason");
  7248. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7249. string method = GetPostString("method");
  7250. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7251. string handler = GetPostString("handler");
  7252. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7253. string handledate1 = GetPostString("handledate1");
  7254. string handledate2 = GetPostString("handledate2");
  7255. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7256. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7257. string supplier = GetPostString("supplier");
  7258. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7259. string responsible = GetPostString("responsibleman");
  7260. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7261. string customer = GetPostString("customer");
  7262. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7263. string design = GetPostString("design");
  7264. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7265. string afterMemoType = GetPostString("aftermemotype");
  7266. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7267. string afterSaleMemo = GetPostString("afterSaleMemo");
  7268. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7269. string afterresult = GetPostString("afterresult");
  7270. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7271. string poscode = CurrentUser.UserPost.Post.Code;
  7272. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7273. {
  7274. string shopid = CurrentUser.User.pemShop;
  7275. lw.Add(string.Format("shopId in ({0})", shopid));
  7276. }
  7277. var mainwhere = string.Join(" and ", lw.ToArray());
  7278. string ro_json = "";
  7279. string type = GetPostString("gather_type");
  7280. int number = 0;
  7281. if (poscode == "AfterSale")
  7282. {
  7283. //处理中
  7284. if (type == "Handling")
  7285. {
  7286. 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) : ""));
  7287. DataTable dt = null;
  7288. try
  7289. {
  7290. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7291. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7292. }
  7293. catch (Exception e)
  7294. {
  7295. dt = new DataTable();
  7296. }
  7297. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7298. return;
  7299. }
  7300. if (type == "Wait")
  7301. {
  7302. //待处理
  7303. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7304. DataTable dt1 = null;
  7305. try
  7306. {
  7307. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7308. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7309. }
  7310. catch (Exception e)
  7311. {
  7312. dt1 = new DataTable();
  7313. }
  7314. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7315. return;
  7316. }
  7317. if (type == "back")
  7318. {
  7319. //打回
  7320. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7321. DataTable dt2 = null;
  7322. try
  7323. {
  7324. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7325. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7326. }
  7327. catch (Exception e)
  7328. {
  7329. dt2 = new DataTable();
  7330. }
  7331. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7332. return;
  7333. }
  7334. if (type == "preCompletion")
  7335. {
  7336. //预完成
  7337. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7338. DataTable dt3 = null;
  7339. try
  7340. {
  7341. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7342. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7343. }
  7344. catch (Exception e)
  7345. {
  7346. dt3 = new DataTable();
  7347. }
  7348. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7349. return;
  7350. }
  7351. if (type == "documentary")
  7352. {
  7353. //跟单中
  7354. 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) : ""));
  7355. DataTable dt4 = null;
  7356. try
  7357. {
  7358. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7359. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7360. }
  7361. catch (Exception e)
  7362. {
  7363. dt4 = new DataTable();
  7364. }
  7365. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7366. return;
  7367. }
  7368. if (type == "reBack")
  7369. {
  7370. //被打回
  7371. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7372. DataTable dt1 = null;
  7373. try
  7374. {
  7375. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7376. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7377. }
  7378. catch (Exception e)
  7379. {
  7380. dt1 = new DataTable();
  7381. }
  7382. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7383. return;
  7384. }
  7385. }
  7386. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7387. {
  7388. if (type == "puBack")
  7389. {
  7390. //退回
  7391. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7392. DataTable dt = null;
  7393. try
  7394. {
  7395. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7396. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7397. }
  7398. catch (Exception e)
  7399. {
  7400. dt = new DataTable();
  7401. }
  7402. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7403. return;
  7404. }
  7405. if (type == "reBack")
  7406. {
  7407. //打回
  7408. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7409. DataTable dt1 = null;
  7410. try
  7411. {
  7412. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7413. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7414. }
  7415. catch (Exception e)
  7416. {
  7417. dt1 = new DataTable();
  7418. }
  7419. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7420. return;
  7421. }
  7422. if (type == "examEd")
  7423. {
  7424. //已审核
  7425. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7426. DataTable dt2 = null;
  7427. try
  7428. {
  7429. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7430. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7431. }
  7432. catch (Exception e)
  7433. {
  7434. dt2 = new DataTable();
  7435. }
  7436. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7437. return;
  7438. }
  7439. if (type == "waitExam")
  7440. {
  7441. //待审核
  7442. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7443. DataTable dt3 = null;
  7444. try
  7445. {
  7446. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7447. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7448. }
  7449. catch (Exception e)
  7450. {
  7451. dt3 = new DataTable();
  7452. }
  7453. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7454. return;
  7455. }
  7456. if (type == "Handling")
  7457. {
  7458. //处理中
  7459. 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) : ""));
  7460. DataTable dt4 = null;
  7461. try
  7462. {
  7463. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7464. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7465. }
  7466. catch (Exception e)
  7467. {
  7468. dt4 = new DataTable();
  7469. }
  7470. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7471. return;
  7472. }
  7473. if (type == "Wait")
  7474. {
  7475. //待处理
  7476. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7477. DataTable dt5 = null;
  7478. try
  7479. {
  7480. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7481. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7482. }
  7483. catch (Exception e)
  7484. {
  7485. dt5 = new DataTable();
  7486. }
  7487. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7488. return;
  7489. }
  7490. if (type == "documentary")
  7491. {
  7492. //跟单中
  7493. 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) : ""));
  7494. DataTable dt6 = null;
  7495. try
  7496. {
  7497. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7498. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7499. }
  7500. catch (Exception e)
  7501. {
  7502. dt6 = new DataTable();
  7503. }
  7504. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7505. return;
  7506. }
  7507. }
  7508. returnSuccess(ro_json);
  7509. }
  7510. public void end_erp_aftersale()
  7511. {
  7512. if (UrlPostParmsCheck("ctid"))
  7513. {
  7514. string eid = GetPostString("ctid");
  7515. CeErpTradeCell entity = null;
  7516. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7517. if (entity != null)
  7518. {
  7519. string stype = GetPostString("stype");
  7520. string typeStr = stype;
  7521. entity.AfterSaleState = 4;
  7522. entity.FinishAfterSaleTime = DateTime.Now;
  7523. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7524. entity.Update();
  7525. ApiVo apiVo = new ApiVo();
  7526. apiVo.orderNumber = entity.ctid;
  7527. apiVo.actionName = "afterOver";
  7528. designHelper.API_WorkCore(apiVo); //afterOver
  7529. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7530. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7531. CeErpSukuraData.createInfo(entity.ctid, 8);
  7532. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7533. returnSuccessMsg("操作成功!");
  7534. return;
  7535. }
  7536. returnErrorMsg("找不到订单记录");
  7537. }
  7538. }
  7539. public void ins_erp_finishaftersale()
  7540. {
  7541. if (UrlPostParmsCheck("id"))
  7542. {
  7543. string eid = GetPostString("id");
  7544. CeErpTradeResponsible entity = null;
  7545. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7546. if (entity != null)
  7547. {
  7548. entity.VerifyState = 1;
  7549. entity.VerifyTime = DateTime.Now;
  7550. entity.Update();
  7551. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7552. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7553. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7554. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7555. if (dt.Rows.Count <= 0)
  7556. {
  7557. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7558. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7559. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7560. CeErpSukuraData.createInfo(entity.tid, 8);
  7561. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7562. {
  7563. CeErpDesignerBill.Del(entity.tid);
  7564. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7565. }
  7566. }
  7567. returnSuccessMsg("操作成功!");
  7568. return;
  7569. }
  7570. returnErrorMsg("找不到订单记录");
  7571. }
  7572. }
  7573. public void upd_erp_arbitrateaftersale()
  7574. {
  7575. if (UrlPostParmsCheck("id"))
  7576. {
  7577. string eid = GetPostString("id");
  7578. CeErpTradeResponsible entity = null;
  7579. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7580. if (entity != null)
  7581. {
  7582. entity.IsArbitrate = 1;
  7583. entity.ArbitradeMemo = GetPostString("reason");
  7584. entity.VerifyState = 2;
  7585. entity.Update();
  7586. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7587. if (tradecell != null)
  7588. {
  7589. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7590. tradecell.IsArbitrate = 1;
  7591. tradecell.Update();
  7592. }
  7593. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7594. returnSuccessMsg("操作成功!");
  7595. return;
  7596. }
  7597. returnErrorMsg("找不到订单记录");
  7598. }
  7599. }
  7600. public void upd_erp_backaftersale()
  7601. {
  7602. if (UrlPostParmsCheck("tid"))
  7603. {
  7604. string eid = GetPostString("tid");
  7605. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7606. int backNum = 0;
  7607. if (number != null)
  7608. {
  7609. backNum = number.BackNum;
  7610. }
  7611. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7612. CeErpTradeCell entity = null;
  7613. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7614. if (entity != null)
  7615. {
  7616. entity.AfterSaleBackReason = GetPostString("backreason");
  7617. entity.AfterSaleState = 1;
  7618. entity.AfterSaleSupplierState = 0;
  7619. entity.UpdateTime = DateTime.Now;
  7620. entity.Update();
  7621. returnSuccessMsg("操作成功!");
  7622. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7623. return;
  7624. }
  7625. returnErrorMsg("找不到订单记录");
  7626. }
  7627. }
  7628. public void get_erp_supplieraftersalelist()
  7629. {
  7630. DataStruct dStruct = GetPostStruct();
  7631. List<string> lw = new List<string>();
  7632. string tid = GetPostString("ctid");
  7633. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7634. string shopname = GetPostString("shopname");
  7635. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7636. string buyernick = GetPostString("buyer_nick");
  7637. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7638. string sellermemo = GetPostString("seller_memo");
  7639. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7640. string orderState = GetPostString("orderState");
  7641. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7642. string afterState = GetPostString("afterstate");
  7643. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7644. string date1 = GetPostString("date1");
  7645. string date2 = GetPostString("date2");
  7646. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7647. if (dw.Length > 0) lw.Add(dw);
  7648. string price1 = GetPostString("price1");
  7649. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7650. string price2 = GetPostString("price2");
  7651. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7652. string reason = GetPostString("reason");
  7653. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7654. string method = GetPostString("method");
  7655. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7656. string handledate1 = GetPostString("handledate1");
  7657. string handledate2 = GetPostString("handledate2");
  7658. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7659. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7660. string handler = GetPostString("handler");
  7661. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7662. string afterdate1 = GetPostString("afterdate1");
  7663. string afterdate2 = GetPostString("afterdate2");
  7664. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7665. if (afterDate.Length > 0) lw.Add(afterDate);
  7666. string customer = GetPostString("customer");
  7667. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7668. string design = GetPostString("design");
  7669. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7670. string afterMemoType = GetPostString("aftermemotype");
  7671. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7672. string vstate = GetPostString("vstate");
  7673. if (vstate.Length > 0)
  7674. {
  7675. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7676. }
  7677. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7678. string supplier = GetPostString("supplier");
  7679. int supid = commonHelper.getSupplierIDByName(supplier);
  7680. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7681. string posCode = CurrentUser.UserPost.Post.Code;
  7682. if (posCode == "Supplier")
  7683. {
  7684. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7685. }
  7686. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7687. {
  7688. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7689. }
  7690. else
  7691. {
  7692. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7693. }
  7694. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7695. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7696. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7697. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7698. writeGridDataTableJson(dStruct.TotalCount, dt);
  7699. }
  7700. public void upd_erp_supverifyaftersale()
  7701. {
  7702. if (UrlPostParmsCheck("id"))
  7703. {
  7704. string id = GetPostString("id");
  7705. int st = GetPostInt("afterstate");
  7706. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7707. CeErpTradeCell entity = null;
  7708. if (ceErpTradeResponsible != null)
  7709. {
  7710. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7711. }
  7712. string afmemo = GetPostString("supmemo");
  7713. string image = GetPostString("image");
  7714. if (entity != null)
  7715. {
  7716. entity.AfterSaleSupplierState = st;
  7717. entity.AfterSaleSupplierMemo = afmemo;
  7718. if (st == 1)
  7719. {
  7720. ceErpTradeResponsible.VerifyState = 1;
  7721. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7722. ceErpTradeResponsible.Update();
  7723. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7724. if (isAll)
  7725. {
  7726. entity.AfterSaleState = 4;
  7727. entity.FinishAfterSaleTime = DateTime.Now;
  7728. }
  7729. }
  7730. else
  7731. {
  7732. CeErpTradeResponsible.dateByTid(entity.ctid);
  7733. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7734. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7735. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7736. if (num <= 1)
  7737. {
  7738. entity.AfterSaleState = 1;
  7739. }
  7740. else
  7741. {
  7742. entity.AfterSaleState = 5;
  7743. }
  7744. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7745. if (ceErpTradeAfterSaleExtend != null)
  7746. {
  7747. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7748. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7749. ceErpTradeAfterSaleExtend.Update();
  7750. }
  7751. else
  7752. {
  7753. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7754. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7755. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7756. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7757. ceErpTradeAfterSaleExtend.Create();
  7758. }
  7759. }
  7760. if (entity.AfterSaleState == 4)
  7761. {
  7762. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7763. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7764. {
  7765. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7766. }
  7767. ApiVo apiVo = new ApiVo();
  7768. apiVo.orderNumber = entity.ctid;
  7769. apiVo.actionName = "afterOver";
  7770. designHelper.API_WorkCore(apiVo); //afterOver
  7771. }
  7772. entity.UpdateTime = DateTime.Now;
  7773. entity.Update();
  7774. returnSuccessMsg("操作成功!");
  7775. CeErpSukuraData.createInfo(entity.ctid, 8);
  7776. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7777. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7778. return;
  7779. }
  7780. returnErrorMsg("找不到订单记录");
  7781. }
  7782. }
  7783. public void upd_erp_masteraftersale()
  7784. {
  7785. if (UrlPostParmsCheck("id"))
  7786. {
  7787. string id = GetPostString("id");
  7788. int st = GetPostInt("afterstate");
  7789. string afmemo = GetPostString("supmemo");
  7790. string image = GetPostString("image");
  7791. string textResult = GetPostString("textResult");
  7792. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7793. if (ceErpTradeResponsible != null)
  7794. {
  7795. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7796. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7797. ceErpTradeResponsible.Update();
  7798. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7799. if (entity != null)
  7800. {
  7801. entity.AfterSaleSupplierState = st;
  7802. entity.AfterSaleSupplierMemo = afmemo;
  7803. if (st == 1)
  7804. {
  7805. }
  7806. else
  7807. {
  7808. CeErpTradeResponsible.dateByTid(entity.ctid);
  7809. //退回到售后
  7810. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7811. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7812. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7813. if (num <= 1)
  7814. {
  7815. entity.AfterSaleState = 1;
  7816. }
  7817. else
  7818. {
  7819. entity.AfterSaleState = 5;
  7820. }
  7821. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7822. if (ceErpTradeAfterSaleExtend != null)
  7823. {
  7824. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7825. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7826. ceErpTradeAfterSaleExtend.Update();
  7827. }
  7828. else
  7829. {
  7830. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7831. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7832. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7833. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7834. ceErpTradeAfterSaleExtend.Create();
  7835. }
  7836. }
  7837. entity.UpdateTime = DateTime.Now;
  7838. entity.Update();
  7839. returnSuccessMsg("操作成功!");
  7840. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7841. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7842. return;
  7843. }
  7844. }
  7845. returnErrorMsg("找不到订单记录");
  7846. }
  7847. }
  7848. public void upd_erp_personaftersale()
  7849. {
  7850. if (UrlPostParmsCheck("id"))
  7851. {
  7852. //林小连
  7853. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7854. {
  7855. upd_erp_masteraftersale();
  7856. return;
  7857. }
  7858. string id = GetPostString("id");
  7859. int st = GetPostInt("afterstate");
  7860. string afmemo = GetPostString("supmemo");
  7861. string image = GetPostString("image");
  7862. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7863. if (ceErpTradeResponsible != null)
  7864. {
  7865. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7866. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7867. ceErpTradeResponsible.Update();
  7868. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7869. if (entity != null)
  7870. {
  7871. entity.AfterSaleSupplierMemo = afmemo;
  7872. entity.AfterSaleSupplierState = st;
  7873. if (st == 1)
  7874. {
  7875. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7876. if (isAll)
  7877. {
  7878. entity.AfterSaleState = 4;
  7879. entity.FinishAfterSaleTime = DateTime.Now;
  7880. }
  7881. }
  7882. else
  7883. {
  7884. CeErpTradeResponsible.dateByTid(entity.ctid);
  7885. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7886. if (ceErpTradeAfterSaleExtend != null)
  7887. {
  7888. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7889. ceErpTradeAfterSaleExtend.Update();
  7890. }
  7891. else
  7892. {
  7893. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7894. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7895. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7896. ceErpTradeAfterSaleExtend.Create();
  7897. }
  7898. //退回到主管
  7899. //entity.AfterSaleState = 2;
  7900. }
  7901. if (entity.AfterSaleState == 4)
  7902. {
  7903. ApiVo apiVo = new ApiVo();
  7904. apiVo.orderNumber = entity.ctid;
  7905. apiVo.actionName = "afterOver";
  7906. designHelper.API_WorkCore(apiVo); //afterOver
  7907. }
  7908. entity.UpdateTime = DateTime.Now;
  7909. entity.Update();
  7910. returnSuccessMsg("操作成功!");
  7911. CeErpSukuraData.createInfo(entity.ctid, 8);
  7912. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7913. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7914. return;
  7915. }
  7916. }
  7917. returnErrorMsg("找不到订单记录");
  7918. }
  7919. }
  7920. public void set_erp_supplierrefundtag()
  7921. {
  7922. if (UrlPostParmsCheck("ctid"))
  7923. {
  7924. string eid = GetPostString("ctid");
  7925. CeErpTradeCell entity = null;
  7926. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7927. if (entity != null)
  7928. {
  7929. entity.IsSupplierRefund = GetPostInt("tag");
  7930. entity.Update();
  7931. returnSuccessMsg("操作成功!");
  7932. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7933. return;
  7934. }
  7935. returnErrorMsg("找不到订单记录");
  7936. }
  7937. }
  7938. public void get_erp_refundlist()
  7939. {
  7940. DataStruct dStruct = GetPostStruct();
  7941. List<string> lw = new List<string>();
  7942. string tid = GetPostString("tid");
  7943. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7944. //string rid = GetPostString("refund_id");
  7945. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7946. string shopname = GetPostString("shopname");
  7947. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7948. string buyernick = GetPostString("buyer_nick");
  7949. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7950. string customer = GetPostString("customer");
  7951. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7952. string design = GetPostString("design");
  7953. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7954. string sellermemo = GetPostString("seller_memo");
  7955. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7956. //string date1 = GetPostString("date1");
  7957. //string date2 = GetPostString("date2");
  7958. //string dateType = GetPostString("dateType");
  7959. //if (dateType.Length > 0)
  7960. //{
  7961. // if (dateType == "1001") dateType = "0";
  7962. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7963. // if (searchDT.Count == 2)
  7964. // {
  7965. // date1 = searchDT[0].ToString();
  7966. // date2 = searchDT[1].ToString();
  7967. // }
  7968. //}
  7969. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7970. //if (dw.Length > 0) lw.Add(dw);
  7971. string redate1 = GetPostString("refunddate1");
  7972. string redate2 = GetPostString("refunddate2");
  7973. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7974. if (dwdate.Length > 0) lw.Add(dwdate);
  7975. string price1 = GetPostString("price1");
  7976. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7977. string price2 = GetPostString("price2");
  7978. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7979. string ispartrefund = GetPostString("ispartrefund");
  7980. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7981. string refundState = GetPostString("refundvstate");
  7982. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7983. int st = GetInt("st");
  7984. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7985. {
  7986. string responsible = GetPostString("responsibleman");
  7987. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7988. lw.Add(string.Format("RefundState>={0}", st));
  7989. string code = CurrentUser.UserPost.Post.Code;
  7990. if (code == "CustomerService")
  7991. {
  7992. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7993. }
  7994. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7995. {
  7996. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7997. }
  7998. else if (code == "Place" || code == "PlaceMr")
  7999. {
  8000. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8001. }
  8002. dStruct.Order = "RefundState asc,created desc";
  8003. }
  8004. else if (st == 10)
  8005. {
  8006. string responsible = GetPostString("responsibleman");
  8007. if (responsible == "空白")
  8008. {
  8009. lw.Add(string.Format("ResponsibleUserName = ''"));
  8010. }
  8011. else if (responsible.Length > 0)
  8012. {
  8013. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8014. }
  8015. lw.Add(string.Format("RefundState>=0"));
  8016. dStruct.Order = "created desc";
  8017. }
  8018. else
  8019. {
  8020. string responsible = GetPostString("responsibleman");
  8021. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8022. lw.Add(string.Format("RefundState={0}", st));
  8023. dStruct.Order = "created desc";
  8024. }
  8025. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8026. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8027. dt.Columns.Add("refund_fees");
  8028. foreach (DataRow dr in dt.Rows)
  8029. {
  8030. String status = dr["status"].ToString();
  8031. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8032. {
  8033. dr["refund_fees"] = dr["refund_fee"];
  8034. }
  8035. else
  8036. {
  8037. dr["refund_fees"] = "0.0";
  8038. }
  8039. }
  8040. writeGridDataTableJson(dStruct.TotalCount, dt);
  8041. }
  8042. public void get_erp_refunddesignlist()
  8043. {
  8044. DataStruct dStruct = GetPostStruct();
  8045. List<string> lw = new List<string>();
  8046. string tid = GetPostString("tid");
  8047. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8048. string shopname = GetPostString("shopname");
  8049. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8050. string buyernick = GetPostString("buyer_nick");
  8051. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8052. string customer = GetPostString("customer");
  8053. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8054. string design = GetPostString("design");
  8055. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8056. string sellermemo = GetPostString("seller_memo");
  8057. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8058. string redate1 = GetPostString("refunddate1");
  8059. string redate2 = GetPostString("refunddate2");
  8060. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8061. if (dwdate.Length > 0) lw.Add(dwdate);
  8062. string price1 = GetPostString("price1");
  8063. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8064. string price2 = GetPostString("price2");
  8065. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8066. string ispartrefund = GetPostString("ispartrefund");
  8067. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8068. string designerorg = GetPostString("designerorg");
  8069. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8070. string refundState = GetPostString("refundState");
  8071. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8072. int myOrgid = CurrentUser.UserPost.OrgID;
  8073. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8074. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8075. {
  8076. if (CurrentUser.User.TeamIds.Length > 0)
  8077. {
  8078. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8079. }
  8080. else
  8081. {
  8082. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8083. }
  8084. }
  8085. else if ("SysAdmin".Equals(myOrgCode))
  8086. {
  8087. }
  8088. else
  8089. {
  8090. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8091. {
  8092. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8093. }
  8094. else
  8095. {
  8096. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8097. }
  8098. }
  8099. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8100. dStruct.Order = "created desc";
  8101. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8102. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8103. dt.Columns.Add("refund_fees");
  8104. foreach (DataRow dr in dt.Rows)
  8105. {
  8106. String status = dr["status"].ToString();
  8107. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8108. {
  8109. dr["refund_fees"] = dr["refund_fee"];
  8110. }
  8111. else
  8112. {
  8113. dr["refund_fees"] = "0.0";
  8114. }
  8115. }
  8116. writeGridDataTableJson(dStruct.TotalCount, dt);
  8117. }
  8118. public void handle_erp_refundtag()
  8119. {
  8120. if (UrlPostParmsCheck("refund_id"))
  8121. {
  8122. string eid = GetPostString("refund_id");
  8123. string respMan = GetPostString("ResponsibleName");
  8124. if (respMan.Length <= 0)
  8125. {
  8126. returnErrorMsg("责任人不能为空");
  8127. return;
  8128. }
  8129. CeErpTradeRefund entity = null;
  8130. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8131. if (entity != null)
  8132. {
  8133. entity.ResponsibleUserName = respMan;
  8134. string userid = GetPostString("ResponsibleUserId");
  8135. if (userid.Length > 0)
  8136. {
  8137. entity.ResponsibleUserId = userid;
  8138. }
  8139. entity.Memo = GetPostString("Memo");
  8140. if (respMan.IndexOf("客服") != -1 ||
  8141. respMan.IndexOf("设计师") != -1 ||
  8142. respMan.IndexOf("下单员") != -1)
  8143. {
  8144. entity.RefundState = 2;
  8145. }
  8146. else
  8147. {
  8148. entity.RefundState = 3;
  8149. }
  8150. entity.modified = DateTime.Now;
  8151. entity.Update();
  8152. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8153. returnSuccessMsg("操作成功!");
  8154. return;
  8155. }
  8156. returnErrorMsg("找不到订单记录");
  8157. }
  8158. }
  8159. public void handle_erp_designrefundtag()
  8160. {
  8161. if (UrlPostParmsCheck("refund_id"))
  8162. {
  8163. string eid = GetPostString("refund_id");
  8164. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8165. if (ceErpTradeCellExtend == null)
  8166. {
  8167. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8168. ceErpTradeCellExtend.ctid = eid;
  8169. }
  8170. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8171. if (ceErpTradeCellExtend.ID > 0)
  8172. {
  8173. ceErpTradeCellExtend.Update();
  8174. }
  8175. else
  8176. {
  8177. ceErpTradeCellExtend.Create();
  8178. }
  8179. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8180. returnSuccessMsg("操作成功!");
  8181. return;
  8182. }
  8183. returnErrorMsg("找不到订单记录");
  8184. }
  8185. public void upd_erp_refundverify()
  8186. {
  8187. if (UrlPostParmsCheck("refund_id"))
  8188. {
  8189. string eid = GetPostString("refund_id");
  8190. CeErpTradeRefund entity = null;
  8191. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8192. if (entity != null)
  8193. {
  8194. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8195. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8196. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8197. {
  8198. entity.RefundState = 2;
  8199. }
  8200. else
  8201. {
  8202. entity.RefundState = 3;
  8203. }
  8204. entity.Update();
  8205. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8206. returnSuccessMsg("操作成功!");
  8207. return;
  8208. }
  8209. returnErrorMsg("找不到订单记录");
  8210. }
  8211. }
  8212. public void upd_erp_refundapprove()
  8213. {
  8214. if (UrlPostParmsCheck("refund_id"))
  8215. {
  8216. string eid = GetPostString("refund_id");
  8217. CeErpTradeRefund entity = null;
  8218. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8219. if (entity != null)
  8220. {
  8221. int apr = GetPostInt("approve");
  8222. if (apr == 0)
  8223. {
  8224. entity.RefundState = 1;
  8225. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8226. }
  8227. else if (apr == 1)
  8228. {
  8229. entity.RefundState = 3;
  8230. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8231. }
  8232. entity.modified = DateTime.Now;
  8233. entity.Update();
  8234. returnSuccessMsg("操作成功!");
  8235. return;
  8236. }
  8237. returnErrorMsg("找不到订单记录");
  8238. }
  8239. }
  8240. public void get_erp_billlist()
  8241. {
  8242. DataStruct dStruct = GetPostStruct();
  8243. List<string> lw = new List<string>();
  8244. string title = GetPostString("title");
  8245. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8246. string tid = GetPostString("tid");
  8247. string tids = GetPostString("tids");
  8248. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8249. if (tids.Length > 0)
  8250. {
  8251. tids = "'" + tids + "'";
  8252. tids = tids.Replace(",", "','");
  8253. lw.Add(string.Format("tid in ({0})", tids));
  8254. }
  8255. string shopname = GetPostString("shopname");
  8256. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8257. string buyernick = GetPostString("buyer_nick");
  8258. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8259. string customer = GetPostString("customer");
  8260. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8261. string date1 = GetPostString("date1");
  8262. string date2 = GetPostString("date2");
  8263. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8264. if (dw.Length > 0) lw.Add(dw);
  8265. string price1 = GetPostString("price1");
  8266. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8267. string price2 = GetPostString("price2");
  8268. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8269. string returndate1 = GetPostString("returndate1");
  8270. string returndate2 = GetPostString("returndate2");
  8271. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8272. if (dw1.Length > 0) lw.Add(dw1);
  8273. string billtype = GetPostString("billtype");
  8274. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8275. string billstate = GetPostString("billstate");
  8276. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8277. string usershop = CurrentUser.User.pemShop;
  8278. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8279. dStruct.Order = "createTime desc";
  8280. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8281. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8282. //foreach (DataRow dr in dt.Rows)
  8283. //{
  8284. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8285. //}
  8286. writeGridDataTableJson(dStruct.TotalCount, dt);
  8287. }
  8288. public void modify_erp_billinfo()
  8289. {
  8290. if (UrlPostParmsCheck("ID"))
  8291. {
  8292. string eid = GetPostString("ID");
  8293. CeErpBill bill_entity = null;
  8294. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8295. if (bill_entity != null)
  8296. {
  8297. bill_entity.tid = GetPostString("tid");
  8298. bill_entity.title = GetPostString("title");
  8299. bill_entity.tax = GetPostString("tax");
  8300. bill_entity.bank = GetPostString("bank");
  8301. bill_entity.bankac = GetPostString("bankac");
  8302. bill_entity.address = GetPostString("address");
  8303. bill_entity.phone = GetPostString("phone");
  8304. bill_entity.price = GetPostString("price");
  8305. bill_entity.productId = GetPostInt("ProductName");
  8306. bill_entity.num = GetPostInt("num");
  8307. bill_entity.unit = GetPostString("unit");
  8308. bill_entity.type = GetPostString("type");
  8309. bill_entity.sendType = GetPostString("SendType");
  8310. bill_entity.email = GetPostString("email");
  8311. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8312. bill_entity.shopName = GetPostString("ShopName");
  8313. bill_entity.applymemo = GetPostString("applymemo");
  8314. bill_entity.modifyTime = DateTime.Now;
  8315. bill_entity.createTime = DateTime.Now;
  8316. bill_entity.state = 0;
  8317. bill_entity.Update();
  8318. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8319. returnSuccessMsg("发票修改成功!");
  8320. return;
  8321. }
  8322. returnErrorMsg("找不到对应记录");
  8323. }
  8324. }
  8325. public void set_erp_invoicing()
  8326. {
  8327. if (UrlPostParmsCheck("id"))
  8328. {
  8329. try
  8330. {
  8331. string eid = GetPostString("id");
  8332. CeErpBill bill_entity = null;
  8333. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8334. if (bill_entity != null)
  8335. {
  8336. int ComId = GetPostInt("ComId");
  8337. //string memo = GetPostString("Memo");
  8338. int allInfo = GetPostInt("allinfo");
  8339. string clert = CurrentUser.User.Name;
  8340. //string detailValue = GetPostString("detailvalue");
  8341. string billId = bill_entity.billOrderId;
  8342. string[] billIdList = billId.Split(',');
  8343. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8344. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8345. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8346. {
  8347. billCount += 1;
  8348. }
  8349. if (billId.Length <= 0 || billIdList.Length != billCount)
  8350. {
  8351. bill_entity.billOrderId = "";
  8352. string prebill = "ltb";
  8353. for (int idx = 1; idx <= billCount; idx++)
  8354. {
  8355. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8356. string billoid = prebill + idx + dtstr;
  8357. bill_entity.billOrderId += billoid;
  8358. if (idx < billCount)
  8359. {
  8360. bill_entity.billOrderId += ",";
  8361. }
  8362. }
  8363. }
  8364. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8365. if (bill_entity.state == 5)
  8366. {
  8367. string errMsg = bill_entity.failerror;
  8368. string[] errlist = errMsg.Split('|');
  8369. string[] errTags = new string[errlist.Length];
  8370. for (int itag = 0; itag < errlist.Length; itag++)
  8371. {
  8372. if (errlist[itag].Length <= 0) continue;
  8373. errTags[itag] = errlist[itag].Split('&')[0];
  8374. }
  8375. for (int iii = 0; iii < errTags.Length; iii++)
  8376. {
  8377. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8378. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8379. if (billOrderList.Length >= erroBillOrderTag)
  8380. {
  8381. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8382. if (needModifyBillId.Length <= 19)
  8383. {
  8384. needModifyBillId = needModifyBillId + "1";
  8385. }
  8386. else
  8387. {
  8388. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8389. last = last + 1;
  8390. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8391. }
  8392. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8393. }
  8394. }
  8395. }
  8396. bool isHaveBillSucces = false;
  8397. string totalRes = "";
  8398. bill_entity.failerror = "";
  8399. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8400. {
  8401. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8402. totalRes += res;
  8403. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8404. {
  8405. isHaveBillSucces = true;
  8406. bill_entity.comId = ComId;
  8407. bill_entity.state = 1;
  8408. bill_entity.executeTime = DateTime.Now;
  8409. bill_entity.executeUser = clert;
  8410. }
  8411. else
  8412. {
  8413. bill_entity.state = 5;
  8414. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8415. }
  8416. }
  8417. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8418. bill_entity.Update();
  8419. if (isHaveBillSucces)
  8420. {
  8421. StringBuilder sql = new StringBuilder();
  8422. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8423. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8424. }
  8425. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8426. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8427. {
  8428. returnErrorMsg("开票失败");
  8429. }
  8430. else
  8431. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8432. return;
  8433. }
  8434. returnErrorMsg("找不到对应记录");
  8435. }
  8436. catch (Exception ex)
  8437. {
  8438. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8439. returnErrorMsg("操作失败");
  8440. }
  8441. }
  8442. }
  8443. public void get_erp_invoicing_back()
  8444. {
  8445. if (UrlPostParmsCheck("id"))
  8446. {
  8447. try
  8448. {
  8449. string id = GetPostString("id");
  8450. CeErpBill entiy = CeErpBill.Get(id);
  8451. if (entiy != null)
  8452. {
  8453. if (entiy.state == 0)
  8454. {
  8455. returnErrorMsg("发票还未开具");
  8456. return;
  8457. }
  8458. string[] billOrderList = entiy.billOrderId.Split(',');
  8459. int iTag = 0;
  8460. entiy.fplsh = "";
  8461. entiy.fpdm = "";
  8462. entiy.fphm = "";
  8463. foreach (string billOrderId in billOrderList)
  8464. {
  8465. iTag++;
  8466. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8467. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8468. {
  8469. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8470. try
  8471. {
  8472. Invoicing_get_response_Obj iObj = null;
  8473. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8474. if (iObj != null)
  8475. {
  8476. entiy.state = 2;
  8477. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8478. entiy.fpdm += iObj.list[0].c_fpdm;
  8479. entiy.fphm += iObj.list[0].c_fphm;
  8480. if (iTag < billOrderList.Length)
  8481. {
  8482. entiy.fplsh += ",";
  8483. entiy.fpdm += ",";
  8484. entiy.fphm += ",";
  8485. }
  8486. entiy.Update();
  8487. }
  8488. StringBuilder sql = new StringBuilder();
  8489. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8490. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8491. returnSuccessMsg("开票成功");
  8492. }
  8493. catch (Exception ex)
  8494. {
  8495. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8496. }
  8497. return;
  8498. }
  8499. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8500. {
  8501. var res_obj = new
  8502. {
  8503. data = "开票中"
  8504. };
  8505. string ro_json = JsonConvert.SerializeObject(res_obj);
  8506. returnSuccess(ro_json);
  8507. return;
  8508. }
  8509. else
  8510. {
  8511. int eidx = res.IndexOf("c_resultmsg");
  8512. int lidx = res.IndexOf("c_status");
  8513. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8514. entiy.state = 5;
  8515. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8516. entiy.Update();
  8517. returnErrorMsg("开票失败");
  8518. return;
  8519. }
  8520. }
  8521. }
  8522. }
  8523. catch (Exception ex)
  8524. {
  8525. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8526. }
  8527. return;
  8528. }
  8529. }
  8530. public void get_erp_invoicing()
  8531. {
  8532. if (UrlPostParmsCheck("id"))
  8533. {
  8534. try
  8535. {
  8536. string id = GetPostString("id");
  8537. CeErpBill entiy = CeErpBill.Get(id);
  8538. if (entiy != null)
  8539. {
  8540. if (entiy.state == 0)
  8541. {
  8542. returnErrorMsg("发票还未开具");
  8543. return;
  8544. }
  8545. if (entiy.sendType == "纸质发票")
  8546. {
  8547. if (entiy.img.Length <= 0)
  8548. {
  8549. returnErrorMsg("查无纸质发票");
  8550. return;
  8551. }
  8552. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8553. returnSuccess(returnres);
  8554. return;
  8555. }
  8556. string[] billOrderList = entiy.billOrderId.Split(',');
  8557. int iTag = 0;
  8558. string fpUrl = "";
  8559. entiy.fplsh = "";
  8560. entiy.fpdm = "";
  8561. entiy.fphm = "";
  8562. foreach (string billOrderId in billOrderList)
  8563. {
  8564. iTag++;
  8565. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8566. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8567. {
  8568. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8569. Invoicing_get_response_Obj iObj = null;
  8570. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8571. if (iObj != null)
  8572. {
  8573. //entiy.state = 2;
  8574. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8575. entiy.fpdm += iObj.list[0].c_fpdm;
  8576. entiy.fphm += iObj.list[0].c_fphm;
  8577. if (iTag < billOrderList.Length)
  8578. {
  8579. entiy.fplsh += ",";
  8580. entiy.fpdm += ",";
  8581. entiy.fphm += ",";
  8582. }
  8583. entiy.Update();
  8584. fpUrl += iObj.list[0].c_url + ",";
  8585. }
  8586. //returnSuccess(res);
  8587. StringBuilder sql = new StringBuilder();
  8588. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8589. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8590. }
  8591. else
  8592. {
  8593. int eidx = res.IndexOf("c_resultmsg");
  8594. //int lidx = res.IndexOf("c_status");
  8595. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8596. //开票失败
  8597. entiy.state = 5;
  8598. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8599. entiy.Update();
  8600. returnErrorMsg("开票失败");
  8601. return;
  8602. }
  8603. }
  8604. var returnObj = new
  8605. {
  8606. data = fpUrl
  8607. };
  8608. string ro_json = JsonConvert.SerializeObject(returnObj);
  8609. returnSuccess(ro_json);
  8610. }
  8611. }
  8612. catch (Exception ex)
  8613. {
  8614. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8615. }
  8616. return;
  8617. }
  8618. }
  8619. public void save_erp_billimg()
  8620. {
  8621. if (UrlPostParmsCheck("id"))
  8622. {
  8623. string eid = GetPostString("id");
  8624. CeErpBill bill_entity = null;
  8625. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8626. if (bill_entity != null)
  8627. {
  8628. bill_entity.img = GetPostString("img");
  8629. bill_entity.executeTime = DateTime.Now;
  8630. bill_entity.state = 2;
  8631. bill_entity.Update();
  8632. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8633. returnSuccessMsg("保存成功");
  8634. }
  8635. return;
  8636. }
  8637. }
  8638. public void upd_erp_billreturnback()
  8639. {
  8640. if (UrlPostParmsCheck("id"))
  8641. {
  8642. int eid = GetPostInt("id");
  8643. CeErpBill bill_entity = null;
  8644. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8645. if (bill_entity != null)
  8646. {
  8647. bill_entity.state = 3;
  8648. bill_entity.returnReason = GetPostString("reason");
  8649. bill_entity.Update();
  8650. returnSuccessMsg("驳回成功!");
  8651. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8652. }
  8653. return;
  8654. }
  8655. }
  8656. public void cancel_erp_bill()
  8657. {
  8658. if (UrlPostParmsCheck("id"))
  8659. {
  8660. int eid = GetPostInt("id");
  8661. int detailValue = GetPostInt("detailvalue");
  8662. CeErpBill bill_entity = null;
  8663. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8664. string cres = "";
  8665. string gres = "";
  8666. if (bill_entity != null)
  8667. {
  8668. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8669. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8670. {
  8671. int iTag = 0;
  8672. bill_entity.fplsh = "";
  8673. bill_entity.fpdm = "";
  8674. bill_entity.fphm = "";
  8675. foreach (string billOrderId in billOrderList)
  8676. {
  8677. iTag++;
  8678. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8679. if (gres.IndexOf("success") != -1)
  8680. {
  8681. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8682. Invoicing_get_response_Obj iObj = null;
  8683. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8684. if (iObj != null)
  8685. {
  8686. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8687. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8688. bill_entity.fphm += iObj.list[0].c_fphm;
  8689. if (iTag < billOrderList.Length)
  8690. {
  8691. bill_entity.fplsh += ",";
  8692. bill_entity.fpdm += ",";
  8693. bill_entity.fphm += ",";
  8694. }
  8695. bill_entity.Update();
  8696. }
  8697. }
  8698. else
  8699. {
  8700. returnErrorMsg(gres);
  8701. return;
  8702. }
  8703. }
  8704. }
  8705. if (bill_entity.sendType == "纸质发票")
  8706. {
  8707. //作废
  8708. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8709. //if (DateTime.Now.Month == extime.Month)
  8710. //{
  8711. //cres = taobaoHelper.cancel_invoicing(eid);
  8712. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8713. //{
  8714. bill_entity.state = 4;//已作废
  8715. bill_entity.Update();
  8716. returnSuccessMsg("发票已作废");
  8717. return;
  8718. //}
  8719. //else
  8720. //{
  8721. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8722. // bill_entity.Update();
  8723. // returnErrorMsg(cres);
  8724. // return;
  8725. //}
  8726. //}
  8727. //else
  8728. //{
  8729. // returnErrorMsg("纸质发票只能作废本月的发票");
  8730. // return;
  8731. //}
  8732. }
  8733. //红冲
  8734. int redTag = 0;
  8735. string[] fpdmList = bill_entity.fpdm.Split(',');
  8736. string[] fphmList = bill_entity.fphm.Split(',');
  8737. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8738. {
  8739. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8740. return;
  8741. }
  8742. foreach (string billOrderId in billOrderList)
  8743. {
  8744. redTag++;
  8745. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8746. cres += onecres;
  8747. cres += ",";
  8748. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8749. {
  8750. bill_entity.state = 4;//已作废
  8751. //bill_entity.Update();
  8752. //returnSuccessMsg("发票已红冲");
  8753. }
  8754. else if (onecres.IndexOf("重复冲红") != -1)
  8755. {
  8756. bill_entity.state = 4;//已作废
  8757. //bill_entity.Update();
  8758. //returnSuccessMsg("发票已红冲");
  8759. }
  8760. else
  8761. {
  8762. string errmsg = commonHelper.KeepChinese(onecres);
  8763. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8764. }
  8765. }
  8766. bill_entity.Update();
  8767. if (cres.IndexOf("失败") != -1)
  8768. returnErrorMsg("红冲失败");
  8769. else
  8770. returnSuccessMsg("发票已红冲");
  8771. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8772. return;
  8773. }
  8774. return;
  8775. }
  8776. }
  8777. public void del_erp_billorder()
  8778. {
  8779. if (UrlPostParmsCheck("id"))
  8780. {
  8781. string eid = GetPostString("id");
  8782. CeErpBill.Del(eid);
  8783. CeErpBill bill = CeErpBill.Get(eid);
  8784. if (bill != null)
  8785. {
  8786. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8787. }
  8788. returnSuccessMsg("删除成功");
  8789. }
  8790. }
  8791. public void finish_erp_bill()
  8792. {
  8793. if (UrlPostParmsCheck("ids"))
  8794. {
  8795. string eids = GetPostString("ids");
  8796. string[] list = eids.Split(',');
  8797. foreach (string eid in list)
  8798. {
  8799. CeErpBill bill = CeErpBill.Get(eid);
  8800. if (bill != null)
  8801. {
  8802. bill.state = 2;
  8803. bill.Update();
  8804. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8805. }
  8806. }
  8807. returnSuccessMsg("操作成功");
  8808. }
  8809. }
  8810. public void get_erp_returncash()
  8811. {
  8812. DataStruct dStruct = GetPostStruct();
  8813. List<string> lw = new List<string>();
  8814. string tid = GetPostString("tid");
  8815. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8816. string shopname = GetPostString("shopname");
  8817. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8818. string buyernick = GetPostString("buyer_nick");
  8819. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8820. string customer = GetPostString("customer");
  8821. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8822. string returndate1 = GetPostString("returndate1");
  8823. string returndate2 = GetPostString("returndate2");
  8824. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8825. if (dw.Length > 0) lw.Add(dw);
  8826. string finishDate1 = GetPostString("finishdate1");
  8827. string finishDate2 = GetPostString("finishdate2");
  8828. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8829. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8830. string returntype = GetPostString("returntype");
  8831. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8832. string returnvstate = GetPostString("returnvstate");
  8833. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8834. dStruct.Order = "created desc";
  8835. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8836. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8837. writeGridDataTableJson(dStruct.TotalCount, dt);
  8838. }
  8839. public void get_erp_staygoods()
  8840. {
  8841. DataStruct dStruct = GetPostStruct();
  8842. List<string> lw = new List<string>();
  8843. string tid = GetPostString("tid");
  8844. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8845. string shopname = GetPostString("shopname");
  8846. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8847. string wangwang = GetPostString("wangwang");
  8848. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8849. string customer = GetPostString("customer");
  8850. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8851. string returndate1 = GetPostString("returndate1");
  8852. string returndate2 = GetPostString("returndate2");
  8853. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8854. if (dw.Length > 0) lw.Add(dw);
  8855. string finishDate1 = GetPostString("finishdate1");
  8856. string finishDate2 = GetPostString("finishdate2");
  8857. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8858. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8859. string returnvstate = GetPostString("returnvstate");
  8860. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8861. string persuadetype = GetPostString("persuadetype");
  8862. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8863. string customerOrg = GetPostString("customerOrg");
  8864. if (customerOrg.Length > 0)
  8865. {
  8866. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8867. }
  8868. dStruct.Order = "creata_time desc";
  8869. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8870. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8871. writeGridDataTableJson(dStruct.TotalCount, dt);
  8872. }
  8873. public void upd_erp_staygoods()
  8874. {
  8875. if (UrlPostParmsCheck("id"))
  8876. {
  8877. int eid = GetPostInt("id");
  8878. CeErpStayGoods entity = null;
  8879. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8880. if (entity != null)
  8881. {
  8882. entity.audit_type = 1;
  8883. entity.audit_time = DateTime.Now;
  8884. entity.audit_u_id = CurrentUser.UserID;
  8885. entity.audit_u_name = CurrentUser.UserName;
  8886. entity.Update();
  8887. returnSuccessMsg("审核成功!");
  8888. return;
  8889. }
  8890. returnErrorMsg("找不到订单记录");
  8891. }
  8892. }
  8893. public void upd_erp_stayGoodsback()
  8894. {
  8895. if (UrlPostParmsCheck("id"))
  8896. {
  8897. int eid = GetPostInt("id");
  8898. CeErpStayGoods entity = null;
  8899. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8900. if (entity != null)
  8901. {
  8902. entity.audit_text = GetPostString("reason");
  8903. entity.audit_type = 2;
  8904. entity.audit_time = DateTime.Now;
  8905. entity.audit_u_id = CurrentUser.UserID;
  8906. entity.audit_u_name = CurrentUser.UserName;
  8907. entity.Update();
  8908. returnSuccessMsg("退回成功!");
  8909. return;
  8910. }
  8911. returnErrorMsg("找不到订单记录");
  8912. }
  8913. }
  8914. public void upd_erp_returncashverify()
  8915. {
  8916. if (UrlPostParmsCheck("ID"))
  8917. {
  8918. int eid = GetPostInt("ID");
  8919. CeErpReturnCash entity = null;
  8920. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8921. if (entity != null)
  8922. {
  8923. entity.cashstate = 1;
  8924. entity.verifytime = DateTime.Now;
  8925. entity.verifyuserid = CurrentUser.UserID;
  8926. entity.Update();
  8927. returnSuccessMsg("审核成功!");
  8928. return;
  8929. }
  8930. returnErrorMsg("找不到订单记录");
  8931. }
  8932. }
  8933. public void upd_all_erp_returncashverify()
  8934. {
  8935. if (UrlPostParmsCheck("ID"))
  8936. {
  8937. String[] list = GetPostString("ID").Split(',');
  8938. CeErpReturnCash entity = null;
  8939. for (int i = 0; i < list.Length; i++)
  8940. {
  8941. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8942. if (entity != null)
  8943. {
  8944. if (entity.cashstate == 1)
  8945. {
  8946. returnErrorMsg("已审核过的订单不需要在审核!");
  8947. return;
  8948. }
  8949. entity.cashstate = 1;
  8950. entity.verifytime = DateTime.Now;
  8951. entity.verifyuserid = CurrentUser.UserID;
  8952. entity.Update();
  8953. }
  8954. }
  8955. returnSuccessMsg("审核成功!");
  8956. return;
  8957. }
  8958. }
  8959. public void upd_erp_returncashback()
  8960. {
  8961. if (UrlPostParmsCheck("ID"))
  8962. {
  8963. int eid = GetPostInt("ID");
  8964. CeErpReturnCash entity = null;
  8965. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8966. if (entity != null)
  8967. {
  8968. entity.backreason = GetPostString("reason");
  8969. entity.cashstate = 2;
  8970. entity.verifytime = DateTime.Now;
  8971. entity.verifyuserid = CurrentUser.UserID;
  8972. entity.Update();
  8973. returnSuccessMsg("退回成功!");
  8974. return;
  8975. }
  8976. returnErrorMsg("找不到订单记录");
  8977. }
  8978. }
  8979. public void upd_erp_returnprice()
  8980. {
  8981. if (UrlPostParmsCheck("ID"))
  8982. {
  8983. int eid = GetPostInt("ID");
  8984. CeErpReturnCash entity = null;
  8985. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8986. if (entity != null)
  8987. {
  8988. if (entity.cashstate == 1)
  8989. {
  8990. returnErrorMsg("审核通过了不能改");
  8991. return;
  8992. }
  8993. entity.returnprice = GetPostDouble("returnprice");
  8994. entity.Update();
  8995. returnSuccessMsg("修改成功!");
  8996. return;
  8997. }
  8998. returnErrorMsg("找不到订单记录");
  8999. }
  9000. }
  9001. public void del_erp_returncash()
  9002. {
  9003. if (UrlPostParmsCheck("ID"))
  9004. {
  9005. int eid = GetPostInt("ID");
  9006. CeErpReturnCash.Del(eid);
  9007. returnSuccessMsg("操作成功");
  9008. return;
  9009. }
  9010. }
  9011. public void test_for_do_sql()
  9012. {
  9013. string sql = GetPostString("sqlstr");
  9014. if (sql.Length > 0)
  9015. {
  9016. try
  9017. {
  9018. DbHelper.DbConn.ExecuteNonQuery(sql);
  9019. var res_obj = new
  9020. {
  9021. data = "成功",
  9022. };
  9023. string ro_json = JsonConvert.SerializeObject(res_obj);
  9024. returnSuccess(ro_json);
  9025. }
  9026. catch (Exception ex)
  9027. {
  9028. var res_obj = new
  9029. {
  9030. data = ex.Message,
  9031. };
  9032. string ro_json = JsonConvert.SerializeObject(res_obj);
  9033. returnSuccess(ro_json);
  9034. }
  9035. }
  9036. }
  9037. public void get_user_info()
  9038. {
  9039. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9040. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9041. }
  9042. public void get_total_data()
  9043. {
  9044. int userId = CurrentUser.UserID;
  9045. string sql = "";
  9046. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9047. {
  9048. 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);
  9049. }
  9050. else
  9051. {
  9052. 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 " +
  9053. "(select ID from CE_ErpUser where ID = {0}) d " +
  9054. "left join " +
  9055. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9056. ") a on d.ID = a.id left join " +
  9057. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9058. ") b on a.id = b.id1 left join" +
  9059. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9060. ") c on a.id = c.id2;", userId);
  9061. }
  9062. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9063. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9064. }
  9065. public void get_date_area_total_data2()
  9066. {
  9067. int userId = CurrentUser.UserID;
  9068. string date_type = GetPostString("timetype");
  9069. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9070. string sql = "";
  9071. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9072. {
  9073. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9074. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9075. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9076. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9077. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9078. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9079. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9080. ") a on e.ID = a.id left join " +
  9081. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9082. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9083. ") b on a.id = b.id1 " +
  9084. "left join " +
  9085. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9086. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9087. ") c on a.id = c.id2 " +
  9088. "left join " +
  9089. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9090. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9091. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9092. }
  9093. else
  9094. {
  9095. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9096. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9097. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9098. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9099. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9100. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9101. ") a on e.ID = a.id left join " +
  9102. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9103. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9104. ") c on a.id = c.id2 " +
  9105. "left join " +
  9106. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9107. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9108. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9109. }
  9110. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9111. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9112. }
  9113. public void get_date_area_total_data()
  9114. {
  9115. int userId = CurrentUser.UserID;
  9116. string date_type = GetPostString("timetype");
  9117. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9118. string date1 = searchDT[0].ToString();
  9119. string date2 = searchDT[1].ToString();
  9120. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9121. {
  9122. SqlParameter[] sqlParameter ={
  9123. new SqlParameter("@userId", SqlDbType.Int,4),
  9124. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9125. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9126. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9127. };
  9128. sqlParameter[0].Value = userId;
  9129. sqlParameter[1].Value = date1;
  9130. sqlParameter[2].Value = date2;
  9131. sqlParameter[3].Direction = ParameterDirection.Output;
  9132. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9133. string res = sqlParameter[3].Value.ToString();
  9134. var res_obj = new
  9135. {
  9136. data = res
  9137. };
  9138. string ro_json = JsonConvert.SerializeObject(res_obj);
  9139. returnSuccess(ro_json);
  9140. }
  9141. else
  9142. {
  9143. SqlParameter[] sqlParameter ={
  9144. new SqlParameter("@userId", SqlDbType.Int,4),
  9145. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9146. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9147. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9148. };
  9149. sqlParameter[0].Value = userId;
  9150. sqlParameter[1].Value = date1;
  9151. sqlParameter[2].Value = date2;
  9152. sqlParameter[3].Direction = ParameterDirection.Output;
  9153. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9154. string res = sqlParameter[3].Value.ToString();
  9155. var res_obj = new
  9156. {
  9157. data = res
  9158. };
  9159. string ro_json = JsonConvert.SerializeObject(res_obj);
  9160. returnSuccess(ro_json);
  9161. }
  9162. //writeGridDataViewJson(dt.Rows.Count, dv);
  9163. }
  9164. public void get_order_list()
  9165. {
  9166. string strFields = GetPostString("paraFields");
  9167. string strOrder = GetPostString("paraOrder");
  9168. string strWhere = GetPostString("paraWhere");
  9169. string strPageSize = GetPostString("paraPageSize");
  9170. DataStruct dStruct = GetPostStruct();
  9171. dStruct.PageSize = int.Parse(strPageSize);
  9172. dStruct.Fileds = strFields;
  9173. dStruct.Order = strOrder;
  9174. dStruct.MainWhere = strWhere;
  9175. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9176. writeGridDataTableJson(dStruct.TotalCount, dt);
  9177. }
  9178. ////获取待开始订单列表
  9179. //public void get_wait_design_order_list()
  9180. //{
  9181. // string date_type = GetPostString("date_type");
  9182. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9183. // DataStruct dStruct = GetPostStruct();
  9184. // dStruct.PageSize = 1000;
  9185. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9186. // List<string> lw = new List<string>();
  9187. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9188. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9189. // dStruct.Order = "WaitDesignTime asc";
  9190. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9191. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9192. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9193. //}
  9194. //获取完成单量排名
  9195. public void get_finish_order_count_ranking()
  9196. {
  9197. /* string date_type = GetPostString("date_type");
  9198. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9199. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9200. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9201. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9202. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9203. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9204. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9205. writeGridDataTableJson(0, new DataTable());
  9206. }
  9207. public void get_finish_order_amount_ranking()
  9208. {
  9209. /*string date_type = GetPostString("date_type");
  9210. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9211. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9212. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9213. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9214. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9215. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9216. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9217. writeGridDataTableJson(0, new DataTable());
  9218. }
  9219. public void get_finish_refund_count_ranking()
  9220. {
  9221. string date_type = GetPostString("date_type");
  9222. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9223. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9224. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9225. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9226. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9227. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9228. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9229. writeGridDataTableJson(dt.Rows.Count, dt);
  9230. }
  9231. public void get_finish_refund_amount_ranking()
  9232. {
  9233. string date_type = GetPostString("date_type");
  9234. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9235. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9236. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9237. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9238. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9239. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9240. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9241. writeGridDataTableJson(dt.Rows.Count, dt);
  9242. }
  9243. public void set_erp_finishorder_director()
  9244. {
  9245. if (UrlPostParmsCheck("ctid"))
  9246. {
  9247. string eid = GetPostString("ctid");
  9248. CeErpTradeCell entity = null;
  9249. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9250. if (entity != null)
  9251. {
  9252. entity.OrderState = 8;
  9253. entity.Update();
  9254. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9255. returnSuccessMsg("操作成功!");
  9256. return;
  9257. }
  9258. returnErrorMsg("找不到记录");
  9259. }
  9260. }
  9261. public void get_erp_placeregistlist()
  9262. {
  9263. DataStruct dStruct = GetPostStruct();
  9264. List<string> lw = new List<string>();
  9265. string outsid = GetPostString("outsid");
  9266. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9267. string memo = GetPostString("memo");
  9268. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9269. string filename = GetPostString("filename");
  9270. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9271. string islate = GetPostString("islate");
  9272. if (islate.Length > 0)
  9273. {
  9274. if (islate == "1")
  9275. lw.Add(string.Format("OutLate>0"));
  9276. else
  9277. lw.Add(string.Format("OutLate=0"));
  9278. }
  9279. string placedate1 = GetPostString("placedate1");
  9280. string placedate2 = GetPostString("placedate2");
  9281. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9282. if (dw.Length > 0) lw.Add(dw);
  9283. string deliveryDate1 = GetPostString("deliverydate1");
  9284. string deliveryDate2 = GetPostString("deliverydate2");
  9285. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9286. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9287. dStruct.Order = "ID desc";
  9288. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9289. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9290. writeGridDataTableJson(dStruct.TotalCount, dt);
  9291. }
  9292. public void ins_erp_placeregist()
  9293. {
  9294. if (UrlPostParmsCheck("id"))
  9295. {
  9296. string eid = GetPostString("id");
  9297. CeErpPlaceRegister entity = null;
  9298. if (eid == "0")//新增
  9299. {
  9300. entity = new CeErpPlaceRegister();
  9301. string xdTime = GetPostString("placeTime");
  9302. if (xdTime.Length > 0)
  9303. {
  9304. entity.PlactTime = Convert.ToDateTime(xdTime);
  9305. }
  9306. string fhTime = GetPostString("deliveryTime");
  9307. if (fhTime.Length > 0)
  9308. {
  9309. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9310. }
  9311. string preTime = GetPostString("preOutTime");
  9312. if (preTime.Length > 0)
  9313. {
  9314. entity.PreOutTime = Convert.ToDateTime(preTime);
  9315. }
  9316. entity.DeliveryCount = GetPostInt("deliveryCount");
  9317. entity.ReceiveCount = GetPostInt("receiveCount");
  9318. entity.OutSid = GetPostString("outSid");
  9319. entity.FileName = GetPostString("fileName");
  9320. entity.Memo = GetPostString("memo");
  9321. entity.AddUserId = CurrentUser.UserID;
  9322. entity.CreateTime = DateTime.Now;
  9323. entity.Img = GetPostString("img");
  9324. entity.Supplier = GetPostInt("supplier");
  9325. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9326. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9327. {
  9328. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9329. DateTime dt2 = (DateTime)entity.PreOutTime;
  9330. TimeSpan span = dt1.Subtract(dt2);
  9331. if (span.Days > 0)
  9332. {
  9333. entity.OutLate = span.Days;
  9334. }
  9335. }
  9336. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9337. entity.Create();
  9338. returnSuccessMsg("添加成功!");
  9339. return;
  9340. }
  9341. else //修改
  9342. {
  9343. entity = CeErpPlaceRegister.Get(eid);
  9344. if (entity != null)
  9345. {
  9346. string xdTime = GetPostString("placeTime");
  9347. if (xdTime.Length > 0)
  9348. {
  9349. entity.PlactTime = Convert.ToDateTime(xdTime);
  9350. }
  9351. string fhTime = GetPostString("deliveryTime");
  9352. if (fhTime.Length > 0)
  9353. {
  9354. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9355. }
  9356. string preTime = GetPostString("preOutTime");
  9357. if (preTime.Length > 0)
  9358. {
  9359. entity.PreOutTime = Convert.ToDateTime(preTime);
  9360. }
  9361. entity.DeliveryCount = GetPostInt("deliveryCount");
  9362. entity.ReceiveCount = GetPostInt("receiveCount");
  9363. if (entity.DeliveryCount == entity.ReceiveCount)
  9364. {
  9365. entity.CurState = "已完成";
  9366. }
  9367. else
  9368. {
  9369. entity.CurState = "未完成";
  9370. }
  9371. entity.OutSid = GetPostString("outSid");
  9372. entity.FileName = GetPostString("fileName");
  9373. entity.Memo = GetPostString("memo");
  9374. entity.Img = GetPostString("img");
  9375. entity.Supplier = GetPostInt("supplier");
  9376. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9377. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9378. {
  9379. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9380. DateTime dt2 = (DateTime)entity.PreOutTime;
  9381. TimeSpan span = dt1.Subtract(dt2);
  9382. if (span.Days > 0)
  9383. {
  9384. entity.OutLate = span.Days;
  9385. }
  9386. }
  9387. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9388. entity.Update();
  9389. returnSuccessMsg("修改成功");
  9390. return;
  9391. }
  9392. returnErrorMsg("找不到对应的记录");
  9393. return;
  9394. }
  9395. }
  9396. returnErrorMsg("缺少必要参数");
  9397. }
  9398. public void del_erp_placeregist()
  9399. {
  9400. string eid = GetPostString("id");
  9401. CeErpPlaceRegister.Del(eid);
  9402. returnSuccessMsg("删除成功!");
  9403. return;
  9404. }
  9405. public void ins_erp_placeregistbyorder()
  9406. {
  9407. string ctid = GetPostString("ctid");
  9408. if (ctid.Length > 0)
  9409. {
  9410. StringBuilder sql = new StringBuilder();
  9411. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9412. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9413. if (dt.Rows.Count > 0)
  9414. {
  9415. foreach (DataRow dr in dt.Rows)
  9416. {
  9417. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9418. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9419. entity.AddUserId = CurrentUser.UserID;
  9420. entity.tid = dr["tid"].ToString();
  9421. entity.Did = Convert.ToString(dr["ctid"]);
  9422. entity.splitTag = dr["SplitTag"].ToString();
  9423. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9424. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9425. if (pre_ctid.Length > 0)
  9426. {
  9427. sellmemo = sellmemo.Replace(pre_ctid, "");
  9428. }
  9429. sellmemo = sellmemo.Replace("[", "");
  9430. sellmemo = sellmemo.Replace("]", "");
  9431. entity.FileName = sellmemo;
  9432. string count = dr["ProductCount"].ToString();
  9433. int usecount = commonHelper.getIntCountFromString(count);
  9434. entity.DeliveryCount = usecount;
  9435. entity.CurState = "未完成";
  9436. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9437. {
  9438. entity.Supplier = 24;//dl手提袋定制
  9439. }
  9440. else
  9441. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9442. entity.CreateTime = DateTime.Now;
  9443. entity.Create();
  9444. }
  9445. returnSuccessMsg("操作成功");
  9446. return;
  9447. }
  9448. returnErrorMsg("没有找到对应订单");
  9449. return;
  9450. }
  9451. returnErrorMsg("缺少订单编号");
  9452. return;
  9453. }
  9454. public void get_erp_persuadelist()
  9455. {
  9456. DataStruct dStruct = GetPostStruct();
  9457. List<string> lw = new List<string>();
  9458. string ctid = GetPostString("ctid");
  9459. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9460. string shopname = GetPostString("shopname");
  9461. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9462. string buyernick = GetPostString("buyer_nick");
  9463. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9464. string customer = GetPostString("customer");
  9465. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9466. string returndate1 = GetPostString("returndate1");
  9467. string returndate2 = GetPostString("returndate2");
  9468. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9469. if (dw.Length > 0) lw.Add(dw);
  9470. string finishDate1 = GetPostString("finishdate1");
  9471. string finishDate2 = GetPostString("finishdate2");
  9472. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9473. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9474. string persuadetype = GetPostString("persuadetype");
  9475. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9476. string returnvstate = GetPostString("returnvstate");
  9477. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9478. dStruct.Order = "created desc";
  9479. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9480. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9481. writeGridDataTableJson(dStruct.TotalCount, dt);
  9482. }
  9483. public void upd_erp_returnpersuadeback()
  9484. {
  9485. if (UrlPostParmsCheck("ID"))
  9486. {
  9487. int eid = GetPostInt("ID");
  9488. CeErpPersuade entity = null;
  9489. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9490. if (entity != null)
  9491. {
  9492. entity.backreason = GetPostString("reason");
  9493. entity.pstate = 2;
  9494. entity.verifytime = DateTime.Now;
  9495. entity.verifyuserid = CurrentUser.UserID;
  9496. entity.Update();
  9497. returnSuccessMsg("退回成功!");
  9498. return;
  9499. }
  9500. returnErrorMsg("找不到订单记录");
  9501. }
  9502. }
  9503. public void upd_erp_returnpersuadeverify()
  9504. {
  9505. if (UrlPostParmsCheck("ID"))
  9506. {
  9507. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9508. {
  9509. returnErrorMsg("暂无权限审核");
  9510. return;
  9511. }
  9512. int eid = GetPostInt("ID");
  9513. CeErpPersuade entity = null;
  9514. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9515. if (entity != null)
  9516. {
  9517. entity.pstate = 1;
  9518. entity.verifytime = DateTime.Now;
  9519. entity.verifyuserid = CurrentUser.UserID;
  9520. entity.Update();
  9521. returnSuccessMsg("审核成功!");
  9522. return;
  9523. }
  9524. returnErrorMsg("找不到订单记录");
  9525. }
  9526. }
  9527. public void del_erp_persuade()
  9528. {
  9529. if (UrlPostParmsCheck("ID"))
  9530. {
  9531. int eid = GetPostInt("ID");
  9532. CeErpPersuade.Del(eid);
  9533. returnSuccessMsg("操作成功");
  9534. return;
  9535. }
  9536. }
  9537. public void get_erp_oldcustoupload()
  9538. {
  9539. DataStruct dStruct = GetPostStruct();
  9540. List<string> lw = new List<string>();
  9541. string buyernick = GetPostString("buyer_nick");
  9542. if (buyernick.Length > 0)
  9543. {
  9544. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9545. }
  9546. else
  9547. return;
  9548. dStruct.Order = "pay_time desc";
  9549. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9550. DataTable dt = null;
  9551. dt = WebCache.GetData("view_erptradecell", dStruct);
  9552. writeGridDataTableJson(dStruct.TotalCount, dt);
  9553. }
  9554. public void get_erp_checkorderlist()
  9555. {
  9556. DataStruct dStruct = GetPostStruct();
  9557. List<string> lw = new List<string>();
  9558. string tid = GetPostString("ctid");
  9559. if (tid.Length > 0)
  9560. {
  9561. string select_tid = getTidByCtid(tid);
  9562. lw.Add(string.Format("tid='{0}'", select_tid));
  9563. }
  9564. string shopname = GetPostString("shopname");
  9565. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9566. string buyernick = GetPostString("buyer_nick");
  9567. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9568. string customer = GetPostString("customer");
  9569. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9570. string design = GetPostString("design");
  9571. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9572. string orderState = GetPostString("orderState");
  9573. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9574. string address = GetPostString("address");
  9575. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9576. string sellermemo = GetPostString("seller_memo");
  9577. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9578. string supplier = GetPostString("supplier");
  9579. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9580. {
  9581. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9582. }
  9583. else
  9584. {
  9585. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9586. }
  9587. string date1 = GetPostString("date1");
  9588. string date2 = GetPostString("date2");
  9589. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9590. if (dw.Length > 0) lw.Add(dw);
  9591. string placedate1 = GetPostString("placedate1");
  9592. string placedate2 = GetPostString("placedate2");
  9593. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9594. if (fdw.Length > 0) lw.Add(fdw);
  9595. string price1 = GetPostString("price1");
  9596. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9597. string price2 = GetPostString("price2");
  9598. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9599. string checkst = GetPostString("checkstate");
  9600. if (checkst.Length > 0 && "10".Equals(checkst))
  9601. {
  9602. lw.Add(string.Format("CheckOut>0"));
  9603. }
  9604. else
  9605. {
  9606. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9607. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9608. }
  9609. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9610. {
  9611. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9612. }
  9613. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9614. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9615. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9616. writeGridDataTableJson(dStruct.TotalCount, dt);
  9617. }
  9618. public void ins_erp_startCheck()
  9619. {
  9620. if (UrlPostParmsCheck("ctid"))
  9621. {
  9622. string eid = GetPostString("ctid");
  9623. CeErpTradeCell entity = null;
  9624. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9625. if (entity != null)
  9626. {
  9627. entity.MemoOpt = 4;
  9628. entity.UpdateTime = DateTime.Now;
  9629. entity.Update();
  9630. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9631. CeErpSukuraData.createInfo(entity.ctid, 6);
  9632. returnSuccessMsg("操作成功!");
  9633. return;
  9634. }
  9635. returnErrorMsg("找不到记录");
  9636. }
  9637. }
  9638. public void upd_erp_sendXlw()
  9639. {
  9640. if (UrlPostParmsCheck("ctid"))
  9641. {
  9642. string eid = GetPostString("ctid");
  9643. CeErpTradeCell entity = null;
  9644. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9645. if (entity != null)
  9646. {
  9647. if (entity.IsSendGift == 1)
  9648. {
  9649. returnErrorMsg("请勿重复标记");
  9650. return;
  9651. }
  9652. entity.IsSendGift = 1;
  9653. entity.Update();
  9654. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9655. returnSuccessMsg("操作成功!");
  9656. return;
  9657. }
  9658. returnErrorMsg("找不到记录");
  9659. }
  9660. }
  9661. public void cancel_sendXlw()
  9662. {
  9663. if (UrlPostParmsCheck("ctid"))
  9664. {
  9665. string eid = GetPostString("ctid");
  9666. CeErpTradeCell entity = null;
  9667. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9668. if (entity != null)
  9669. {
  9670. if (entity.IsSendGift == 0)
  9671. {
  9672. returnErrorMsg("未标记小礼物");
  9673. return;
  9674. }
  9675. entity.IsSendGift = 0;
  9676. entity.Update();
  9677. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9678. returnSuccessMsg("操作成功!");
  9679. return;
  9680. }
  9681. returnErrorMsg("找不到记录");
  9682. }
  9683. }
  9684. public void get_erp_designbill()
  9685. {
  9686. DataStruct dStruct = GetPostStruct();
  9687. List<string> lw = new List<string>();
  9688. int isMy = GetInt("my");
  9689. if (isMy == 1)
  9690. {
  9691. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9692. }
  9693. string tid = GetPostString("tid");
  9694. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9695. string userName = GetPostString("design");
  9696. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9697. string price1 = GetPostString("price1");
  9698. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9699. string price2 = GetPostString("price2");
  9700. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9701. string rePrice1 = GetPostString("rePrice1");
  9702. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9703. string rePrice2 = GetPostString("rePrice2");
  9704. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9705. string designerType = GetPostString("designerType");
  9706. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9707. string orderState = GetPostString("orderState");
  9708. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9709. string endTime1 = GetPostString("endTime1");
  9710. string endTime2 = GetPostString("endTime2");
  9711. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9712. if (dw.Length > 0) lw.Add(dw);
  9713. string isDk = GetPostString("isDk");
  9714. if (isDk == "1")
  9715. {
  9716. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9717. }
  9718. else if (isDk == "0")
  9719. {
  9720. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9721. }
  9722. dStruct.Order = "oid, create_time desc";
  9723. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9724. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9725. writeGridDataTableJson(dStruct.TotalCount, dt);
  9726. }
  9727. public void upd_erp_designerbill()
  9728. {
  9729. if (UrlPostParmsCheck("ID"))
  9730. {
  9731. string eid = GetPostString("ID");
  9732. CeErpDesignerBill entity = null;
  9733. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9734. if (entity != null)
  9735. {
  9736. if (GetPostDouble("designerpirce") > 0)
  9737. {
  9738. entity.realPrice = GetPostDouble("designerpirce");
  9739. entity.update_time = DateTime.Now;
  9740. entity.update_u_id = CurrentUser.UserID;
  9741. entity.update_u_name = CurrentUser.UserName;
  9742. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9743. entity.Update();
  9744. returnSuccessMsg("操作成功!");
  9745. return;
  9746. }
  9747. else
  9748. {
  9749. entity.price = GetPostDouble("price");
  9750. entity.update_time = DateTime.Now;
  9751. entity.update_u_id = CurrentUser.UserID;
  9752. entity.update_u_name = CurrentUser.UserName;
  9753. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9754. entity.Update();
  9755. returnSuccessMsg("操作成功!");
  9756. return;
  9757. }
  9758. }
  9759. returnErrorMsg("找不到记录");
  9760. }
  9761. }
  9762. public void audit_erp_designerbill()
  9763. {
  9764. if (UrlPostParmsCheck("ID"))
  9765. {
  9766. string eid = GetPostString("ID");
  9767. CeErpDesignerBill entity = null;
  9768. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9769. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9770. if (entity != null)
  9771. {
  9772. entity.realPrice = GetPostDouble("designerpirce");
  9773. entity.update_time = DateTime.Now;
  9774. entity.update_u_id = CurrentUser.UserID;
  9775. entity.update_u_name = CurrentUser.UserName;
  9776. entity.isAudit = 1;
  9777. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9778. entity.Update();
  9779. if (orderEntity != null)
  9780. {
  9781. orderEntity.IsReadTag = 3;
  9782. orderEntity.Update();
  9783. }
  9784. returnSuccessMsg("操作成功!");
  9785. return;
  9786. }
  9787. returnErrorMsg("找不到记录");
  9788. }
  9789. }
  9790. public void all_audit_erp_designerbill()
  9791. {
  9792. if (UrlPostParmsCheck("idList"))
  9793. {
  9794. string[] list = GetPostString("idList").Split(',');
  9795. CeErpDesignerBill entity = null;
  9796. for (int i = 0; i < list.Length; i++)
  9797. {
  9798. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9799. if (entity == null) return;
  9800. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9801. if (orderEntity == null) return;
  9802. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9803. entity.update_time = DateTime.Now;
  9804. entity.update_u_id = CurrentUser.UserID;
  9805. entity.update_u_name = CurrentUser.UserName;
  9806. entity.isAudit = 1;
  9807. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9808. entity.Update();
  9809. orderEntity.IsReadTag = 3;
  9810. orderEntity.Update();
  9811. }
  9812. returnSuccessMsg("操作成功!");
  9813. return;
  9814. }
  9815. }
  9816. public void get_erp_sameorders()
  9817. {
  9818. if (UrlPostParmsCheck("ctid"))
  9819. {
  9820. string eid = GetPostString("ctid");
  9821. CeErpTradeCell entity = null;
  9822. entity = CeErpTradeCell.GetByCtid(eid);
  9823. if (entity != null)
  9824. {
  9825. StringBuilder sql = new StringBuilder();
  9826. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9827. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9828. var res = new
  9829. {
  9830. data = dt.Rows.Count
  9831. };
  9832. string ro_jsond = JsonConvert.SerializeObject(res);
  9833. returnSuccess(ro_jsond);
  9834. return;
  9835. }
  9836. returnErrorMsg("未找到订单");
  9837. return;
  9838. }
  9839. returnErrorMsg("缺少必要的参数");
  9840. }
  9841. public void get_erp_islasthavesameorder()
  9842. {
  9843. if (UrlPostParmsCheck("ctid"))
  9844. {
  9845. string eid = GetPostString("ctid");
  9846. string[] ctidList = eid.Split(',');
  9847. StringBuilder sql = new StringBuilder();
  9848. string tisCtid = "";
  9849. foreach (string ctid in ctidList)
  9850. {
  9851. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9852. if (entity != null)
  9853. {
  9854. sql = new StringBuilder();
  9855. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9856. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9857. if (dth.Rows.Count > 0)
  9858. {
  9859. tisCtid += entity.ctid;
  9860. tisCtid += ",";
  9861. }
  9862. }
  9863. }
  9864. if (tisCtid.Length > 0)
  9865. {
  9866. var res = new
  9867. {
  9868. data = tisCtid
  9869. };
  9870. string ro_jsond = JsonConvert.SerializeObject(res);
  9871. returnSuccess(ro_jsond);
  9872. }
  9873. else
  9874. {
  9875. var res = new
  9876. {
  9877. data = ""
  9878. };
  9879. string ro_jsond = JsonConvert.SerializeObject(res);
  9880. returnSuccess(ro_jsond);
  9881. }
  9882. return;
  9883. }
  9884. returnErrorMsg("缺少必要的参数");
  9885. }
  9886. public void file_client_down_url()
  9887. {
  9888. if (!UrlPostParmsCheck("userId"))
  9889. {
  9890. returnErrorMsg("缺少必要的参数");
  9891. }
  9892. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9893. }
  9894. public void checkout_form_data()
  9895. {
  9896. if (!UrlPostParmsCheck("tid"))
  9897. {
  9898. returnErrorMsg("缺少必要的参数");
  9899. }
  9900. string tid = GetPostString("tid");
  9901. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9902. if (ceErpOrderFormData != null)
  9903. {
  9904. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9905. returnSuccess(ro_jsond);
  9906. return;
  9907. }
  9908. returnErrorMsg("尚未有文件!");
  9909. }
  9910. public void back_supplier_audit()
  9911. {
  9912. int userId = CurrentUser.UserID;
  9913. StringBuilder sql = new StringBuilder();
  9914. 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);
  9915. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9916. if (dt.Rows.Count > 0)
  9917. {
  9918. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9919. }
  9920. else
  9921. {
  9922. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9923. }
  9924. }
  9925. public void back_supplier_query()
  9926. {
  9927. string eid = GetPostString("ctid");
  9928. if (eid != "")
  9929. {
  9930. StringBuilder sql = new StringBuilder();
  9931. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9932. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9933. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9934. }
  9935. else
  9936. {
  9937. returnErrorMsg("找不到订单记录");
  9938. return;
  9939. }
  9940. }
  9941. public void verified_to_order()
  9942. {
  9943. int userId = CurrentUser.UserID;
  9944. StringBuilder sql = new StringBuilder();
  9945. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9946. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9947. if (dt.Rows.Count > 0)
  9948. {
  9949. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9950. }
  9951. else
  9952. {
  9953. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9954. }
  9955. }
  9956. public void upd_supplier_audit()
  9957. {
  9958. if (UrlPostParmsCheck("ctid"))
  9959. {
  9960. string eid = GetPostString("ctid");
  9961. string reason = GetPostString("returnreason");
  9962. CeErpTradeCell entity = null;
  9963. CeWithdraw withdraw = null;
  9964. withdraw = CeWithdraw.GetByTid(eid);
  9965. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9966. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9967. {
  9968. if (withdraw != null)
  9969. {
  9970. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9971. {
  9972. returnSuccessMsg("您没有权限操作!");
  9973. return;
  9974. }
  9975. else
  9976. {
  9977. if (reason.Equals("1"))
  9978. {
  9979. if (entity.OrderState == -1)
  9980. {
  9981. if (entity.FinishPlaceTime == null)
  9982. {
  9983. entity.OrderState = 2;
  9984. }
  9985. else
  9986. {
  9987. entity.OrderState = 6;
  9988. }
  9989. }
  9990. entity.Update();
  9991. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9992. if (withdraw != null)
  9993. {
  9994. withdraw.status = int.Parse(reason);
  9995. withdraw.Update();
  9996. }
  9997. returnSuccessMsg("操作成功!");
  9998. return;
  9999. }
  10000. else
  10001. {
  10002. withdraw.status = int.Parse(reason);
  10003. withdraw.acknowledgingtime = DateTime.Now;
  10004. withdraw.Update();
  10005. returnSuccessMsg("查看详细请点击线下订单查询");
  10006. return;
  10007. }
  10008. }
  10009. }
  10010. // 第一个字符是 'N'
  10011. }
  10012. if (eid[0] != 'N')
  10013. {
  10014. }
  10015. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10016. {
  10017. entity.IsVerifyToSupplier = false;
  10018. entity.IsReturn = 1;
  10019. entity.ReturnTime = DateTime.Now;
  10020. entity.ReturnReason = reason;
  10021. if (entity.OrderState == 6)
  10022. {
  10023. entity.OrderState = 5;
  10024. }
  10025. entity.Update();
  10026. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10027. if (withdraw != null)
  10028. {
  10029. withdraw.status = int.Parse(reason);
  10030. withdraw.Update();
  10031. }
  10032. returnSuccessMsg("操作成功!");
  10033. return;
  10034. }
  10035. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10036. {
  10037. ;
  10038. if (withdraw != null)
  10039. {
  10040. withdraw.status = int.Parse(reason);
  10041. withdraw.acknowledgingtime = DateTime.Now;
  10042. withdraw.Update();
  10043. returnSuccessMsg("供应商取消撤回!");
  10044. return;
  10045. }
  10046. }
  10047. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10048. {
  10049. if (entity.OrderState == -1)
  10050. {
  10051. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10052. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10053. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10054. {
  10055. returnErrorMsg("台湾客户需填写身份证!");
  10056. return;
  10057. }
  10058. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10059. {
  10060. returnErrorMsg("偏远地区需要填写物流费!");
  10061. return;
  10062. }
  10063. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10064. {
  10065. returnErrorMsg("订单spu没有确认无法通过审核!");
  10066. return;
  10067. }
  10068. if (entity.FinishPlaceTime == null)
  10069. {
  10070. entity.OrderState = 2;
  10071. }
  10072. else
  10073. {
  10074. entity.OrderState = 3;
  10075. }
  10076. commonHelper.getCytPrice(entity);
  10077. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10078. {
  10079. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10080. }
  10081. }
  10082. entity.Update();
  10083. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10084. if (withdraw != null)
  10085. {
  10086. withdraw.status = int.Parse(reason);
  10087. withdraw.Update();
  10088. }
  10089. returnSuccessMsg("操作成功!");
  10090. return;
  10091. }
  10092. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10093. {
  10094. if (withdraw == null)
  10095. {
  10096. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10097. return;
  10098. }
  10099. }
  10100. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10101. {
  10102. if (withdraw != null)
  10103. {
  10104. withdraw.status = int.Parse(reason);
  10105. withdraw.acknowledgingtime = DateTime.Now;
  10106. withdraw.Update();
  10107. returnSuccessMsg("查看详细请点击线下订单查询");
  10108. return;
  10109. }
  10110. }
  10111. return;
  10112. }
  10113. }
  10114. //校验报价
  10115. public void refund_order_tip()
  10116. {
  10117. int userid = CurrentUser.UserID;
  10118. int sectionId = CurrentUser.UserPost.OrgID;
  10119. StringBuilder sql = new StringBuilder();
  10120. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10121. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10122. List<string> ids = new List<string>();
  10123. if (dth.Rows.Count > 0)
  10124. {
  10125. foreach (DataRow dr in dth.Rows)
  10126. {
  10127. ids.Add(dr["ID"].ToString());
  10128. }
  10129. try
  10130. {
  10131. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10132. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10133. }
  10134. catch (Exception ex)
  10135. {
  10136. }
  10137. }
  10138. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10139. }
  10140. public void refund_order_Design()
  10141. {
  10142. int userid = CurrentUser.UserID;
  10143. int sectionId = CurrentUser.UserPost.OrgID;
  10144. StringBuilder sql = new StringBuilder();
  10145. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10146. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10147. List<string> ids = new List<string>();
  10148. if (dth.Rows.Count > 0)
  10149. {
  10150. foreach (DataRow dr in dth.Rows)
  10151. {
  10152. ids.Add(dr["ID"].ToString());
  10153. }
  10154. try
  10155. {
  10156. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10157. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10158. }
  10159. catch (Exception ex)
  10160. {
  10161. }
  10162. }
  10163. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10164. }
  10165. public void change_order_info()
  10166. {
  10167. int userid = CurrentUser.UserID;
  10168. StringBuilder sql = new StringBuilder();
  10169. 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);
  10170. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10171. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10172. }
  10173. public void change_win_mome()
  10174. {
  10175. if (UrlPostParmsCheck("id,ctid"))
  10176. {
  10177. string id = GetPostString("id");
  10178. string ctid = GetPostString("ctid");
  10179. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10180. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10181. if (ce == null || ceErpMessageTip == null)
  10182. {
  10183. returnSuccessMsg("未找到对应的订单!");
  10184. return;
  10185. }
  10186. if (ce.OrderState >= 5)
  10187. {
  10188. ceErpMessageTip.isVisit = true;
  10189. ceErpMessageTip.Update();
  10190. returnSuccessMsg("已上传文件无法修改!");
  10191. return;
  10192. }
  10193. int type = GetPostInt("type");
  10194. string content = GetPostString("content");
  10195. if (type == 0)
  10196. {
  10197. content = content.Replace("(", "(");
  10198. content = content.Replace(")", ")");
  10199. string check = MidStrEx(content, "(", ")").Trim();
  10200. if (string.IsNullOrEmpty(check))
  10201. {
  10202. returnSuccessMsg("文件名格式不正确");
  10203. return;
  10204. }
  10205. }
  10206. ce.seller_memo = content;
  10207. ce.Update();
  10208. ceErpMessageTip.isVisit = true;
  10209. ceErpMessageTip.Update();
  10210. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10211. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10212. ApiVo apiVo = new ApiVo();
  10213. apiVo.orderNumber = ce.ctid;
  10214. apiVo.actionName = "demandDesign";
  10215. apiVo.orderRemarks = content;
  10216. apiVo.demandExamine = type + 1;
  10217. designHelper.API_WorkCore(apiVo);//demandDesign
  10218. returnSuccessMsg("修改成功!");
  10219. }
  10220. }
  10221. public static string MidStrEx(string sourse, string startstr, string endstr)
  10222. {
  10223. string result = string.Empty;
  10224. int startindex, endindex;
  10225. try
  10226. {
  10227. startindex = sourse.IndexOf(startstr);
  10228. if (startindex == -1)
  10229. return result;
  10230. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10231. endindex = tmpstr.IndexOf(endstr);
  10232. if (endindex == -1)
  10233. return result;
  10234. result = tmpstr.Remove(endindex);
  10235. }
  10236. catch (Exception ex)
  10237. {
  10238. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10239. }
  10240. return result;
  10241. }
  10242. public void refund_order_list()
  10243. {
  10244. int userid = CurrentUser.UserID;
  10245. int sectionId = CurrentUser.UserPost.OrgID;
  10246. StringBuilder sql = new StringBuilder();
  10247. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10248. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10249. DataStruct dStruct = GetPostStruct();
  10250. DataTable dt = null;
  10251. List<string> ids = new List<string>();
  10252. List<string> tids = new List<string>();
  10253. if (dth.Rows.Count > 0)
  10254. {
  10255. foreach (DataRow dr in dth.Rows)
  10256. {
  10257. tids.Add("'" + dr["tid"].ToString() + "'");
  10258. ids.Add(dr["id"].ToString());
  10259. }
  10260. try
  10261. {
  10262. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10263. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10264. List<string> lw = new List<string>();
  10265. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10266. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10267. dt = WebCache.GetData("view_orderlist", dStruct);
  10268. }
  10269. catch (Exception ex)
  10270. {
  10271. }
  10272. }
  10273. writeGridDataTableJson(dStruct.TotalCount, dt);
  10274. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10275. }
  10276. //新增
  10277. public void order_batch_downloads()
  10278. {
  10279. string ceid = GetPostString("tid");
  10280. String[] tid = ceid.Split(',');
  10281. order_batch_caiyingtong(tid);
  10282. /* (string success, string errors) = UploadFiles(tid);
  10283. returnSuccessMsg(success + errors);*/
  10284. return;
  10285. }
  10286. //报价接口
  10287. public void Get_To_Quote()
  10288. {
  10289. string ceid = GetPostString("ctid");
  10290. if (ceid != null)
  10291. {
  10292. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10293. if (entity != null)
  10294. {
  10295. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10296. {
  10297. return;
  10298. }
  10299. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10300. double price = 0;
  10301. if (cp == null)
  10302. {
  10303. JObject jsonObject12 = new JObject
  10304. {
  10305. { "UserId", "77886" },
  10306. { "Pwd", "lt666888" },
  10307. { "Filename", entity.seller_memo }
  10308. };
  10309. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10310. JObject jsonObjects1 = JObject.Parse(response1);
  10311. string ms1g = (string)jsonObjects1["msg"];
  10312. if (ms1g == "报价成功")
  10313. {
  10314. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10315. string data = (string)jsonObject1["price"];
  10316. 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 + "');";
  10317. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10318. returnSuccessMsg("获取报价成功:" + data);
  10319. price = Convert.ToDouble(data);
  10320. }
  10321. else
  10322. {
  10323. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10324. return;
  10325. }
  10326. }
  10327. String[] beizhu = entity.seller_memo.Split('-');
  10328. String chanp = "";
  10329. if (beizhu.Length > 0)
  10330. {
  10331. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10332. }
  10333. else
  10334. {
  10335. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10336. }
  10337. JObject jsonObject = new JObject
  10338. {
  10339. { "UserId", "77886" },
  10340. { "Pwd", "lt666888" },
  10341. { "Filename", chanp }
  10342. };
  10343. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10344. JObject jsonObjects = JObject.Parse(response);
  10345. string msg = (string)jsonObjects["msg"];
  10346. if (msg == "报价成功")
  10347. {
  10348. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10349. string data = (string)jsonObject1["price"];
  10350. 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 + "');";
  10351. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10352. returnSuccessMsg("获取报价成功:" + data);
  10353. price = Convert.ToDouble(data);
  10354. }
  10355. else
  10356. {
  10357. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10358. return;
  10359. }
  10360. if (price > 0)
  10361. {
  10362. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10363. if (ceErpTradeCellExtend == null)
  10364. {
  10365. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10366. ceErpTradeCellExtend.ctid = entity.ctid;
  10367. ceErpTradeCellExtend.payment_cyt = price;
  10368. ceErpTradeCellExtend.Create();
  10369. }
  10370. else
  10371. {
  10372. ceErpTradeCellExtend.payment_cyt = price;
  10373. ceErpTradeCellExtend.Update();
  10374. }
  10375. }
  10376. return;
  10377. }
  10378. }
  10379. else
  10380. {
  10381. returnErrorMsg("请至少选择一条数据");
  10382. return;
  10383. }
  10384. }
  10385. //新增
  10386. public void order_To_Supplier()
  10387. {
  10388. string ceid = GetPostString("tid");
  10389. String[] tid = ceid.Split(',');
  10390. if (tid.Length > 0)
  10391. {
  10392. try
  10393. {
  10394. for (int i = 0; i < tid.Length; i++)
  10395. {
  10396. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10397. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10398. entity.SupplierId = suid;
  10399. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10400. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10401. entity.Update();
  10402. }
  10403. }
  10404. catch (Exception ex)
  10405. {
  10406. returnErrorMsg("自动匹配供应商失败");
  10407. return;
  10408. }
  10409. }
  10410. else
  10411. {
  10412. returnErrorMsg("请至少选择一条数据");
  10413. return;
  10414. }
  10415. returnSuccessMsg("自动匹配供应商成功");
  10416. return;
  10417. }
  10418. public (string, string) UploadFiles(string[] urls)
  10419. {
  10420. string success = "";
  10421. string errors = "";
  10422. int userid = CurrentUser.UserID;
  10423. foreach (string url in urls)
  10424. {
  10425. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10426. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10427. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10428. {
  10429. JObject jsonObject = new JObject
  10430. {
  10431. { "Userid", "77886" },
  10432. { "pwd", "cyt86435015" },
  10433. { "content", base64FileContent },
  10434. { "ext", Path.GetExtension(fileName) }
  10435. };
  10436. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10437. JObject jsonObjects = JObject.Parse(response);
  10438. string msg = (string)jsonObjects["msg"];
  10439. if (msg.Equals("上传成功"))
  10440. {
  10441. success += url + " 上传成功";
  10442. }
  10443. else
  10444. {
  10445. errors += url + " 上传失败";
  10446. }
  10447. }
  10448. else
  10449. {
  10450. errors += url + " 格式出现问题";
  10451. }
  10452. }
  10453. if (urls.Length == 0)
  10454. {
  10455. return (success, errors);
  10456. }
  10457. return (success, errors);
  10458. }
  10459. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10460. {
  10461. return true; //总是接受
  10462. }
  10463. public static string HttpPost(string url, string param = null)
  10464. {
  10465. HttpWebRequest request;
  10466. //如果是发送HTTPS请求
  10467. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10468. {
  10469. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10470. request = WebRequest.Create(url) as HttpWebRequest;
  10471. request.ProtocolVersion = HttpVersion.Version10;
  10472. }
  10473. else
  10474. {
  10475. request = WebRequest.Create(url) as HttpWebRequest;
  10476. }
  10477. request.Method = "POST";
  10478. request.ContentType = "application/json";
  10479. request.Accept = "*/*";
  10480. request.Timeout = 120000;
  10481. request.AllowAutoRedirect = false;
  10482. StreamWriter requestStream = null;
  10483. WebResponse response = null;
  10484. string responseStr = null;
  10485. try
  10486. {
  10487. requestStream = new StreamWriter(request.GetRequestStream());
  10488. requestStream.Write(param);
  10489. requestStream.Close();
  10490. response = request.GetResponse();
  10491. if (response != null)
  10492. {
  10493. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10494. responseStr = reader.ReadToEnd();
  10495. reader.Close();
  10496. }
  10497. }
  10498. catch (Exception ex)
  10499. {
  10500. return ex.Message;
  10501. }
  10502. finally
  10503. {
  10504. request = null;
  10505. requestStream = null;
  10506. response = null;
  10507. }
  10508. return responseStr;
  10509. }
  10510. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10511. {
  10512. string base64FileContent;
  10513. string fileName;
  10514. using (WebClient webClient = new WebClient())
  10515. {
  10516. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10517. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10518. {
  10519. using (Stream stream = response.GetResponseStream())
  10520. {
  10521. using (MemoryStream memoryStream = new MemoryStream())
  10522. {
  10523. stream.CopyTo(memoryStream);
  10524. byte[] fileBytes = memoryStream.ToArray();
  10525. base64FileContent = Convert.ToBase64String(fileBytes);
  10526. fileName = response.Headers["Content-Disposition"];
  10527. if (!string.IsNullOrEmpty(fileName))
  10528. {
  10529. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10530. if (index >= 0)
  10531. {
  10532. fileName = fileName.Substring(index + 9).Trim('\"');
  10533. }
  10534. }
  10535. else
  10536. {
  10537. fileName = Path.GetFileName(downloadUrl);
  10538. }
  10539. }
  10540. }
  10541. }
  10542. }
  10543. return (fileName, base64FileContent);
  10544. }
  10545. //新增
  10546. public void order_batch_caiyingtong(string[] downloadUrls)
  10547. {
  10548. try
  10549. {
  10550. //遍历文件
  10551. DataStruct dStruct = GetPostStruct();
  10552. DataTable dt = null;
  10553. int userid = CurrentUser.UserID;
  10554. List<string> ids = new List<string>();//失败组
  10555. List<string> tids = new List<string>();
  10556. using (WebClient webClient = new WebClient())
  10557. {
  10558. foreach (var url in downloadUrls)
  10559. {
  10560. try
  10561. {
  10562. tids.Add("'" + url + "'");
  10563. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10564. if (entity != null)
  10565. {
  10566. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10567. if (cp == null)
  10568. {
  10569. JObject jsonObject = new JObject
  10570. {
  10571. { "Userid", "77886" },
  10572. { "pwd", "lt666888" },
  10573. { "Filename",entity.seller_memo }
  10574. };
  10575. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10576. JObject jsonObjects = JObject.Parse(response);
  10577. string msg = (string)jsonObjects["msg"];
  10578. if (msg == "报价成功")
  10579. {
  10580. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10581. DownloadAndConvertToBase64(url1);
  10582. }
  10583. else
  10584. {
  10585. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10586. }
  10587. }
  10588. else
  10589. {
  10590. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10591. JObject jsonObject = new JObject
  10592. {
  10593. { "Userid", "77886" },
  10594. { "pwd", "lt666888" },
  10595. { "Filename",chanp }
  10596. };
  10597. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10598. JObject jsonObjects = JObject.Parse(response);
  10599. string msg = (string)jsonObjects["msg"];
  10600. if (msg == "报价成功")
  10601. {
  10602. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10603. DownloadAndConvertToBase64(url1);
  10604. }
  10605. else
  10606. {
  10607. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10608. }
  10609. }
  10610. }
  10611. // 上传文件到FTP
  10612. }
  10613. catch (Exception ex)
  10614. {
  10615. Console.WriteLine($"An error occurred: {ex.Message}");
  10616. }
  10617. }
  10618. List<string> lw = new List<string>();
  10619. lw.Add(string.Format("( OrderState < 6 )"));
  10620. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10621. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10622. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10623. if (dt.Rows.Count > 0)
  10624. {
  10625. foreach (DataRow dr in dt.Rows)
  10626. {
  10627. ids.Add(dr["ctid"].ToString());
  10628. }
  10629. }
  10630. String ErrorMsgs = "";
  10631. foreach (String id in ids)
  10632. {
  10633. ErrorMsgs += id + ",";
  10634. }
  10635. if (ErrorMsgs.Length > 1)
  10636. {
  10637. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10638. }
  10639. if (ErrorMsgs.Length < 1)
  10640. {
  10641. ErrorMsgs = "上传成功";
  10642. returnSuccessMsg(ErrorMsgs);
  10643. }
  10644. else
  10645. {
  10646. returnErrorMsg("以下订单" + ErrorMsgs);
  10647. }
  10648. }
  10649. // 删除文件夹及其内容
  10650. /* Directory.Delete(localDirectory, true);*/
  10651. }
  10652. catch { }
  10653. }
  10654. public void get_center_data()
  10655. {
  10656. int userId = CurrentUser.UserID;
  10657. string postCode = CurrentUser.UserPost.Post.Code;
  10658. List<string> lw = new List<string>();
  10659. List<string> ww = new List<string>();
  10660. DateTime currentTime = DateTime.Now;
  10661. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10662. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10663. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10664. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10665. string sql = " SELECT ";
  10666. string startTime = "2023-10-01 11:22:31";
  10667. //设计
  10668. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10669. {
  10670. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10671. 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));
  10672. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10673. 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));
  10674. }
  10675. //客服
  10676. else if (postCode == "CustomerService" || postCode == "Director")
  10677. {
  10678. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10679. 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));
  10680. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10681. 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));
  10682. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10683. 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));
  10684. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10685. 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));
  10686. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10687. 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));
  10688. }
  10689. //售后
  10690. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10691. {
  10692. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10693. 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));
  10694. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10695. 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));
  10696. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10697. 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));
  10698. }
  10699. //下单部
  10700. else if (postCode == "Place" || postCode == "PlaceMr")
  10701. {
  10702. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10703. 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));
  10704. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10705. 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));
  10706. }
  10707. //车间
  10708. else if (postCode == "Supplier")
  10709. {
  10710. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10711. 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));
  10712. }
  10713. DataTable dt = new DataTable();
  10714. if (lw.Count > 0)
  10715. {
  10716. sql += string.Join(" , ", lw);
  10717. sql += " FROM ";
  10718. sql += string.Join(" , ", ww);
  10719. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10720. }
  10721. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10722. }
  10723. public void get_center_data_list()
  10724. {
  10725. int userId = CurrentUser.UserID;
  10726. string postCode = CurrentUser.UserPost.Post.Code;
  10727. string shopIds = CurrentUser.User.pemShop;
  10728. DataStruct dStruct = GetPostStruct();
  10729. List<string> lw = new List<string>();
  10730. DateTime currentTime = DateTime.Now;
  10731. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10732. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10733. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10734. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10735. string startTime = "2023-10-01 11:22:31";
  10736. int order_type = GetPostInt("order_type");
  10737. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10738. {
  10739. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10740. if (order_type == 0)
  10741. {
  10742. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10743. }
  10744. else if (order_type == 3)
  10745. {
  10746. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10747. }
  10748. else
  10749. {
  10750. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10751. }
  10752. }
  10753. //客服
  10754. if (postCode == "CustomerService" || postCode == "Director")
  10755. {
  10756. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10757. if (order_type == 0)
  10758. {
  10759. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10760. }
  10761. else if (order_type == 1)
  10762. {
  10763. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10764. }
  10765. else if (order_type == 2)
  10766. {
  10767. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10768. }
  10769. else if (order_type == 3)
  10770. {
  10771. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10772. }
  10773. else if (order_type == 4)
  10774. {
  10775. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10776. }
  10777. else
  10778. {
  10779. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10780. }
  10781. }
  10782. //售后
  10783. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10784. {
  10785. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10786. if (shopIds != "")
  10787. {
  10788. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10789. }
  10790. if (order_type == 2)
  10791. {
  10792. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10793. }
  10794. else if (order_type == 4)
  10795. {
  10796. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10797. }
  10798. else if (order_type == 5)
  10799. {
  10800. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10801. }
  10802. else
  10803. {
  10804. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10805. }
  10806. }
  10807. //下单部
  10808. if (postCode == "Place" || postCode == "PlaceMr")
  10809. {
  10810. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10811. if (shopIds != "")
  10812. {
  10813. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10814. }
  10815. else if (order_type == 1)
  10816. {
  10817. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10818. }
  10819. else if (order_type == 2)
  10820. {
  10821. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10822. }
  10823. else
  10824. {
  10825. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10826. }
  10827. }
  10828. //车间
  10829. if (postCode == "Supplier")
  10830. {
  10831. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10832. if (order_type == 5)
  10833. {
  10834. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10835. }
  10836. else
  10837. {
  10838. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10839. }
  10840. }
  10841. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10842. dStruct.Fileds = "tid,ctid";
  10843. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10844. writeGridDataTableJson(dStruct.TotalCount, dt);
  10845. }
  10846. public void aftersale_audit_master()
  10847. {
  10848. if (UrlPostParmsCheck("ctid"))
  10849. {
  10850. string ctid = GetPostString("ctid");
  10851. if (ctid.Length > 0)
  10852. {
  10853. bool result = aftersale_data_change(ctid);
  10854. if (result)
  10855. {
  10856. returnSuccessMsg("修改成功!");
  10857. return;
  10858. }
  10859. }
  10860. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10861. }
  10862. }
  10863. public void aftersale_batch_audit_master()
  10864. {
  10865. if (UrlPostParmsCheck("ctids"))
  10866. {
  10867. string ctids = GetPostString("ctids");
  10868. if (ctids.Length > 0)
  10869. {
  10870. List<string> list = new List<string>();
  10871. string[] ctid_list = ctids.Split(',');
  10872. foreach (var item in ctid_list)
  10873. {
  10874. bool result = aftersale_data_change(item);
  10875. if (!result)
  10876. {
  10877. list.Add(item);
  10878. }
  10879. }
  10880. if (list.Count > 0)
  10881. {
  10882. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10883. return;
  10884. }
  10885. returnSuccessMsg("修改成功!");
  10886. return;
  10887. }
  10888. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10889. }
  10890. }
  10891. public bool aftersale_data_change(string ctid)
  10892. {
  10893. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10894. if (ceErpTradeCell != null)
  10895. {
  10896. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10897. ceErpTradeCell.AfterSaleSupplierState = 0;
  10898. StringBuilder sql = new StringBuilder();
  10899. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10900. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10901. CeErpTradeResponsible.DelByTid(ctid, 0);
  10902. 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 == "不理赔")
  10903. {
  10904. CeErpTradeResponsible.DelByTid(ctid, 1);
  10905. ceErpTradeCell.AfterSaleSupplierState = 1;
  10906. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10907. ceErpTradeCell.AfterSaleState = 4;
  10908. }
  10909. else
  10910. {
  10911. ceErpTradeCell.AfterSaleState = 3;
  10912. }
  10913. bool needCyt = false;
  10914. if (dt != null)
  10915. {
  10916. if (dt.Rows.Count == 1)
  10917. {
  10918. bool isEnd = false;
  10919. foreach (DataRow dr in dt.Rows)
  10920. {
  10921. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10922. {
  10923. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10924. isEnd = true;
  10925. }
  10926. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10927. {
  10928. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10929. isEnd = true;
  10930. }
  10931. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10932. {
  10933. needCyt = true;
  10934. }
  10935. }
  10936. if (isEnd)
  10937. {
  10938. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10939. ceErpTradeCell.AfterSaleState = 4;
  10940. ceErpTradeCell.AfterSaleSupplierState = 1;
  10941. }
  10942. }
  10943. else
  10944. {
  10945. bool isAll = true;
  10946. foreach (DataRow dr in dt.Rows)
  10947. {
  10948. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10949. {
  10950. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10951. continue;
  10952. }
  10953. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10954. {
  10955. string path = "";
  10956. int OrgID = 0;
  10957. if (!Convert.IsDBNull(dr["OrgPath"]))
  10958. {
  10959. path = dr["OrgPath"].ToString();
  10960. }
  10961. if (!Convert.IsDBNull(dr["OrgID"]))
  10962. {
  10963. OrgID = Convert.ToInt32(dr["OrgID"]);
  10964. }
  10965. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10966. {
  10967. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10968. continue;
  10969. }
  10970. }
  10971. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10972. {
  10973. needCyt = true;
  10974. }
  10975. isAll = false;
  10976. }
  10977. if (isAll)
  10978. {
  10979. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10980. ceErpTradeCell.AfterSaleState = 4;
  10981. ceErpTradeCell.AfterSaleSupplierState = 1;
  10982. }
  10983. }
  10984. }
  10985. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10986. {
  10987. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10988. }
  10989. if (ceErpTradeCell.AfterSaleState == 4)
  10990. {
  10991. ApiVo apiVo = new ApiVo();
  10992. apiVo.orderNumber = ceErpTradeCell.ctid;
  10993. apiVo.actionName = "afterOver";
  10994. designHelper.API_WorkCore(apiVo); //afterOver
  10995. }
  10996. ceErpTradeCell.Update();
  10997. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10998. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10999. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11000. return true;
  11001. }
  11002. return false;
  11003. }
  11004. public void get_erp_wechatorder()
  11005. {
  11006. DataStruct dStruct = GetPostStruct();
  11007. List<string> lw = new List<string>();
  11008. string tid = GetPostString("tid");
  11009. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11010. string shopname = GetPostString("shopname");
  11011. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11012. string buyernick = GetPostString("buyer_nick");
  11013. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11014. string customer = GetPostString("customer");
  11015. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11016. string returndate1 = GetPostString("returndate1");
  11017. string returndate2 = GetPostString("returndate2");
  11018. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11019. if (dw.Length > 0) lw.Add(dw);
  11020. string finishDate1 = GetPostString("finishdate1");
  11021. string finishDate2 = GetPostString("finishdate2");
  11022. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11023. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11024. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11025. dStruct.Order = "created desc";
  11026. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11027. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11028. writeGridDataTableJson(dStruct.TotalCount, dt);
  11029. }
  11030. public void get_erp_wechatlist_sumprice()
  11031. {
  11032. DataStruct dStruct = GetPostStruct();
  11033. List<string> lw = new List<string>();
  11034. string tid = GetPostString("tid");
  11035. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11036. string shopname = GetPostString("shopname");
  11037. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11038. string buyernick = GetPostString("buyer_nick");
  11039. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11040. string customer = GetPostString("customer");
  11041. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11042. string returndate1 = GetPostString("returndate1");
  11043. string returndate2 = GetPostString("returndate2");
  11044. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11045. if (dw.Length > 0) lw.Add(dw);
  11046. string finishDate1 = GetPostString("finishdate1");
  11047. string finishDate2 = GetPostString("finishdate2");
  11048. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11049. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11050. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11051. string mainWhere = string.Join(" and ", lw.ToArray());
  11052. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11053. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11054. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11055. decimal total = 0;
  11056. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11057. {
  11058. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11059. }
  11060. var res = new
  11061. {
  11062. data = total
  11063. };
  11064. string ro_jsond = JsonConvert.SerializeObject(res);
  11065. returnSuccess(ro_jsond);
  11066. return;
  11067. }
  11068. public void get_erp_qr_waitdeliverylist()
  11069. {
  11070. DataStruct dStruct = GetPostStruct();
  11071. List<string> lw = new List<string>();
  11072. string tid = GetPostString("ctid");
  11073. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11074. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11075. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11076. var res_objz = new
  11077. {
  11078. restype = 1,
  11079. data = dt
  11080. };
  11081. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11082. returnSuccess(ro_jsonz);
  11083. }
  11084. public void get_erp_yield_list()
  11085. {
  11086. DataStruct dStruct = GetPostStruct();
  11087. List<string> lw = new List<string>();
  11088. string tid = GetPostString("ctid");
  11089. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11090. string shopname = GetPostString("shopname");
  11091. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11092. string buyernick = GetPostString("buyer_nick");
  11093. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11094. //if (tid.Length == 0 && buyernick.Length == 0)
  11095. //{
  11096. // lw.Add(string.Format("IsRefund<={0}", 1));
  11097. //}
  11098. string customer = GetPostString("customer");
  11099. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11100. string design = GetPostString("design");
  11101. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11102. string orderState = GetPostString("orderState");
  11103. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11104. string address = GetPostString("address");
  11105. 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));
  11106. string sellermemo = GetPostString("seller_memo");
  11107. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11108. string supplier = GetPostString("supplier");
  11109. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11110. string OrderArea = GetPostString("order_area");
  11111. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11112. string placedate1 = GetPostString("placedate1");
  11113. string placedate2 = GetPostString("placedate2");
  11114. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11115. if (fdw.Length > 0) lw.Add(fdw);
  11116. string price1 = GetPostString("price1");
  11117. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11118. string price2 = GetPostString("price2");
  11119. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11120. string unusualCon = GetPostString("unusualcon");
  11121. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11122. string posTag = CurrentUser.UserPost.Post.Code;
  11123. if (posTag == "Supplier")
  11124. {
  11125. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11126. }
  11127. lw.Add(string.Format("OrderState = 6 "));
  11128. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11129. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11130. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11131. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11132. writeGridDataTableJson(dStruct.TotalCount, dt);
  11133. }
  11134. public void change_erp_sup_state()
  11135. {
  11136. if (UrlPostParmsCheck("ctid"))
  11137. {
  11138. string ctid = GetPostString("ctid");
  11139. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11140. if (ceErpTradeCell != null)
  11141. {
  11142. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11143. if (ceErpTradeCellExtend == null)
  11144. {
  11145. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11146. ceErpTradeCellExtend.ctid = ctid;
  11147. ceErpTradeCellExtend.SupState = 1;
  11148. ceErpTradeCellExtend.Create();
  11149. }
  11150. else
  11151. {
  11152. ceErpTradeCellExtend.SupState = 1;
  11153. ceErpTradeCellExtend.Update();
  11154. }
  11155. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11156. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11157. return;
  11158. }
  11159. returnErrorMsg("找不到订单");
  11160. }
  11161. }
  11162. public void supplier_all_downs()
  11163. {
  11164. if (UrlPostParmsCheck("tids"))
  11165. {
  11166. string tids = GetPostString("tids");
  11167. if (tids != null && tids.Length > 0)
  11168. {
  11169. StringBuilder sql = new StringBuilder();
  11170. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11171. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11172. sql = new StringBuilder();
  11173. 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, "下载设计文件");
  11174. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11175. string[] list = tids.Split(',');
  11176. foreach (string ctid in list)
  11177. {
  11178. CeErpSukuraData.createInfo(ctid, 3);
  11179. }
  11180. designHelper.api_approveDesign(tids); //approveDesign
  11181. returnSuccessMsg("下载成功!");
  11182. return;
  11183. }
  11184. returnErrorMsg("下载订单更新失败");
  11185. }
  11186. }
  11187. public void uploaderFileSuccess()
  11188. {
  11189. if (UrlPostParmsCheck("fileName"))
  11190. {
  11191. string fileName = GetPostString("fileName");
  11192. ApiVo apiVo = new ApiVo();
  11193. apiVo.orderNumber = fileName;
  11194. apiVo.actionName = "finishDesign";
  11195. designHelper.API_WorkCore(apiVo);//finishDesign
  11196. returnSuccessMsg("");
  11197. }
  11198. }
  11199. public void get_sample2_order()
  11200. {
  11201. if (UrlPostParmsCheck("ctid"))
  11202. {
  11203. string ctid = GetPostString("ctid");
  11204. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11205. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11206. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11207. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11208. double total = 0.0;
  11209. double order_price = 0.0;
  11210. if (dt_bu.Rows.Count > 0)
  11211. {
  11212. foreach (DataRow dr in dt_bu.Rows)
  11213. {
  11214. total += Convert.ToDouble(dr["payment"]);
  11215. }
  11216. }
  11217. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11218. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11219. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11220. string tid = ctid.Replace("S_", "");
  11221. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11222. double paymant = 0.0;
  11223. if (entity != null)
  11224. {
  11225. paymant = entity.payment;
  11226. }
  11227. string return_reason = "";
  11228. if (dt_after != null && dt_after.Rows.Count > 0)
  11229. {
  11230. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11231. }
  11232. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11233. }
  11234. }
  11235. public void get_erp_design_status()
  11236. {
  11237. string designName = GetPostString("designName");
  11238. DataStruct dStruct = GetPostStruct();
  11239. if (designName.Length > 0)
  11240. {
  11241. 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";
  11242. sql_user += " and Name like '%" + designName + "%'";
  11243. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11244. List<string> ids_list = new List<string>();
  11245. if (user_table.Rows.Count > 0)
  11246. {
  11247. foreach (DataRow item in user_table.Rows)
  11248. {
  11249. ids_list.Add(item["id"].ToString());
  11250. string ids_s = item["TeamIds"].ToString();
  11251. if (ids_s.Length > 0)
  11252. {
  11253. ids_list.AddRange(ids_s.Split(','));
  11254. }
  11255. }
  11256. }
  11257. HashSet<string> set = new HashSet<string>(ids_list);
  11258. ids_list = set.ToList();
  11259. if (ids_list.Count > 0)
  11260. {
  11261. 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));
  11262. dStruct.MainWhere = sql;
  11263. DataTable dt = null;
  11264. dt = WebCache.GetData("view_ErpUser", dStruct);
  11265. writeGridDataTableJson(dStruct.TotalCount, dt);
  11266. }
  11267. }
  11268. }
  11269. public void change_erp_order_price()
  11270. {
  11271. string ctid = GetPostString("ctid");
  11272. double price = GetPostDouble("price");
  11273. if (ctid.Length > 0)
  11274. {
  11275. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11276. if (ceErpTradeCellExtend == null)
  11277. {
  11278. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11279. ceErpTradeCellExtend.ctid = ctid;
  11280. ceErpTradeCellExtend.payment_cyt = price;
  11281. ceErpTradeCellExtend.Create();
  11282. }
  11283. else
  11284. {
  11285. ceErpTradeCellExtend.payment_cyt = price;
  11286. ceErpTradeCellExtend.Update();
  11287. }
  11288. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11289. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11290. {
  11291. ceErpDataSendOrderInfo.isSync = false;
  11292. ceErpDataSendOrderInfo.Update();
  11293. }
  11294. if (ceErpDataSendOrderInfo == null)
  11295. {
  11296. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11297. ceErpDataSendOrderInfo.isSync = false;
  11298. ceErpDataSendOrderInfo.ctid = ctid;
  11299. ceErpDataSendOrderInfo.Create();
  11300. }
  11301. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11302. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11303. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11304. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11305. {
  11306. dataSendOrderBean dataSendOrderBean = null;
  11307. foreach (DataRow item in dth.Rows)
  11308. {
  11309. try
  11310. {
  11311. dataSendOrderBean = new dataSendOrderBean();
  11312. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11313. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11314. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11315. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11316. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11317. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11318. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11319. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11320. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11321. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11322. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11323. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11324. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11325. if (result != null)
  11326. {
  11327. if ("0".Equals(result.errcode))
  11328. {
  11329. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11330. }
  11331. else
  11332. {
  11333. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11334. }
  11335. }
  11336. }
  11337. catch (Exception ex)
  11338. {
  11339. }
  11340. }
  11341. }
  11342. returnSuccessMsg("修改成功!");
  11343. return;
  11344. }
  11345. returnErrorMsg("找不到订单");
  11346. }
  11347. public void find_he_together()
  11348. {
  11349. string ctid = GetPostString("ctid");
  11350. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11351. List<string> list = new List<string>();
  11352. if (ceErpTradeCell != null)
  11353. {
  11354. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11355. {
  11356. 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);
  11357. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11358. if (table != null && table.Rows.Count > 0)
  11359. {
  11360. foreach (TableRow row in table.Rows)
  11361. {
  11362. }
  11363. }
  11364. }
  11365. }
  11366. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11367. }
  11368. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11369. {
  11370. //chy----19
  11371. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11372. //GD-CYT-----64
  11373. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11374. //ZHX----3
  11375. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11376. //JK----97
  11377. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11378. //ZT----70
  11379. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11380. //LHCY-----98
  11381. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11382. //XD-----90
  11383. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11384. //CYCY-----14
  11385. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11386. };
  11387. //其他改名
  11388. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11389. {
  11390. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11391. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11392. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11393. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11394. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11395. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11396. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11397. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11398. };
  11399. //不统计
  11400. List<int> no_suppliers = new List<int>()
  11401. {
  11402. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11403. };
  11404. //配件单
  11405. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11406. {
  11407. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11408. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11409. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11410. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11411. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11412. {"旗杆",new List<string>(){ "班旗" } },
  11413. {"牙签",new List<string>(){ "不干胶" } }
  11414. };
  11415. public void get_place_order_data()
  11416. {
  11417. string date1 = GetPostString("date1");
  11418. string date2 = GetPostString("date2");
  11419. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11420. DateTime start = DateTime.Parse(starttime);
  11421. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11422. DateTime end = DateTime.Parse(endtime);
  11423. if (date1 != null && date1.Length > 0)
  11424. {
  11425. DateTime dateTime = DateTime.Parse(date1);
  11426. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11427. start = DateTime.Parse(starttime);
  11428. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11429. end = DateTime.Parse(endtime);
  11430. }
  11431. if (date2 != null && date2.Length > 0)
  11432. {
  11433. DateTime dateTime = DateTime.Parse(date2);
  11434. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11435. end = DateTime.Parse(endtime);
  11436. }
  11437. 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);
  11438. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11439. //不干胶-----1,卡片-----29
  11440. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11441. foreach (DataRow row in data.Rows)
  11442. {
  11443. int productId = Convert.ToInt32(row["ProductId"]);
  11444. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11445. if (no_suppliers.Contains(supplierId))
  11446. {
  11447. continue;
  11448. }
  11449. string seller_memo = row["seller_memo"].ToString();
  11450. bool ispj = false;//是否配件单
  11451. bool isfirst = true;//第一个配
  11452. maps.Keys.ForEach(key =>
  11453. {
  11454. //备注包含配件
  11455. if (seller_memo.Contains(key) && isfirst)
  11456. {
  11457. List<string> list = maps[key];
  11458. ispj = true;
  11459. isfirst = false;
  11460. for (int i = 0; i < list.Count; i++)
  11461. {
  11462. if (seller_memo.Contains(list[i]))
  11463. {
  11464. ispj = false;
  11465. break;
  11466. }
  11467. }
  11468. }
  11469. });
  11470. if (ispj)
  11471. {
  11472. continue;
  11473. }
  11474. seller_memo = seller_memo.Replace("UV", "uv");
  11475. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11476. //吊牌归到卡片
  11477. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11478. seller_memo = seller_memo.Replace("卡套", "卡片");
  11479. seller_memo = seller_memo.Replace("封套", "卡片");
  11480. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11481. seller_memo = seller_memo.Replace("腰封", "卡片");
  11482. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11483. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11484. seller_memo = seller_memo.Replace("横幅", "条幅");
  11485. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11486. string map_key = "";
  11487. string type = "";
  11488. if (supplierMap.ContainsKey(supplierId))
  11489. {
  11490. foreach (var kvp in supplierMap[supplierId])
  11491. {
  11492. if (seller_memo.Contains(kvp.Key))
  11493. {
  11494. map_key = kvp.Value;
  11495. type = kvp.Value;
  11496. break;
  11497. }
  11498. }
  11499. }
  11500. if (map_key == "")
  11501. {
  11502. type = "其他";
  11503. map_key = "其他";
  11504. }
  11505. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11506. {
  11507. map_key = suppliers[supplierId];
  11508. }
  11509. if (supplierId == 70)
  11510. {
  11511. supplierId = 70;
  11512. }
  11513. map_key += "_" + row["SupplierName"].ToString();
  11514. Dictionary<string, int> map = null;
  11515. if (other_map.ContainsKey(map_key))
  11516. {
  11517. other_map.TryGetValue(map_key, out map);
  11518. }
  11519. else
  11520. {
  11521. map = new Dictionary<string, int>();
  11522. map.Add("dayDev", 0);//当天出货
  11523. map.Add("dayTotal", 0);//下单总数
  11524. map.Add("payTotal", 0);//500以上
  11525. map.Add("today", 0);//当天出货数量
  11526. map.Add("unusua", 0);//异常数
  11527. other_map.Add(map_key, map);
  11528. other_map.TryGetValue(map_key, out map);
  11529. }
  11530. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11531. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11532. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11533. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11534. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11535. {
  11536. map["dayTotal"]++;
  11537. if (supplierId == 97)
  11538. {
  11539. supplierId = 97;
  11540. }
  11541. }
  11542. if (Convert.ToDecimal(row["payment"]) >= 500)
  11543. {
  11544. map["payTotal"]++;
  11545. }
  11546. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11547. {
  11548. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11549. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11550. {
  11551. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11552. {
  11553. map["today"]++;
  11554. }
  11555. }
  11556. else
  11557. {
  11558. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11559. {
  11560. map["today"]++;
  11561. }
  11562. else
  11563. {
  11564. }
  11565. }
  11566. }
  11567. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11568. {
  11569. map["unusua"]++;
  11570. }
  11571. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11572. //GD-CYT-----64
  11573. DateTime two = palceTimeStart.AddHours(14);
  11574. DateTime three = palceTimeStart.AddHours(15);
  11575. DateTime four = palceTimeStart.AddHours(16);
  11576. DateTime six = palceTimeStart.AddHours(18);
  11577. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11578. {
  11579. //下午四点前 500-1000
  11580. string count = row["ProductCount"].ToString();
  11581. if (count != null && count.Length > 0)
  11582. {
  11583. int productCount = commonHelper.getPlaceProductCount(count);
  11584. if (productCount >= 500 && productCount <= 1000)
  11585. {
  11586. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11587. {
  11588. map["dayDev"]++;
  11589. }
  11590. }
  11591. }
  11592. }
  11593. //UV
  11594. else if ("uv".Equals(type))
  11595. {
  11596. //ZT----70
  11597. //ZHX----3
  11598. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11599. {
  11600. map["dayDev"]++;
  11601. }
  11602. //JK----97
  11603. //HZX----105
  11604. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11605. {
  11606. map["dayDev"]++;
  11607. }
  11608. }
  11609. //帆布---52|条幅---27
  11610. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11611. {
  11612. //LHCY-----98
  11613. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11614. {
  11615. map["dayDev"]++;
  11616. }
  11617. }
  11618. //条幅
  11619. else if ("条幅".Equals(type))
  11620. {
  11621. //XD-----90
  11622. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11623. {
  11624. map["dayDev"]++;
  11625. }
  11626. }
  11627. //桌布
  11628. else if ("桌布".Equals(type))
  11629. {
  11630. //XD-----90
  11631. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11632. {
  11633. map["dayDev"]++;
  11634. }
  11635. }
  11636. //DL---10
  11637. //AYTW---119
  11638. //FS-CYT-DY ----80
  11639. //JK----97
  11640. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11641. {
  11642. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11643. {
  11644. map["dayDev"]++;
  11645. }
  11646. }
  11647. // QC---121
  11648. else if (supplierId == 121)
  11649. {
  11650. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11651. {
  11652. map["dayDev"]++;
  11653. }
  11654. }
  11655. }
  11656. DataTable dt = new DataTable();
  11657. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11658. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11659. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11660. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11661. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11662. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11663. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11664. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11665. other_map.Keys.ForEach(key =>
  11666. {
  11667. DataRow dr = dt.NewRow();
  11668. Dictionary<string, int> map = other_map[key];
  11669. string[] key_list = key.Split('_');
  11670. dr[0] = key_list[0];
  11671. dr[1] = key_list[1];
  11672. if (key_list.Length > 2)
  11673. {
  11674. dr[1] += "(" + key_list[2] + ")";
  11675. }
  11676. dr[2] = map["dayTotal"];
  11677. dr[3] = map["payTotal"];
  11678. dr[4] = map["today"];
  11679. dr[5] = map["unusua"];
  11680. dr[6] = map["dayDev"];
  11681. double rate = 0.00;
  11682. if (map["dayDev"] > 0)
  11683. {
  11684. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11685. }
  11686. dr[7] = rate.ToString();
  11687. dt.Rows.Add(dr);
  11688. });
  11689. DataView dv = new DataView(dt);
  11690. dv.Sort = "SupplierName";
  11691. //dv.Sort = "AllOrder desc";
  11692. DataTable dtNew = dv.ToTable();
  11693. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11694. }
  11695. public void check_order_desing_info()
  11696. {
  11697. string ctid = GetPostString("ctid");
  11698. if (!string.IsNullOrEmpty(ctid))
  11699. {
  11700. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11701. if (ceErpTradeCell != null)
  11702. {
  11703. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11704. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11705. return;
  11706. }
  11707. returnErrorMsg("找不到订单");
  11708. return;
  11709. }
  11710. returnErrorMsg("找不到订单");
  11711. }
  11712. public void get_timeout_detail()
  11713. {
  11714. string poscode = CurrentUser.UserPost.Post.Code;
  11715. DataStruct dStruct = GetPostStruct();
  11716. List<string> lw = new List<string>();
  11717. string id = GetPostString("id");
  11718. string pay_date1 = GetPostString("pay_date1");
  11719. string pay_date2 = GetPostString("pay_date2");
  11720. int type = GetPostInt("type");
  11721. if (type == 0)
  11722. {
  11723. if (pay_date1.Length > 0)
  11724. {
  11725. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11726. }
  11727. if (pay_date2.Length > 0)
  11728. {
  11729. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11730. }
  11731. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11732. }
  11733. if (type == 1)
  11734. {
  11735. if (pay_date1.Length > 0)
  11736. {
  11737. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11738. }
  11739. if (pay_date2.Length > 0)
  11740. {
  11741. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11742. }
  11743. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11744. }
  11745. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11746. DataTable dt = null;
  11747. dt = WebCache.GetData("view_orderlist", dStruct);
  11748. writeGridDataTableJson(dStruct.TotalCount, dt);
  11749. }
  11750. public void saveUrgentChargePrice()
  11751. {
  11752. string ctid = GetPostString("ctid");
  11753. if (!string.IsNullOrEmpty(ctid))
  11754. {
  11755. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11756. if (ceErpTradeCell != null)
  11757. {
  11758. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11759. if (prices <= 100)
  11760. {
  11761. returnErrorMsg("此订单金额不足100元,无法加急。");
  11762. return;
  11763. }
  11764. double price = GetPostDouble("price");
  11765. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11766. if (ceErpTradeCellExtend == null)
  11767. {
  11768. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11769. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11770. }
  11771. ceErpTradeCellExtend.urgentCharge = price;
  11772. if (ceErpTradeCellExtend.ID > 0)
  11773. {
  11774. ceErpTradeCellExtend.Update();
  11775. }
  11776. else
  11777. {
  11778. ceErpTradeCellExtend.Save();
  11779. }
  11780. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11781. returnSuccessMsg("修改成功!");
  11782. return;
  11783. }
  11784. returnErrorMsg("找不到订单");
  11785. return;
  11786. }
  11787. returnErrorMsg("找不到订单");
  11788. }
  11789. public void finish_erp_order()
  11790. {
  11791. string ctid = GetPostString("ctid");
  11792. if (!string.IsNullOrEmpty(ctid))
  11793. {
  11794. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11795. {
  11796. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11797. if (ceErpTradeCell != null)
  11798. {
  11799. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11800. ceErpTradeCell.Update();
  11801. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11802. returnSuccessMsg("修改成功!");
  11803. return;
  11804. }
  11805. }
  11806. }
  11807. returnErrorMsg("找不到订单");
  11808. }
  11809. public void get_trade_order_list()
  11810. {
  11811. string tid = GetPostString("tid");
  11812. if (!string.IsNullOrEmpty(tid))
  11813. {
  11814. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11815. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11816. writeGridDataTableJson(data.Rows.Count, data);
  11817. return;
  11818. }
  11819. returnErrorMsg("找不到订单");
  11820. }
  11821. public void save_cell_spu()
  11822. {
  11823. string ctid = GetPostString("ctid");
  11824. string spu_id = GetPostString("spu_id");
  11825. if (!string.IsNullOrEmpty(ctid))
  11826. {
  11827. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11828. if (ceErpTradeCellExtend == null)
  11829. {
  11830. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11831. ceErpTradeCellExtend.ctid = ctid;
  11832. }
  11833. ceErpTradeCellExtend.spu_id = spu_id;
  11834. if (!string.IsNullOrEmpty(spu_id))
  11835. {
  11836. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11837. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11838. }
  11839. if (ceErpTradeCellExtend.ID == 0)
  11840. {
  11841. ceErpTradeCellExtend.Create();
  11842. }
  11843. else
  11844. {
  11845. ceErpTradeCellExtend.Update();
  11846. }
  11847. returnSuccessMsg("修改成功!");
  11848. return;
  11849. }
  11850. returnErrorMsg("找不到订单");
  11851. }
  11852. public void change_express_info()
  11853. {
  11854. string ctid = GetPostString("ctid");
  11855. string transNo = GetPostString("transNo");
  11856. string transCom = GetPostString("transCom");
  11857. if (!string.IsNullOrEmpty(ctid))
  11858. {
  11859. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11860. if (ceErpTradeCellExtend == null)
  11861. {
  11862. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11863. ceErpTradeCellExtend.ctid = ctid;
  11864. }
  11865. ceErpTradeCellExtend.modExpressNo = transNo;
  11866. ceErpTradeCellExtend.modExpressCom = transCom;
  11867. ceErpTradeCellExtend.readMod = 2;
  11868. if (ceErpTradeCellExtend.ID == 0)
  11869. {
  11870. ceErpTradeCellExtend.Create();
  11871. }
  11872. else
  11873. {
  11874. ceErpTradeCellExtend.Update();
  11875. }
  11876. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11877. returnSuccessMsg("修改成功!");
  11878. return;
  11879. }
  11880. returnErrorMsg("找不到订单");
  11881. }
  11882. public void get_change_express_list()
  11883. {
  11884. DataStruct dStruct = GetPostStruct();
  11885. List<string> lw = new List<string>();
  11886. int st = 2;
  11887. string tid = GetPostString("ctid");
  11888. if (tid.Length > 0)
  11889. {
  11890. string select_tid = getTidByCtid(tid);
  11891. lw.Add(string.Format("tid='{0}'", select_tid));
  11892. }
  11893. string shopname = GetPostString("shopname");
  11894. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11895. string buyernick = GetPostString("buyer_nick");
  11896. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11897. string sellermemo = GetPostString("seller_memo");
  11898. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11899. string supplier = GetPostString("supplier");
  11900. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11901. string customer = GetPostString("customer");
  11902. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11903. string design = GetPostString("design");
  11904. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11905. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11906. string poscode = CurrentUser.UserPost.Post.Code;
  11907. if (poscode != "SysAdmin")
  11908. {
  11909. string shopid = CurrentUser.User.pemShop;
  11910. lw.Add(string.Format("shopId in ({0})", shopid));
  11911. }
  11912. lw.Add("readMod = 2");
  11913. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11914. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11915. writeGridDataTableJson(dStruct.TotalCount, dt);
  11916. }
  11917. public void deal_express_complete()
  11918. {
  11919. string ctid = GetPostString("ctid");
  11920. if (!string.IsNullOrEmpty(ctid))
  11921. {
  11922. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11923. if (ceErpTradeCellExtend == null)
  11924. {
  11925. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11926. ceErpTradeCellExtend.ctid = ctid;
  11927. }
  11928. ceErpTradeCellExtend.readMod = 1;
  11929. if (ceErpTradeCellExtend.ID == 0)
  11930. {
  11931. ceErpTradeCellExtend.Create();
  11932. }
  11933. else
  11934. {
  11935. ceErpTradeCellExtend.Update();
  11936. }
  11937. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11938. returnSuccessMsg("修改成功!");
  11939. return;
  11940. }
  11941. returnErrorMsg("找不到订单");
  11942. }
  11943. public void aftersale_return_visit()
  11944. {
  11945. string ctid = GetPostString("ctid");
  11946. if (!string.IsNullOrEmpty(ctid))
  11947. {
  11948. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11949. if (ceErpTradeCellExtend == null)
  11950. {
  11951. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11952. ceErpTradeCellExtend.ctid = ctid;
  11953. }
  11954. ceErpTradeCellExtend.returnVisit = 1;
  11955. if (ceErpTradeCellExtend.ID == 0)
  11956. {
  11957. ceErpTradeCellExtend.Create();
  11958. }
  11959. else
  11960. {
  11961. ceErpTradeCellExtend.Update();
  11962. }
  11963. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11964. if (ceErpTradeAfterSaleExtend != null)
  11965. {
  11966. ceErpTradeAfterSaleExtend.TextResult = "";
  11967. ceErpTradeAfterSaleExtend.Update();
  11968. }
  11969. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11970. returnSuccessMsg("修改成功!");
  11971. return;
  11972. }
  11973. returnErrorMsg("找不到订单");
  11974. }
  11975. public void orderPlaceInfo()
  11976. {
  11977. string ctids = GetPostString("ctids");
  11978. string[] list = ctids.Split(',');
  11979. foreach (string ctid in list)
  11980. {
  11981. CeErpSukuraData.createInfo(ctid, 3);
  11982. }
  11983. StringBuilder sql = new StringBuilder();
  11984. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11985. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11986. designHelper.api_approveDesign(ctids); //approveDesign
  11987. returnSuccessMsg("");
  11988. }
  11989. public void get_issue_list()
  11990. {
  11991. DataStruct dStruct = GetPostStruct();
  11992. List<string> lw = new List<string>();
  11993. int st = 2;
  11994. string tid = GetPostString("ctid");
  11995. if (tid.Length > 0)
  11996. {
  11997. string select_tid = getTidByCtid(tid);
  11998. lw.Add(string.Format("tid='{0}'", select_tid));
  11999. }
  12000. string shopname = GetPostString("shopname");
  12001. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12002. string buyernick = GetPostString("buyer_nick");
  12003. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12004. string sellermemo = GetPostString("seller_memo");
  12005. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12006. string supplier = GetPostString("supplier");
  12007. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12008. string customer = GetPostString("customer");
  12009. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12010. string design = GetPostString("design");
  12011. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12012. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12013. string poscode = CurrentUser.UserPost.Post.Code;
  12014. if (poscode != "SysAdmin")
  12015. {
  12016. string shopid = CurrentUser.User.pemShop;
  12017. lw.Add(string.Format("shopId in ({0})", shopid));
  12018. }
  12019. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12020. {
  12021. lw.Add("IssueState = 1");
  12022. }
  12023. else
  12024. {
  12025. string iisstate = GetPostString("iisstate");
  12026. if ("1".Equals(iisstate))
  12027. {
  12028. lw.Add("IssueState =1");
  12029. }
  12030. else if ("2".Equals(iisstate))
  12031. {
  12032. lw.Add("IssueState = 2");
  12033. }
  12034. else
  12035. {
  12036. lw.Add("IssueState > 0");
  12037. }
  12038. }
  12039. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12040. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12041. writeGridDataTableJson(dStruct.TotalCount, dt);
  12042. }
  12043. public void saveIssueContent()
  12044. {
  12045. string ctid = GetPostString("ctid");
  12046. if (!string.IsNullOrEmpty(ctid))
  12047. {
  12048. string content = GetPostString("content");
  12049. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12050. if (ceErpTradeAfterSaleExtend == null)
  12051. {
  12052. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12053. ceErpTradeAfterSaleExtend.tid = ctid;
  12054. }
  12055. ceErpTradeAfterSaleExtend.IssueContent = content;
  12056. ceErpTradeAfterSaleExtend.IssueState = 1;
  12057. if (ceErpTradeAfterSaleExtend.ID > 0)
  12058. {
  12059. ceErpTradeAfterSaleExtend.Update();
  12060. }
  12061. else
  12062. {
  12063. ceErpTradeAfterSaleExtend.Create();
  12064. }
  12065. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12066. returnSuccessMsg("添加成功!");
  12067. return;
  12068. }
  12069. returnErrorMsg("找不到订单");
  12070. }
  12071. public void dealIssueContent()
  12072. {
  12073. string ctid = GetPostString("ctid");
  12074. if (!string.IsNullOrEmpty(ctid))
  12075. {
  12076. string content = GetPostString("content");
  12077. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12078. if (ceErpTradeAfterSaleExtend != null)
  12079. {
  12080. ceErpTradeAfterSaleExtend.IssueState = 2;
  12081. ceErpTradeAfterSaleExtend.Update();
  12082. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12083. returnSuccessMsg("修改完成!");
  12084. return;
  12085. }
  12086. }
  12087. returnErrorMsg("找不到订单");
  12088. }
  12089. public void set_tid_attachments()
  12090. {
  12091. string tid = GetPostString("tid");
  12092. string atta = GetPostString("atta");
  12093. if (!string.IsNullOrEmpty(tid))
  12094. {
  12095. if (string.IsNullOrEmpty(atta))
  12096. {
  12097. returnErrorMsg("文件地址为空");
  12098. return;
  12099. }
  12100. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12101. if (ceErpTradeCell != null)
  12102. {
  12103. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12104. if (ceErpTrade == null)
  12105. {
  12106. returnErrorMsg("找不到订单");
  12107. return;
  12108. }
  12109. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12110. bool isSend = false;
  12111. if (dt != null && dt.Rows.Count > 0)
  12112. {
  12113. foreach (DataRow row in dt.Rows)
  12114. {
  12115. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12116. {
  12117. isSend = true;
  12118. }
  12119. }
  12120. if (isSend)
  12121. {
  12122. returnErrorMsg("已发货无法修改");
  12123. return;
  12124. }
  12125. ceErpTrade.Attachments = atta;
  12126. ceErpTrade.Update();
  12127. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12128. returnSuccessMsg("上传成功!");
  12129. return;
  12130. }
  12131. }
  12132. }
  12133. returnErrorMsg("找不到订单");
  12134. }
  12135. public void get_tid_attachments()
  12136. {
  12137. string tid = GetPostString("tid");
  12138. if (!string.IsNullOrEmpty(tid))
  12139. {
  12140. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12141. if (ceErpTradeCell != null)
  12142. {
  12143. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12144. if (ceErpTrade == null)
  12145. {
  12146. returnErrorMsg("找不到订单");
  12147. return;
  12148. }
  12149. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12150. return;
  12151. }
  12152. }
  12153. returnErrorMsg("找不到订单");
  12154. }
  12155. public void check_erp_sameorders()
  12156. {
  12157. if (UrlPostParmsCheck("ctid"))
  12158. {
  12159. string eid = GetPostString("ctid");
  12160. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12161. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12162. if (entity != null && ceErpTrade != null)
  12163. {
  12164. if (entity.OrderState > 6)
  12165. {
  12166. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12167. return;
  12168. }
  12169. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12170. List<string> ids = new List<string>();
  12171. if (dt != null && dt.Rows.Count > 1)
  12172. {
  12173. bool needhe = true;
  12174. foreach (DataRow dr in dt.Rows)
  12175. {
  12176. ids.Add("'" + dr["ctid"] + "'");
  12177. /* //备注有合包
  12178. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12179. {
  12180. needhe = true;
  12181. }
  12182. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12183. {
  12184. needhe = true;
  12185. }
  12186. //顺丰快递
  12187. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12188. {
  12189. needhe = true;
  12190. }*/
  12191. }
  12192. if (!needhe)
  12193. {
  12194. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12195. return;
  12196. }
  12197. StringBuilder sql = new StringBuilder();
  12198. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12199. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12200. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12201. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12202. foreach (DataRow dr in dt.Rows)
  12203. {
  12204. dr["dstate"] = 0;
  12205. dr["dnumber"] = 0;
  12206. foreach (DataRow row in dt1.Rows)
  12207. {
  12208. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12209. {
  12210. dr["dstate"] = 2;
  12211. dr["default"] = 1;
  12212. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12213. }
  12214. }
  12215. if (eid.Equals(dr["ctid"].ToString()))
  12216. {
  12217. dr["dstate"] = 1;
  12218. dr["default"] = 1;
  12219. }
  12220. }
  12221. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12222. return;
  12223. }
  12224. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12225. return;
  12226. }
  12227. returnErrorMsg("未找到订单");
  12228. return;
  12229. }
  12230. returnErrorMsg("缺少必要的参数");
  12231. }
  12232. public void get_mark_number()
  12233. {
  12234. string eid = GetPostString("ctid");
  12235. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12236. if (entity != null)
  12237. {
  12238. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12239. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12240. int current = 1;
  12241. if (ceErpDeliverMark == null)
  12242. {
  12243. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12244. List<string> ids = new List<string>();
  12245. if (dt != null && dt.Rows.Count > 1)
  12246. {
  12247. foreach (DataRow dr in dt.Rows)
  12248. {
  12249. ids.Add("'" + dr["ctid"] + "'");
  12250. }
  12251. //查询已有的编号
  12252. StringBuilder sql = new StringBuilder();
  12253. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12254. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12255. if (dt1 == null || dt1.Rows.Count == 0)
  12256. {
  12257. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12258. List<int> list_number = new List<int>();
  12259. foreach (DataRow row in numbers.Rows)
  12260. {
  12261. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12262. }
  12263. //查询空余编号
  12264. for (int i = 0; i < list_number.Count + 2; i++)
  12265. {
  12266. if (!list_number.Contains(current))
  12267. {
  12268. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12269. //防止查询过程中有新数据生成
  12270. if (ceErpDeliverMark1 == null)
  12271. {
  12272. break;
  12273. }
  12274. }
  12275. current++;
  12276. }
  12277. }
  12278. else
  12279. {
  12280. foreach (DataRow row in dt1.Rows)
  12281. {
  12282. current = Convert.ToInt32(row["markNumber"]);
  12283. }
  12284. }
  12285. ceErpDeliverMark = new CeErpDeliverMark();
  12286. ceErpDeliverMark.ctid = eid;
  12287. ceErpDeliverMark.createtime = DateTime.Now;
  12288. if (ceErpTrade != null)
  12289. {
  12290. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12291. }
  12292. ceErpDeliverMark.markNumber = current;
  12293. ceErpDeliverMark.Create();
  12294. }
  12295. }
  12296. else
  12297. {
  12298. current = ceErpDeliverMark.markNumber;
  12299. }
  12300. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12301. return;
  12302. }
  12303. }
  12304. public void aftersaleCytSend()
  12305. {
  12306. string ctid = GetPostString("ctid");
  12307. if (!string.IsNullOrEmpty(ctid))
  12308. {
  12309. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12310. if (ceErpTradeCell != null)
  12311. {
  12312. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12313. }
  12314. returnSuccessMsg("推送成功");
  12315. return;
  12316. }
  12317. returnErrorMsg("缺少必要的参数");
  12318. }
  12319. public void packOrderInfo()
  12320. {
  12321. string ctids = GetPostString("ctids");
  12322. if (!string.IsNullOrEmpty(ctids))
  12323. {
  12324. string[] ctid_list = ctids.Split(',');
  12325. if (ctid_list.Length > 20)
  12326. {
  12327. returnErrorMsg("单次下载次数不能超过20个");
  12328. return;
  12329. }
  12330. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12331. StringBuilder sql = new StringBuilder();
  12332. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12333. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12334. int supplierId = 0;
  12335. StringBuilder insterSql = new StringBuilder();
  12336. for (int i = 0; i < dt.Rows.Count; i++)
  12337. {
  12338. DataRow row = dt.Rows[i];
  12339. if (i == 0)
  12340. {
  12341. supplierId = Convert.ToInt32(row["SupplierId"]);
  12342. }
  12343. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12344. {
  12345. returnErrorMsg("同车间的订单才能一起打包");
  12346. return;
  12347. }
  12348. int orderState = Convert.ToInt32(row["OrderState"]);
  12349. if (orderState != 5)
  12350. {
  12351. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12352. return;
  12353. }
  12354. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12355. }
  12356. CeErpPackData ceErpPackData = new CeErpPackData();
  12357. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12358. ceErpPackData.supplierId = supplierId;
  12359. ceErpPackData.createtime = DateTime.Now;
  12360. ceErpPackData.createBy = CurrentUser.UserID;
  12361. ceErpPackData.createName = CurrentUser.UserName;
  12362. ceErpPackData.Create();
  12363. if (ceErpPackData.ID > 0)
  12364. {
  12365. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12366. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12367. }
  12368. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12369. returnSuccessMsg("打包成功");
  12370. return;
  12371. }
  12372. returnErrorMsg("缺少必要的参数");
  12373. }
  12374. public void rePackOrderInfo()
  12375. {
  12376. string id = GetPostString("id");
  12377. if (!string.IsNullOrEmpty(id))
  12378. {
  12379. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12380. if (ceErpPackData == null)
  12381. {
  12382. returnSuccessMsg("查无数据");
  12383. return;
  12384. }
  12385. ceErpPackData.upStatus = 0;
  12386. ceErpPackData.message = "";
  12387. ceErpPackData.Update();
  12388. returnSuccessMsg("打包成功");
  12389. return;
  12390. }
  12391. returnErrorMsg("缺少必要的参数");
  12392. }
  12393. public void backPackOrderInfo()
  12394. {
  12395. string id = GetPostString("id");
  12396. if (!string.IsNullOrEmpty(id))
  12397. {
  12398. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12399. if (ceErpPackData == null)
  12400. {
  12401. returnSuccessMsg("查无数据");
  12402. return;
  12403. }
  12404. ceErpPackData.upStatus = 4;
  12405. ceErpPackData.Update();
  12406. List<string> list = new List<string>();
  12407. StringBuilder sql = new StringBuilder();
  12408. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12409. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12410. for (int i = 0; i < dt.Rows.Count; i++)
  12411. {
  12412. DataRow row = dt.Rows[i];
  12413. list.Add("'" + row["ctid"].ToString() + "'");
  12414. }
  12415. string textCtids = string.Join(",", list);
  12416. 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));
  12417. 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, "无法打包退回"));
  12418. returnSuccessMsg("退回成功");
  12419. return;
  12420. }
  12421. returnErrorMsg("缺少必要的参数");
  12422. }
  12423. public void addPackDownNum()
  12424. {
  12425. string id = GetPostString("id");
  12426. if (!string.IsNullOrEmpty(id))
  12427. {
  12428. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12429. returnSuccessMsg("下载成功");
  12430. return;
  12431. }
  12432. returnErrorMsg("缺少必要的参数");
  12433. }
  12434. public void get_pack_list()
  12435. {
  12436. DataStruct dStruct = GetPostStruct();
  12437. List<string> lw = new List<string>();
  12438. string supplier = GetPostString("supplier");
  12439. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12440. string posTag = CurrentUser.UserPost.Post.Code;
  12441. if (posTag == "Supplier")
  12442. {
  12443. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12444. }
  12445. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12446. dStruct.Order = "createtime desc";
  12447. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12448. writeGridDataTableJson(dStruct.TotalCount, dt);
  12449. }
  12450. public void get_pack_order_list()
  12451. {
  12452. string packId = GetPostString("packId");
  12453. if (string.IsNullOrEmpty(packId))
  12454. {
  12455. returnErrorMsg("缺少必要的参数");
  12456. return;
  12457. }
  12458. StringBuilder sql = new StringBuilder();
  12459. 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);
  12460. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12461. if (dt == null || dt.Rows.Count == 0)
  12462. {
  12463. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12464. return;
  12465. }
  12466. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12467. return;
  12468. }
  12469. public void get_supplier_product_time_list()
  12470. {
  12471. DataStruct dStruct = GetPostStruct();
  12472. List<string> lw = new List<string>();
  12473. string supplier = GetPostString("supplier");
  12474. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12475. string posTag = CurrentUser.UserPost.Post.Code;
  12476. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12477. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12478. writeGridDataTableJson(dStruct.TotalCount, dt);
  12479. }
  12480. public void saveSupplierProductTime()
  12481. {
  12482. string productId = GetPostString("productId");
  12483. if (string.IsNullOrEmpty(productId))
  12484. {
  12485. returnErrorMsg("缺少必要的参数");
  12486. return;
  12487. }
  12488. string productName = GetPostString("productName");
  12489. int supplierId = GetPostInt("supplierId");
  12490. if (supplierId == 0)
  12491. {
  12492. returnErrorMsg("缺少必要的参数");
  12493. return;
  12494. }
  12495. int quantity = GetPostInt("quantity");
  12496. int sendDay = GetPostInt("sendTime");
  12497. string supplierName = GetPostString("supplierName");
  12498. string craft = GetPostString("craft");
  12499. string deadLine = GetPostString("deadLine");
  12500. string dayDeadLine = GetPostString("dayDeadLine");
  12501. try
  12502. {
  12503. int eid = GetPostInt("eid");
  12504. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12505. if (ceErpSupplierProductTime == null)
  12506. {
  12507. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12508. }
  12509. ceErpSupplierProductTime.productId = productId;
  12510. ceErpSupplierProductTime.productName = productName;
  12511. ceErpSupplierProductTime.supplierId = supplierId;
  12512. ceErpSupplierProductTime.supplierName = supplierName;
  12513. ceErpSupplierProductTime.craft = craft;
  12514. ceErpSupplierProductTime.sendDay = sendDay;
  12515. ceErpSupplierProductTime.quantity = quantity;
  12516. if (!string.IsNullOrEmpty(deadLine))
  12517. {
  12518. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12519. }
  12520. if (!string.IsNullOrEmpty(dayDeadLine))
  12521. {
  12522. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12523. }
  12524. if (ceErpSupplierProductTime.ID == 0)
  12525. {
  12526. ceErpSupplierProductTime.Save();
  12527. }
  12528. else
  12529. {
  12530. ceErpSupplierProductTime.Update();
  12531. }
  12532. }
  12533. catch (Exception e)
  12534. {
  12535. }
  12536. returnSuccessMsg("保存成功");
  12537. return;
  12538. }
  12539. public void delSupplierProductTime()
  12540. {
  12541. int eid = GetPostInt("eid");
  12542. if (eid > 0)
  12543. {
  12544. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12545. if (ceErpSupplierProductTime == null)
  12546. {
  12547. returnErrorMsg("查无数据");
  12548. return;
  12549. }
  12550. ceErpSupplierProductTime.Delete();
  12551. returnSuccessMsg("保存成功");
  12552. return;
  12553. }
  12554. returnErrorMsg("缺少必要的参数");
  12555. }
  12556. public void getExpressInfo()
  12557. {
  12558. string ctid = GetPostString("ctid");
  12559. if (!string.IsNullOrEmpty(ctid))
  12560. {
  12561. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12562. if (ceErpTradeCell != null)
  12563. {
  12564. string outSid = ceErpTradeCell.OutSid;
  12565. if (outSid.Length > 0)
  12566. {
  12567. 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);
  12568. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12569. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12570. return;
  12571. }
  12572. }
  12573. returnErrorMsg("查无记录");
  12574. return;
  12575. }
  12576. returnErrorMsg("缺少必要的参数");
  12577. }
  12578. public void getExpressPostData()
  12579. {
  12580. string express = GetPostString("express");
  12581. if (!string.IsNullOrEmpty(express))
  12582. {
  12583. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12584. if (ceErpExpressInfo != null)
  12585. {
  12586. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12587. return;
  12588. }
  12589. }
  12590. returnErrorMsg("缺少必要的参数");
  12591. }
  12592. public void checkSupplierOrder()
  12593. {
  12594. string ctids = GetPostString("ctids");
  12595. if (ctids != null)
  12596. {
  12597. List<string> list = new List<string>();
  12598. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12599. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12600. for (int i = 0; i < dt.Rows.Count; i++)
  12601. {
  12602. DataRow row = dt.Rows[i];
  12603. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12604. {
  12605. continue;
  12606. }
  12607. list.Add(row["seller_memo"].ToString());
  12608. }
  12609. if (list.Count > 0)
  12610. {
  12611. 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, "点击下载按钮"));
  12612. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12613. return;
  12614. }
  12615. }
  12616. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12617. return;
  12618. }
  12619. public void addPersonId()
  12620. {
  12621. string tid = GetPostString("tid");
  12622. string personId = GetPostString("personId");
  12623. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12624. if (ceErpTrade != null)
  12625. {
  12626. ceErpTrade.receiver_zip = personId;
  12627. ceErpTrade.Update();
  12628. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12629. returnSuccessMsg("保存成功");
  12630. return;
  12631. }
  12632. returnErrorMsg("缺少必要的参数");
  12633. }
  12634. public void addDeliveryPaymant()
  12635. {
  12636. string tid = GetPostString("tid");
  12637. string paymant = GetPostString("paymant");
  12638. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12639. if (ceErpTrade != null)
  12640. {
  12641. if (!string.IsNullOrEmpty(paymant))
  12642. {
  12643. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12644. }
  12645. ceErpTrade.Update();
  12646. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12647. returnSuccessMsg("保存成功");
  12648. return;
  12649. }
  12650. returnErrorMsg("缺少必要的参数");
  12651. }
  12652. public void saveCellFile()
  12653. {
  12654. string tid = GetPostString("tid");
  12655. string ctid = GetPostString("ctid");
  12656. string urls = GetPostString("urls");
  12657. string type = GetPostString("type");
  12658. string del = GetPostString("del");
  12659. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12660. {
  12661. if ("1".Equals(del))
  12662. {
  12663. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12664. }
  12665. string[] list = urls.Split(',');
  12666. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12667. {
  12668. foreach (string item in list)
  12669. {
  12670. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12671. ceErpTradeCellFile.Create();
  12672. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12673. }
  12674. }
  12675. returnSuccessMsg("保存成功");
  12676. return;
  12677. }
  12678. returnErrorMsg("缺少必要的参数");
  12679. }
  12680. public void getCellFile()
  12681. {
  12682. string tid = GetPostString("tid");
  12683. string ctid = GetPostString("ctid");
  12684. string type = GetPostString("type");
  12685. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12686. {
  12687. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12688. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12689. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12690. return;
  12691. }
  12692. returnErrorMsg("缺少必要的参数");
  12693. }
  12694. public void delCellFile()
  12695. {
  12696. string id = GetPostString("id");
  12697. if (string.IsNullOrEmpty(id))
  12698. {
  12699. returnErrorMsg("缺少必要的参数");
  12700. return;
  12701. }
  12702. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12703. CeErpTradeCellFile.delByID(id);
  12704. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12705. returnSuccessMsg("保存成功");
  12706. }
  12707. }
  12708. }