sync.order.cs 658 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080
  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\\领淘文件名命名规范.xls");
  63. //apiHelper.Api_SyncOrderByTime("598825");
  64. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  65. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  66. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  67. //banniuApiHelper.sendLogisticsInfo(null);
  68. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  69. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  70. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  71. //int sid = commonHelper.autoDistributeToSupplier(entity);
  72. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  73. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1756945416000,\"deliveryType\":\"OFFLINE\",\"discountFee\":20.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1757118213000,\"lines\":[{\"latestDeliveryTime\":1757118213000,\"mark2\":[\"DELIVERED\"],\"num\":1,\"outerId\":\"JSBHUVZYT\",\"payment\":10.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/490100363/O1CN01pEaojF1EYIjYhp76h_!!490100363.jpg\",\"platServiceFee\":0.0,\"price\":30.0,\"refOlId\":\"4718408366815008220\",\"refSkuId\":\"5139754537453\",\"refSpuId\":\"641811002682\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":10.0,\"singleFee\":10.0,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"【撕膜留字 | 易撕无残留】\",\"status\":\"SHIPPED\",\"title\":\"水晶标贴UV转印贴logo定制透明标识贴纸设计金属商标烫金标签定做\",\"totalFee\":10.0,\"totalPrice\":30.0,\"totalSellPrice\":10.0}],\"logisticsOrderNo\":\"YT7568465598389\",\"mark2\":[],\"modifyTime\":1756946987000,\"openBuyerId\":\"AAEVRHraABkUZRPgSx3gFRIR\",\"openBuyerNick\":\"a**\",\"openSellerNick\":\"琳19890725\",\"orderSource\":\"SYNC\",\"orderTime\":1756945412000,\"payTime\":1756945413000,\"payment\":10.0,\"platServiceFee\":0.0,\"posCode\":\"guliang\",\"posId\":598696,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0,\"logisticList\":[{\"logisticNo\":\"YT7568465598389\",\"logisticName\":\"圆通速递\"}]},\"receivedPayment\":0.0,\"receiverCity\":\"苏州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吴江区\",\"receiverId\":\"871dbaa880a955e031c5061436d7a5c1$\",\"receiverState\":\"江苏省\",\"receiverTown\":\"江陵街道\",\"refOid\":\"4718408366815008220\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"寄样-不干胶-uv转印贴小尺寸字母银色黑色-aa_小f-龙井-5,寄样-不干胶-金属标字母银色黑色-aa_小f-龙井-5\",\"serviceFee\":0.0,\"shippingTime\":1756946983000,\"status\":\"SHIPPED\",\"sysTags\":[],\"totalFee\":10.0,\"totalPrice\":30.0,\"totalSellPrice\":10.0,\"type\":\"SALE\"}}");
  74. //refundTmcHelper.Api_TmcRefundMsg("{\"content\":{\"afterStatus\":\"SUCCESS\",\"createTime\":1735287446000,\"desc\":\"\",\"interceptInvestor\":\"NONE\",\"interceptStatus\":\"NONE\",\"interceptType\":\"NONE\",\"lines\":[{\"num\":2,\"outerId\":\"\",\"price\":50.0,\"refAid\":\"313001208133750610\",\"refAlId\":\"313001208133750610\",\"refBoughtSkuId\":\"\",\"refOid\":\"4181722704291751006\",\"refOlId\":\"4181722704291751006\",\"refSkuId\":\"0\",\"refSpuId\":\"865893808768\",\"refundFee\":98.86,\"refundStatus\":\"SUCCESS\",\"title\":\"新年会抽奖券定制2025蛇年公司活动正副可撕代金券打印纪念票根奖品兑换尾牙晚宴邀请卡号码牌创意入场券设计\",\"totalFee\":98.86,\"type\":1}],\"logisticsCompany\":\"\",\"logisticsOrderNo\":\"\",\"mark2\":[],\"openBuyerNick\":\"0**\",\"openSellerNick\":\"万慕办公旗舰店\",\"posCode\":\"wanmu\",\"posId\":598798,\"reason\":\"订单信息拍错(规格/尺码/颜色等)\",\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"\",\"receiverState\":\"\",\"receiverTown\":\"\",\"receiverZip\":\"\",\"refAid\":\"313001208133750610\",\"refOid\":\"4181722704291751006\",\"refPlatform\":\"TB\",\"refType\":\"TMALL\",\"refundCreateTime\":1735287358000,\"refundFee\":\"98.86\",\"refundPhase\":\"ON_SALE\",\"refundTime\":1735289443000,\"refundUpdateTime\":1735289443000,\"refundVersion\":1735287358100,\"senderAddress\":\"\",\"senderCity\":\"\",\"senderCountry\":\"中国\",\"senderDistrict\":\"\",\"senderMobile\":\"\",\"senderName\":\"\",\"senderPhone\":\"\",\"senderState\":\"\",\"senderTown\":\"\",\"senderZip\":\"\",\"status\":\"SUCCESS\",\"statusCode\":\"SUCCESS\",\"statusName\":\"退款成功\",\"totalFee\":\"98.86\",\"type\":\"REFUND\",\"updateTime\":1735289479000}}");
  75. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  76. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  77. //preSalesHelper.dealMessageInfo("{\"bizOrder\":{\"id\":235819,\"parentId\":null,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderNo\":\"4624034580248409502\",\"shopId\":4,\"shopCode\":\"aolifu\",\"customerId\":345874,\"customerServiceId\":3184,\"thirdOrderId\":\"4624034580248409502\",\"orderPlatform\":\"TMALL\",\"openBuyerId\":\"AAEORHraABkUZRHgSx6ksuhU\",\"openBuyerNick\":\"tb278604202340\",\"openSellerNick\":\"奥丽芙旗舰店\",\"productUrl\":null,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"payAmount\":125.0,\"unrefundedAmount\":125.0,\"discountAmount\":5.0,\"csDiscountAmount\":-35.0,\"num\":13,\"province\":\"山西省\",\"city\":\"吕梁市\",\"area\":\"孝义市\",\"receiverTown\":\"孝义市\",\"address\":null,\"thirdReceiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"receiverName\":null,\"receiverMobile\":null,\"weChatId\":null,\"phone\":null,\"designContent\":\"\",\"designPics\":\"[]\",\"weChatQrPics\":\"[]\",\"addressFileUrl\":\"\",\"thirdFlag\":\"NONE\",\"remark\":null,\"sellerRemark\":\"\",\"buyerRemark\":\"\",\"timeoutRemark\":null,\"discountRemark\":null,\"status\":\"NOT_SHIPPED\",\"refundStatus\":0,\"internalStatus\":2,\"auditStatus\":null,\"auditUserId\":null,\"auditor\":null,\"customTag\":null,\"isRepurchase\":false,\"isOffline\":false,\"paymentFile\":null,\"orderTime\":\"2025-07-10 14:46:13\",\"modifyTime\":\"2025-07-10 14:46:37\",\"payTime\":\"2025-07-10 14:46:37\",\"confirmTime\":\"2025-07-10 14:51:23\",\"auditTime\":null,\"shippingTime\":null,\"finishTime\":null,\"erpCustomerServiceId\":3319,\"openBuyerID\":\"AAEORHraABkUZRHgSx6ksuhU\",\"orderFrom\":\"10\",\"receiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"bizOrderItems\":[{\"id\":310334,\"orderId\":235819,\"thirdOrderItemId\":\"4624034580248409502\",\"thirdSpuId\":\"740203900330\",\"thirdSkuId\":\"0\",\"title\":\"pvc贴纸定制防水不干胶圆形贴标自粘商标logo广告二维码标签印刷\",\"specification\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2433960672/O1CN01D0ZzzR1GppCHSoBjD_!!4611686018427382496-0-item_pic.jpg\",\"price\":10.0,\"sellPrice\":9.62,\"amount\":9.62,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"totalAmount\":125.0,\"num\":13,\"refundStatus\":\"NO_REFUND\"}],\"bizOrderSplits\":[{\"id\":151557,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328848\",\"splitNo\":\"C1_4624034580248409502\",\"splitInfoNo\":\"C2+1\",\"splitAmount\":52.64,\"quoteRecordId\":520208,\"quoteAmount\":40.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328848)-[C2+1]-80x20mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328848\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":40.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":80.00,\"width\":20.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"80x20mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":40.00,\"numberType\":\"\",\"isDianziOrder\":0},{\"id\":151558,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328853\",\"splitNo\":\"C2_4624034580248409502\",\"splitInfoNo\":\"C2+2\",\"splitAmount\":72.36,\"quoteRecordId\":520209,\"quoteAmount\":55.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328853)-[C2+2]-90x50mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328853\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":55.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":90.00,\"width\":50.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"90x50mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":55.00,\"numberType\":\"\",\"isDianziOrder\":0}]}}");
  78. /*string path = "C:\\Users\\231010\\Downloads\\tids.txt";
  79. string path1 = "C:\\Users\\231010\\Downloads\\tid.txt";
  80. string tids = File.ReadAllText(path);
  81. List<string> list = tids.Split(',').ToList();
  82. int index = 0;
  83. foreach (string item in list)
  84. {
  85. CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
  86. try
  87. {
  88. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  89. if (string.IsNullOrEmpty(ceErpTrade.buyer_nick))
  90. {
  91. sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  92. }
  93. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  94. List<string> tidList = new List<string>();
  95. if (dataTable != null && dataTable.Rows.Count > 0)
  96. {
  97. foreach (DataRow row in dataTable.Rows)
  98. {
  99. tidList.Add("'" + row["tid"].ToString() + "'");
  100. }
  101. }
  102. if (tidList.Count > 0)
  103. {
  104. sql = string.Format("SELECT count(*) as number FROM [dbo].[CE_ErpTradeCell] WITH(NOLOCK) WHERE tid in ({0}) AND IsSample = 0 ", string.Join(",", tidList));
  105. dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  106. if (dataTable != null && dataTable.Rows.Count > 0)
  107. {
  108. int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
  109. if (count > 0)
  110. {
  111. Debug.WriteLine(index++);
  112. continue;
  113. }
  114. }
  115. }
  116. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  117. }
  118. catch (Exception e)
  119. {
  120. File.AppendAllText(path1, "e:" + ceErpTrade.tid + "\n");
  121. }
  122. Debug.WriteLine(index++);
  123. }*/
  124. //string a = commonHelper.convertQNMemo("48x61mm-4款各40个-铜版纸-不干胶-覆膜模切-tb963561715-金陵-顺丰到付.粘成品.6.5cm牙签-老客户改稿找金陵拉群-16发", CeErpTradeCell.GetByCtid("2879265072537265386"));
  125. List<string> lw = new List<string>();
  126. string tid = GetPostString("ctid");
  127. string date1 = GetPostString("date1");
  128. //12-1 修改
  129. string urgent = GetPostString("urgent");
  130. string back = GetPostString("back");
  131. string offlineSearch = GetPostString("offlineSearch");
  132. int paramsCount = 0;
  133. if (!string.IsNullOrWhiteSpace(urgent))
  134. {
  135. if (urgent.Equals("true"))
  136. {
  137. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  138. }
  139. }
  140. if (!string.IsNullOrWhiteSpace(back))
  141. {
  142. if (back.Equals("true"))
  143. {
  144. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  145. }
  146. }
  147. if (!string.IsNullOrWhiteSpace(offlineSearch))
  148. {
  149. if (offlineSearch.Equals("true"))
  150. {
  151. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  152. }
  153. }
  154. //end
  155. string date2 = GetPostString("date2");
  156. string buyernick = GetPostString("buyer_nick");
  157. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  158. {
  159. if (tid.Length <= 0 && buyernick.Length <= 0)
  160. {
  161. return;
  162. }
  163. }
  164. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  165. {
  166. if (tid.Length > 0)
  167. {
  168. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  169. if (ceErpTradeCell != null)
  170. {
  171. tid = ceErpTradeCell.tid;
  172. }
  173. List<string> select_tid = getTidByCtidMore(tid);
  174. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  175. }
  176. if (buyernick.Length > 0)
  177. {
  178. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  179. }
  180. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  181. if (dw.Length > 0)
  182. {
  183. lw.Add(dw);
  184. }
  185. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  186. {
  187. string usershop = CurrentUser.User.pemShop;
  188. lw.Add(string.Format("ShopId in ({0})", usershop));
  189. }
  190. }
  191. else
  192. {
  193. if (ex_psize == 0)
  194. {
  195. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  196. }
  197. if (PKey != "admin" && poscode != "SysAdmin")
  198. {
  199. string usershop = CurrentUser.User.pemShop;
  200. lw.Add(string.Format("ShopId in ({0})", usershop));
  201. paramsCount++;
  202. }
  203. }
  204. string uploaddate1 = GetPostString("uploaddate1");
  205. string uploaddate2 = GetPostString("uploaddate2");
  206. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  207. if (update.Length > 0) lw.Add(update);
  208. string deliverydate1 = GetPostString("deliverydate1");
  209. string deliverydate2 = GetPostString("deliverydate2");
  210. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  211. if (deliverydate.Length > 0)
  212. {
  213. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  214. };
  215. string shopname = GetPostString("shopname");
  216. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  217. string addwechat = GetPostString("addwechat");
  218. if (addwechat.Length > 0)
  219. {
  220. int addWt = Convert.ToInt32(addwechat);
  221. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  222. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  223. }
  224. string customer = GetPostString("customer");
  225. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  226. string design = GetPostString("design");
  227. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  228. string orderState = GetPostString("orderState");
  229. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  230. string address = GetPostString("address");
  231. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  232. string sellermemo = GetPostString("seller_memo");
  233. if (sellermemo.Length > 0)
  234. {
  235. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  236. }
  237. string backReason = GetPostString("backReason");
  238. if (backReason.Length > 0)
  239. {
  240. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  241. }
  242. string apdate1 = GetPostString("apdate1");
  243. string apdate2 = GetPostString("apdate2");
  244. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  245. if (dwap.Length > 0) lw.Add(dwap);
  246. string price1 = GetPostString("price1");
  247. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  248. string price2 = GetPostString("price2");
  249. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  250. string isoldcustomer = GetPostString("isoldcus");
  251. string spudata = GetPostString("spudata");
  252. if ("0".Equals(spudata))
  253. {
  254. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  255. }
  256. if ("1".Equals(spudata))
  257. {
  258. lw.Add(string.Format("spu_id <> ''"));
  259. }
  260. string finishdate1 = GetPostString("finishdate1");
  261. string finishdate2 = GetPostString("finishdate2");
  262. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  263. bool isFinish = false;
  264. if (finishdate.Length > 0)
  265. {
  266. lw.Add(finishdate);
  267. isFinish = true;
  268. paramsCount++;
  269. }
  270. if (isoldcustomer.Length > 0)
  271. {
  272. if ("2".Equals(isoldcustomer))
  273. {
  274. lw.Add(string.Format("VipCustomer=1"));
  275. }
  276. else
  277. {
  278. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  279. }
  280. }
  281. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  282. if (ex_psize > 0)
  283. {
  284. int UserID = CurrentUser.UserID;
  285. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  286. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  287. {
  288. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  289. }
  290. dStruct.Order = "pay_time desc";
  291. }
  292. string isNew = GetPostString("isNew");
  293. if (isNew == "true")
  294. {
  295. lw.Add(string.Format("IsNew = {0}", 1));
  296. }
  297. string overtime = GetPostString("overtime");
  298. if (overtime == "1")
  299. {
  300. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  301. }
  302. String usePost = CurrentUser.UserPost.Post.Code;
  303. if (usePost.Equals("Operation") == true)
  304. {
  305. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  306. }
  307. else
  308. {
  309. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  310. }
  311. //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";
  312. if (dStruct.PageSize == 100000)
  313. {
  314. dStruct.Order = "";
  315. }
  316. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  317. DataTable dt = null;
  318. string tablename = "view_orderlist";
  319. if (isFinish)
  320. {
  321. tablename = "view_orderlist_end";
  322. }
  323. dt = WebCache.GetData(tablename, dStruct);
  324. if (dt != null && dt.Rows.Count > 0)
  325. {
  326. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  327. foreach (DataRow dr in dt.Rows)
  328. {
  329. try
  330. {
  331. if (dr["refund_fees"] != null)
  332. {
  333. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  334. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  335. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  336. if (payment == refund_fees)
  337. {
  338. dr["refund_fees"] = Math.Round(refund_fees, 2);
  339. }
  340. else if (refund_fees == total_fee)
  341. {
  342. dr["refund_fees"] = payment;
  343. }
  344. else
  345. {
  346. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  347. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  348. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  349. }
  350. }
  351. // 对象操作
  352. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  353. ceErpTradeCell.ctid = dr["ctid"].ToString();
  354. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  355. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  356. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  357. if (dStruct.PageSize != 100000)
  358. {
  359. if (dr["DispatchSort"].ToString() == "2")
  360. {
  361. dr["gongchuang"] = 200;
  362. }
  363. else if ("外协".Equals(dr["ToType"].ToString()))
  364. {
  365. dr["gongchuang"] = 200;
  366. }
  367. else if ("内部".Equals(dr["ToType"].ToString()))
  368. {
  369. dr["gongchuang"] = -1;
  370. }
  371. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  372. {
  373. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  374. dr["gongchuang"] = response.code;
  375. }
  376. }
  377. }
  378. catch (NullReferenceException ex)
  379. {
  380. // 处理空引用异常
  381. dr["refund_fees"] = "0.00";
  382. }
  383. }
  384. }
  385. writeGridDataTableJson(dStruct.TotalCount, dt);
  386. }
  387. public void get_erp_orderlist_sumprice()
  388. {
  389. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  390. return;
  391. List<string> lw = new List<string>();
  392. string tid = GetPostString("ctid");
  393. string date1 = GetPostString("date1");
  394. string date2 = GetPostString("date2");
  395. if (tid.Length > 0 || date1.Length > 0)
  396. {
  397. lw.Add(string.Format("ctid like '%{0}%'", tid));
  398. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  399. if (dw.Length > 0) lw.Add(dw);
  400. }
  401. else
  402. {
  403. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  404. }
  405. string shopname = GetPostString("shopname");
  406. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  407. string buyernick = GetPostString("buyer_nick");
  408. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  409. string customer = GetPostString("customer");
  410. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  411. string design = GetPostString("design");
  412. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  413. string orderState = GetPostString("orderState");
  414. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  415. string address = GetPostString("address");
  416. 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));
  417. string sellermemo = GetPostString("seller_memo");
  418. if (sellermemo.Length > 0)
  419. {
  420. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  421. }
  422. string apdate1 = GetPostString("apdate1");
  423. string apdate2 = GetPostString("apdate2");
  424. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  425. if (dwap.Length > 0) lw.Add(dwap);
  426. string price1 = GetPostString("price1");
  427. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  428. string price2 = GetPostString("price2");
  429. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  430. string isoldcustomer = GetPostString("isoldcus");
  431. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  432. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  433. if (PKey != "admin")
  434. {
  435. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  436. lw.Add(string.Format("shopId in ({0})", usershop));
  437. }
  438. //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";
  439. string mainWhere = string.Join(" and ", lw.ToArray());
  440. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  441. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  442. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  443. decimal total = 0;
  444. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  445. {
  446. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  447. }
  448. var res = new
  449. {
  450. data = total
  451. };
  452. string ro_jsond = JsonConvert.SerializeObject(res);
  453. returnSuccess(ro_jsond);
  454. return;
  455. }
  456. public void get_erp_CustomerServiceGather()
  457. {
  458. string userWhere = "", orderWhere = "";
  459. List<string> lw = new List<string>();
  460. string customer = GetPostString("customer");
  461. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  462. string shopname = GetPostString("shopname");
  463. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  464. string date1 = GetPostString("date1");
  465. string date2 = GetPostString("date2");
  466. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  467. if (dw.Length > 0) lw.Add(dw);
  468. orderWhere = string.Join(" and ", lw.ToArray());
  469. 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 " +
  470. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  471. "left join " +
  472. "( " +
  473. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  474. ") as b on a.ID = b.CustomerUserId " +
  475. "left join " +
  476. "( " +
  477. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  478. ") as d on a.ID = d.CustomerUserId " +
  479. "left join " +
  480. "( " +
  481. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  482. ") as e on a.ID = e.CustomerUserId " +
  483. "left join " +
  484. "( " +
  485. " select CustomerUserId, RefundCount, RefundSum from " +
  486. " ( " +
  487. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  488. " from CE_ErpTradeRefund a " +
  489. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  490. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  491. " group by CustomerUserId " +
  492. " ) as a " +
  493. ") as f on a.ID = f.CustomerUserId " +
  494. "where a.PostCode = 'CustomerService'",
  495. userWhere, orderWhere);
  496. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  497. writeGridDataTableJson(dt.Rows.Count, dt);
  498. //writeGridDataTableJson(dt.Rows.Count, dt);
  499. }
  500. //设计汇总
  501. public void get_erp_DesignerGather()
  502. {
  503. string userWhere = "", orderWhere = "";
  504. List<string> lw = new List<string>();
  505. string Designer = GetPostString("designer");
  506. int org = GetPostInt("org");
  507. if (Designer.Length > 0)
  508. {
  509. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  510. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  511. }
  512. else if (org > 0)
  513. {
  514. userWhere = string.Format(" where OrgID ={0}", org);
  515. }
  516. string shopname = GetPostString("shopname");
  517. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  518. string state = GetPostString("state");
  519. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  520. string OrderArea = GetPostString("order_area");
  521. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  522. string date1 = GetPostString("date1");
  523. string date2 = GetPostString("date2");
  524. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  525. if (dw.Length > 0) lw.Add(dw);
  526. string UpDate1 = GetPostString("UpDate1");
  527. string UpDate2 = GetPostString("UpDate2");
  528. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  529. if (dw.Length > 0) lw.Add(dw);
  530. orderWhere = string.Join(" and ", lw.ToArray());
  531. 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 (" +
  532. "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 " +
  533. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  534. "left join " +
  535. "( " +
  536. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  537. ") as b on a.ID = b.DesignUserId " +
  538. "left join " +
  539. "( " +
  540. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  541. ") as d on a.ID = d.DesignUserId " +
  542. "left join " +
  543. "( " +
  544. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  545. ") as e on a.ID = e.DesignUserId " +
  546. "left join " +
  547. "( " +
  548. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  549. ") as g on a.ID = g.DesignUserId " +
  550. "left join " +
  551. "( " +
  552. " select CustomerUserId, RefundCount, RefundSum from " +
  553. " ( " +
  554. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  555. " from CE_ErpTradeRefund a " +
  556. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  557. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  558. " group by CustomerUserId " +
  559. " ) as a " +
  560. ") as f on a.ID = f.CustomerUserId " +
  561. "where a.PostCode = 'Designer') as z",
  562. userWhere, orderWhere);
  563. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  564. writeGridDataTableJson(dt.Rows.Count, dt);
  565. }
  566. //删除tradecell的订单
  567. public void del_erp_cellorder()
  568. {
  569. if (UrlPostParmsCheck("ctid"))
  570. {
  571. string eid = GetPostString("ctid");
  572. CeErpTradeCell.DelByCtid(eid);
  573. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  574. returnSuccessMsg("删除成功");
  575. }
  576. }
  577. public void clear_erp_refundstate()
  578. {
  579. if (UrlPostParmsCheck("ids"))
  580. {
  581. string eids = GetPostString("ids");
  582. string[] ctidList = eids.Split(',');
  583. foreach (string ctid in ctidList)
  584. {
  585. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  586. if (entity != null)
  587. {
  588. entity.IsRefund = 0;
  589. entity.Update();
  590. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  591. }
  592. else
  593. continue;
  594. }
  595. returnSuccessMsg("操作成功");
  596. return;
  597. }
  598. returnErrorMsg("缺少必要参数");
  599. }
  600. public void set_erp_urgency()
  601. {
  602. if (UrlPostParmsCheck("ctid"))
  603. {
  604. string eid = GetPostString("ctid");
  605. CeErpTradeCell entity = null;
  606. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  607. if (entity != null)
  608. {
  609. double prices = commonHelper.calculationPrice(entity);
  610. if (prices <= 100)
  611. {
  612. returnErrorMsg("此订单金额不足100元,无法加急。");
  613. return;
  614. }
  615. string utime = GetPostString("urgencytime");
  616. if (utime.Length > 0)
  617. {
  618. entity.UrgencyTime = Convert.ToDateTime(utime);
  619. }
  620. else
  621. {
  622. returnErrorMsg("请选择加急时间");
  623. return;
  624. }
  625. if (entity.OrderState <= 4)
  626. {
  627. //entity.seller_memo = entity.seller_memo + "-加急";
  628. string smemo = entity.seller_memo;
  629. int kindex = smemo.IndexOf(")");
  630. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  631. if (lastoneStr != "-")
  632. {
  633. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  634. }
  635. string prememo = smemo.Substring(0, kindex + 2);
  636. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  637. int lastkindex = lastmemo.IndexOf("(");
  638. DateTime urgtime = Convert.ToDateTime(utime);
  639. string newlastmemo = "";
  640. if (lastkindex == 0)
  641. {
  642. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  643. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  644. }
  645. else
  646. {
  647. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  648. }
  649. entity.seller_memo = prememo + newlastmemo;
  650. }
  651. entity.IsUrgency = true;
  652. entity.UpdateTime = DateTime.Now;
  653. entity.Update();
  654. ApiVo apiVo = new ApiVo();
  655. apiVo.orderNumber = entity.ctid;
  656. apiVo.actionName = "changeDesign";
  657. apiVo.orderRemarks = entity.seller_memo;
  658. apiVo.remarkSign = 3;
  659. designHelper.API_WorkCore(apiVo); //changeDesign
  660. CeErpSukuraData.createInfo(entity.ctid, 7);
  661. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  662. returnSuccessMsg("设置成功!");
  663. return;
  664. }
  665. returnErrorMsg("找不到记录");
  666. }
  667. }
  668. public void set_erp_reset()
  669. {
  670. if (UrlPostParmsCheck("ctid"))
  671. {
  672. string eid = GetPostString("ctid");
  673. CeErpTradeCell entity = null;
  674. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  675. if (entity != null)
  676. {
  677. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  678. {
  679. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  680. {
  681. returnErrorMsg("财务要求已下单已发货无法重置");
  682. return;
  683. }
  684. }
  685. entity.IsUrgency = false;
  686. entity.seller_memo = "";
  687. entity.OtherMemo = "";
  688. entity.OrderState = 0;
  689. entity.IsReturn = 0;
  690. //entity.IsRefund = 0;
  691. entity.MemoOpt = 0;
  692. entity.AfterSaleState = 0;
  693. entity.AfterSaleResponsible = "";
  694. entity.AfterSaleUserId = 0;
  695. entity.IsNeedBill = 0;
  696. entity.CustomerUserId = 0;
  697. entity.DesignUserId = 0;
  698. entity.SupplierId = 0;
  699. entity.PlaceUserId = 0;
  700. entity.ptid = "";
  701. entity.IsSample = 0;
  702. entity.IsXianHuo = 0;
  703. entity.isDianziOrder = 0;
  704. entity.DispatchSort = 0;
  705. entity.IsVerifyToSupplier = false;
  706. entity.FinishPlaceTime = null;
  707. entity.Update();
  708. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  709. if (trade != null)
  710. {
  711. trade.seller_memo = "";
  712. trade.Update();
  713. }
  714. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  715. returnSuccessMsg("重置成功!");
  716. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  717. if (desginBill != null)
  718. {
  719. desginBill.isDel = 1;
  720. desginBill.Update();
  721. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  722. }
  723. ApiVo apiVo = new ApiVo();
  724. apiVo.orderNumber = entity.ctid;
  725. apiVo.actionName = "resetDesign";
  726. designHelper.API_WorkCore(apiVo);//resetDesign
  727. return;
  728. }
  729. returnErrorMsg("找不到记录");
  730. }
  731. }
  732. public void save_erp_sellermemo()
  733. {
  734. if (UrlPostParmsCheck("ctid"))
  735. {
  736. string ctid = GetPostString("ctid");
  737. CeErpTradeCell entity = null;
  738. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  739. if (entity != null)
  740. {
  741. string memo = GetPostString("seller_memo");
  742. string qn_memo = GetPostString("qn_memo");
  743. memo = memo.Replace(" ", "");
  744. if (memo.Contains("补差"))
  745. {
  746. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  747. return;
  748. }
  749. List<string> bitList = new List<string>
  750. {
  751. "\\","/",":","*","?", "\"","<" ,">","|"
  752. };
  753. bool isIn = false;
  754. foreach (string bit in bitList)
  755. {
  756. if (memo.Contains(bit))
  757. {
  758. isIn = true;
  759. }
  760. }
  761. if (isIn)
  762. {
  763. returnErrorMsg("不能使用 一些符合作为文件名");
  764. return;
  765. }
  766. if (entity.seller_memo != memo)
  767. {
  768. if (entity.IsSample == 2)
  769. {
  770. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  771. return;
  772. }
  773. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  774. {
  775. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  776. {
  777. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  778. return;
  779. }
  780. /*if (CurrentUser.UserPost.Post.Code != "Place")
  781. {
  782. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  783. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  784. {
  785. returnErrorMsg("售前系统订单无法再此修改!");
  786. return;
  787. }
  788. }*/
  789. }
  790. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  791. }
  792. if (!string.IsNullOrEmpty(qn_memo) && !(entity.IsSample > 0 || entity.ctid.Contains("N_") || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物")))
  793. {
  794. if (entity.OrderState >= 5)
  795. {
  796. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  797. return;
  798. }
  799. string delMemo = commonHelper.convertQNMemo(qn_memo, ref entity);
  800. if (string.IsNullOrEmpty(delMemo))
  801. {
  802. returnErrorMsg("备注不规范,无法识别");
  803. return;
  804. }
  805. memo = delMemo;
  806. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统千牛修改为:" + memo, entity.OrderState, 1);
  807. }
  808. commonHelper.getCytPrice(entity);
  809. int memoopt = GetPostInt("MemoOpt");
  810. Boolean ismemoopt = false;
  811. if (memoopt > 0)
  812. {
  813. string stropt = "";
  814. if (memoopt == 1)
  815. {
  816. stropt = "“改稿”";
  817. ismemoopt = true;
  818. }
  819. else if (memoopt == 2)
  820. {
  821. stropt = "“定稿”";
  822. }
  823. else if (memoopt == 3)
  824. {
  825. stropt = "“查货”";
  826. CeErpSukuraData.createInfo(entity.ctid, 6);
  827. }
  828. entity.MemoOpt = Convert.ToInt32(memoopt);
  829. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  830. }
  831. if (entity.OrderState < 5)
  832. {
  833. memo = memo.Replace("(", "(");
  834. memo = memo.Replace(")", ")");
  835. }
  836. /* if (entity.OrderState < 3)
  837. {
  838. entity.DispatchSort = 0;
  839. }*/
  840. entity.seller_memo = memo;
  841. entity.UpdateTime = DateTime.Now;
  842. entity.Update();
  843. ApiVo apiVo = new ApiVo();
  844. apiVo.orderNumber = entity.ctid;
  845. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  846. apiVo.orderRemarks = memo;
  847. apiVo.remarkSign = memoopt;
  848. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  849. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  850. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  851. {
  852. dataHelper.api_orderBack(entity.ctid, "0", "");
  853. }
  854. if (entity.seller_memo.Contains("改稿"))
  855. {
  856. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  857. }
  858. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  859. returnSuccessMsg("保存成功!");
  860. return;
  861. }
  862. returnErrorMsg("找不到记录");
  863. }
  864. }
  865. public void ins_erp_checkorder()
  866. {
  867. if (UrlPostParmsCheck("ctid"))
  868. {
  869. string ctid = GetPostString("ctid");
  870. CeErpTradeCell entity = null;
  871. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  872. if (entity != null)
  873. {
  874. if (entity.OrderState < 6)
  875. {
  876. returnErrorMsg("下单完成后才可查货");
  877. return;
  878. }
  879. /*if (entity.OrderState > 6)
  880. {
  881. returnErrorMsg("订单已发货");
  882. return;
  883. }*/
  884. if (entity.FinishPlaceTime != null)
  885. {
  886. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  887. {
  888. returnErrorMsg("下单时间不足,无法查货");
  889. return;
  890. }
  891. }
  892. entity.MemoOpt = 3;
  893. entity.CheckOrderTime = DateTime.Now;
  894. entity.UpdateTime = DateTime.Now;
  895. entity.Update();
  896. CeErpSukuraData.createInfo(entity.ctid, 6);
  897. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  898. returnSuccessMsg("操作成功!");
  899. return;
  900. }
  901. returnErrorMsg("找不到记录");
  902. }
  903. }
  904. public void save_erp_othermemo()
  905. {
  906. if (UrlPostParmsCheck("ctid"))
  907. {
  908. string ctid = GetPostString("ctid");
  909. CeErpTradeCell entity = null;
  910. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  911. if (entity != null)
  912. {
  913. entity.OtherMemo = GetPostString("otherMemo");
  914. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  915. {
  916. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  917. StringBuilder sql = new StringBuilder();
  918. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  919. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  920. if (dt != null && dt.Rows.Count > 0)
  921. {
  922. foreach (DataRow dr in dt.Rows)
  923. {
  924. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  925. {
  926. //品类一直
  927. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  928. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  929. if (ceErpSampleCustomer == null)
  930. {
  931. ceErpSampleCustomer = new CeErpSampleCustomer();
  932. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  933. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  934. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  935. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  936. ceErpSampleCustomer.shopId = entity.ShopId;
  937. }
  938. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  939. ceErpSampleCustomer.lastTid = entity.tid;
  940. if (ceErpSampleCustomer.ID > 0)
  941. {
  942. ceErpSampleCustomer.Update();
  943. }
  944. else
  945. {
  946. ceErpSampleCustomer.Create();
  947. }
  948. }
  949. }
  950. }
  951. }
  952. //if (entity.IsOldCustomer == 1)
  953. //{
  954. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  955. //{
  956. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  957. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  958. //}
  959. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  960. //{
  961. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  962. // {
  963. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  964. // {
  965. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  966. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  967. // }
  968. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  969. // {
  970. // entity.OrderState = 2;
  971. // entity.DesignUserId = 0;
  972. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  973. // }
  974. // else
  975. // {
  976. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  977. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  978. // }
  979. // }
  980. //}
  981. //}
  982. entity.UpdateTime = DateTime.Now;
  983. entity.Update();
  984. returnSuccessMsg("保存成功!");
  985. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  986. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  987. if (entity.OtherMemo.Contains("改稿"))
  988. {
  989. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  990. }
  991. return;
  992. }
  993. returnErrorMsg("找不到记录");
  994. }
  995. }
  996. public void save_erp_customermemo()
  997. {
  998. if (UrlPostParmsCheck("ctid"))
  999. {
  1000. string ctid = GetPostString("ctid");
  1001. CeErpTradeCell entity = null;
  1002. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  1003. if (entity != null)
  1004. {
  1005. entity.UpdateTime = DateTime.Now;
  1006. entity.CustomerMemo = GetPostString("CustomerMemo");
  1007. entity.Update();
  1008. ApiVo apiVo = new ApiVo();
  1009. apiVo.orderNumber = entity.ctid;
  1010. apiVo.actionName = "followRemarks";
  1011. apiVo.orderRemarks = entity.CustomerMemo;
  1012. designHelper.API_WorkCore(apiVo);//followRemarks
  1013. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1014. returnSuccessMsg("保存成功!");
  1015. return;
  1016. }
  1017. returnErrorMsg("找不到记录");
  1018. }
  1019. }
  1020. public void upd_erp_addmemotag()
  1021. {
  1022. if (UrlPostParmsCheck("ctid"))
  1023. {
  1024. ;
  1025. string eid = GetPostString("ctid");
  1026. string sfTagstr = GetPostString("memotag");
  1027. CeErpTradeCell entity = null;
  1028. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1029. if (entity != null)
  1030. {
  1031. ApiVo apiVo = new ApiVo();
  1032. if (entity.OrderState == 0)
  1033. {
  1034. returnErrorMsg("请先领单");
  1035. return;
  1036. }
  1037. //撤销顺丰
  1038. if (sfTagstr == "撤销顺丰")
  1039. {
  1040. entity.IsSF = 0;
  1041. string reMsg = "";
  1042. string oldmemo = entity.seller_memo;
  1043. if (entity.OrderState < 5)
  1044. {
  1045. oldmemo = oldmemo.Replace("顺丰到付", "");
  1046. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1047. entity.seller_memo = oldmemo;
  1048. }
  1049. else
  1050. {
  1051. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1052. {
  1053. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1054. }
  1055. }
  1056. entity.Update();
  1057. apiVo.orderNumber = entity.ctid;
  1058. apiVo.actionName = "orderRemarks";
  1059. apiVo.orderRemarks = entity.seller_memo;
  1060. apiVo.isSf = entity.IsSF.ToString();
  1061. designHelper.API_WorkCore(apiVo);//orderRemarks
  1062. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1063. returnSuccessMsg("撤销成功!" + reMsg);
  1064. return;
  1065. }
  1066. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1067. {
  1068. //string oldmemo = entity.seller_memo;
  1069. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1070. string sfStr = GetPostString("memotag");
  1071. string smemo = entity.seller_memo;
  1072. int kindex = smemo.IndexOf(")");
  1073. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1074. if (lastoneStr != "-")
  1075. {
  1076. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1077. }
  1078. string prememo = smemo.Substring(0, kindex + 2);
  1079. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1080. int lastkindex = lastmemo.IndexOf("(");
  1081. string newlastmemo = "";
  1082. if (lastkindex == 0)
  1083. {
  1084. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1085. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1086. }
  1087. else
  1088. {
  1089. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1090. }
  1091. entity.seller_memo = prememo + newlastmemo;
  1092. }
  1093. string sfTagMSg = "";
  1094. if (sfTagstr == "顺丰寄付")
  1095. {
  1096. entity.IsSF = 1;
  1097. sfTagMSg = "顺丰寄付";
  1098. }
  1099. else if (sfTagstr == "顺丰到付")
  1100. {
  1101. entity.IsSF = 2;
  1102. sfTagMSg = "顺丰到付";
  1103. }
  1104. if (entity.SupplierId == 19 && entity.OrderState == 6)
  1105. {
  1106. string deliveryWayName = "";
  1107. if (sfTagstr == "撤销顺丰")
  1108. {
  1109. sfTagstr = "普通快递";
  1110. }
  1111. if (sfTagstr == "顺丰寄付")
  1112. {
  1113. sfTagstr = "顺丰特快寄付";
  1114. }
  1115. if (sfTagstr == "顺丰到付")
  1116. {
  1117. sfTagstr = "顺丰特快到付";
  1118. }
  1119. string result = apichyHelper.updateExpressMark(entity.tid, sfTagstr);
  1120. if ("修改失败".Equals(result))
  1121. {
  1122. returnErrorMsg("修改失败");
  1123. return;
  1124. }
  1125. }
  1126. entity.Update();
  1127. apiVo = new ApiVo();
  1128. apiVo.orderNumber = entity.ctid;
  1129. apiVo.actionName = "orderRemarks";
  1130. apiVo.orderRemarks = entity.seller_memo;
  1131. apiVo.isSf = entity.IsSF.ToString();
  1132. designHelper.API_WorkCore(apiVo);//orderRemarks
  1133. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1134. returnSuccessMsg("标记成功!");
  1135. return;
  1136. }
  1137. returnErrorMsg("找不到记录");
  1138. }
  1139. }
  1140. public void upd_erp_ordertag()
  1141. {
  1142. if (UrlPostParmsCheck("ctid"))
  1143. {
  1144. string eid = GetPostString("ctid");
  1145. CeErpTradeCell entity = null;
  1146. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1147. if (entity != null)
  1148. {
  1149. int tag = GetPostInt("wechattag");
  1150. //if(tag==4 && entity.IsSample == 2)
  1151. //{
  1152. // returnErrorMsg("补差价单不能标记微信单");
  1153. // return;
  1154. //}
  1155. entity.wechatTag = tag;
  1156. entity.Update();
  1157. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1158. if (tag == 1)
  1159. {
  1160. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1161. if (cash == null)
  1162. {
  1163. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1164. cash = new CeErpReturnCash();
  1165. cash.tid = entity.tid;
  1166. cash.seller_nick = main.seller_nick;
  1167. cash.payment = trade.payment;
  1168. cash.buyer_nick = main.buyer_nick;
  1169. cash.cashstate = 0;
  1170. cash.rtype = "微信返现";
  1171. cash.returnprice = 0;
  1172. cash.created = DateTime.Now;
  1173. cash.con = "订单标记微信单";
  1174. cash.img = "";
  1175. cash.applyuserid = CurrentUser.UserID;
  1176. cash.Create();
  1177. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1178. }
  1179. else
  1180. {
  1181. cash.cashstate = 0;
  1182. cash.Update();
  1183. }
  1184. CeErpSukuraData.createInfo(entity.ctid, 9);
  1185. }
  1186. else if (tag == 2)
  1187. {
  1188. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1189. if (cash == null)
  1190. {
  1191. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1192. cash = new CeErpReturnCash();
  1193. cash.tid = entity.tid;
  1194. cash.seller_nick = main.seller_nick;
  1195. cash.payment = trade.payment;
  1196. cash.buyer_nick = main.buyer_nick;
  1197. cash.cashstate = 0;
  1198. cash.rtype = "推购返现";
  1199. cash.returnprice = 5;
  1200. cash.created = DateTime.Now;
  1201. cash.con = "订单标记推购单";
  1202. cash.img = "";
  1203. cash.applyuserid = CurrentUser.UserID;
  1204. cash.Create();
  1205. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1206. }
  1207. else
  1208. {
  1209. cash.cashstate = 0;
  1210. cash.Update();
  1211. }
  1212. CeErpSukuraData.createInfo(entity.ctid, 9);
  1213. }
  1214. else if (tag == 3)
  1215. {
  1216. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1217. if (pers == null)
  1218. {
  1219. pers = new CeErpPersuade();
  1220. pers.ctid = entity.ctid;
  1221. pers.pstate = 0;
  1222. pers.created = DateTime.Now;
  1223. pers.applyuserid = CurrentUser.UserID;
  1224. pers.Create();
  1225. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1226. }
  1227. else
  1228. {
  1229. pers.pstate = 0;
  1230. pers.Update();
  1231. }
  1232. }
  1233. else if (tag == 4 || tag == 5)
  1234. {
  1235. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1236. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1237. if (pers == null)
  1238. {
  1239. pers = CeErpStayGoods.GetByTid(entity.tid);
  1240. }
  1241. if (pers == null)
  1242. {
  1243. pers = new CeErpStayGoods();
  1244. pers.t_id = entity.tid;
  1245. pers.ctid = entity.ctid;
  1246. pers.status = "待审核";
  1247. pers.audit_type = 0;
  1248. if (tag == 4)
  1249. {
  1250. pers.stay_type = "微信推购";
  1251. }
  1252. else
  1253. {
  1254. pers.stay_type = "旺旺推购";
  1255. }
  1256. if (entity.IsXianHuo == 0)
  1257. {
  1258. pers.product_id = entity.ProductId;
  1259. }
  1260. pers.wangwang = main.buyer_nick;
  1261. pers.shop_name = main.seller_nick;
  1262. pers.creata_time = DateTime.Now;
  1263. pers.create_u_id = CurrentUser.UserID;
  1264. pers.create_u_name = CurrentUser.UserName;
  1265. pers.Create();
  1266. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1267. }
  1268. else
  1269. {
  1270. pers.ctid = entity.ctid;
  1271. pers.audit_type = 0;
  1272. pers.Update();
  1273. }
  1274. CeErpSukuraData.createInfo(entity.ctid, 10);
  1275. }
  1276. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1277. returnSuccessMsg("标记成功!");
  1278. return;
  1279. }
  1280. returnErrorMsg("找不到记录");
  1281. }
  1282. }
  1283. public void upd_erp_ordertag_cancel()
  1284. {
  1285. if (UrlPostParmsCheck("ctid"))
  1286. {
  1287. string eid = GetPostString("ctid");
  1288. CeErpTradeCell entity = null;
  1289. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1290. if (entity != null)
  1291. {
  1292. entity.wechatTag = 0;
  1293. entity.Update();
  1294. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1295. if (pers != null)
  1296. {
  1297. pers.status = "取消推购";
  1298. pers.audit_type = 3;
  1299. pers.Update();
  1300. }
  1301. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1302. returnSuccessMsg("标记成功!");
  1303. return;
  1304. }
  1305. returnErrorMsg("找不到记录");
  1306. }
  1307. }
  1308. public void upd_erp_addweichattag()
  1309. {
  1310. if (UrlPostParmsCheck("ctid"))
  1311. {
  1312. ;
  1313. string eid = GetPostString("ctid");
  1314. CeErpTradeCell entity = null;
  1315. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1316. if (entity != null)
  1317. {
  1318. if (entity.IsAddWechat > 0)
  1319. {
  1320. returnErrorMsg("此单已经标记过了");
  1321. return;
  1322. }
  1323. 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);
  1324. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1325. if (dt.Rows.Count > 0)
  1326. {
  1327. entity.IsAddWechat = 2;
  1328. }
  1329. else
  1330. {
  1331. entity.IsAddWechat = 1;
  1332. }
  1333. entity.Update();
  1334. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1335. returnSuccessMsg("标记成功!");
  1336. return;
  1337. }
  1338. returnErrorMsg("找不到记录");
  1339. }
  1340. }
  1341. public void upd_erp_getmyorder()
  1342. {
  1343. if (UrlPostParmsCheck("ctid"))
  1344. {
  1345. string eid = GetPostString("ctid");
  1346. CeErpTradeCell entity = null;
  1347. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1348. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1349. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1350. {
  1351. returnErrorMsg("台湾客户需填写身份证号!");
  1352. return;
  1353. }
  1354. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1355. {
  1356. returnErrorMsg("偏远地区需要填写物流费!");
  1357. return;
  1358. }
  1359. if (entity != null)
  1360. {
  1361. if (entity.ctid.IndexOf("C") != -1)
  1362. {
  1363. StringBuilder sql = new StringBuilder();
  1364. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1365. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1366. if (dt.Rows.Count > 0)
  1367. {
  1368. decimal total = 0;
  1369. foreach (DataRow dr in dt.Rows)
  1370. {
  1371. total += Convert.ToDecimal(dr["payment"]);
  1372. }
  1373. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1374. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1375. {
  1376. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1377. return;
  1378. }
  1379. }
  1380. }
  1381. if (entity.OrderState == -1)
  1382. {
  1383. returnErrorMsg("待审核订单无法领取!");
  1384. return;
  1385. }
  1386. entity.CustomerUserId = CurrentUser.UserID;
  1387. if (entity.OrderState < 2)
  1388. {
  1389. entity.OrderState = 2;
  1390. if (entity.ShopId != 0)
  1391. {
  1392. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1393. }
  1394. }
  1395. entity.UpdateTime = DateTime.Now;
  1396. entity.Update();
  1397. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1398. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1399. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1400. {
  1401. dataHelper.api_orderBack(entity.ctid, "0", "");
  1402. }
  1403. returnSuccessMsg("领单成功!");
  1404. return;
  1405. }
  1406. returnErrorMsg("找不到记录");
  1407. }
  1408. }
  1409. public void getmyorder_from_init()
  1410. {
  1411. if (UrlPostParmsCheck("ctid"))
  1412. {
  1413. string eid = GetPostString("ctid");
  1414. CeErpTradeCell entity = null;
  1415. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1416. if (entity != null)
  1417. {
  1418. string sellerMemo = GetPostString("sellerMemo");
  1419. if (sellerMemo.Length > 0)
  1420. {
  1421. entity.seller_memo = sellerMemo;
  1422. }
  1423. string oterhMemo = GetPostString("otherMemo");
  1424. if (oterhMemo.Length > 0)
  1425. {
  1426. entity.OtherMemo = oterhMemo;
  1427. }
  1428. int urg = GetPostInt("urgency");
  1429. entity.IsUrgency = (urg == 1 ? true : false);
  1430. int wechat = GetPostInt("wechat");
  1431. int command = GetPostInt("command");
  1432. if (wechat == 1)
  1433. {
  1434. entity.wechatTag = 1;
  1435. }
  1436. if (command == 1)
  1437. {
  1438. entity.wechatTag = 2;
  1439. }
  1440. string pPro = GetPostString("pprofession");
  1441. if (pPro.Length > 0)
  1442. {
  1443. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1444. string spro = GetPostString("profession");
  1445. if (spro.Length > 0)
  1446. {
  1447. entity.ProfessionId = Convert.ToInt32(spro);
  1448. }
  1449. }
  1450. string proId = GetPostString("productId");
  1451. if (proId.Length > 0)
  1452. {
  1453. entity.ProductId = Convert.ToInt32(proId);
  1454. }
  1455. entity.Material = GetPostString("material");
  1456. entity.Craft = GetPostString("craft");
  1457. entity.CustomerUserId = CurrentUser.UserID;
  1458. if (entity.OrderState < 2)
  1459. {
  1460. entity.OrderState = 2;
  1461. if (entity.ShopId != 0)
  1462. {
  1463. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1464. }
  1465. }
  1466. entity.Update();
  1467. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1468. returnSuccessMsg("领单成功!");
  1469. return;
  1470. }
  1471. returnErrorMsg("找不到记录");
  1472. }
  1473. }
  1474. public void upd_erp_setrelationorder()
  1475. {
  1476. if (UrlPostParmsCheck("ctid"))
  1477. {
  1478. ;
  1479. string eid = GetPostString("ctid");
  1480. string ftid = GetPostString("ftid");
  1481. CeErpTradeCell entity = null;
  1482. CeErpTradeCell fentity = null;
  1483. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1484. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1485. if (fentity == null)
  1486. {
  1487. returnErrorMsg("找不到关联的主订单");
  1488. return;
  1489. }
  1490. if (entity != null)
  1491. {
  1492. if (entity.OrderState >= 5)
  1493. {
  1494. returnErrorMsg("本单已经设计完成无法关联");
  1495. return;
  1496. }
  1497. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1498. {
  1499. returnErrorMsg("线下单续审核后才能关联!");
  1500. return;
  1501. }
  1502. entity.ptid = ftid;
  1503. entity.OrderState = fentity.OrderState;
  1504. //entity.status = fentity.status;
  1505. entity.CustomerUserId = fentity.CustomerUserId;
  1506. entity.DesignUserId = fentity.DesignUserId;
  1507. entity.seller_memo = "补差价单:" + ftid;
  1508. entity.IsSample = 2;
  1509. entity.Update();
  1510. ApiVo apiVo = new ApiVo();
  1511. apiVo.orderNumber = ftid;
  1512. apiVo.payment = entity.payment;
  1513. apiVo.actionName = "repairDesign";
  1514. designHelper.API_WorkCore(apiVo);//repairDesign
  1515. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1516. returnSuccessMsg("关联成功!");
  1517. return;
  1518. }
  1519. else
  1520. returnErrorMsg("找不到记录");
  1521. }
  1522. }
  1523. public void download_erp_neworder()
  1524. {
  1525. string seller = GetPostString("seller_nick");
  1526. string tid = GetPostString("tid");
  1527. if (seller.Length <= 0 || tid.Length <= 0)
  1528. {
  1529. returnErrorMsg("数据错误");
  1530. }
  1531. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1532. //{
  1533. // returnErrorMsg("找不到店铺Sessionkey");
  1534. //}
  1535. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1536. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1537. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1538. if (res.IndexOf("refOid") == -1)
  1539. {
  1540. returnErrorMsg("下载订单数据失败");
  1541. return;
  1542. }
  1543. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1544. returnSuccessMsg("下载完成");
  1545. //tmcHelper.createNewOrder(res);
  1546. //CeErpTrade entr = null;
  1547. //entr = CeErpTrade.Get(tid);
  1548. //if (entr != null)
  1549. //{
  1550. // returnSuccess("下载成功");
  1551. // //下载成功之后,Cell表生成对应的订单;
  1552. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1553. //}
  1554. //else
  1555. //{
  1556. // returnErrorMsg("下载失败或者创建订单失败");
  1557. //}
  1558. }
  1559. public void set_erp_atersale()
  1560. {
  1561. if (UrlPostParmsCheck("ctid"))
  1562. {
  1563. string eid = GetPostString("ctid");
  1564. string reason = GetPostString("AfterSaleReason");
  1565. CeErpTradeCell entity = null;
  1566. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1567. if (entity != null)
  1568. {
  1569. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1570. {
  1571. returnErrorMsg("此订单已经在售后");
  1572. return;
  1573. }*/
  1574. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1575. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1576. entity.AfterSaleTime = DateTime.Now;
  1577. entity.HandleTime = null;
  1578. entity.Update();
  1579. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1580. returnSuccessMsg("转售后成功!");
  1581. return;
  1582. }
  1583. returnErrorMsg("找不到记录");
  1584. }
  1585. }
  1586. public void set_erp_withdraw()
  1587. {
  1588. if (UrlPostParmsCheck("ctid"))
  1589. {
  1590. try
  1591. {
  1592. string eid = GetPostString("ctid");//商品id
  1593. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1594. CeWithdraw ceWithdrawSelect = null;
  1595. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1596. if (ceWithdrawSelect != null)
  1597. {
  1598. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1599. {
  1600. ceWithdrawSelect.status = -1;
  1601. ceWithdrawSelect.Update();
  1602. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1603. returnSuccessMsg("重新发起审核成功");
  1604. return;
  1605. }
  1606. else
  1607. {
  1608. returnSuccessMsg("请勿重复申请!");
  1609. return;
  1610. }
  1611. }
  1612. else
  1613. {
  1614. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1615. if (string.IsNullOrEmpty(CustomerUserId))
  1616. {
  1617. CustomerUserId = "-1";
  1618. }
  1619. int Userid = CurrentUser.UserID;//用户id
  1620. CeWithdraw ceWithdraw = new CeWithdraw();
  1621. ceWithdraw.tid = eid;
  1622. ceWithdraw.userid = Userid;
  1623. ceWithdraw.providerid = CustomerUserId;
  1624. ceWithdraw.status = 3;
  1625. ceWithdraw.creationtime = DateTime.Now;
  1626. ceWithdraw.Create();
  1627. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1628. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1629. return;
  1630. }
  1631. }
  1632. catch
  1633. {
  1634. returnErrorMsg("申请撤回订单失败");
  1635. return;
  1636. }
  1637. }
  1638. }
  1639. public void ins_erp_billinfo()
  1640. {
  1641. if (UrlPostParmsCheck("ctid"))
  1642. {
  1643. string eid = GetPostString("ctid");
  1644. CeErpTradeCell entity = null;
  1645. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1646. if (entity != null)
  1647. {
  1648. CeErpBill bill = CeErpBill.GetByTid(eid);
  1649. bool isHave = false;
  1650. if (bill != null)
  1651. {
  1652. isHave = true;
  1653. if (bill.state != 4)
  1654. {
  1655. returnErrorMsg("此单已经申请过发票了");
  1656. return;
  1657. }
  1658. }
  1659. if (entity.IsNeedBill == 0)
  1660. {
  1661. entity.IsNeedBill = 1;
  1662. }
  1663. entity.Update();
  1664. string errjson = "";
  1665. try
  1666. {
  1667. CeErpBill bill_entity = new CeErpBill();
  1668. bill_entity.tid = entity.tid;
  1669. bill_entity.title = GetPostString("title");
  1670. string taxstr = GetPostString("tax");
  1671. taxstr = taxstr.Replace(" ", "");
  1672. bill_entity.tax = taxstr;
  1673. bill_entity.bank = GetPostString("bank");
  1674. string bankacstr = GetPostString("bankac");
  1675. bankacstr = bankacstr.Replace(" ", "");
  1676. bill_entity.bankac = bankacstr;
  1677. bill_entity.address = GetPostString("address");
  1678. bill_entity.phone = GetPostString("phone");
  1679. bill_entity.price = GetPostString("price");
  1680. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1681. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1682. {
  1683. billCount += 1;
  1684. }
  1685. string prebill = "ltb";
  1686. for (int idx = 1; idx <= billCount; idx++)
  1687. {
  1688. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1689. string billoid = prebill + idx + dtstr;
  1690. bill_entity.billOrderId += billoid;
  1691. if (idx < billCount)
  1692. {
  1693. bill_entity.billOrderId += ",";
  1694. }
  1695. }
  1696. bill_entity.productId = GetPostInt("ProductName");
  1697. bill_entity.num = GetPostInt("num");
  1698. bill_entity.unit = GetPostString("unit");
  1699. bill_entity.type = GetPostString("type");
  1700. bill_entity.sendType = GetPostString("SendType");
  1701. bill_entity.email = GetPostString("email");
  1702. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1703. bill_entity.shopName = GetPostString("ShopName");
  1704. bill_entity.applymemo = GetPostString("applyMemo");
  1705. bill_entity.createTime = DateTime.Now;
  1706. bill_entity.state = 0;
  1707. bill_entity.userId = CurrentUser.UserID;
  1708. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1709. bill_entity.Create();
  1710. }
  1711. catch (Exception ex)
  1712. {
  1713. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1714. returnErrorMsg("创建发票出错!");
  1715. return;
  1716. }
  1717. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1718. returnSuccessMsg("发票申请成功!");
  1719. return;
  1720. }
  1721. returnErrorMsg("找不到记录");
  1722. }
  1723. }
  1724. public void ins_erp_neworder()
  1725. {
  1726. if (UrlPostParmsCheck("receiver_name"))
  1727. {
  1728. CeErpTrade entity = new CeErpTrade();
  1729. string plat_form = GetPostString("platform");
  1730. string preStr = "N_";
  1731. if (plat_form == "拼多多")
  1732. {
  1733. preStr = "P_";
  1734. }
  1735. else if (plat_form == "阿里巴巴")
  1736. {
  1737. preStr = "A_";
  1738. }
  1739. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1740. entity.seller_nick = GetPostString("seller_nick");
  1741. entity.buyer_nick = GetPostString("buyer_nick");
  1742. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1743. entity.total_fee = entity.payment;
  1744. entity.pay_time = DateTime.Now;
  1745. entity.status = "NOT_SHIPPED";
  1746. entity.receiver_name = GetPostString("receiver_name");
  1747. entity.receiver_mobile = GetPostString("receiver_mobile");
  1748. entity.receiver_state = GetPostString("receiver_state");
  1749. entity.receiver_city = GetPostString("receiver_city");
  1750. entity.receiver_district = GetPostString("receiver_district");
  1751. entity.receiver_address = GetPostString("receiver_address");
  1752. if (entity.receiver_state == "" || entity.receiver_city == "")
  1753. {
  1754. returnErrorMsg("收件地址不能为空");
  1755. return;
  1756. }
  1757. int shopId = 0;
  1758. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1759. if (nShop != null)
  1760. {
  1761. shopId = nShop.ID;
  1762. }
  1763. if (shopId != 34 && entity.payment == 0)
  1764. {
  1765. returnErrorMsg("公司自用的单金额才能为0");
  1766. return;
  1767. }
  1768. entity.Create();
  1769. CeErpTradeCell entitycell = new CeErpTradeCell();
  1770. entitycell.ctid = entity.tid;
  1771. entitycell.tid = entity.tid;
  1772. entitycell.ShopId = shopId;
  1773. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1774. entitycell.OrderState = 0;
  1775. entitycell.pay_time = entity.pay_time;
  1776. entitycell.IsOffLineOrder = 1;
  1777. entitycell.Create();
  1778. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1779. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1780. return;
  1781. }
  1782. }
  1783. public void ins_erp_neworder2()
  1784. {
  1785. if (UrlPostParmsCheck("receiver_name"))
  1786. {
  1787. //string plat_form = GetPostString("platform");
  1788. string preStr = "X_";
  1789. string memo = GetPostString("memo");
  1790. string productId = GetPostString("productId");
  1791. string primg = GetPostString("proofimg");
  1792. string sellerNick = GetPostString("seller_nick");
  1793. string addFrom = GetPostString("addfrom");
  1794. if (addFrom == "1")
  1795. {
  1796. preStr = "N_";
  1797. }
  1798. int shopId = 0;
  1799. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1800. if (nShop != null)
  1801. {
  1802. shopId = nShop.ID;
  1803. }
  1804. else
  1805. {
  1806. returnErrorMsg("找不到对应店铺");
  1807. return;
  1808. }
  1809. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1810. {
  1811. returnErrorMsg("必须上传付款凭证");
  1812. return;
  1813. }
  1814. CeErpTrade entity = new CeErpTrade();
  1815. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1816. entity.seller_nick = sellerNick;
  1817. entity.buyer_nick = GetPostString("buyer_nick");
  1818. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1819. entity.total_fee = entity.payment;
  1820. entity.pay_time = DateTime.Now;
  1821. entity.status = "NOT_SHIPPED";
  1822. entity.receiver_name = GetPostString("receiver_name");
  1823. entity.receiver_mobile = GetPostString("receiver_mobile");
  1824. entity.receiver_state = GetPostString("receiver_state");
  1825. entity.receiver_city = GetPostString("receiver_city");
  1826. entity.receiver_district = GetPostString("receiver_district");
  1827. entity.receiver_address = GetPostString("receiver_address");
  1828. entity.seller_memo = memo;
  1829. entity.orderFrom = 20;
  1830. entity.orderType = 15;
  1831. if (entity.receiver_state == "" || entity.receiver_city == "")
  1832. {
  1833. returnErrorMsg("收件地址不能为空");
  1834. return;
  1835. }
  1836. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1837. {
  1838. returnErrorMsg("公司自用的单金额才能为0");
  1839. return;
  1840. }
  1841. entity.Create();
  1842. string toWhere = GetPostString("towhere");
  1843. CeErpTradeCell entitycell = new CeErpTradeCell();
  1844. entitycell.ctid = entity.tid;
  1845. //唯一标识
  1846. entitycell.OrderSn = entity.tid;
  1847. string orderSn = dataHelper.getSaleOrderSn();
  1848. if (orderSn != "")
  1849. {
  1850. entitycell.OrderSn = orderSn;
  1851. }
  1852. entitycell.tid = entity.tid;
  1853. //if (preStr == "X_")
  1854. //{
  1855. entitycell.IsOffLineOrder = 1;
  1856. //}
  1857. entitycell.CustomerUserId = CurrentUser.UserID;
  1858. entitycell.PayProofImg = primg;
  1859. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1860. entitycell.ProductId = Convert.ToInt32(productId);
  1861. entitycell.ShopId = shopId;
  1862. entitycell.UpdateTime = DateTime.Now;
  1863. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1864. if (entitycell.ProductId > 0)
  1865. {
  1866. CeErpProduct ceErpProduct = CeErpProduct.GetById(entitycell.ProductId);
  1867. if (ceErpProduct.CreateTime != null && DateTime.Compare(ceErpProduct.CreateTime, DateTime.Now.AddDays(-90)) > 0)
  1868. {
  1869. entitycell.NewProduct = 1;
  1870. }
  1871. }
  1872. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1873. {
  1874. entitycell.IsXianHuo = 1;
  1875. }
  1876. entitycell.pay_time = entity.pay_time;
  1877. if (toWhere == "1")
  1878. {
  1879. entitycell.OrderState = 2;
  1880. }
  1881. else
  1882. {
  1883. entitycell.OrderState = 6;
  1884. entitycell.FinishPlaceTime = entitycell.pay_time;
  1885. }
  1886. if (shopId == 94)
  1887. {
  1888. entitycell.OrderState = 4;
  1889. entitycell.WaitDesignTime = entitycell.pay_time;
  1890. entitycell.StartDesignTime = entitycell.pay_time;
  1891. entitycell.DesignUserId = 218;
  1892. }
  1893. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1894. {
  1895. entitycell.OrderState = -1;//修改12-5
  1896. CeWithdraw ceWithdraw = new CeWithdraw();
  1897. ceWithdraw.tid = entity.tid;
  1898. ceWithdraw.providerid = "-1";
  1899. ceWithdraw.status = -1;
  1900. ceWithdraw.creationtime = DateTime.Now;
  1901. ceWithdraw.userid = 4634;
  1902. ceWithdraw.Create();
  1903. }
  1904. entitycell.Create();
  1905. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1906. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1907. {
  1908. addPlaceRegist(entitycell, CurrentUser.UserID);
  1909. }
  1910. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1911. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1912. return;
  1913. }
  1914. }
  1915. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1916. {
  1917. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1918. entity.PlactTime = tradecell.pay_time;
  1919. entity.AddUserId = userid;
  1920. entity.FileName = tradecell.seller_memo;
  1921. entity.Supplier = 24;
  1922. entity.CreateTime = DateTime.Now;
  1923. entity.Did = tradecell.ctid;
  1924. entity.tid = tradecell.tid;
  1925. entity.splitTag = tradecell.SplitTag;
  1926. entity.CurState = "未完成";
  1927. entity.Create();
  1928. }
  1929. public void get_erp_offlinelist()
  1930. {
  1931. DataStruct dStruct = GetPostStruct();
  1932. List<string> lw = new List<string>();
  1933. string tid = GetPostString("ctid");
  1934. string date1 = GetPostString("date1");
  1935. string date2 = GetPostString("date2");
  1936. if (tid.Length > 0 || date1.Length > 0)
  1937. {
  1938. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1939. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1940. if (dw.Length > 0) lw.Add(dw);
  1941. }
  1942. else
  1943. {
  1944. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1945. }
  1946. string shopname = GetPostString("shopname");
  1947. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1948. string buyernick = GetPostString("buyer_nick");
  1949. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1950. string customer = GetPostString("customer");
  1951. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1952. string design = GetPostString("design");
  1953. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1954. string orderState = GetPostString("orderState");
  1955. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1956. string address = GetPostString("address");
  1957. 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));
  1958. string sellermemo = GetPostString("seller_memo");
  1959. if (sellermemo.Length > 0)
  1960. {
  1961. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1962. }
  1963. string price1 = GetPostString("price1");
  1964. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1965. string price2 = GetPostString("price2");
  1966. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1967. //if (PKey != "admin")
  1968. //{
  1969. // string usershop = CurrentUser.User.pemShop;
  1970. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1971. //}
  1972. //if (ex_psize > 0)
  1973. //{
  1974. dStruct.Order = "pay_time desc";
  1975. //}
  1976. //else
  1977. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1978. lw.Add(string.Format("IsOffLineOrder=1"));
  1979. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1980. DataTable dt = null;
  1981. dt = WebCache.GetData("view_erptradecell", dStruct);
  1982. writeGridDataTableJson(dStruct.TotalCount, dt);
  1983. }
  1984. public void get_erp_returncashrecord()
  1985. {
  1986. DataStruct dStruct = GetPostStruct();
  1987. List<string> lw = new List<string>();
  1988. string tid = GetPostString("ctid");
  1989. if (tid.Length > 0)
  1990. {
  1991. lw.Add(string.Format("tid like '%{0}%'", tid));
  1992. dStruct.Order = "id desc";
  1993. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1994. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1995. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1996. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1997. return;
  1998. }
  1999. returnErrorMsg("id数据错误!");
  2000. }
  2001. public void ins_erp_returncashrecord()
  2002. {
  2003. if (UrlPostParmsCheck("tid"))
  2004. {
  2005. string tid = GetPostString("tid");
  2006. string retype = GetPostString("type");
  2007. StringBuilder sql = new StringBuilder();
  2008. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  2009. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2010. if (dt.Rows.Count > 0)
  2011. {
  2012. returnErrorMsg("相同返现类型记录已存在");
  2013. return;
  2014. }
  2015. CeErpReturnCash entity = new CeErpReturnCash();
  2016. entity.tid = tid;
  2017. entity.seller_nick = GetPostString("seller_nick");
  2018. string pment = GetPostString("payment");
  2019. if (pment.Length > 0)
  2020. {
  2021. entity.payment = Convert.ToDouble(pment);
  2022. }
  2023. entity.buyer_nick = GetPostString("buyer_nick");
  2024. entity.cashstate = 0;
  2025. entity.rtype = retype;
  2026. string rPrice = GetPostString("returnprice");
  2027. if (rPrice.Length > 0)
  2028. {
  2029. entity.returnprice = Convert.ToDouble(rPrice);
  2030. }
  2031. entity.created = DateTime.Now;
  2032. entity.con = GetPostString("con");
  2033. entity.img = GetPostString("img");
  2034. entity.applyuserid = CurrentUser.UserID;
  2035. entity.Create();
  2036. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  2037. returnSuccessMsg("操作成功!");
  2038. return;
  2039. }
  2040. }
  2041. public void set_erp_predelivery()
  2042. {
  2043. if (UrlPostParmsCheck("ctid"))
  2044. {
  2045. string eid = GetPostString("ctid");
  2046. CeErpTradeCell entity = null;
  2047. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2048. if (entity != null)
  2049. {
  2050. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2051. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2052. //{
  2053. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2054. // return;
  2055. //}
  2056. entity.IsPreDelivery = 1;
  2057. entity.Update();
  2058. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2059. returnSuccessMsg("预发货成功!");
  2060. return;
  2061. //string shop = GetPostString("seller_nick");
  2062. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2063. //string comName = GetPostString("comName");
  2064. //string comCode = GetPostString("comCode");
  2065. //string outSid = GetPostString("outSid");//运单号
  2066. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2067. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2068. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2069. //string apires = "";
  2070. //if (deliveryType == "虚拟发货")
  2071. //{
  2072. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2073. //}
  2074. //else
  2075. //{
  2076. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2077. //}
  2078. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2079. ////{
  2080. //if (apires.IndexOf("发货成功") != -1)
  2081. //{
  2082. // if (deliveryType != "虚拟发货")
  2083. // {
  2084. // //还要插入快递信息到 快递信息表
  2085. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2086. // exinfo.tid = eid;
  2087. // exinfo.out_sid = outSid;
  2088. // exinfo.company_code = comCode;
  2089. // exinfo.company_name = comName;
  2090. // exinfo.delivery_memo = deliveryMemo;
  2091. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2092. // exinfo.deliveryType = deliveryType;
  2093. // exinfo.Create();
  2094. // }
  2095. // returnSuccessMsg("发货成功!");
  2096. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2097. //}
  2098. //else
  2099. //{
  2100. // returnErrorMsg("淘宝发货失败!!");
  2101. //}
  2102. //return;
  2103. }
  2104. returnErrorMsg("找不到订单记录");
  2105. }
  2106. }
  2107. public void get_erp_unusuallist()
  2108. {
  2109. DataStruct dStruct = GetPostStruct();
  2110. List<string> lw = new List<string>();
  2111. string tid = GetPostString("ctid");
  2112. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2113. string shopname = GetPostString("shopname");
  2114. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2115. string buyernick = GetPostString("buyer_nick");
  2116. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2117. string ResponsibleMan = GetPostString("responsible");
  2118. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2119. string date1 = GetPostString("date1");
  2120. string date2 = GetPostString("date2");
  2121. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2122. if (dw.Length > 0) lw.Add(dw);
  2123. string price1 = GetPostString("price1");
  2124. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2125. string price2 = GetPostString("price2");
  2126. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2127. string orderState = GetPostString("orderState");
  2128. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2129. string sellermemo = GetPostString("seller_memo");
  2130. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2131. lw.Add(string.Format("UnusualTag > 0"));
  2132. lw.Add(string.Format("IsRefund<={0}", 1));
  2133. dStruct.Order = "pay_time desc";
  2134. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2135. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2136. writeGridDataTableJson(dStruct.TotalCount, dt);
  2137. }
  2138. public void set_erp_unusualtonomal()
  2139. {
  2140. if (UrlPostParmsCheck("ctid"))
  2141. {
  2142. string eid = GetPostString("ctid");
  2143. CeErpTradeCell entity = null;
  2144. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2145. if (entity != null)
  2146. {
  2147. entity.UnusualTag = -1;
  2148. entity.Update();
  2149. returnSuccessMsg("忽略成功!");
  2150. return;
  2151. }
  2152. returnErrorMsg("找不到记录");
  2153. }
  2154. }
  2155. public void ins_erp_unusualreason()
  2156. {
  2157. if (UrlPostParmsCheck("ctid"))
  2158. {
  2159. string eid = GetPostString("ctid");
  2160. CeErpTradeCell entity = null;
  2161. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2162. if (entity != null)
  2163. {
  2164. entity.MemoOpt = 4;
  2165. entity.UnusualCon = GetPostString("con");
  2166. entity.Update();
  2167. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2168. if (trade != null)
  2169. {
  2170. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2171. }
  2172. //查货是否超时
  2173. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2174. if (ceErpTradeCellExtend == null)
  2175. {
  2176. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2177. ceErpTradeCellExtend.ctid = entity.ctid;
  2178. }
  2179. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2180. {
  2181. ceErpTradeCellExtend.CheckOut += 1;
  2182. }
  2183. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2184. if (ceErpTradeCellExtend.ID > 0)
  2185. {
  2186. ceErpTradeCellExtend.Update();
  2187. }
  2188. else
  2189. {
  2190. ceErpTradeCellExtend.Create();
  2191. }
  2192. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2193. returnSuccessMsg("操作成功!");
  2194. return;
  2195. }
  2196. returnErrorMsg("找不到记录");
  2197. }
  2198. }
  2199. public void upd_erp_sampleorder()
  2200. {
  2201. if (UrlPostParmsCheck("ctid"))
  2202. {
  2203. string eid = GetPostString("ctid");
  2204. string[] eArr = eid.Split(',');
  2205. if (eArr.Length > 1)
  2206. {
  2207. List<string> eLst = new List<string>();
  2208. for (int i = 0; i < eArr.Length; i++)
  2209. {
  2210. eLst.Add("'" + eArr[i] + "'");
  2211. }
  2212. eid = string.Join(",", eLst.ToArray());
  2213. }
  2214. else
  2215. {
  2216. eid = "'" + eid + "'";
  2217. }
  2218. StringBuilder sql = new StringBuilder();
  2219. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2220. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2221. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2222. if (dt.Rows.Count > 0)
  2223. {
  2224. string errmsg = "";
  2225. foreach (DataRow dr in dt.Rows)
  2226. {
  2227. StringBuilder sqlsb = new StringBuilder();
  2228. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2229. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2230. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2231. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2232. //string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2233. /*if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2234. {
  2235. continue;
  2236. }
  2237. else
  2238. {
  2239. string emsg = commonHelper.KeepChinese(apires);
  2240. errmsg += emsg;
  2241. }*/
  2242. }
  2243. if (errmsg.Length > 0)
  2244. {
  2245. returnErrorMsg(errmsg);
  2246. return;
  2247. }
  2248. returnSuccessMsg("操作成功");
  2249. return;
  2250. }
  2251. returnErrorMsg("找不到记录");
  2252. }
  2253. }
  2254. public void upd_erp_transcustomer()
  2255. {
  2256. if (UrlPostParmsCheck("ctid"))
  2257. {
  2258. string eid = GetPostString("ctid");
  2259. int userid = GetPostInt("CustomerUserId");
  2260. CeErpTradeCell entity = null;
  2261. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2262. if (entity != null)
  2263. {
  2264. //string[] mlist = entity.seller_memo.Split('-');
  2265. //string sql = "select * from view_erpuser where id=" + userid;
  2266. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2267. //if (dt != null && dt.Rows.Count > 0)
  2268. //{
  2269. // string nmemo = "";
  2270. // for(int i = 0; i < mlist.Length - 1; i++)
  2271. // {
  2272. // nmemo += mlist[i];
  2273. // nmemo += "-";
  2274. // }
  2275. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2276. // entity.seller_memo = nmemo;
  2277. //}
  2278. entity.CustomerUserId = userid;
  2279. entity.Update();
  2280. returnSuccessMsg("操作成功!");
  2281. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2282. return;
  2283. }
  2284. returnErrorMsg("找不到记录");
  2285. }
  2286. }
  2287. public void upd_erp_transdesigner()
  2288. {
  2289. if (UrlPostParmsCheck("ctid"))
  2290. {
  2291. string eids = GetPostString("ctid");
  2292. string[] ctidList = eids.Split(',');
  2293. int userid = GetPostInt("DesignUserId");
  2294. foreach (string ctid in ctidList)
  2295. {
  2296. CeErpTradeCell entity = null;
  2297. CeErpDesignerBill entitys = null;
  2298. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2299. entitys = CeErpDesignerBill.GetByTid(ctid);
  2300. if (entity != null)
  2301. {
  2302. if (entity.OrderState > 4)
  2303. {
  2304. continue;
  2305. }
  2306. //存在退款不能流转
  2307. if (entity.IsRefund > 0)
  2308. {
  2309. continue;
  2310. }
  2311. entity.DesignUserId = userid;
  2312. entity.WaitDesignTime = DateTime.Now;
  2313. entity.Update();
  2314. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2315. }
  2316. }
  2317. returnSuccessMsg("操作成功!");
  2318. }
  2319. }
  2320. public void upd_erp_distributedesigner()
  2321. {
  2322. if (UrlPostParmsCheck("ctid"))
  2323. {
  2324. string eid = GetPostString("ctid");
  2325. int userid = GetPostInt("DesignUserId");
  2326. string[] idlist = eid.Split(',');
  2327. if (idlist.Length <= 0)
  2328. {
  2329. returnErrorMsg("订单不能为空");
  2330. return;
  2331. }
  2332. foreach (string ctid in idlist)
  2333. {
  2334. CeErpTradeCell entity = null;
  2335. CeErpDesignerBill entitys = null;
  2336. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2337. else continue;
  2338. if (entity != null)
  2339. {
  2340. if (userid == 2125 || userid == 3542)
  2341. { }
  2342. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2343. {
  2344. returnErrorMsg("金额错误的订单无法指派");
  2345. return;
  2346. }
  2347. if (entity.OrderState >= 5)
  2348. {
  2349. returnErrorMsg("已经设计完成无法指派");
  2350. return;
  2351. }
  2352. if (entity.OrderState == -1)
  2353. {
  2354. returnErrorMsg("审核中的订单无法指派");
  2355. return;
  2356. }
  2357. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2358. {
  2359. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2360. return;
  2361. }
  2362. //157赖橙帆 159林晨 73 静之颖
  2363. 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)
  2364. {
  2365. returnErrorMsg("指派设计共创无法再次指派!");
  2366. return;
  2367. }
  2368. entity.OrderState = 3;
  2369. if (entity.SupplierId == 0)
  2370. {
  2371. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2372. entity.SupplierId = suid;
  2373. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2374. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2375. }
  2376. if (userid == 2125 && entity.seller_memo != "")
  2377. {
  2378. apiDesign.API_GetPrintData_CreateOrder(entity);
  2379. }
  2380. if (userid == 3542 && entity.seller_memo != "")
  2381. {
  2382. string userPost = CurrentUser.UserPost.Post.Code;
  2383. if (CurrentUser.UserID == 73)
  2384. {
  2385. userPost = "SysAdmin";
  2386. }
  2387. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2388. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2389. if (response.msg != "设计共创:成功")
  2390. {
  2391. returnErrorMsg(response.msg);
  2392. return;
  2393. }
  2394. entity.DispatchSort = 2;
  2395. }
  2396. else
  2397. {
  2398. if (entity.DispatchSort == 2)
  2399. {
  2400. ApiVo apiVo = new ApiVo();
  2401. apiVo.actionName = "closeDesign";
  2402. apiVo.orderNumber = entity.ctid;
  2403. designHelper.API_WorkCore(apiVo);//closeDesign
  2404. }
  2405. entity.DispatchSort = 0;
  2406. }
  2407. entity.DesignUserId = userid;
  2408. entity.WaitDesignTime = DateTime.Now;
  2409. entity.UpdateTime = DateTime.Now;
  2410. entity.Update();
  2411. string name = commonHelper.getUserNameById(userid);
  2412. commonHelper.UpdateRelationOrder(entity.ctid);
  2413. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2414. }
  2415. }
  2416. returnSuccessMsg("操作成功!");
  2417. return;
  2418. }
  2419. }
  2420. public string getTidByCtid(string ctid)
  2421. {
  2422. string tid = "";
  2423. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2424. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2425. if (dataTable != null && dataTable.Rows.Count > 0)
  2426. {
  2427. tid = dataTable.Rows[0]["tid"].ToString();
  2428. }
  2429. return tid;
  2430. }
  2431. public List<string> getTidByCtidMore(string ctid)
  2432. {
  2433. 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);
  2434. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2435. List<string> list = new List<string>();
  2436. if (dataTable != null && dataTable.Rows.Count > 0)
  2437. {
  2438. foreach (DataRow item in dataTable.Rows)
  2439. {
  2440. list.Add("'" + item["tid"].ToString() + "'");
  2441. }
  2442. }
  2443. return list;
  2444. }
  2445. public List<string> getTidByCtidLike(string ctid)
  2446. {
  2447. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2448. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2449. List<string> list = new List<string>();
  2450. if (dataTable != null && dataTable.Rows.Count > 0)
  2451. {
  2452. foreach (DataRow item in dataTable.Rows)
  2453. {
  2454. list.Add("'" + item["tid"].ToString() + "'");
  2455. }
  2456. }
  2457. return list;
  2458. }
  2459. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2460. {
  2461. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2462. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2463. List<string> list = new List<string>();
  2464. if (dataTable != null && dataTable.Rows.Count > 0)
  2465. {
  2466. foreach (DataRow item in dataTable.Rows)
  2467. {
  2468. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2469. {
  2470. continue;
  2471. }
  2472. list.Add("'" + item["receiverId"].ToString() + "'");
  2473. }
  2474. }
  2475. return list;
  2476. }
  2477. public void get_erp_myorderlist()
  2478. {
  2479. DataStruct dStruct = GetPostStruct();
  2480. List<string> lw = new List<string>();
  2481. string tid = GetPostString("ctid");
  2482. if (tid.Length > 0)
  2483. {
  2484. string select_tid = getTidByCtid(tid);
  2485. lw.Add(string.Format("tid='{0}'", select_tid));
  2486. }
  2487. else
  2488. {
  2489. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2490. }
  2491. //12-1 修改
  2492. string urgent = GetPostString("urgent");
  2493. string back = GetPostString("back");
  2494. string offlineSearch = GetPostString("offlineSearch");
  2495. if (!string.IsNullOrWhiteSpace(urgent))
  2496. {
  2497. if (urgent.Equals("true"))
  2498. {
  2499. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2500. }
  2501. }
  2502. if (!string.IsNullOrWhiteSpace(back))
  2503. {
  2504. if (back.Equals("true"))
  2505. {
  2506. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2507. }
  2508. }
  2509. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2510. {
  2511. if (offlineSearch.Equals("true"))
  2512. {
  2513. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2514. }
  2515. }
  2516. //end
  2517. string shopname = GetPostString("shopname");
  2518. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2519. string buyernick = GetPostString("buyer_nick");
  2520. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2521. string design = GetPostString("design");
  2522. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2523. string orderState = GetPostString("orderState");
  2524. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2525. string sellermemo = GetPostString("seller_memo");
  2526. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2527. string date1 = GetPostString("date1");
  2528. string date2 = GetPostString("date2");
  2529. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2530. if (dw.Length > 0) lw.Add(dw);
  2531. string price1 = GetPostString("price1");
  2532. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2533. string price2 = GetPostString("price2");
  2534. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2535. string urgency = GetPostString("urgency");
  2536. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2537. string after = GetPostString("after");
  2538. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2539. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2540. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2541. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2542. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2543. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2544. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2545. if (dt != null && dt.Rows.Count > 0)
  2546. {
  2547. foreach (DataRow dr in dt.Rows)
  2548. {
  2549. try
  2550. {
  2551. // 对象操作
  2552. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2553. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2554. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2555. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2556. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2557. if (dStruct.PageSize != 100000)
  2558. {
  2559. if (dr["DispatchSort"].ToString() == "2")
  2560. {
  2561. dr["gongchuang"] = 200;
  2562. }
  2563. else if ("外协".Equals(dr["ToType"].ToString()))
  2564. {
  2565. dr["gongchuang"] = 200;
  2566. }
  2567. else if ("内部".Equals(dr["ToType"].ToString()))
  2568. {
  2569. dr["gongchuang"] = -1;
  2570. }
  2571. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2572. {
  2573. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2574. dr["gongchuang"] = response.code;
  2575. }
  2576. }
  2577. }
  2578. catch (NullReferenceException ex)
  2579. {
  2580. }
  2581. }
  2582. }
  2583. writeGridDataTableJson(dStruct.TotalCount, dt);
  2584. }
  2585. public void get_erp_myreturnorderlist()
  2586. {
  2587. DataStruct dStruct = GetPostStruct();
  2588. List<string> lw = new List<string>();
  2589. string tid = GetPostString("ctid");
  2590. if (tid.Length > 0)
  2591. {
  2592. string select_tid = getTidByCtid(tid);
  2593. lw.Add(string.Format("tid='{0}'", select_tid));
  2594. }
  2595. else
  2596. {
  2597. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2598. }
  2599. string shopname = GetPostString("shopname");
  2600. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2601. string buyernick = GetPostString("buyer_nick");
  2602. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2603. string design = GetPostString("design");
  2604. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2605. string orderState = GetPostString("orderState");
  2606. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2607. string sellermemo = GetPostString("seller_memo");
  2608. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2609. string date1 = GetPostString("date1");
  2610. string date2 = GetPostString("date2");
  2611. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2612. if (dw.Length > 0) lw.Add(dw);
  2613. string price1 = GetPostString("price1");
  2614. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2615. string price2 = GetPostString("price2");
  2616. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2617. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2618. {
  2619. lw.Add(string.Format("CusOrgID = 94"));
  2620. }
  2621. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2622. {
  2623. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2624. }
  2625. else
  2626. {
  2627. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2628. }
  2629. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2630. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2631. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2632. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2633. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2634. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2635. if (dt != null && dt.Rows.Count > 0)
  2636. {
  2637. foreach (DataRow dr in dt.Rows)
  2638. {
  2639. try
  2640. {
  2641. // 对象操作
  2642. if (dStruct.PageSize != 100000)
  2643. {
  2644. if (dr["DispatchSort"].ToString() == "2")
  2645. {
  2646. dr["gongchuang"] = 200;
  2647. }
  2648. else if ("外协".Equals(dr["ToType"].ToString()))
  2649. {
  2650. dr["gongchuang"] = 200;
  2651. }
  2652. else if ("内部".Equals(dr["ToType"].ToString()))
  2653. {
  2654. dr["gongchuang"] = -1;
  2655. }
  2656. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2657. {
  2658. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2659. dr["gongchuang"] = response.code;
  2660. }
  2661. }
  2662. }
  2663. catch (NullReferenceException ex)
  2664. {
  2665. // 处理空引用异常
  2666. }
  2667. }
  2668. }
  2669. writeGridDataTableJson(dStruct.TotalCount, dt);
  2670. }
  2671. public void get_erp_myorderlist_pregather()
  2672. {
  2673. string date1 = GetPostString("date1");
  2674. string date2 = GetPostString("date2");
  2675. int userId = CurrentUser.UserID; //客服id
  2676. string orderWhere = "";
  2677. List<string> lw = new List<string>();
  2678. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2679. if (dw.Length > 0) lw.Add(dw);
  2680. lw.Add(string.Format("CustomerUserId={0}", userId));
  2681. lw.Add(string.Format("OrderState<9"));
  2682. orderWhere = string.Join(" and ", lw.ToArray());
  2683. string orderWhere2 = "";
  2684. List<string> lw2 = new List<string>();
  2685. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2686. if (dw2.Length > 0) lw2.Add(dw2);
  2687. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2688. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2689. string sql = string.Format("select *" +
  2690. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2691. "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 " +
  2692. "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 " +
  2693. "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");
  2694. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2695. //writeGridDataTableJson(dt.Rows.Count, dt);
  2696. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2697. }
  2698. public void upd_erp_publishorder()
  2699. {
  2700. if (UrlPostParmsCheck("ctid"))
  2701. {
  2702. string eid = GetPostString("ctid");
  2703. CeErpTradeCell entity = null;
  2704. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2705. if (entity != null)
  2706. {
  2707. entity.OrderState = 0; //发布后,变为待抢单
  2708. entity.Update();
  2709. commonHelper.UpdateRelationOrder(entity.ctid);
  2710. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2711. returnSuccessMsg("发布成功!");
  2712. return;
  2713. }
  2714. returnErrorMsg("找不到记录");
  2715. }
  2716. }
  2717. public void get_erp_my_tiporder()
  2718. {
  2719. StringBuilder sql = new StringBuilder();
  2720. int userId = 0;
  2721. if (CurrentUser != null) userId = CurrentUser.UserID;
  2722. string posCode = CurrentUser.UserPost.Post.Code;
  2723. string isTipedAfterSaleVerify = GetPostString("af");
  2724. DataTable dt = new DataTable();
  2725. if (posCode != "Supplier")
  2726. {
  2727. if (posCode == "CustomerService" || posCode == "Director")
  2728. {
  2729. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2730. }
  2731. else if (posCode == "Place" || posCode == "PlaceMr")
  2732. {
  2733. }
  2734. else
  2735. {
  2736. string teamIds = CurrentUser.User.TeamIds;
  2737. if (teamIds == "")
  2738. {
  2739. teamIds = "0";
  2740. }
  2741. 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);
  2742. }
  2743. if (sql.Length > 0)
  2744. {
  2745. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2746. }
  2747. }
  2748. if (dt.Rows.Count <= 0)
  2749. {
  2750. string key = "aftersale_order_" + userId;
  2751. if (RedisHelper.HasKey(key))
  2752. {
  2753. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2754. dt.Columns.Add("ctid", typeof(string));
  2755. dt.Columns.Add("IsReadTag", typeof(int));
  2756. foreach (var i in list)
  2757. {
  2758. DataRow data = dt.NewRow();
  2759. data["ctid"] = i;
  2760. data["IsReadTag"] = 4;
  2761. dt.Rows.Add(data);
  2762. }
  2763. RedisHelper.StringDelete(key);
  2764. }
  2765. }
  2766. if (dt.Rows.Count <= 0)
  2767. {
  2768. sql = new StringBuilder();
  2769. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2770. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2771. }
  2772. if (posCode == "Supplier")
  2773. {
  2774. string ids = CurrentUser.User.pemVend;
  2775. if (ids != null && ids.Length > 0)
  2776. {
  2777. string[] ids_list = ids.Split(',');
  2778. foreach (var item in ids_list)
  2779. {
  2780. string key = "return_order_" + item;
  2781. if (RedisHelper.HasKey(key))
  2782. {
  2783. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2784. dt.Columns.Add("ctid", typeof(string));
  2785. dt.Columns.Add("IsReadTag", typeof(int));
  2786. foreach (var i in list)
  2787. {
  2788. DataRow data = dt.NewRow();
  2789. data["ctid"] = i;
  2790. data["IsReadTag"] = 1;
  2791. dt.Rows.Add(data);
  2792. }
  2793. RedisHelper.StringDelete(key);
  2794. }
  2795. }
  2796. }
  2797. if (dt.Rows.Count <= 0)
  2798. {
  2799. sql = new StringBuilder();
  2800. 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);
  2801. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2802. }
  2803. }
  2804. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2805. }
  2806. public void reset_erp_tiporder()
  2807. {
  2808. string ids = GetPostString("ids");
  2809. string[] ctidList = ids.Split(',');
  2810. foreach (string ctid in ctidList)
  2811. {
  2812. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2813. if (enty != null)
  2814. {
  2815. enty.IsReadTag = 0;
  2816. enty.Update();
  2817. }
  2818. }
  2819. returnSuccessMsg("成功!");
  2820. return;
  2821. }
  2822. public void get_erp_designlist()
  2823. {
  2824. DataStruct dStruct = GetPostStruct();
  2825. List<string> lw = new List<string>();
  2826. string tid = GetPostString("ctid");
  2827. if (tid.Length > 0)
  2828. {
  2829. string select_tid = getTidByCtid(tid);
  2830. lw.Add(string.Format("tid='{0}'", select_tid));
  2831. }
  2832. string shopname = GetPostString("shopname");
  2833. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2834. string buyernick = GetPostString("buyer_nick");
  2835. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2836. string customer = GetPostString("customer");
  2837. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2838. string design = GetPostString("design");
  2839. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2840. string orderState = GetPostString("orderState");
  2841. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2842. lw.Add(string.Format("OrderState<6"));
  2843. string address = GetPostString("address");
  2844. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2845. string sellermemo = GetPostString("seller_memo");
  2846. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2847. string date1 = GetPostString("date1");
  2848. string date2 = GetPostString("date2");
  2849. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2850. if (dw.Length > 0) lw.Add(dw);
  2851. string apdate1 = GetPostString("apdate1");
  2852. string apdate2 = GetPostString("apdate2");
  2853. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2854. if (dwap.Length > 0) lw.Add(dwap);
  2855. string price1 = GetPostString("price1");
  2856. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2857. string price2 = GetPostString("price2");
  2858. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2859. string designTime = GetPostString("designtime");
  2860. if (designTime.Length > 0)
  2861. {
  2862. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2863. }
  2864. string usershop = CurrentUser.User.pemShop;
  2865. if (usershop.Length > 0)
  2866. {
  2867. lw.Add(string.Format("shopId in ({0})", usershop));
  2868. }
  2869. int myOrgid = CurrentUser.UserPost.OrgID;
  2870. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2871. if (myOrgCode.IndexOf("Designer") != -1)
  2872. {
  2873. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2874. {
  2875. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2876. }
  2877. else
  2878. {
  2879. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2880. }
  2881. }
  2882. else
  2883. {
  2884. string orgId = GetPostString("designerhd");
  2885. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2886. }
  2887. if (tid.Length > 0 || buyernick.Length > 0)
  2888. {
  2889. lw.Add(string.Format("OrderState >= 3"));
  2890. }
  2891. else
  2892. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2893. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2894. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2895. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2896. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2897. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2898. if (dt != null && dt.Rows.Count > 0)
  2899. {
  2900. foreach (DataRow dr in dt.Rows)
  2901. {
  2902. try
  2903. {
  2904. // 对象操作
  2905. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2906. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2907. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2908. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2909. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2910. if (dStruct.PageSize != 100000)
  2911. {
  2912. if (dr["DispatchSort"].ToString() == "2")
  2913. {
  2914. dr["gongchuang"] = 200;
  2915. }
  2916. else if ("外协".Equals(dr["ToType"].ToString()))
  2917. {
  2918. dr["gongchuang"] = 200;
  2919. }
  2920. else if ("内部".Equals(dr["ToType"].ToString()))
  2921. {
  2922. dr["gongchuang"] = -1;
  2923. }
  2924. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2925. {
  2926. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2927. dr["gongchuang"] = response.code;
  2928. }
  2929. }
  2930. }
  2931. catch (NullReferenceException ex)
  2932. {
  2933. }
  2934. }
  2935. }
  2936. writeGridDataTableJson(dStruct.TotalCount, dt);
  2937. }
  2938. public void get_erp_mydesignlist()
  2939. {
  2940. DataStruct dStruct = GetPostStruct();
  2941. List<string> lw = new List<string>();
  2942. string tid = GetPostString("ctid");
  2943. if (tid.Length > 0)
  2944. {
  2945. string select_tid = getTidByCtid(tid);
  2946. lw.Add(string.Format("tid='{0}'", select_tid));
  2947. }
  2948. string shopname = GetPostString("shopname");
  2949. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2950. string buyernick = GetPostString("buyer_nick");
  2951. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2952. string customer = GetPostString("customer");
  2953. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2954. string orderState = GetPostString("orderState");
  2955. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2956. //lw.Add(string.Format("OrderState<6"));
  2957. string date1 = GetPostString("date1");
  2958. string date2 = GetPostString("date2");
  2959. string dw = GetDateWhere("pay_time", date1, date2);
  2960. if (dw.Length > 0) lw.Add(dw);
  2961. string apdate1 = GetPostString("apdate1");
  2962. string apdate2 = GetPostString("apdate2");
  2963. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2964. if (dwap.Length > 0) lw.Add(dwap);
  2965. string price1 = GetPostString("price1");
  2966. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2967. string price2 = GetPostString("price2");
  2968. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2969. string olddownload = GetPostString("olddown");
  2970. if (olddownload == "1")
  2971. {
  2972. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2973. }
  2974. else if (olddownload == "2")
  2975. {
  2976. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2977. }
  2978. string sellermemo = GetPostString("seller_memo");
  2979. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2980. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2981. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2982. {
  2983. if (CurrentUser.User.TeamIds.Length > 0)
  2984. {
  2985. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2986. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2987. else
  2988. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2989. }
  2990. else
  2991. {
  2992. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2993. }
  2994. }
  2995. if (tid.Length <= 0)
  2996. {
  2997. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2998. }
  2999. lw.Add(string.Format("IsReturn!=3"));
  3000. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  3001. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3002. string teamids = CurrentUser.User.TeamIds.ToString();
  3003. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3004. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  3005. if (dt != null && dt.Rows.Count > 0)
  3006. {
  3007. foreach (DataRow dr in dt.Rows)
  3008. {
  3009. try
  3010. {
  3011. // 对象操作
  3012. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  3013. ceErpTradeCell.ctid = dr["ctid"].ToString();
  3014. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  3015. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  3016. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  3017. if (dStruct.PageSize != 100000)
  3018. {
  3019. if (dr["DispatchSort"].ToString() == "2")
  3020. {
  3021. dr["gongchuang"] = 200;
  3022. }
  3023. else if ("外协".Equals(dr["ToType"].ToString()))
  3024. {
  3025. dr["gongchuang"] = 200;
  3026. }
  3027. else if ("内部".Equals(dr["ToType"].ToString()))
  3028. {
  3029. dr["gongchuang"] = -1;
  3030. }
  3031. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  3032. {
  3033. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  3034. dr["gongchuang"] = response.code;
  3035. }
  3036. }
  3037. }
  3038. catch (NullReferenceException ex)
  3039. {
  3040. }
  3041. }
  3042. }
  3043. writeGridDataTableJson(dStruct.TotalCount, dt);
  3044. }
  3045. public void set_erp_startdesign()
  3046. {
  3047. if (UrlPostParmsCheck("ctid"))
  3048. {
  3049. string eid = GetPostString("ctid");
  3050. CeErpTradeCell entity = null;
  3051. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3052. if (entity != null)
  3053. {
  3054. if (entity.OrderState != 3)
  3055. {
  3056. returnErrorMsg("请刷新,订单已经设计了");
  3057. return;
  3058. }
  3059. entity.StartDesignTime = DateTime.Now;
  3060. entity.OrderState = 4;
  3061. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3062. {
  3063. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3064. entity.SupplierId = suid;
  3065. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3066. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3067. }
  3068. entity.UpdateTime = DateTime.Now;
  3069. //entity.MakeSupplier = suname;
  3070. entity.Update();
  3071. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3072. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3073. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3074. commonHelper.getCytPrice(entity);
  3075. returnSuccessMsg("操作成功!");
  3076. return;
  3077. }
  3078. returnErrorMsg("找不到记录");
  3079. }
  3080. }
  3081. public void ins_erp_designselfmemo()
  3082. {
  3083. if (UrlPostParmsCheck("ctid"))
  3084. {
  3085. string eid = GetPostString("ctid");
  3086. string con = GetPostString("con");
  3087. CeErpTradeCell entity = null;
  3088. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3089. if (entity != null)
  3090. {
  3091. entity.DesignSelfMemo = con;
  3092. entity.Update();
  3093. returnSuccessMsg("操作成功!");
  3094. return;
  3095. }
  3096. returnErrorMsg("找不到记录");
  3097. }
  3098. }
  3099. public void ins_erp_designprice()
  3100. {
  3101. if (UrlPostParmsCheck("ctid"))
  3102. {
  3103. string eid = GetPostString("ctid");
  3104. int uid = CurrentUser.UserID;
  3105. string userName = CurrentUser.UserName;
  3106. CeErpTradeCell entity = null;
  3107. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3108. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3109. if (entitys == null)
  3110. {
  3111. entitys = new CeErpDesignerBill();
  3112. }
  3113. if (entity != null)
  3114. {
  3115. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3116. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3117. entity.StartDesignTime = DateTime.Now;
  3118. entity.OrderState = 4;
  3119. string suname = "";
  3120. if (entity.SupplierId == 0)
  3121. {
  3122. int sid = commonHelper.autoDistributeToSupplier(entity);
  3123. entity.SupplierId = sid;
  3124. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3125. }
  3126. entity.Update();
  3127. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3128. if (ceErpUserPost != null)
  3129. {
  3130. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3131. if (ceErpPost != null)
  3132. {
  3133. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3134. {
  3135. entitys.tid = entity.ctid;
  3136. entitys.oid = entity.tid;
  3137. entitys.uid = uid;
  3138. entitys.userName = userName;
  3139. entitys.designerType = 1;
  3140. entitys.designerTypeText = "内部设计师";
  3141. entitys.price = Convert.ToDouble(GetPostString("price"));
  3142. entitys.designNum = GetPostInt("designNum");
  3143. entitys.modifyNum = GetPostInt("modifyNum");
  3144. entitys.designSize = GetPostString("designSize");
  3145. entitys.modifySize = GetPostString("modifySize");
  3146. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3147. {
  3148. entitys.create_time = DateTime.Now;
  3149. entitys.create_u_id = uid;
  3150. entitys.create_u_name = userName;
  3151. entitys.Save();
  3152. }
  3153. else
  3154. {
  3155. entitys.update_time = DateTime.Now;
  3156. entitys.update_u_id = uid;
  3157. entitys.update_u_name = userName;
  3158. entitys.Update();
  3159. }
  3160. }
  3161. }
  3162. }
  3163. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3164. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3165. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3166. if (suname != "")
  3167. {
  3168. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3169. }
  3170. commonHelper.getCytPrice(entity);
  3171. returnSuccessMsg("操作成功!");
  3172. return;
  3173. }
  3174. returnErrorMsg("找不到记录");
  3175. }
  3176. }
  3177. public void upload_erp_filecomplete()
  3178. {
  3179. if (UrlPostParmsCheck("ctid"))
  3180. {
  3181. string eid = GetPostString("ctid");
  3182. CeErpTradeCell entity = null;
  3183. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3184. if (entity != null)
  3185. {
  3186. entity.OrderState = 5; //设计完成
  3187. entity.Update();
  3188. returnSuccessMsg(eid + "上传成功,设计完成!");
  3189. return;
  3190. }
  3191. returnErrorMsg("找不到订单记录");
  3192. }
  3193. }
  3194. public void get_erp_designovertimelist()
  3195. {
  3196. DataStruct dStruct = GetPostStruct();
  3197. List<string> lw = new List<string>();
  3198. string tid = GetPostString("ctid");
  3199. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3200. string shopname = GetPostString("shopname");
  3201. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3202. string buyernick = GetPostString("buyer_nick");
  3203. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3204. string ResponsibleMan = GetPostString("responsible");
  3205. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3206. string date1 = GetPostString("date1");
  3207. string date2 = GetPostString("date2");
  3208. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3209. if (dw.Length > 0) lw.Add(dw);
  3210. string price1 = GetPostString("price1");
  3211. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3212. string price2 = GetPostString("price2");
  3213. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3214. string orderState = GetPostString("orderState");
  3215. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3216. string sellermemo = GetPostString("seller_memo");
  3217. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3218. lw.Add(string.Format("UnusualTag=3"));
  3219. lw.Add(string.Format("IsRefund<={0}", 1));
  3220. dStruct.Order = "WaitDesignTime desc";
  3221. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3222. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3223. writeGridDataTableJson(dStruct.TotalCount, dt);
  3224. }
  3225. //设计管理 获取抢单大厅列表
  3226. public void get_erp_grabinglist()
  3227. {
  3228. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3229. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3230. bool oldOrder = false;
  3231. if (org != null)
  3232. {
  3233. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3234. }
  3235. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3236. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3237. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3238. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3239. //先处理订单数据
  3240. if (dt.Rows.Count > 0)
  3241. {
  3242. Dictionary<string, int> design = null;
  3243. int count = 0;
  3244. foreach (DataRow row in dt.Rows)
  3245. {
  3246. if (map.ContainsKey(row["ShopId"].ToString()))
  3247. {
  3248. map.TryGetValue(row["ShopId"].ToString(), out design);
  3249. }
  3250. else
  3251. {
  3252. design = new Dictionary<string, int>();
  3253. }
  3254. if (design.ContainsKey(row["ProductId"].ToString()))
  3255. {
  3256. design.TryGetValue(row["ProductId"].ToString(), out count);
  3257. }
  3258. count++;
  3259. design[row["ProductId"].ToString()] = count;
  3260. map[row["ShopId"].ToString()] = design;
  3261. }
  3262. }
  3263. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3264. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3265. //把店铺排序和技能排序分类
  3266. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3267. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3268. if (design_dt.Rows.Count > 0)
  3269. {
  3270. Dictionary<string, string> design = null;
  3271. List<string> shopIds = null;
  3272. foreach (DataRow row in design_dt.Rows)
  3273. {
  3274. if ("0".Equals(row["designId"].ToString()))
  3275. {
  3276. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3277. {
  3278. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3279. }
  3280. else
  3281. {
  3282. shopIds = new List<string>();
  3283. }
  3284. shopIds.Add(row["shopId"].ToString());
  3285. shop_orders[row["orders"].ToString()] = shopIds;
  3286. }
  3287. else
  3288. {
  3289. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3290. {
  3291. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3292. }
  3293. else
  3294. {
  3295. design = new Dictionary<string, string>();
  3296. }
  3297. design[row["orders"].ToString()] = row["designId"].ToString();
  3298. design_orders[row["shopId"].ToString()] = design;
  3299. }
  3300. }
  3301. //处理成key value后根据key排序
  3302. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3303. foreach (List<string> val in shop_orders.Values)
  3304. {
  3305. if (val != null)
  3306. {
  3307. foreach (string key in val)
  3308. {
  3309. if (design_orders.ContainsKey(key.ToString()))
  3310. {
  3311. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3312. }
  3313. }
  3314. }
  3315. }
  3316. }
  3317. //校验哪个优先级有订单
  3318. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3319. foreach (string key in shop_orders.Keys)
  3320. {
  3321. List<string> ids = null;
  3322. shop_orders.TryGetValue(key, out ids);
  3323. //id为shopid
  3324. foreach (string id in ids)
  3325. {
  3326. Dictionary<string, int> list = null;
  3327. Dictionary<string, string> desing = null;
  3328. map.TryGetValue(id, out list);
  3329. design_orders.TryGetValue(id, out desing);
  3330. if (list != null && desing != null)
  3331. {
  3332. foreach (var item in desing)
  3333. {
  3334. int count = 0;
  3335. if (list.ContainsKey(item.Value))
  3336. {
  3337. list.TryGetValue(item.Value, out count);
  3338. if (count > 0)
  3339. {
  3340. designIds[id] = item.Value;
  3341. break;
  3342. }
  3343. }
  3344. }
  3345. }
  3346. }
  3347. if (designIds.Count > 0)
  3348. {
  3349. break;
  3350. }
  3351. }
  3352. DataTable table = new DataTable();
  3353. table.Columns.Add("tid", typeof(string));
  3354. table.Columns.Add("ctid", typeof(string));
  3355. table.Columns.Add("seller_nick", typeof(string));
  3356. table.Columns.Add("productName", typeof(string));
  3357. table.Columns.Add("pay_time", typeof(string));
  3358. table.Columns.Add("seller_memo", typeof(string));
  3359. if (designIds.Count > 0)
  3360. {
  3361. string shopId = "";
  3362. string productId = "";
  3363. foreach (var designInfo in designIds)
  3364. {
  3365. shopId = designInfo.Key;
  3366. productId = designInfo.Value;
  3367. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3368. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3369. if (dt.Rows.Count > 0)
  3370. {
  3371. foreach (DataRow row in dt.Rows)
  3372. {
  3373. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3374. {
  3375. DataRow data = table.NewRow();
  3376. data["ctid"] = row["ctid"].ToString();
  3377. data["tid"] = row["tid"].ToString();
  3378. data["seller_nick"] = ceErpShop.ShopName;
  3379. data["pay_time"] = row["pay_time"].ToString();
  3380. data["seller_memo"] = row["seller_memo"].ToString();
  3381. data["productName"] = ceErpProduct.PType;
  3382. table.Rows.Add(data);
  3383. }
  3384. }
  3385. }
  3386. }
  3387. }
  3388. writeGridDataTableJson(table.Rows.Count, table);
  3389. }
  3390. private object rushLockObject = new object();
  3391. public void set_erp_grabingorder()
  3392. {
  3393. if (UrlPostParmsCheck("ctid"))
  3394. {
  3395. int total = CurrentUser.User.Person.Total;
  3396. int userId = CurrentUser.User.ID;
  3397. int noFinish = CurrentUser.User.Person.NoFinish;
  3398. int finalization = CurrentUser.User.Person.Finalization;
  3399. string eids = GetPostString("ctid");
  3400. string key = "RushKey_" + userId;
  3401. int count = 0;
  3402. if (erpRedis.RedisHelper.KeyExists(key))
  3403. {
  3404. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3405. if (redisCount != null)
  3406. {
  3407. count = Convert.ToInt32(redisCount);
  3408. }
  3409. }
  3410. if (count >= total)
  3411. {
  3412. returnErrorMsg("半小时内已经抢" + total + "单");
  3413. return;
  3414. }
  3415. string[] ctidlist = eids.Split(',');
  3416. if (count + ctidlist.Length > total)
  3417. {
  3418. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3419. return;
  3420. }
  3421. int itag = 0;
  3422. lock (rushLockObject)
  3423. {
  3424. if (ctidlist.Length > 0)
  3425. {
  3426. string[] dtList = new string[ctidlist.Length];
  3427. for (int i = 0; i < ctidlist.Length; i++)
  3428. {
  3429. dtList[i] = "'" + ctidlist[i] + "'";
  3430. }
  3431. 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"));
  3432. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3433. if (dt_user.Rows.Count > 0)
  3434. {
  3435. int doing = 0;//未定稿
  3436. int finish = 0;//已完成
  3437. foreach (DataRow dr in dt_user.Rows)
  3438. {
  3439. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3440. {
  3441. doing++;
  3442. }
  3443. else
  3444. {
  3445. finish++;
  3446. }
  3447. }
  3448. if (doing >= noFinish)
  3449. {
  3450. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3451. return;
  3452. }
  3453. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3454. {
  3455. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3456. return;
  3457. }
  3458. }
  3459. //校验选择单子状态
  3460. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3461. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3462. if (dt.Rows.Count > 0)
  3463. {
  3464. List<string> list = new List<string>();
  3465. foreach (DataRow dr in dt.Rows)
  3466. {
  3467. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3468. {
  3469. list.Add(dr["ctid"].ToString());
  3470. }
  3471. }
  3472. if (list.Count > 0)
  3473. {
  3474. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3475. return;
  3476. }
  3477. }
  3478. foreach (string ctid in ctidlist)
  3479. {
  3480. CeErpTradeCell entity = null;
  3481. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3482. if (entity != null)
  3483. {
  3484. entity.OrderState = 3;
  3485. entity.DesignUserId = CurrentUser.UserID;
  3486. entity.WaitDesignTime = DateTime.Now;
  3487. entity.StartDesignTime = DateTime.Now;
  3488. entity.Update();
  3489. commonHelper.UpdateRelationOrder(entity.ctid);
  3490. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3491. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3492. itag++;
  3493. }
  3494. }
  3495. }
  3496. }
  3497. count += ctidlist.Length;
  3498. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3499. if (itag == 0)
  3500. returnErrorMsg("没有找到相关订单");
  3501. else
  3502. returnSuccessMsg("抢单成功!");
  3503. return;
  3504. }
  3505. }
  3506. public void get_erp_waitorderlist()
  3507. {
  3508. DataStruct dStruct = GetPostStruct();
  3509. List<string> lw = new List<string>();
  3510. string tid = GetPostString("ctid");
  3511. if (tid.Length > 0)
  3512. {
  3513. string select_tid = getTidByCtid(tid);
  3514. lw.Add(string.Format("tid='{0}'", select_tid));
  3515. }
  3516. string shopname = GetPostString("shopname");
  3517. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3518. string buyernick = GetPostString("buyer_nick");
  3519. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3520. string customer = GetPostString("customer");
  3521. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3522. string design = GetPostString("design");
  3523. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3524. string orderState = GetPostString("orderState");
  3525. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3526. string supplier = GetPostString("supplier");
  3527. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3528. string sellermemo = GetPostString("seller_memo");
  3529. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3530. string otherMemo = GetPostString("otherMemo");
  3531. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3532. string address = GetPostString("address");
  3533. 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));
  3534. string date1 = GetPostString("date1");
  3535. string date2 = GetPostString("date2");
  3536. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3537. if (dw.Length > 0) lw.Add(dw);
  3538. string price1 = GetPostString("price1");
  3539. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3540. string price2 = GetPostString("price2");
  3541. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3542. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3543. lw.Add(string.Format("IsSample != 2 "));
  3544. lw.Add(string.Format("OrderState = 5 "));
  3545. lw.Add(string.Format("IsRefund<={0}", 1));
  3546. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3547. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3548. string pagesize = GetPostString("pagesize");
  3549. if (pagesize != null)
  3550. {
  3551. dStruct.PageSize = 200;
  3552. }
  3553. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3554. List<string> tids = new List<string>();
  3555. if (dt != null)
  3556. {
  3557. dt.Columns.Add("compenPrice", typeof(double));
  3558. foreach (DataRow dr in dt.Rows)
  3559. {
  3560. if (Convert.IsDBNull(dr["compenPrice"]))
  3561. {
  3562. dr["compenPrice"] = 0;
  3563. }
  3564. tids.Add("'" + dr["tid"].ToString() + "'");
  3565. 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();
  3566. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3567. {
  3568. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3569. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3570. entity.SupplierId = suid;
  3571. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3572. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3573. entity.Update();
  3574. }
  3575. }
  3576. }
  3577. if (tids.Count > 0)
  3578. {
  3579. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3580. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3581. if (dt_price != null && dt_price.Rows.Count > 0)
  3582. {
  3583. foreach (DataRow dr in dt_price.Rows)
  3584. {
  3585. foreach (DataRow row in dt.Rows)
  3586. {
  3587. if (row["tid"].Equals(dr["ptid"]))
  3588. {
  3589. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3590. break;
  3591. }
  3592. }
  3593. }
  3594. }
  3595. }
  3596. writeGridDataTableJson(dStruct.TotalCount, dt);
  3597. }
  3598. public void get_erp_supplierwaitorderlist()
  3599. {
  3600. DataStruct dStruct = GetPostStruct();
  3601. List<string> lw = new List<string>();
  3602. string tid = GetPostString("ctid");
  3603. if (tid.Length > 0)
  3604. {
  3605. string select_tid = getTidByCtid(tid);
  3606. lw.Add(string.Format("tid='{0}'", select_tid));
  3607. }
  3608. string shopname = GetPostString("shopname");
  3609. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3610. string sellermemo = GetPostString("seller_memo");
  3611. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3612. string date1 = GetPostString("date1");
  3613. string date2 = GetPostString("date2");
  3614. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3615. if (dw.Length > 0) lw.Add(dw);
  3616. lw.Add(string.Format("OrderState = 5 "));
  3617. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3618. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3619. {
  3620. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3621. }
  3622. string supplier = GetPostString("supplier");
  3623. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3624. {
  3625. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3626. }
  3627. lw.Add(string.Format("IsRefund<={0}", 1));
  3628. dStruct.Order = "FinishDesignTime desc";
  3629. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3630. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3631. if (dt != null)
  3632. {
  3633. foreach (DataRow dr in dt.Rows)
  3634. {
  3635. 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();
  3636. }
  3637. }
  3638. writeGridDataTableJson(dStruct.TotalCount, dt);
  3639. }
  3640. public void upd_erp_verifytosupplier()
  3641. {
  3642. if (UrlPostParmsCheck("ctid"))
  3643. {
  3644. string eids = GetPostString("ctid");
  3645. CeErpTradeCell entity = null;
  3646. string[] eidsList = eids.Split(',');
  3647. if (eidsList.Length <= 0)
  3648. {
  3649. returnErrorMsg("订单号不能空");
  3650. return;
  3651. }
  3652. List<string> tLst = new List<string>();
  3653. foreach (string ctidstr in eidsList)
  3654. {
  3655. tLst.Add("'" + ctidstr + "'");
  3656. CeErpDataSendOrderInfo.createObject(ctidstr);
  3657. }
  3658. string needtids = string.Join(",", tLst.ToArray());
  3659. StringBuilder sql = new StringBuilder();
  3660. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3661. 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);
  3662. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3663. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3664. returnSuccessMsg("操作成功!");
  3665. return;
  3666. /**foreach (string ctidstr in eidsList)
  3667. {
  3668. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3669. if (entity != null)
  3670. {
  3671. if (entity.SupplierId == 0)
  3672. {
  3673. continue;
  3674. }
  3675. entity.IsVerifyToSupplier = true;
  3676. if (entity.IsReturn == 1) //1是供应商打回
  3677. {
  3678. entity.IsReturn = 0;
  3679. }
  3680. entity.FinishPlaceTime = DateTime.Now;
  3681. entity.PlaceUserId = CurrentUser.UserID;
  3682. entity.Update();
  3683. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3684. }
  3685. }
  3686. returnSuccessMsg("操作成功!");
  3687. return;**/
  3688. }
  3689. }
  3690. public void upd_erp_supplierback()
  3691. {
  3692. if (UrlPostParmsCheck("ctid"))
  3693. {
  3694. string eid = GetPostString("ctid");
  3695. string reason = GetPostString("returnreason");
  3696. CeErpTradeCell entity = null;
  3697. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3698. if (entity != null)
  3699. {
  3700. string message = "操作成功!";
  3701. string isDown = "";
  3702. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3703. {
  3704. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3705. isDown = "被点击下载";
  3706. }
  3707. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3708. {
  3709. string key = "return_order_" + entity.SupplierId;
  3710. List<string> list = new List<string>();
  3711. if (RedisHelper.HasKey(key))
  3712. {
  3713. object data = RedisHelper.StringGet(key);
  3714. list = Convert.ToString(data).Split(',').ToList();
  3715. }
  3716. list.Add(eid);
  3717. RedisHelper.StringSet(key, string.Join(",", list));
  3718. }
  3719. entity.IsVerifyToSupplier = false;
  3720. entity.IsReturn = 1;
  3721. entity.IsHaveNewOrder = 0;
  3722. entity.ReturnTime = DateTime.Now;
  3723. entity.ReturnReason = reason;
  3724. if (entity.OrderState == 6)
  3725. {
  3726. entity.OrderState = 5;
  3727. }
  3728. entity.Update();
  3729. CeErpSukuraData.createInfo(entity.ctid, 5);
  3730. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3731. returnSuccessMsg(message);
  3732. return;
  3733. }
  3734. returnErrorMsg("找不到订单记录");
  3735. }
  3736. }
  3737. public void upd_erp_toaftersaleorder()
  3738. {
  3739. if (UrlPostParmsCheck("ctid"))
  3740. {
  3741. string eid = GetPostString("ctid");
  3742. string reason = GetPostString("returnreason");
  3743. CeErpTradeCell entity = null;
  3744. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3745. if (entity != null)
  3746. {
  3747. if (entity.isAfterSaleOrder != 1)
  3748. {
  3749. returnErrorMsg("带S的售后单才能打回给售后");
  3750. return;
  3751. }
  3752. if (entity.OrderState >= 5)
  3753. {
  3754. returnErrorMsg("已经设计完成了不能打回给售后");
  3755. return;
  3756. }
  3757. entity.OrderState = 0;
  3758. entity.IsReturn = 3;
  3759. entity.ReturnTime = DateTime.Now;
  3760. entity.UpdateTime = DateTime.Now;
  3761. entity.ReturnReason = reason;
  3762. entity.Update();
  3763. CeErpSukuraData.createInfo(entity.ctid, 5);
  3764. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3765. returnSuccessMsg("操作成功!");
  3766. return;
  3767. }
  3768. returnErrorMsg("找不到订单记录");
  3769. }
  3770. }
  3771. public void upd_erp_aftersaletodesign()
  3772. {
  3773. if (UrlPostParmsCheck("ctid"))
  3774. {
  3775. string eid = GetPostString("ctid");
  3776. CeErpTradeCell entity = null;
  3777. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3778. if (entity != null)
  3779. {
  3780. entity.OrderState = 3;
  3781. entity.IsReturn = 0;
  3782. entity.UpdateTime = DateTime.Now;
  3783. entity.Update();
  3784. CeErpSukuraData.createInfo(entity.ctid, 5);
  3785. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3786. returnSuccessMsg("操作成功!");
  3787. return;
  3788. }
  3789. returnErrorMsg("找不到订单记录");
  3790. }
  3791. }
  3792. public void assign_erp_supplier()
  3793. {
  3794. if (UrlPostParmsCheck("ctid"))
  3795. {
  3796. string eids = GetPostString("ctid");
  3797. int sid = GetPostInt("SupplierName");
  3798. string fromTag = GetPostString("tag");
  3799. string[] eidList = eids.Split(',');
  3800. if (eidList.Length <= 0)
  3801. {
  3802. returnErrorMsg("指派不能为空");
  3803. return;
  3804. }
  3805. string errMsg = "";
  3806. string suname = commonHelper.getSupplierNameById(sid);
  3807. foreach (string ctid in eidList)
  3808. {
  3809. CeErpTradeCell entity = null;
  3810. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3811. if (entity != null)
  3812. {
  3813. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3814. {
  3815. errMsg += (ctid + "指派失败!!!");
  3816. continue;
  3817. }
  3818. entity.SupplierId = sid;
  3819. entity.Update();
  3820. commonHelper.UpdateRelationOrder(entity.ctid);
  3821. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3822. if (entity.OrderState >= 6)
  3823. {
  3824. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3825. //{
  3826. // string msl = entity.MakeSupplier;
  3827. // string[] mslist = msl.Split(',');
  3828. // 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);
  3829. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3830. //}
  3831. //else
  3832. //{
  3833. StringBuilder sql = new StringBuilder();
  3834. 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);
  3835. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3836. //}
  3837. }
  3838. }
  3839. else
  3840. {
  3841. continue;
  3842. }
  3843. }
  3844. if (errMsg.Length > 0)
  3845. {
  3846. returnErrorMsg(errMsg);
  3847. return;
  3848. }
  3849. returnSuccessMsg("操作成功!");
  3850. return;
  3851. }
  3852. }
  3853. public void assign_erp_makesupplier()
  3854. {
  3855. if (UrlPostParmsCheck("ctid"))
  3856. {
  3857. string eids = GetPostString("ctid");
  3858. string sname = GetPostString("SupplierName");
  3859. string[] eidList = eids.Split(',');
  3860. if (eidList.Length <= 0)
  3861. {
  3862. returnErrorMsg("指派不能为空");
  3863. return;
  3864. }
  3865. List<string> tLst = new List<string>();
  3866. foreach (string ctid in eidList)
  3867. {
  3868. CeErpTradeCell entity = null;
  3869. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3870. if (entity != null)
  3871. {
  3872. entity.MakeSupplier = sname;
  3873. entity.Update();
  3874. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3875. tLst.Add("'" + ctid + "'");
  3876. }
  3877. else
  3878. {
  3879. continue;
  3880. }
  3881. }
  3882. string ctids = string.Join(",", tLst.ToArray());
  3883. StringBuilder sql2 = new StringBuilder();
  3884. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3885. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3886. returnSuccessMsg("操作成功!");
  3887. return;
  3888. }
  3889. }
  3890. public void ins_erp_returnreason()
  3891. {
  3892. if (UrlPostParmsCheck("ctid"))
  3893. {
  3894. string eid = GetPostString("ctid");
  3895. CeErpTradeCell entity = null;
  3896. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3897. string userpost = CurrentUser.UserPost.Post.Code;
  3898. if (entity != null)
  3899. {
  3900. bool isPlace = false;
  3901. if (entity.OrderState > 6)
  3902. {
  3903. returnErrorMsg("已发货无法打回!");
  3904. return;
  3905. }
  3906. if (entity.OrderState == 6)
  3907. {
  3908. isPlace = true;
  3909. }
  3910. bool isNeedUpdateCell2 = false;
  3911. if (entity.OrderState >= 6)
  3912. {
  3913. isNeedUpdateCell2 = true;
  3914. }
  3915. int returnTag = 2;
  3916. if (userpost == "Supplier")
  3917. {
  3918. returnTag = 1;
  3919. }
  3920. int toType = GetPostInt("totype");
  3921. string fromType = "3";
  3922. if (entity.OrderState < 5)
  3923. {
  3924. fromType = "3";
  3925. }
  3926. else
  3927. {
  3928. fromType = "4";
  3929. }
  3930. if (entity.IsXianHuo == 0)
  3931. {
  3932. if (returnTag == 2)
  3933. {
  3934. if (toType == 1)
  3935. {
  3936. entity.OrderState = 0;
  3937. entity.ReturnUserType = 1;
  3938. string clearman = GetPostString("clearman");
  3939. if (!string.IsNullOrEmpty(clearman))
  3940. {
  3941. entity.DesignUserId = 0;
  3942. }
  3943. }
  3944. else
  3945. {
  3946. entity.OrderState = 3;
  3947. entity.ReturnUserType = 2;
  3948. }
  3949. entity.IsReadTag = 1;
  3950. }
  3951. else if (returnTag == 1)
  3952. {
  3953. entity.OrderState = 5;
  3954. }
  3955. entity.IsVerifyToSupplier = false;
  3956. }
  3957. if (entity.IsXianHuo == 1)
  3958. {
  3959. entity.OrderState = 5;
  3960. }
  3961. entity.UnusualTag = 0;
  3962. entity.UnusualTime = null;
  3963. entity.UnusualCon = "";
  3964. entity.IsReturn = returnTag;
  3965. entity.ReturnTime = DateTime.Now;
  3966. entity.UpdateTime = DateTime.Now;
  3967. entity.ReturnReason = GetPostString("returnreason");
  3968. entity.Update();
  3969. if (entity.OrderState == 3)
  3970. {
  3971. ApiVo apiVo = new ApiVo();
  3972. apiVo.orderNumber = entity.ctid;
  3973. apiVo.actionName = "rebutDesign";
  3974. apiVo.orderRemarks = entity.ReturnReason;
  3975. designHelper.API_WorkCore(apiVo);//rebutDesign
  3976. }
  3977. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3978. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3979. {
  3980. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3981. }
  3982. CeErpSukuraData.createInfo(entity.ctid, 5);
  3983. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3984. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3985. if (isPlace)
  3986. {
  3987. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3988. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3989. if (dth != null && dth.Rows.Count > 0)
  3990. {
  3991. dataSendOrderBean dataSendOrderBean = null;
  3992. foreach (DataRow item in dth.Rows)
  3993. {
  3994. try
  3995. {
  3996. dataSendOrderBean = new dataSendOrderBean();
  3997. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3998. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3999. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  4000. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  4001. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  4002. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  4003. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  4004. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  4005. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  4006. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  4007. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  4008. dataSendOrderBean.Radio1723534706288 = "打回";
  4009. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  4010. if (result != null)
  4011. {
  4012. if ("0".Equals(result.errcode))
  4013. {
  4014. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  4015. }
  4016. else
  4017. {
  4018. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  4019. }
  4020. }
  4021. }
  4022. catch (Exception ex)
  4023. {
  4024. }
  4025. }
  4026. }
  4027. }
  4028. if (isNeedUpdateCell2)
  4029. {
  4030. if (entity.MakeSupplier.IndexOf(",") != -1)
  4031. {
  4032. StringBuilder sql2 = new StringBuilder();
  4033. 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);
  4034. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4035. }
  4036. else
  4037. {
  4038. StringBuilder sql2 = new StringBuilder();
  4039. 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);
  4040. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4041. }
  4042. }
  4043. returnSuccessMsg("操作成功!");
  4044. return;
  4045. }
  4046. returnErrorMsg("找不到订单记录");
  4047. }
  4048. }
  4049. public void cyt_erp_returnreason()
  4050. {
  4051. if (UrlPostParmsCheck("ctid"))
  4052. {
  4053. string eid = GetPostString("ctid");
  4054. CeErpTradeCell entity = null;
  4055. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4056. string userpost = CurrentUser.UserPost.Post.Code;
  4057. if (entity != null)
  4058. {
  4059. if (entity.OrderState > 6)
  4060. {
  4061. returnErrorMsg("已发货无法打回!");
  4062. return;
  4063. }
  4064. JObject jsonObject = new JObject
  4065. {
  4066. { "Userid", "77886" },
  4067. { "Pwd", "lt666888" },
  4068. { "LTOrderId",eid }
  4069. };
  4070. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4071. JObject jsonObjects = JObject.Parse(response);
  4072. string msg = (string)jsonObjects["msg"];
  4073. if (msg != "取消成功")
  4074. {
  4075. returnErrorMsg(msg);
  4076. return;
  4077. }
  4078. bool isNeedUpdateCell2 = false;
  4079. if (entity.OrderState >= 6)
  4080. {
  4081. isNeedUpdateCell2 = true;
  4082. }
  4083. int returnTag = 2;
  4084. if (userpost == "Supplier")
  4085. {
  4086. returnTag = 1;
  4087. }
  4088. if (entity.IsXianHuo == 0)
  4089. {
  4090. if (returnTag == 2)
  4091. {
  4092. int toType = GetPostInt("totype");
  4093. if (toType == 1)
  4094. {
  4095. entity.OrderState = 0;
  4096. entity.ReturnUserType = 1;
  4097. }
  4098. else
  4099. {
  4100. entity.OrderState = 4;
  4101. entity.ReturnUserType = 2;
  4102. }
  4103. entity.IsReadTag = 1;
  4104. }
  4105. else if (returnTag == 1)
  4106. {
  4107. entity.OrderState = 5;
  4108. }
  4109. entity.IsVerifyToSupplier = false;
  4110. }
  4111. entity.UnusualTag = 0;
  4112. entity.UnusualTime = null;
  4113. entity.UnusualCon = "";
  4114. entity.IsReturn = returnTag;
  4115. entity.ReturnTime = DateTime.Now;
  4116. entity.ReturnReason = GetPostString("returnreason");
  4117. entity.Update();
  4118. if (entity.OrderState == 4)
  4119. {
  4120. ApiVo apiVo = new ApiVo();
  4121. apiVo.orderNumber = entity.ctid;
  4122. apiVo.actionName = "rebutDesign";
  4123. apiVo.orderRemarks = entity.ReturnReason;
  4124. designHelper.API_WorkCore(apiVo);//rebutDesign
  4125. }
  4126. CeErpSukuraData.createInfo(entity.ctid, 5);
  4127. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4128. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4129. if (isNeedUpdateCell2)
  4130. {
  4131. if (entity.MakeSupplier.IndexOf(",") != -1)
  4132. {
  4133. StringBuilder sql2 = new StringBuilder();
  4134. 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);
  4135. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4136. }
  4137. else
  4138. {
  4139. StringBuilder sql2 = new StringBuilder();
  4140. 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);
  4141. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4142. }
  4143. }
  4144. returnSuccessMsg("操作成功!");
  4145. return;
  4146. }
  4147. returnErrorMsg("找不到订单记录");
  4148. }
  4149. }
  4150. public void upd_erp_xianhuoreturntag()
  4151. {
  4152. if (UrlPostParmsCheck("ctid"))
  4153. {
  4154. string eids = GetPostString("ctid");
  4155. string[] ctids = eids.Split(',');
  4156. foreach (string ctid in ctids)
  4157. {
  4158. CeErpTradeCell entity = null;
  4159. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4160. if (entity != null)
  4161. {
  4162. entity.IsReturn = 0;
  4163. entity.Update();
  4164. CeErpSukuraData.createInfo(entity.ctid, 5);
  4165. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4166. }
  4167. }
  4168. returnSuccessMsg("操作成功!");
  4169. return;
  4170. }
  4171. }
  4172. public void get_erp_waitdeliverylist()
  4173. {
  4174. DataStruct dStruct = GetPostStruct();
  4175. List<string> lw = new List<string>();
  4176. string tid = GetPostString("ctid");
  4177. if (tid.Length > 0)
  4178. {
  4179. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4180. if (tid.Length > 5)
  4181. {
  4182. List<string> tids = getTidByCtidLike(tid);
  4183. if (tids.Count > 0 && tids.Count < 10)
  4184. {
  4185. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4186. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4187. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4188. {
  4189. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4190. }*/
  4191. }
  4192. }
  4193. lw.Add(tid_sql);
  4194. }
  4195. string shopname = GetPostString("shopname");
  4196. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4197. string buyernick = GetPostString("buyer_nick");
  4198. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4199. //if (tid.Length == 0 && buyernick.Length == 0)
  4200. //{
  4201. // lw.Add(string.Format("IsRefund<={0}", 1));
  4202. //}
  4203. string customer = GetPostString("customer");
  4204. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4205. string design = GetPostString("design");
  4206. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4207. string orderState = GetPostString("orderState");
  4208. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4209. string address = GetPostString("address");
  4210. 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));
  4211. string sellermemo = GetPostString("seller_memo");
  4212. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4213. string supplier = GetPostString("supplier");
  4214. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4215. string OrderArea = GetPostString("order_area");
  4216. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4217. string placedate1 = GetPostString("placedate1");
  4218. string placedate2 = GetPostString("placedate2");
  4219. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4220. if (fdw.Length > 0) lw.Add(fdw);
  4221. string price1 = GetPostString("price1");
  4222. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4223. string price2 = GetPostString("price2");
  4224. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4225. string unusualCon = GetPostString("unusualcon");
  4226. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4227. string otherMemo = GetPostString("otherMemo");
  4228. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4229. string posTag = CurrentUser.UserPost.Post.Code;
  4230. if (posTag == "Supplier")
  4231. {
  4232. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4233. }
  4234. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4235. lw.Add(string.Format("type != 'PDD' "));
  4236. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4237. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4238. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4239. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4240. writeGridDataTableJson(dStruct.TotalCount, dt);
  4241. }
  4242. public void get_erp_changedeliverylist()
  4243. {
  4244. DataStruct dStruct = GetPostStruct();
  4245. List<string> lw = new List<string>();
  4246. string tid = GetPostString("ctid");
  4247. if (tid.Length > 0)
  4248. {
  4249. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4250. if (tid.Length > 5)
  4251. {
  4252. List<string> tids = getTidByCtidLike(tid);
  4253. if (tids.Count > 0 && tids.Count < 10)
  4254. {
  4255. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4256. }
  4257. }
  4258. lw.Add(tid_sql);
  4259. }
  4260. string shopname = GetPostString("shopname");
  4261. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4262. string buyernick = GetPostString("buyer_nick");
  4263. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4264. //if (tid.Length == 0 && buyernick.Length == 0)
  4265. //{
  4266. // lw.Add(string.Format("IsRefund<={0}", 1));
  4267. //}
  4268. string customer = GetPostString("customer");
  4269. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4270. string design = GetPostString("design");
  4271. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4272. string orderState = GetPostString("orderState");
  4273. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4274. string address = GetPostString("address");
  4275. 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));
  4276. string sellermemo = GetPostString("seller_memo");
  4277. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4278. string supplier = GetPostString("supplier");
  4279. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4280. string OrderArea = GetPostString("order_area");
  4281. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4282. string placedate1 = GetPostString("placedate1");
  4283. string placedate2 = GetPostString("placedate2");
  4284. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4285. if (fdw.Length > 0) lw.Add(fdw);
  4286. string price1 = GetPostString("price1");
  4287. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4288. string price2 = GetPostString("price2");
  4289. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4290. string unusualCon = GetPostString("unusualcon");
  4291. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4292. string otherMemo = GetPostString("otherMemo");
  4293. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4294. string posTag = CurrentUser.UserPost.Post.Code;
  4295. if (posTag == "Supplier")
  4296. {
  4297. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4298. }
  4299. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4300. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4301. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4302. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4303. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4304. /*if (tid.Length > 0)
  4305. {
  4306. List<string> tids = new List<string>();
  4307. if (dt != null && dt.Rows.Count > 0)
  4308. {
  4309. foreach (DataRow item in dt.Rows)
  4310. {
  4311. tids.Add("'" + item["tid"] + "'");
  4312. }
  4313. }
  4314. if (tids.Count > 0)
  4315. {
  4316. lw.RemoveAt(0);
  4317. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4318. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4319. dt = WebCache.GetData("view_erptradecell", dStruct);
  4320. }
  4321. }*/
  4322. writeGridDataTableJson(dStruct.TotalCount, dt);
  4323. }
  4324. public void get_erp_pddderiving()
  4325. {
  4326. DataStruct dStruct = GetPostStruct();
  4327. List<string> lw = new List<string>();
  4328. string tid = GetPostString("ctid");
  4329. if (tid.Length > 0)
  4330. {
  4331. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4332. if (tid.Length > 5)
  4333. {
  4334. List<string> tids = getTidByCtidLike(tid);
  4335. if (tids.Count > 0 && tids.Count < 10)
  4336. {
  4337. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4338. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4339. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4340. {
  4341. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4342. }*/
  4343. }
  4344. }
  4345. lw.Add(tid_sql);
  4346. }
  4347. string shopname = GetPostString("shopname");
  4348. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4349. string buyernick = GetPostString("buyer_nick");
  4350. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4351. //if (tid.Length == 0 && buyernick.Length == 0)
  4352. //{
  4353. // lw.Add(string.Format("IsRefund<={0}", 1));
  4354. //}
  4355. string customer = GetPostString("customer");
  4356. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4357. string design = GetPostString("design");
  4358. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4359. string orderState = GetPostString("orderState");
  4360. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4361. string address = GetPostString("address");
  4362. 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));
  4363. string sellermemo = GetPostString("seller_memo");
  4364. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4365. string supplier = GetPostString("supplier");
  4366. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4367. string OrderArea = GetPostString("order_area");
  4368. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4369. string placedate1 = GetPostString("placedate1");
  4370. string placedate2 = GetPostString("placedate2");
  4371. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4372. if (fdw.Length > 0) lw.Add(fdw);
  4373. string price1 = GetPostString("price1");
  4374. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4375. string price2 = GetPostString("price2");
  4376. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4377. string unusualCon = GetPostString("unusualcon");
  4378. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4379. string posTag = CurrentUser.UserPost.Post.Code;
  4380. if (posTag == "Supplier")
  4381. {
  4382. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4383. }
  4384. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4385. lw.Add(string.Format("type = 'PDD' "));
  4386. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4387. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4388. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4389. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4390. /*if (tid.Length > 0)
  4391. {
  4392. List<string> tids = new List<string>();
  4393. if (dt != null && dt.Rows.Count > 0)
  4394. {
  4395. foreach (DataRow item in dt.Rows)
  4396. {
  4397. tids.Add("'" + item["tid"] + "'");
  4398. }
  4399. }
  4400. if (tids.Count > 0)
  4401. {
  4402. lw.RemoveAt(0);
  4403. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4404. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4405. dt = WebCache.GetData("view_erptradecell", dStruct);
  4406. }
  4407. }*/
  4408. writeGridDataTableJson(dStruct.TotalCount, dt);
  4409. }
  4410. public void get_erp_jdderiving()
  4411. {
  4412. DataStruct dStruct = GetPostStruct();
  4413. List<string> lw = new List<string>();
  4414. string tid = GetPostString("ctid");
  4415. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4416. string shopname = GetPostString("shopname");
  4417. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4418. string buyernick = GetPostString("buyer_nick");
  4419. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4420. //if (tid.Length == 0 && buyernick.Length == 0)
  4421. //{
  4422. // lw.Add(string.Format("IsRefund<={0}", 1));
  4423. //}
  4424. string customer = GetPostString("customer");
  4425. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4426. string design = GetPostString("design");
  4427. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4428. string orderState = GetPostString("orderState");
  4429. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4430. string address = GetPostString("address");
  4431. 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));
  4432. string sellermemo = GetPostString("seller_memo");
  4433. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4434. string supplier = GetPostString("supplier");
  4435. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4436. string OrderArea = GetPostString("order_area");
  4437. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4438. string placedate1 = GetPostString("placedate1");
  4439. string placedate2 = GetPostString("placedate2");
  4440. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4441. if (fdw.Length > 0) lw.Add(fdw);
  4442. string price1 = GetPostString("price1");
  4443. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4444. string price2 = GetPostString("price2");
  4445. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4446. string unusualCon = GetPostString("unusualcon");
  4447. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4448. string posTag = CurrentUser.UserPost.Post.Code;
  4449. if (posTag == "Supplier")
  4450. {
  4451. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4452. }
  4453. lw.Add(string.Format("OrderState = 6 "));
  4454. lw.Add(string.Format("type = 'JD' "));
  4455. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4456. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4457. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4458. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4459. writeGridDataTableJson(dStruct.TotalCount, dt);
  4460. }
  4461. public void get_erp_demoorderlist()
  4462. {
  4463. DataStruct dStruct = GetPostStruct();
  4464. List<string> lw = new List<string>();
  4465. string tid = GetPostString("ctid");
  4466. if (tid.Length > 0)
  4467. {
  4468. string select_tid = getTidByCtid(tid);
  4469. lw.Add(string.Format("tid='{0}'", select_tid));
  4470. }
  4471. string shopname = GetPostString("shopname");
  4472. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4473. string buyernick = GetPostString("buyer_nick");
  4474. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4475. string customer = GetPostString("customer");
  4476. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4477. string design = GetPostString("design");
  4478. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4479. string orderState = GetPostString("orderState");
  4480. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4481. string address = GetPostString("address");
  4482. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4483. string sellermemo = GetPostString("seller_memo");
  4484. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4485. string supplier = GetPostString("supplier");
  4486. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4487. string OrderArea = GetPostString("order_area");
  4488. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4489. string date1 = GetPostString("date1");
  4490. string date2 = GetPostString("date2");
  4491. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4492. if (dw.Length > 0) lw.Add(dw);
  4493. string price1 = GetPostString("price1");
  4494. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4495. string price2 = GetPostString("price2");
  4496. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4497. string posTag = CurrentUser.UserPost.Post.Code;
  4498. if (posTag == "Supplier")
  4499. {
  4500. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4501. }
  4502. //lw.Add(string.Format("OrderState = 6 "));
  4503. lw.Add(string.Format("IsSample={0}", 3));
  4504. lw.Add(string.Format("IsRefund<={0}", 1));
  4505. dStruct.Order = "pay_time desc";
  4506. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4507. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4508. writeGridDataTableJson(dStruct.TotalCount, dt);
  4509. }
  4510. public void save_erp_checkmemo()
  4511. {
  4512. if (UrlPostParmsCheck("ctid"))
  4513. {
  4514. string ctid = GetPostString("ctid");
  4515. CeErpTradeCell entity = null;
  4516. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4517. if (entity != null)
  4518. {
  4519. entity.CheckMemo = GetPostString("CheckMemo");
  4520. entity.Update();
  4521. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4522. if (trade != null)
  4523. {
  4524. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4525. }
  4526. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4527. returnSuccessMsg("保存成功!");
  4528. return;
  4529. }
  4530. returnErrorMsg("找不到记录");
  4531. }
  4532. }
  4533. public void get_erp_returnlist()
  4534. {
  4535. DataStruct dStruct = GetPostStruct();
  4536. List<string> lw = new List<string>();
  4537. string tid = GetPostString("ctid");
  4538. if (tid.Length > 0)
  4539. {
  4540. string select_tid = getTidByCtid(tid);
  4541. lw.Add(string.Format("tid='{0}'", select_tid));
  4542. }
  4543. string shopname = GetPostString("shopname");
  4544. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4545. string buyernick = GetPostString("buyer_nick");
  4546. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4547. string customer = GetPostString("customer");
  4548. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4549. string design = GetPostString("design");
  4550. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4551. string orderState = GetPostString("orderState");
  4552. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4553. string address = GetPostString("address");
  4554. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4555. string sellermemo = GetPostString("seller_memo");
  4556. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4557. string supplier = GetPostString("supplier");
  4558. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4559. string date1 = GetPostString("date1");
  4560. string date2 = GetPostString("date2");
  4561. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4562. if (dw.Length > 0) lw.Add(dw);
  4563. string bdate1 = GetPostString("backdate1");
  4564. string bdate2 = GetPostString("backdate2");
  4565. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4566. if (dw_back.Length > 0) lw.Add(dw_back);
  4567. string price1 = GetPostString("price1");
  4568. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4569. string price2 = GetPostString("price2");
  4570. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4571. lw.Add(string.Format("IsReturn>0"));
  4572. lw.Add(string.Format("IsXianHuo=0"));
  4573. lw.Add(string.Format("IsReturn!=3"));
  4574. string backtype = GetPostString("backtype");
  4575. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4576. dStruct.Order = "FinishDesignTime desc";
  4577. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4578. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4579. writeGridDataTableJson(dStruct.TotalCount, dt);
  4580. }
  4581. public void get_erp_today_sumreturn()
  4582. {
  4583. DataStruct dStruct = GetPostStruct();
  4584. List<string> lw = new List<string>();
  4585. string bdate1 = GetPostString("returnTimeS");
  4586. string bdate2 = GetPostString("returnTimeE");
  4587. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4588. if (dw_back.Length > 0) lw.Add(dw_back);
  4589. lw.Add(string.Format("IsReturn=0"));
  4590. lw.Add(string.Format("IsXianHuo=0"));
  4591. string mainWhere = string.Join(" and ", lw.ToArray());
  4592. string sql = "";
  4593. if (dw_back.Length > 0)
  4594. {
  4595. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4596. }
  4597. else
  4598. {
  4599. 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 + "'";
  4600. }
  4601. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4602. decimal total = 0, today_finish = 0;
  4603. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4604. {
  4605. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4606. }
  4607. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4608. {
  4609. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4610. }
  4611. var res = new
  4612. {
  4613. data = total,
  4614. data1 = today_finish,
  4615. };
  4616. string ro_jsond = JsonConvert.SerializeObject(res);
  4617. returnSuccess(ro_jsond);
  4618. return;
  4619. }
  4620. public void get_erp_allreturnlist()
  4621. {
  4622. DataStruct dStruct = GetPostStruct();
  4623. List<string> lw = new List<string>();
  4624. string tid = GetPostString("ctid");
  4625. if (tid.Length > 0)
  4626. {
  4627. string select_tid = getTidByCtid(tid);
  4628. lw.Add(string.Format("tid='{0}'", select_tid));
  4629. }
  4630. string shopname = GetPostString("shopname");
  4631. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4632. string buyernick = GetPostString("buyer_nick");
  4633. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4634. string customer = GetPostString("customer");
  4635. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4636. string design = GetPostString("design");
  4637. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4638. string orderState = GetPostString("orderState");
  4639. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4640. string address = GetPostString("address");
  4641. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4642. string sellermemo = GetPostString("seller_memo");
  4643. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4644. string supplier = GetPostString("supplier");
  4645. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4646. string date1 = GetPostString("date1");
  4647. string date2 = GetPostString("date2");
  4648. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4649. if (dw.Length > 0) lw.Add(dw);
  4650. string bdate1 = GetPostString("backdate1");
  4651. string bdate2 = GetPostString("backdate2");
  4652. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4653. if (dw_back.Length > 0) lw.Add(dw_back);
  4654. string price1 = GetPostString("price1");
  4655. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4656. string price2 = GetPostString("price2");
  4657. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4658. string backreason = GetPostString("backreason");
  4659. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4660. lw.Add(string.Format("IsXianHuo=0"));
  4661. lw.Add(string.Format("ReturnTime != ''"));
  4662. string backtype = GetPostString("backtype");
  4663. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4664. dStruct.Order = "FinishDesignTime desc";
  4665. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4666. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4667. writeGridDataTableJson(dStruct.TotalCount, dt);
  4668. }
  4669. public void get_erp_aftersalereturnlist()
  4670. {
  4671. DataStruct dStruct = GetPostStruct();
  4672. List<string> lw = new List<string>();
  4673. string tid = GetPostString("ctid");
  4674. if (tid.Length > 0)
  4675. {
  4676. string select_tid = getTidByCtid(tid);
  4677. lw.Add(string.Format("tid='{0}'", select_tid));
  4678. }
  4679. string shopname = GetPostString("shopname");
  4680. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4681. string buyernick = GetPostString("buyer_nick");
  4682. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4683. string customer = GetPostString("customer");
  4684. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4685. string design = GetPostString("design");
  4686. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4687. string orderState = GetPostString("orderState");
  4688. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4689. string address = GetPostString("address");
  4690. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4691. string sellermemo = GetPostString("seller_memo");
  4692. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4693. string supplier = GetPostString("supplier");
  4694. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4695. string date1 = GetPostString("date1");
  4696. string date2 = GetPostString("date2");
  4697. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4698. if (dw.Length > 0) lw.Add(dw);
  4699. string bdate1 = GetPostString("backdate1");
  4700. string bdate2 = GetPostString("backdate2");
  4701. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4702. if (dw_back.Length > 0) lw.Add(dw_back);
  4703. string price1 = GetPostString("price1");
  4704. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4705. string price2 = GetPostString("price2");
  4706. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4707. lw.Add(string.Format("IsReturn=3"));
  4708. string backtype = GetPostString("backtype");
  4709. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4710. string backreason = GetPostString("backreason");
  4711. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4712. dStruct.Order = "ReturnTime desc";
  4713. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4714. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4715. writeGridDataTableJson(dStruct.TotalCount, dt);
  4716. }
  4717. public void get_erp_xianhuoreturnlist()
  4718. {
  4719. DataStruct dStruct = GetPostStruct();
  4720. List<string> lw = new List<string>();
  4721. string tid = GetPostString("ctid");
  4722. if (tid.Length > 0)
  4723. {
  4724. string select_tid = getTidByCtid(tid);
  4725. lw.Add(string.Format("tid='{0}'", select_tid));
  4726. }
  4727. string shopname = GetPostString("shopname");
  4728. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4729. string buyernick = GetPostString("buyer_nick");
  4730. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4731. string customer = GetPostString("customer");
  4732. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4733. string design = GetPostString("design");
  4734. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4735. string orderState = GetPostString("orderState");
  4736. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4737. string address = GetPostString("address");
  4738. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4739. string sellermemo = GetPostString("seller_memo");
  4740. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4741. string supplier = GetPostString("supplier");
  4742. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4743. string OrderArea = GetPostString("order_area");
  4744. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4745. string date1 = GetPostString("date1");
  4746. string date2 = GetPostString("date2");
  4747. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4748. if (dw.Length > 0) lw.Add(dw);
  4749. string price1 = GetPostString("price1");
  4750. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4751. string price2 = GetPostString("price2");
  4752. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4753. string posTag = CurrentUser.UserPost.Post.Code;
  4754. if (posTag == "Supplier")
  4755. {
  4756. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4757. }
  4758. lw.Add(string.Format("OrderState=6 "));
  4759. lw.Add(string.Format("IsXianHuo=1 "));
  4760. lw.Add(string.Format("IsReturn>0 "));
  4761. lw.Add(string.Format("IsReturn!=3"));
  4762. lw.Add(string.Format("IsRefund<={0}", 1));
  4763. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4764. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4765. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4766. writeGridDataTableJson(dStruct.TotalCount, dt);
  4767. }
  4768. public void set_erp_orderdelivery()
  4769. {
  4770. if (UrlPostParmsCheck("ctid"))
  4771. {
  4772. string eid = GetPostString("ctid");
  4773. CeErpTradeCell entity = null;
  4774. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4775. if (entity != null)
  4776. {
  4777. if (entity.OrderState >= 7)
  4778. {
  4779. returnErrorMsg("此单已发货,无需重复发货");
  4780. return;
  4781. }
  4782. if (entity.OrderState != 6)
  4783. {
  4784. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4785. return;
  4786. }
  4787. string shop = GetPostString("seller_nick");
  4788. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4789. string comName = GetPostString("comName");
  4790. string comCode = GetPostString("comCode");
  4791. string outSid = GetPostString("outSid");
  4792. string deliveryType = GetPostString("deliveryType");
  4793. string deliveryMemo = GetPostString("deliveryMemo");
  4794. outSid = outSid.Trim();
  4795. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4796. if (mainEn == null)
  4797. {
  4798. returnErrorMsg("找不到原始订单记录");
  4799. return;
  4800. }
  4801. bool isInitOrderDeliv = false;
  4802. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4803. {
  4804. isInitOrderDeliv = true;
  4805. }
  4806. string apires = "";
  4807. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4808. 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)
  4809. {
  4810. apires = "发货成功true";
  4811. }
  4812. else
  4813. {
  4814. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4815. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4816. }
  4817. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4818. {
  4819. entity.OrderState = 7;//发货后订单已发货
  4820. entity.OutSid = outSid;
  4821. entity.MemoOpt = 0;
  4822. entity.UpdateTime = DateTime.Now;
  4823. entity.FinishDeliveryTime = DateTime.Now;
  4824. entity.Update();
  4825. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4826. commonHelper.UpdateRelationOrder(entity.ctid);
  4827. //还要插入快递信息到 快递信息表
  4828. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4829. exinfo.tid = eid;
  4830. exinfo.out_sid = outSid;
  4831. exinfo.company_code = comCode;
  4832. exinfo.company_name = comName;
  4833. exinfo.delivery_memo = deliveryMemo;
  4834. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4835. exinfo.deliveryType = deliveryType;
  4836. exinfo.Create();
  4837. returnSuccessMsg("发货操作成功!");
  4838. commonHelper.UpdateRelationOrder(entity.ctid);
  4839. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4840. CeErpSukuraData.createInfo(entity.ctid, 4);
  4841. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  4842. {
  4843. commonHelper.sendCytExpress(exinfo);
  4844. }
  4845. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4846. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid + ",备注:" + deliveryMemo, entity.OrderState);
  4847. }
  4848. else
  4849. {
  4850. string errmsg = commonHelper.KeepChinese(apires);
  4851. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4852. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4853. }
  4854. return;
  4855. }
  4856. returnErrorMsg("找不到订单记录");
  4857. }
  4858. }
  4859. public void set_erp_multidelivery()
  4860. {
  4861. string eids = GetPostString("tids");
  4862. string[] eidList = eids.Split(',');
  4863. if (eidList.Length <= 0)
  4864. {
  4865. returnErrorMsg("发货不能为空");
  4866. return;
  4867. }
  4868. foreach (string ctid in eidList)
  4869. {
  4870. if (ctid.Length <= 0) continue;
  4871. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4872. if (expInfo != null)
  4873. {
  4874. StringBuilder sql = new StringBuilder();
  4875. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4876. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4877. if (dt.Rows.Count > 0)
  4878. {
  4879. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4880. {
  4881. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4882. expInfo.state = "异常";
  4883. expInfo.isMultiDelivery = 1;
  4884. expInfo.Update();
  4885. continue;
  4886. }
  4887. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4888. {
  4889. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4890. expInfo.state = "异常";
  4891. expInfo.Update();
  4892. continue;
  4893. }
  4894. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4895. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4896. bool isInitOrderDeliv = false;
  4897. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4898. {
  4899. isInitOrderDeliv = true;
  4900. expInfo.isMultiDelivery = 1;
  4901. }
  4902. if (ctid.IndexOf("N") != -1)
  4903. {
  4904. StringBuilder sqlbucha = new StringBuilder();
  4905. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4906. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4907. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4908. commonHelper.UpdateRelationOrder(ctid);
  4909. expInfo.delivery_memo = "发货成功";
  4910. expInfo.state = "发货成功";
  4911. expInfo.isMultiDelivery = 1;
  4912. expInfo.Update();
  4913. }
  4914. else
  4915. {
  4916. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4917. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4918. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4919. {
  4920. expInfo.delivery_memo = "发货成功";
  4921. expInfo.state = "发货成功";
  4922. expInfo.isMultiDelivery = 1;
  4923. expInfo.Update();
  4924. commonHelper.UpdateRelationOrder(ctid);
  4925. CeErpSukuraData.createInfo(ctid, 4);
  4926. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4927. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4928. }
  4929. else
  4930. {
  4931. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4932. expInfo.state = "异常";
  4933. expInfo.Update();
  4934. }
  4935. }
  4936. }
  4937. }
  4938. }
  4939. returnSuccessMsg("操作完成");
  4940. }
  4941. public void reset_erp_memoopt()
  4942. {
  4943. if (UrlPostParmsCheck("ctid"))
  4944. {
  4945. string eid = GetPostString("ctid");
  4946. CeErpTradeCell entity = null;
  4947. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4948. if (entity != null)
  4949. {
  4950. string stropt = "";
  4951. if (entity.MemoOpt == 1)
  4952. {
  4953. stropt = "“改稿”";
  4954. }
  4955. else if (entity.MemoOpt == 2)
  4956. {
  4957. stropt = "“定稿”";
  4958. }
  4959. else if (entity.MemoOpt == 3)
  4960. {
  4961. stropt = "“完成查货”";
  4962. CeErpSukuraData.createInfo(entity.ctid, 6);
  4963. }
  4964. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4965. entity.UpdateTime = DateTime.Now;
  4966. entity.MemoOpt = 0;
  4967. entity.Update();
  4968. returnSuccessMsg("操作成功!");
  4969. return;
  4970. }
  4971. returnErrorMsg("找不到记录");
  4972. }
  4973. }
  4974. public void get_erp_deliveryunusual()
  4975. {
  4976. DataStruct dStruct = GetPostStruct();
  4977. List<string> lw = new List<string>();
  4978. string tid = GetPostString("ctid");
  4979. if (tid.Length > 0)
  4980. {
  4981. string select_tid = getTidByCtid(tid);
  4982. lw.Add(string.Format("tid='{0}'", select_tid));
  4983. }
  4984. string shopname = GetPostString("shopname");
  4985. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4986. string buyernick = GetPostString("buyer_nick");
  4987. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4988. string customer = GetPostString("customer");
  4989. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4990. string design = GetPostString("design");
  4991. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4992. string sellermemo = GetPostString("seller_memo");
  4993. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4994. string supplier = GetPostString("supplier");
  4995. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4996. string date1 = GetPostString("date1");
  4997. string date2 = GetPostString("date2");
  4998. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4999. if (dw.Length > 0) lw.Add(dw);
  5000. string placedate1 = GetPostString("placedate1");
  5001. string placedate2 = GetPostString("placedate2");
  5002. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5003. if (dw_place.Length > 0) lw.Add(dw_place);
  5004. string price1 = GetPostString("price1");
  5005. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5006. string price2 = GetPostString("price2");
  5007. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5008. string unusualCon = GetPostString("unusualcon");
  5009. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  5010. string posTag = CurrentUser.UserPost.Post.Code;
  5011. if (posTag == "Supplier")
  5012. {
  5013. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5014. }
  5015. lw.Add(string.Format("OrderState = 6"));
  5016. lw.Add(string.Format("UnusualTag = 5"));
  5017. lw.Add(string.Format("IsRefund<={0}", 1));
  5018. dStruct.Order = "FinishPlaceTime desc";
  5019. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5020. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5021. writeGridDataTableJson(dStruct.TotalCount, dt);
  5022. }
  5023. public void get_erp_deliveryedlist()
  5024. {
  5025. DataStruct dStruct = GetPostStruct();
  5026. List<string> lw = new List<string>();
  5027. string tid = GetPostString("ctid");
  5028. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5029. string shopname = GetPostString("shopname");
  5030. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5031. string buyernick = GetPostString("buyer_nick");
  5032. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5033. string customer = GetPostString("customer");
  5034. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5035. string design = GetPostString("design");
  5036. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5037. string sellermemo = GetPostString("seller_memo");
  5038. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5039. string logistics = GetPostString("logistics");
  5040. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5041. string date1 = GetPostString("date1");
  5042. string date2 = GetPostString("date2");
  5043. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5044. //if (dw.Length > 0) lw.Add(dw);
  5045. string placedate1 = GetPostString("placedate1");
  5046. string placedate2 = GetPostString("placedate2");
  5047. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5048. if (fdw.Length > 0) lw.Add(fdw);
  5049. string devdate1 = GetPostString("deliverydate1");
  5050. string devdate2 = GetPostString("deliverydate2");
  5051. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5052. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5053. string price1 = GetPostString("price1");
  5054. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5055. string price2 = GetPostString("price2");
  5056. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5057. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5058. {
  5059. if (tid.Length > 0)
  5060. {
  5061. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5062. if (tid.Length > 5)
  5063. {
  5064. List<string> tids = getTidByCtidLike(tid);
  5065. if (tids.Count > 0 && tids.Count < 10)
  5066. {
  5067. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5068. }
  5069. }
  5070. lw.Add(tid_sql);
  5071. }
  5072. if (buyernick.Length > 0)
  5073. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5074. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5075. if (dw.Length > 0) lw.Add(dw);
  5076. }
  5077. else
  5078. {
  5079. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5080. }
  5081. string posTag = CurrentUser.UserPost.Post.Code;
  5082. if (posTag == "Supplier")
  5083. {
  5084. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5085. }
  5086. else
  5087. {
  5088. string supplier = GetPostString("supplier");
  5089. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5090. }
  5091. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5092. lw.Add(string.Format("type != 'PDD' "));
  5093. lw.Add(string.Format("IsRefund!={0}", 2));
  5094. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5095. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5096. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5097. /*if (tid.Length > 0)
  5098. {
  5099. List<string> tids = new List<string>();
  5100. if (dt != null && dt.Rows.Count > 0)
  5101. {
  5102. foreach (DataRow item in dt.Rows)
  5103. {
  5104. tids.Add("'" + item["tid"] + "'");
  5105. }
  5106. }
  5107. if (tids.Count > 0)
  5108. {
  5109. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5110. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5111. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5112. dt = WebCache.GetData("view_erptradecell", dStruct);
  5113. }
  5114. }*/
  5115. if (dt != null)
  5116. {
  5117. foreach (DataRow dr in dt.Rows)
  5118. {
  5119. 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();
  5120. }
  5121. }
  5122. writeGridDataTableJson(dStruct.TotalCount, dt);
  5123. }
  5124. public void get_erp_pdddeliveryed()
  5125. {
  5126. DataStruct dStruct = GetPostStruct();
  5127. List<string> lw = new List<string>();
  5128. string tid = GetPostString("ctid");
  5129. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5130. string shopname = GetPostString("shopname");
  5131. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5132. string buyernick = GetPostString("buyer_nick");
  5133. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5134. string customer = GetPostString("customer");
  5135. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5136. string design = GetPostString("design");
  5137. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5138. string sellermemo = GetPostString("seller_memo");
  5139. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5140. string logistics = GetPostString("logistics");
  5141. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5142. string date1 = GetPostString("date1");
  5143. string date2 = GetPostString("date2");
  5144. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5145. //if (dw.Length > 0) lw.Add(dw);
  5146. string placedate1 = GetPostString("placedate1");
  5147. string placedate2 = GetPostString("placedate2");
  5148. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5149. if (fdw.Length > 0) lw.Add(fdw);
  5150. string devdate1 = GetPostString("deliverydate1");
  5151. string devdate2 = GetPostString("deliverydate2");
  5152. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5153. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5154. string price1 = GetPostString("price1");
  5155. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5156. string price2 = GetPostString("price2");
  5157. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5158. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5159. {
  5160. if (tid.Length > 0)
  5161. {
  5162. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5163. if (tid.Length > 5)
  5164. {
  5165. List<string> tids = getTidByCtidLike(tid);
  5166. if (tids.Count > 0 && tids.Count < 10)
  5167. {
  5168. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5169. }
  5170. }
  5171. lw.Add(tid_sql);
  5172. }
  5173. if (buyernick.Length > 0)
  5174. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5175. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5176. if (dw.Length > 0) lw.Add(dw);
  5177. }
  5178. else
  5179. {
  5180. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5181. }
  5182. string posTag = CurrentUser.UserPost.Post.Code;
  5183. if (posTag == "Supplier")
  5184. {
  5185. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5186. }
  5187. else
  5188. {
  5189. string supplier = GetPostString("supplier");
  5190. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5191. }
  5192. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5193. lw.Add(string.Format("type = 'PDD' "));
  5194. lw.Add(string.Format("IsRefund!={0}", 2));
  5195. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5196. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5197. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5198. /* if (tid.Length > 0)
  5199. {
  5200. List<string> tids = new List<string>();
  5201. if (dt != null && dt.Rows.Count > 0)
  5202. {
  5203. foreach (DataRow item in dt.Rows)
  5204. {
  5205. tids.Add("'" + item["tid"] + "'");
  5206. }
  5207. }
  5208. if (tids.Count > 0)
  5209. {
  5210. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5211. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5212. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5213. dt = WebCache.GetData("view_erptradecell", dStruct);
  5214. }
  5215. }*/
  5216. foreach (DataRow dr in dt.Rows)
  5217. {
  5218. 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();
  5219. }
  5220. writeGridDataTableJson(dStruct.TotalCount, dt);
  5221. }
  5222. public void get_erp_jddeliveryed()
  5223. {
  5224. DataStruct dStruct = GetPostStruct();
  5225. List<string> lw = new List<string>();
  5226. string tid = GetPostString("ctid");
  5227. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5228. string shopname = GetPostString("shopname");
  5229. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5230. string buyernick = GetPostString("buyer_nick");
  5231. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5232. string customer = GetPostString("customer");
  5233. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5234. string design = GetPostString("design");
  5235. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5236. string sellermemo = GetPostString("seller_memo");
  5237. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5238. string date1 = GetPostString("date1");
  5239. string date2 = GetPostString("date2");
  5240. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5241. //if (dw.Length > 0) lw.Add(dw);
  5242. string placedate1 = GetPostString("placedate1");
  5243. string placedate2 = GetPostString("placedate2");
  5244. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5245. if (fdw.Length > 0) lw.Add(fdw);
  5246. string devdate1 = GetPostString("deliverydate1");
  5247. string devdate2 = GetPostString("deliverydate2");
  5248. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5249. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5250. string price1 = GetPostString("price1");
  5251. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5252. string price2 = GetPostString("price2");
  5253. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5254. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5255. {
  5256. if (tid.Length > 0)
  5257. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5258. if (buyernick.Length > 0)
  5259. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5260. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5261. if (dw.Length > 0) lw.Add(dw);
  5262. }
  5263. else
  5264. {
  5265. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5266. }
  5267. string posTag = CurrentUser.UserPost.Post.Code;
  5268. if (posTag == "Supplier")
  5269. {
  5270. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5271. }
  5272. else
  5273. {
  5274. string supplier = GetPostString("supplier");
  5275. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5276. }
  5277. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5278. lw.Add(string.Format("type = 'JD' "));
  5279. lw.Add(string.Format("IsRefund!={0}", 2));
  5280. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5281. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5282. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5283. foreach (DataRow dr in dt.Rows)
  5284. {
  5285. 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();
  5286. }
  5287. writeGridDataTableJson(dStruct.TotalCount, dt);
  5288. }
  5289. public void get_erp_allplacelist()
  5290. {
  5291. DataStruct dStruct = GetPostStruct();
  5292. List<string> lw = new List<string>();
  5293. string tid = GetPostString("ctid");
  5294. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5295. string shopname = GetPostString("shopname");
  5296. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5297. string buyernick = GetPostString("buyer_nick");
  5298. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5299. string customer = GetPostString("customer");
  5300. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5301. string design = GetPostString("design");
  5302. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5303. string sellermemo = GetPostString("seller_memo");
  5304. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5305. string supplier = GetPostString("supplier");
  5306. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5307. string date1 = GetPostString("date1");
  5308. string date2 = GetPostString("date2");
  5309. string pldate1 = GetPostString("placedate1");
  5310. string pldate2 = GetPostString("placedate2");
  5311. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5312. //if (dw.Length > 0) lw.Add(dw);
  5313. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5314. {
  5315. if (tid.Length > 0)
  5316. {
  5317. string select_tid = getTidByCtid(tid);
  5318. lw.Add(string.Format("tid='{0}'", select_tid));
  5319. }
  5320. if (buyernick.Length > 0)
  5321. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5322. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5323. if (dw.Length > 0) lw.Add(dw);
  5324. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5325. if (dw_place.Length > 0) lw.Add(dw_place);
  5326. }
  5327. else
  5328. {
  5329. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5330. {
  5331. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5332. }
  5333. }
  5334. string price1 = GetPostString("price1");
  5335. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5336. string price2 = GetPostString("price2");
  5337. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5338. string posTag = CurrentUser.UserPost.Post.Code;
  5339. if (posTag == "Supplier")
  5340. {
  5341. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5342. }
  5343. lw.Add(string.Format("OrderState >= 6"));
  5344. lw.Add(string.Format("IsSample != 2 "));
  5345. //lw.Add(string.Format("isDianziOrder = 0 "));
  5346. lw.Add(string.Format("SupplierId > 0 "));
  5347. //lw.Add(string.Format("IsRefund<={0}", 1));
  5348. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5349. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5350. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5351. foreach (DataRow dr in dt.Rows)
  5352. {
  5353. 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();
  5354. }
  5355. writeGridDataTableJson(dStruct.TotalCount, dt);
  5356. }
  5357. public void get_erp_financeallplacelist()
  5358. {
  5359. DataStruct dStruct = GetPostStruct();
  5360. List<string> lw = new List<string>();
  5361. string tid = GetPostString("ctid");
  5362. string shopname = GetPostString("shopname");
  5363. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5364. string buyernick = GetPostString("buyer_nick");
  5365. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5366. string customer = GetPostString("customer");
  5367. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5368. string design = GetPostString("design");
  5369. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5370. string sellermemo = GetPostString("seller_memo");
  5371. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5372. string supplier = GetPostString("supplier");
  5373. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5374. string date1 = GetPostString("date1");
  5375. string date2 = GetPostString("date2");
  5376. string pldate1 = GetPostString("placedate1");
  5377. string pldate2 = GetPostString("placedate2");
  5378. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5379. {
  5380. if (tid.Length > 0)
  5381. {
  5382. string select_tid = getTidByCtid(tid);
  5383. lw.Add(string.Format("tid='{0}'", select_tid));
  5384. }
  5385. if (buyernick.Length > 0)
  5386. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5387. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5388. if (dw.Length > 0) lw.Add(dw);
  5389. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5390. if (dw_place.Length > 0) lw.Add(dw_place);
  5391. }
  5392. else
  5393. {
  5394. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5395. {
  5396. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5397. }
  5398. }
  5399. string price1 = GetPostString("price1");
  5400. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5401. string price2 = GetPostString("price2");
  5402. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5403. string posTag = CurrentUser.UserPost.Post.Code;
  5404. if (posTag == "Supplier")
  5405. {
  5406. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5407. }
  5408. //lw.Add(string.Format("OrderState >= 6"));
  5409. lw.Add(string.Format("IsSample != 2 "));
  5410. lw.Add(string.Format("isDianziOrder = 0 "));
  5411. //lw.Add(string.Format("IsRefund<={0}", 1));
  5412. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5413. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5414. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5415. foreach (DataRow dr in dt.Rows)
  5416. {
  5417. 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();
  5418. }
  5419. writeGridDataTableJson(dStruct.TotalCount, dt);
  5420. }
  5421. public void get_erp_expresslist()
  5422. {
  5423. int listtype = GetInt("ltype");
  5424. DataStruct dStruct = GetPostStruct();
  5425. List<string> lw = new List<string>();
  5426. string tid = GetPostString("tid");
  5427. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5428. string outsid = GetPostString("out_sid");
  5429. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5430. string importer = GetPostString("ImportUserName");
  5431. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5432. string file = GetPostString("import_file");
  5433. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5434. string printman = GetPostString("printman");
  5435. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5436. string date1 = GetPostString("date1");
  5437. string date2 = GetPostString("date2");
  5438. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5439. if (dw.Length > 0) lw.Add(dw);
  5440. string fdate1 = GetPostString("finishdate1");
  5441. string fdate2 = GetPostString("finishdate2");
  5442. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5443. if (fdw.Length > 0) lw.Add(fdw);
  5444. string supplierId = GetPostString("supplierId");
  5445. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5446. if (listtype == 1)
  5447. {
  5448. lw.Add(string.Format("importUserId !=0"));
  5449. }
  5450. string posTag = CurrentUser.UserPost.Post.Code;
  5451. if (posTag == "Supplier")
  5452. {
  5453. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5454. }
  5455. if (dStruct.PageSize != 100000)
  5456. {
  5457. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5458. }
  5459. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5460. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5461. writeGridDataTableJson(dStruct.TotalCount, dt);
  5462. }
  5463. public void set_erp_buchaorderdelivery()
  5464. {
  5465. if (UrlPostParmsCheck("ctid"))
  5466. {
  5467. string eid = GetPostString("ctid");
  5468. CeErpTradeCell entity = null;
  5469. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5470. if (entity != null)
  5471. {
  5472. if (entity.IsSample != 2)
  5473. {
  5474. returnErrorMsg("补差价单才能标记为已发货");
  5475. return;
  5476. }
  5477. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5478. entity.OrderState = 7;
  5479. entity.Update();
  5480. returnSuccessMsg("操作成功!");
  5481. return;
  5482. }
  5483. returnErrorMsg("找不到记录");
  5484. }
  5485. }
  5486. public void get_stdtemplates()
  5487. {
  5488. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5489. //string res = taobaoHelper.test();
  5490. string res = apiHelper.API_PrintTemplate();
  5491. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5492. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5493. {
  5494. int sidx = res.IndexOf("error_code");
  5495. int eidx = res.IndexOf("success");
  5496. string msg = res.Substring(sidx, eidx - sidx);
  5497. returnErrorMsg(msg);
  5498. return;
  5499. }
  5500. if (res.Length <= 0)
  5501. {
  5502. returnErrorMsg("模板数据为空!");
  5503. return;
  5504. }
  5505. ReturnSuccess(res);
  5506. }
  5507. public void cancel_print_order()
  5508. {
  5509. if (UrlPostParmsCheck("ctid"))
  5510. {
  5511. string ctid = GetPostString("ctid");
  5512. CeErpTradeCell entity = null;
  5513. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5514. if (entity != null)
  5515. {
  5516. string res = "";
  5517. string code = entity.LastBillWaybillCode;
  5518. if (code == "")
  5519. {
  5520. code = entity.OutSid;
  5521. }
  5522. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5523. XLog.SaveLog(0, "取消面单" + res);
  5524. }
  5525. }
  5526. }
  5527. public void set_erp_printwaybill()
  5528. {
  5529. if (UrlPostParmsCheck("ctid"))
  5530. {
  5531. string ctid = GetPostString("ctid");
  5532. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5533. string cpName = GetPostString("cpname");
  5534. string isTogether = GetPostString("together");
  5535. string printType = GetPostString("printType");
  5536. //var res_obj = new
  5537. //{
  5538. // restype = 1,
  5539. // 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\"}"
  5540. //};
  5541. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5542. //ReturnSuccess(ro_json);
  5543. //return;
  5544. bool isUseLastWayBillCode = false;
  5545. CeErpTradeCell entity = null;
  5546. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5547. if (entity != null)
  5548. {
  5549. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5550. {
  5551. isUseLastWayBillCode = true;
  5552. }
  5553. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5554. {
  5555. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5556. return;
  5557. }
  5558. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5559. {
  5560. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5561. return;
  5562. }
  5563. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5564. {
  5565. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5566. return;
  5567. }
  5568. }
  5569. string res = "";
  5570. Api_waybill_code_response_Obj fullObj = null;
  5571. string pData_str = "";
  5572. string curUseWayBillCode = "";
  5573. if (isUseLastWayBillCode == false)
  5574. {
  5575. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5576. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5577. if (res.IndexOf("failure") != -1)
  5578. {
  5579. //int idx = res.IndexOf("sub_message");
  5580. //int idx2 = res.IndexOf("flag");
  5581. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5582. string errMsgNeed = commonHelper.KeepChinese(res);
  5583. var res_objd = new
  5584. {
  5585. restype = 0,
  5586. data = "获取面单失败" + errMsgNeed
  5587. };
  5588. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5589. returnSuccess(ro_jsond);
  5590. if (res.IndexOf("停发") != -1)
  5591. {
  5592. entity.UnusualCon = "物流停发";
  5593. entity.Update();
  5594. }
  5595. //returnErrorMsg("获取面单失败,"+emsg);
  5596. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5597. return;
  5598. }
  5599. else if (res.IndexOf("errorMsg") != -1)
  5600. {
  5601. //int idx = res.IndexOf("errorMsg");
  5602. //int idx2 = res.IndexOf("}]}");
  5603. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5604. string errMsgNeed = commonHelper.KeepChinese(res);
  5605. var res_objf = new
  5606. {
  5607. restype = 0,
  5608. data = "获取面单失败2" + errMsgNeed
  5609. };
  5610. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5611. if (res.IndexOf("停发") != -1)
  5612. {
  5613. entity.UnusualCon = "物流停发";
  5614. entity.Update();
  5615. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5616. if (trade != null)
  5617. {
  5618. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5619. }
  5620. }
  5621. returnSuccess(ro_jsonf);
  5622. //returnErrorMsg("获取面单失败," + emsg);
  5623. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5624. return;
  5625. }
  5626. try
  5627. {
  5628. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5629. //res = res.Replace(" ", "");
  5630. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5631. }
  5632. catch (Exception ex)
  5633. {
  5634. XLog.SaveLog(0, "生成fullObj" + res);
  5635. var res_objf = new
  5636. {
  5637. restype = 0,
  5638. data = "生成fullObj发生错误" + ex.Message
  5639. };
  5640. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5641. returnSuccess(ro_jsonf);
  5642. return;
  5643. }
  5644. if (fullObj.response.data.content.Count > 0)
  5645. {
  5646. ContentItem codeObj = fullObj.response.data.content[0];
  5647. if (cpCode.IndexOf("SFFQ-") != -1)
  5648. {
  5649. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5650. }
  5651. else
  5652. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5653. curUseWayBillCode = codeObj.waybillCode;
  5654. }
  5655. else
  5656. {
  5657. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5658. var res_objf = new
  5659. {
  5660. restype = 0,
  5661. data = "生成fullObj找不到快递单号waybillCode"
  5662. };
  5663. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5664. returnSuccess(ro_jsonf);
  5665. return;
  5666. }
  5667. }
  5668. else
  5669. {
  5670. //使用上次打印的快递单号
  5671. if (cpCode == "SFFQ-LY")
  5672. {
  5673. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5674. }
  5675. else
  5676. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5677. curUseWayBillCode = entity.LastBillWaybillCode;
  5678. }
  5679. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5680. {
  5681. var res_obje = new
  5682. {
  5683. restype = 0,
  5684. data = "获取加密打印数据失败"
  5685. };
  5686. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5687. returnSuccess(ro_jsone);
  5688. entity.LastBillCpCode = cpCode;
  5689. entity.LastBillWaybillCode = curUseWayBillCode;
  5690. entity.Update();
  5691. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5692. //returnErrorMsg("获取加密打印数据失败");
  5693. return;
  5694. }
  5695. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5696. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5697. string btnType = "";
  5698. string errorMsg = "";
  5699. if (entity != null)
  5700. {
  5701. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5702. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5703. //cpcode是 YTO-CAINIAO
  5704. //string comCode = cpCode.Split('-')[0].ToString();
  5705. string apires = "";
  5706. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5707. //isTogether=2是新的合包弹窗
  5708. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5709. {
  5710. if (ctid.IndexOf("N") != -1)
  5711. {
  5712. apires = "发货成功";
  5713. }
  5714. else
  5715. {
  5716. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5717. }
  5718. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5719. //打单后发货
  5720. StringBuilder sql = new StringBuilder();
  5721. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5722. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5723. {
  5724. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5725. }
  5726. else
  5727. {
  5728. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5729. }
  5730. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5731. foreach (DataRow row in dt.Rows)
  5732. {
  5733. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5734. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5735. {
  5736. try
  5737. {
  5738. btnType = "待发货";
  5739. entity.OutSid = curUseWayBillCode;
  5740. entity.OrderState = 7;
  5741. entity.IsUrgency = false;
  5742. entity.LastBillCpCode = "";
  5743. entity.LastBillWaybillCode = "";
  5744. entity.FinishDeliveryTime = DateTime.Now;
  5745. entity.IsReturn = 0;
  5746. entity.MemoOpt = 0;
  5747. entity.UpdateTime = DateTime.Now;
  5748. entity.Update();
  5749. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5750. //还要插入快递信息到 快递信息表
  5751. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5752. exinfo.tid = entity.ctid;
  5753. exinfo.out_sid = curUseWayBillCode;
  5754. exinfo.company_code = cpCode;
  5755. exinfo.company_name = cpName;
  5756. exinfo.supplierUserName = supplierName;
  5757. exinfo.deliveryType = "发货成功";
  5758. exinfo.print_time = DateTime.Now;
  5759. exinfo.printUser = CurrentUser.UserName;
  5760. exinfo.postData = pData_str;
  5761. exinfo.Create();
  5762. commonHelper.UpdateRelationOrder(entity.ctid);
  5763. CeErpSukuraData.createInfo(ctid, 4);
  5764. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5765. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5766. {
  5767. commonHelper.sendCytExpress(exinfo);
  5768. }
  5769. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5770. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5771. }
  5772. catch (Exception ex)
  5773. {
  5774. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5775. }
  5776. }
  5777. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5778. {
  5779. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5780. if (entity.OrderState == 6)
  5781. {
  5782. entity.OrderState = 7;
  5783. }
  5784. entity.UpdateTime = DateTime.Now;
  5785. entity.FinishDeliveryTime = DateTime.Now;
  5786. btnType = "已发货";
  5787. entity.Update();
  5788. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5789. exinfo.tid = entity.ctid;
  5790. exinfo.out_sid = curUseWayBillCode;
  5791. exinfo.company_code = cpCode;
  5792. exinfo.company_name = cpName;
  5793. exinfo.supplierUserName = supplierName;
  5794. exinfo.deliveryType = "发货成功";
  5795. exinfo.print_time = DateTime.Now;
  5796. exinfo.printUser = CurrentUser.UserName;
  5797. exinfo.postData = pData_str;
  5798. exinfo.Create();
  5799. commonHelper.UpdateRelationOrder(entity.ctid);
  5800. CeErpSukuraData.createInfo(entity.ctid, 4);
  5801. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5802. {
  5803. commonHelper.sendCytExpress(exinfo);
  5804. }
  5805. //不处理
  5806. }
  5807. else
  5808. {
  5809. entity.UpdateTime = DateTime.Now;
  5810. entity.LastBillCpCode = cpCode;
  5811. entity.LastBillWaybillCode = curUseWayBillCode;
  5812. entity.Update();
  5813. string errmsg = commonHelper.KeepChinese(apires);
  5814. var res_objz = new
  5815. {
  5816. restype = 0,
  5817. data = "打单后发货失败"
  5818. };
  5819. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5820. returnSuccess(ro_jsonz);
  5821. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5822. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5823. return;
  5824. }
  5825. }
  5826. }
  5827. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5828. {
  5829. string ctids = GetPostString("ctids");
  5830. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5831. List<string> list = new List<string>();
  5832. List<string> send_list = new List<string>();
  5833. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5834. CeErpTrade ceErpTrade = new CeErpTrade();
  5835. //可合包的合并一起发货
  5836. if (dt == null && string.IsNullOrEmpty(ctids))
  5837. {
  5838. var res_objz = new
  5839. {
  5840. restype = 0,
  5841. data = "打单后发货失败"
  5842. };
  5843. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5844. returnSuccess(ro_jsonz);
  5845. return;
  5846. }
  5847. if (!string.IsNullOrEmpty(ctids))
  5848. {
  5849. StringBuilder sql = new StringBuilder();
  5850. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5851. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5852. }
  5853. foreach (DataRow row in dt.Rows)
  5854. {
  5855. list.Add("'" + row["ctid"] + "'");
  5856. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5857. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5858. if (ctid.IndexOf("N") != -1)
  5859. {
  5860. apires = "发货成功";
  5861. }
  5862. else
  5863. {
  5864. if (!send_list.Contains(ceErpTrade.tid))
  5865. {
  5866. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5867. }
  5868. else
  5869. {
  5870. apires = "发货成功";
  5871. }
  5872. }
  5873. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5874. {
  5875. send_list.Add(ceErpTrade.tid);
  5876. try
  5877. {
  5878. btnType = "待发货";
  5879. ceErpTradeCell.OutSid = curUseWayBillCode;
  5880. ceErpTradeCell.OrderState = 7;
  5881. ceErpTradeCell.IsUrgency = false;
  5882. ceErpTradeCell.LastBillCpCode = "";
  5883. ceErpTradeCell.LastBillWaybillCode = "";
  5884. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5885. ceErpTradeCell.IsReturn = 0;
  5886. ceErpTradeCell.MemoOpt = 0;
  5887. ceErpTradeCell.UpdateTime = DateTime.Now;
  5888. ceErpTradeCell.Update();
  5889. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5890. //还要插入快递信息到 快递信息表
  5891. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5892. exinfo.tid = ceErpTradeCell.ctid;
  5893. exinfo.out_sid = curUseWayBillCode;
  5894. exinfo.company_code = cpCode;
  5895. exinfo.company_name = cpName;
  5896. exinfo.supplierUserName = supplierName;
  5897. exinfo.deliveryType = "发货成功";
  5898. exinfo.print_time = DateTime.Now;
  5899. exinfo.printUser = CurrentUser.UserName;
  5900. exinfo.postData = pData_str;
  5901. exinfo.Create();
  5902. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5903. CeErpSukuraData.createInfo(ctid, 4);
  5904. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5905. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80 || entity.SupplierId == 126)
  5906. {
  5907. commonHelper.sendCytExpress(exinfo);
  5908. }
  5909. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5910. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5911. }
  5912. catch (Exception ex)
  5913. {
  5914. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5915. }
  5916. }
  5917. else
  5918. {
  5919. ceErpTradeCell.UpdateTime = DateTime.Now;
  5920. ceErpTradeCell.LastBillCpCode = cpCode;
  5921. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5922. ceErpTradeCell.Update();
  5923. string errmsg = commonHelper.KeepChinese(apires);
  5924. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5925. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5926. }
  5927. }
  5928. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5929. }
  5930. }
  5931. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5932. var res_obj = new
  5933. {
  5934. restype = 1,
  5935. data = pData_str,
  5936. errorMsg
  5937. };
  5938. string ro_json = JsonConvert.SerializeObject(res_obj);
  5939. ReturnSuccess(ro_json);
  5940. return;
  5941. }
  5942. }
  5943. private string GetUTF8String(byte[] vs)
  5944. {
  5945. throw new NotImplementedException();
  5946. }
  5947. public void set_erp_printwaybill_cn()
  5948. {
  5949. if (UrlPostParmsCheck("ctid"))
  5950. {
  5951. string ctid = GetPostString("ctid");
  5952. string cpCode = GetPostString("cpcode");
  5953. string cpName = GetPostString("cpname");
  5954. string tempUrl = GetPostString("tempurl");
  5955. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5956. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5957. //string res = taobaoHelper.test();
  5958. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5959. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5960. {
  5961. int sidx = res.IndexOf("errorMsg");
  5962. int eidx = res.IndexOf("}");
  5963. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5964. var res_objzxx = new
  5965. {
  5966. restype = 0,
  5967. data = msg
  5968. };
  5969. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5970. returnSuccess(ro_jsonzxx);
  5971. //returnErrorMsg(msg);
  5972. return;
  5973. }
  5974. int idx = res.IndexOf("waybillCode");
  5975. int idx2 = res.IndexOf("printData");
  5976. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5977. string eid = GetPostString("ctid");
  5978. CeErpTradeCell entity = null;
  5979. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5980. if (entity != null)
  5981. {
  5982. string osid = entity.OutSid;
  5983. entity.OutSid = osid + "," + outsid;
  5984. entity.FinishDeliveryTime = DateTime.Now;
  5985. entity.OrderState = 7;
  5986. entity.UpdateTime = DateTime.Now;
  5987. entity.IsReturn = 0;
  5988. entity.Update();
  5989. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5990. exinfo.tid = entity.ctid;
  5991. exinfo.out_sid = outsid;
  5992. exinfo.company_code = cpCode;
  5993. exinfo.company_name = cpName;
  5994. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5995. exinfo.deliveryType = "发货成功";
  5996. exinfo.print_time = DateTime.Now;
  5997. exinfo.printUser = CurrentUser.UserName;
  5998. exinfo.Create();
  5999. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  6000. {
  6001. commonHelper.sendCytExpress(exinfo);
  6002. }
  6003. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  6004. }
  6005. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  6006. var res_objz = new
  6007. {
  6008. restype = 1,
  6009. data = res
  6010. };
  6011. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6012. returnSuccess(ro_jsonz);
  6013. //ReturnSuccess(res);
  6014. }
  6015. }
  6016. ////打单,打印面单 获取面单号
  6017. //public void set_erp_printwaybill()
  6018. //{
  6019. // if (UrlPostParmsCheck("ctid"))
  6020. // {
  6021. // string ctid = GetPostString("ctid");
  6022. // string cpCode = GetPostString("cpcode");
  6023. // string tempUrl = GetPostString("tempurl");
  6024. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6025. // //string res = taobaoHelper.test();
  6026. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6027. // if (res.IndexOf("error_response") != -1)
  6028. // {
  6029. // int sidx = res.IndexOf("sub_msg");
  6030. // int eidx = res.IndexOf("request_id");
  6031. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  6032. // returnErrorMsg(msg);
  6033. // return;
  6034. // }
  6035. // int idx = res.IndexOf("waybill_code");
  6036. // int idx2 = res.IndexOf("}]}");
  6037. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  6038. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  6039. // ReturnSuccess(res);
  6040. // }
  6041. //}
  6042. public void cancel_erp_aftersale()
  6043. {
  6044. if (UrlPostParmsCheck("ctid"))
  6045. {
  6046. string eid = GetPostString("ctid");
  6047. CeErpTradeCell entity = null;
  6048. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6049. if (entity != null)
  6050. {
  6051. //有过处理的售后,取消也不能删除 售 字,保留
  6052. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6053. {
  6054. entity.AfterSaleState = 4;
  6055. }
  6056. else
  6057. entity.AfterSaleState = 0;
  6058. entity.UpdateTime = DateTime.Now;
  6059. entity.Update();
  6060. returnSuccessMsg("操作成功!");
  6061. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6062. return;
  6063. }
  6064. returnErrorMsg("找不到订单记录");
  6065. }
  6066. }
  6067. public void get_erp_aftersalelist()
  6068. {
  6069. DataStruct dStruct = GetPostStruct();
  6070. List<string> lw = new List<string>();
  6071. int st = GetInt("st");
  6072. string tid = GetPostString("ctid");
  6073. if (st == 3)
  6074. {
  6075. if (tid.Length > 0)
  6076. {
  6077. string select_tid = getTidByCtid(tid);
  6078. lw.Add(string.Format("tid='{0}'", select_tid));
  6079. }
  6080. }
  6081. else
  6082. {
  6083. if (tid.Length > 0)
  6084. {
  6085. string select_tid = getTidByCtid(tid);
  6086. lw.Add(string.Format("tid='{0}'", select_tid));
  6087. }
  6088. }
  6089. string shopname = GetPostString("shopname");
  6090. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6091. string buyernick = GetPostString("buyer_nick");
  6092. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6093. string sellermemo = GetPostString("seller_memo");
  6094. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6095. string orderState = GetPostString("orderState");
  6096. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6097. string afterState = GetPostString("afterstate");
  6098. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6099. string date1 = GetPostString("date1");
  6100. string date2 = GetPostString("date2");
  6101. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6102. if (dw.Length > 0) lw.Add(dw);
  6103. string price1 = GetPostString("price1");
  6104. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6105. string price2 = GetPostString("price2");
  6106. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6107. //lw.Add(string.Format("IsRefund!={0}", 1));
  6108. string reason = GetPostString("reason");
  6109. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6110. string method = GetPostString("method");
  6111. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6112. string handler = GetPostString("handler");
  6113. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6114. string handledate1 = GetPostString("handledate1");
  6115. string handledate2 = GetPostString("handledate2");
  6116. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6117. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6118. string finish1 = GetPostString("finishdate1");
  6119. string finish2 = GetPostString("finishdate2");
  6120. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6121. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6122. string afterdate1 = GetPostString("afterdate1");
  6123. string afterdate2 = GetPostString("afterdate2");
  6124. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6125. if (afterDate.Length > 0) lw.Add(afterDate);
  6126. string supplier = GetPostString("supplier");
  6127. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6128. string responsible = GetPostString("responsibleman");
  6129. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6130. string customer = GetPostString("customer");
  6131. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6132. string design = GetPostString("design");
  6133. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6134. string afterMemoType = GetPostString("aftermemotype");
  6135. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6136. string posCode = CurrentUser.UserPost.Post.Code;
  6137. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6138. //{
  6139. // string vstate = GetPostString("vstate");
  6140. // if (vstate.Length > 0)
  6141. // {
  6142. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6143. // }
  6144. // if (posCode == "Supplier")
  6145. // {
  6146. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6147. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6148. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6149. // }
  6150. // else
  6151. // {
  6152. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6153. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6154. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6155. // {
  6156. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6157. // }
  6158. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6159. // {
  6160. // int orgid = CurrentUser.UserPost.OrgID;
  6161. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6162. // }
  6163. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6164. // {
  6165. // string shopid = CurrentUser.User.pemShop;
  6166. // lw.Add(string.Format("shopId in ({0})", shopid));
  6167. // }
  6168. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6169. // //{
  6170. // // int org_id = CurrentUser.UserPost.OrgID;
  6171. // // lw.Add(string.Format("OrgID={0}", org_id));
  6172. // //}
  6173. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6174. // }
  6175. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6176. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6177. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6178. //}
  6179. if (st == 5)
  6180. {
  6181. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6182. {
  6183. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6184. {
  6185. string shopid = CurrentUser.User.pemShop;
  6186. lw.Add(string.Format("shopId in ({0})", shopid));
  6187. }
  6188. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6189. {
  6190. int mrOrgid = CurrentUser.UserPost.OrgID;
  6191. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6192. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6193. }
  6194. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6195. //{
  6196. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6197. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6198. //}
  6199. else
  6200. {
  6201. string userIdStr = "";
  6202. if (posCode == "CustomerService")
  6203. {
  6204. userIdStr = CurrentUser.UserID + "_k";
  6205. }
  6206. else if (posCode == "Designer" || posCode == "wxDesigner")
  6207. {
  6208. userIdStr = CurrentUser.UserID + "_s";
  6209. }
  6210. else if (posCode == "Place")
  6211. {
  6212. userIdStr = CurrentUser.UserID + "_x";
  6213. }
  6214. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6215. }
  6216. }
  6217. string placedate1 = GetPostString("placedate1");
  6218. string placedate2 = GetPostString("placedate2");
  6219. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6220. if (dwplace.Length > 0) lw.Add(dwplace);
  6221. string supState = GetPostString("supState");
  6222. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6223. string searchType = GetPostString("searchType");
  6224. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6225. {
  6226. lw.Add(string.Format("BackNum>1"));
  6227. }
  6228. lw.Add(string.Format("AfterSaleState>0"));
  6229. if (ex_psize > 0)
  6230. {
  6231. if (CurrentUser.UserPost.Post.Code == "Finance")
  6232. dStruct.Order = "pay_time desc";
  6233. else
  6234. dStruct.Order = "HandleTime desc";
  6235. }
  6236. else
  6237. dStruct.Order = "HandleTime desc";
  6238. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6239. DataTable dt = WebCache.GetData("view_test", dStruct);
  6240. writeGridDataTableJson(dStruct.TotalCount, dt);
  6241. }
  6242. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6243. //{
  6244. // lw.Add(string.Format("AfterSaleState=4"));
  6245. // string code = CurrentUser.UserPost.Post.Code;
  6246. // if (code == "CustomerService")
  6247. // {
  6248. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6249. // }
  6250. // else if (code == "Designer" || code == "DesignerMr")
  6251. // {
  6252. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6253. // }
  6254. // else if (code == "Place" || code == "PlaceMr")
  6255. // {
  6256. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6257. // }
  6258. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6259. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6260. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6261. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6262. //}
  6263. //else //处理中的售后,待处理和处理中合并
  6264. //{
  6265. // if (afterState.Length <= 0)
  6266. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6267. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6268. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6269. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6270. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6271. //}
  6272. }
  6273. public void get_erp_disagreeftersalelist()
  6274. {
  6275. DataStruct dStruct = GetPostStruct();
  6276. List<string> lw = new List<string>();
  6277. int st = 2;
  6278. string tid = GetPostString("ctid");
  6279. if (tid.Length > 0)
  6280. {
  6281. string select_tid = getTidByCtid(tid);
  6282. lw.Add(string.Format("tid='{0}'", select_tid));
  6283. }
  6284. string shopname = GetPostString("shopname");
  6285. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6286. string buyernick = GetPostString("buyer_nick");
  6287. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6288. string sellermemo = GetPostString("seller_memo");
  6289. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6290. string orderState = GetPostString("orderState");
  6291. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6292. string afterState = GetPostString("afterstate");
  6293. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6294. string date1 = GetPostString("date1");
  6295. string date2 = GetPostString("date2");
  6296. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6297. if (dw.Length > 0) lw.Add(dw);
  6298. string price1 = GetPostString("price1");
  6299. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6300. string price2 = GetPostString("price2");
  6301. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6302. //lw.Add(string.Format("IsRefund!={0}", 1));
  6303. string reason = GetPostString("reason");
  6304. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6305. string method = GetPostString("method");
  6306. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6307. string handler = GetPostString("handler");
  6308. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6309. string handledate1 = GetPostString("handledate1");
  6310. string handledate2 = GetPostString("handledate2");
  6311. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6312. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6313. string afterdate1 = GetPostString("afterdate1");
  6314. string afterdate2 = GetPostString("afterdate2");
  6315. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6316. if (afterDate.Length > 0) lw.Add(afterDate);
  6317. string backdate1 = GetPostString("backdate1");
  6318. string backdate2 = GetPostString("backdate2");
  6319. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6320. if (backDate.Length > 0) lw.Add(backDate);
  6321. string supplier = GetPostString("supplier");
  6322. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6323. string responsible = GetPostString("responsibleman");
  6324. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6325. string customer = GetPostString("customer");
  6326. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6327. string design = GetPostString("design");
  6328. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6329. string afterSaleMemo = GetPostString("afterSaleMemo");
  6330. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6331. string afterMemoType = GetPostString("aftermemotype");
  6332. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6333. string aftersakereason = GetPostString("aftersakereason");
  6334. if (aftersakereason.Length > 0)
  6335. {
  6336. if (aftersakereason == "1")
  6337. {
  6338. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6339. }
  6340. if (aftersakereason == "2")
  6341. {
  6342. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6343. }
  6344. }
  6345. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6346. string poscode = CurrentUser.UserPost.Post.Code;
  6347. if (poscode != "SysAdmin")
  6348. {
  6349. string shopid = CurrentUser.User.pemShop;
  6350. lw.Add(string.Format("shopId in ({0})", shopid));
  6351. }
  6352. string searchType = GetPostString("searchType");
  6353. if (searchType == "wait")
  6354. {
  6355. lw.Add(string.Format("HandleTime is null"));
  6356. }
  6357. if (searchType == "handling")
  6358. {
  6359. lw.Add(string.Format("HandleTime is not null "));
  6360. }
  6361. if (searchType == "back" || searchType == "puBack")
  6362. {
  6363. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6364. }
  6365. if (searchType == "reBack")
  6366. {
  6367. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6368. }
  6369. if (searchType == "moreBack")
  6370. {
  6371. lw.Add(string.Format("backNum > 1"));
  6372. }
  6373. lw.Add(string.Format("(AfterSaleState=5)"));
  6374. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6375. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6376. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6377. writeGridDataTableJson(dStruct.TotalCount, dt);
  6378. }
  6379. public void get_erp_handlingaftersalelist()
  6380. {
  6381. DataStruct dStruct = GetPostStruct();
  6382. List<string> lw = new List<string>();
  6383. int st = 2;
  6384. string tid = GetPostString("ctid");
  6385. if (tid.Length > 0)
  6386. {
  6387. string select_tid = getTidByCtid(tid);
  6388. lw.Add(string.Format("tid='{0}'", select_tid));
  6389. }
  6390. string shopname = GetPostString("shopname");
  6391. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6392. string buyernick = GetPostString("buyer_nick");
  6393. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6394. string sellermemo = GetPostString("seller_memo");
  6395. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6396. string orderState = GetPostString("orderState");
  6397. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6398. string afterState = GetPostString("afterstate");
  6399. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6400. string date1 = GetPostString("date1");
  6401. string date2 = GetPostString("date2");
  6402. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6403. if (dw.Length > 0) lw.Add(dw);
  6404. string price1 = GetPostString("price1");
  6405. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6406. string price2 = GetPostString("price2");
  6407. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6408. //lw.Add(string.Format("IsRefund!={0}", 1));
  6409. string reason = GetPostString("reason");
  6410. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6411. string method = GetPostString("method");
  6412. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6413. string handler = GetPostString("handler");
  6414. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6415. string handledate1 = GetPostString("handledate1");
  6416. string handledate2 = GetPostString("handledate2");
  6417. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6418. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6419. string afterdate1 = GetPostString("afterdate1");
  6420. string afterdate2 = GetPostString("afterdate2");
  6421. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6422. if (afterDate.Length > 0) lw.Add(afterDate);
  6423. string supplier = GetPostString("supplier");
  6424. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6425. string responsible = GetPostString("responsibleman");
  6426. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6427. string customer = GetPostString("customer");
  6428. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6429. string design = GetPostString("design");
  6430. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6431. string afterSaleMemo = GetPostString("afterSaleMemo");
  6432. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6433. string afterMemoType = GetPostString("aftermemotype");
  6434. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6435. string afterresult = GetPostString("afterresult");
  6436. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6437. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6438. string poscode = CurrentUser.UserPost.Post.Code;
  6439. if (poscode != "SysAdmin")
  6440. {
  6441. string shopid = CurrentUser.User.pemShop;
  6442. lw.Add(string.Format("shopId in ({0})", shopid));
  6443. }
  6444. string searchType = GetPostString("searchType");
  6445. if (searchType == "wait")
  6446. {
  6447. lw.Add(string.Format("HandleTime is null"));
  6448. }
  6449. if (searchType == "documentary")
  6450. {
  6451. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6452. }
  6453. if (searchType == "handling")
  6454. {
  6455. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6456. }
  6457. if (searchType == "back" || searchType == "puBack")
  6458. {
  6459. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6460. }
  6461. if (searchType == "reBack")
  6462. {
  6463. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6464. }
  6465. if (afterState.Length <= 0)
  6466. {
  6467. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6468. }
  6469. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6470. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6471. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6472. writeGridDataTableJson(dStruct.TotalCount, dt);
  6473. }
  6474. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6475. //public void get_erp_back_handlingaftersalelist()
  6476. //{
  6477. // DataStruct dStruct = GetPostStruct();
  6478. // List<string> lw = new List<string>();
  6479. // string tid = GetPostString("ctid");
  6480. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6481. // string shopname = GetPostString("shopname");
  6482. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6483. // string buyernick = GetPostString("buyer_nick");
  6484. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6485. // string sellermemo = GetPostString("seller_memo");
  6486. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6487. // string orderState = GetPostString("orderState");
  6488. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6489. // string afterState = GetPostString("afterstate");
  6490. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6491. // string date1 = GetPostString("date1");
  6492. // string date2 = GetPostString("date2");
  6493. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6494. // if (dw.Length > 0) lw.Add(dw);
  6495. // string price1 = GetPostString("price1");
  6496. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6497. // string price2 = GetPostString("price2");
  6498. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6499. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6500. // string reason = GetPostString("reason");
  6501. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6502. // string method = GetPostString("method");
  6503. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6504. // string handler = GetPostString("handler");
  6505. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6506. // string handledate1 = GetPostString("handledate1");
  6507. // string handledate2 = GetPostString("handledate2");
  6508. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6509. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6510. // string afterdate1 = GetPostString("afterdate1");
  6511. // string afterdate2 = GetPostString("afterdate2");
  6512. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6513. // if (afterDate.Length > 0) lw.Add(afterDate);
  6514. // string supplier = GetPostString("supplier");
  6515. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6516. // string responsible = GetPostString("responsibleman");
  6517. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6518. // string customer = GetPostString("customer");
  6519. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6520. // string design = GetPostString("design");
  6521. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6522. // string afterMemoType = GetPostString("aftermemotype");
  6523. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6524. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6525. // if (afterState.Length <= 0)
  6526. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6527. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6528. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6529. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6530. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6531. //}
  6532. public void get_erp_aftersaleverifylist()
  6533. {
  6534. DataStruct dStruct = GetPostStruct();
  6535. List<string> lw = new List<string>();
  6536. string tid = GetPostString("ctid");
  6537. if (tid.Length > 0)
  6538. {
  6539. string select_tid = getTidByCtid(tid);
  6540. lw.Add(string.Format("otid='{0}'", select_tid));
  6541. }
  6542. string shopname = GetPostString("shopname");
  6543. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6544. string buyernick = GetPostString("buyer_nick");
  6545. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6546. string sellermemo = GetPostString("seller_memo");
  6547. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6548. string orderState = GetPostString("orderState");
  6549. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6550. //lw.Add(string.Format("IsRefund!={0}", 1));
  6551. string reason = GetPostString("reason");
  6552. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6553. string method = GetPostString("method");
  6554. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6555. string handler = GetPostString("handler");
  6556. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6557. string handledate1 = GetPostString("handledate1");
  6558. string handledate2 = GetPostString("handledate2");
  6559. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6560. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6561. string finish1 = GetPostString("finishdate1");
  6562. string finish2 = GetPostString("finishdate2");
  6563. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6564. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6565. string supplier = GetPostString("supplier");
  6566. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6567. string responsible = GetPostString("responsibleman");
  6568. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6569. string posCode = CurrentUser.UserPost.Post.Code;
  6570. string vstate = GetPostString("vstate");
  6571. if (vstate.Length > 0)
  6572. {
  6573. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6574. }
  6575. if (posCode == "Supplier")
  6576. {
  6577. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6578. lw.Add(string.Format("VerifyState = 0"));
  6579. lw.Add("type = 1");
  6580. lw.Add(string.Format("AfterSaleState={0}", 3));
  6581. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6582. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6583. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6584. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6585. writeGridDataTableJson(dStruct.TotalCount, dt);
  6586. }
  6587. else if (posCode == "logistics")
  6588. {
  6589. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6590. lw.Add(string.Format("VerifyState = 0"));
  6591. lw.Add("type = 2");
  6592. lw.Add(string.Format("AfterSaleState={0}", 3));
  6593. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6594. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6595. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6596. writeGridDataTableJson(dStruct.TotalCount, dt);
  6597. }
  6598. else
  6599. {
  6600. lw.Add(string.Format("(AfterSaleState = 3)"));
  6601. lw.Add("type = 0");
  6602. string reasonState = GetPostString("reasonState");
  6603. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6604. {
  6605. if (reasonState == "2")
  6606. {
  6607. lw.Add("VerifyState = 3");
  6608. }
  6609. else if (reasonState == "1")
  6610. {
  6611. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6612. }
  6613. else
  6614. {
  6615. lw.Add("VerifyState in (0,3)");
  6616. }
  6617. //不加条件,可以看全部
  6618. }
  6619. 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")
  6620. {
  6621. int orgid = CurrentUser.UserPost.OrgID;
  6622. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6623. if (string.IsNullOrEmpty(manageOrgId))
  6624. {
  6625. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6626. }
  6627. else
  6628. {
  6629. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6630. }
  6631. if (reasonState == "1")
  6632. {
  6633. lw.Add("VerifyState = 3");
  6634. }
  6635. else if (reasonState == "2")
  6636. {
  6637. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6638. }
  6639. else
  6640. {
  6641. }
  6642. }
  6643. else
  6644. {
  6645. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6646. }
  6647. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6648. //{
  6649. // int org_id = CurrentUser.UserPost.OrgID;
  6650. // lw.Add(string.Format("OrgID={0}", org_id));
  6651. //}
  6652. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6653. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6654. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6655. writeGridDataTableJson(dStruct.TotalCount, dt);
  6656. }
  6657. }
  6658. public void get_erp_finishaftersalelist()
  6659. {
  6660. DataStruct dStruct = GetPostStruct();
  6661. List<string> lw = new List<string>();
  6662. int st = 4;
  6663. string tid = GetPostString("ctid");
  6664. if (tid.Length > 0)
  6665. {
  6666. string select_tid = getTidByCtid(tid);
  6667. lw.Add(string.Format("otid='{0}'", select_tid));
  6668. }
  6669. string shopname = GetPostString("shopname");
  6670. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6671. //lw.Add(string.Format("IsRefund!={0}", 1));
  6672. string reason = GetPostString("reason");
  6673. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6674. string method = GetPostString("method");
  6675. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6676. string buyernick = GetPostString("buyer_nick");
  6677. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6678. string handler = GetPostString("handler");
  6679. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6680. string handledate1 = GetPostString("handledate1");
  6681. string handledate2 = GetPostString("handledate2");
  6682. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6683. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6684. string finish1 = GetPostString("finishdate1");
  6685. string finish2 = GetPostString("finishdate2");
  6686. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6687. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6688. string supplier = GetPostString("supplier");
  6689. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6690. string responsible = GetPostString("responsibleman");
  6691. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6692. string vstate = GetPostString("vstate");
  6693. if (vstate.Length > 0)
  6694. {
  6695. if ("3".Equals(vstate))
  6696. {
  6697. lw.Add(string.Format("IsTem=1"));
  6698. }
  6699. else
  6700. {
  6701. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6702. }
  6703. }
  6704. lw.Add(string.Format("AfterSaleState=4"));
  6705. string code = CurrentUser.UserPost.Post.Code;
  6706. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6707. {
  6708. //不加条件,可以看全部
  6709. }
  6710. else if (code == "Supplier")
  6711. {
  6712. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6713. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6714. lw.Add("type = 1");
  6715. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6716. }
  6717. else if (code == "logistics")
  6718. {
  6719. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6720. lw.Add("type = 2");
  6721. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6722. }
  6723. 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")
  6724. {
  6725. lw.Add("type = 0");
  6726. int orgid = CurrentUser.UserPost.OrgID;
  6727. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6728. if (string.IsNullOrEmpty(manageOrgIds))
  6729. {
  6730. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6731. }
  6732. else
  6733. {
  6734. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6735. }
  6736. }
  6737. else
  6738. {
  6739. lw.Add("type = 0");
  6740. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6741. }
  6742. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6743. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6744. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6745. writeGridDataTableJson(dStruct.TotalCount, dt);
  6746. }
  6747. public void handle_erp_aftersale()
  6748. {
  6749. if (UrlPostParmsCheck("ctid"))
  6750. {
  6751. string eid = GetPostString("ctid");
  6752. string responStr = GetPostString("AfterSaleResponsible");
  6753. if (responStr.Length <= 0)
  6754. {
  6755. returnErrorMsg("售后责任人不能为空");
  6756. return;
  6757. }
  6758. bool isDesign = false;
  6759. double designFree = 0.00;
  6760. int responsibleId = 0;
  6761. CeErpTradeCell entity = null;
  6762. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6763. if (entity != null)
  6764. {
  6765. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6766. string afterMethod = GetPostString("AfterSaleMethod");
  6767. if (isNeedNewOrder == 1)
  6768. {
  6769. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6770. bool ishav = true;
  6771. if (newentity == null)
  6772. {
  6773. newentity = entity.Clone() as CeErpTradeCell;
  6774. ishav = false;
  6775. newentity.ctid = "S_" + entity.ctid;
  6776. newentity.OrderState = 0;
  6777. //唯一标识
  6778. newentity.OrderSn = newentity.ctid;
  6779. string orderSn = dataHelper.getSaleOrderSn();
  6780. if (orderSn != "")
  6781. {
  6782. newentity.OrderSn = orderSn;
  6783. }
  6784. }
  6785. newentity.UpdateTime = DateTime.Now;
  6786. newentity.AfterSaleState = 0;
  6787. newentity.AfterSaleMethod = afterMethod;
  6788. if (!ishav)
  6789. {
  6790. string memo_str = newentity.seller_memo;
  6791. memo_str = memo_str.Replace("(", "(");
  6792. memo_str = memo_str.Replace(")", ")");
  6793. int sIndex = memo_str.IndexOf("(");
  6794. int eIndex = memo_str.IndexOf(")");
  6795. if (sIndex == -1 || eIndex == -1)
  6796. {
  6797. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6798. return;
  6799. }
  6800. string first = memo_str.Substring(0, sIndex + 1);
  6801. string memoCtid = newentity.OrderSn;
  6802. //if (memoCtid.IndexOf("C") != -1)
  6803. //{
  6804. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6805. //if (CIdx.IndexOf("+") != -1)
  6806. //{
  6807. //CIdx = "C" + CIdx.Split('+')[1];
  6808. //}
  6809. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6810. //}
  6811. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6812. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6813. string newMemo = first + memoCtid + last;
  6814. newentity.seller_memo = newMemo;
  6815. newentity.FinishPlaceTime = null;
  6816. newentity.UnusualTag = 0;
  6817. newentity.UnusualCon = "";
  6818. newentity.UnusualTime = null;
  6819. newentity.AfterSaleMemo = "";
  6820. newentity.AfterSaleMethod = afterMethod;
  6821. newentity.AfterSalePreTime = null;
  6822. newentity.AfterSaleReason = "";
  6823. newentity.AfterSaleResponsible = "";
  6824. newentity.AfterSaleState = 0;
  6825. newentity.AfterSaleTime = null;
  6826. newentity.AfterSaleUserId = 0;
  6827. newentity.AfterSaleSupplierState = 0;
  6828. newentity.LastBillWaybillCode = "";
  6829. newentity.LastBillCpCode = "";
  6830. newentity.FinishAfterSaleTime = null;
  6831. newentity.HandleTime = null;
  6832. newentity.IsSF = 0;
  6833. newentity.IsOldCustomer = 0;
  6834. newentity.UrgencyTime = null;
  6835. newentity.ResponsibleUserId = "";
  6836. newentity.IsVerifyToSupplier = false;
  6837. newentity.payment = 0;
  6838. newentity.CheckMemo = "";
  6839. newentity.OutSid = "";
  6840. newentity.CheckOrderTime = null;
  6841. newentity.MemoOpt = 0;
  6842. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6843. }
  6844. newentity.isAfterSaleOrder = 1;
  6845. newentity.IsRefund = 0;
  6846. string receiveMobile = GetPostString("receiver_mobile");
  6847. if (receiveMobile.Length > 0)
  6848. {
  6849. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6850. if (trade != null)
  6851. {
  6852. trade.receiver_name = GetPostString("receiver_name");
  6853. trade.receiver_mobile = receiveMobile;
  6854. trade.receiver_state = GetPostString("receiver_state");
  6855. trade.receiver_city = GetPostString("receiver_city");
  6856. trade.receiver_district = GetPostString("receiver_district");
  6857. trade.receiver_address = GetPostString("receiver_address");
  6858. newentity.IsOffLineOrder = 1;
  6859. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6860. }
  6861. }
  6862. string st = GetPostString("ToState");
  6863. if (st.Length > 0)
  6864. {
  6865. if (newentity.OrderState <= 3)
  6866. {
  6867. newentity.WaitDesignTime = DateTime.Now;
  6868. newentity.StartDesignTime = null;
  6869. newentity.FinishDesignTime = null;
  6870. newentity.OrderState = 3;
  6871. if (st == "下单员")
  6872. {
  6873. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6874. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6875. {
  6876. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6877. }
  6878. }
  6879. else
  6880. {
  6881. newentity.WaitDesignTime = DateTime.Now;
  6882. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6883. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6884. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6885. {
  6886. DataRow user = dt1.Rows[0];
  6887. //找主管
  6888. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6889. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6890. if (dt != null && dt.Rows.Count > 0)
  6891. {
  6892. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6893. newentity.DesignUserId = designMr;
  6894. string key = "aftersale_order_" + designMr;
  6895. if (RedisHelper.HasKey(key))
  6896. {
  6897. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6898. list.Add(newentity.ctid);
  6899. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6900. }
  6901. }
  6902. //账号正常
  6903. if (user["State"].ToString() == "0")
  6904. {
  6905. newentity.DesignUserId = entity.DesignUserId;
  6906. string key = "aftersale_order_" + entity.DesignUserId;
  6907. if (RedisHelper.HasKey(key))
  6908. {
  6909. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6910. list.Add(newentity.ctid);
  6911. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6912. }
  6913. }
  6914. }
  6915. }
  6916. }
  6917. if (entity.IsXianHuo == 1)
  6918. {
  6919. newentity.OrderState = 6;
  6920. entity.FinishPlaceTime = DateTime.Now;
  6921. }
  6922. }
  6923. if (ishav)
  6924. {
  6925. newentity.Update();
  6926. }
  6927. else
  6928. {
  6929. newentity.Create();
  6930. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6931. newCellExtend.ctid = newentity.ctid;
  6932. newCellExtend.orderFrom = 20;
  6933. newCellExtend.orderType = 30;
  6934. if (st == "下单员")
  6935. {
  6936. }
  6937. else
  6938. {
  6939. newCellExtend.ReprintTime = DateTime.Now;
  6940. }
  6941. newCellExtend.Create();
  6942. }
  6943. if (st != "下单员")
  6944. {
  6945. if (entity.DispatchSort == 2)
  6946. {
  6947. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6948. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6949. }
  6950. }
  6951. }
  6952. //处理售后扩展
  6953. string resIdStr = GetPostString("ResponsibleUserId");
  6954. string refundFees = GetPostString("refundFrees");
  6955. int IsComplain = GetPostInt("isComplain");
  6956. int IsBad = GetPostInt("isBad");
  6957. string IsOriginal = GetPostString("isOriginal");
  6958. double diffResultPrice = GetPostDouble("diffResultPrice");
  6959. string textResult = GetPostString("textResult");
  6960. string supplierResponsible = GetPostString("supplierResponsible");
  6961. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6962. if (ceErpTradeAfterSaleExtend == null)
  6963. {
  6964. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6965. ceErpTradeAfterSaleExtend.tid = eid;
  6966. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6967. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6968. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6969. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6970. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6971. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6972. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6973. ceErpTradeAfterSaleExtend.Create();
  6974. }
  6975. else
  6976. {
  6977. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6978. {
  6979. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6980. }
  6981. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6982. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6983. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6984. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6985. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6986. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6987. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6988. ceErpTradeAfterSaleExtend.Update();
  6989. }
  6990. int gysid = GetPostInt("ResponsibleSupId");
  6991. if (entity.AfterSaleUserId == 0)
  6992. {
  6993. entity.AfterSaleUserId = CurrentUser.UserID;
  6994. }
  6995. entity.ResponsibleUserId = resIdStr;
  6996. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6997. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6998. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6999. {
  7000. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7001. int backNum = 0;
  7002. if (number != null)
  7003. {
  7004. backNum = number.BackNum;
  7005. }
  7006. char[] separator = { ',' };
  7007. string[] sArray = resIdStr.Split(separator);
  7008. string[] refundFreeList = { };
  7009. if (refundFees.Length > 0)
  7010. {
  7011. refundFreeList = refundFees.Split(separator);
  7012. }
  7013. int index = -1;
  7014. List<int> responsibleIds = new List<int>();
  7015. foreach (string i in sArray)
  7016. {
  7017. index++;
  7018. if (i.Length <= 0) continue;
  7019. char[] separator2 = { '_' };
  7020. string idstr = i.Split(separator2)[0];
  7021. string idtype = i.Split(separator2)[1];
  7022. double refudFree = 0;
  7023. if (refundFreeList.Length > 0)
  7024. {
  7025. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  7026. }
  7027. if (idtype == "s")
  7028. {
  7029. isDesign = true;
  7030. designFree = refudFree;
  7031. }
  7032. int userId = Convert.ToInt32(idstr);
  7033. int type = 0;
  7034. if (idtype == "g")
  7035. {
  7036. type = 1;
  7037. }
  7038. if (idtype == "w")
  7039. {
  7040. type = 2;
  7041. }
  7042. if (idtype == "t")
  7043. {
  7044. type = 3;
  7045. }
  7046. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7047. if (ceErpTradeResponsible == null)
  7048. {
  7049. ceErpTradeResponsible = new CeErpTradeResponsible();
  7050. ceErpTradeResponsible.tid = eid;
  7051. ceErpTradeResponsible.UserId = userId;
  7052. ceErpTradeResponsible.createdTime = DateTime.Now;
  7053. ceErpTradeResponsible.type = type;
  7054. if (type == 1)
  7055. {
  7056. ceErpTradeResponsible.IsSup = 1;
  7057. }
  7058. if (type == 2)
  7059. {
  7060. ceErpTradeResponsible.IsFlow = 1;
  7061. }
  7062. }
  7063. int state = 0;
  7064. //已认可的不需要再次认可
  7065. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7066. {
  7067. state = 1;
  7068. }
  7069. ceErpTradeResponsible.RefundFee = refudFree;
  7070. ceErpTradeResponsible.VerifyState = state;
  7071. if (userId == 2125 || idtype == "w")
  7072. {
  7073. ceErpTradeResponsible.VerifyState = 1;
  7074. }
  7075. if (idtype == "w" && userId == 101)
  7076. {
  7077. ceErpTradeResponsible.VerifyState = state;
  7078. }
  7079. if (ceErpTradeResponsible.ID > 0)
  7080. {
  7081. ceErpTradeResponsible.Update();
  7082. }
  7083. else
  7084. {
  7085. ceErpTradeResponsible.Create();
  7086. }
  7087. if (isDesign)
  7088. {
  7089. responsibleId = ceErpTradeResponsible.ID;
  7090. }
  7091. responsibleIds.Add(ceErpTradeResponsible.ID);
  7092. }
  7093. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7094. CeErpTradeResponsible.NumByTid(backNum, eid);
  7095. }
  7096. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7097. if (ceErpTradeCellExtend != null)
  7098. {
  7099. ceErpTradeCellExtend.returnVisit = 0;
  7100. ceErpTradeCellExtend.Update();
  7101. }
  7102. if (entity.HandleTime != null)
  7103. {
  7104. if (entity.AfterSaleState == 1)
  7105. {
  7106. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7107. }
  7108. else
  7109. {
  7110. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7111. }
  7112. }
  7113. else
  7114. {
  7115. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7116. entity.HandleTime = DateTime.Now;
  7117. }
  7118. bool isCompale = false;
  7119. if (entity.AfterSaleState == 5)
  7120. {
  7121. isCompale = true;
  7122. entity.AfterSaleState = 3;
  7123. }
  7124. entity.AfterSaleSupplierState = 0;
  7125. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7126. {
  7127. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7128. }
  7129. string sImgs = GetPostString("img");
  7130. entity.AfterSaleSupplierImg = sImgs;
  7131. entity.supRefundType = GetPostString("supRefundType");
  7132. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7133. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7134. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7135. entity.AfterSaleMemoType = GetPostString("MemoType");
  7136. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7137. {
  7138. //entity.AfterSaleSupplierState = 2;
  7139. }
  7140. string df = GetPostString("DeductFee");
  7141. if (df == "")
  7142. {
  7143. df = "0";
  7144. }
  7145. string rf = GetPostString("RefundFee");
  7146. if (rf == "")
  7147. {
  7148. rf = "0";
  7149. }
  7150. string pm = GetPostString("AfterSalePayment");
  7151. if (pm == "")
  7152. {
  7153. pm = "0";
  7154. }
  7155. entity.AfterSalePayment = Convert.ToDouble(pm);
  7156. entity.DeductFee = Convert.ToDouble(df);
  7157. entity.RefundFee = Convert.ToDouble(rf);
  7158. entity.UpdateTime = DateTime.Now;
  7159. entity.Update();
  7160. string toState = GetPostString("ToState");
  7161. string original = GetPostString("isOriginal");
  7162. ApiVo apiVo = new ApiVo();
  7163. apiVo.orderNumber = entity.ctid;
  7164. apiVo.actionName = "afterDesign";
  7165. apiVo.orderRemarks = entity.AfterSaleMethod;
  7166. apiVo.reasonRemarks = entity.AfterSaleReason;
  7167. apiVo.isDesign = isDesign;
  7168. apiVo.designFree = designFree;
  7169. apiVo.responsibleId = responsibleId;
  7170. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7171. if (toState == "设计师")
  7172. {
  7173. apiVo.isOriginal = Convert.ToBoolean(original);
  7174. }
  7175. designHelper.API_WorkCore(apiVo);//afterDesign
  7176. CeErpMethod methodSql = new CeErpMethod();
  7177. methodSql.con = entity.AfterSaleMethod;
  7178. methodSql.addTime = DateTime.Now;
  7179. methodSql.Create();
  7180. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7181. CeErpMethod.ExecuteNonQuery(delsql);
  7182. if (isCompale)
  7183. {
  7184. aftersale_data_change(entity.ctid);
  7185. }
  7186. returnSuccessMsg("操作成功!");
  7187. return;
  7188. }
  7189. returnErrorMsg("找不到订单记录");
  7190. }
  7191. }
  7192. public void ins_erp_toresponsible()
  7193. {
  7194. if (UrlPostParmsCheck("ctid"))
  7195. {
  7196. string eid = GetPostString("ctid");
  7197. CeErpTradeCell entity = null;
  7198. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7199. if (entity != null)
  7200. {
  7201. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7202. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7203. {
  7204. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7205. return;
  7206. }
  7207. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7208. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7209. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7210. if (entity.AfterSalePreTime == null)
  7211. {
  7212. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7213. {
  7214. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7215. }
  7216. }
  7217. entity.AfterSalePreTime = DateTime.Now;
  7218. //预完成给售后主管审核客户问题直接完成
  7219. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7220. {
  7221. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7222. {
  7223. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7224. }
  7225. }
  7226. ceErpTradeAfterSaleExtend.Update();
  7227. entity.AfterSaleState = 2;
  7228. entity.UpdateTime = DateTime.Now;
  7229. entity.Update();
  7230. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7231. aftersale_data_change(entity.ctid);
  7232. returnSuccessMsg("操作成功!");
  7233. return;
  7234. }
  7235. returnErrorMsg("找不到订单记录");
  7236. }
  7237. }
  7238. public void cancel_erp_aftersaleanddelnew()
  7239. {
  7240. if (UrlPostParmsCheck("ctid"))
  7241. {
  7242. string eid = GetPostString("ctid");
  7243. CeErpTradeCell entity = null;
  7244. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7245. if (entity != null)
  7246. {
  7247. entity.AfterSaleState = 0;
  7248. entity.AfterSaleReason = "";
  7249. entity.AfterSaleMethod = "";
  7250. entity.AfterSaleMemo = "";
  7251. entity.AfterSaleResponsible = "";
  7252. entity.ResponsibleUserId = "";
  7253. entity.DeductFee = 0;
  7254. entity.RefundFee = 0;
  7255. entity.IsArbitrate = 0;
  7256. CeErpTradeResponsible.DelByTid(eid, -1);
  7257. entity.Update();
  7258. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7259. if (after != null)
  7260. {
  7261. if (after.OrderState < 5)
  7262. CeErpTradeCell.DelByCtid("S_" + eid);
  7263. }
  7264. returnSuccessMsg("操作成功!");
  7265. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7266. return;
  7267. }
  7268. returnErrorMsg("找不到订单记录");
  7269. }
  7270. }
  7271. public void get_erp_aftersale_pregather()
  7272. {
  7273. List<string> lw = new List<string>();
  7274. int st = GetInt("st");
  7275. string tid = GetPostString("ctid");
  7276. if (tid.Length > 0)
  7277. {
  7278. string select_tid = getTidByCtid(tid);
  7279. lw.Add(string.Format("tid='{0}'", select_tid));
  7280. }
  7281. string shopname = GetPostString("shopname");
  7282. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7283. string buyernick = GetPostString("buyer_nick");
  7284. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7285. string sellermemo = GetPostString("seller_memo");
  7286. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7287. string orderState = GetPostString("orderState");
  7288. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7289. string reason = GetPostString("reason");
  7290. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7291. string method = GetPostString("method");
  7292. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7293. string handler = GetPostString("handler");
  7294. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7295. string handledate1 = GetPostString("handledate1");
  7296. string handledate2 = GetPostString("handledate2");
  7297. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7298. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7299. string supplier = GetPostString("supplier");
  7300. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7301. string responsible = GetPostString("responsibleman");
  7302. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7303. string customer = GetPostString("customer");
  7304. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7305. string design = GetPostString("design");
  7306. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7307. string afterMemoType = GetPostString("aftermemotype");
  7308. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7309. string afterSaleMemo = GetPostString("afterSaleMemo");
  7310. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7311. string afterresult = GetPostString("afterresult");
  7312. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7313. string poscode = CurrentUser.UserPost.Post.Code;
  7314. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7315. {
  7316. string shopid = CurrentUser.User.pemShop;
  7317. lw.Add(string.Format("shopId in ({0})", shopid));
  7318. }
  7319. var mainwhere = string.Join(" and ", lw.ToArray());
  7320. string ro_json = "";
  7321. string type = GetPostString("gather_type");
  7322. int number = 0;
  7323. if (poscode == "AfterSale")
  7324. {
  7325. //处理中
  7326. if (type == "Handling")
  7327. {
  7328. 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) : ""));
  7329. DataTable dt = null;
  7330. try
  7331. {
  7332. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7333. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7334. }
  7335. catch (Exception e)
  7336. {
  7337. dt = new DataTable();
  7338. }
  7339. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7340. return;
  7341. }
  7342. if (type == "Wait")
  7343. {
  7344. //待处理
  7345. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7346. DataTable dt1 = null;
  7347. try
  7348. {
  7349. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7350. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7351. }
  7352. catch (Exception e)
  7353. {
  7354. dt1 = new DataTable();
  7355. }
  7356. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7357. return;
  7358. }
  7359. if (type == "back")
  7360. {
  7361. //打回
  7362. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7363. DataTable dt2 = null;
  7364. try
  7365. {
  7366. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7367. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7368. }
  7369. catch (Exception e)
  7370. {
  7371. dt2 = new DataTable();
  7372. }
  7373. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7374. return;
  7375. }
  7376. if (type == "preCompletion")
  7377. {
  7378. //预完成
  7379. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7380. DataTable dt3 = null;
  7381. try
  7382. {
  7383. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7384. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7385. }
  7386. catch (Exception e)
  7387. {
  7388. dt3 = new DataTable();
  7389. }
  7390. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7391. return;
  7392. }
  7393. if (type == "documentary")
  7394. {
  7395. //跟单中
  7396. 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) : ""));
  7397. DataTable dt4 = null;
  7398. try
  7399. {
  7400. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7401. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7402. }
  7403. catch (Exception e)
  7404. {
  7405. dt4 = new DataTable();
  7406. }
  7407. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7408. return;
  7409. }
  7410. if (type == "reBack")
  7411. {
  7412. //被打回
  7413. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7414. DataTable dt1 = null;
  7415. try
  7416. {
  7417. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7418. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7419. }
  7420. catch (Exception e)
  7421. {
  7422. dt1 = new DataTable();
  7423. }
  7424. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7425. return;
  7426. }
  7427. }
  7428. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7429. {
  7430. if (type == "puBack")
  7431. {
  7432. //退回
  7433. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7434. DataTable dt = null;
  7435. try
  7436. {
  7437. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7438. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7439. }
  7440. catch (Exception e)
  7441. {
  7442. dt = new DataTable();
  7443. }
  7444. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7445. return;
  7446. }
  7447. if (type == "reBack")
  7448. {
  7449. //打回
  7450. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7451. DataTable dt1 = null;
  7452. try
  7453. {
  7454. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7455. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7456. }
  7457. catch (Exception e)
  7458. {
  7459. dt1 = new DataTable();
  7460. }
  7461. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7462. return;
  7463. }
  7464. if (type == "examEd")
  7465. {
  7466. //已审核
  7467. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7468. DataTable dt2 = null;
  7469. try
  7470. {
  7471. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7472. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7473. }
  7474. catch (Exception e)
  7475. {
  7476. dt2 = new DataTable();
  7477. }
  7478. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7479. return;
  7480. }
  7481. if (type == "waitExam")
  7482. {
  7483. //待审核
  7484. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7485. DataTable dt3 = null;
  7486. try
  7487. {
  7488. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7489. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7490. }
  7491. catch (Exception e)
  7492. {
  7493. dt3 = new DataTable();
  7494. }
  7495. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7496. return;
  7497. }
  7498. if (type == "Handling")
  7499. {
  7500. //处理中
  7501. 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) : ""));
  7502. DataTable dt4 = null;
  7503. try
  7504. {
  7505. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7506. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7507. }
  7508. catch (Exception e)
  7509. {
  7510. dt4 = new DataTable();
  7511. }
  7512. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7513. return;
  7514. }
  7515. if (type == "Wait")
  7516. {
  7517. //待处理
  7518. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7519. DataTable dt5 = null;
  7520. try
  7521. {
  7522. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7523. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7524. }
  7525. catch (Exception e)
  7526. {
  7527. dt5 = new DataTable();
  7528. }
  7529. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7530. return;
  7531. }
  7532. if (type == "documentary")
  7533. {
  7534. //跟单中
  7535. 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) : ""));
  7536. DataTable dt6 = null;
  7537. try
  7538. {
  7539. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7540. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7541. }
  7542. catch (Exception e)
  7543. {
  7544. dt6 = new DataTable();
  7545. }
  7546. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7547. return;
  7548. }
  7549. }
  7550. returnSuccess(ro_json);
  7551. }
  7552. public void end_erp_aftersale()
  7553. {
  7554. if (UrlPostParmsCheck("ctid"))
  7555. {
  7556. string eid = GetPostString("ctid");
  7557. CeErpTradeCell entity = null;
  7558. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7559. if (entity != null)
  7560. {
  7561. string stype = GetPostString("stype");
  7562. string typeStr = stype;
  7563. entity.AfterSaleState = 4;
  7564. entity.FinishAfterSaleTime = DateTime.Now;
  7565. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7566. entity.Update();
  7567. ApiVo apiVo = new ApiVo();
  7568. apiVo.orderNumber = entity.ctid;
  7569. apiVo.actionName = "afterOver";
  7570. designHelper.API_WorkCore(apiVo); //afterOver
  7571. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7572. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7573. CeErpSukuraData.createInfo(entity.ctid, 8);
  7574. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7575. returnSuccessMsg("操作成功!");
  7576. return;
  7577. }
  7578. returnErrorMsg("找不到订单记录");
  7579. }
  7580. }
  7581. public void ins_erp_finishaftersale()
  7582. {
  7583. if (UrlPostParmsCheck("id"))
  7584. {
  7585. string eid = GetPostString("id");
  7586. CeErpTradeResponsible entity = null;
  7587. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7588. if (entity != null)
  7589. {
  7590. entity.VerifyState = 1;
  7591. entity.VerifyTime = DateTime.Now;
  7592. entity.Update();
  7593. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7594. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7595. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7596. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7597. if (dt.Rows.Count <= 0)
  7598. {
  7599. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7600. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7601. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7602. CeErpSukuraData.createInfo(entity.tid, 8);
  7603. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7604. {
  7605. CeErpDesignerBill.Del(entity.tid);
  7606. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7607. }
  7608. }
  7609. returnSuccessMsg("操作成功!");
  7610. return;
  7611. }
  7612. returnErrorMsg("找不到订单记录");
  7613. }
  7614. }
  7615. public void upd_erp_arbitrateaftersale()
  7616. {
  7617. if (UrlPostParmsCheck("id"))
  7618. {
  7619. string eid = GetPostString("id");
  7620. CeErpTradeResponsible entity = null;
  7621. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7622. if (entity != null)
  7623. {
  7624. entity.IsArbitrate = 1;
  7625. entity.ArbitradeMemo = GetPostString("reason");
  7626. entity.VerifyState = 2;
  7627. entity.Update();
  7628. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7629. if (tradecell != null)
  7630. {
  7631. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7632. tradecell.IsArbitrate = 1;
  7633. tradecell.Update();
  7634. }
  7635. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7636. returnSuccessMsg("操作成功!");
  7637. return;
  7638. }
  7639. returnErrorMsg("找不到订单记录");
  7640. }
  7641. }
  7642. public void upd_erp_backaftersale()
  7643. {
  7644. if (UrlPostParmsCheck("tid"))
  7645. {
  7646. string eid = GetPostString("tid");
  7647. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7648. int backNum = 0;
  7649. if (number != null)
  7650. {
  7651. backNum = number.BackNum;
  7652. }
  7653. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7654. CeErpTradeCell entity = null;
  7655. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7656. if (entity != null)
  7657. {
  7658. entity.AfterSaleBackReason = GetPostString("backreason");
  7659. entity.AfterSaleState = 1;
  7660. entity.AfterSaleSupplierState = 0;
  7661. entity.UpdateTime = DateTime.Now;
  7662. entity.Update();
  7663. returnSuccessMsg("操作成功!");
  7664. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7665. return;
  7666. }
  7667. returnErrorMsg("找不到订单记录");
  7668. }
  7669. }
  7670. public void get_erp_supplieraftersalelist()
  7671. {
  7672. DataStruct dStruct = GetPostStruct();
  7673. List<string> lw = new List<string>();
  7674. string tid = GetPostString("ctid");
  7675. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7676. string shopname = GetPostString("shopname");
  7677. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7678. string buyernick = GetPostString("buyer_nick");
  7679. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7680. string sellermemo = GetPostString("seller_memo");
  7681. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7682. string orderState = GetPostString("orderState");
  7683. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7684. string afterState = GetPostString("afterstate");
  7685. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7686. string date1 = GetPostString("date1");
  7687. string date2 = GetPostString("date2");
  7688. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7689. if (dw.Length > 0) lw.Add(dw);
  7690. string price1 = GetPostString("price1");
  7691. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7692. string price2 = GetPostString("price2");
  7693. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7694. string reason = GetPostString("reason");
  7695. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7696. string method = GetPostString("method");
  7697. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7698. string handledate1 = GetPostString("handledate1");
  7699. string handledate2 = GetPostString("handledate2");
  7700. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7701. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7702. string handler = GetPostString("handler");
  7703. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7704. string afterdate1 = GetPostString("afterdate1");
  7705. string afterdate2 = GetPostString("afterdate2");
  7706. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7707. if (afterDate.Length > 0) lw.Add(afterDate);
  7708. string customer = GetPostString("customer");
  7709. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7710. string design = GetPostString("design");
  7711. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7712. string afterMemoType = GetPostString("aftermemotype");
  7713. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7714. string vstate = GetPostString("vstate");
  7715. if (vstate.Length > 0)
  7716. {
  7717. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7718. }
  7719. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7720. string supplier = GetPostString("supplier");
  7721. int supid = commonHelper.getSupplierIDByName(supplier);
  7722. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7723. string posCode = CurrentUser.UserPost.Post.Code;
  7724. if (posCode == "Supplier")
  7725. {
  7726. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7727. }
  7728. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7729. {
  7730. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7731. }
  7732. else
  7733. {
  7734. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7735. }
  7736. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7737. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7738. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7739. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7740. writeGridDataTableJson(dStruct.TotalCount, dt);
  7741. }
  7742. public void upd_erp_supverifyaftersale()
  7743. {
  7744. if (UrlPostParmsCheck("id"))
  7745. {
  7746. string id = GetPostString("id");
  7747. int st = GetPostInt("afterstate");
  7748. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7749. CeErpTradeCell entity = null;
  7750. if (ceErpTradeResponsible != null)
  7751. {
  7752. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7753. }
  7754. string afmemo = GetPostString("supmemo");
  7755. string image = GetPostString("image");
  7756. if (entity != null)
  7757. {
  7758. entity.AfterSaleSupplierState = st;
  7759. entity.AfterSaleSupplierMemo = afmemo;
  7760. if (st == 1)
  7761. {
  7762. ceErpTradeResponsible.VerifyState = 1;
  7763. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7764. ceErpTradeResponsible.Update();
  7765. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7766. if (isAll)
  7767. {
  7768. entity.AfterSaleState = 4;
  7769. entity.FinishAfterSaleTime = DateTime.Now;
  7770. }
  7771. }
  7772. else
  7773. {
  7774. CeErpTradeResponsible.dateByTid(entity.ctid);
  7775. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7776. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7777. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7778. if (num <= 1)
  7779. {
  7780. entity.AfterSaleState = 1;
  7781. }
  7782. else
  7783. {
  7784. entity.AfterSaleState = 5;
  7785. }
  7786. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7787. if (ceErpTradeAfterSaleExtend != null)
  7788. {
  7789. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7790. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7791. ceErpTradeAfterSaleExtend.Update();
  7792. }
  7793. else
  7794. {
  7795. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7796. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7797. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7798. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7799. ceErpTradeAfterSaleExtend.Create();
  7800. }
  7801. }
  7802. if (entity.AfterSaleState == 4)
  7803. {
  7804. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7805. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7806. {
  7807. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7808. }
  7809. ApiVo apiVo = new ApiVo();
  7810. apiVo.orderNumber = entity.ctid;
  7811. apiVo.actionName = "afterOver";
  7812. designHelper.API_WorkCore(apiVo); //afterOver
  7813. }
  7814. entity.UpdateTime = DateTime.Now;
  7815. entity.Update();
  7816. returnSuccessMsg("操作成功!");
  7817. CeErpSukuraData.createInfo(entity.ctid, 8);
  7818. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7819. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7820. return;
  7821. }
  7822. returnErrorMsg("找不到订单记录");
  7823. }
  7824. }
  7825. public void upd_erp_masteraftersale()
  7826. {
  7827. if (UrlPostParmsCheck("id"))
  7828. {
  7829. string id = GetPostString("id");
  7830. int st = GetPostInt("afterstate");
  7831. string afmemo = GetPostString("supmemo");
  7832. string image = GetPostString("image");
  7833. string textResult = GetPostString("textResult");
  7834. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7835. if (ceErpTradeResponsible != null)
  7836. {
  7837. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7838. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7839. ceErpTradeResponsible.Update();
  7840. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7841. if (entity != null)
  7842. {
  7843. entity.AfterSaleSupplierState = st;
  7844. entity.AfterSaleSupplierMemo = afmemo;
  7845. if (st == 1)
  7846. {
  7847. }
  7848. else
  7849. {
  7850. CeErpTradeResponsible.dateByTid(entity.ctid);
  7851. //退回到售后
  7852. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7853. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7854. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7855. if (num <= 1)
  7856. {
  7857. entity.AfterSaleState = 1;
  7858. }
  7859. else
  7860. {
  7861. entity.AfterSaleState = 5;
  7862. }
  7863. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7864. if (ceErpTradeAfterSaleExtend != null)
  7865. {
  7866. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7867. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7868. ceErpTradeAfterSaleExtend.Update();
  7869. }
  7870. else
  7871. {
  7872. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7873. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7874. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7875. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7876. ceErpTradeAfterSaleExtend.Create();
  7877. }
  7878. }
  7879. entity.UpdateTime = DateTime.Now;
  7880. entity.Update();
  7881. returnSuccessMsg("操作成功!");
  7882. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7883. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7884. return;
  7885. }
  7886. }
  7887. returnErrorMsg("找不到订单记录");
  7888. }
  7889. }
  7890. public void upd_erp_personaftersale()
  7891. {
  7892. if (UrlPostParmsCheck("id"))
  7893. {
  7894. //林小连
  7895. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7896. {
  7897. upd_erp_masteraftersale();
  7898. return;
  7899. }
  7900. string id = GetPostString("id");
  7901. int st = GetPostInt("afterstate");
  7902. string afmemo = GetPostString("supmemo");
  7903. string image = GetPostString("image");
  7904. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7905. if (ceErpTradeResponsible != null)
  7906. {
  7907. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7908. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7909. ceErpTradeResponsible.Update();
  7910. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7911. if (entity != null)
  7912. {
  7913. entity.AfterSaleSupplierMemo = afmemo;
  7914. entity.AfterSaleSupplierState = st;
  7915. if (st == 1)
  7916. {
  7917. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7918. if (isAll)
  7919. {
  7920. entity.AfterSaleState = 4;
  7921. entity.FinishAfterSaleTime = DateTime.Now;
  7922. }
  7923. }
  7924. else
  7925. {
  7926. CeErpTradeResponsible.dateByTid(entity.ctid);
  7927. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7928. if (ceErpTradeAfterSaleExtend != null)
  7929. {
  7930. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7931. ceErpTradeAfterSaleExtend.Update();
  7932. }
  7933. else
  7934. {
  7935. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7936. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7937. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7938. ceErpTradeAfterSaleExtend.Create();
  7939. }
  7940. //退回到主管
  7941. //entity.AfterSaleState = 2;
  7942. }
  7943. if (entity.AfterSaleState == 4)
  7944. {
  7945. ApiVo apiVo = new ApiVo();
  7946. apiVo.orderNumber = entity.ctid;
  7947. apiVo.actionName = "afterOver";
  7948. designHelper.API_WorkCore(apiVo); //afterOver
  7949. }
  7950. entity.UpdateTime = DateTime.Now;
  7951. entity.Update();
  7952. returnSuccessMsg("操作成功!");
  7953. CeErpSukuraData.createInfo(entity.ctid, 8);
  7954. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7955. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7956. return;
  7957. }
  7958. }
  7959. returnErrorMsg("找不到订单记录");
  7960. }
  7961. }
  7962. public void set_erp_supplierrefundtag()
  7963. {
  7964. if (UrlPostParmsCheck("ctid"))
  7965. {
  7966. string eid = GetPostString("ctid");
  7967. CeErpTradeCell entity = null;
  7968. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7969. if (entity != null)
  7970. {
  7971. entity.IsSupplierRefund = GetPostInt("tag");
  7972. entity.Update();
  7973. returnSuccessMsg("操作成功!");
  7974. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7975. return;
  7976. }
  7977. returnErrorMsg("找不到订单记录");
  7978. }
  7979. }
  7980. public void get_erp_refundlist()
  7981. {
  7982. DataStruct dStruct = GetPostStruct();
  7983. List<string> lw = new List<string>();
  7984. string tid = GetPostString("tid");
  7985. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7986. //string rid = GetPostString("refund_id");
  7987. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7988. string shopname = GetPostString("shopname");
  7989. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7990. string buyernick = GetPostString("buyer_nick");
  7991. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7992. string customer = GetPostString("customer");
  7993. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7994. string design = GetPostString("design");
  7995. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7996. string sellermemo = GetPostString("seller_memo");
  7997. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7998. //string date1 = GetPostString("date1");
  7999. //string date2 = GetPostString("date2");
  8000. //string dateType = GetPostString("dateType");
  8001. //if (dateType.Length > 0)
  8002. //{
  8003. // if (dateType == "1001") dateType = "0";
  8004. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  8005. // if (searchDT.Count == 2)
  8006. // {
  8007. // date1 = searchDT[0].ToString();
  8008. // date2 = searchDT[1].ToString();
  8009. // }
  8010. //}
  8011. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8012. //if (dw.Length > 0) lw.Add(dw);
  8013. string redate1 = GetPostString("refunddate1");
  8014. string redate2 = GetPostString("refunddate2");
  8015. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8016. if (dwdate.Length > 0) lw.Add(dwdate);
  8017. string price1 = GetPostString("price1");
  8018. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8019. string price2 = GetPostString("price2");
  8020. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8021. string ispartrefund = GetPostString("ispartrefund");
  8022. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8023. string refundState = GetPostString("refundvstate");
  8024. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  8025. int st = GetInt("st");
  8026. if (st == 2) //待确认列表中,把state=3已确认的也显示
  8027. {
  8028. string responsible = GetPostString("responsibleman");
  8029. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8030. lw.Add(string.Format("RefundState>={0}", st));
  8031. string code = CurrentUser.UserPost.Post.Code;
  8032. if (code == "CustomerService")
  8033. {
  8034. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  8035. }
  8036. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  8037. {
  8038. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  8039. }
  8040. else if (code == "Place" || code == "PlaceMr")
  8041. {
  8042. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8043. }
  8044. dStruct.Order = "RefundState asc,created desc";
  8045. }
  8046. else if (st == 10)
  8047. {
  8048. string responsible = GetPostString("responsibleman");
  8049. if (responsible == "空白")
  8050. {
  8051. lw.Add(string.Format("ResponsibleUserName = ''"));
  8052. }
  8053. else if (responsible.Length > 0)
  8054. {
  8055. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8056. }
  8057. lw.Add(string.Format("RefundState>=0"));
  8058. dStruct.Order = "created desc";
  8059. }
  8060. else
  8061. {
  8062. string responsible = GetPostString("responsibleman");
  8063. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8064. lw.Add(string.Format("RefundState={0}", st));
  8065. dStruct.Order = "created desc";
  8066. }
  8067. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8068. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8069. dt.Columns.Add("refund_fees");
  8070. foreach (DataRow dr in dt.Rows)
  8071. {
  8072. String status = dr["status"].ToString();
  8073. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8074. {
  8075. dr["refund_fees"] = dr["refund_fee"];
  8076. }
  8077. else
  8078. {
  8079. dr["refund_fees"] = "0.0";
  8080. }
  8081. }
  8082. writeGridDataTableJson(dStruct.TotalCount, dt);
  8083. }
  8084. public void get_erp_refunddesignlist()
  8085. {
  8086. DataStruct dStruct = GetPostStruct();
  8087. List<string> lw = new List<string>();
  8088. string tid = GetPostString("tid");
  8089. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8090. string shopname = GetPostString("shopname");
  8091. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8092. string buyernick = GetPostString("buyer_nick");
  8093. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8094. string customer = GetPostString("customer");
  8095. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8096. string design = GetPostString("design");
  8097. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8098. string sellermemo = GetPostString("seller_memo");
  8099. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8100. string redate1 = GetPostString("refunddate1");
  8101. string redate2 = GetPostString("refunddate2");
  8102. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8103. if (dwdate.Length > 0) lw.Add(dwdate);
  8104. string price1 = GetPostString("price1");
  8105. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8106. string price2 = GetPostString("price2");
  8107. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8108. string ispartrefund = GetPostString("ispartrefund");
  8109. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8110. string designerorg = GetPostString("designerorg");
  8111. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8112. string refundState = GetPostString("refundState");
  8113. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8114. int myOrgid = CurrentUser.UserPost.OrgID;
  8115. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8116. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8117. {
  8118. if (CurrentUser.User.TeamIds.Length > 0)
  8119. {
  8120. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8121. }
  8122. else
  8123. {
  8124. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8125. }
  8126. }
  8127. else if ("SysAdmin".Equals(myOrgCode))
  8128. {
  8129. }
  8130. else
  8131. {
  8132. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8133. {
  8134. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8135. }
  8136. else
  8137. {
  8138. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8139. }
  8140. }
  8141. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8142. dStruct.Order = "created desc";
  8143. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8144. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8145. dt.Columns.Add("refund_fees");
  8146. foreach (DataRow dr in dt.Rows)
  8147. {
  8148. String status = dr["status"].ToString();
  8149. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8150. {
  8151. dr["refund_fees"] = dr["refund_fee"];
  8152. }
  8153. else
  8154. {
  8155. dr["refund_fees"] = "0.0";
  8156. }
  8157. }
  8158. writeGridDataTableJson(dStruct.TotalCount, dt);
  8159. }
  8160. public void handle_erp_refundtag()
  8161. {
  8162. if (UrlPostParmsCheck("refund_id"))
  8163. {
  8164. string eid = GetPostString("refund_id");
  8165. string respMan = GetPostString("ResponsibleName");
  8166. if (respMan.Length <= 0)
  8167. {
  8168. returnErrorMsg("责任人不能为空");
  8169. return;
  8170. }
  8171. CeErpTradeRefund entity = null;
  8172. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8173. if (entity != null)
  8174. {
  8175. entity.ResponsibleUserName = respMan;
  8176. string userid = GetPostString("ResponsibleUserId");
  8177. if (userid.Length > 0)
  8178. {
  8179. entity.ResponsibleUserId = userid;
  8180. }
  8181. entity.Memo = GetPostString("Memo");
  8182. if (respMan.IndexOf("客服") != -1 ||
  8183. respMan.IndexOf("设计师") != -1 ||
  8184. respMan.IndexOf("下单员") != -1)
  8185. {
  8186. entity.RefundState = 2;
  8187. }
  8188. else
  8189. {
  8190. entity.RefundState = 3;
  8191. }
  8192. entity.modified = DateTime.Now;
  8193. entity.Update();
  8194. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8195. returnSuccessMsg("操作成功!");
  8196. return;
  8197. }
  8198. returnErrorMsg("找不到订单记录");
  8199. }
  8200. }
  8201. public void handle_erp_designrefundtag()
  8202. {
  8203. if (UrlPostParmsCheck("refund_id"))
  8204. {
  8205. string eid = GetPostString("refund_id");
  8206. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8207. if (ceErpTradeCellExtend == null)
  8208. {
  8209. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8210. ceErpTradeCellExtend.ctid = eid;
  8211. }
  8212. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8213. if (ceErpTradeCellExtend.ID > 0)
  8214. {
  8215. ceErpTradeCellExtend.Update();
  8216. }
  8217. else
  8218. {
  8219. ceErpTradeCellExtend.Create();
  8220. }
  8221. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8222. returnSuccessMsg("操作成功!");
  8223. return;
  8224. }
  8225. returnErrorMsg("找不到订单记录");
  8226. }
  8227. public void upd_erp_refundverify()
  8228. {
  8229. if (UrlPostParmsCheck("refund_id"))
  8230. {
  8231. string eid = GetPostString("refund_id");
  8232. CeErpTradeRefund entity = null;
  8233. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8234. if (entity != null)
  8235. {
  8236. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8237. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8238. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8239. {
  8240. entity.RefundState = 2;
  8241. }
  8242. else
  8243. {
  8244. entity.RefundState = 3;
  8245. }
  8246. entity.Update();
  8247. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8248. returnSuccessMsg("操作成功!");
  8249. return;
  8250. }
  8251. returnErrorMsg("找不到订单记录");
  8252. }
  8253. }
  8254. public void upd_erp_refundapprove()
  8255. {
  8256. if (UrlPostParmsCheck("refund_id"))
  8257. {
  8258. string eid = GetPostString("refund_id");
  8259. CeErpTradeRefund entity = null;
  8260. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8261. if (entity != null)
  8262. {
  8263. int apr = GetPostInt("approve");
  8264. if (apr == 0)
  8265. {
  8266. entity.RefundState = 1;
  8267. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8268. }
  8269. else if (apr == 1)
  8270. {
  8271. entity.RefundState = 3;
  8272. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8273. }
  8274. entity.modified = DateTime.Now;
  8275. entity.Update();
  8276. returnSuccessMsg("操作成功!");
  8277. return;
  8278. }
  8279. returnErrorMsg("找不到订单记录");
  8280. }
  8281. }
  8282. public void get_erp_billlist()
  8283. {
  8284. DataStruct dStruct = GetPostStruct();
  8285. List<string> lw = new List<string>();
  8286. string title = GetPostString("title");
  8287. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8288. string tid = GetPostString("tid");
  8289. string tids = GetPostString("tids");
  8290. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8291. if (tids.Length > 0)
  8292. {
  8293. tids = "'" + tids + "'";
  8294. tids = tids.Replace(",", "','");
  8295. lw.Add(string.Format("tid in ({0})", tids));
  8296. }
  8297. string shopname = GetPostString("shopname");
  8298. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8299. string buyernick = GetPostString("buyer_nick");
  8300. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8301. string customer = GetPostString("customer");
  8302. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8303. string date1 = GetPostString("date1");
  8304. string date2 = GetPostString("date2");
  8305. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8306. if (dw.Length > 0) lw.Add(dw);
  8307. string price1 = GetPostString("price1");
  8308. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8309. string price2 = GetPostString("price2");
  8310. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8311. string returndate1 = GetPostString("returndate1");
  8312. string returndate2 = GetPostString("returndate2");
  8313. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8314. if (dw1.Length > 0) lw.Add(dw1);
  8315. string billtype = GetPostString("billtype");
  8316. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8317. string billstate = GetPostString("billstate");
  8318. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8319. string usershop = CurrentUser.User.pemShop;
  8320. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8321. dStruct.Order = "createTime desc";
  8322. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8323. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8324. //foreach (DataRow dr in dt.Rows)
  8325. //{
  8326. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8327. //}
  8328. writeGridDataTableJson(dStruct.TotalCount, dt);
  8329. }
  8330. public void modify_erp_billinfo()
  8331. {
  8332. if (UrlPostParmsCheck("ID"))
  8333. {
  8334. string eid = GetPostString("ID");
  8335. CeErpBill bill_entity = null;
  8336. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8337. if (bill_entity != null)
  8338. {
  8339. bill_entity.tid = GetPostString("tid");
  8340. bill_entity.title = GetPostString("title");
  8341. bill_entity.tax = GetPostString("tax");
  8342. bill_entity.bank = GetPostString("bank");
  8343. bill_entity.bankac = GetPostString("bankac");
  8344. bill_entity.address = GetPostString("address");
  8345. bill_entity.phone = GetPostString("phone");
  8346. bill_entity.price = GetPostString("price");
  8347. bill_entity.productId = GetPostInt("ProductName");
  8348. bill_entity.num = GetPostInt("num");
  8349. bill_entity.unit = GetPostString("unit");
  8350. bill_entity.type = GetPostString("type");
  8351. bill_entity.sendType = GetPostString("SendType");
  8352. bill_entity.email = GetPostString("email");
  8353. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8354. bill_entity.shopName = GetPostString("ShopName");
  8355. bill_entity.applymemo = GetPostString("applymemo");
  8356. bill_entity.modifyTime = DateTime.Now;
  8357. bill_entity.createTime = DateTime.Now;
  8358. bill_entity.state = 0;
  8359. bill_entity.Update();
  8360. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8361. returnSuccessMsg("发票修改成功!");
  8362. return;
  8363. }
  8364. returnErrorMsg("找不到对应记录");
  8365. }
  8366. }
  8367. public void set_erp_invoicing()
  8368. {
  8369. if (UrlPostParmsCheck("id"))
  8370. {
  8371. try
  8372. {
  8373. string eid = GetPostString("id");
  8374. CeErpBill bill_entity = null;
  8375. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8376. if (bill_entity != null)
  8377. {
  8378. int ComId = GetPostInt("ComId");
  8379. //string memo = GetPostString("Memo");
  8380. int allInfo = GetPostInt("allinfo");
  8381. string clert = CurrentUser.User.Name;
  8382. //string detailValue = GetPostString("detailvalue");
  8383. string billId = bill_entity.billOrderId;
  8384. string[] billIdList = billId.Split(',');
  8385. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8386. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8387. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8388. {
  8389. billCount += 1;
  8390. }
  8391. if (billId.Length <= 0 || billIdList.Length != billCount)
  8392. {
  8393. bill_entity.billOrderId = "";
  8394. string prebill = "ltb";
  8395. for (int idx = 1; idx <= billCount; idx++)
  8396. {
  8397. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8398. string billoid = prebill + idx + dtstr;
  8399. bill_entity.billOrderId += billoid;
  8400. if (idx < billCount)
  8401. {
  8402. bill_entity.billOrderId += ",";
  8403. }
  8404. }
  8405. }
  8406. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8407. if (bill_entity.state == 5)
  8408. {
  8409. string errMsg = bill_entity.failerror;
  8410. string[] errlist = errMsg.Split('|');
  8411. string[] errTags = new string[errlist.Length];
  8412. for (int itag = 0; itag < errlist.Length; itag++)
  8413. {
  8414. if (errlist[itag].Length <= 0) continue;
  8415. errTags[itag] = errlist[itag].Split('&')[0];
  8416. }
  8417. for (int iii = 0; iii < errTags.Length; iii++)
  8418. {
  8419. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8420. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8421. if (billOrderList.Length >= erroBillOrderTag)
  8422. {
  8423. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8424. if (needModifyBillId.Length <= 19)
  8425. {
  8426. needModifyBillId = needModifyBillId + "1";
  8427. }
  8428. else
  8429. {
  8430. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8431. last = last + 1;
  8432. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8433. }
  8434. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8435. }
  8436. }
  8437. }
  8438. bool isHaveBillSucces = false;
  8439. string totalRes = "";
  8440. bill_entity.failerror = "";
  8441. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8442. {
  8443. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8444. totalRes += res;
  8445. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8446. {
  8447. isHaveBillSucces = true;
  8448. bill_entity.comId = ComId;
  8449. bill_entity.state = 1;
  8450. bill_entity.executeTime = DateTime.Now;
  8451. bill_entity.executeUser = clert;
  8452. }
  8453. else
  8454. {
  8455. bill_entity.state = 5;
  8456. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8457. }
  8458. }
  8459. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8460. bill_entity.Update();
  8461. if (isHaveBillSucces)
  8462. {
  8463. StringBuilder sql = new StringBuilder();
  8464. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8465. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8466. }
  8467. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8468. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8469. {
  8470. returnErrorMsg("开票失败");
  8471. }
  8472. else
  8473. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8474. return;
  8475. }
  8476. returnErrorMsg("找不到对应记录");
  8477. }
  8478. catch (Exception ex)
  8479. {
  8480. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8481. returnErrorMsg("操作失败");
  8482. }
  8483. }
  8484. }
  8485. public void get_erp_invoicing_back()
  8486. {
  8487. if (UrlPostParmsCheck("id"))
  8488. {
  8489. try
  8490. {
  8491. string id = GetPostString("id");
  8492. CeErpBill entiy = CeErpBill.Get(id);
  8493. if (entiy != null)
  8494. {
  8495. if (entiy.state == 0)
  8496. {
  8497. returnErrorMsg("发票还未开具");
  8498. return;
  8499. }
  8500. string[] billOrderList = entiy.billOrderId.Split(',');
  8501. int iTag = 0;
  8502. entiy.fplsh = "";
  8503. entiy.fpdm = "";
  8504. entiy.fphm = "";
  8505. foreach (string billOrderId in billOrderList)
  8506. {
  8507. iTag++;
  8508. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8509. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8510. {
  8511. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8512. try
  8513. {
  8514. Invoicing_get_response_Obj iObj = null;
  8515. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8516. if (iObj != null)
  8517. {
  8518. entiy.state = 2;
  8519. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8520. entiy.fpdm += iObj.list[0].c_fpdm;
  8521. entiy.fphm += iObj.list[0].c_fphm;
  8522. if (iTag < billOrderList.Length)
  8523. {
  8524. entiy.fplsh += ",";
  8525. entiy.fpdm += ",";
  8526. entiy.fphm += ",";
  8527. }
  8528. entiy.Update();
  8529. }
  8530. StringBuilder sql = new StringBuilder();
  8531. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8532. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8533. returnSuccessMsg("开票成功");
  8534. }
  8535. catch (Exception ex)
  8536. {
  8537. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8538. }
  8539. return;
  8540. }
  8541. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8542. {
  8543. var res_obj = new
  8544. {
  8545. data = "开票中"
  8546. };
  8547. string ro_json = JsonConvert.SerializeObject(res_obj);
  8548. returnSuccess(ro_json);
  8549. return;
  8550. }
  8551. else
  8552. {
  8553. int eidx = res.IndexOf("c_resultmsg");
  8554. int lidx = res.IndexOf("c_status");
  8555. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8556. entiy.state = 5;
  8557. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8558. entiy.Update();
  8559. returnErrorMsg("开票失败");
  8560. return;
  8561. }
  8562. }
  8563. }
  8564. }
  8565. catch (Exception ex)
  8566. {
  8567. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8568. }
  8569. return;
  8570. }
  8571. }
  8572. public void get_erp_invoicing()
  8573. {
  8574. if (UrlPostParmsCheck("id"))
  8575. {
  8576. try
  8577. {
  8578. string id = GetPostString("id");
  8579. CeErpBill entiy = CeErpBill.Get(id);
  8580. if (entiy != null)
  8581. {
  8582. if (entiy.state == 0)
  8583. {
  8584. returnErrorMsg("发票还未开具");
  8585. return;
  8586. }
  8587. if (entiy.sendType == "纸质发票")
  8588. {
  8589. if (entiy.img.Length <= 0)
  8590. {
  8591. returnErrorMsg("查无纸质发票");
  8592. return;
  8593. }
  8594. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8595. returnSuccess(returnres);
  8596. return;
  8597. }
  8598. string[] billOrderList = entiy.billOrderId.Split(',');
  8599. int iTag = 0;
  8600. string fpUrl = "";
  8601. entiy.fplsh = "";
  8602. entiy.fpdm = "";
  8603. entiy.fphm = "";
  8604. foreach (string billOrderId in billOrderList)
  8605. {
  8606. iTag++;
  8607. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8608. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8609. {
  8610. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8611. Invoicing_get_response_Obj iObj = null;
  8612. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8613. if (iObj != null)
  8614. {
  8615. //entiy.state = 2;
  8616. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8617. entiy.fpdm += iObj.list[0].c_fpdm;
  8618. entiy.fphm += iObj.list[0].c_fphm;
  8619. if (iTag < billOrderList.Length)
  8620. {
  8621. entiy.fplsh += ",";
  8622. entiy.fpdm += ",";
  8623. entiy.fphm += ",";
  8624. }
  8625. entiy.Update();
  8626. fpUrl += iObj.list[0].c_url + ",";
  8627. }
  8628. //returnSuccess(res);
  8629. StringBuilder sql = new StringBuilder();
  8630. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8631. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8632. }
  8633. else
  8634. {
  8635. int eidx = res.IndexOf("c_resultmsg");
  8636. //int lidx = res.IndexOf("c_status");
  8637. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8638. //开票失败
  8639. entiy.state = 5;
  8640. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8641. entiy.Update();
  8642. returnErrorMsg("开票失败");
  8643. return;
  8644. }
  8645. }
  8646. var returnObj = new
  8647. {
  8648. data = fpUrl
  8649. };
  8650. string ro_json = JsonConvert.SerializeObject(returnObj);
  8651. returnSuccess(ro_json);
  8652. }
  8653. }
  8654. catch (Exception ex)
  8655. {
  8656. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8657. }
  8658. return;
  8659. }
  8660. }
  8661. public void save_erp_billimg()
  8662. {
  8663. if (UrlPostParmsCheck("id"))
  8664. {
  8665. string eid = GetPostString("id");
  8666. CeErpBill bill_entity = null;
  8667. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8668. if (bill_entity != null)
  8669. {
  8670. bill_entity.img = GetPostString("img");
  8671. bill_entity.executeTime = DateTime.Now;
  8672. bill_entity.state = 2;
  8673. bill_entity.Update();
  8674. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8675. returnSuccessMsg("保存成功");
  8676. }
  8677. return;
  8678. }
  8679. }
  8680. public void upd_erp_billreturnback()
  8681. {
  8682. if (UrlPostParmsCheck("id"))
  8683. {
  8684. int eid = GetPostInt("id");
  8685. CeErpBill bill_entity = null;
  8686. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8687. if (bill_entity != null)
  8688. {
  8689. bill_entity.state = 3;
  8690. bill_entity.returnReason = GetPostString("reason");
  8691. bill_entity.Update();
  8692. returnSuccessMsg("驳回成功!");
  8693. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8694. }
  8695. return;
  8696. }
  8697. }
  8698. public void cancel_erp_bill()
  8699. {
  8700. if (UrlPostParmsCheck("id"))
  8701. {
  8702. int eid = GetPostInt("id");
  8703. int detailValue = GetPostInt("detailvalue");
  8704. CeErpBill bill_entity = null;
  8705. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8706. string cres = "";
  8707. string gres = "";
  8708. if (bill_entity != null)
  8709. {
  8710. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8711. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8712. {
  8713. int iTag = 0;
  8714. bill_entity.fplsh = "";
  8715. bill_entity.fpdm = "";
  8716. bill_entity.fphm = "";
  8717. foreach (string billOrderId in billOrderList)
  8718. {
  8719. iTag++;
  8720. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8721. if (gres.IndexOf("success") != -1)
  8722. {
  8723. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8724. Invoicing_get_response_Obj iObj = null;
  8725. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8726. if (iObj != null)
  8727. {
  8728. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8729. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8730. bill_entity.fphm += iObj.list[0].c_fphm;
  8731. if (iTag < billOrderList.Length)
  8732. {
  8733. bill_entity.fplsh += ",";
  8734. bill_entity.fpdm += ",";
  8735. bill_entity.fphm += ",";
  8736. }
  8737. bill_entity.Update();
  8738. }
  8739. }
  8740. else
  8741. {
  8742. returnErrorMsg(gres);
  8743. return;
  8744. }
  8745. }
  8746. }
  8747. if (bill_entity.sendType == "纸质发票")
  8748. {
  8749. //作废
  8750. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8751. //if (DateTime.Now.Month == extime.Month)
  8752. //{
  8753. //cres = taobaoHelper.cancel_invoicing(eid);
  8754. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8755. //{
  8756. bill_entity.state = 4;//已作废
  8757. bill_entity.Update();
  8758. returnSuccessMsg("发票已作废");
  8759. return;
  8760. //}
  8761. //else
  8762. //{
  8763. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8764. // bill_entity.Update();
  8765. // returnErrorMsg(cres);
  8766. // return;
  8767. //}
  8768. //}
  8769. //else
  8770. //{
  8771. // returnErrorMsg("纸质发票只能作废本月的发票");
  8772. // return;
  8773. //}
  8774. }
  8775. //红冲
  8776. int redTag = 0;
  8777. string[] fpdmList = bill_entity.fpdm.Split(',');
  8778. string[] fphmList = bill_entity.fphm.Split(',');
  8779. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8780. {
  8781. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8782. return;
  8783. }
  8784. foreach (string billOrderId in billOrderList)
  8785. {
  8786. redTag++;
  8787. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8788. cres += onecres;
  8789. cres += ",";
  8790. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8791. {
  8792. bill_entity.state = 4;//已作废
  8793. //bill_entity.Update();
  8794. //returnSuccessMsg("发票已红冲");
  8795. }
  8796. else if (onecres.IndexOf("重复冲红") != -1)
  8797. {
  8798. bill_entity.state = 4;//已作废
  8799. //bill_entity.Update();
  8800. //returnSuccessMsg("发票已红冲");
  8801. }
  8802. else
  8803. {
  8804. string errmsg = commonHelper.KeepChinese(onecres);
  8805. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8806. }
  8807. }
  8808. bill_entity.Update();
  8809. if (cres.IndexOf("失败") != -1)
  8810. returnErrorMsg("红冲失败");
  8811. else
  8812. returnSuccessMsg("发票已红冲");
  8813. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8814. return;
  8815. }
  8816. return;
  8817. }
  8818. }
  8819. public void del_erp_billorder()
  8820. {
  8821. if (UrlPostParmsCheck("id"))
  8822. {
  8823. string eid = GetPostString("id");
  8824. CeErpBill.Del(eid);
  8825. CeErpBill bill = CeErpBill.Get(eid);
  8826. if (bill != null)
  8827. {
  8828. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8829. }
  8830. returnSuccessMsg("删除成功");
  8831. }
  8832. }
  8833. public void finish_erp_bill()
  8834. {
  8835. if (UrlPostParmsCheck("ids"))
  8836. {
  8837. string eids = GetPostString("ids");
  8838. string[] list = eids.Split(',');
  8839. foreach (string eid in list)
  8840. {
  8841. CeErpBill bill = CeErpBill.Get(eid);
  8842. if (bill != null)
  8843. {
  8844. bill.state = 2;
  8845. bill.Update();
  8846. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8847. }
  8848. }
  8849. returnSuccessMsg("操作成功");
  8850. }
  8851. }
  8852. public void get_erp_returncash()
  8853. {
  8854. DataStruct dStruct = GetPostStruct();
  8855. List<string> lw = new List<string>();
  8856. string tid = GetPostString("tid");
  8857. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8858. string shopname = GetPostString("shopname");
  8859. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8860. string buyernick = GetPostString("buyer_nick");
  8861. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8862. string customer = GetPostString("customer");
  8863. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8864. string returndate1 = GetPostString("returndate1");
  8865. string returndate2 = GetPostString("returndate2");
  8866. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8867. if (dw.Length > 0) lw.Add(dw);
  8868. string finishDate1 = GetPostString("finishdate1");
  8869. string finishDate2 = GetPostString("finishdate2");
  8870. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8871. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8872. string returntype = GetPostString("returntype");
  8873. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8874. string returnvstate = GetPostString("returnvstate");
  8875. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8876. dStruct.Order = "created desc";
  8877. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8878. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8879. writeGridDataTableJson(dStruct.TotalCount, dt);
  8880. }
  8881. public void get_erp_staygoods()
  8882. {
  8883. DataStruct dStruct = GetPostStruct();
  8884. List<string> lw = new List<string>();
  8885. string tid = GetPostString("tid");
  8886. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8887. string shopname = GetPostString("shopname");
  8888. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8889. string wangwang = GetPostString("wangwang");
  8890. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8891. string customer = GetPostString("customer");
  8892. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8893. string returndate1 = GetPostString("returndate1");
  8894. string returndate2 = GetPostString("returndate2");
  8895. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8896. if (dw.Length > 0) lw.Add(dw);
  8897. string finishDate1 = GetPostString("finishdate1");
  8898. string finishDate2 = GetPostString("finishdate2");
  8899. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8900. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8901. string returnvstate = GetPostString("returnvstate");
  8902. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8903. string persuadetype = GetPostString("persuadetype");
  8904. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8905. string customerOrg = GetPostString("customerOrg");
  8906. if (customerOrg.Length > 0)
  8907. {
  8908. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8909. }
  8910. string designerorg = GetPostString("designerorg");
  8911. if (designerorg.Length > 0)
  8912. {
  8913. lw.Add(string.Format("OrgID = {0}", designerorg));
  8914. }
  8915. dStruct.Order = "creata_time desc";
  8916. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8917. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8918. writeGridDataTableJson(dStruct.TotalCount, dt);
  8919. }
  8920. public void upd_erp_staygoods()
  8921. {
  8922. if (UrlPostParmsCheck("id"))
  8923. {
  8924. int eid = GetPostInt("id");
  8925. CeErpStayGoods entity = null;
  8926. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8927. if (entity != null)
  8928. {
  8929. entity.audit_type = 1;
  8930. entity.audit_time = DateTime.Now;
  8931. entity.audit_u_id = CurrentUser.UserID;
  8932. entity.audit_u_name = CurrentUser.UserName;
  8933. entity.Update();
  8934. returnSuccessMsg("审核成功!");
  8935. return;
  8936. }
  8937. returnErrorMsg("找不到订单记录");
  8938. }
  8939. }
  8940. public void upd_erp_stayGoodsback()
  8941. {
  8942. if (UrlPostParmsCheck("id"))
  8943. {
  8944. int eid = GetPostInt("id");
  8945. CeErpStayGoods entity = null;
  8946. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8947. if (entity != null)
  8948. {
  8949. entity.audit_text = GetPostString("reason");
  8950. entity.audit_type = 2;
  8951. entity.audit_time = DateTime.Now;
  8952. entity.audit_u_id = CurrentUser.UserID;
  8953. entity.audit_u_name = CurrentUser.UserName;
  8954. entity.Update();
  8955. returnSuccessMsg("退回成功!");
  8956. return;
  8957. }
  8958. returnErrorMsg("找不到订单记录");
  8959. }
  8960. }
  8961. public void upd_erp_returncashverify()
  8962. {
  8963. if (UrlPostParmsCheck("ID"))
  8964. {
  8965. int eid = GetPostInt("ID");
  8966. CeErpReturnCash entity = null;
  8967. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8968. if (entity != null)
  8969. {
  8970. entity.cashstate = 1;
  8971. entity.verifytime = DateTime.Now;
  8972. entity.verifyuserid = CurrentUser.UserID;
  8973. entity.Update();
  8974. returnSuccessMsg("审核成功!");
  8975. return;
  8976. }
  8977. returnErrorMsg("找不到订单记录");
  8978. }
  8979. }
  8980. public void upd_all_erp_returncashverify()
  8981. {
  8982. if (UrlPostParmsCheck("ID"))
  8983. {
  8984. String[] list = GetPostString("ID").Split(',');
  8985. CeErpReturnCash entity = null;
  8986. for (int i = 0; i < list.Length; i++)
  8987. {
  8988. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8989. if (entity != null)
  8990. {
  8991. if (entity.cashstate == 1)
  8992. {
  8993. returnErrorMsg("已审核过的订单不需要在审核!");
  8994. return;
  8995. }
  8996. entity.cashstate = 1;
  8997. entity.verifytime = DateTime.Now;
  8998. entity.verifyuserid = CurrentUser.UserID;
  8999. entity.Update();
  9000. }
  9001. }
  9002. returnSuccessMsg("审核成功!");
  9003. return;
  9004. }
  9005. }
  9006. public void upd_erp_returncashback()
  9007. {
  9008. if (UrlPostParmsCheck("ID"))
  9009. {
  9010. int eid = GetPostInt("ID");
  9011. CeErpReturnCash entity = null;
  9012. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9013. if (entity != null)
  9014. {
  9015. entity.backreason = GetPostString("reason");
  9016. entity.cashstate = 2;
  9017. entity.verifytime = DateTime.Now;
  9018. entity.verifyuserid = CurrentUser.UserID;
  9019. entity.Update();
  9020. returnSuccessMsg("退回成功!");
  9021. return;
  9022. }
  9023. returnErrorMsg("找不到订单记录");
  9024. }
  9025. }
  9026. public void upd_erp_returnprice()
  9027. {
  9028. if (UrlPostParmsCheck("ID"))
  9029. {
  9030. int eid = GetPostInt("ID");
  9031. CeErpReturnCash entity = null;
  9032. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9033. if (entity != null)
  9034. {
  9035. if (entity.cashstate == 1)
  9036. {
  9037. returnErrorMsg("审核通过了不能改");
  9038. return;
  9039. }
  9040. entity.returnprice = GetPostDouble("returnprice");
  9041. entity.Update();
  9042. returnSuccessMsg("修改成功!");
  9043. return;
  9044. }
  9045. returnErrorMsg("找不到订单记录");
  9046. }
  9047. }
  9048. public void del_erp_returncash()
  9049. {
  9050. if (UrlPostParmsCheck("ID"))
  9051. {
  9052. int eid = GetPostInt("ID");
  9053. CeErpReturnCash.Del(eid);
  9054. returnSuccessMsg("操作成功");
  9055. return;
  9056. }
  9057. }
  9058. public void test_for_do_sql()
  9059. {
  9060. string sql = GetPostString("sqlstr");
  9061. if (sql.Length > 0)
  9062. {
  9063. try
  9064. {
  9065. DbHelper.DbConn.ExecuteNonQuery(sql);
  9066. var res_obj = new
  9067. {
  9068. data = "成功",
  9069. };
  9070. string ro_json = JsonConvert.SerializeObject(res_obj);
  9071. returnSuccess(ro_json);
  9072. }
  9073. catch (Exception ex)
  9074. {
  9075. var res_obj = new
  9076. {
  9077. data = ex.Message,
  9078. };
  9079. string ro_json = JsonConvert.SerializeObject(res_obj);
  9080. returnSuccess(ro_json);
  9081. }
  9082. }
  9083. }
  9084. public void get_user_info()
  9085. {
  9086. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9087. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9088. }
  9089. public void get_total_data()
  9090. {
  9091. int userId = CurrentUser.UserID;
  9092. string sql = "";
  9093. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9094. {
  9095. 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);
  9096. }
  9097. else
  9098. {
  9099. 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 " +
  9100. "(select ID from CE_ErpUser where ID = {0}) d " +
  9101. "left join " +
  9102. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9103. ") a on d.ID = a.id left join " +
  9104. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9105. ") b on a.id = b.id1 left join" +
  9106. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9107. ") c on a.id = c.id2;", userId);
  9108. }
  9109. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9110. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9111. }
  9112. public void get_date_area_total_data2()
  9113. {
  9114. int userId = CurrentUser.UserID;
  9115. string date_type = GetPostString("timetype");
  9116. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9117. string sql = "";
  9118. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9119. {
  9120. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9121. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9122. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9123. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9124. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9125. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9126. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9127. ") a on e.ID = a.id left join " +
  9128. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9129. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9130. ") b on a.id = b.id1 " +
  9131. "left join " +
  9132. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9133. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9134. ") c on a.id = c.id2 " +
  9135. "left join " +
  9136. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9137. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9138. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9139. }
  9140. else
  9141. {
  9142. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9143. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9144. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9145. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9146. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9147. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9148. ") a on e.ID = a.id left join " +
  9149. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9150. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9151. ") c on a.id = c.id2 " +
  9152. "left join " +
  9153. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9154. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9155. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9156. }
  9157. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9158. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9159. }
  9160. public void get_date_area_total_data()
  9161. {
  9162. int userId = CurrentUser.UserID;
  9163. string date_type = GetPostString("timetype");
  9164. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9165. string date1 = searchDT[0].ToString();
  9166. string date2 = searchDT[1].ToString();
  9167. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9168. {
  9169. SqlParameter[] sqlParameter ={
  9170. new SqlParameter("@userId", SqlDbType.Int,4),
  9171. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9172. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9173. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9174. };
  9175. sqlParameter[0].Value = userId;
  9176. sqlParameter[1].Value = date1;
  9177. sqlParameter[2].Value = date2;
  9178. sqlParameter[3].Direction = ParameterDirection.Output;
  9179. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9180. string res = sqlParameter[3].Value.ToString();
  9181. var res_obj = new
  9182. {
  9183. data = res
  9184. };
  9185. string ro_json = JsonConvert.SerializeObject(res_obj);
  9186. returnSuccess(ro_json);
  9187. }
  9188. else
  9189. {
  9190. SqlParameter[] sqlParameter ={
  9191. new SqlParameter("@userId", SqlDbType.Int,4),
  9192. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9193. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9194. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9195. };
  9196. sqlParameter[0].Value = userId;
  9197. sqlParameter[1].Value = date1;
  9198. sqlParameter[2].Value = date2;
  9199. sqlParameter[3].Direction = ParameterDirection.Output;
  9200. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9201. string res = sqlParameter[3].Value.ToString();
  9202. var res_obj = new
  9203. {
  9204. data = res
  9205. };
  9206. string ro_json = JsonConvert.SerializeObject(res_obj);
  9207. returnSuccess(ro_json);
  9208. }
  9209. //writeGridDataViewJson(dt.Rows.Count, dv);
  9210. }
  9211. public void get_order_list()
  9212. {
  9213. string strFields = GetPostString("paraFields");
  9214. string strOrder = GetPostString("paraOrder");
  9215. string strWhere = GetPostString("paraWhere");
  9216. string strPageSize = GetPostString("paraPageSize");
  9217. DataStruct dStruct = GetPostStruct();
  9218. dStruct.PageSize = int.Parse(strPageSize);
  9219. dStruct.Fileds = strFields;
  9220. dStruct.Order = strOrder;
  9221. dStruct.MainWhere = strWhere;
  9222. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9223. writeGridDataTableJson(dStruct.TotalCount, dt);
  9224. }
  9225. ////获取待开始订单列表
  9226. //public void get_wait_design_order_list()
  9227. //{
  9228. // string date_type = GetPostString("date_type");
  9229. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9230. // DataStruct dStruct = GetPostStruct();
  9231. // dStruct.PageSize = 1000;
  9232. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9233. // List<string> lw = new List<string>();
  9234. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9235. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9236. // dStruct.Order = "WaitDesignTime asc";
  9237. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9238. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9239. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9240. //}
  9241. //获取完成单量排名
  9242. public void get_finish_order_count_ranking()
  9243. {
  9244. /* string date_type = GetPostString("date_type");
  9245. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9246. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9247. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9248. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9249. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9250. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9251. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9252. writeGridDataTableJson(0, new DataTable());
  9253. }
  9254. public void get_finish_order_amount_ranking()
  9255. {
  9256. /*string date_type = GetPostString("date_type");
  9257. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9258. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9259. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9260. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9261. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9262. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9263. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9264. writeGridDataTableJson(0, new DataTable());
  9265. }
  9266. public void get_finish_refund_count_ranking()
  9267. {
  9268. string date_type = GetPostString("date_type");
  9269. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9270. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9271. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9272. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9273. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9274. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9275. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9276. writeGridDataTableJson(dt.Rows.Count, dt);
  9277. }
  9278. public void get_finish_refund_amount_ranking()
  9279. {
  9280. string date_type = GetPostString("date_type");
  9281. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9282. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9283. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9284. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9285. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9286. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9287. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9288. writeGridDataTableJson(dt.Rows.Count, dt);
  9289. }
  9290. public void set_erp_finishorder_director()
  9291. {
  9292. if (UrlPostParmsCheck("ctid"))
  9293. {
  9294. string eid = GetPostString("ctid");
  9295. CeErpTradeCell entity = null;
  9296. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9297. if (entity != null)
  9298. {
  9299. entity.OrderState = 8;
  9300. entity.Update();
  9301. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9302. returnSuccessMsg("操作成功!");
  9303. return;
  9304. }
  9305. returnErrorMsg("找不到记录");
  9306. }
  9307. }
  9308. public void get_erp_placeregistlist()
  9309. {
  9310. DataStruct dStruct = GetPostStruct();
  9311. List<string> lw = new List<string>();
  9312. string outsid = GetPostString("outsid");
  9313. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9314. string memo = GetPostString("memo");
  9315. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9316. string filename = GetPostString("filename");
  9317. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9318. string islate = GetPostString("islate");
  9319. if (islate.Length > 0)
  9320. {
  9321. if (islate == "1")
  9322. lw.Add(string.Format("OutLate>0"));
  9323. else
  9324. lw.Add(string.Format("OutLate=0"));
  9325. }
  9326. string placedate1 = GetPostString("placedate1");
  9327. string placedate2 = GetPostString("placedate2");
  9328. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9329. if (dw.Length > 0) lw.Add(dw);
  9330. string deliveryDate1 = GetPostString("deliverydate1");
  9331. string deliveryDate2 = GetPostString("deliverydate2");
  9332. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9333. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9334. dStruct.Order = "ID desc";
  9335. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9336. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9337. writeGridDataTableJson(dStruct.TotalCount, dt);
  9338. }
  9339. public void ins_erp_placeregist()
  9340. {
  9341. if (UrlPostParmsCheck("id"))
  9342. {
  9343. string eid = GetPostString("id");
  9344. CeErpPlaceRegister entity = null;
  9345. if (eid == "0")//新增
  9346. {
  9347. entity = new CeErpPlaceRegister();
  9348. string xdTime = GetPostString("placeTime");
  9349. if (xdTime.Length > 0)
  9350. {
  9351. entity.PlactTime = Convert.ToDateTime(xdTime);
  9352. }
  9353. string fhTime = GetPostString("deliveryTime");
  9354. if (fhTime.Length > 0)
  9355. {
  9356. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9357. }
  9358. string preTime = GetPostString("preOutTime");
  9359. if (preTime.Length > 0)
  9360. {
  9361. entity.PreOutTime = Convert.ToDateTime(preTime);
  9362. }
  9363. entity.DeliveryCount = GetPostInt("deliveryCount");
  9364. entity.ReceiveCount = GetPostInt("receiveCount");
  9365. entity.OutSid = GetPostString("outSid");
  9366. entity.FileName = GetPostString("fileName");
  9367. entity.Memo = GetPostString("memo");
  9368. entity.AddUserId = CurrentUser.UserID;
  9369. entity.CreateTime = DateTime.Now;
  9370. entity.Img = GetPostString("img");
  9371. entity.Supplier = GetPostInt("supplier");
  9372. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9373. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9374. {
  9375. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9376. DateTime dt2 = (DateTime)entity.PreOutTime;
  9377. TimeSpan span = dt1.Subtract(dt2);
  9378. if (span.Days > 0)
  9379. {
  9380. entity.OutLate = span.Days;
  9381. }
  9382. }
  9383. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9384. entity.Create();
  9385. returnSuccessMsg("添加成功!");
  9386. return;
  9387. }
  9388. else //修改
  9389. {
  9390. entity = CeErpPlaceRegister.Get(eid);
  9391. if (entity != null)
  9392. {
  9393. string xdTime = GetPostString("placeTime");
  9394. if (xdTime.Length > 0)
  9395. {
  9396. entity.PlactTime = Convert.ToDateTime(xdTime);
  9397. }
  9398. string fhTime = GetPostString("deliveryTime");
  9399. if (fhTime.Length > 0)
  9400. {
  9401. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9402. }
  9403. string preTime = GetPostString("preOutTime");
  9404. if (preTime.Length > 0)
  9405. {
  9406. entity.PreOutTime = Convert.ToDateTime(preTime);
  9407. }
  9408. entity.DeliveryCount = GetPostInt("deliveryCount");
  9409. entity.ReceiveCount = GetPostInt("receiveCount");
  9410. if (entity.DeliveryCount == entity.ReceiveCount)
  9411. {
  9412. entity.CurState = "已完成";
  9413. }
  9414. else
  9415. {
  9416. entity.CurState = "未完成";
  9417. }
  9418. entity.OutSid = GetPostString("outSid");
  9419. entity.FileName = GetPostString("fileName");
  9420. entity.Memo = GetPostString("memo");
  9421. entity.Img = GetPostString("img");
  9422. entity.Supplier = GetPostInt("supplier");
  9423. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9424. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9425. {
  9426. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9427. DateTime dt2 = (DateTime)entity.PreOutTime;
  9428. TimeSpan span = dt1.Subtract(dt2);
  9429. if (span.Days > 0)
  9430. {
  9431. entity.OutLate = span.Days;
  9432. }
  9433. }
  9434. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9435. entity.Update();
  9436. returnSuccessMsg("修改成功");
  9437. return;
  9438. }
  9439. returnErrorMsg("找不到对应的记录");
  9440. return;
  9441. }
  9442. }
  9443. returnErrorMsg("缺少必要参数");
  9444. }
  9445. public void del_erp_placeregist()
  9446. {
  9447. string eid = GetPostString("id");
  9448. CeErpPlaceRegister.Del(eid);
  9449. returnSuccessMsg("删除成功!");
  9450. return;
  9451. }
  9452. public void ins_erp_placeregistbyorder()
  9453. {
  9454. string ctid = GetPostString("ctid");
  9455. if (ctid.Length > 0)
  9456. {
  9457. StringBuilder sql = new StringBuilder();
  9458. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9459. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9460. if (dt.Rows.Count > 0)
  9461. {
  9462. foreach (DataRow dr in dt.Rows)
  9463. {
  9464. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9465. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9466. entity.AddUserId = CurrentUser.UserID;
  9467. entity.tid = dr["tid"].ToString();
  9468. entity.Did = Convert.ToString(dr["ctid"]);
  9469. entity.splitTag = dr["SplitTag"].ToString();
  9470. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9471. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9472. if (pre_ctid.Length > 0)
  9473. {
  9474. sellmemo = sellmemo.Replace(pre_ctid, "");
  9475. }
  9476. sellmemo = sellmemo.Replace("[", "");
  9477. sellmemo = sellmemo.Replace("]", "");
  9478. entity.FileName = sellmemo;
  9479. string count = dr["ProductCount"].ToString();
  9480. int usecount = commonHelper.getIntCountFromString(count);
  9481. entity.DeliveryCount = usecount;
  9482. entity.CurState = "未完成";
  9483. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9484. {
  9485. entity.Supplier = 24;//dl手提袋定制
  9486. }
  9487. else
  9488. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9489. entity.CreateTime = DateTime.Now;
  9490. entity.Create();
  9491. }
  9492. returnSuccessMsg("操作成功");
  9493. return;
  9494. }
  9495. returnErrorMsg("没有找到对应订单");
  9496. return;
  9497. }
  9498. returnErrorMsg("缺少订单编号");
  9499. return;
  9500. }
  9501. public void get_erp_persuadelist()
  9502. {
  9503. DataStruct dStruct = GetPostStruct();
  9504. List<string> lw = new List<string>();
  9505. string ctid = GetPostString("ctid");
  9506. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9507. string shopname = GetPostString("shopname");
  9508. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9509. string buyernick = GetPostString("buyer_nick");
  9510. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9511. string customer = GetPostString("customer");
  9512. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9513. string returndate1 = GetPostString("returndate1");
  9514. string returndate2 = GetPostString("returndate2");
  9515. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9516. if (dw.Length > 0) lw.Add(dw);
  9517. string finishDate1 = GetPostString("finishdate1");
  9518. string finishDate2 = GetPostString("finishdate2");
  9519. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9520. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9521. string persuadetype = GetPostString("persuadetype");
  9522. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9523. string returnvstate = GetPostString("returnvstate");
  9524. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9525. dStruct.Order = "created desc";
  9526. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9527. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9528. writeGridDataTableJson(dStruct.TotalCount, dt);
  9529. }
  9530. public void upd_erp_returnpersuadeback()
  9531. {
  9532. if (UrlPostParmsCheck("ID"))
  9533. {
  9534. int eid = GetPostInt("ID");
  9535. CeErpPersuade entity = null;
  9536. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9537. if (entity != null)
  9538. {
  9539. entity.backreason = GetPostString("reason");
  9540. entity.pstate = 2;
  9541. entity.verifytime = DateTime.Now;
  9542. entity.verifyuserid = CurrentUser.UserID;
  9543. entity.Update();
  9544. returnSuccessMsg("退回成功!");
  9545. return;
  9546. }
  9547. returnErrorMsg("找不到订单记录");
  9548. }
  9549. }
  9550. public void upd_erp_returnpersuadeverify()
  9551. {
  9552. if (UrlPostParmsCheck("ID"))
  9553. {
  9554. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9555. {
  9556. returnErrorMsg("暂无权限审核");
  9557. return;
  9558. }
  9559. int eid = GetPostInt("ID");
  9560. CeErpPersuade entity = null;
  9561. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9562. if (entity != null)
  9563. {
  9564. entity.pstate = 1;
  9565. entity.verifytime = DateTime.Now;
  9566. entity.verifyuserid = CurrentUser.UserID;
  9567. entity.Update();
  9568. returnSuccessMsg("审核成功!");
  9569. return;
  9570. }
  9571. returnErrorMsg("找不到订单记录");
  9572. }
  9573. }
  9574. public void del_erp_persuade()
  9575. {
  9576. if (UrlPostParmsCheck("ID"))
  9577. {
  9578. int eid = GetPostInt("ID");
  9579. CeErpPersuade.Del(eid);
  9580. returnSuccessMsg("操作成功");
  9581. return;
  9582. }
  9583. }
  9584. public void get_erp_oldcustoupload()
  9585. {
  9586. DataStruct dStruct = GetPostStruct();
  9587. List<string> lw = new List<string>();
  9588. string buyernick = GetPostString("buyer_nick");
  9589. if (buyernick.Length > 0)
  9590. {
  9591. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9592. }
  9593. else
  9594. return;
  9595. dStruct.Order = "pay_time desc";
  9596. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9597. DataTable dt = null;
  9598. dt = WebCache.GetData("view_erptradecell", dStruct);
  9599. writeGridDataTableJson(dStruct.TotalCount, dt);
  9600. }
  9601. public void get_erp_checkorderlist()
  9602. {
  9603. DataStruct dStruct = GetPostStruct();
  9604. List<string> lw = new List<string>();
  9605. string tid = GetPostString("ctid");
  9606. if (tid.Length > 0)
  9607. {
  9608. string select_tid = getTidByCtid(tid);
  9609. lw.Add(string.Format("tid='{0}'", select_tid));
  9610. }
  9611. string shopname = GetPostString("shopname");
  9612. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9613. string buyernick = GetPostString("buyer_nick");
  9614. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9615. string customer = GetPostString("customer");
  9616. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9617. string design = GetPostString("design");
  9618. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9619. string orderState = GetPostString("orderState");
  9620. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9621. string address = GetPostString("address");
  9622. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9623. string sellermemo = GetPostString("seller_memo");
  9624. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9625. string supplier = GetPostString("supplier");
  9626. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9627. {
  9628. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9629. }
  9630. else
  9631. {
  9632. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9633. }
  9634. string date1 = GetPostString("date1");
  9635. string date2 = GetPostString("date2");
  9636. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9637. if (dw.Length > 0) lw.Add(dw);
  9638. string placedate1 = GetPostString("placedate1");
  9639. string placedate2 = GetPostString("placedate2");
  9640. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9641. if (fdw.Length > 0) lw.Add(fdw);
  9642. string price1 = GetPostString("price1");
  9643. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9644. string price2 = GetPostString("price2");
  9645. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9646. string checkst = GetPostString("checkstate");
  9647. if (checkst.Length > 0 && "10".Equals(checkst))
  9648. {
  9649. lw.Add(string.Format("CheckOut>0"));
  9650. }
  9651. else
  9652. {
  9653. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9654. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9655. }
  9656. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9657. {
  9658. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9659. }
  9660. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9661. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9662. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9663. writeGridDataTableJson(dStruct.TotalCount, dt);
  9664. }
  9665. public void ins_erp_startCheck()
  9666. {
  9667. if (UrlPostParmsCheck("ctid"))
  9668. {
  9669. string eid = GetPostString("ctid");
  9670. CeErpTradeCell entity = null;
  9671. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9672. if (entity != null)
  9673. {
  9674. entity.MemoOpt = 4;
  9675. entity.UpdateTime = DateTime.Now;
  9676. entity.Update();
  9677. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9678. CeErpSukuraData.createInfo(entity.ctid, 6);
  9679. returnSuccessMsg("操作成功!");
  9680. return;
  9681. }
  9682. returnErrorMsg("找不到记录");
  9683. }
  9684. }
  9685. public void upd_erp_sendXlw()
  9686. {
  9687. if (UrlPostParmsCheck("ctid"))
  9688. {
  9689. string eid = GetPostString("ctid");
  9690. CeErpTradeCell entity = null;
  9691. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9692. if (entity != null)
  9693. {
  9694. if (entity.IsSendGift == 1)
  9695. {
  9696. returnErrorMsg("请勿重复标记");
  9697. return;
  9698. }
  9699. entity.IsSendGift = 1;
  9700. entity.Update();
  9701. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9702. returnSuccessMsg("操作成功!");
  9703. return;
  9704. }
  9705. returnErrorMsg("找不到记录");
  9706. }
  9707. }
  9708. public void cancel_sendXlw()
  9709. {
  9710. if (UrlPostParmsCheck("ctid"))
  9711. {
  9712. string eid = GetPostString("ctid");
  9713. CeErpTradeCell entity = null;
  9714. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9715. if (entity != null)
  9716. {
  9717. if (entity.IsSendGift == 0)
  9718. {
  9719. returnErrorMsg("未标记小礼物");
  9720. return;
  9721. }
  9722. entity.IsSendGift = 0;
  9723. entity.Update();
  9724. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9725. returnSuccessMsg("操作成功!");
  9726. return;
  9727. }
  9728. returnErrorMsg("找不到记录");
  9729. }
  9730. }
  9731. public void get_erp_designbill()
  9732. {
  9733. DataStruct dStruct = GetPostStruct();
  9734. List<string> lw = new List<string>();
  9735. int isMy = GetInt("my");
  9736. if (isMy == 1)
  9737. {
  9738. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9739. }
  9740. string tid = GetPostString("tid");
  9741. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9742. string userName = GetPostString("design");
  9743. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9744. string price1 = GetPostString("price1");
  9745. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9746. string price2 = GetPostString("price2");
  9747. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9748. string rePrice1 = GetPostString("rePrice1");
  9749. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9750. string rePrice2 = GetPostString("rePrice2");
  9751. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9752. string designerType = GetPostString("designerType");
  9753. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9754. string orderState = GetPostString("orderState");
  9755. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9756. string endTime1 = GetPostString("endTime1");
  9757. string endTime2 = GetPostString("endTime2");
  9758. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9759. if (dw.Length > 0) lw.Add(dw);
  9760. string isDk = GetPostString("isDk");
  9761. if (isDk == "1")
  9762. {
  9763. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9764. }
  9765. else if (isDk == "0")
  9766. {
  9767. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9768. }
  9769. dStruct.Order = "oid, create_time desc";
  9770. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9771. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9772. writeGridDataTableJson(dStruct.TotalCount, dt);
  9773. }
  9774. public void upd_erp_designerbill()
  9775. {
  9776. if (UrlPostParmsCheck("ID"))
  9777. {
  9778. string eid = GetPostString("ID");
  9779. CeErpDesignerBill entity = null;
  9780. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9781. if (entity != null)
  9782. {
  9783. if (GetPostDouble("designerpirce") > 0)
  9784. {
  9785. entity.realPrice = GetPostDouble("designerpirce");
  9786. entity.update_time = DateTime.Now;
  9787. entity.update_u_id = CurrentUser.UserID;
  9788. entity.update_u_name = CurrentUser.UserName;
  9789. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9790. entity.Update();
  9791. returnSuccessMsg("操作成功!");
  9792. return;
  9793. }
  9794. else
  9795. {
  9796. entity.price = GetPostDouble("price");
  9797. entity.update_time = DateTime.Now;
  9798. entity.update_u_id = CurrentUser.UserID;
  9799. entity.update_u_name = CurrentUser.UserName;
  9800. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9801. entity.Update();
  9802. returnSuccessMsg("操作成功!");
  9803. return;
  9804. }
  9805. }
  9806. returnErrorMsg("找不到记录");
  9807. }
  9808. }
  9809. public void audit_erp_designerbill()
  9810. {
  9811. if (UrlPostParmsCheck("ID"))
  9812. {
  9813. string eid = GetPostString("ID");
  9814. CeErpDesignerBill entity = null;
  9815. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9816. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9817. if (entity != null)
  9818. {
  9819. entity.realPrice = GetPostDouble("designerpirce");
  9820. entity.update_time = DateTime.Now;
  9821. entity.update_u_id = CurrentUser.UserID;
  9822. entity.update_u_name = CurrentUser.UserName;
  9823. entity.isAudit = 1;
  9824. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9825. entity.Update();
  9826. if (orderEntity != null)
  9827. {
  9828. orderEntity.IsReadTag = 3;
  9829. orderEntity.Update();
  9830. }
  9831. returnSuccessMsg("操作成功!");
  9832. return;
  9833. }
  9834. returnErrorMsg("找不到记录");
  9835. }
  9836. }
  9837. public void all_audit_erp_designerbill()
  9838. {
  9839. if (UrlPostParmsCheck("idList"))
  9840. {
  9841. string[] list = GetPostString("idList").Split(',');
  9842. CeErpDesignerBill entity = null;
  9843. for (int i = 0; i < list.Length; i++)
  9844. {
  9845. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9846. if (entity == null) return;
  9847. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9848. if (orderEntity == null) return;
  9849. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9850. entity.update_time = DateTime.Now;
  9851. entity.update_u_id = CurrentUser.UserID;
  9852. entity.update_u_name = CurrentUser.UserName;
  9853. entity.isAudit = 1;
  9854. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9855. entity.Update();
  9856. orderEntity.IsReadTag = 3;
  9857. orderEntity.Update();
  9858. }
  9859. returnSuccessMsg("操作成功!");
  9860. return;
  9861. }
  9862. }
  9863. public void get_erp_sameorders()
  9864. {
  9865. if (UrlPostParmsCheck("ctid"))
  9866. {
  9867. string eid = GetPostString("ctid");
  9868. CeErpTradeCell entity = null;
  9869. entity = CeErpTradeCell.GetByCtid(eid);
  9870. if (entity != null)
  9871. {
  9872. StringBuilder sql = new StringBuilder();
  9873. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9874. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9875. var res = new
  9876. {
  9877. data = dt.Rows.Count
  9878. };
  9879. string ro_jsond = JsonConvert.SerializeObject(res);
  9880. returnSuccess(ro_jsond);
  9881. return;
  9882. }
  9883. returnErrorMsg("未找到订单");
  9884. return;
  9885. }
  9886. returnErrorMsg("缺少必要的参数");
  9887. }
  9888. public void get_erp_islasthavesameorder()
  9889. {
  9890. if (UrlPostParmsCheck("ctid"))
  9891. {
  9892. string eid = GetPostString("ctid");
  9893. string[] ctidList = eid.Split(',');
  9894. StringBuilder sql = new StringBuilder();
  9895. string tisCtid = "";
  9896. foreach (string ctid in ctidList)
  9897. {
  9898. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9899. if (entity != null)
  9900. {
  9901. sql = new StringBuilder();
  9902. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9903. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9904. if (dth.Rows.Count > 0)
  9905. {
  9906. tisCtid += entity.ctid;
  9907. tisCtid += ",";
  9908. }
  9909. }
  9910. }
  9911. if (tisCtid.Length > 0)
  9912. {
  9913. var res = new
  9914. {
  9915. data = tisCtid
  9916. };
  9917. string ro_jsond = JsonConvert.SerializeObject(res);
  9918. returnSuccess(ro_jsond);
  9919. }
  9920. else
  9921. {
  9922. var res = new
  9923. {
  9924. data = ""
  9925. };
  9926. string ro_jsond = JsonConvert.SerializeObject(res);
  9927. returnSuccess(ro_jsond);
  9928. }
  9929. return;
  9930. }
  9931. returnErrorMsg("缺少必要的参数");
  9932. }
  9933. public void file_client_down_url()
  9934. {
  9935. if (!UrlPostParmsCheck("userId"))
  9936. {
  9937. returnErrorMsg("缺少必要的参数");
  9938. }
  9939. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9940. }
  9941. public void checkout_form_data()
  9942. {
  9943. if (!UrlPostParmsCheck("tid"))
  9944. {
  9945. returnErrorMsg("缺少必要的参数");
  9946. }
  9947. string tid = GetPostString("tid");
  9948. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9949. if (ceErpOrderFormData != null)
  9950. {
  9951. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9952. returnSuccess(ro_jsond);
  9953. return;
  9954. }
  9955. returnErrorMsg("尚未有文件!");
  9956. }
  9957. public void back_supplier_audit()
  9958. {
  9959. int userId = CurrentUser.UserID;
  9960. StringBuilder sql = new StringBuilder();
  9961. 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);
  9962. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9963. if (dt.Rows.Count > 0)
  9964. {
  9965. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9966. }
  9967. else
  9968. {
  9969. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9970. }
  9971. }
  9972. public void back_supplier_query()
  9973. {
  9974. string eid = GetPostString("ctid");
  9975. if (eid != "")
  9976. {
  9977. StringBuilder sql = new StringBuilder();
  9978. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9979. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9980. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9981. }
  9982. else
  9983. {
  9984. returnErrorMsg("找不到订单记录");
  9985. return;
  9986. }
  9987. }
  9988. public void verified_to_order()
  9989. {
  9990. int userId = CurrentUser.UserID;
  9991. StringBuilder sql = new StringBuilder();
  9992. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9993. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9994. if (dt.Rows.Count > 0)
  9995. {
  9996. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9997. }
  9998. else
  9999. {
  10000. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10001. }
  10002. }
  10003. public void upd_supplier_audit()
  10004. {
  10005. if (UrlPostParmsCheck("ctid"))
  10006. {
  10007. string eid = GetPostString("ctid");
  10008. string reason = GetPostString("returnreason");
  10009. CeErpTradeCell entity = null;
  10010. CeWithdraw withdraw = null;
  10011. withdraw = CeWithdraw.GetByTid(eid);
  10012. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  10013. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  10014. {
  10015. if (withdraw != null)
  10016. {
  10017. if (!withdraw.userid.Equals(CurrentUser.UserID))
  10018. {
  10019. returnSuccessMsg("您没有权限操作!");
  10020. return;
  10021. }
  10022. else
  10023. {
  10024. if (reason.Equals("1"))
  10025. {
  10026. if (entity.OrderState == -1)
  10027. {
  10028. if (entity.FinishPlaceTime == null)
  10029. {
  10030. entity.OrderState = 2;
  10031. }
  10032. else
  10033. {
  10034. entity.OrderState = 6;
  10035. }
  10036. }
  10037. entity.Update();
  10038. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10039. if (withdraw != null)
  10040. {
  10041. withdraw.status = int.Parse(reason);
  10042. withdraw.Update();
  10043. }
  10044. returnSuccessMsg("操作成功!");
  10045. return;
  10046. }
  10047. else
  10048. {
  10049. withdraw.status = int.Parse(reason);
  10050. withdraw.acknowledgingtime = DateTime.Now;
  10051. withdraw.Update();
  10052. returnSuccessMsg("查看详细请点击线下订单查询");
  10053. return;
  10054. }
  10055. }
  10056. }
  10057. // 第一个字符是 'N'
  10058. }
  10059. if (eid[0] != 'N')
  10060. {
  10061. }
  10062. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10063. {
  10064. entity.IsVerifyToSupplier = false;
  10065. entity.IsReturn = 1;
  10066. entity.ReturnTime = DateTime.Now;
  10067. entity.ReturnReason = reason;
  10068. if (entity.OrderState == 6)
  10069. {
  10070. entity.OrderState = 5;
  10071. }
  10072. entity.Update();
  10073. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10074. if (withdraw != null)
  10075. {
  10076. withdraw.status = int.Parse(reason);
  10077. withdraw.Update();
  10078. }
  10079. returnSuccessMsg("操作成功!");
  10080. return;
  10081. }
  10082. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10083. {
  10084. ;
  10085. if (withdraw != null)
  10086. {
  10087. withdraw.status = int.Parse(reason);
  10088. withdraw.acknowledgingtime = DateTime.Now;
  10089. withdraw.Update();
  10090. returnSuccessMsg("供应商取消撤回!");
  10091. return;
  10092. }
  10093. }
  10094. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10095. {
  10096. if (entity.OrderState == -1)
  10097. {
  10098. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10099. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10100. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10101. {
  10102. returnErrorMsg("台湾客户需填写身份证!");
  10103. return;
  10104. }
  10105. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10106. {
  10107. returnErrorMsg("偏远地区需要填写物流费!");
  10108. return;
  10109. }
  10110. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10111. {
  10112. returnErrorMsg("订单spu没有确认无法通过审核!");
  10113. return;
  10114. }
  10115. if (entity.FinishPlaceTime == null)
  10116. {
  10117. entity.OrderState = 2;
  10118. }
  10119. else
  10120. {
  10121. entity.OrderState = 3;
  10122. }
  10123. commonHelper.getCytPrice(entity);
  10124. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10125. {
  10126. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10127. }
  10128. if (entity.IsSample > 1 || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物"))
  10129. {
  10130. entity.OrderState = 6;
  10131. }
  10132. }
  10133. entity.Update();
  10134. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10135. if (withdraw != null)
  10136. {
  10137. withdraw.status = int.Parse(reason);
  10138. withdraw.Update();
  10139. }
  10140. returnSuccessMsg("操作成功!");
  10141. return;
  10142. }
  10143. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10144. {
  10145. if (withdraw == null)
  10146. {
  10147. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10148. return;
  10149. }
  10150. }
  10151. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10152. {
  10153. if (withdraw != null)
  10154. {
  10155. withdraw.status = int.Parse(reason);
  10156. withdraw.acknowledgingtime = DateTime.Now;
  10157. withdraw.Update();
  10158. returnSuccessMsg("查看详细请点击线下订单查询");
  10159. return;
  10160. }
  10161. }
  10162. return;
  10163. }
  10164. }
  10165. //校验报价
  10166. public void refund_order_tip()
  10167. {
  10168. int userid = CurrentUser.UserID;
  10169. int sectionId = CurrentUser.UserPost.OrgID;
  10170. StringBuilder sql = new StringBuilder();
  10171. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10172. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10173. List<string> ids = new List<string>();
  10174. if (dth.Rows.Count > 0)
  10175. {
  10176. foreach (DataRow dr in dth.Rows)
  10177. {
  10178. ids.Add(dr["ID"].ToString());
  10179. }
  10180. try
  10181. {
  10182. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10183. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10184. }
  10185. catch (Exception ex)
  10186. {
  10187. }
  10188. }
  10189. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10190. }
  10191. public void refund_order_Design()
  10192. {
  10193. int userid = CurrentUser.UserID;
  10194. int sectionId = CurrentUser.UserPost.OrgID;
  10195. StringBuilder sql = new StringBuilder();
  10196. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10197. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10198. List<string> ids = new List<string>();
  10199. if (dth.Rows.Count > 0)
  10200. {
  10201. foreach (DataRow dr in dth.Rows)
  10202. {
  10203. ids.Add(dr["ID"].ToString());
  10204. }
  10205. try
  10206. {
  10207. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10208. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10209. }
  10210. catch (Exception ex)
  10211. {
  10212. }
  10213. }
  10214. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10215. }
  10216. public void change_order_info()
  10217. {
  10218. int userid = CurrentUser.UserID;
  10219. StringBuilder sql = new StringBuilder();
  10220. 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);
  10221. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10222. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10223. }
  10224. public void change_win_mome()
  10225. {
  10226. if (UrlPostParmsCheck("id,ctid"))
  10227. {
  10228. string id = GetPostString("id");
  10229. string ctid = GetPostString("ctid");
  10230. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10231. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10232. if (ce == null || ceErpMessageTip == null)
  10233. {
  10234. returnSuccessMsg("未找到对应的订单!");
  10235. return;
  10236. }
  10237. if (ce.OrderState >= 5)
  10238. {
  10239. ceErpMessageTip.isVisit = true;
  10240. ceErpMessageTip.Update();
  10241. returnSuccessMsg("已上传文件无法修改!");
  10242. return;
  10243. }
  10244. int type = GetPostInt("type");
  10245. string content = GetPostString("content");
  10246. if (type == 0)
  10247. {
  10248. content = content.Replace("(", "(");
  10249. content = content.Replace(")", ")");
  10250. string check = MidStrEx(content, "(", ")").Trim();
  10251. if (string.IsNullOrEmpty(check))
  10252. {
  10253. returnSuccessMsg("文件名格式不正确");
  10254. return;
  10255. }
  10256. }
  10257. ce.seller_memo = content;
  10258. ce.Update();
  10259. ceErpMessageTip.isVisit = true;
  10260. ceErpMessageTip.Update();
  10261. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10262. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10263. ApiVo apiVo = new ApiVo();
  10264. apiVo.orderNumber = ce.ctid;
  10265. apiVo.actionName = "demandDesign";
  10266. apiVo.orderRemarks = content;
  10267. apiVo.demandExamine = type + 1;
  10268. designHelper.API_WorkCore(apiVo);//demandDesign
  10269. returnSuccessMsg("修改成功!");
  10270. }
  10271. }
  10272. public static string MidStrEx(string sourse, string startstr, string endstr)
  10273. {
  10274. string result = string.Empty;
  10275. int startindex, endindex;
  10276. try
  10277. {
  10278. startindex = sourse.IndexOf(startstr);
  10279. if (startindex == -1)
  10280. return result;
  10281. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10282. endindex = tmpstr.IndexOf(endstr);
  10283. if (endindex == -1)
  10284. return result;
  10285. result = tmpstr.Remove(endindex);
  10286. }
  10287. catch (Exception ex)
  10288. {
  10289. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10290. }
  10291. return result;
  10292. }
  10293. public void refund_order_list()
  10294. {
  10295. int userid = CurrentUser.UserID;
  10296. int sectionId = CurrentUser.UserPost.OrgID;
  10297. StringBuilder sql = new StringBuilder();
  10298. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10299. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10300. DataStruct dStruct = GetPostStruct();
  10301. DataTable dt = null;
  10302. List<string> ids = new List<string>();
  10303. List<string> tids = new List<string>();
  10304. if (dth.Rows.Count > 0)
  10305. {
  10306. foreach (DataRow dr in dth.Rows)
  10307. {
  10308. tids.Add("'" + dr["tid"].ToString() + "'");
  10309. ids.Add(dr["id"].ToString());
  10310. }
  10311. try
  10312. {
  10313. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10314. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10315. List<string> lw = new List<string>();
  10316. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10317. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10318. dt = WebCache.GetData("view_orderlist", dStruct);
  10319. }
  10320. catch (Exception ex)
  10321. {
  10322. }
  10323. }
  10324. writeGridDataTableJson(dStruct.TotalCount, dt);
  10325. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10326. }
  10327. //新增
  10328. public void order_batch_downloads()
  10329. {
  10330. string ceid = GetPostString("tid");
  10331. String[] tid = ceid.Split(',');
  10332. order_batch_caiyingtong(tid);
  10333. /* (string success, string errors) = UploadFiles(tid);
  10334. returnSuccessMsg(success + errors);*/
  10335. return;
  10336. }
  10337. //报价接口
  10338. public void Get_To_Quote()
  10339. {
  10340. string ceid = GetPostString("ctid");
  10341. if (ceid != null)
  10342. {
  10343. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10344. if (entity != null)
  10345. {
  10346. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10347. {
  10348. return;
  10349. }
  10350. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10351. double price = 0;
  10352. if (cp == null)
  10353. {
  10354. JObject jsonObject12 = new JObject
  10355. {
  10356. { "UserId", "77886" },
  10357. { "Pwd", "lt666888" },
  10358. { "Filename", entity.seller_memo }
  10359. };
  10360. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10361. JObject jsonObjects1 = JObject.Parse(response1);
  10362. string ms1g = (string)jsonObjects1["msg"];
  10363. if (ms1g == "报价成功")
  10364. {
  10365. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10366. string data = (string)jsonObject1["price"];
  10367. 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 + "');";
  10368. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10369. returnSuccessMsg("获取报价成功:" + data);
  10370. price = Convert.ToDouble(data);
  10371. }
  10372. else
  10373. {
  10374. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10375. return;
  10376. }
  10377. }
  10378. String[] beizhu = entity.seller_memo.Split('-');
  10379. String chanp = "";
  10380. if (beizhu.Length > 0)
  10381. {
  10382. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10383. }
  10384. else
  10385. {
  10386. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10387. }
  10388. JObject jsonObject = new JObject
  10389. {
  10390. { "UserId", "77886" },
  10391. { "Pwd", "lt666888" },
  10392. { "Filename", chanp }
  10393. };
  10394. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10395. JObject jsonObjects = JObject.Parse(response);
  10396. string msg = (string)jsonObjects["msg"];
  10397. if (msg == "报价成功")
  10398. {
  10399. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10400. string data = (string)jsonObject1["price"];
  10401. 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 + "');";
  10402. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10403. returnSuccessMsg("获取报价成功:" + data);
  10404. price = Convert.ToDouble(data);
  10405. }
  10406. else
  10407. {
  10408. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10409. return;
  10410. }
  10411. if (price > 0)
  10412. {
  10413. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10414. if (ceErpTradeCellExtend == null)
  10415. {
  10416. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10417. ceErpTradeCellExtend.ctid = entity.ctid;
  10418. ceErpTradeCellExtend.payment_cyt = price;
  10419. ceErpTradeCellExtend.Create();
  10420. }
  10421. else
  10422. {
  10423. ceErpTradeCellExtend.payment_cyt = price;
  10424. ceErpTradeCellExtend.Update();
  10425. }
  10426. }
  10427. return;
  10428. }
  10429. }
  10430. else
  10431. {
  10432. returnErrorMsg("请至少选择一条数据");
  10433. return;
  10434. }
  10435. }
  10436. //新增
  10437. public void order_To_Supplier()
  10438. {
  10439. string ceid = GetPostString("tid");
  10440. String[] tid = ceid.Split(',');
  10441. if (tid.Length > 0)
  10442. {
  10443. try
  10444. {
  10445. for (int i = 0; i < tid.Length; i++)
  10446. {
  10447. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10448. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10449. entity.SupplierId = suid;
  10450. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10451. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10452. entity.Update();
  10453. }
  10454. }
  10455. catch (Exception ex)
  10456. {
  10457. returnErrorMsg("自动匹配供应商失败");
  10458. return;
  10459. }
  10460. }
  10461. else
  10462. {
  10463. returnErrorMsg("请至少选择一条数据");
  10464. return;
  10465. }
  10466. returnSuccessMsg("自动匹配供应商成功");
  10467. return;
  10468. }
  10469. public (string, string) UploadFiles(string[] urls)
  10470. {
  10471. string success = "";
  10472. string errors = "";
  10473. int userid = CurrentUser.UserID;
  10474. foreach (string url in urls)
  10475. {
  10476. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10477. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10478. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10479. {
  10480. JObject jsonObject = new JObject
  10481. {
  10482. { "Userid", "77886" },
  10483. { "pwd", "cyt86435015" },
  10484. { "content", base64FileContent },
  10485. { "ext", Path.GetExtension(fileName) }
  10486. };
  10487. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10488. JObject jsonObjects = JObject.Parse(response);
  10489. string msg = (string)jsonObjects["msg"];
  10490. if (msg.Equals("上传成功"))
  10491. {
  10492. success += url + " 上传成功";
  10493. }
  10494. else
  10495. {
  10496. errors += url + " 上传失败";
  10497. }
  10498. }
  10499. else
  10500. {
  10501. errors += url + " 格式出现问题";
  10502. }
  10503. }
  10504. if (urls.Length == 0)
  10505. {
  10506. return (success, errors);
  10507. }
  10508. return (success, errors);
  10509. }
  10510. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10511. {
  10512. return true; //总是接受
  10513. }
  10514. public static string HttpPost(string url, string param = null)
  10515. {
  10516. HttpWebRequest request;
  10517. //如果是发送HTTPS请求
  10518. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10519. {
  10520. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10521. request = WebRequest.Create(url) as HttpWebRequest;
  10522. request.ProtocolVersion = HttpVersion.Version10;
  10523. }
  10524. else
  10525. {
  10526. request = WebRequest.Create(url) as HttpWebRequest;
  10527. }
  10528. request.Method = "POST";
  10529. request.ContentType = "application/json";
  10530. request.Accept = "*/*";
  10531. request.Timeout = 120000;
  10532. request.AllowAutoRedirect = false;
  10533. StreamWriter requestStream = null;
  10534. WebResponse response = null;
  10535. string responseStr = null;
  10536. try
  10537. {
  10538. requestStream = new StreamWriter(request.GetRequestStream());
  10539. requestStream.Write(param);
  10540. requestStream.Close();
  10541. response = request.GetResponse();
  10542. if (response != null)
  10543. {
  10544. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10545. responseStr = reader.ReadToEnd();
  10546. reader.Close();
  10547. }
  10548. }
  10549. catch (Exception ex)
  10550. {
  10551. return ex.Message;
  10552. }
  10553. finally
  10554. {
  10555. request = null;
  10556. requestStream = null;
  10557. response = null;
  10558. }
  10559. return responseStr;
  10560. }
  10561. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10562. {
  10563. string base64FileContent;
  10564. string fileName;
  10565. using (WebClient webClient = new WebClient())
  10566. {
  10567. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10568. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10569. {
  10570. using (Stream stream = response.GetResponseStream())
  10571. {
  10572. using (MemoryStream memoryStream = new MemoryStream())
  10573. {
  10574. stream.CopyTo(memoryStream);
  10575. byte[] fileBytes = memoryStream.ToArray();
  10576. base64FileContent = Convert.ToBase64String(fileBytes);
  10577. fileName = response.Headers["Content-Disposition"];
  10578. if (!string.IsNullOrEmpty(fileName))
  10579. {
  10580. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10581. if (index >= 0)
  10582. {
  10583. fileName = fileName.Substring(index + 9).Trim('\"');
  10584. }
  10585. }
  10586. else
  10587. {
  10588. fileName = Path.GetFileName(downloadUrl);
  10589. }
  10590. }
  10591. }
  10592. }
  10593. }
  10594. return (fileName, base64FileContent);
  10595. }
  10596. //新增
  10597. public void order_batch_caiyingtong(string[] downloadUrls)
  10598. {
  10599. try
  10600. {
  10601. //遍历文件
  10602. DataStruct dStruct = GetPostStruct();
  10603. DataTable dt = null;
  10604. int userid = CurrentUser.UserID;
  10605. List<string> ids = new List<string>();//失败组
  10606. List<string> tids = new List<string>();
  10607. using (WebClient webClient = new WebClient())
  10608. {
  10609. foreach (var url in downloadUrls)
  10610. {
  10611. try
  10612. {
  10613. tids.Add("'" + url + "'");
  10614. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10615. if (entity != null)
  10616. {
  10617. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10618. if (cp == null)
  10619. {
  10620. JObject jsonObject = new JObject
  10621. {
  10622. { "Userid", "77886" },
  10623. { "pwd", "lt666888" },
  10624. { "Filename",entity.seller_memo }
  10625. };
  10626. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10627. JObject jsonObjects = JObject.Parse(response);
  10628. string msg = (string)jsonObjects["msg"];
  10629. if (msg == "报价成功")
  10630. {
  10631. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10632. DownloadAndConvertToBase64(url1);
  10633. }
  10634. else
  10635. {
  10636. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10637. }
  10638. }
  10639. else
  10640. {
  10641. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10642. JObject jsonObject = new JObject
  10643. {
  10644. { "Userid", "77886" },
  10645. { "pwd", "lt666888" },
  10646. { "Filename",chanp }
  10647. };
  10648. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10649. JObject jsonObjects = JObject.Parse(response);
  10650. string msg = (string)jsonObjects["msg"];
  10651. if (msg == "报价成功")
  10652. {
  10653. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10654. DownloadAndConvertToBase64(url1);
  10655. }
  10656. else
  10657. {
  10658. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10659. }
  10660. }
  10661. }
  10662. // 上传文件到FTP
  10663. }
  10664. catch (Exception ex)
  10665. {
  10666. Console.WriteLine($"An error occurred: {ex.Message}");
  10667. }
  10668. }
  10669. List<string> lw = new List<string>();
  10670. lw.Add(string.Format("( OrderState < 6 )"));
  10671. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10672. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10673. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10674. if (dt.Rows.Count > 0)
  10675. {
  10676. foreach (DataRow dr in dt.Rows)
  10677. {
  10678. ids.Add(dr["ctid"].ToString());
  10679. }
  10680. }
  10681. String ErrorMsgs = "";
  10682. foreach (String id in ids)
  10683. {
  10684. ErrorMsgs += id + ",";
  10685. }
  10686. if (ErrorMsgs.Length > 1)
  10687. {
  10688. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10689. }
  10690. if (ErrorMsgs.Length < 1)
  10691. {
  10692. ErrorMsgs = "上传成功";
  10693. returnSuccessMsg(ErrorMsgs);
  10694. }
  10695. else
  10696. {
  10697. returnErrorMsg("以下订单" + ErrorMsgs);
  10698. }
  10699. }
  10700. // 删除文件夹及其内容
  10701. /* Directory.Delete(localDirectory, true);*/
  10702. }
  10703. catch { }
  10704. }
  10705. public void get_center_data()
  10706. {
  10707. int userId = CurrentUser.UserID;
  10708. string postCode = CurrentUser.UserPost.Post.Code;
  10709. List<string> lw = new List<string>();
  10710. List<string> ww = new List<string>();
  10711. DateTime currentTime = DateTime.Now;
  10712. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10713. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10714. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10715. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10716. string sql = " SELECT ";
  10717. string startTime = "2023-10-01 11:22:31";
  10718. //设计
  10719. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10720. {
  10721. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10722. 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));
  10723. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10724. 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));
  10725. }
  10726. //客服
  10727. else if (postCode == "CustomerService" || postCode == "Director")
  10728. {
  10729. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10730. 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));
  10731. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10732. 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));
  10733. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10734. 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));
  10735. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10736. 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));
  10737. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10738. 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));
  10739. }
  10740. //售后
  10741. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10742. {
  10743. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10744. 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));
  10745. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10746. 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));
  10747. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10748. 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));
  10749. }
  10750. //下单部
  10751. else if (postCode == "Place" || postCode == "PlaceMr")
  10752. {
  10753. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10754. 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));
  10755. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10756. 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));
  10757. }
  10758. //车间
  10759. else if (postCode == "Supplier")
  10760. {
  10761. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10762. 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));
  10763. }
  10764. DataTable dt = new DataTable();
  10765. if (lw.Count > 0)
  10766. {
  10767. sql += string.Join(" , ", lw);
  10768. sql += " FROM ";
  10769. sql += string.Join(" , ", ww);
  10770. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10771. }
  10772. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10773. }
  10774. public void get_center_data_list()
  10775. {
  10776. int userId = CurrentUser.UserID;
  10777. string postCode = CurrentUser.UserPost.Post.Code;
  10778. string shopIds = CurrentUser.User.pemShop;
  10779. DataStruct dStruct = GetPostStruct();
  10780. List<string> lw = new List<string>();
  10781. DateTime currentTime = DateTime.Now;
  10782. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10783. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10784. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10785. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10786. string startTime = "2023-10-01 11:22:31";
  10787. int order_type = GetPostInt("order_type");
  10788. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10789. {
  10790. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10791. if (order_type == 0)
  10792. {
  10793. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10794. }
  10795. else if (order_type == 3)
  10796. {
  10797. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10798. }
  10799. else
  10800. {
  10801. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10802. }
  10803. }
  10804. //客服
  10805. if (postCode == "CustomerService" || postCode == "Director")
  10806. {
  10807. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10808. if (order_type == 0)
  10809. {
  10810. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10811. }
  10812. else if (order_type == 1)
  10813. {
  10814. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10815. }
  10816. else if (order_type == 2)
  10817. {
  10818. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10819. }
  10820. else if (order_type == 3)
  10821. {
  10822. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10823. }
  10824. else if (order_type == 4)
  10825. {
  10826. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10827. }
  10828. else
  10829. {
  10830. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10831. }
  10832. }
  10833. //售后
  10834. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10835. {
  10836. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10837. if (shopIds != "")
  10838. {
  10839. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10840. }
  10841. if (order_type == 2)
  10842. {
  10843. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10844. }
  10845. else if (order_type == 4)
  10846. {
  10847. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10848. }
  10849. else if (order_type == 5)
  10850. {
  10851. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10852. }
  10853. else
  10854. {
  10855. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10856. }
  10857. }
  10858. //下单部
  10859. if (postCode == "Place" || postCode == "PlaceMr")
  10860. {
  10861. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10862. if (shopIds != "")
  10863. {
  10864. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10865. }
  10866. else if (order_type == 1)
  10867. {
  10868. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10869. }
  10870. else if (order_type == 2)
  10871. {
  10872. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10873. }
  10874. else
  10875. {
  10876. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10877. }
  10878. }
  10879. //车间
  10880. if (postCode == "Supplier")
  10881. {
  10882. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10883. if (order_type == 5)
  10884. {
  10885. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10886. }
  10887. else
  10888. {
  10889. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10890. }
  10891. }
  10892. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10893. dStruct.Fileds = "tid,ctid";
  10894. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10895. writeGridDataTableJson(dStruct.TotalCount, dt);
  10896. }
  10897. public void aftersale_audit_master()
  10898. {
  10899. if (UrlPostParmsCheck("ctid"))
  10900. {
  10901. string ctid = GetPostString("ctid");
  10902. if (ctid.Length > 0)
  10903. {
  10904. bool result = aftersale_data_change(ctid);
  10905. if (result)
  10906. {
  10907. returnSuccessMsg("修改成功!");
  10908. return;
  10909. }
  10910. }
  10911. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10912. }
  10913. }
  10914. public void aftersale_batch_audit_master()
  10915. {
  10916. if (UrlPostParmsCheck("ctids"))
  10917. {
  10918. string ctids = GetPostString("ctids");
  10919. if (ctids.Length > 0)
  10920. {
  10921. List<string> list = new List<string>();
  10922. string[] ctid_list = ctids.Split(',');
  10923. foreach (var item in ctid_list)
  10924. {
  10925. bool result = aftersale_data_change(item);
  10926. if (!result)
  10927. {
  10928. list.Add(item);
  10929. }
  10930. }
  10931. if (list.Count > 0)
  10932. {
  10933. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10934. return;
  10935. }
  10936. returnSuccessMsg("修改成功!");
  10937. return;
  10938. }
  10939. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10940. }
  10941. }
  10942. public bool aftersale_data_change(string ctid)
  10943. {
  10944. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10945. if (ceErpTradeCell != null)
  10946. {
  10947. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10948. ceErpTradeCell.AfterSaleSupplierState = 0;
  10949. StringBuilder sql = new StringBuilder();
  10950. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10951. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10952. CeErpTradeResponsible.DelByTid(ctid, 0);
  10953. 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 == "不理赔")
  10954. {
  10955. CeErpTradeResponsible.DelByTid(ctid, 1);
  10956. ceErpTradeCell.AfterSaleSupplierState = 1;
  10957. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10958. ceErpTradeCell.AfterSaleState = 4;
  10959. }
  10960. else
  10961. {
  10962. ceErpTradeCell.AfterSaleState = 3;
  10963. }
  10964. bool needCyt = false;
  10965. if (dt != null)
  10966. {
  10967. if (dt.Rows.Count == 1)
  10968. {
  10969. bool isEnd = false;
  10970. foreach (DataRow dr in dt.Rows)
  10971. {
  10972. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10973. {
  10974. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10975. isEnd = true;
  10976. }
  10977. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10978. {
  10979. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10980. isEnd = true;
  10981. }
  10982. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10983. {
  10984. needCyt = true;
  10985. }
  10986. }
  10987. if (isEnd)
  10988. {
  10989. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10990. ceErpTradeCell.AfterSaleState = 4;
  10991. ceErpTradeCell.AfterSaleSupplierState = 1;
  10992. }
  10993. }
  10994. else
  10995. {
  10996. bool isAll = true;
  10997. foreach (DataRow dr in dt.Rows)
  10998. {
  10999. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11000. {
  11001. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11002. continue;
  11003. }
  11004. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  11005. {
  11006. string path = "";
  11007. int OrgID = 0;
  11008. if (!Convert.IsDBNull(dr["OrgPath"]))
  11009. {
  11010. path = dr["OrgPath"].ToString();
  11011. }
  11012. if (!Convert.IsDBNull(dr["OrgID"]))
  11013. {
  11014. OrgID = Convert.ToInt32(dr["OrgID"]);
  11015. }
  11016. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  11017. {
  11018. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11019. continue;
  11020. }
  11021. }
  11022. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11023. {
  11024. needCyt = true;
  11025. }
  11026. isAll = false;
  11027. }
  11028. if (isAll)
  11029. {
  11030. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11031. ceErpTradeCell.AfterSaleState = 4;
  11032. ceErpTradeCell.AfterSaleSupplierState = 1;
  11033. }
  11034. }
  11035. }
  11036. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  11037. {
  11038. commonHelper.sendCytAfterSale(ceErpTradeCell);
  11039. }
  11040. if (ceErpTradeCell.AfterSaleState == 4)
  11041. {
  11042. ApiVo apiVo = new ApiVo();
  11043. apiVo.orderNumber = ceErpTradeCell.ctid;
  11044. apiVo.actionName = "afterOver";
  11045. designHelper.API_WorkCore(apiVo); //afterOver
  11046. }
  11047. ceErpTradeCell.Update();
  11048. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  11049. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  11050. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11051. return true;
  11052. }
  11053. return false;
  11054. }
  11055. public void get_erp_wechatorder()
  11056. {
  11057. DataStruct dStruct = GetPostStruct();
  11058. List<string> lw = new List<string>();
  11059. string tid = GetPostString("tid");
  11060. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11061. string shopname = GetPostString("shopname");
  11062. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11063. string buyernick = GetPostString("buyer_nick");
  11064. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11065. string customer = GetPostString("customer");
  11066. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11067. string returndate1 = GetPostString("returndate1");
  11068. string returndate2 = GetPostString("returndate2");
  11069. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11070. if (dw.Length > 0) lw.Add(dw);
  11071. string finishDate1 = GetPostString("finishdate1");
  11072. string finishDate2 = GetPostString("finishdate2");
  11073. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11074. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11075. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11076. dStruct.Order = "created desc";
  11077. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11078. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11079. writeGridDataTableJson(dStruct.TotalCount, dt);
  11080. }
  11081. public void get_erp_wechatlist_sumprice()
  11082. {
  11083. DataStruct dStruct = GetPostStruct();
  11084. List<string> lw = new List<string>();
  11085. string tid = GetPostString("tid");
  11086. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11087. string shopname = GetPostString("shopname");
  11088. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11089. string buyernick = GetPostString("buyer_nick");
  11090. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11091. string customer = GetPostString("customer");
  11092. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11093. string returndate1 = GetPostString("returndate1");
  11094. string returndate2 = GetPostString("returndate2");
  11095. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11096. if (dw.Length > 0) lw.Add(dw);
  11097. string finishDate1 = GetPostString("finishdate1");
  11098. string finishDate2 = GetPostString("finishdate2");
  11099. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11100. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11101. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11102. string mainWhere = string.Join(" and ", lw.ToArray());
  11103. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11104. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11105. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11106. decimal total = 0;
  11107. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11108. {
  11109. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11110. }
  11111. var res = new
  11112. {
  11113. data = total
  11114. };
  11115. string ro_jsond = JsonConvert.SerializeObject(res);
  11116. returnSuccess(ro_jsond);
  11117. return;
  11118. }
  11119. public void get_erp_qr_waitdeliverylist()
  11120. {
  11121. DataStruct dStruct = GetPostStruct();
  11122. List<string> lw = new List<string>();
  11123. string tid = GetPostString("ctid");
  11124. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11125. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11126. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11127. var res_objz = new
  11128. {
  11129. restype = 1,
  11130. data = dt
  11131. };
  11132. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11133. returnSuccess(ro_jsonz);
  11134. }
  11135. public void get_erp_yield_list()
  11136. {
  11137. DataStruct dStruct = GetPostStruct();
  11138. List<string> lw = new List<string>();
  11139. string tid = GetPostString("ctid");
  11140. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11141. string shopname = GetPostString("shopname");
  11142. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11143. string buyernick = GetPostString("buyer_nick");
  11144. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11145. //if (tid.Length == 0 && buyernick.Length == 0)
  11146. //{
  11147. // lw.Add(string.Format("IsRefund<={0}", 1));
  11148. //}
  11149. string customer = GetPostString("customer");
  11150. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11151. string design = GetPostString("design");
  11152. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11153. string orderState = GetPostString("orderState");
  11154. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11155. string address = GetPostString("address");
  11156. 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));
  11157. string sellermemo = GetPostString("seller_memo");
  11158. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11159. string supplier = GetPostString("supplier");
  11160. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11161. string OrderArea = GetPostString("order_area");
  11162. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11163. string placedate1 = GetPostString("placedate1");
  11164. string placedate2 = GetPostString("placedate2");
  11165. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11166. if (fdw.Length > 0) lw.Add(fdw);
  11167. string price1 = GetPostString("price1");
  11168. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11169. string price2 = GetPostString("price2");
  11170. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11171. string unusualCon = GetPostString("unusualcon");
  11172. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11173. string posTag = CurrentUser.UserPost.Post.Code;
  11174. if (posTag == "Supplier")
  11175. {
  11176. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11177. }
  11178. lw.Add(string.Format("OrderState = 6 "));
  11179. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11180. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11181. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11182. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11183. writeGridDataTableJson(dStruct.TotalCount, dt);
  11184. }
  11185. public void change_erp_sup_state()
  11186. {
  11187. if (UrlPostParmsCheck("ctid"))
  11188. {
  11189. string ctid = GetPostString("ctid");
  11190. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11191. if (ceErpTradeCell != null)
  11192. {
  11193. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11194. if (ceErpTradeCellExtend == null)
  11195. {
  11196. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11197. ceErpTradeCellExtend.ctid = ctid;
  11198. ceErpTradeCellExtend.SupState = 1;
  11199. ceErpTradeCellExtend.Create();
  11200. }
  11201. else
  11202. {
  11203. ceErpTradeCellExtend.SupState = 1;
  11204. ceErpTradeCellExtend.Update();
  11205. }
  11206. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11207. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11208. return;
  11209. }
  11210. returnErrorMsg("找不到订单");
  11211. }
  11212. }
  11213. public void supplier_all_downs()
  11214. {
  11215. if (UrlPostParmsCheck("tids"))
  11216. {
  11217. string tids = GetPostString("tids");
  11218. if (tids != null && tids.Length > 0)
  11219. {
  11220. StringBuilder sql = new StringBuilder();
  11221. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11222. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11223. sql = new StringBuilder();
  11224. 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, "下载设计文件");
  11225. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11226. string[] list = tids.Split(',');
  11227. foreach (string ctid in list)
  11228. {
  11229. CeErpSukuraData.createInfo(ctid, 3);
  11230. }
  11231. designHelper.api_approveDesign(tids); //approveDesign
  11232. returnSuccessMsg("下载成功!");
  11233. return;
  11234. }
  11235. returnErrorMsg("下载订单更新失败");
  11236. }
  11237. }
  11238. public void uploaderFileSuccess()
  11239. {
  11240. if (UrlPostParmsCheck("fileName"))
  11241. {
  11242. string fileName = GetPostString("fileName");
  11243. ApiVo apiVo = new ApiVo();
  11244. apiVo.orderNumber = fileName;
  11245. apiVo.actionName = "finishDesign";
  11246. designHelper.API_WorkCore(apiVo);//finishDesign
  11247. returnSuccessMsg("");
  11248. }
  11249. }
  11250. public void get_sample2_order()
  11251. {
  11252. if (UrlPostParmsCheck("ctid"))
  11253. {
  11254. string ctid = GetPostString("ctid");
  11255. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11256. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11257. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11258. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11259. double total = 0.0;
  11260. double order_price = 0.0;
  11261. if (dt_bu.Rows.Count > 0)
  11262. {
  11263. foreach (DataRow dr in dt_bu.Rows)
  11264. {
  11265. total += Convert.ToDouble(dr["payment"]);
  11266. }
  11267. }
  11268. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11269. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11270. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11271. string tid = ctid.Replace("S_", "");
  11272. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11273. double paymant = 0.0;
  11274. if (entity != null)
  11275. {
  11276. paymant = entity.payment;
  11277. }
  11278. string return_reason = "";
  11279. if (dt_after != null && dt_after.Rows.Count > 0)
  11280. {
  11281. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11282. }
  11283. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11284. }
  11285. }
  11286. public void get_erp_design_status()
  11287. {
  11288. string designName = GetPostString("designName");
  11289. DataStruct dStruct = GetPostStruct();
  11290. if (designName.Length > 0)
  11291. {
  11292. 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";
  11293. sql_user += " and Name like '%" + designName + "%'";
  11294. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11295. List<string> ids_list = new List<string>();
  11296. if (user_table.Rows.Count > 0)
  11297. {
  11298. foreach (DataRow item in user_table.Rows)
  11299. {
  11300. ids_list.Add(item["id"].ToString());
  11301. string ids_s = item["TeamIds"].ToString();
  11302. if (ids_s.Length > 0)
  11303. {
  11304. ids_list.AddRange(ids_s.Split(','));
  11305. }
  11306. }
  11307. }
  11308. HashSet<string> set = new HashSet<string>(ids_list);
  11309. ids_list = set.ToList();
  11310. if (ids_list.Count > 0)
  11311. {
  11312. 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));
  11313. dStruct.MainWhere = sql;
  11314. DataTable dt = null;
  11315. dt = WebCache.GetData("view_ErpUser", dStruct);
  11316. writeGridDataTableJson(dStruct.TotalCount, dt);
  11317. }
  11318. }
  11319. }
  11320. public void change_erp_order_price()
  11321. {
  11322. string ctid = GetPostString("ctid");
  11323. double price = GetPostDouble("price");
  11324. if (ctid.Length > 0)
  11325. {
  11326. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11327. if (ceErpTradeCellExtend == null)
  11328. {
  11329. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11330. ceErpTradeCellExtend.ctid = ctid;
  11331. ceErpTradeCellExtend.payment_cyt = price;
  11332. ceErpTradeCellExtend.Create();
  11333. }
  11334. else
  11335. {
  11336. ceErpTradeCellExtend.payment_cyt = price;
  11337. ceErpTradeCellExtend.Update();
  11338. }
  11339. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11340. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11341. {
  11342. ceErpDataSendOrderInfo.isSync = false;
  11343. ceErpDataSendOrderInfo.Update();
  11344. }
  11345. if (ceErpDataSendOrderInfo == null)
  11346. {
  11347. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11348. ceErpDataSendOrderInfo.isSync = false;
  11349. ceErpDataSendOrderInfo.ctid = ctid;
  11350. ceErpDataSendOrderInfo.Create();
  11351. }
  11352. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11353. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11354. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11355. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11356. {
  11357. dataSendOrderBean dataSendOrderBean = null;
  11358. foreach (DataRow item in dth.Rows)
  11359. {
  11360. try
  11361. {
  11362. dataSendOrderBean = new dataSendOrderBean();
  11363. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11364. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11365. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11366. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11367. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11368. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11369. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11370. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11371. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11372. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11373. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11374. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11375. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11376. if (result != null)
  11377. {
  11378. if ("0".Equals(result.errcode))
  11379. {
  11380. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11381. }
  11382. else
  11383. {
  11384. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11385. }
  11386. }
  11387. }
  11388. catch (Exception ex)
  11389. {
  11390. }
  11391. }
  11392. }
  11393. returnSuccessMsg("修改成功!");
  11394. return;
  11395. }
  11396. returnErrorMsg("找不到订单");
  11397. }
  11398. public void find_he_together()
  11399. {
  11400. string ctid = GetPostString("ctid");
  11401. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11402. List<string> list = new List<string>();
  11403. if (ceErpTradeCell != null)
  11404. {
  11405. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11406. {
  11407. 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);
  11408. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11409. if (table != null && table.Rows.Count > 0)
  11410. {
  11411. foreach (TableRow row in table.Rows)
  11412. {
  11413. }
  11414. }
  11415. }
  11416. }
  11417. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11418. }
  11419. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11420. {
  11421. //chy----19
  11422. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11423. //GD-CYT-----64
  11424. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11425. //ZHX----3
  11426. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11427. //JK----97
  11428. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11429. //ZT----70
  11430. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11431. //GD-CYTUV---126
  11432. {126, new Dictionary<string, string> {{"uv", "uv"}}},
  11433. //LHCY-----98
  11434. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11435. //XD-----90
  11436. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11437. //CYCY-----14
  11438. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11439. };
  11440. //其他改名
  11441. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11442. {
  11443. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11444. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11445. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11446. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11447. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11448. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11449. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11450. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11451. };
  11452. //不统计
  11453. List<int> no_suppliers = new List<int>()
  11454. {
  11455. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11456. };
  11457. //配件单
  11458. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11459. {
  11460. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11461. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11462. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11463. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11464. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11465. {"旗杆",new List<string>(){ "班旗" } },
  11466. {"牙签",new List<string>(){ "不干胶" } }
  11467. };
  11468. public void get_place_order_data()
  11469. {
  11470. string date1 = GetPostString("date1");
  11471. string date2 = GetPostString("date2");
  11472. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11473. DateTime start = DateTime.Parse(starttime);
  11474. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11475. DateTime end = DateTime.Parse(endtime);
  11476. if (date1 != null && date1.Length > 0)
  11477. {
  11478. DateTime dateTime = DateTime.Parse(date1);
  11479. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11480. start = DateTime.Parse(starttime);
  11481. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11482. end = DateTime.Parse(endtime);
  11483. }
  11484. if (date2 != null && date2.Length > 0)
  11485. {
  11486. DateTime dateTime = DateTime.Parse(date2);
  11487. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11488. end = DateTime.Parse(endtime);
  11489. }
  11490. 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);
  11491. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11492. //不干胶-----1,卡片-----29
  11493. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11494. foreach (DataRow row in data.Rows)
  11495. {
  11496. int productId = Convert.ToInt32(row["ProductId"]);
  11497. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11498. if (no_suppliers.Contains(supplierId))
  11499. {
  11500. continue;
  11501. }
  11502. string seller_memo = row["seller_memo"].ToString();
  11503. bool ispj = false;//是否配件单
  11504. bool isfirst = true;//第一个配
  11505. maps.Keys.ForEach(key =>
  11506. {
  11507. //备注包含配件
  11508. if (seller_memo.Contains(key) && isfirst)
  11509. {
  11510. List<string> list = maps[key];
  11511. ispj = true;
  11512. isfirst = false;
  11513. for (int i = 0; i < list.Count; i++)
  11514. {
  11515. if (seller_memo.Contains(list[i]))
  11516. {
  11517. ispj = false;
  11518. break;
  11519. }
  11520. }
  11521. }
  11522. });
  11523. if (ispj)
  11524. {
  11525. continue;
  11526. }
  11527. seller_memo = seller_memo.Replace("UV", "uv");
  11528. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11529. //吊牌归到卡片
  11530. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11531. seller_memo = seller_memo.Replace("卡套", "卡片");
  11532. seller_memo = seller_memo.Replace("封套", "卡片");
  11533. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11534. seller_memo = seller_memo.Replace("腰封", "卡片");
  11535. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11536. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11537. seller_memo = seller_memo.Replace("横幅", "条幅");
  11538. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11539. string map_key = "";
  11540. string type = "";
  11541. if (supplierMap.ContainsKey(supplierId))
  11542. {
  11543. foreach (var kvp in supplierMap[supplierId])
  11544. {
  11545. if (seller_memo.Contains(kvp.Key))
  11546. {
  11547. map_key = kvp.Value;
  11548. type = kvp.Value;
  11549. break;
  11550. }
  11551. }
  11552. }
  11553. if (map_key == "")
  11554. {
  11555. type = "其他";
  11556. map_key = "其他";
  11557. }
  11558. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11559. {
  11560. map_key = suppliers[supplierId];
  11561. }
  11562. if (supplierId == 70)
  11563. {
  11564. supplierId = 70;
  11565. }
  11566. map_key += "_" + row["SupplierName"].ToString();
  11567. Dictionary<string, int> map = null;
  11568. if (other_map.ContainsKey(map_key))
  11569. {
  11570. other_map.TryGetValue(map_key, out map);
  11571. }
  11572. else
  11573. {
  11574. map = new Dictionary<string, int>();
  11575. map.Add("dayDev", 0);//当天出货
  11576. map.Add("dayTotal", 0);//下单总数
  11577. map.Add("payTotal", 0);//500以上
  11578. map.Add("today", 0);//当天出货数量
  11579. map.Add("unusua", 0);//异常数
  11580. other_map.Add(map_key, map);
  11581. other_map.TryGetValue(map_key, out map);
  11582. }
  11583. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11584. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11585. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11586. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11587. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11588. {
  11589. map["dayTotal"]++;
  11590. if (supplierId == 97)
  11591. {
  11592. supplierId = 97;
  11593. }
  11594. }
  11595. if (Convert.ToDecimal(row["payment"]) >= 500)
  11596. {
  11597. map["payTotal"]++;
  11598. }
  11599. bool istoday = false;
  11600. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11601. {
  11602. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11603. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11604. {
  11605. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11606. {
  11607. map["today"]++;
  11608. }
  11609. }
  11610. else
  11611. {
  11612. if (supplierId == 80)
  11613. {
  11614. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11615. {
  11616. map["today"]++;
  11617. }
  11618. }
  11619. else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11620. {
  11621. map["today"]++;
  11622. istoday = true;
  11623. }
  11624. }
  11625. }
  11626. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11627. {
  11628. map["unusua"]++;
  11629. }
  11630. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11631. //GD-CYT-----64
  11632. DateTime two = palceTimeStart.AddHours(14);
  11633. DateTime three = palceTimeStart.AddHours(15);
  11634. DateTime four = palceTimeStart.AddHours(16);
  11635. DateTime six = palceTimeStart.AddHours(18);
  11636. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11637. {
  11638. //下午四点前 500-1000
  11639. string count = row["ProductCount"].ToString();
  11640. if (count != null && count.Length > 0)
  11641. {
  11642. int productCount = commonHelper.getPlaceProductCount(count);
  11643. if (productCount >= 500 && productCount <= 1000)
  11644. {
  11645. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11646. {
  11647. map["dayDev"]++;
  11648. }
  11649. }
  11650. }
  11651. }
  11652. //UV
  11653. else if ("uv".Equals(type))
  11654. {
  11655. //ZT----70
  11656. //ZHX----3
  11657. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11658. {
  11659. map["dayDev"]++;
  11660. }
  11661. //JK----97
  11662. //HZX----105
  11663. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11664. {
  11665. map["dayDev"]++;
  11666. }
  11667. }
  11668. //帆布---52|条幅---27
  11669. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11670. {
  11671. //LHCY-----98
  11672. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11673. {
  11674. map["dayDev"]++;
  11675. }
  11676. }
  11677. //条幅
  11678. else if ("条幅".Equals(type))
  11679. {
  11680. //XD-----90
  11681. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11682. {
  11683. map["dayDev"]++;
  11684. }
  11685. }
  11686. //桌布
  11687. else if ("桌布".Equals(type))
  11688. {
  11689. //XD-----90
  11690. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11691. {
  11692. map["dayDev"]++;
  11693. }
  11694. }
  11695. //DL---10
  11696. //AYTW---119
  11697. //FS-CYT-DY ----80
  11698. //JK----97
  11699. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11700. {
  11701. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11702. {
  11703. map["dayDev"]++;
  11704. if (supplierId == 80 && istoday)
  11705. {
  11706. Debug.WriteLine(seller_memo);
  11707. }
  11708. }
  11709. }
  11710. // QC---121
  11711. else if (supplierId == 121)
  11712. {
  11713. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11714. {
  11715. map["dayDev"]++;
  11716. }
  11717. }
  11718. }
  11719. DataTable dt = new DataTable();
  11720. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11721. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11722. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11723. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11724. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11725. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11726. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11727. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11728. other_map.Keys.ForEach(key =>
  11729. {
  11730. DataRow dr = dt.NewRow();
  11731. Dictionary<string, int> map = other_map[key];
  11732. string[] key_list = key.Split('_');
  11733. dr[0] = key_list[0];
  11734. dr[1] = key_list[1];
  11735. if (key_list.Length > 2)
  11736. {
  11737. dr[1] += "(" + key_list[2] + ")";
  11738. }
  11739. dr[2] = map["dayTotal"];
  11740. dr[3] = map["payTotal"];
  11741. dr[4] = map["today"];
  11742. dr[5] = map["unusua"];
  11743. dr[6] = map["dayDev"];
  11744. double rate = 0.00;
  11745. if (map["dayDev"] > 0)
  11746. {
  11747. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11748. }
  11749. dr[7] = rate.ToString();
  11750. dt.Rows.Add(dr);
  11751. });
  11752. DataView dv = new DataView(dt);
  11753. dv.Sort = "SupplierName";
  11754. //dv.Sort = "AllOrder desc";
  11755. DataTable dtNew = dv.ToTable();
  11756. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11757. }
  11758. public void check_order_desing_info()
  11759. {
  11760. string ctid = GetPostString("ctid");
  11761. if (!string.IsNullOrEmpty(ctid))
  11762. {
  11763. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11764. if (ceErpTradeCell != null)
  11765. {
  11766. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11767. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11768. return;
  11769. }
  11770. returnErrorMsg("找不到订单");
  11771. return;
  11772. }
  11773. returnErrorMsg("找不到订单");
  11774. }
  11775. public void get_timeout_detail()
  11776. {
  11777. string poscode = CurrentUser.UserPost.Post.Code;
  11778. DataStruct dStruct = GetPostStruct();
  11779. List<string> lw = new List<string>();
  11780. string id = GetPostString("id");
  11781. string pay_date1 = GetPostString("pay_date1");
  11782. string pay_date2 = GetPostString("pay_date2");
  11783. int type = GetPostInt("type");
  11784. if (type == 0)
  11785. {
  11786. if (pay_date1.Length > 0)
  11787. {
  11788. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11789. }
  11790. if (pay_date2.Length > 0)
  11791. {
  11792. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11793. }
  11794. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11795. }
  11796. if (type == 1)
  11797. {
  11798. if (pay_date1.Length > 0)
  11799. {
  11800. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11801. }
  11802. if (pay_date2.Length > 0)
  11803. {
  11804. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11805. }
  11806. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11807. }
  11808. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11809. DataTable dt = null;
  11810. dt = WebCache.GetData("view_orderlist", dStruct);
  11811. writeGridDataTableJson(dStruct.TotalCount, dt);
  11812. }
  11813. public void saveUrgentChargePrice()
  11814. {
  11815. string ctid = GetPostString("ctid");
  11816. if (!string.IsNullOrEmpty(ctid))
  11817. {
  11818. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11819. if (ceErpTradeCell != null)
  11820. {
  11821. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11822. if (prices <= 100)
  11823. {
  11824. returnErrorMsg("此订单金额不足100元,无法加急。");
  11825. return;
  11826. }
  11827. double price = GetPostDouble("price");
  11828. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11829. if (ceErpTradeCellExtend == null)
  11830. {
  11831. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11832. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11833. }
  11834. ceErpTradeCellExtend.urgentCharge = price;
  11835. if (ceErpTradeCellExtend.ID > 0)
  11836. {
  11837. ceErpTradeCellExtend.Update();
  11838. }
  11839. else
  11840. {
  11841. ceErpTradeCellExtend.Save();
  11842. }
  11843. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11844. returnSuccessMsg("修改成功!");
  11845. return;
  11846. }
  11847. returnErrorMsg("找不到订单");
  11848. return;
  11849. }
  11850. returnErrorMsg("找不到订单");
  11851. }
  11852. public void finish_erp_order()
  11853. {
  11854. string ctid = GetPostString("ctid");
  11855. if (!string.IsNullOrEmpty(ctid))
  11856. {
  11857. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11858. {
  11859. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11860. if (ceErpTradeCell != null)
  11861. {
  11862. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11863. ceErpTradeCell.Update();
  11864. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11865. returnSuccessMsg("修改成功!");
  11866. return;
  11867. }
  11868. }
  11869. }
  11870. returnErrorMsg("找不到订单");
  11871. }
  11872. public void get_trade_order_list()
  11873. {
  11874. string tid = GetPostString("tid");
  11875. if (!string.IsNullOrEmpty(tid))
  11876. {
  11877. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11878. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11879. writeGridDataTableJson(data.Rows.Count, data);
  11880. return;
  11881. }
  11882. returnErrorMsg("找不到订单");
  11883. }
  11884. public void save_cell_spu()
  11885. {
  11886. string ctid = GetPostString("ctid");
  11887. string spu_id = GetPostString("spu_id");
  11888. if (!string.IsNullOrEmpty(ctid))
  11889. {
  11890. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11891. if (ceErpTradeCellExtend == null)
  11892. {
  11893. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11894. ceErpTradeCellExtend.ctid = ctid;
  11895. }
  11896. ceErpTradeCellExtend.spu_id = spu_id;
  11897. if (!string.IsNullOrEmpty(spu_id))
  11898. {
  11899. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11900. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11901. }
  11902. if (ceErpTradeCellExtend.ID == 0)
  11903. {
  11904. ceErpTradeCellExtend.Create();
  11905. }
  11906. else
  11907. {
  11908. ceErpTradeCellExtend.Update();
  11909. }
  11910. returnSuccessMsg("修改成功!");
  11911. return;
  11912. }
  11913. returnErrorMsg("找不到订单");
  11914. }
  11915. public void change_express_info()
  11916. {
  11917. string ctid = GetPostString("ctid");
  11918. string transNo = GetPostString("transNo");
  11919. string transCom = GetPostString("transCom");
  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.modExpressNo = transNo;
  11929. ceErpTradeCellExtend.modExpressCom = transCom;
  11930. ceErpTradeCellExtend.readMod = 2;
  11931. if (ceErpTradeCellExtend.ID == 0)
  11932. {
  11933. ceErpTradeCellExtend.Create();
  11934. }
  11935. else
  11936. {
  11937. ceErpTradeCellExtend.Update();
  11938. }
  11939. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11940. returnSuccessMsg("修改成功!");
  11941. return;
  11942. }
  11943. returnErrorMsg("找不到订单");
  11944. }
  11945. public void get_change_express_list()
  11946. {
  11947. DataStruct dStruct = GetPostStruct();
  11948. List<string> lw = new List<string>();
  11949. int st = 2;
  11950. string tid = GetPostString("ctid");
  11951. if (tid.Length > 0)
  11952. {
  11953. string select_tid = getTidByCtid(tid);
  11954. lw.Add(string.Format("tid='{0}'", select_tid));
  11955. }
  11956. string shopname = GetPostString("shopname");
  11957. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11958. string buyernick = GetPostString("buyer_nick");
  11959. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11960. string sellermemo = GetPostString("seller_memo");
  11961. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11962. string supplier = GetPostString("supplier");
  11963. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11964. string customer = GetPostString("customer");
  11965. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11966. string design = GetPostString("design");
  11967. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11968. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11969. string poscode = CurrentUser.UserPost.Post.Code;
  11970. if (poscode != "SysAdmin")
  11971. {
  11972. string shopid = CurrentUser.User.pemShop;
  11973. lw.Add(string.Format("shopId in ({0})", shopid));
  11974. }
  11975. lw.Add("readMod = 2");
  11976. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11977. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11978. writeGridDataTableJson(dStruct.TotalCount, dt);
  11979. }
  11980. public void deal_express_complete()
  11981. {
  11982. string ctid = GetPostString("ctid");
  11983. if (!string.IsNullOrEmpty(ctid))
  11984. {
  11985. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11986. if (ceErpTradeCellExtend == null)
  11987. {
  11988. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11989. ceErpTradeCellExtend.ctid = ctid;
  11990. }
  11991. ceErpTradeCellExtend.readMod = 1;
  11992. if (ceErpTradeCellExtend.ID == 0)
  11993. {
  11994. ceErpTradeCellExtend.Create();
  11995. }
  11996. else
  11997. {
  11998. ceErpTradeCellExtend.Update();
  11999. }
  12000. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  12001. returnSuccessMsg("修改成功!");
  12002. return;
  12003. }
  12004. returnErrorMsg("找不到订单");
  12005. }
  12006. public void aftersale_return_visit()
  12007. {
  12008. string ctid = GetPostString("ctid");
  12009. if (!string.IsNullOrEmpty(ctid))
  12010. {
  12011. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12012. if (ceErpTradeCellExtend == null)
  12013. {
  12014. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12015. ceErpTradeCellExtend.ctid = ctid;
  12016. }
  12017. ceErpTradeCellExtend.returnVisit = 1;
  12018. if (ceErpTradeCellExtend.ID == 0)
  12019. {
  12020. ceErpTradeCellExtend.Create();
  12021. }
  12022. else
  12023. {
  12024. ceErpTradeCellExtend.Update();
  12025. }
  12026. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12027. if (ceErpTradeAfterSaleExtend != null)
  12028. {
  12029. ceErpTradeAfterSaleExtend.TextResult = "";
  12030. ceErpTradeAfterSaleExtend.Update();
  12031. }
  12032. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  12033. returnSuccessMsg("修改成功!");
  12034. return;
  12035. }
  12036. returnErrorMsg("找不到订单");
  12037. }
  12038. public void orderPlaceInfo()
  12039. {
  12040. string ctids = GetPostString("ctids");
  12041. string[] list = ctids.Split(',');
  12042. foreach (string ctid in list)
  12043. {
  12044. CeErpSukuraData.createInfo(ctid, 3);
  12045. }
  12046. StringBuilder sql = new StringBuilder();
  12047. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  12048. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  12049. designHelper.api_approveDesign(ctids); //approveDesign
  12050. returnSuccessMsg("");
  12051. }
  12052. public void get_issue_list()
  12053. {
  12054. DataStruct dStruct = GetPostStruct();
  12055. List<string> lw = new List<string>();
  12056. int st = 2;
  12057. string tid = GetPostString("ctid");
  12058. if (tid.Length > 0)
  12059. {
  12060. string select_tid = getTidByCtid(tid);
  12061. lw.Add(string.Format("tid='{0}'", select_tid));
  12062. }
  12063. string shopname = GetPostString("shopname");
  12064. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12065. string buyernick = GetPostString("buyer_nick");
  12066. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12067. string sellermemo = GetPostString("seller_memo");
  12068. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12069. string supplier = GetPostString("supplier");
  12070. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12071. string customer = GetPostString("customer");
  12072. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12073. string design = GetPostString("design");
  12074. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12075. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12076. string poscode = CurrentUser.UserPost.Post.Code;
  12077. if (poscode != "SysAdmin")
  12078. {
  12079. string shopid = CurrentUser.User.pemShop;
  12080. lw.Add(string.Format("shopId in ({0})", shopid));
  12081. }
  12082. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12083. {
  12084. lw.Add("IssueState = 1");
  12085. }
  12086. else
  12087. {
  12088. string iisstate = GetPostString("iisstate");
  12089. if ("1".Equals(iisstate))
  12090. {
  12091. lw.Add("IssueState =1");
  12092. }
  12093. else if ("2".Equals(iisstate))
  12094. {
  12095. lw.Add("IssueState = 2");
  12096. }
  12097. else
  12098. {
  12099. lw.Add("IssueState > 0");
  12100. }
  12101. }
  12102. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12103. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12104. writeGridDataTableJson(dStruct.TotalCount, dt);
  12105. }
  12106. public void saveIssueContent()
  12107. {
  12108. string ctid = GetPostString("ctid");
  12109. if (!string.IsNullOrEmpty(ctid))
  12110. {
  12111. string content = GetPostString("content");
  12112. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12113. if (ceErpTradeAfterSaleExtend == null)
  12114. {
  12115. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12116. ceErpTradeAfterSaleExtend.tid = ctid;
  12117. }
  12118. ceErpTradeAfterSaleExtend.IssueContent = content;
  12119. ceErpTradeAfterSaleExtend.IssueState = 1;
  12120. if (ceErpTradeAfterSaleExtend.ID > 0)
  12121. {
  12122. ceErpTradeAfterSaleExtend.Update();
  12123. }
  12124. else
  12125. {
  12126. ceErpTradeAfterSaleExtend.Create();
  12127. }
  12128. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12129. returnSuccessMsg("添加成功!");
  12130. return;
  12131. }
  12132. returnErrorMsg("找不到订单");
  12133. }
  12134. public void dealIssueContent()
  12135. {
  12136. string ctid = GetPostString("ctid");
  12137. if (!string.IsNullOrEmpty(ctid))
  12138. {
  12139. string content = GetPostString("content");
  12140. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12141. if (ceErpTradeAfterSaleExtend != null)
  12142. {
  12143. ceErpTradeAfterSaleExtend.IssueState = 2;
  12144. ceErpTradeAfterSaleExtend.Update();
  12145. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12146. returnSuccessMsg("修改完成!");
  12147. return;
  12148. }
  12149. }
  12150. returnErrorMsg("找不到订单");
  12151. }
  12152. public void set_tid_attachments()
  12153. {
  12154. string tid = GetPostString("tid");
  12155. string atta = GetPostString("atta");
  12156. if (!string.IsNullOrEmpty(tid))
  12157. {
  12158. if (string.IsNullOrEmpty(atta))
  12159. {
  12160. returnErrorMsg("文件地址为空");
  12161. return;
  12162. }
  12163. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12164. if (ceErpTradeCell != null)
  12165. {
  12166. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12167. if (ceErpTrade == null)
  12168. {
  12169. returnErrorMsg("找不到订单");
  12170. return;
  12171. }
  12172. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12173. bool isSend = false;
  12174. if (dt != null && dt.Rows.Count > 0)
  12175. {
  12176. foreach (DataRow row in dt.Rows)
  12177. {
  12178. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12179. {
  12180. isSend = true;
  12181. }
  12182. }
  12183. if (isSend)
  12184. {
  12185. returnErrorMsg("已发货无法修改");
  12186. return;
  12187. }
  12188. ceErpTrade.Attachments = atta;
  12189. ceErpTrade.Update();
  12190. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12191. returnSuccessMsg("上传成功!");
  12192. return;
  12193. }
  12194. }
  12195. }
  12196. returnErrorMsg("找不到订单");
  12197. }
  12198. public void get_tid_attachments()
  12199. {
  12200. string tid = GetPostString("tid");
  12201. if (!string.IsNullOrEmpty(tid))
  12202. {
  12203. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12204. if (ceErpTradeCell != null)
  12205. {
  12206. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12207. if (ceErpTrade == null)
  12208. {
  12209. returnErrorMsg("找不到订单");
  12210. return;
  12211. }
  12212. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12213. return;
  12214. }
  12215. }
  12216. returnErrorMsg("找不到订单");
  12217. }
  12218. public void check_erp_sameorders()
  12219. {
  12220. if (UrlPostParmsCheck("ctid"))
  12221. {
  12222. string eid = GetPostString("ctid");
  12223. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12224. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12225. if (entity != null && ceErpTrade != null)
  12226. {
  12227. if (entity.OrderState > 6)
  12228. {
  12229. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12230. return;
  12231. }
  12232. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12233. List<string> ids = new List<string>();
  12234. if (dt != null && dt.Rows.Count > 1)
  12235. {
  12236. bool needhe = true;
  12237. foreach (DataRow dr in dt.Rows)
  12238. {
  12239. ids.Add("'" + dr["ctid"] + "'");
  12240. /* //备注有合包
  12241. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12242. {
  12243. needhe = true;
  12244. }
  12245. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12246. {
  12247. needhe = true;
  12248. }
  12249. //顺丰快递
  12250. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12251. {
  12252. needhe = true;
  12253. }*/
  12254. }
  12255. if (!needhe)
  12256. {
  12257. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12258. return;
  12259. }
  12260. StringBuilder sql = new StringBuilder();
  12261. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12262. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12263. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12264. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12265. foreach (DataRow dr in dt.Rows)
  12266. {
  12267. dr["dstate"] = 0;
  12268. dr["dnumber"] = 0;
  12269. foreach (DataRow row in dt1.Rows)
  12270. {
  12271. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12272. {
  12273. dr["dstate"] = 2;
  12274. dr["default"] = 1;
  12275. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12276. }
  12277. }
  12278. if (eid.Equals(dr["ctid"].ToString()))
  12279. {
  12280. dr["dstate"] = 1;
  12281. dr["default"] = 1;
  12282. }
  12283. }
  12284. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12285. return;
  12286. }
  12287. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12288. return;
  12289. }
  12290. returnErrorMsg("未找到订单");
  12291. return;
  12292. }
  12293. returnErrorMsg("缺少必要的参数");
  12294. }
  12295. public void get_mark_number()
  12296. {
  12297. string eid = GetPostString("ctid");
  12298. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12299. if (entity != null)
  12300. {
  12301. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12302. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12303. int current = 1;
  12304. if (ceErpDeliverMark == null)
  12305. {
  12306. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12307. List<string> ids = new List<string>();
  12308. if (dt != null && dt.Rows.Count > 1)
  12309. {
  12310. foreach (DataRow dr in dt.Rows)
  12311. {
  12312. ids.Add("'" + dr["ctid"] + "'");
  12313. }
  12314. //查询已有的编号
  12315. StringBuilder sql = new StringBuilder();
  12316. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12317. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12318. if (dt1 == null || dt1.Rows.Count == 0)
  12319. {
  12320. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12321. List<int> list_number = new List<int>();
  12322. foreach (DataRow row in numbers.Rows)
  12323. {
  12324. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12325. }
  12326. //查询空余编号
  12327. for (int i = 0; i < list_number.Count + 2; i++)
  12328. {
  12329. if (!list_number.Contains(current))
  12330. {
  12331. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12332. //防止查询过程中有新数据生成
  12333. if (ceErpDeliverMark1 == null)
  12334. {
  12335. break;
  12336. }
  12337. }
  12338. current++;
  12339. }
  12340. }
  12341. else
  12342. {
  12343. foreach (DataRow row in dt1.Rows)
  12344. {
  12345. current = Convert.ToInt32(row["markNumber"]);
  12346. }
  12347. }
  12348. ceErpDeliverMark = new CeErpDeliverMark();
  12349. ceErpDeliverMark.ctid = eid;
  12350. ceErpDeliverMark.createtime = DateTime.Now;
  12351. if (ceErpTrade != null)
  12352. {
  12353. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12354. }
  12355. ceErpDeliverMark.markNumber = current;
  12356. ceErpDeliverMark.Create();
  12357. }
  12358. }
  12359. else
  12360. {
  12361. current = ceErpDeliverMark.markNumber;
  12362. }
  12363. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12364. return;
  12365. }
  12366. }
  12367. public void aftersaleCytSend()
  12368. {
  12369. string ctid = GetPostString("ctid");
  12370. if (!string.IsNullOrEmpty(ctid))
  12371. {
  12372. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12373. if (ceErpTradeCell != null)
  12374. {
  12375. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12376. }
  12377. returnSuccessMsg("推送成功");
  12378. return;
  12379. }
  12380. returnErrorMsg("缺少必要的参数");
  12381. }
  12382. public void packOrderInfo()
  12383. {
  12384. string ctids = GetPostString("ctids");
  12385. if (!string.IsNullOrEmpty(ctids))
  12386. {
  12387. string[] ctid_list = ctids.Split(',');
  12388. if (ctid_list.Length > 20)
  12389. {
  12390. returnErrorMsg("单次下载次数不能超过20个");
  12391. return;
  12392. }
  12393. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12394. StringBuilder sql = new StringBuilder();
  12395. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12396. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12397. int supplierId = 0;
  12398. StringBuilder insterSql = new StringBuilder();
  12399. for (int i = 0; i < dt.Rows.Count; i++)
  12400. {
  12401. DataRow row = dt.Rows[i];
  12402. if (i == 0)
  12403. {
  12404. supplierId = Convert.ToInt32(row["SupplierId"]);
  12405. }
  12406. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12407. {
  12408. returnErrorMsg("同车间的订单才能一起打包");
  12409. return;
  12410. }
  12411. int orderState = Convert.ToInt32(row["OrderState"]);
  12412. if (orderState != 5)
  12413. {
  12414. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12415. return;
  12416. }
  12417. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12418. }
  12419. CeErpPackData ceErpPackData = new CeErpPackData();
  12420. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12421. ceErpPackData.supplierId = supplierId;
  12422. ceErpPackData.createtime = DateTime.Now;
  12423. ceErpPackData.createBy = CurrentUser.UserID;
  12424. ceErpPackData.createName = CurrentUser.UserName;
  12425. ceErpPackData.Create();
  12426. if (ceErpPackData.ID > 0)
  12427. {
  12428. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12429. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12430. }
  12431. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12432. returnSuccessMsg("打包成功");
  12433. return;
  12434. }
  12435. returnErrorMsg("缺少必要的参数");
  12436. }
  12437. public void rePackOrderInfo()
  12438. {
  12439. string id = GetPostString("id");
  12440. if (!string.IsNullOrEmpty(id))
  12441. {
  12442. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12443. if (ceErpPackData == null)
  12444. {
  12445. returnSuccessMsg("查无数据");
  12446. return;
  12447. }
  12448. ceErpPackData.upStatus = 0;
  12449. ceErpPackData.message = "";
  12450. ceErpPackData.Update();
  12451. returnSuccessMsg("打包成功");
  12452. return;
  12453. }
  12454. returnErrorMsg("缺少必要的参数");
  12455. }
  12456. public void backPackOrderInfo()
  12457. {
  12458. string id = GetPostString("id");
  12459. if (!string.IsNullOrEmpty(id))
  12460. {
  12461. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12462. if (ceErpPackData == null)
  12463. {
  12464. returnSuccessMsg("查无数据");
  12465. return;
  12466. }
  12467. ceErpPackData.upStatus = 4;
  12468. ceErpPackData.Update();
  12469. List<string> list = new List<string>();
  12470. StringBuilder sql = new StringBuilder();
  12471. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12472. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12473. for (int i = 0; i < dt.Rows.Count; i++)
  12474. {
  12475. DataRow row = dt.Rows[i];
  12476. list.Add("'" + row["ctid"].ToString() + "'");
  12477. }
  12478. string textCtids = string.Join(",", list);
  12479. 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));
  12480. 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, "无法打包退回"));
  12481. returnSuccessMsg("退回成功");
  12482. return;
  12483. }
  12484. returnErrorMsg("缺少必要的参数");
  12485. }
  12486. public void addPackDownNum()
  12487. {
  12488. string id = GetPostString("id");
  12489. if (!string.IsNullOrEmpty(id))
  12490. {
  12491. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12492. returnSuccessMsg("下载成功");
  12493. return;
  12494. }
  12495. returnErrorMsg("缺少必要的参数");
  12496. }
  12497. public void get_pack_list()
  12498. {
  12499. DataStruct dStruct = GetPostStruct();
  12500. List<string> lw = new List<string>();
  12501. string supplier = GetPostString("supplier");
  12502. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12503. string posTag = CurrentUser.UserPost.Post.Code;
  12504. if (posTag == "Supplier")
  12505. {
  12506. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12507. }
  12508. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12509. dStruct.Order = "createtime desc";
  12510. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12511. writeGridDataTableJson(dStruct.TotalCount, dt);
  12512. }
  12513. public void get_pack_order_list()
  12514. {
  12515. string packId = GetPostString("packId");
  12516. if (string.IsNullOrEmpty(packId))
  12517. {
  12518. returnErrorMsg("缺少必要的参数");
  12519. return;
  12520. }
  12521. StringBuilder sql = new StringBuilder();
  12522. 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);
  12523. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12524. if (dt == null || dt.Rows.Count == 0)
  12525. {
  12526. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12527. return;
  12528. }
  12529. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12530. return;
  12531. }
  12532. public void get_supplier_product_time_list()
  12533. {
  12534. DataStruct dStruct = GetPostStruct();
  12535. List<string> lw = new List<string>();
  12536. string supplier = GetPostString("supplier");
  12537. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12538. string posTag = CurrentUser.UserPost.Post.Code;
  12539. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12540. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12541. writeGridDataTableJson(dStruct.TotalCount, dt);
  12542. }
  12543. public void saveSupplierProductTime()
  12544. {
  12545. string productId = GetPostString("productId");
  12546. if (string.IsNullOrEmpty(productId))
  12547. {
  12548. returnErrorMsg("缺少必要的参数");
  12549. return;
  12550. }
  12551. string productName = GetPostString("productName");
  12552. int supplierId = GetPostInt("supplierId");
  12553. if (supplierId == 0)
  12554. {
  12555. returnErrorMsg("缺少必要的参数");
  12556. return;
  12557. }
  12558. int quantity = GetPostInt("quantity");
  12559. int sendDay = GetPostInt("sendTime");
  12560. string supplierName = GetPostString("supplierName");
  12561. string craft = GetPostString("craft");
  12562. string deadLine = GetPostString("deadLine");
  12563. string dayDeadLine = GetPostString("dayDeadLine");
  12564. try
  12565. {
  12566. int eid = GetPostInt("eid");
  12567. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12568. if (ceErpSupplierProductTime == null)
  12569. {
  12570. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12571. }
  12572. ceErpSupplierProductTime.productId = productId;
  12573. ceErpSupplierProductTime.productName = productName;
  12574. ceErpSupplierProductTime.supplierId = supplierId;
  12575. ceErpSupplierProductTime.supplierName = supplierName;
  12576. ceErpSupplierProductTime.craft = craft;
  12577. ceErpSupplierProductTime.sendDay = sendDay;
  12578. ceErpSupplierProductTime.quantity = quantity;
  12579. if (!string.IsNullOrEmpty(deadLine))
  12580. {
  12581. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12582. }
  12583. if (!string.IsNullOrEmpty(dayDeadLine))
  12584. {
  12585. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12586. }
  12587. if (ceErpSupplierProductTime.ID == 0)
  12588. {
  12589. ceErpSupplierProductTime.Save();
  12590. }
  12591. else
  12592. {
  12593. ceErpSupplierProductTime.Update();
  12594. }
  12595. }
  12596. catch (Exception e)
  12597. {
  12598. }
  12599. returnSuccessMsg("保存成功");
  12600. return;
  12601. }
  12602. public void delSupplierProductTime()
  12603. {
  12604. int eid = GetPostInt("eid");
  12605. if (eid > 0)
  12606. {
  12607. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12608. if (ceErpSupplierProductTime == null)
  12609. {
  12610. returnErrorMsg("查无数据");
  12611. return;
  12612. }
  12613. ceErpSupplierProductTime.Delete();
  12614. returnSuccessMsg("保存成功");
  12615. return;
  12616. }
  12617. returnErrorMsg("缺少必要的参数");
  12618. }
  12619. public void getExpressInfo()
  12620. {
  12621. string ctid = GetPostString("ctid");
  12622. if (!string.IsNullOrEmpty(ctid))
  12623. {
  12624. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12625. if (ceErpTradeCell != null)
  12626. {
  12627. string outSid = ceErpTradeCell.OutSid;
  12628. if (outSid.Length > 0)
  12629. {
  12630. 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);
  12631. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12632. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12633. return;
  12634. }
  12635. }
  12636. returnErrorMsg("查无记录");
  12637. return;
  12638. }
  12639. returnErrorMsg("缺少必要的参数");
  12640. }
  12641. public void getExpressPostData()
  12642. {
  12643. string express = GetPostString("express");
  12644. if (!string.IsNullOrEmpty(express))
  12645. {
  12646. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12647. if (ceErpExpressInfo != null)
  12648. {
  12649. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12650. return;
  12651. }
  12652. }
  12653. returnErrorMsg("缺少必要的参数");
  12654. }
  12655. public void checkSupplierOrder()
  12656. {
  12657. string ctids = GetPostString("ctids");
  12658. if (ctids != null)
  12659. {
  12660. List<string> list = new List<string>();
  12661. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12662. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12663. for (int i = 0; i < dt.Rows.Count; i++)
  12664. {
  12665. DataRow row = dt.Rows[i];
  12666. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12667. {
  12668. continue;
  12669. }
  12670. list.Add(row["seller_memo"].ToString());
  12671. }
  12672. if (list.Count > 0)
  12673. {
  12674. 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, "点击下载按钮"));
  12675. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12676. return;
  12677. }
  12678. }
  12679. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12680. return;
  12681. }
  12682. public void addPersonId()
  12683. {
  12684. string tid = GetPostString("tid");
  12685. string personId = GetPostString("personId");
  12686. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12687. if (ceErpTrade != null)
  12688. {
  12689. ceErpTrade.receiver_zip = personId;
  12690. ceErpTrade.Update();
  12691. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12692. returnSuccessMsg("保存成功");
  12693. return;
  12694. }
  12695. returnErrorMsg("缺少必要的参数");
  12696. }
  12697. public void addDeliveryPaymant()
  12698. {
  12699. string tid = GetPostString("tid");
  12700. string paymant = GetPostString("paymant");
  12701. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12702. if (ceErpTrade != null)
  12703. {
  12704. if (!string.IsNullOrEmpty(paymant))
  12705. {
  12706. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12707. }
  12708. ceErpTrade.Update();
  12709. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12710. returnSuccessMsg("保存成功");
  12711. return;
  12712. }
  12713. returnErrorMsg("缺少必要的参数");
  12714. }
  12715. public void saveCellFile()
  12716. {
  12717. string tid = GetPostString("tid");
  12718. string ctid = GetPostString("ctid");
  12719. string urls = GetPostString("urls");
  12720. string type = GetPostString("type");
  12721. string del = GetPostString("del");
  12722. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12723. {
  12724. if ("1".Equals(del))
  12725. {
  12726. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12727. }
  12728. string[] list = urls.Split(',');
  12729. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12730. {
  12731. foreach (string item in list)
  12732. {
  12733. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12734. ceErpTradeCellFile.Create();
  12735. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12736. }
  12737. }
  12738. returnSuccessMsg("保存成功");
  12739. return;
  12740. }
  12741. returnErrorMsg("缺少必要的参数");
  12742. }
  12743. public void getCellFile()
  12744. {
  12745. string tid = GetPostString("tid");
  12746. string ctid = GetPostString("ctid");
  12747. string type = GetPostString("type");
  12748. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12749. {
  12750. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12751. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12752. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12753. return;
  12754. }
  12755. returnErrorMsg("缺少必要的参数");
  12756. }
  12757. public void delCellFile()
  12758. {
  12759. string id = GetPostString("id");
  12760. if (string.IsNullOrEmpty(id))
  12761. {
  12762. returnErrorMsg("缺少必要的参数");
  12763. return;
  12764. }
  12765. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12766. CeErpTradeCellFile.delByID(id);
  12767. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12768. returnSuccessMsg("保存成功");
  12769. }
  12770. }
  12771. }