sync.order.cs 629 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591
  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. namespace SiteCore.Handler
  48. {
  49. public partial class sync
  50. {
  51. public void get_erp_orderlist()
  52. {
  53. string poscode = CurrentUser.UserPost.Post.Code;
  54. DataStruct dStruct = GetPostStruct();
  55. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\CE_ErpProduct(2).xlsx");
  56. //apiHelper.Api_SyncOrderByTime("598825");
  57. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  58. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  59. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  60. //banniuApiHelper.sendLogisticsInfo(null);
  61. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  62. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  63. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  64. //int sid = commonHelper.autoDistributeToSupplier(entity);
  65. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  66. //tmcHelper.Api_TmcTradeMsg("{\r\n \"content\": {\r\n \"businessType\": \"GUARANTEE\",\r\n \"buyerMemo\": \"\",\r\n \"consolidateType\": \"\",\r\n \"createTime\": 1744882656361,\r\n \"deliveryType\": \"OFFLINE\",\r\n \"discountFee\": 0.0,\r\n \"flag\": \"NONE\",\r\n \"latestDeliveryTime\": 1744882656361,\r\n \"lines\": [\r\n {\r\n \"mark2\": [],\r\n \"num\": 4,\r\n \"outerId\": \"\",\r\n \"payment\": 60.0,\r\n \"picUrl\": \"https://img.alicdn.com/bao/uploaded/i4/2209226402185/O1CN011Zh53V1S0mQKgHJyF_!!4611686018427382153-0-item_pic.jpg\",\r\n \"platServiceFee\": 0.0,\r\n \"price\": 10.0,\r\n \"refOlId\": \"1111122222333338942\",\r\n \"refSkuId\": \"0\",\r\n \"refSpuId\": \"908453435193\",\r\n \"refundStatus\": \"NO_REFUND\",\r\n \"sellPrice\": 10.0,\r\n \"singleFee\": 10.0,\r\n \"standards\": \"测试内部\",\r\n \"status\": \"NOT_SHIPPED\",\r\n \"title\": \"【老客户订单2】测试老客户订单内部\",\r\n \"totalFee\": 60.0,\r\n \"totalPrice\": 60.0,\r\n \"totalSellPrice\": 60.0\r\n }\r\n ],\r\n \"logisticsOrderNo\": \"\",\r\n \"mark2\": [],\r\n \"modifyTime\": 1744882656361,\r\n \"openBuyerId\": \"AAG1RHraABkUZRPgSx3g7Eam\",\r\n \"openBuyerNick\": \"0**\",\r\n \"openSellerNick\": \"海角七旗舰店\",\r\n \"orderSource\": \"SYNC\",\r\n \"orderTime\": 1744882656361,\r\n \"payTime\": 1744882656361,\r\n \"payment\": 100.0,\r\n \"platServiceFee\": 0.0,\r\n \"posCode\": \"HJQ\",\r\n \"posId\": 663281,\r\n \"postFee\": 0.0,\r\n \"props\": {\r\n \"payType\": \"ALI_PAY\",\r\n \"govSubsidyAmount\": 0\r\n },\r\n \"receivedPayment\": 0.0,\r\n \"receiverCity\": \"龙岩市\",\r\n \"receiverCountry\": \"中国\",\r\n \"receiverDistrict\": \"新罗区\",\r\n \"receiverId\": \"d1b65912ef886228ac4ada4b65055e52$\",\r\n \"receiverState\": \"福建省\",\r\n \"receiverTown\": \"西陂街道\",\r\n \"refOid\": \"1111122222333338942\",\r\n \"refType\": \"TB\",\r\n \"refundStatus\": \"NO_REFUND\",\r\n \"sellerMemo\": \"\",\r\n \"serviceFee\": 0.0,\r\n \"status\": \"NOT_SHIPPED\",\r\n \"totalFee\": 100.0,\r\n \"totalPrice\": 100.0,\r\n \"totalSellPrice\": 100.0,\r\n \"type\": \"SALE\"\r\n }\r\n}");
  67. //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}}");
  68. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  69. List<string> lw = new List<string>();
  70. string tid = GetPostString("ctid");
  71. string date1 = GetPostString("date1");
  72. //12-1 修改
  73. string urgent = GetPostString("urgent");
  74. string back = GetPostString("back");
  75. string offlineSearch = GetPostString("offlineSearch");
  76. int paramsCount = 0;
  77. if (!string.IsNullOrWhiteSpace(urgent))
  78. {
  79. if (urgent.Equals("true"))
  80. {
  81. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  82. }
  83. }
  84. if (!string.IsNullOrWhiteSpace(back))
  85. {
  86. if (back.Equals("true"))
  87. {
  88. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  89. }
  90. }
  91. if (!string.IsNullOrWhiteSpace(offlineSearch))
  92. {
  93. if (offlineSearch.Equals("true"))
  94. {
  95. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  96. }
  97. }
  98. //end
  99. string date2 = GetPostString("date2");
  100. string buyernick = GetPostString("buyer_nick");
  101. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  102. {
  103. if (tid.Length <= 0 && buyernick.Length <= 0)
  104. {
  105. return;
  106. }
  107. }
  108. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  109. {
  110. if (tid.Length > 0)
  111. {
  112. string select_tid = getTidByCtid(tid);
  113. lw.Add(string.Format("tid='{0}'", select_tid));
  114. }
  115. if (buyernick.Length > 0)
  116. {
  117. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  118. }
  119. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  120. if (dw.Length > 0)
  121. {
  122. lw.Add(dw);
  123. }
  124. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  125. {
  126. string usershop = CurrentUser.User.pemShop;
  127. lw.Add(string.Format("ShopId in ({0})", usershop));
  128. }
  129. }
  130. else
  131. {
  132. if (ex_psize == 0)
  133. {
  134. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  135. }
  136. if (PKey != "admin")
  137. {
  138. string usershop = CurrentUser.User.pemShop;
  139. lw.Add(string.Format("ShopId in ({0})", usershop));
  140. paramsCount++;
  141. }
  142. }
  143. string uploaddate1 = GetPostString("uploaddate1");
  144. string uploaddate2 = GetPostString("uploaddate2");
  145. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  146. if (update.Length > 0) lw.Add(update);
  147. string deliverydate1 = GetPostString("deliverydate1");
  148. string deliverydate2 = GetPostString("deliverydate2");
  149. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  150. if (deliverydate.Length > 0)
  151. {
  152. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  153. };
  154. string shopname = GetPostString("shopname");
  155. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  156. string addwechat = GetPostString("addwechat");
  157. if (addwechat.Length > 0)
  158. {
  159. int addWt = Convert.ToInt32(addwechat);
  160. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  161. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  162. }
  163. string customer = GetPostString("customer");
  164. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  165. string design = GetPostString("design");
  166. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  167. string orderState = GetPostString("orderState");
  168. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  169. string address = GetPostString("address");
  170. 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));
  171. string sellermemo = GetPostString("seller_memo");
  172. if (sellermemo.Length > 0)
  173. {
  174. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  175. }
  176. string backReason = GetPostString("backReason");
  177. if (backReason.Length > 0)
  178. {
  179. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  180. }
  181. string apdate1 = GetPostString("apdate1");
  182. string apdate2 = GetPostString("apdate2");
  183. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  184. if (dwap.Length > 0) lw.Add(dwap);
  185. string price1 = GetPostString("price1");
  186. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  187. string price2 = GetPostString("price2");
  188. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  189. string isoldcustomer = GetPostString("isoldcus");
  190. string spudata = GetPostString("spudata");
  191. if ("0".Equals(spudata))
  192. {
  193. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  194. }
  195. if ("1".Equals(spudata))
  196. {
  197. lw.Add(string.Format("spu_id <> ''"));
  198. }
  199. string finishdate1 = GetPostString("finishdate1");
  200. string finishdate2 = GetPostString("finishdate2");
  201. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  202. bool isFinish = false;
  203. if (finishdate.Length > 0)
  204. {
  205. lw.Add(finishdate);
  206. isFinish = true;
  207. paramsCount++;
  208. }
  209. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  210. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  211. if (ex_psize > 0)
  212. {
  213. int UserID = CurrentUser.UserID;
  214. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  215. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  216. {
  217. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  218. }
  219. dStruct.Order = "pay_time desc";
  220. }
  221. string isNew = GetPostString("isNew");
  222. if (isNew == "true")
  223. {
  224. lw.Add(string.Format("IsNew = {0}", 1));
  225. }
  226. string overtime = GetPostString("overtime");
  227. if (overtime == "1")
  228. {
  229. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  230. }
  231. String usePost = CurrentUser.UserPost.Post.Code;
  232. if (usePost.Equals("Operation") == true)
  233. {
  234. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  235. }
  236. else
  237. {
  238. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  239. }
  240. //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";
  241. if (dStruct.PageSize == 100000)
  242. {
  243. dStruct.Order = "";
  244. }
  245. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  246. DataTable dt = null;
  247. string tablename = "view_orderlist";
  248. if (isFinish)
  249. {
  250. tablename = "view_orderlist_end";
  251. }
  252. dt = WebCache.GetData(tablename, dStruct);
  253. if (dt != null && dt.Rows.Count > 0)
  254. {
  255. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  256. foreach (DataRow dr in dt.Rows)
  257. {
  258. try
  259. {
  260. if (dr["refund_fees"] != null)
  261. {
  262. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  263. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  264. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  265. if (payment == refund_fees)
  266. {
  267. dr["refund_fees"] = Math.Round(refund_fees, 2);
  268. }
  269. else if (refund_fees == total_fee)
  270. {
  271. dr["refund_fees"] = payment;
  272. }
  273. else
  274. {
  275. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  276. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  277. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  278. }
  279. }
  280. // 对象操作
  281. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  282. ceErpTradeCell.ctid = dr["ctid"].ToString();
  283. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  284. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  285. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  286. if (dStruct.PageSize != 100000)
  287. {
  288. if (dr["DispatchSort"].ToString() == "2")
  289. {
  290. dr["gongchuang"] = 200;
  291. }
  292. else if ("外协".Equals(dr["ToType"].ToString()))
  293. {
  294. dr["gongchuang"] = 200;
  295. }
  296. else if ("内部".Equals(dr["ToType"].ToString()))
  297. {
  298. dr["gongchuang"] = -1;
  299. }
  300. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  301. {
  302. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  303. dr["gongchuang"] = response.code;
  304. }
  305. }
  306. }
  307. catch (NullReferenceException ex)
  308. {
  309. // 处理空引用异常
  310. dr["refund_fees"] = "0.00";
  311. }
  312. }
  313. }
  314. writeGridDataTableJson(dStruct.TotalCount, dt);
  315. }
  316. public void get_erp_orderlist_sumprice()
  317. {
  318. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  319. return;
  320. List<string> lw = new List<string>();
  321. string tid = GetPostString("ctid");
  322. string date1 = GetPostString("date1");
  323. string date2 = GetPostString("date2");
  324. if (tid.Length > 0 || date1.Length > 0)
  325. {
  326. lw.Add(string.Format("ctid like '%{0}%'", tid));
  327. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  328. if (dw.Length > 0) lw.Add(dw);
  329. }
  330. else
  331. {
  332. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  333. }
  334. string shopname = GetPostString("shopname");
  335. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  336. string buyernick = GetPostString("buyer_nick");
  337. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  338. string customer = GetPostString("customer");
  339. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  340. string design = GetPostString("design");
  341. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  342. string orderState = GetPostString("orderState");
  343. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  344. string address = GetPostString("address");
  345. 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));
  346. string sellermemo = GetPostString("seller_memo");
  347. if (sellermemo.Length > 0)
  348. {
  349. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  350. }
  351. string apdate1 = GetPostString("apdate1");
  352. string apdate2 = GetPostString("apdate2");
  353. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  354. if (dwap.Length > 0) lw.Add(dwap);
  355. string price1 = GetPostString("price1");
  356. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  357. string price2 = GetPostString("price2");
  358. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  359. string isoldcustomer = GetPostString("isoldcus");
  360. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  361. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  362. if (PKey != "admin")
  363. {
  364. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  365. lw.Add(string.Format("shopId in ({0})", usershop));
  366. }
  367. //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";
  368. string mainWhere = string.Join(" and ", lw.ToArray());
  369. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  370. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  371. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  372. decimal total = 0;
  373. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  374. {
  375. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  376. }
  377. var res = new
  378. {
  379. data = total
  380. };
  381. string ro_jsond = JsonConvert.SerializeObject(res);
  382. returnSuccess(ro_jsond);
  383. return;
  384. }
  385. public void get_erp_CustomerServiceGather()
  386. {
  387. string userWhere = "", orderWhere = "";
  388. List<string> lw = new List<string>();
  389. string customer = GetPostString("customer");
  390. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  391. string shopname = GetPostString("shopname");
  392. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  393. string date1 = GetPostString("date1");
  394. string date2 = GetPostString("date2");
  395. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  396. if (dw.Length > 0) lw.Add(dw);
  397. orderWhere = string.Join(" and ", lw.ToArray());
  398. 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 " +
  399. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  400. "left join " +
  401. "( " +
  402. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  403. ") as b on a.ID = b.CustomerUserId " +
  404. "left join " +
  405. "( " +
  406. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  407. ") as d on a.ID = d.CustomerUserId " +
  408. "left join " +
  409. "( " +
  410. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  411. ") as e on a.ID = e.CustomerUserId " +
  412. "left join " +
  413. "( " +
  414. " select CustomerUserId, RefundCount, RefundSum from " +
  415. " ( " +
  416. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  417. " from CE_ErpTradeRefund a " +
  418. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  419. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  420. " group by CustomerUserId " +
  421. " ) as a " +
  422. ") as f on a.ID = f.CustomerUserId " +
  423. "where a.PostCode = 'CustomerService'",
  424. userWhere, orderWhere);
  425. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  426. writeGridDataTableJson(dt.Rows.Count, dt);
  427. //writeGridDataTableJson(dt.Rows.Count, dt);
  428. }
  429. //设计汇总
  430. public void get_erp_DesignerGather()
  431. {
  432. string userWhere = "", orderWhere = "";
  433. List<string> lw = new List<string>();
  434. string Designer = GetPostString("designer");
  435. int org = GetPostInt("org");
  436. if (Designer.Length > 0)
  437. {
  438. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  439. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  440. }
  441. else if (org > 0)
  442. {
  443. userWhere = string.Format(" where OrgID ={0}", org);
  444. }
  445. string shopname = GetPostString("shopname");
  446. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  447. string state = GetPostString("state");
  448. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  449. string OrderArea = GetPostString("order_area");
  450. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  451. string date1 = GetPostString("date1");
  452. string date2 = GetPostString("date2");
  453. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  454. if (dw.Length > 0) lw.Add(dw);
  455. string UpDate1 = GetPostString("UpDate1");
  456. string UpDate2 = GetPostString("UpDate2");
  457. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  458. if (dw.Length > 0) lw.Add(dw);
  459. orderWhere = string.Join(" and ", lw.ToArray());
  460. 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 (" +
  461. "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 " +
  462. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  463. "left join " +
  464. "( " +
  465. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  466. ") as b on a.ID = b.DesignUserId " +
  467. "left join " +
  468. "( " +
  469. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  470. ") as d on a.ID = d.DesignUserId " +
  471. "left join " +
  472. "( " +
  473. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  474. ") as e on a.ID = e.DesignUserId " +
  475. "left join " +
  476. "( " +
  477. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  478. ") as g on a.ID = g.DesignUserId " +
  479. "left join " +
  480. "( " +
  481. " select CustomerUserId, RefundCount, RefundSum from " +
  482. " ( " +
  483. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  484. " from CE_ErpTradeRefund a " +
  485. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  486. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  487. " group by CustomerUserId " +
  488. " ) as a " +
  489. ") as f on a.ID = f.CustomerUserId " +
  490. "where a.PostCode = 'Designer') as z",
  491. userWhere, orderWhere);
  492. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  493. writeGridDataTableJson(dt.Rows.Count, dt);
  494. }
  495. //删除tradecell的订单
  496. public void del_erp_cellorder()
  497. {
  498. if (UrlPostParmsCheck("ctid"))
  499. {
  500. string eid = GetPostString("ctid");
  501. CeErpTradeCell.DelByCtid(eid);
  502. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  503. returnSuccessMsg("删除成功");
  504. }
  505. }
  506. public void clear_erp_refundstate()
  507. {
  508. if (UrlPostParmsCheck("ids"))
  509. {
  510. string eids = GetPostString("ids");
  511. string[] ctidList = eids.Split(',');
  512. foreach (string ctid in ctidList)
  513. {
  514. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  515. if (entity != null)
  516. {
  517. entity.IsRefund = 0;
  518. entity.Update();
  519. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  520. }
  521. else
  522. continue;
  523. }
  524. returnSuccessMsg("操作成功");
  525. return;
  526. }
  527. returnErrorMsg("缺少必要参数");
  528. }
  529. public void set_erp_urgency()
  530. {
  531. if (UrlPostParmsCheck("ctid"))
  532. {
  533. string eid = GetPostString("ctid");
  534. CeErpTradeCell entity = null;
  535. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  536. if (entity != null)
  537. {
  538. string utime = GetPostString("urgencytime");
  539. if (utime.Length > 0)
  540. {
  541. entity.UrgencyTime = Convert.ToDateTime(utime);
  542. }
  543. else
  544. {
  545. returnErrorMsg("请选择加急时间");
  546. return;
  547. }
  548. if (entity.OrderState <= 4)
  549. {
  550. //entity.seller_memo = entity.seller_memo + "-加急";
  551. string smemo = entity.seller_memo;
  552. int kindex = smemo.IndexOf(")");
  553. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  554. if (lastoneStr != "-")
  555. {
  556. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  557. }
  558. string prememo = smemo.Substring(0, kindex + 2);
  559. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  560. int lastkindex = lastmemo.IndexOf("(");
  561. DateTime urgtime = Convert.ToDateTime(utime);
  562. string newlastmemo = "";
  563. if (lastkindex == 0)
  564. {
  565. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  566. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  567. }
  568. else
  569. {
  570. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  571. }
  572. entity.seller_memo = prememo + newlastmemo;
  573. }
  574. entity.IsUrgency = true;
  575. entity.UpdateTime = DateTime.Now;
  576. entity.Update();
  577. ApiVo apiVo = new ApiVo();
  578. apiVo.orderNumber = entity.ctid;
  579. apiVo.actionName = "changeDesign";
  580. apiVo.orderRemarks = entity.seller_memo;
  581. apiVo.remarkSign = 3;
  582. designHelper.API_WorkCore(apiVo); //changeDesign
  583. CeErpSukuraData.createInfo(entity.ctid, 7);
  584. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  585. returnSuccessMsg("设置成功!");
  586. return;
  587. }
  588. returnErrorMsg("找不到记录");
  589. }
  590. }
  591. public void set_erp_reset()
  592. {
  593. if (UrlPostParmsCheck("ctid"))
  594. {
  595. string eid = GetPostString("ctid");
  596. CeErpTradeCell entity = null;
  597. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  598. if (entity != null)
  599. {
  600. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  601. {
  602. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  603. {
  604. returnErrorMsg("财务要求已下单已发货无法重置");
  605. return;
  606. }
  607. }
  608. entity.IsUrgency = false;
  609. entity.seller_memo = "";
  610. entity.OtherMemo = "";
  611. entity.OrderState = 0;
  612. entity.IsReturn = 0;
  613. //entity.IsRefund = 0;
  614. entity.MemoOpt = 0;
  615. entity.AfterSaleState = 0;
  616. entity.AfterSaleResponsible = "";
  617. entity.AfterSaleUserId = 0;
  618. entity.IsNeedBill = 0;
  619. entity.CustomerUserId = 0;
  620. entity.DesignUserId = 0;
  621. entity.SupplierId = 0;
  622. entity.PlaceUserId = 0;
  623. entity.ptid = "";
  624. entity.IsSample = 0;
  625. entity.IsXianHuo = 0;
  626. entity.isDianziOrder = 0;
  627. entity.DispatchSort = 0;
  628. entity.FinishPlaceTime = null;
  629. entity.Update();
  630. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  631. if (trade != null)
  632. {
  633. trade.seller_memo = "";
  634. trade.Update();
  635. }
  636. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  637. returnSuccessMsg("重置成功!");
  638. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  639. if (desginBill != null)
  640. {
  641. desginBill.isDel = 1;
  642. desginBill.Update();
  643. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  644. }
  645. ApiVo apiVo = new ApiVo();
  646. apiVo.orderNumber = entity.ctid;
  647. apiVo.actionName = "resetDesign";
  648. designHelper.API_WorkCore(apiVo);//resetDesign
  649. return;
  650. }
  651. returnErrorMsg("找不到记录");
  652. }
  653. }
  654. public void save_erp_sellermemo()
  655. {
  656. if (UrlPostParmsCheck("ctid"))
  657. {
  658. string ctid = GetPostString("ctid");
  659. CeErpTradeCell entity = null;
  660. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  661. if (entity != null)
  662. {
  663. string memo = GetPostString("seller_memo");
  664. memo = memo.Replace(" ", "");
  665. if (memo.Contains("补差"))
  666. {
  667. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  668. return;
  669. }
  670. List<string> bitList = new List<string>
  671. {
  672. "\\","/",":","*","?", "\"","<" ,">","|"
  673. };
  674. bool isIn = false;
  675. foreach (string bit in bitList)
  676. {
  677. if (memo.Contains(bit))
  678. {
  679. isIn = true;
  680. }
  681. }
  682. if (isIn)
  683. {
  684. returnErrorMsg("不能使用 一些符合作为文件名");
  685. return;
  686. }
  687. if (entity.seller_memo != memo)
  688. {
  689. if (entity.IsSample == 2)
  690. {
  691. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  692. return;
  693. }
  694. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  695. {
  696. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  697. {
  698. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  699. return;
  700. }
  701. }
  702. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  703. }
  704. commonHelper.getCytPrice(entity);
  705. int memoopt = GetPostInt("MemoOpt");
  706. Boolean ismemoopt = false;
  707. if (memoopt > 0)
  708. {
  709. string stropt = "";
  710. if (memoopt == 1)
  711. {
  712. stropt = "“改稿”";
  713. ismemoopt = true;
  714. }
  715. else if (memoopt == 2)
  716. {
  717. stropt = "“定稿”";
  718. }
  719. else if (memoopt == 3)
  720. {
  721. stropt = "“查货”";
  722. CeErpSukuraData.createInfo(entity.ctid, 6);
  723. }
  724. entity.MemoOpt = Convert.ToInt32(memoopt);
  725. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  726. }
  727. if (entity.OrderState < 5)
  728. {
  729. memo = memo.Replace("(", "(");
  730. memo = memo.Replace(")", ")");
  731. }
  732. if (entity.OrderState < 3)
  733. {
  734. entity.DispatchSort = 0;
  735. }
  736. entity.seller_memo = memo;
  737. entity.UpdateTime = DateTime.Now;
  738. entity.Update();
  739. ApiVo apiVo = new ApiVo();
  740. apiVo.orderNumber = entity.ctid;
  741. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  742. apiVo.orderRemarks = memo;
  743. apiVo.remarkSign = memoopt;
  744. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  745. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  746. returnSuccessMsg("保存成功!");
  747. return;
  748. }
  749. returnErrorMsg("找不到记录");
  750. }
  751. }
  752. public void ins_erp_checkorder()
  753. {
  754. if (UrlPostParmsCheck("ctid"))
  755. {
  756. string ctid = GetPostString("ctid");
  757. CeErpTradeCell entity = null;
  758. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  759. if (entity != null)
  760. {
  761. if (entity.OrderState < 6)
  762. {
  763. returnErrorMsg("下单完成后才可查货");
  764. return;
  765. }
  766. /*if (entity.OrderState > 6)
  767. {
  768. returnErrorMsg("订单已发货");
  769. return;
  770. }*/
  771. if (entity.FinishPlaceTime != null)
  772. {
  773. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  774. {
  775. returnErrorMsg("下单时间不足,无法查货");
  776. return;
  777. }
  778. }
  779. entity.MemoOpt = 3;
  780. entity.CheckOrderTime = DateTime.Now;
  781. entity.UpdateTime = DateTime.Now;
  782. entity.Update();
  783. CeErpSukuraData.createInfo(entity.ctid, 6);
  784. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  785. returnSuccessMsg("操作成功!");
  786. return;
  787. }
  788. returnErrorMsg("找不到记录");
  789. }
  790. }
  791. public void save_erp_othermemo()
  792. {
  793. if (UrlPostParmsCheck("ctid"))
  794. {
  795. string ctid = GetPostString("ctid");
  796. CeErpTradeCell entity = null;
  797. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  798. if (entity != null)
  799. {
  800. entity.OtherMemo = GetPostString("otherMemo");
  801. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  802. {
  803. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  804. StringBuilder sql = new StringBuilder();
  805. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  806. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  807. if (dt != null && dt.Rows.Count > 0)
  808. {
  809. foreach (DataRow dr in dt.Rows)
  810. {
  811. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  812. {
  813. //品类一直
  814. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  815. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  816. if (ceErpSampleCustomer == null)
  817. {
  818. ceErpSampleCustomer = new CeErpSampleCustomer();
  819. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  820. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  821. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  822. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  823. ceErpSampleCustomer.shopId = entity.ShopId;
  824. }
  825. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  826. ceErpSampleCustomer.lastTid = entity.tid;
  827. if (ceErpSampleCustomer.ID > 0)
  828. {
  829. ceErpSampleCustomer.Update();
  830. }
  831. else
  832. {
  833. ceErpSampleCustomer.Create();
  834. }
  835. }
  836. }
  837. }
  838. }
  839. //if (entity.IsOldCustomer == 1)
  840. //{
  841. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  842. //{
  843. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  844. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  845. //}
  846. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  847. //{
  848. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  849. // {
  850. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  851. // {
  852. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  853. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  854. // }
  855. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  856. // {
  857. // entity.OrderState = 2;
  858. // entity.DesignUserId = 0;
  859. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  860. // }
  861. // else
  862. // {
  863. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  864. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  865. // }
  866. // }
  867. //}
  868. //}
  869. entity.UpdateTime = DateTime.Now;
  870. entity.Update();
  871. returnSuccessMsg("保存成功!");
  872. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  873. return;
  874. }
  875. returnErrorMsg("找不到记录");
  876. }
  877. }
  878. public void save_erp_customermemo()
  879. {
  880. if (UrlPostParmsCheck("ctid"))
  881. {
  882. string ctid = GetPostString("ctid");
  883. CeErpTradeCell entity = null;
  884. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  885. if (entity != null)
  886. {
  887. entity.UpdateTime = DateTime.Now;
  888. entity.CustomerMemo = GetPostString("CustomerMemo");
  889. entity.Update();
  890. ApiVo apiVo = new ApiVo();
  891. apiVo.orderNumber = entity.ctid;
  892. apiVo.actionName = "followRemarks";
  893. apiVo.orderRemarks = entity.CustomerMemo;
  894. designHelper.API_WorkCore(apiVo);//followRemarks
  895. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  896. returnSuccessMsg("保存成功!");
  897. return;
  898. }
  899. returnErrorMsg("找不到记录");
  900. }
  901. }
  902. public void upd_erp_addmemotag()
  903. {
  904. if (UrlPostParmsCheck("ctid"))
  905. {
  906. ;
  907. string eid = GetPostString("ctid");
  908. string sfTagstr = GetPostString("memotag");
  909. CeErpTradeCell entity = null;
  910. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  911. if (entity != null)
  912. {
  913. ApiVo apiVo = new ApiVo();
  914. if (entity.OrderState == 0)
  915. {
  916. returnErrorMsg("请先领单");
  917. return;
  918. }
  919. //撤销顺丰
  920. if (sfTagstr == "撤销顺丰")
  921. {
  922. entity.IsSF = 0;
  923. string reMsg = "";
  924. string oldmemo = entity.seller_memo;
  925. if (entity.OrderState < 5)
  926. {
  927. oldmemo = oldmemo.Replace("顺丰到付", "");
  928. oldmemo = oldmemo.Replace("顺丰寄付", "");
  929. entity.seller_memo = oldmemo;
  930. }
  931. else
  932. {
  933. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  934. {
  935. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  936. }
  937. }
  938. entity.Update();
  939. apiVo.orderNumber = entity.ctid;
  940. apiVo.actionName = "orderRemarks";
  941. apiVo.orderRemarks = entity.seller_memo;
  942. apiVo.isSf = entity.IsSF.ToString();
  943. designHelper.API_WorkCore(apiVo);//orderRemarks
  944. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  945. returnSuccessMsg("撤销成功!" + reMsg);
  946. return;
  947. }
  948. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  949. {
  950. //string oldmemo = entity.seller_memo;
  951. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  952. string sfStr = GetPostString("memotag");
  953. string smemo = entity.seller_memo;
  954. int kindex = smemo.IndexOf(")");
  955. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  956. if (lastoneStr != "-")
  957. {
  958. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  959. }
  960. string prememo = smemo.Substring(0, kindex + 2);
  961. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  962. int lastkindex = lastmemo.IndexOf("(");
  963. string newlastmemo = "";
  964. if (lastkindex == 0)
  965. {
  966. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  967. newlastmemo = "(" + sfStr + "." + useLastmemo;
  968. }
  969. else
  970. {
  971. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  972. }
  973. entity.seller_memo = prememo + newlastmemo;
  974. }
  975. string sfTagMSg = "";
  976. if (sfTagstr == "顺丰寄付")
  977. {
  978. entity.IsSF = 1;
  979. sfTagMSg = "顺丰寄付";
  980. }
  981. else if (sfTagstr == "顺丰到付")
  982. {
  983. entity.IsSF = 2;
  984. sfTagMSg = "顺丰到付";
  985. }
  986. entity.Update();
  987. apiVo = new ApiVo();
  988. apiVo.orderNumber = entity.ctid;
  989. apiVo.actionName = "orderRemarks";
  990. apiVo.orderRemarks = entity.seller_memo;
  991. apiVo.isSf = entity.IsSF.ToString();
  992. designHelper.API_WorkCore(apiVo);//orderRemarks
  993. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  994. returnSuccessMsg("标记成功!");
  995. return;
  996. }
  997. returnErrorMsg("找不到记录");
  998. }
  999. }
  1000. public void upd_erp_ordertag()
  1001. {
  1002. if (UrlPostParmsCheck("ctid"))
  1003. {
  1004. string eid = GetPostString("ctid");
  1005. CeErpTradeCell entity = null;
  1006. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1007. if (entity != null)
  1008. {
  1009. int tag = GetPostInt("wechattag");
  1010. //if(tag==4 && entity.IsSample == 2)
  1011. //{
  1012. // returnErrorMsg("补差价单不能标记微信单");
  1013. // return;
  1014. //}
  1015. entity.wechatTag = tag;
  1016. entity.Update();
  1017. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1018. if (tag == 1)
  1019. {
  1020. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1021. if (cash == null)
  1022. {
  1023. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1024. cash = new CeErpReturnCash();
  1025. cash.tid = entity.tid;
  1026. cash.seller_nick = main.seller_nick;
  1027. cash.payment = trade.payment;
  1028. cash.buyer_nick = main.buyer_nick;
  1029. cash.cashstate = 0;
  1030. cash.rtype = "微信返现";
  1031. cash.returnprice = 0;
  1032. cash.created = DateTime.Now;
  1033. cash.con = "订单标记微信单";
  1034. cash.img = "";
  1035. cash.applyuserid = CurrentUser.UserID;
  1036. cash.Create();
  1037. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1038. }
  1039. else
  1040. {
  1041. cash.cashstate = 0;
  1042. cash.Update();
  1043. }
  1044. CeErpSukuraData.createInfo(entity.ctid, 9);
  1045. }
  1046. else if (tag == 2)
  1047. {
  1048. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1049. if (cash == null)
  1050. {
  1051. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1052. cash = new CeErpReturnCash();
  1053. cash.tid = entity.tid;
  1054. cash.seller_nick = main.seller_nick;
  1055. cash.payment = trade.payment;
  1056. cash.buyer_nick = main.buyer_nick;
  1057. cash.cashstate = 0;
  1058. cash.rtype = "推购返现";
  1059. cash.returnprice = 5;
  1060. cash.created = DateTime.Now;
  1061. cash.con = "订单标记推购单";
  1062. cash.img = "";
  1063. cash.applyuserid = CurrentUser.UserID;
  1064. cash.Create();
  1065. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1066. }
  1067. else
  1068. {
  1069. cash.cashstate = 0;
  1070. cash.Update();
  1071. }
  1072. CeErpSukuraData.createInfo(entity.ctid, 9);
  1073. }
  1074. else if (tag == 3)
  1075. {
  1076. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1077. if (pers == null)
  1078. {
  1079. pers = new CeErpPersuade();
  1080. pers.ctid = entity.ctid;
  1081. pers.pstate = 0;
  1082. pers.created = DateTime.Now;
  1083. pers.applyuserid = CurrentUser.UserID;
  1084. pers.Create();
  1085. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1086. }
  1087. else
  1088. {
  1089. pers.pstate = 0;
  1090. pers.Update();
  1091. }
  1092. }
  1093. else if (tag == 4 || tag == 5)
  1094. {
  1095. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1096. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1097. if (pers == null)
  1098. {
  1099. pers = new CeErpStayGoods();
  1100. pers.t_id = entity.tid;
  1101. pers.status = "待审核";
  1102. pers.audit_type = 0;
  1103. if (tag == 4)
  1104. {
  1105. pers.stay_type = "微信推购";
  1106. }
  1107. else
  1108. {
  1109. pers.stay_type = "旺旺推购";
  1110. }
  1111. if (entity.IsXianHuo == 0)
  1112. {
  1113. pers.product_id = entity.ProductId;
  1114. }
  1115. pers.wangwang = main.buyer_nick;
  1116. pers.shop_name = main.seller_nick;
  1117. pers.creata_time = DateTime.Now;
  1118. pers.create_u_id = CurrentUser.UserID;
  1119. pers.create_u_name = CurrentUser.UserName;
  1120. pers.Create();
  1121. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1122. }
  1123. else
  1124. {
  1125. pers.audit_type = 0;
  1126. pers.Update();
  1127. }
  1128. CeErpSukuraData.createInfo(entity.ctid, 10);
  1129. }
  1130. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1131. returnSuccessMsg("标记成功!");
  1132. return;
  1133. }
  1134. returnErrorMsg("找不到记录");
  1135. }
  1136. }
  1137. public void upd_erp_ordertag_cancel()
  1138. {
  1139. if (UrlPostParmsCheck("ctid"))
  1140. {
  1141. string eid = GetPostString("ctid");
  1142. CeErpTradeCell entity = null;
  1143. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1144. if (entity != null)
  1145. {
  1146. entity.wechatTag = 0;
  1147. entity.Update();
  1148. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1149. if (pers != null)
  1150. {
  1151. pers.status = "取消推购";
  1152. pers.audit_type = 3;
  1153. pers.Update();
  1154. }
  1155. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1156. returnSuccessMsg("标记成功!");
  1157. return;
  1158. }
  1159. returnErrorMsg("找不到记录");
  1160. }
  1161. }
  1162. public void upd_erp_addweichattag()
  1163. {
  1164. if (UrlPostParmsCheck("ctid"))
  1165. {
  1166. ;
  1167. string eid = GetPostString("ctid");
  1168. CeErpTradeCell entity = null;
  1169. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1170. if (entity != null)
  1171. {
  1172. if (entity.IsAddWechat > 0)
  1173. {
  1174. returnErrorMsg("此单已经标记过了");
  1175. return;
  1176. }
  1177. 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);
  1178. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1179. if (dt.Rows.Count > 0)
  1180. {
  1181. entity.IsAddWechat = 2;
  1182. }
  1183. else
  1184. {
  1185. entity.IsAddWechat = 1;
  1186. }
  1187. entity.Update();
  1188. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1189. returnSuccessMsg("标记成功!");
  1190. return;
  1191. }
  1192. returnErrorMsg("找不到记录");
  1193. }
  1194. }
  1195. public void upd_erp_getmyorder()
  1196. {
  1197. if (UrlPostParmsCheck("ctid"))
  1198. {
  1199. ;
  1200. string eid = GetPostString("ctid");
  1201. CeErpTradeCell entity = null;
  1202. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1203. if (entity != null)
  1204. {
  1205. if (entity.ctid.IndexOf("C") != -1)
  1206. {
  1207. StringBuilder sql = new StringBuilder();
  1208. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1209. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1210. if (dt.Rows.Count > 0)
  1211. {
  1212. decimal total = 0;
  1213. foreach (DataRow dr in dt.Rows)
  1214. {
  1215. total += Convert.ToDecimal(dr["payment"]);
  1216. }
  1217. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1218. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1219. {
  1220. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1221. return;
  1222. }
  1223. }
  1224. }
  1225. if (entity.OrderState == -1)
  1226. {
  1227. returnErrorMsg("待审核订单无法领取!");
  1228. return;
  1229. }
  1230. entity.CustomerUserId = CurrentUser.UserID;
  1231. if (entity.OrderState < 2)
  1232. {
  1233. entity.OrderState = 2;
  1234. if (entity.ShopId != 0)
  1235. {
  1236. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1237. }
  1238. }
  1239. entity.UpdateTime = DateTime.Now;
  1240. entity.Update();
  1241. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1242. returnSuccessMsg("领单成功!");
  1243. return;
  1244. }
  1245. returnErrorMsg("找不到记录");
  1246. }
  1247. }
  1248. public void getmyorder_from_init()
  1249. {
  1250. if (UrlPostParmsCheck("ctid"))
  1251. {
  1252. string eid = GetPostString("ctid");
  1253. CeErpTradeCell entity = null;
  1254. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1255. if (entity != null)
  1256. {
  1257. string sellerMemo = GetPostString("sellerMemo");
  1258. if (sellerMemo.Length > 0)
  1259. {
  1260. entity.seller_memo = sellerMemo;
  1261. }
  1262. string oterhMemo = GetPostString("otherMemo");
  1263. if (oterhMemo.Length > 0)
  1264. {
  1265. entity.OtherMemo = oterhMemo;
  1266. }
  1267. int urg = GetPostInt("urgency");
  1268. entity.IsUrgency = (urg == 1 ? true : false);
  1269. int wechat = GetPostInt("wechat");
  1270. int command = GetPostInt("command");
  1271. if (wechat == 1)
  1272. {
  1273. entity.wechatTag = 1;
  1274. }
  1275. if (command == 1)
  1276. {
  1277. entity.wechatTag = 2;
  1278. }
  1279. string pPro = GetPostString("pprofession");
  1280. if (pPro.Length > 0)
  1281. {
  1282. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1283. string spro = GetPostString("profession");
  1284. if (spro.Length > 0)
  1285. {
  1286. entity.ProfessionId = Convert.ToInt32(spro);
  1287. }
  1288. }
  1289. string proId = GetPostString("productId");
  1290. if (proId.Length > 0)
  1291. {
  1292. entity.ProductId = Convert.ToInt32(proId);
  1293. }
  1294. entity.Material = GetPostString("material");
  1295. entity.Craft = GetPostString("craft");
  1296. entity.CustomerUserId = CurrentUser.UserID;
  1297. if (entity.OrderState < 2)
  1298. {
  1299. entity.OrderState = 2;
  1300. if (entity.ShopId != 0)
  1301. {
  1302. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1303. }
  1304. }
  1305. entity.Update();
  1306. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1307. returnSuccessMsg("领单成功!");
  1308. return;
  1309. }
  1310. returnErrorMsg("找不到记录");
  1311. }
  1312. }
  1313. public void upd_erp_setrelationorder()
  1314. {
  1315. if (UrlPostParmsCheck("ctid"))
  1316. {
  1317. ;
  1318. string eid = GetPostString("ctid");
  1319. string ftid = GetPostString("ftid");
  1320. CeErpTradeCell entity = null;
  1321. CeErpTradeCell fentity = null;
  1322. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1323. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1324. if (fentity == null)
  1325. {
  1326. returnErrorMsg("找不到关联的主订单");
  1327. return;
  1328. }
  1329. if (entity != null)
  1330. {
  1331. if (entity.OrderState >= 5)
  1332. {
  1333. returnErrorMsg("本单已经设计完成无法关联");
  1334. return;
  1335. }
  1336. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1337. {
  1338. returnErrorMsg("线下单续审核后才能关联!");
  1339. return;
  1340. }
  1341. entity.ptid = ftid;
  1342. entity.OrderState = fentity.OrderState;
  1343. //entity.status = fentity.status;
  1344. entity.CustomerUserId = fentity.CustomerUserId;
  1345. entity.DesignUserId = fentity.DesignUserId;
  1346. entity.seller_memo = "补差价单:" + ftid;
  1347. entity.IsSample = 2;
  1348. entity.Update();
  1349. ApiVo apiVo = new ApiVo();
  1350. apiVo.orderNumber = ftid;
  1351. apiVo.payment = entity.payment;
  1352. apiVo.actionName = "repairDesign";
  1353. designHelper.API_WorkCore(apiVo);//repairDesign
  1354. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1355. returnSuccessMsg("关联成功!");
  1356. return;
  1357. }
  1358. else
  1359. returnErrorMsg("找不到记录");
  1360. }
  1361. }
  1362. public void download_erp_neworder()
  1363. {
  1364. string seller = GetPostString("seller_nick");
  1365. string tid = GetPostString("tid");
  1366. if (seller.Length <= 0 || tid.Length <= 0)
  1367. {
  1368. returnErrorMsg("数据错误");
  1369. }
  1370. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1371. //{
  1372. // returnErrorMsg("找不到店铺Sessionkey");
  1373. //}
  1374. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1375. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1376. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1377. if (res.IndexOf("refOid") == -1)
  1378. {
  1379. returnErrorMsg("下载订单数据失败");
  1380. return;
  1381. }
  1382. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1383. returnSuccessMsg("下载完成");
  1384. //tmcHelper.createNewOrder(res);
  1385. //CeErpTrade entr = null;
  1386. //entr = CeErpTrade.Get(tid);
  1387. //if (entr != null)
  1388. //{
  1389. // returnSuccess("下载成功");
  1390. // //下载成功之后,Cell表生成对应的订单;
  1391. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1392. //}
  1393. //else
  1394. //{
  1395. // returnErrorMsg("下载失败或者创建订单失败");
  1396. //}
  1397. }
  1398. public void set_erp_atersale()
  1399. {
  1400. if (UrlPostParmsCheck("ctid"))
  1401. {
  1402. string eid = GetPostString("ctid");
  1403. string reason = GetPostString("AfterSaleReason");
  1404. CeErpTradeCell entity = null;
  1405. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1406. if (entity != null)
  1407. {
  1408. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1409. {
  1410. returnErrorMsg("此订单已经在售后");
  1411. return;
  1412. }
  1413. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1414. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1415. entity.AfterSaleTime = DateTime.Now;
  1416. entity.Update();
  1417. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1418. returnSuccessMsg("转售后成功!");
  1419. return;
  1420. }
  1421. returnErrorMsg("找不到记录");
  1422. }
  1423. }
  1424. public void set_erp_withdraw()
  1425. {
  1426. if (UrlPostParmsCheck("ctid"))
  1427. {
  1428. try
  1429. {
  1430. string eid = GetPostString("ctid");//商品id
  1431. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1432. CeWithdraw ceWithdrawSelect = null;
  1433. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1434. if (ceWithdrawSelect != null)
  1435. {
  1436. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1437. {
  1438. ceWithdrawSelect.status = -1;
  1439. ceWithdrawSelect.Update();
  1440. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1441. returnSuccessMsg("重新发起审核成功");
  1442. return;
  1443. }
  1444. else
  1445. {
  1446. returnSuccessMsg("请勿重复申请!");
  1447. return;
  1448. }
  1449. }
  1450. else
  1451. {
  1452. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1453. if (string.IsNullOrEmpty(CustomerUserId))
  1454. {
  1455. CustomerUserId = "-1";
  1456. }
  1457. int Userid = CurrentUser.UserID;//用户id
  1458. CeWithdraw ceWithdraw = new CeWithdraw();
  1459. ceWithdraw.tid = eid;
  1460. ceWithdraw.userid = Userid;
  1461. ceWithdraw.providerid = CustomerUserId;
  1462. ceWithdraw.status = 3;
  1463. ceWithdraw.creationtime = DateTime.Now;
  1464. ceWithdraw.Create();
  1465. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1466. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1467. return;
  1468. }
  1469. }
  1470. catch
  1471. {
  1472. returnErrorMsg("申请撤回订单失败");
  1473. return;
  1474. }
  1475. }
  1476. }
  1477. public void ins_erp_billinfo()
  1478. {
  1479. if (UrlPostParmsCheck("ctid"))
  1480. {
  1481. string eid = GetPostString("ctid");
  1482. CeErpTradeCell entity = null;
  1483. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1484. if (entity != null)
  1485. {
  1486. CeErpBill bill = CeErpBill.GetByTid(eid);
  1487. bool isHave = false;
  1488. if (bill != null)
  1489. {
  1490. isHave = true;
  1491. if (bill.state != 4)
  1492. {
  1493. returnErrorMsg("此单已经申请过发票了");
  1494. return;
  1495. }
  1496. }
  1497. if (entity.IsNeedBill == 0)
  1498. {
  1499. entity.IsNeedBill = 1;
  1500. }
  1501. entity.Update();
  1502. string errjson = "";
  1503. try
  1504. {
  1505. CeErpBill bill_entity = new CeErpBill();
  1506. bill_entity.tid = entity.tid;
  1507. bill_entity.title = GetPostString("title");
  1508. string taxstr = GetPostString("tax");
  1509. taxstr = taxstr.Replace(" ", "");
  1510. bill_entity.tax = taxstr;
  1511. bill_entity.bank = GetPostString("bank");
  1512. string bankacstr = GetPostString("bankac");
  1513. bankacstr = bankacstr.Replace(" ", "");
  1514. bill_entity.bankac = bankacstr;
  1515. bill_entity.address = GetPostString("address");
  1516. bill_entity.phone = GetPostString("phone");
  1517. bill_entity.price = GetPostString("price");
  1518. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1519. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1520. {
  1521. billCount += 1;
  1522. }
  1523. string prebill = "ltb";
  1524. for (int idx = 1; idx <= billCount; idx++)
  1525. {
  1526. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1527. string billoid = prebill + idx + dtstr;
  1528. bill_entity.billOrderId += billoid;
  1529. if (idx < billCount)
  1530. {
  1531. bill_entity.billOrderId += ",";
  1532. }
  1533. }
  1534. bill_entity.productId = GetPostInt("ProductName");
  1535. bill_entity.num = GetPostInt("num");
  1536. bill_entity.unit = GetPostString("unit");
  1537. bill_entity.type = GetPostString("type");
  1538. bill_entity.sendType = GetPostString("SendType");
  1539. bill_entity.email = GetPostString("email");
  1540. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1541. bill_entity.shopName = GetPostString("ShopName");
  1542. bill_entity.applymemo = GetPostString("applyMemo");
  1543. bill_entity.createTime = DateTime.Now;
  1544. bill_entity.state = 0;
  1545. bill_entity.userId = CurrentUser.UserID;
  1546. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1547. bill_entity.Create();
  1548. }
  1549. catch (Exception ex)
  1550. {
  1551. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1552. returnErrorMsg("创建发票出错!");
  1553. return;
  1554. }
  1555. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1556. returnSuccessMsg("发票申请成功!");
  1557. return;
  1558. }
  1559. returnErrorMsg("找不到记录");
  1560. }
  1561. }
  1562. public void ins_erp_neworder()
  1563. {
  1564. if (UrlPostParmsCheck("receiver_name"))
  1565. {
  1566. CeErpTrade entity = new CeErpTrade();
  1567. string plat_form = GetPostString("platform");
  1568. string preStr = "N_";
  1569. if (plat_form == "拼多多")
  1570. {
  1571. preStr = "P_";
  1572. }
  1573. else if (plat_form == "阿里巴巴")
  1574. {
  1575. preStr = "A_";
  1576. }
  1577. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1578. entity.seller_nick = GetPostString("seller_nick");
  1579. entity.buyer_nick = GetPostString("buyer_nick");
  1580. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1581. entity.total_fee = entity.payment;
  1582. entity.pay_time = DateTime.Now;
  1583. entity.status = "NOT_SHIPPED";
  1584. entity.receiver_name = GetPostString("receiver_name");
  1585. entity.receiver_mobile = GetPostString("receiver_mobile");
  1586. entity.receiver_state = GetPostString("receiver_state");
  1587. entity.receiver_city = GetPostString("receiver_city");
  1588. entity.receiver_district = GetPostString("receiver_district");
  1589. entity.receiver_address = GetPostString("receiver_address");
  1590. if (entity.receiver_state == "" || entity.receiver_city == "")
  1591. {
  1592. returnErrorMsg("收件地址不能为空");
  1593. return;
  1594. }
  1595. int shopId = 0;
  1596. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1597. if (nShop != null)
  1598. {
  1599. shopId = nShop.ID;
  1600. }
  1601. if (shopId != 34 && entity.payment == 0)
  1602. {
  1603. returnErrorMsg("公司自用的单金额才能为0");
  1604. return;
  1605. }
  1606. entity.Create();
  1607. CeErpTradeCell entitycell = new CeErpTradeCell();
  1608. entitycell.ctid = entity.tid;
  1609. entitycell.tid = entity.tid;
  1610. entitycell.ShopId = shopId;
  1611. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1612. entitycell.OrderState = 0;
  1613. entitycell.pay_time = entity.pay_time;
  1614. entitycell.IsOffLineOrder = 1;
  1615. entitycell.Create();
  1616. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1617. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1618. return;
  1619. }
  1620. }
  1621. public void ins_erp_neworder2()
  1622. {
  1623. if (UrlPostParmsCheck("receiver_name"))
  1624. {
  1625. //string plat_form = GetPostString("platform");
  1626. string preStr = "X_";
  1627. string memo = GetPostString("memo");
  1628. string productId = GetPostString("productId");
  1629. string primg = GetPostString("proofimg");
  1630. string sellerNick = GetPostString("seller_nick");
  1631. string addFrom = GetPostString("addfrom");
  1632. if (addFrom == "1")
  1633. {
  1634. preStr = "N_";
  1635. }
  1636. int shopId = 0;
  1637. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1638. if (nShop != null)
  1639. {
  1640. shopId = nShop.ID;
  1641. }
  1642. else
  1643. {
  1644. returnErrorMsg("找不到对应店铺");
  1645. return;
  1646. }
  1647. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1648. {
  1649. returnErrorMsg("必须上传付款凭证");
  1650. return;
  1651. }
  1652. CeErpTrade entity = new CeErpTrade();
  1653. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1654. entity.seller_nick = sellerNick;
  1655. entity.buyer_nick = GetPostString("buyer_nick");
  1656. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1657. entity.total_fee = entity.payment;
  1658. entity.pay_time = DateTime.Now;
  1659. entity.status = "NOT_SHIPPED";
  1660. entity.receiver_name = GetPostString("receiver_name");
  1661. entity.receiver_mobile = GetPostString("receiver_mobile");
  1662. entity.receiver_state = GetPostString("receiver_state");
  1663. entity.receiver_city = GetPostString("receiver_city");
  1664. entity.receiver_district = GetPostString("receiver_district");
  1665. entity.receiver_address = GetPostString("receiver_address");
  1666. entity.seller_memo = memo;
  1667. entity.orderFrom = 20;
  1668. entity.orderType = 15;
  1669. if (entity.receiver_state == "" || entity.receiver_city == "")
  1670. {
  1671. returnErrorMsg("收件地址不能为空");
  1672. return;
  1673. }
  1674. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1675. {
  1676. returnErrorMsg("公司自用的单金额才能为0");
  1677. return;
  1678. }
  1679. entity.Create();
  1680. string toWhere = GetPostString("towhere");
  1681. CeErpTradeCell entitycell = new CeErpTradeCell();
  1682. entitycell.ctid = entity.tid;
  1683. //唯一标识
  1684. entitycell.OrderSn = entity.tid;
  1685. string orderSn = dataHelper.getSaleOrderSn();
  1686. if (orderSn != "")
  1687. {
  1688. entitycell.OrderSn = orderSn;
  1689. }
  1690. entitycell.tid = entity.tid;
  1691. //if (preStr == "X_")
  1692. //{
  1693. entitycell.IsOffLineOrder = 1;
  1694. //}
  1695. entitycell.CustomerUserId = CurrentUser.UserID;
  1696. entitycell.PayProofImg = primg;
  1697. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1698. entitycell.ProductId = Convert.ToInt32(productId);
  1699. entitycell.ShopId = shopId;
  1700. entitycell.UpdateTime = DateTime.Now;
  1701. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1702. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1703. {
  1704. entitycell.IsXianHuo = 1;
  1705. }
  1706. entitycell.pay_time = entity.pay_time;
  1707. if (toWhere == "1")
  1708. {
  1709. entitycell.OrderState = 2;
  1710. }
  1711. else
  1712. {
  1713. entitycell.OrderState = 6;
  1714. entitycell.FinishPlaceTime = entitycell.pay_time;
  1715. }
  1716. if (shopId == 94)
  1717. {
  1718. entitycell.OrderState = 4;
  1719. entitycell.WaitDesignTime = entitycell.pay_time;
  1720. entitycell.StartDesignTime = entitycell.pay_time;
  1721. entitycell.DesignUserId = 218;
  1722. }
  1723. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1724. {
  1725. entitycell.OrderState = -1;//修改12-5
  1726. CeWithdraw ceWithdraw = new CeWithdraw();
  1727. ceWithdraw.tid = entity.tid;
  1728. ceWithdraw.providerid = "-1";
  1729. ceWithdraw.status = -1;
  1730. ceWithdraw.creationtime = DateTime.Now;
  1731. ceWithdraw.userid = 1337;
  1732. ceWithdraw.Create();
  1733. }
  1734. entitycell.Create();
  1735. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1736. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1737. {
  1738. addPlaceRegist(entitycell, CurrentUser.UserID);
  1739. }
  1740. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1741. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1742. return;
  1743. }
  1744. }
  1745. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1746. {
  1747. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1748. entity.PlactTime = tradecell.pay_time;
  1749. entity.AddUserId = userid;
  1750. entity.FileName = tradecell.seller_memo;
  1751. entity.Supplier = 24;
  1752. entity.CreateTime = DateTime.Now;
  1753. entity.Did = tradecell.ctid;
  1754. entity.tid = tradecell.tid;
  1755. entity.splitTag = tradecell.SplitTag;
  1756. entity.CurState = "未完成";
  1757. entity.Create();
  1758. }
  1759. public void get_erp_offlinelist()
  1760. {
  1761. DataStruct dStruct = GetPostStruct();
  1762. List<string> lw = new List<string>();
  1763. string tid = GetPostString("ctid");
  1764. string date1 = GetPostString("date1");
  1765. string date2 = GetPostString("date2");
  1766. if (tid.Length > 0 || date1.Length > 0)
  1767. {
  1768. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1769. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1770. if (dw.Length > 0) lw.Add(dw);
  1771. }
  1772. else
  1773. {
  1774. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1775. }
  1776. string shopname = GetPostString("shopname");
  1777. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1778. string buyernick = GetPostString("buyer_nick");
  1779. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1780. string customer = GetPostString("customer");
  1781. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1782. string design = GetPostString("design");
  1783. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1784. string orderState = GetPostString("orderState");
  1785. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1786. string address = GetPostString("address");
  1787. 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));
  1788. string sellermemo = GetPostString("seller_memo");
  1789. if (sellermemo.Length > 0)
  1790. {
  1791. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1792. }
  1793. string price1 = GetPostString("price1");
  1794. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1795. string price2 = GetPostString("price2");
  1796. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1797. //if (PKey != "admin")
  1798. //{
  1799. // string usershop = CurrentUser.User.pemShop;
  1800. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1801. //}
  1802. //if (ex_psize > 0)
  1803. //{
  1804. dStruct.Order = "pay_time desc";
  1805. //}
  1806. //else
  1807. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1808. lw.Add(string.Format("IsOffLineOrder=1"));
  1809. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1810. DataTable dt = null;
  1811. dt = WebCache.GetData("view_erptradecell", dStruct);
  1812. writeGridDataTableJson(dStruct.TotalCount, dt);
  1813. }
  1814. public void get_erp_returncashrecord()
  1815. {
  1816. DataStruct dStruct = GetPostStruct();
  1817. List<string> lw = new List<string>();
  1818. string tid = GetPostString("ctid");
  1819. if (tid.Length > 0)
  1820. {
  1821. lw.Add(string.Format("tid like '%{0}%'", tid));
  1822. dStruct.Order = "id desc";
  1823. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1824. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1825. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1826. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1827. return;
  1828. }
  1829. returnErrorMsg("id数据错误!");
  1830. }
  1831. public void ins_erp_returncashrecord()
  1832. {
  1833. if (UrlPostParmsCheck("tid"))
  1834. {
  1835. string tid = GetPostString("tid");
  1836. string retype = GetPostString("type");
  1837. StringBuilder sql = new StringBuilder();
  1838. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1839. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1840. if (dt.Rows.Count > 0)
  1841. {
  1842. returnErrorMsg("相同返现类型记录已存在");
  1843. return;
  1844. }
  1845. CeErpReturnCash entity = new CeErpReturnCash();
  1846. entity.tid = tid;
  1847. entity.seller_nick = GetPostString("seller_nick");
  1848. string pment = GetPostString("payment");
  1849. if (pment.Length > 0)
  1850. {
  1851. entity.payment = Convert.ToDouble(pment);
  1852. }
  1853. entity.buyer_nick = GetPostString("buyer_nick");
  1854. entity.cashstate = 0;
  1855. entity.rtype = retype;
  1856. string rPrice = GetPostString("returnprice");
  1857. if (rPrice.Length > 0)
  1858. {
  1859. entity.returnprice = Convert.ToDouble(rPrice);
  1860. }
  1861. entity.created = DateTime.Now;
  1862. entity.con = GetPostString("con");
  1863. entity.img = GetPostString("img");
  1864. entity.applyuserid = CurrentUser.UserID;
  1865. entity.Create();
  1866. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1867. returnSuccessMsg("操作成功!");
  1868. return;
  1869. }
  1870. }
  1871. public void set_erp_predelivery()
  1872. {
  1873. if (UrlPostParmsCheck("ctid"))
  1874. {
  1875. string eid = GetPostString("ctid");
  1876. CeErpTradeCell entity = null;
  1877. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1878. if (entity != null)
  1879. {
  1880. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1881. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1882. //{
  1883. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1884. // return;
  1885. //}
  1886. entity.IsPreDelivery = 1;
  1887. entity.Update();
  1888. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1889. returnSuccessMsg("预发货成功!");
  1890. return;
  1891. //string shop = GetPostString("seller_nick");
  1892. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1893. //string comName = GetPostString("comName");
  1894. //string comCode = GetPostString("comCode");
  1895. //string outSid = GetPostString("outSid");//运单号
  1896. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1897. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1898. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1899. //string apires = "";
  1900. //if (deliveryType == "虚拟发货")
  1901. //{
  1902. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1903. //}
  1904. //else
  1905. //{
  1906. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1907. //}
  1908. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1909. ////{
  1910. //if (apires.IndexOf("发货成功") != -1)
  1911. //{
  1912. // if (deliveryType != "虚拟发货")
  1913. // {
  1914. // //还要插入快递信息到 快递信息表
  1915. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1916. // exinfo.tid = eid;
  1917. // exinfo.out_sid = outSid;
  1918. // exinfo.company_code = comCode;
  1919. // exinfo.company_name = comName;
  1920. // exinfo.delivery_memo = deliveryMemo;
  1921. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1922. // exinfo.deliveryType = deliveryType;
  1923. // exinfo.Create();
  1924. // }
  1925. // returnSuccessMsg("发货成功!");
  1926. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1927. //}
  1928. //else
  1929. //{
  1930. // returnErrorMsg("淘宝发货失败!!");
  1931. //}
  1932. //return;
  1933. }
  1934. returnErrorMsg("找不到订单记录");
  1935. }
  1936. }
  1937. public void get_erp_unusuallist()
  1938. {
  1939. DataStruct dStruct = GetPostStruct();
  1940. List<string> lw = new List<string>();
  1941. string tid = GetPostString("ctid");
  1942. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1943. string shopname = GetPostString("shopname");
  1944. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1945. string buyernick = GetPostString("buyer_nick");
  1946. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1947. string ResponsibleMan = GetPostString("responsible");
  1948. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1949. string date1 = GetPostString("date1");
  1950. string date2 = GetPostString("date2");
  1951. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1952. if (dw.Length > 0) lw.Add(dw);
  1953. string price1 = GetPostString("price1");
  1954. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1955. string price2 = GetPostString("price2");
  1956. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1957. string orderState = GetPostString("orderState");
  1958. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1959. string sellermemo = GetPostString("seller_memo");
  1960. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1961. lw.Add(string.Format("UnusualTag > 0"));
  1962. lw.Add(string.Format("IsRefund<={0}", 1));
  1963. dStruct.Order = "pay_time desc";
  1964. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1965. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1966. writeGridDataTableJson(dStruct.TotalCount, dt);
  1967. }
  1968. public void set_erp_unusualtonomal()
  1969. {
  1970. if (UrlPostParmsCheck("ctid"))
  1971. {
  1972. string eid = GetPostString("ctid");
  1973. CeErpTradeCell entity = null;
  1974. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1975. if (entity != null)
  1976. {
  1977. entity.UnusualTag = -1;
  1978. entity.Update();
  1979. returnSuccessMsg("忽略成功!");
  1980. return;
  1981. }
  1982. returnErrorMsg("找不到记录");
  1983. }
  1984. }
  1985. public void ins_erp_unusualreason()
  1986. {
  1987. if (UrlPostParmsCheck("ctid"))
  1988. {
  1989. string eid = GetPostString("ctid");
  1990. CeErpTradeCell entity = null;
  1991. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1992. if (entity != null)
  1993. {
  1994. entity.MemoOpt = 4;
  1995. entity.UnusualCon = GetPostString("con");
  1996. entity.Update();
  1997. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1998. if (trade != null)
  1999. {
  2000. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2001. }
  2002. //查货是否超时
  2003. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2004. if (ceErpTradeCellExtend == null)
  2005. {
  2006. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2007. ceErpTradeCellExtend.ctid = entity.ctid;
  2008. }
  2009. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2010. {
  2011. ceErpTradeCellExtend.CheckOut += 1;
  2012. }
  2013. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2014. if (ceErpTradeCellExtend.ID > 0)
  2015. {
  2016. ceErpTradeCellExtend.Update();
  2017. }
  2018. else
  2019. {
  2020. ceErpTradeCellExtend.Create();
  2021. }
  2022. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2023. returnSuccessMsg("操作成功!");
  2024. return;
  2025. }
  2026. returnErrorMsg("找不到记录");
  2027. }
  2028. }
  2029. public void upd_erp_sampleorder()
  2030. {
  2031. if (UrlPostParmsCheck("ctid"))
  2032. {
  2033. string eid = GetPostString("ctid");
  2034. string[] eArr = eid.Split(',');
  2035. if (eArr.Length > 1)
  2036. {
  2037. List<string> eLst = new List<string>();
  2038. for (int i = 0; i < eArr.Length; i++)
  2039. {
  2040. eLst.Add("'" + eArr[i] + "'");
  2041. }
  2042. eid = string.Join(",", eLst.ToArray());
  2043. }
  2044. else
  2045. {
  2046. eid = "'" + eid + "'";
  2047. }
  2048. StringBuilder sql = new StringBuilder();
  2049. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2050. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2051. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2052. if (dt.Rows.Count > 0)
  2053. {
  2054. string errmsg = "";
  2055. foreach (DataRow dr in dt.Rows)
  2056. {
  2057. StringBuilder sqlsb = new StringBuilder();
  2058. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2059. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2060. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2061. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2062. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2063. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2064. {
  2065. continue;
  2066. }
  2067. else
  2068. {
  2069. string emsg = commonHelper.KeepChinese(apires);
  2070. errmsg += emsg;
  2071. }
  2072. }
  2073. if (errmsg.Length > 0)
  2074. {
  2075. returnErrorMsg(errmsg);
  2076. return;
  2077. }
  2078. returnSuccessMsg("操作成功");
  2079. return;
  2080. }
  2081. returnErrorMsg("找不到记录");
  2082. }
  2083. }
  2084. public void upd_erp_transcustomer()
  2085. {
  2086. if (UrlPostParmsCheck("ctid"))
  2087. {
  2088. string eid = GetPostString("ctid");
  2089. int userid = GetPostInt("CustomerUserId");
  2090. CeErpTradeCell entity = null;
  2091. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2092. if (entity != null)
  2093. {
  2094. //string[] mlist = entity.seller_memo.Split('-');
  2095. //string sql = "select * from view_erpuser where id=" + userid;
  2096. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2097. //if (dt != null && dt.Rows.Count > 0)
  2098. //{
  2099. // string nmemo = "";
  2100. // for(int i = 0; i < mlist.Length - 1; i++)
  2101. // {
  2102. // nmemo += mlist[i];
  2103. // nmemo += "-";
  2104. // }
  2105. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2106. // entity.seller_memo = nmemo;
  2107. //}
  2108. entity.CustomerUserId = userid;
  2109. entity.Update();
  2110. returnSuccessMsg("操作成功!");
  2111. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2112. return;
  2113. }
  2114. returnErrorMsg("找不到记录");
  2115. }
  2116. }
  2117. public void upd_erp_transdesigner()
  2118. {
  2119. if (UrlPostParmsCheck("ctid"))
  2120. {
  2121. string eids = GetPostString("ctid");
  2122. string[] ctidList = eids.Split(',');
  2123. int userid = GetPostInt("DesignUserId");
  2124. foreach (string ctid in ctidList)
  2125. {
  2126. CeErpTradeCell entity = null;
  2127. CeErpDesignerBill entitys = null;
  2128. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2129. entitys = CeErpDesignerBill.GetByTid(ctid);
  2130. if (entity != null)
  2131. {
  2132. if (entity.OrderState > 4)
  2133. {
  2134. continue;
  2135. }
  2136. //存在退款不能流转
  2137. if (entity.IsRefund > 0)
  2138. {
  2139. continue;
  2140. }
  2141. entity.DesignUserId = userid;
  2142. entity.WaitDesignTime = DateTime.Now;
  2143. entity.Update();
  2144. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2145. }
  2146. }
  2147. returnSuccessMsg("操作成功!");
  2148. }
  2149. }
  2150. public void upd_erp_distributedesigner()
  2151. {
  2152. if (UrlPostParmsCheck("ctid"))
  2153. {
  2154. string eid = GetPostString("ctid");
  2155. int userid = GetPostInt("DesignUserId");
  2156. string[] idlist = eid.Split(',');
  2157. if (idlist.Length <= 0)
  2158. {
  2159. returnErrorMsg("订单不能为空");
  2160. return;
  2161. }
  2162. foreach (string ctid in idlist)
  2163. {
  2164. CeErpTradeCell entity = null;
  2165. CeErpDesignerBill entitys = null;
  2166. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2167. else continue;
  2168. if (entity != null)
  2169. {
  2170. if (userid == 2125 || userid == 3542)
  2171. { }
  2172. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2173. {
  2174. returnErrorMsg("金额错误的订单无法指派");
  2175. return;
  2176. }
  2177. if (entity.OrderState >= 5)
  2178. {
  2179. returnErrorMsg("已经设计完成无法指派");
  2180. return;
  2181. }
  2182. if (entity.OrderState == -1)
  2183. {
  2184. returnErrorMsg("审核中的订单无法指派");
  2185. return;
  2186. }
  2187. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2188. {
  2189. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2190. return;
  2191. }
  2192. //157赖橙帆 159林晨 73 静之颖
  2193. 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)
  2194. {
  2195. returnErrorMsg("指派设计共创无法再次指派!");
  2196. return;
  2197. }
  2198. entity.OrderState = 3;
  2199. if (entity.SupplierId == 0)
  2200. {
  2201. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2202. entity.SupplierId = suid;
  2203. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2204. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2205. }
  2206. if (userid == 2125 && entity.seller_memo != "")
  2207. {
  2208. apiDesign.API_GetPrintData_CreateOrder(entity);
  2209. }
  2210. if (userid == 3542 && entity.seller_memo != "")
  2211. {
  2212. string userPost = CurrentUser.UserPost.Post.Code;
  2213. if (CurrentUser.UserID == 73)
  2214. {
  2215. userPost = "SysAdmin";
  2216. }
  2217. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2218. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2219. if (response.msg != "设计共创:成功")
  2220. {
  2221. returnErrorMsg(response.msg);
  2222. return;
  2223. }
  2224. entity.DispatchSort = 2;
  2225. }
  2226. else
  2227. {
  2228. if (entity.DispatchSort == 2)
  2229. {
  2230. ApiVo apiVo = new ApiVo();
  2231. apiVo.actionName = "closeDesign";
  2232. apiVo.orderNumber = entity.ctid;
  2233. designHelper.API_WorkCore(apiVo);//closeDesign
  2234. }
  2235. entity.DispatchSort = 0;
  2236. }
  2237. entity.DesignUserId = userid;
  2238. entity.WaitDesignTime = DateTime.Now;
  2239. entity.UpdateTime = DateTime.Now;
  2240. entity.Update();
  2241. string name = commonHelper.getUserNameById(userid);
  2242. commonHelper.UpdateRelationOrder(entity.ctid);
  2243. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2244. }
  2245. }
  2246. returnSuccessMsg("操作成功!");
  2247. return;
  2248. }
  2249. }
  2250. public string getTidByCtid(string ctid)
  2251. {
  2252. string tid = "";
  2253. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2254. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2255. if (dataTable != null && dataTable.Rows.Count > 0)
  2256. {
  2257. tid = dataTable.Rows[0]["tid"].ToString();
  2258. }
  2259. return tid;
  2260. }
  2261. public List<string> getTidByCtidLike(string ctid)
  2262. {
  2263. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2264. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2265. List<string> list = new List<string>();
  2266. if (dataTable != null && dataTable.Rows.Count > 0)
  2267. {
  2268. foreach (DataRow item in dataTable.Rows)
  2269. {
  2270. list.Add("'" + item["tid"].ToString() + "'");
  2271. }
  2272. }
  2273. return list;
  2274. }
  2275. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2276. {
  2277. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2278. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2279. List<string> list = new List<string>();
  2280. if (dataTable != null && dataTable.Rows.Count > 0)
  2281. {
  2282. foreach (DataRow item in dataTable.Rows)
  2283. {
  2284. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2285. {
  2286. continue;
  2287. }
  2288. list.Add("'" + item["receiverId"].ToString() + "'");
  2289. }
  2290. }
  2291. return list;
  2292. }
  2293. public void get_erp_myorderlist()
  2294. {
  2295. DataStruct dStruct = GetPostStruct();
  2296. List<string> lw = new List<string>();
  2297. string tid = GetPostString("ctid");
  2298. if (tid.Length > 0)
  2299. {
  2300. string select_tid = getTidByCtid(tid);
  2301. lw.Add(string.Format("tid='{0}'", select_tid));
  2302. }
  2303. else
  2304. {
  2305. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2306. }
  2307. //12-1 修改
  2308. string urgent = GetPostString("urgent");
  2309. string back = GetPostString("back");
  2310. string offlineSearch = GetPostString("offlineSearch");
  2311. if (!string.IsNullOrWhiteSpace(urgent))
  2312. {
  2313. if (urgent.Equals("true"))
  2314. {
  2315. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2316. }
  2317. }
  2318. if (!string.IsNullOrWhiteSpace(back))
  2319. {
  2320. if (back.Equals("true"))
  2321. {
  2322. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2323. }
  2324. }
  2325. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2326. {
  2327. if (offlineSearch.Equals("true"))
  2328. {
  2329. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2330. }
  2331. }
  2332. //end
  2333. string shopname = GetPostString("shopname");
  2334. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2335. string buyernick = GetPostString("buyer_nick");
  2336. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2337. string design = GetPostString("design");
  2338. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2339. string orderState = GetPostString("orderState");
  2340. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2341. string sellermemo = GetPostString("seller_memo");
  2342. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2343. string date1 = GetPostString("date1");
  2344. string date2 = GetPostString("date2");
  2345. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2346. if (dw.Length > 0) lw.Add(dw);
  2347. string price1 = GetPostString("price1");
  2348. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2349. string price2 = GetPostString("price2");
  2350. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2351. string urgency = GetPostString("urgency");
  2352. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2353. string after = GetPostString("after");
  2354. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2355. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2356. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2357. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2358. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2359. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2360. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2361. if (dt != null && dt.Rows.Count > 0)
  2362. {
  2363. foreach (DataRow dr in dt.Rows)
  2364. {
  2365. try
  2366. {
  2367. // 对象操作
  2368. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2369. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2370. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2371. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2372. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2373. if (dStruct.PageSize != 100000)
  2374. {
  2375. if (dr["DispatchSort"].ToString() == "2")
  2376. {
  2377. dr["gongchuang"] = 200;
  2378. }
  2379. else if ("外协".Equals(dr["ToType"].ToString()))
  2380. {
  2381. dr["gongchuang"] = 200;
  2382. }
  2383. else if ("内部".Equals(dr["ToType"].ToString()))
  2384. {
  2385. dr["gongchuang"] = -1;
  2386. }
  2387. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2388. {
  2389. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2390. dr["gongchuang"] = response.code;
  2391. }
  2392. }
  2393. }
  2394. catch (NullReferenceException ex)
  2395. {
  2396. }
  2397. }
  2398. }
  2399. writeGridDataTableJson(dStruct.TotalCount, dt);
  2400. }
  2401. public void get_erp_myreturnorderlist()
  2402. {
  2403. DataStruct dStruct = GetPostStruct();
  2404. List<string> lw = new List<string>();
  2405. string tid = GetPostString("ctid");
  2406. if (tid.Length > 0)
  2407. {
  2408. string select_tid = getTidByCtid(tid);
  2409. lw.Add(string.Format("tid='{0}'", select_tid));
  2410. }
  2411. else
  2412. {
  2413. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2414. }
  2415. string shopname = GetPostString("shopname");
  2416. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2417. string buyernick = GetPostString("buyer_nick");
  2418. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2419. string design = GetPostString("design");
  2420. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2421. string orderState = GetPostString("orderState");
  2422. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2423. string sellermemo = GetPostString("seller_memo");
  2424. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2425. string date1 = GetPostString("date1");
  2426. string date2 = GetPostString("date2");
  2427. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2428. if (dw.Length > 0) lw.Add(dw);
  2429. string price1 = GetPostString("price1");
  2430. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2431. string price2 = GetPostString("price2");
  2432. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2433. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2434. {
  2435. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2436. }
  2437. else
  2438. {
  2439. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2440. }
  2441. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2442. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2443. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2444. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2445. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2446. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2447. if (dt != null && dt.Rows.Count > 0)
  2448. {
  2449. foreach (DataRow dr in dt.Rows)
  2450. {
  2451. try
  2452. {
  2453. // 对象操作
  2454. if (dStruct.PageSize != 100000)
  2455. {
  2456. if (dr["DispatchSort"].ToString() == "2")
  2457. {
  2458. dr["gongchuang"] = 200;
  2459. }
  2460. else if ("外协".Equals(dr["ToType"].ToString()))
  2461. {
  2462. dr["gongchuang"] = 200;
  2463. }
  2464. else if ("内部".Equals(dr["ToType"].ToString()))
  2465. {
  2466. dr["gongchuang"] = -1;
  2467. }
  2468. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2469. {
  2470. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2471. dr["gongchuang"] = response.code;
  2472. }
  2473. }
  2474. }
  2475. catch (NullReferenceException ex)
  2476. {
  2477. // 处理空引用异常
  2478. }
  2479. }
  2480. }
  2481. writeGridDataTableJson(dStruct.TotalCount, dt);
  2482. }
  2483. public void get_erp_myorderlist_pregather()
  2484. {
  2485. string date1 = GetPostString("date1");
  2486. string date2 = GetPostString("date2");
  2487. int userId = CurrentUser.UserID; //客服id
  2488. string orderWhere = "";
  2489. List<string> lw = new List<string>();
  2490. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2491. if (dw.Length > 0) lw.Add(dw);
  2492. lw.Add(string.Format("CustomerUserId={0}", userId));
  2493. lw.Add(string.Format("OrderState<9"));
  2494. orderWhere = string.Join(" and ", lw.ToArray());
  2495. string orderWhere2 = "";
  2496. List<string> lw2 = new List<string>();
  2497. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2498. if (dw2.Length > 0) lw2.Add(dw2);
  2499. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2500. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2501. string sql = string.Format("select *" +
  2502. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2503. "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 " +
  2504. "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 " +
  2505. "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");
  2506. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2507. //writeGridDataTableJson(dt.Rows.Count, dt);
  2508. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2509. }
  2510. public void upd_erp_publishorder()
  2511. {
  2512. if (UrlPostParmsCheck("ctid"))
  2513. {
  2514. string eid = GetPostString("ctid");
  2515. CeErpTradeCell entity = null;
  2516. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2517. if (entity != null)
  2518. {
  2519. entity.OrderState = 0; //发布后,变为待抢单
  2520. entity.Update();
  2521. commonHelper.UpdateRelationOrder(entity.ctid);
  2522. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2523. returnSuccessMsg("发布成功!");
  2524. return;
  2525. }
  2526. returnErrorMsg("找不到记录");
  2527. }
  2528. }
  2529. public void get_erp_my_tiporder()
  2530. {
  2531. StringBuilder sql = new StringBuilder();
  2532. int userId = 0;
  2533. if (CurrentUser != null) userId = CurrentUser.UserID;
  2534. string posCode = CurrentUser.UserPost.Post.Code;
  2535. string isTipedAfterSaleVerify = GetPostString("af");
  2536. DataTable dt = new DataTable();
  2537. if (posCode != "Supplier")
  2538. {
  2539. if (posCode == "CustomerService" || posCode == "Director")
  2540. {
  2541. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2542. }
  2543. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2544. {
  2545. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2546. }
  2547. else
  2548. {
  2549. string teamIds = CurrentUser.User.TeamIds;
  2550. if (teamIds == "")
  2551. {
  2552. teamIds = "0";
  2553. }
  2554. 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);
  2555. }
  2556. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2557. }
  2558. if (dt.Rows.Count <= 0)
  2559. {
  2560. string key = "aftersale_order_" + userId;
  2561. if (RedisHelper.HasKey(key))
  2562. {
  2563. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2564. dt.Columns.Add("ctid", typeof(string));
  2565. dt.Columns.Add("IsReadTag", typeof(int));
  2566. foreach (var i in list)
  2567. {
  2568. DataRow data = dt.NewRow();
  2569. data["ctid"] = i;
  2570. data["IsReadTag"] = 4;
  2571. dt.Rows.Add(data);
  2572. }
  2573. RedisHelper.StringDelete(key);
  2574. }
  2575. }
  2576. if (dt.Rows.Count <= 0)
  2577. {
  2578. sql = new StringBuilder();
  2579. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2580. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2581. }
  2582. if (posCode == "Supplier")
  2583. {
  2584. string ids = CurrentUser.User.pemVend;
  2585. if (ids != null && ids.Length > 0)
  2586. {
  2587. string[] ids_list = ids.Split(',');
  2588. foreach (var item in ids_list)
  2589. {
  2590. string key = "return_order_" + item;
  2591. if (RedisHelper.HasKey(key))
  2592. {
  2593. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2594. dt.Columns.Add("ctid", typeof(string));
  2595. dt.Columns.Add("IsReadTag", typeof(int));
  2596. foreach (var i in list)
  2597. {
  2598. DataRow data = dt.NewRow();
  2599. data["ctid"] = i;
  2600. data["IsReadTag"] = 1;
  2601. dt.Rows.Add(data);
  2602. }
  2603. RedisHelper.StringDelete(key);
  2604. }
  2605. }
  2606. }
  2607. if (dt.Rows.Count <= 0)
  2608. {
  2609. sql = new StringBuilder();
  2610. 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);
  2611. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2612. }
  2613. }
  2614. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2615. }
  2616. public void reset_erp_tiporder()
  2617. {
  2618. string ids = GetPostString("ids");
  2619. string[] ctidList = ids.Split(',');
  2620. foreach (string ctid in ctidList)
  2621. {
  2622. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2623. if (enty != null)
  2624. {
  2625. enty.IsReadTag = 0;
  2626. enty.Update();
  2627. }
  2628. }
  2629. returnSuccessMsg("成功!");
  2630. return;
  2631. }
  2632. public void get_erp_designlist()
  2633. {
  2634. DataStruct dStruct = GetPostStruct();
  2635. List<string> lw = new List<string>();
  2636. string tid = GetPostString("ctid");
  2637. if (tid.Length > 0)
  2638. {
  2639. string select_tid = getTidByCtid(tid);
  2640. lw.Add(string.Format("tid='{0}'", select_tid));
  2641. }
  2642. string shopname = GetPostString("shopname");
  2643. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2644. string buyernick = GetPostString("buyer_nick");
  2645. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2646. string customer = GetPostString("customer");
  2647. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2648. string design = GetPostString("design");
  2649. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2650. string orderState = GetPostString("orderState");
  2651. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2652. lw.Add(string.Format("OrderState<6"));
  2653. string address = GetPostString("address");
  2654. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2655. string sellermemo = GetPostString("seller_memo");
  2656. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2657. string date1 = GetPostString("date1");
  2658. string date2 = GetPostString("date2");
  2659. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2660. if (dw.Length > 0) lw.Add(dw);
  2661. string apdate1 = GetPostString("apdate1");
  2662. string apdate2 = GetPostString("apdate2");
  2663. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2664. if (dwap.Length > 0) lw.Add(dwap);
  2665. string price1 = GetPostString("price1");
  2666. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2667. string price2 = GetPostString("price2");
  2668. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2669. string designTime = GetPostString("designtime");
  2670. if (designTime.Length > 0)
  2671. {
  2672. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2673. }
  2674. string usershop = CurrentUser.User.pemShop;
  2675. if (usershop.Length > 0)
  2676. {
  2677. lw.Add(string.Format("shopId in ({0})", usershop));
  2678. }
  2679. int myOrgid = CurrentUser.UserPost.OrgID;
  2680. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2681. if (myOrgCode.IndexOf("Designer") != -1)
  2682. {
  2683. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2684. {
  2685. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2686. }
  2687. else
  2688. {
  2689. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2690. }
  2691. }
  2692. else
  2693. {
  2694. string orgId = GetPostString("designerhd");
  2695. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2696. }
  2697. if (tid.Length > 0 || buyernick.Length > 0)
  2698. {
  2699. lw.Add(string.Format("OrderState >= 3"));
  2700. }
  2701. else
  2702. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2703. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2704. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2705. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2706. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2707. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2708. if (dt != null && dt.Rows.Count > 0)
  2709. {
  2710. foreach (DataRow dr in dt.Rows)
  2711. {
  2712. try
  2713. {
  2714. // 对象操作
  2715. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2716. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2717. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2718. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2719. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2720. if (dStruct.PageSize != 100000)
  2721. {
  2722. if (dr["DispatchSort"].ToString() == "2")
  2723. {
  2724. dr["gongchuang"] = 200;
  2725. }
  2726. else if ("外协".Equals(dr["ToType"].ToString()))
  2727. {
  2728. dr["gongchuang"] = 200;
  2729. }
  2730. else if ("内部".Equals(dr["ToType"].ToString()))
  2731. {
  2732. dr["gongchuang"] = -1;
  2733. }
  2734. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2735. {
  2736. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2737. dr["gongchuang"] = response.code;
  2738. }
  2739. }
  2740. }
  2741. catch (NullReferenceException ex)
  2742. {
  2743. }
  2744. }
  2745. }
  2746. writeGridDataTableJson(dStruct.TotalCount, dt);
  2747. }
  2748. public void get_erp_mydesignlist()
  2749. {
  2750. DataStruct dStruct = GetPostStruct();
  2751. List<string> lw = new List<string>();
  2752. string tid = GetPostString("ctid");
  2753. if (tid.Length > 0)
  2754. {
  2755. string select_tid = getTidByCtid(tid);
  2756. lw.Add(string.Format("tid='{0}'", select_tid));
  2757. }
  2758. string shopname = GetPostString("shopname");
  2759. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2760. string buyernick = GetPostString("buyer_nick");
  2761. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2762. string customer = GetPostString("customer");
  2763. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2764. string orderState = GetPostString("orderState");
  2765. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2766. //lw.Add(string.Format("OrderState<6"));
  2767. string date1 = GetPostString("date1");
  2768. string date2 = GetPostString("date2");
  2769. string dw = GetDateWhere("pay_time", date1, date2);
  2770. if (dw.Length > 0) lw.Add(dw);
  2771. string apdate1 = GetPostString("apdate1");
  2772. string apdate2 = GetPostString("apdate2");
  2773. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2774. if (dwap.Length > 0) lw.Add(dwap);
  2775. string price1 = GetPostString("price1");
  2776. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2777. string price2 = GetPostString("price2");
  2778. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2779. string olddownload = GetPostString("olddown");
  2780. if (olddownload == "1")
  2781. {
  2782. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2783. }
  2784. else if (olddownload == "2")
  2785. {
  2786. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2787. }
  2788. string sellermemo = GetPostString("seller_memo");
  2789. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2790. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2791. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2792. {
  2793. if (CurrentUser.User.TeamIds.Length > 0)
  2794. {
  2795. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2796. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2797. else
  2798. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2799. }
  2800. else
  2801. {
  2802. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2803. }
  2804. }
  2805. if (tid.Length <= 0)
  2806. {
  2807. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2808. }
  2809. lw.Add(string.Format("IsReturn!=3"));
  2810. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2811. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2812. string teamids = CurrentUser.User.TeamIds.ToString();
  2813. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2814. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2815. if (dt != null && dt.Rows.Count > 0)
  2816. {
  2817. foreach (DataRow dr in dt.Rows)
  2818. {
  2819. try
  2820. {
  2821. // 对象操作
  2822. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2823. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2824. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2825. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2826. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2827. if (dStruct.PageSize != 100000)
  2828. {
  2829. if (dr["DispatchSort"].ToString() == "2")
  2830. {
  2831. dr["gongchuang"] = 200;
  2832. }
  2833. else if ("外协".Equals(dr["ToType"].ToString()))
  2834. {
  2835. dr["gongchuang"] = 200;
  2836. }
  2837. else if ("内部".Equals(dr["ToType"].ToString()))
  2838. {
  2839. dr["gongchuang"] = -1;
  2840. }
  2841. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2842. {
  2843. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2844. dr["gongchuang"] = response.code;
  2845. }
  2846. }
  2847. }
  2848. catch (NullReferenceException ex)
  2849. {
  2850. }
  2851. }
  2852. }
  2853. writeGridDataTableJson(dStruct.TotalCount, dt);
  2854. }
  2855. public void set_erp_startdesign()
  2856. {
  2857. if (UrlPostParmsCheck("ctid"))
  2858. {
  2859. string eid = GetPostString("ctid");
  2860. CeErpTradeCell entity = null;
  2861. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2862. if (entity != null)
  2863. {
  2864. if (entity.OrderState != 3)
  2865. {
  2866. returnErrorMsg("请刷新,订单已经设计了");
  2867. return;
  2868. }
  2869. entity.StartDesignTime = DateTime.Now;
  2870. entity.OrderState = 4;
  2871. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2872. {
  2873. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2874. entity.SupplierId = suid;
  2875. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2876. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2877. }
  2878. entity.UpdateTime = DateTime.Now;
  2879. //entity.MakeSupplier = suname;
  2880. entity.Update();
  2881. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2882. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2883. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2884. commonHelper.getCytPrice(entity);
  2885. returnSuccessMsg("操作成功!");
  2886. return;
  2887. }
  2888. returnErrorMsg("找不到记录");
  2889. }
  2890. }
  2891. public void ins_erp_designselfmemo()
  2892. {
  2893. if (UrlPostParmsCheck("ctid"))
  2894. {
  2895. string eid = GetPostString("ctid");
  2896. string con = GetPostString("con");
  2897. CeErpTradeCell entity = null;
  2898. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2899. if (entity != null)
  2900. {
  2901. entity.DesignSelfMemo = con;
  2902. entity.Update();
  2903. returnSuccessMsg("操作成功!");
  2904. return;
  2905. }
  2906. returnErrorMsg("找不到记录");
  2907. }
  2908. }
  2909. public void ins_erp_designprice()
  2910. {
  2911. if (UrlPostParmsCheck("ctid"))
  2912. {
  2913. string eid = GetPostString("ctid");
  2914. int uid = CurrentUser.UserID;
  2915. string userName = CurrentUser.UserName;
  2916. CeErpTradeCell entity = null;
  2917. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2918. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2919. if (entitys == null)
  2920. {
  2921. entitys = new CeErpDesignerBill();
  2922. }
  2923. if (entity != null)
  2924. {
  2925. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2926. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2927. entity.StartDesignTime = DateTime.Now;
  2928. entity.OrderState = 4;
  2929. string suname = "";
  2930. if (entity.SupplierId == 0)
  2931. {
  2932. int sid = commonHelper.autoDistributeToSupplier(entity);
  2933. entity.SupplierId = sid;
  2934. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2935. }
  2936. entity.Update();
  2937. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2938. if (ceErpUserPost != null)
  2939. {
  2940. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2941. if (ceErpPost != null)
  2942. {
  2943. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2944. {
  2945. entitys.tid = entity.ctid;
  2946. entitys.oid = entity.tid;
  2947. entitys.uid = uid;
  2948. entitys.userName = userName;
  2949. entitys.designerType = 1;
  2950. entitys.designerTypeText = "内部设计师";
  2951. entitys.price = Convert.ToDouble(GetPostString("price"));
  2952. entitys.designNum = GetPostInt("designNum");
  2953. entitys.modifyNum = GetPostInt("modifyNum");
  2954. entitys.designSize = GetPostString("designSize");
  2955. entitys.modifySize = GetPostString("modifySize");
  2956. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2957. {
  2958. entitys.create_time = DateTime.Now;
  2959. entitys.create_u_id = uid;
  2960. entitys.create_u_name = userName;
  2961. entitys.Save();
  2962. }
  2963. else
  2964. {
  2965. entitys.update_time = DateTime.Now;
  2966. entitys.update_u_id = uid;
  2967. entitys.update_u_name = userName;
  2968. entitys.Update();
  2969. }
  2970. }
  2971. }
  2972. }
  2973. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2974. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2975. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2976. if (suname != "")
  2977. {
  2978. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2979. }
  2980. commonHelper.getCytPrice(entity);
  2981. returnSuccessMsg("操作成功!");
  2982. return;
  2983. }
  2984. returnErrorMsg("找不到记录");
  2985. }
  2986. }
  2987. public void upload_erp_filecomplete()
  2988. {
  2989. if (UrlPostParmsCheck("ctid"))
  2990. {
  2991. string eid = GetPostString("ctid");
  2992. CeErpTradeCell entity = null;
  2993. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2994. if (entity != null)
  2995. {
  2996. entity.OrderState = 5; //设计完成
  2997. entity.Update();
  2998. returnSuccessMsg(eid + "上传成功,设计完成!");
  2999. return;
  3000. }
  3001. returnErrorMsg("找不到订单记录");
  3002. }
  3003. }
  3004. public void get_erp_designovertimelist()
  3005. {
  3006. DataStruct dStruct = GetPostStruct();
  3007. List<string> lw = new List<string>();
  3008. string tid = GetPostString("ctid");
  3009. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3010. string shopname = GetPostString("shopname");
  3011. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3012. string buyernick = GetPostString("buyer_nick");
  3013. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3014. string ResponsibleMan = GetPostString("responsible");
  3015. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3016. string date1 = GetPostString("date1");
  3017. string date2 = GetPostString("date2");
  3018. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3019. if (dw.Length > 0) lw.Add(dw);
  3020. string price1 = GetPostString("price1");
  3021. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3022. string price2 = GetPostString("price2");
  3023. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3024. string orderState = GetPostString("orderState");
  3025. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3026. string sellermemo = GetPostString("seller_memo");
  3027. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3028. lw.Add(string.Format("UnusualTag=3"));
  3029. lw.Add(string.Format("IsRefund<={0}", 1));
  3030. dStruct.Order = "WaitDesignTime desc";
  3031. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3032. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3033. writeGridDataTableJson(dStruct.TotalCount, dt);
  3034. }
  3035. //设计管理 获取抢单大厅列表
  3036. public void get_erp_grabinglist()
  3037. {
  3038. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3039. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3040. bool oldOrder = false;
  3041. if (org != null)
  3042. {
  3043. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3044. }
  3045. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3046. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3047. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3048. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3049. //先处理订单数据
  3050. if (dt.Rows.Count > 0)
  3051. {
  3052. Dictionary<string, int> design = null;
  3053. int count = 0;
  3054. foreach (DataRow row in dt.Rows)
  3055. {
  3056. if (map.ContainsKey(row["ShopId"].ToString()))
  3057. {
  3058. map.TryGetValue(row["ShopId"].ToString(), out design);
  3059. }
  3060. else
  3061. {
  3062. design = new Dictionary<string, int>();
  3063. }
  3064. if (design.ContainsKey(row["ProductId"].ToString()))
  3065. {
  3066. design.TryGetValue(row["ProductId"].ToString(), out count);
  3067. }
  3068. count++;
  3069. design[row["ProductId"].ToString()] = count;
  3070. map[row["ShopId"].ToString()] = design;
  3071. }
  3072. }
  3073. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3074. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3075. //把店铺排序和技能排序分类
  3076. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3077. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3078. if (design_dt.Rows.Count > 0)
  3079. {
  3080. Dictionary<string, string> design = null;
  3081. List<string> shopIds = null;
  3082. foreach (DataRow row in design_dt.Rows)
  3083. {
  3084. if ("0".Equals(row["designId"].ToString()))
  3085. {
  3086. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3087. {
  3088. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3089. }
  3090. else
  3091. {
  3092. shopIds = new List<string>();
  3093. }
  3094. shopIds.Add(row["shopId"].ToString());
  3095. shop_orders[row["orders"].ToString()] = shopIds;
  3096. }
  3097. else
  3098. {
  3099. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3100. {
  3101. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3102. }
  3103. else
  3104. {
  3105. design = new Dictionary<string, string>();
  3106. }
  3107. design[row["orders"].ToString()] = row["designId"].ToString();
  3108. design_orders[row["shopId"].ToString()] = design;
  3109. }
  3110. }
  3111. //处理成key value后根据key排序
  3112. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3113. foreach (List<string> val in shop_orders.Values)
  3114. {
  3115. if (val != null)
  3116. {
  3117. foreach (string key in val)
  3118. {
  3119. if (design_orders.ContainsKey(key.ToString()))
  3120. {
  3121. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3122. }
  3123. }
  3124. }
  3125. }
  3126. }
  3127. //校验哪个优先级有订单
  3128. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3129. foreach (string key in shop_orders.Keys)
  3130. {
  3131. List<string> ids = null;
  3132. shop_orders.TryGetValue(key, out ids);
  3133. //id为shopid
  3134. foreach (string id in ids)
  3135. {
  3136. Dictionary<string, int> list = null;
  3137. Dictionary<string, string> desing = null;
  3138. map.TryGetValue(id, out list);
  3139. design_orders.TryGetValue(id, out desing);
  3140. if (list != null && desing != null)
  3141. {
  3142. foreach (var item in desing)
  3143. {
  3144. int count = 0;
  3145. if (list.ContainsKey(item.Value))
  3146. {
  3147. list.TryGetValue(item.Value, out count);
  3148. if (count > 0)
  3149. {
  3150. designIds[id] = item.Value;
  3151. break;
  3152. }
  3153. }
  3154. }
  3155. }
  3156. }
  3157. if (designIds.Count > 0)
  3158. {
  3159. break;
  3160. }
  3161. }
  3162. DataTable table = new DataTable();
  3163. table.Columns.Add("tid", typeof(string));
  3164. table.Columns.Add("ctid", typeof(string));
  3165. table.Columns.Add("seller_nick", typeof(string));
  3166. table.Columns.Add("productName", typeof(string));
  3167. table.Columns.Add("pay_time", typeof(string));
  3168. table.Columns.Add("seller_memo", typeof(string));
  3169. if (designIds.Count > 0)
  3170. {
  3171. string shopId = "";
  3172. string productId = "";
  3173. foreach (var designInfo in designIds)
  3174. {
  3175. shopId = designInfo.Key;
  3176. productId = designInfo.Value;
  3177. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3178. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3179. if (dt.Rows.Count > 0)
  3180. {
  3181. foreach (DataRow row in dt.Rows)
  3182. {
  3183. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3184. {
  3185. DataRow data = table.NewRow();
  3186. data["ctid"] = row["ctid"].ToString();
  3187. data["tid"] = row["tid"].ToString();
  3188. data["seller_nick"] = ceErpShop.ShopName;
  3189. data["pay_time"] = row["pay_time"].ToString();
  3190. data["seller_memo"] = row["seller_memo"].ToString();
  3191. data["productName"] = ceErpProduct.PType;
  3192. table.Rows.Add(data);
  3193. }
  3194. }
  3195. }
  3196. }
  3197. }
  3198. writeGridDataTableJson(table.Rows.Count, table);
  3199. }
  3200. private object rushLockObject = new object();
  3201. public void set_erp_grabingorder()
  3202. {
  3203. if (UrlPostParmsCheck("ctid"))
  3204. {
  3205. int total = CurrentUser.User.Person.Total;
  3206. int userId = CurrentUser.User.ID;
  3207. int noFinish = CurrentUser.User.Person.NoFinish;
  3208. int finalization = CurrentUser.User.Person.Finalization;
  3209. string eids = GetPostString("ctid");
  3210. string key = "RushKey_" + userId;
  3211. int count = 0;
  3212. if (erpRedis.RedisHelper.KeyExists(key))
  3213. {
  3214. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3215. if (redisCount != null)
  3216. {
  3217. count = Convert.ToInt32(redisCount);
  3218. }
  3219. }
  3220. if (count >= total)
  3221. {
  3222. returnErrorMsg("半小时内已经抢" + total + "单");
  3223. return;
  3224. }
  3225. string[] ctidlist = eids.Split(',');
  3226. if (count + ctidlist.Length > total)
  3227. {
  3228. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3229. return;
  3230. }
  3231. int itag = 0;
  3232. lock (rushLockObject)
  3233. {
  3234. if (ctidlist.Length > 0)
  3235. {
  3236. string[] dtList = new string[ctidlist.Length];
  3237. for (int i = 0; i < ctidlist.Length; i++)
  3238. {
  3239. dtList[i] = "'" + ctidlist[i] + "'";
  3240. }
  3241. 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"));
  3242. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3243. if (dt_user.Rows.Count > 0)
  3244. {
  3245. int doing = 0;//未定稿
  3246. int finish = 0;//已完成
  3247. foreach (DataRow dr in dt_user.Rows)
  3248. {
  3249. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3250. {
  3251. doing++;
  3252. }
  3253. else
  3254. {
  3255. finish++;
  3256. }
  3257. }
  3258. if (doing >= noFinish)
  3259. {
  3260. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3261. return;
  3262. }
  3263. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3264. {
  3265. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3266. return;
  3267. }
  3268. }
  3269. //校验选择单子状态
  3270. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3271. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3272. if (dt.Rows.Count > 0)
  3273. {
  3274. List<string> list = new List<string>();
  3275. foreach (DataRow dr in dt.Rows)
  3276. {
  3277. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3278. {
  3279. list.Add(dr["ctid"].ToString());
  3280. }
  3281. }
  3282. if (list.Count > 0)
  3283. {
  3284. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3285. return;
  3286. }
  3287. }
  3288. foreach (string ctid in ctidlist)
  3289. {
  3290. CeErpTradeCell entity = null;
  3291. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3292. if (entity != null)
  3293. {
  3294. entity.OrderState = 3;
  3295. entity.DesignUserId = CurrentUser.UserID;
  3296. entity.WaitDesignTime = DateTime.Now;
  3297. entity.StartDesignTime = DateTime.Now;
  3298. entity.Update();
  3299. commonHelper.UpdateRelationOrder(entity.ctid);
  3300. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3301. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3302. itag++;
  3303. }
  3304. }
  3305. }
  3306. }
  3307. count += ctidlist.Length;
  3308. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3309. if (itag == 0)
  3310. returnErrorMsg("没有找到相关订单");
  3311. else
  3312. returnSuccessMsg("抢单成功!");
  3313. return;
  3314. }
  3315. }
  3316. public void get_erp_waitorderlist()
  3317. {
  3318. DataStruct dStruct = GetPostStruct();
  3319. List<string> lw = new List<string>();
  3320. string tid = GetPostString("ctid");
  3321. if (tid.Length > 0)
  3322. {
  3323. string select_tid = getTidByCtid(tid);
  3324. lw.Add(string.Format("tid='{0}'", select_tid));
  3325. }
  3326. string shopname = GetPostString("shopname");
  3327. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3328. string buyernick = GetPostString("buyer_nick");
  3329. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3330. string customer = GetPostString("customer");
  3331. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3332. string design = GetPostString("design");
  3333. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3334. string orderState = GetPostString("orderState");
  3335. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3336. string supplier = GetPostString("supplier");
  3337. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3338. string sellermemo = GetPostString("seller_memo");
  3339. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3340. string otherMemo = GetPostString("otherMemo");
  3341. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3342. string address = GetPostString("address");
  3343. 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));
  3344. string date1 = GetPostString("date1");
  3345. string date2 = GetPostString("date2");
  3346. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3347. if (dw.Length > 0) lw.Add(dw);
  3348. string price1 = GetPostString("price1");
  3349. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3350. string price2 = GetPostString("price2");
  3351. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3352. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3353. lw.Add(string.Format("IsSample != 2 "));
  3354. lw.Add(string.Format("OrderState = 5 "));
  3355. lw.Add(string.Format("IsRefund<={0}", 1));
  3356. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3357. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3358. string pagesize = GetPostString("pagesize");
  3359. if (pagesize != null)
  3360. {
  3361. dStruct.PageSize = 200;
  3362. }
  3363. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3364. if (dt != null)
  3365. {
  3366. foreach (DataRow dr in dt.Rows)
  3367. {
  3368. 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();
  3369. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3370. {
  3371. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3372. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3373. entity.SupplierId = suid;
  3374. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3375. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3376. entity.Update();
  3377. }
  3378. }
  3379. }
  3380. writeGridDataTableJson(dStruct.TotalCount, dt);
  3381. }
  3382. public void get_erp_supplierwaitorderlist()
  3383. {
  3384. DataStruct dStruct = GetPostStruct();
  3385. List<string> lw = new List<string>();
  3386. string tid = GetPostString("ctid");
  3387. if (tid.Length > 0)
  3388. {
  3389. string select_tid = getTidByCtid(tid);
  3390. lw.Add(string.Format("tid='{0}'", select_tid));
  3391. }
  3392. string shopname = GetPostString("shopname");
  3393. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3394. string sellermemo = GetPostString("seller_memo");
  3395. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3396. string date1 = GetPostString("date1");
  3397. string date2 = GetPostString("date2");
  3398. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3399. if (dw.Length > 0) lw.Add(dw);
  3400. lw.Add(string.Format("OrderState = 5 "));
  3401. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3402. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3403. {
  3404. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3405. }
  3406. string supplier = GetPostString("supplier");
  3407. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3408. {
  3409. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3410. }
  3411. lw.Add(string.Format("IsRefund<={0}", 1));
  3412. dStruct.Order = "FinishDesignTime desc";
  3413. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3414. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3415. if (dt != null)
  3416. {
  3417. foreach (DataRow dr in dt.Rows)
  3418. {
  3419. 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();
  3420. }
  3421. }
  3422. writeGridDataTableJson(dStruct.TotalCount, dt);
  3423. }
  3424. public void upd_erp_verifytosupplier()
  3425. {
  3426. if (UrlPostParmsCheck("ctid"))
  3427. {
  3428. string eids = GetPostString("ctid");
  3429. CeErpTradeCell entity = null;
  3430. string[] eidsList = eids.Split(',');
  3431. if (eidsList.Length <= 0)
  3432. {
  3433. returnErrorMsg("订单号不能空");
  3434. return;
  3435. }
  3436. List<string> tLst = new List<string>();
  3437. foreach (string ctidstr in eidsList)
  3438. {
  3439. tLst.Add("'" + ctidstr + "'");
  3440. CeErpDataSendOrderInfo.createObject(ctidstr);
  3441. }
  3442. string needtids = string.Join(",", tLst.ToArray());
  3443. StringBuilder sql = new StringBuilder();
  3444. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3445. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3446. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3447. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3448. returnSuccessMsg("操作成功!");
  3449. return;
  3450. /**foreach (string ctidstr in eidsList)
  3451. {
  3452. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3453. if (entity != null)
  3454. {
  3455. if (entity.SupplierId == 0)
  3456. {
  3457. continue;
  3458. }
  3459. entity.IsVerifyToSupplier = true;
  3460. if (entity.IsReturn == 1) //1是供应商打回
  3461. {
  3462. entity.IsReturn = 0;
  3463. }
  3464. entity.FinishPlaceTime = DateTime.Now;
  3465. entity.PlaceUserId = CurrentUser.UserID;
  3466. entity.Update();
  3467. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3468. }
  3469. }
  3470. returnSuccessMsg("操作成功!");
  3471. return;**/
  3472. }
  3473. }
  3474. public void upd_erp_supplierback()
  3475. {
  3476. if (UrlPostParmsCheck("ctid"))
  3477. {
  3478. string eid = GetPostString("ctid");
  3479. string reason = GetPostString("returnreason");
  3480. CeErpTradeCell entity = null;
  3481. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3482. if (entity != null)
  3483. {
  3484. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3485. {
  3486. string key = "return_order_" + entity.SupplierId;
  3487. List<string> list = new List<string>();
  3488. if (RedisHelper.HasKey(key))
  3489. {
  3490. object data = RedisHelper.StringGet(key);
  3491. list = Convert.ToString(data).Split(',').ToList();
  3492. }
  3493. list.Add(eid);
  3494. RedisHelper.StringSet(key, string.Join(",", list));
  3495. }
  3496. entity.IsVerifyToSupplier = false;
  3497. entity.IsReturn = 1;
  3498. entity.ReturnTime = DateTime.Now;
  3499. entity.ReturnReason = reason;
  3500. if (entity.OrderState == 6)
  3501. {
  3502. entity.OrderState = 5;
  3503. }
  3504. entity.Update();
  3505. CeErpSukuraData.createInfo(entity.ctid, 5);
  3506. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3507. returnSuccessMsg("操作成功!");
  3508. return;
  3509. }
  3510. returnErrorMsg("找不到订单记录");
  3511. }
  3512. }
  3513. public void upd_erp_toaftersaleorder()
  3514. {
  3515. if (UrlPostParmsCheck("ctid"))
  3516. {
  3517. string eid = GetPostString("ctid");
  3518. string reason = GetPostString("returnreason");
  3519. CeErpTradeCell entity = null;
  3520. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3521. if (entity != null)
  3522. {
  3523. if (entity.isAfterSaleOrder != 1)
  3524. {
  3525. returnErrorMsg("带S的售后单才能打回给售后");
  3526. return;
  3527. }
  3528. if (entity.OrderState >= 5)
  3529. {
  3530. returnErrorMsg("已经设计完成了不能打回给售后");
  3531. return;
  3532. }
  3533. entity.OrderState = 0;
  3534. entity.IsReturn = 3;
  3535. entity.ReturnTime = DateTime.Now;
  3536. entity.UpdateTime = DateTime.Now;
  3537. entity.ReturnReason = reason;
  3538. entity.Update();
  3539. CeErpSukuraData.createInfo(entity.ctid, 5);
  3540. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3541. returnSuccessMsg("操作成功!");
  3542. return;
  3543. }
  3544. returnErrorMsg("找不到订单记录");
  3545. }
  3546. }
  3547. public void upd_erp_aftersaletodesign()
  3548. {
  3549. if (UrlPostParmsCheck("ctid"))
  3550. {
  3551. string eid = GetPostString("ctid");
  3552. CeErpTradeCell entity = null;
  3553. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3554. if (entity != null)
  3555. {
  3556. entity.OrderState = 3;
  3557. entity.IsReturn = 0;
  3558. entity.UpdateTime = DateTime.Now;
  3559. entity.Update();
  3560. CeErpSukuraData.createInfo(entity.ctid, 5);
  3561. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3562. returnSuccessMsg("操作成功!");
  3563. return;
  3564. }
  3565. returnErrorMsg("找不到订单记录");
  3566. }
  3567. }
  3568. public void assign_erp_supplier()
  3569. {
  3570. if (UrlPostParmsCheck("ctid"))
  3571. {
  3572. string eids = GetPostString("ctid");
  3573. int sid = GetPostInt("SupplierName");
  3574. string fromTag = GetPostString("tag");
  3575. string[] eidList = eids.Split(',');
  3576. if (eidList.Length <= 0)
  3577. {
  3578. returnErrorMsg("指派不能为空");
  3579. return;
  3580. }
  3581. string errMsg = "";
  3582. string suname = commonHelper.getSupplierNameById(sid);
  3583. foreach (string ctid in eidList)
  3584. {
  3585. CeErpTradeCell entity = null;
  3586. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3587. if (entity != null)
  3588. {
  3589. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3590. {
  3591. errMsg += (ctid + "指派失败!!!");
  3592. continue;
  3593. }
  3594. entity.SupplierId = sid;
  3595. entity.Update();
  3596. commonHelper.UpdateRelationOrder(entity.ctid);
  3597. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3598. if (entity.OrderState >= 6)
  3599. {
  3600. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3601. //{
  3602. // string msl = entity.MakeSupplier;
  3603. // string[] mslist = msl.Split(',');
  3604. // 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);
  3605. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3606. //}
  3607. //else
  3608. //{
  3609. StringBuilder sql = new StringBuilder();
  3610. 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);
  3611. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3612. //}
  3613. }
  3614. }
  3615. else
  3616. {
  3617. continue;
  3618. }
  3619. }
  3620. if (errMsg.Length > 0)
  3621. {
  3622. returnErrorMsg(errMsg);
  3623. return;
  3624. }
  3625. returnSuccessMsg("操作成功!");
  3626. return;
  3627. }
  3628. }
  3629. public void assign_erp_makesupplier()
  3630. {
  3631. if (UrlPostParmsCheck("ctid"))
  3632. {
  3633. string eids = GetPostString("ctid");
  3634. string sname = GetPostString("SupplierName");
  3635. string[] eidList = eids.Split(',');
  3636. if (eidList.Length <= 0)
  3637. {
  3638. returnErrorMsg("指派不能为空");
  3639. return;
  3640. }
  3641. List<string> tLst = new List<string>();
  3642. foreach (string ctid in eidList)
  3643. {
  3644. CeErpTradeCell entity = null;
  3645. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3646. if (entity != null)
  3647. {
  3648. entity.MakeSupplier = sname;
  3649. entity.Update();
  3650. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3651. tLst.Add("'" + ctid + "'");
  3652. }
  3653. else
  3654. {
  3655. continue;
  3656. }
  3657. }
  3658. string ctids = string.Join(",", tLst.ToArray());
  3659. StringBuilder sql2 = new StringBuilder();
  3660. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3661. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3662. returnSuccessMsg("操作成功!");
  3663. return;
  3664. }
  3665. }
  3666. public void ins_erp_returnreason()
  3667. {
  3668. if (UrlPostParmsCheck("ctid"))
  3669. {
  3670. string eid = GetPostString("ctid");
  3671. CeErpTradeCell entity = null;
  3672. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3673. string userpost = CurrentUser.UserPost.Post.Code;
  3674. if (entity != null)
  3675. {
  3676. bool isPlace = false;
  3677. if (entity.OrderState > 6)
  3678. {
  3679. returnErrorMsg("已发货无法打回!");
  3680. return;
  3681. }
  3682. if (entity.OrderState == 6)
  3683. {
  3684. isPlace = true;
  3685. }
  3686. bool isNeedUpdateCell2 = false;
  3687. if (entity.OrderState >= 6)
  3688. {
  3689. isNeedUpdateCell2 = true;
  3690. }
  3691. int returnTag = 2;
  3692. if (userpost == "Supplier")
  3693. {
  3694. returnTag = 1;
  3695. }
  3696. int toType = GetPostInt("totype");
  3697. string fromType = "3";
  3698. if (entity.OrderState < 5)
  3699. {
  3700. fromType = "3";
  3701. }
  3702. else
  3703. {
  3704. fromType = "4";
  3705. }
  3706. if (entity.IsXianHuo == 0)
  3707. {
  3708. if (returnTag == 2)
  3709. {
  3710. if (toType == 1)
  3711. {
  3712. entity.OrderState = 0;
  3713. entity.ReturnUserType = 1;
  3714. string clearman = GetPostString("clearman");
  3715. if (!string.IsNullOrEmpty(clearman))
  3716. {
  3717. entity.DesignUserId = 0;
  3718. }
  3719. }
  3720. else
  3721. {
  3722. entity.OrderState = 3;
  3723. entity.ReturnUserType = 2;
  3724. }
  3725. entity.IsReadTag = 1;
  3726. }
  3727. else if (returnTag == 1)
  3728. {
  3729. entity.OrderState = 5;
  3730. }
  3731. entity.IsVerifyToSupplier = false;
  3732. }
  3733. if (entity.IsXianHuo == 1)
  3734. {
  3735. entity.OrderState = 5;
  3736. }
  3737. entity.UnusualTag = 0;
  3738. entity.UnusualTime = null;
  3739. entity.UnusualCon = "";
  3740. entity.IsReturn = returnTag;
  3741. entity.ReturnTime = DateTime.Now;
  3742. entity.UpdateTime = DateTime.Now;
  3743. entity.ReturnReason = GetPostString("returnreason");
  3744. entity.Update();
  3745. if (entity.OrderState == 3)
  3746. {
  3747. ApiVo apiVo = new ApiVo();
  3748. apiVo.orderNumber = entity.ctid;
  3749. apiVo.actionName = "rebutDesign";
  3750. apiVo.orderRemarks = entity.ReturnReason;
  3751. designHelper.API_WorkCore(apiVo);//rebutDesign
  3752. }
  3753. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3754. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3755. {
  3756. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3757. }
  3758. CeErpSukuraData.createInfo(entity.ctid, 5);
  3759. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3760. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3761. if (isPlace)
  3762. {
  3763. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3764. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3765. if (dth != null && dth.Rows.Count > 0)
  3766. {
  3767. dataSendOrderBean dataSendOrderBean = null;
  3768. foreach (DataRow item in dth.Rows)
  3769. {
  3770. try
  3771. {
  3772. dataSendOrderBean = new dataSendOrderBean();
  3773. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3774. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3775. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3776. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3777. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3778. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3779. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3780. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3781. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3782. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3783. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3784. dataSendOrderBean.Radio1723534706288 = "打回";
  3785. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3786. if (result != null)
  3787. {
  3788. if ("0".Equals(result.errcode))
  3789. {
  3790. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3791. }
  3792. else
  3793. {
  3794. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3795. }
  3796. }
  3797. }
  3798. catch (Exception ex)
  3799. {
  3800. }
  3801. }
  3802. }
  3803. }
  3804. if (isNeedUpdateCell2)
  3805. {
  3806. if (entity.MakeSupplier.IndexOf(",") != -1)
  3807. {
  3808. StringBuilder sql2 = new StringBuilder();
  3809. 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);
  3810. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3811. }
  3812. else
  3813. {
  3814. StringBuilder sql2 = new StringBuilder();
  3815. 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);
  3816. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3817. }
  3818. }
  3819. returnSuccessMsg("操作成功!");
  3820. return;
  3821. }
  3822. returnErrorMsg("找不到订单记录");
  3823. }
  3824. }
  3825. public void cyt_erp_returnreason()
  3826. {
  3827. if (UrlPostParmsCheck("ctid"))
  3828. {
  3829. string eid = GetPostString("ctid");
  3830. CeErpTradeCell entity = null;
  3831. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3832. string userpost = CurrentUser.UserPost.Post.Code;
  3833. if (entity != null)
  3834. {
  3835. if (entity.OrderState > 6)
  3836. {
  3837. returnErrorMsg("已发货无法打回!");
  3838. return;
  3839. }
  3840. JObject jsonObject = new JObject
  3841. {
  3842. { "Userid", "77886" },
  3843. { "Pwd", "lt666888" },
  3844. { "LTOrderId",eid }
  3845. };
  3846. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3847. JObject jsonObjects = JObject.Parse(response);
  3848. string msg = (string)jsonObjects["msg"];
  3849. if (msg != "取消成功")
  3850. {
  3851. returnErrorMsg(msg);
  3852. return;
  3853. }
  3854. bool isNeedUpdateCell2 = false;
  3855. if (entity.OrderState >= 6)
  3856. {
  3857. isNeedUpdateCell2 = true;
  3858. }
  3859. int returnTag = 2;
  3860. if (userpost == "Supplier")
  3861. {
  3862. returnTag = 1;
  3863. }
  3864. if (entity.IsXianHuo == 0)
  3865. {
  3866. if (returnTag == 2)
  3867. {
  3868. int toType = GetPostInt("totype");
  3869. if (toType == 1)
  3870. {
  3871. entity.OrderState = 0;
  3872. entity.ReturnUserType = 1;
  3873. }
  3874. else
  3875. {
  3876. entity.OrderState = 4;
  3877. entity.ReturnUserType = 2;
  3878. }
  3879. entity.IsReadTag = 1;
  3880. }
  3881. else if (returnTag == 1)
  3882. {
  3883. entity.OrderState = 5;
  3884. }
  3885. entity.IsVerifyToSupplier = false;
  3886. }
  3887. entity.UnusualTag = 0;
  3888. entity.UnusualTime = null;
  3889. entity.UnusualCon = "";
  3890. entity.IsReturn = returnTag;
  3891. entity.ReturnTime = DateTime.Now;
  3892. entity.ReturnReason = GetPostString("returnreason");
  3893. entity.Update();
  3894. if (entity.OrderState == 4)
  3895. {
  3896. ApiVo apiVo = new ApiVo();
  3897. apiVo.orderNumber = entity.ctid;
  3898. apiVo.actionName = "rebutDesign";
  3899. apiVo.orderRemarks = entity.ReturnReason;
  3900. designHelper.API_WorkCore(apiVo);//rebutDesign
  3901. }
  3902. CeErpSukuraData.createInfo(entity.ctid, 5);
  3903. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3904. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3905. if (isNeedUpdateCell2)
  3906. {
  3907. if (entity.MakeSupplier.IndexOf(",") != -1)
  3908. {
  3909. StringBuilder sql2 = new StringBuilder();
  3910. 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);
  3911. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3912. }
  3913. else
  3914. {
  3915. StringBuilder sql2 = new StringBuilder();
  3916. 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);
  3917. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3918. }
  3919. }
  3920. returnSuccessMsg("操作成功!");
  3921. return;
  3922. }
  3923. returnErrorMsg("找不到订单记录");
  3924. }
  3925. }
  3926. public void upd_erp_xianhuoreturntag()
  3927. {
  3928. if (UrlPostParmsCheck("ctid"))
  3929. {
  3930. string eids = GetPostString("ctid");
  3931. string[] ctids = eids.Split(',');
  3932. foreach (string ctid in ctids)
  3933. {
  3934. CeErpTradeCell entity = null;
  3935. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3936. if (entity != null)
  3937. {
  3938. entity.IsReturn = 0;
  3939. entity.Update();
  3940. CeErpSukuraData.createInfo(entity.ctid, 5);
  3941. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3942. }
  3943. }
  3944. returnSuccessMsg("操作成功!");
  3945. return;
  3946. }
  3947. }
  3948. public void get_erp_waitdeliverylist()
  3949. {
  3950. DataStruct dStruct = GetPostStruct();
  3951. List<string> lw = new List<string>();
  3952. string tid = GetPostString("ctid");
  3953. if (tid.Length > 0)
  3954. {
  3955. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3956. if (tid.Length > 5)
  3957. {
  3958. List<string> tids = getTidByCtidLike(tid);
  3959. if (tids.Count > 0 && tids.Count < 10)
  3960. {
  3961. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3962. List<string> receiverIds = getReceiverIdByCtidLike(tids);
  3963. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  3964. {
  3965. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  3966. }
  3967. }
  3968. }
  3969. lw.Add(tid_sql);
  3970. }
  3971. string shopname = GetPostString("shopname");
  3972. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3973. string buyernick = GetPostString("buyer_nick");
  3974. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3975. //if (tid.Length == 0 && buyernick.Length == 0)
  3976. //{
  3977. // lw.Add(string.Format("IsRefund<={0}", 1));
  3978. //}
  3979. string customer = GetPostString("customer");
  3980. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3981. string design = GetPostString("design");
  3982. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3983. string orderState = GetPostString("orderState");
  3984. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3985. string address = GetPostString("address");
  3986. 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));
  3987. string sellermemo = GetPostString("seller_memo");
  3988. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3989. string supplier = GetPostString("supplier");
  3990. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3991. string OrderArea = GetPostString("order_area");
  3992. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3993. string placedate1 = GetPostString("placedate1");
  3994. string placedate2 = GetPostString("placedate2");
  3995. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3996. if (fdw.Length > 0) lw.Add(fdw);
  3997. string price1 = GetPostString("price1");
  3998. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3999. string price2 = GetPostString("price2");
  4000. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4001. string unusualCon = GetPostString("unusualcon");
  4002. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4003. string otherMemo = GetPostString("otherMemo");
  4004. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4005. string posTag = CurrentUser.UserPost.Post.Code;
  4006. if (posTag == "Supplier")
  4007. {
  4008. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4009. }
  4010. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4011. lw.Add(string.Format("type != 'PDD' "));
  4012. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4013. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4015. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4016. writeGridDataTableJson(dStruct.TotalCount, dt);
  4017. }
  4018. public void get_erp_changedeliverylist()
  4019. {
  4020. DataStruct dStruct = GetPostStruct();
  4021. List<string> lw = new List<string>();
  4022. string tid = GetPostString("ctid");
  4023. if (tid.Length > 0)
  4024. {
  4025. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4026. if (tid.Length > 5)
  4027. {
  4028. List<string> tids = getTidByCtidLike(tid);
  4029. if (tids.Count > 0 && tids.Count < 10)
  4030. {
  4031. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4032. }
  4033. }
  4034. lw.Add(tid_sql);
  4035. }
  4036. string shopname = GetPostString("shopname");
  4037. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4038. string buyernick = GetPostString("buyer_nick");
  4039. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4040. //if (tid.Length == 0 && buyernick.Length == 0)
  4041. //{
  4042. // lw.Add(string.Format("IsRefund<={0}", 1));
  4043. //}
  4044. string customer = GetPostString("customer");
  4045. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4046. string design = GetPostString("design");
  4047. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4048. string orderState = GetPostString("orderState");
  4049. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4050. string address = GetPostString("address");
  4051. 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));
  4052. string sellermemo = GetPostString("seller_memo");
  4053. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4054. string supplier = GetPostString("supplier");
  4055. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4056. string OrderArea = GetPostString("order_area");
  4057. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4058. string placedate1 = GetPostString("placedate1");
  4059. string placedate2 = GetPostString("placedate2");
  4060. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4061. if (fdw.Length > 0) lw.Add(fdw);
  4062. string price1 = GetPostString("price1");
  4063. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4064. string price2 = GetPostString("price2");
  4065. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4066. string unusualCon = GetPostString("unusualcon");
  4067. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4068. string otherMemo = GetPostString("otherMemo");
  4069. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4070. string posTag = CurrentUser.UserPost.Post.Code;
  4071. if (posTag == "Supplier")
  4072. {
  4073. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4074. }
  4075. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4076. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4077. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4078. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4079. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4080. /*if (tid.Length > 0)
  4081. {
  4082. List<string> tids = new List<string>();
  4083. if (dt != null && dt.Rows.Count > 0)
  4084. {
  4085. foreach (DataRow item in dt.Rows)
  4086. {
  4087. tids.Add("'" + item["tid"] + "'");
  4088. }
  4089. }
  4090. if (tids.Count > 0)
  4091. {
  4092. lw.RemoveAt(0);
  4093. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4094. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4095. dt = WebCache.GetData("view_erptradecell", dStruct);
  4096. }
  4097. }*/
  4098. writeGridDataTableJson(dStruct.TotalCount, dt);
  4099. }
  4100. public void get_erp_pddderiving()
  4101. {
  4102. DataStruct dStruct = GetPostStruct();
  4103. List<string> lw = new List<string>();
  4104. string tid = GetPostString("ctid");
  4105. if (tid.Length > 0)
  4106. {
  4107. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4108. if (tid.Length > 5)
  4109. {
  4110. List<string> tids = getTidByCtidLike(tid);
  4111. if (tids.Count > 0 && tids.Count < 10)
  4112. {
  4113. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4114. List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4115. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4116. {
  4117. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4118. }
  4119. }
  4120. }
  4121. lw.Add(tid_sql);
  4122. }
  4123. string shopname = GetPostString("shopname");
  4124. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4125. string buyernick = GetPostString("buyer_nick");
  4126. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4127. //if (tid.Length == 0 && buyernick.Length == 0)
  4128. //{
  4129. // lw.Add(string.Format("IsRefund<={0}", 1));
  4130. //}
  4131. string customer = GetPostString("customer");
  4132. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4133. string design = GetPostString("design");
  4134. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4135. string orderState = GetPostString("orderState");
  4136. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4137. string address = GetPostString("address");
  4138. 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));
  4139. string sellermemo = GetPostString("seller_memo");
  4140. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4141. string supplier = GetPostString("supplier");
  4142. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4143. string OrderArea = GetPostString("order_area");
  4144. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4145. string placedate1 = GetPostString("placedate1");
  4146. string placedate2 = GetPostString("placedate2");
  4147. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4148. if (fdw.Length > 0) lw.Add(fdw);
  4149. string price1 = GetPostString("price1");
  4150. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4151. string price2 = GetPostString("price2");
  4152. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4153. string unusualCon = GetPostString("unusualcon");
  4154. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4155. string posTag = CurrentUser.UserPost.Post.Code;
  4156. if (posTag == "Supplier")
  4157. {
  4158. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4159. }
  4160. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4161. lw.Add(string.Format("type = 'PDD' "));
  4162. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4163. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4164. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4165. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4166. /*if (tid.Length > 0)
  4167. {
  4168. List<string> tids = new List<string>();
  4169. if (dt != null && dt.Rows.Count > 0)
  4170. {
  4171. foreach (DataRow item in dt.Rows)
  4172. {
  4173. tids.Add("'" + item["tid"] + "'");
  4174. }
  4175. }
  4176. if (tids.Count > 0)
  4177. {
  4178. lw.RemoveAt(0);
  4179. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4180. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4181. dt = WebCache.GetData("view_erptradecell", dStruct);
  4182. }
  4183. }*/
  4184. writeGridDataTableJson(dStruct.TotalCount, dt);
  4185. }
  4186. public void get_erp_jdderiving()
  4187. {
  4188. DataStruct dStruct = GetPostStruct();
  4189. List<string> lw = new List<string>();
  4190. string tid = GetPostString("ctid");
  4191. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4192. string shopname = GetPostString("shopname");
  4193. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4194. string buyernick = GetPostString("buyer_nick");
  4195. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4196. //if (tid.Length == 0 && buyernick.Length == 0)
  4197. //{
  4198. // lw.Add(string.Format("IsRefund<={0}", 1));
  4199. //}
  4200. string customer = GetPostString("customer");
  4201. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4202. string design = GetPostString("design");
  4203. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4204. string orderState = GetPostString("orderState");
  4205. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4206. string address = GetPostString("address");
  4207. 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));
  4208. string sellermemo = GetPostString("seller_memo");
  4209. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4210. string supplier = GetPostString("supplier");
  4211. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4212. string OrderArea = GetPostString("order_area");
  4213. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4214. string placedate1 = GetPostString("placedate1");
  4215. string placedate2 = GetPostString("placedate2");
  4216. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4217. if (fdw.Length > 0) lw.Add(fdw);
  4218. string price1 = GetPostString("price1");
  4219. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4220. string price2 = GetPostString("price2");
  4221. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4222. string unusualCon = GetPostString("unusualcon");
  4223. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4224. string posTag = CurrentUser.UserPost.Post.Code;
  4225. if (posTag == "Supplier")
  4226. {
  4227. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4228. }
  4229. lw.Add(string.Format("OrderState = 6 "));
  4230. lw.Add(string.Format("type = 'JD' "));
  4231. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4232. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4233. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4234. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4235. writeGridDataTableJson(dStruct.TotalCount, dt);
  4236. }
  4237. public void get_erp_demoorderlist()
  4238. {
  4239. DataStruct dStruct = GetPostStruct();
  4240. List<string> lw = new List<string>();
  4241. string tid = GetPostString("ctid");
  4242. if (tid.Length > 0)
  4243. {
  4244. string select_tid = getTidByCtid(tid);
  4245. lw.Add(string.Format("tid='{0}'", select_tid));
  4246. }
  4247. string shopname = GetPostString("shopname");
  4248. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4249. string buyernick = GetPostString("buyer_nick");
  4250. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4251. string customer = GetPostString("customer");
  4252. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4253. string design = GetPostString("design");
  4254. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4255. string orderState = GetPostString("orderState");
  4256. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4257. string address = GetPostString("address");
  4258. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4259. string sellermemo = GetPostString("seller_memo");
  4260. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4261. string supplier = GetPostString("supplier");
  4262. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4263. string OrderArea = GetPostString("order_area");
  4264. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4265. string date1 = GetPostString("date1");
  4266. string date2 = GetPostString("date2");
  4267. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4268. if (dw.Length > 0) lw.Add(dw);
  4269. string price1 = GetPostString("price1");
  4270. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4271. string price2 = GetPostString("price2");
  4272. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4273. string posTag = CurrentUser.UserPost.Post.Code;
  4274. if (posTag == "Supplier")
  4275. {
  4276. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4277. }
  4278. //lw.Add(string.Format("OrderState = 6 "));
  4279. lw.Add(string.Format("IsSample={0}", 3));
  4280. lw.Add(string.Format("IsRefund<={0}", 1));
  4281. dStruct.Order = "pay_time desc";
  4282. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4283. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4284. writeGridDataTableJson(dStruct.TotalCount, dt);
  4285. }
  4286. public void save_erp_checkmemo()
  4287. {
  4288. if (UrlPostParmsCheck("ctid"))
  4289. {
  4290. string ctid = GetPostString("ctid");
  4291. CeErpTradeCell entity = null;
  4292. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4293. if (entity != null)
  4294. {
  4295. entity.CheckMemo = GetPostString("CheckMemo");
  4296. entity.Update();
  4297. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4298. if (trade != null)
  4299. {
  4300. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4301. }
  4302. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4303. returnSuccessMsg("保存成功!");
  4304. return;
  4305. }
  4306. returnErrorMsg("找不到记录");
  4307. }
  4308. }
  4309. public void get_erp_returnlist()
  4310. {
  4311. DataStruct dStruct = GetPostStruct();
  4312. List<string> lw = new List<string>();
  4313. string tid = GetPostString("ctid");
  4314. if (tid.Length > 0)
  4315. {
  4316. string select_tid = getTidByCtid(tid);
  4317. lw.Add(string.Format("tid='{0}'", select_tid));
  4318. }
  4319. string shopname = GetPostString("shopname");
  4320. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4321. string buyernick = GetPostString("buyer_nick");
  4322. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4323. string customer = GetPostString("customer");
  4324. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4325. string design = GetPostString("design");
  4326. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4327. string orderState = GetPostString("orderState");
  4328. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4329. string address = GetPostString("address");
  4330. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4331. string sellermemo = GetPostString("seller_memo");
  4332. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4333. string supplier = GetPostString("supplier");
  4334. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4335. string date1 = GetPostString("date1");
  4336. string date2 = GetPostString("date2");
  4337. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4338. if (dw.Length > 0) lw.Add(dw);
  4339. string bdate1 = GetPostString("backdate1");
  4340. string bdate2 = GetPostString("backdate2");
  4341. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4342. if (dw_back.Length > 0) lw.Add(dw_back);
  4343. string price1 = GetPostString("price1");
  4344. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4345. string price2 = GetPostString("price2");
  4346. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4347. lw.Add(string.Format("IsReturn>0"));
  4348. lw.Add(string.Format("IsXianHuo=0"));
  4349. lw.Add(string.Format("IsReturn!=3"));
  4350. string backtype = GetPostString("backtype");
  4351. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4352. dStruct.Order = "FinishDesignTime desc";
  4353. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4354. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4355. writeGridDataTableJson(dStruct.TotalCount, dt);
  4356. }
  4357. public void get_erp_today_sumreturn()
  4358. {
  4359. DataStruct dStruct = GetPostStruct();
  4360. List<string> lw = new List<string>();
  4361. string bdate1 = GetPostString("returnTimeS");
  4362. string bdate2 = GetPostString("returnTimeE");
  4363. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4364. if (dw_back.Length > 0) lw.Add(dw_back);
  4365. lw.Add(string.Format("IsReturn=0"));
  4366. lw.Add(string.Format("IsXianHuo=0"));
  4367. string mainWhere = string.Join(" and ", lw.ToArray());
  4368. string sql = "";
  4369. if (dw_back.Length > 0)
  4370. {
  4371. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4372. }
  4373. else
  4374. {
  4375. 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 + "'";
  4376. }
  4377. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4378. decimal total = 0, today_finish = 0;
  4379. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4380. {
  4381. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4382. }
  4383. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4384. {
  4385. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4386. }
  4387. var res = new
  4388. {
  4389. data = total,
  4390. data1 = today_finish,
  4391. };
  4392. string ro_jsond = JsonConvert.SerializeObject(res);
  4393. returnSuccess(ro_jsond);
  4394. return;
  4395. }
  4396. public void get_erp_allreturnlist()
  4397. {
  4398. DataStruct dStruct = GetPostStruct();
  4399. List<string> lw = new List<string>();
  4400. string tid = GetPostString("ctid");
  4401. if (tid.Length > 0)
  4402. {
  4403. string select_tid = getTidByCtid(tid);
  4404. lw.Add(string.Format("tid='{0}'", select_tid));
  4405. }
  4406. string shopname = GetPostString("shopname");
  4407. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4408. string buyernick = GetPostString("buyer_nick");
  4409. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4410. string customer = GetPostString("customer");
  4411. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4412. string design = GetPostString("design");
  4413. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4414. string orderState = GetPostString("orderState");
  4415. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4416. string address = GetPostString("address");
  4417. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4418. string sellermemo = GetPostString("seller_memo");
  4419. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4420. string supplier = GetPostString("supplier");
  4421. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4422. string date1 = GetPostString("date1");
  4423. string date2 = GetPostString("date2");
  4424. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4425. if (dw.Length > 0) lw.Add(dw);
  4426. string bdate1 = GetPostString("backdate1");
  4427. string bdate2 = GetPostString("backdate2");
  4428. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4429. if (dw_back.Length > 0) lw.Add(dw_back);
  4430. string price1 = GetPostString("price1");
  4431. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4432. string price2 = GetPostString("price2");
  4433. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4434. string backreason = GetPostString("backreason");
  4435. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4436. lw.Add(string.Format("IsXianHuo=0"));
  4437. lw.Add(string.Format("ReturnTime != ''"));
  4438. string backtype = GetPostString("backtype");
  4439. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4440. dStruct.Order = "FinishDesignTime desc";
  4441. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4442. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4443. writeGridDataTableJson(dStruct.TotalCount, dt);
  4444. }
  4445. public void get_erp_aftersalereturnlist()
  4446. {
  4447. DataStruct dStruct = GetPostStruct();
  4448. List<string> lw = new List<string>();
  4449. string tid = GetPostString("ctid");
  4450. if (tid.Length > 0)
  4451. {
  4452. string select_tid = getTidByCtid(tid);
  4453. lw.Add(string.Format("tid='{0}'", select_tid));
  4454. }
  4455. string shopname = GetPostString("shopname");
  4456. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4457. string buyernick = GetPostString("buyer_nick");
  4458. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4459. string customer = GetPostString("customer");
  4460. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4461. string design = GetPostString("design");
  4462. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4463. string orderState = GetPostString("orderState");
  4464. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4465. string address = GetPostString("address");
  4466. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4467. string sellermemo = GetPostString("seller_memo");
  4468. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4469. string supplier = GetPostString("supplier");
  4470. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4471. string date1 = GetPostString("date1");
  4472. string date2 = GetPostString("date2");
  4473. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4474. if (dw.Length > 0) lw.Add(dw);
  4475. string bdate1 = GetPostString("backdate1");
  4476. string bdate2 = GetPostString("backdate2");
  4477. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4478. if (dw_back.Length > 0) lw.Add(dw_back);
  4479. string price1 = GetPostString("price1");
  4480. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4481. string price2 = GetPostString("price2");
  4482. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4483. lw.Add(string.Format("IsReturn=3"));
  4484. string backtype = GetPostString("backtype");
  4485. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4486. string backreason = GetPostString("backreason");
  4487. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4488. dStruct.Order = "ReturnTime desc";
  4489. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4490. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4491. writeGridDataTableJson(dStruct.TotalCount, dt);
  4492. }
  4493. public void get_erp_xianhuoreturnlist()
  4494. {
  4495. DataStruct dStruct = GetPostStruct();
  4496. List<string> lw = new List<string>();
  4497. string tid = GetPostString("ctid");
  4498. if (tid.Length > 0)
  4499. {
  4500. string select_tid = getTidByCtid(tid);
  4501. lw.Add(string.Format("tid='{0}'", select_tid));
  4502. }
  4503. string shopname = GetPostString("shopname");
  4504. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4505. string buyernick = GetPostString("buyer_nick");
  4506. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4507. string customer = GetPostString("customer");
  4508. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4509. string design = GetPostString("design");
  4510. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4511. string orderState = GetPostString("orderState");
  4512. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4513. string address = GetPostString("address");
  4514. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4515. string sellermemo = GetPostString("seller_memo");
  4516. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4517. string supplier = GetPostString("supplier");
  4518. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4519. string OrderArea = GetPostString("order_area");
  4520. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4521. string date1 = GetPostString("date1");
  4522. string date2 = GetPostString("date2");
  4523. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4524. if (dw.Length > 0) lw.Add(dw);
  4525. string price1 = GetPostString("price1");
  4526. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4527. string price2 = GetPostString("price2");
  4528. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4529. string posTag = CurrentUser.UserPost.Post.Code;
  4530. if (posTag == "Supplier")
  4531. {
  4532. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4533. }
  4534. lw.Add(string.Format("OrderState=6 "));
  4535. lw.Add(string.Format("IsXianHuo=1 "));
  4536. lw.Add(string.Format("IsReturn>0 "));
  4537. lw.Add(string.Format("IsReturn!=3"));
  4538. lw.Add(string.Format("IsRefund<={0}", 1));
  4539. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4540. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4541. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4542. writeGridDataTableJson(dStruct.TotalCount, dt);
  4543. }
  4544. public void set_erp_orderdelivery()
  4545. {
  4546. if (UrlPostParmsCheck("ctid"))
  4547. {
  4548. string eid = GetPostString("ctid");
  4549. CeErpTradeCell entity = null;
  4550. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4551. if (entity != null)
  4552. {
  4553. if (entity.OrderState >= 7)
  4554. {
  4555. returnErrorMsg("此单已发货,无需重复发货");
  4556. return;
  4557. }
  4558. if (entity.OrderState != 6)
  4559. {
  4560. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4561. return;
  4562. }
  4563. string shop = GetPostString("seller_nick");
  4564. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4565. string comName = GetPostString("comName");
  4566. string comCode = GetPostString("comCode");
  4567. string outSid = GetPostString("outSid");
  4568. string deliveryType = GetPostString("deliveryType");
  4569. string deliveryMemo = GetPostString("deliveryMemo");
  4570. outSid = outSid.Trim();
  4571. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4572. if (mainEn == null)
  4573. {
  4574. returnErrorMsg("找不到原始订单记录");
  4575. return;
  4576. }
  4577. bool isInitOrderDeliv = false;
  4578. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4579. {
  4580. isInitOrderDeliv = true;
  4581. }
  4582. string apires = "";
  4583. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4584. 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)
  4585. {
  4586. apires = "发货成功true";
  4587. }
  4588. else
  4589. {
  4590. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4591. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4592. }
  4593. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4594. {
  4595. entity.OrderState = 7;//发货后订单已发货
  4596. entity.OutSid = outSid;
  4597. entity.MemoOpt = 0;
  4598. entity.UpdateTime = DateTime.Now;
  4599. entity.FinishDeliveryTime = DateTime.Now;
  4600. entity.Update();
  4601. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4602. commonHelper.UpdateRelationOrder(entity.ctid);
  4603. //还要插入快递信息到 快递信息表
  4604. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4605. exinfo.tid = eid;
  4606. exinfo.out_sid = outSid;
  4607. exinfo.company_code = comCode;
  4608. exinfo.company_name = comName;
  4609. exinfo.delivery_memo = deliveryMemo;
  4610. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4611. exinfo.deliveryType = deliveryType;
  4612. exinfo.Create();
  4613. returnSuccessMsg("发货操作成功!");
  4614. commonHelper.UpdateRelationOrder(entity.ctid);
  4615. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4616. CeErpSukuraData.createInfo(entity.ctid, 4);
  4617. if (entity.SupplierId == 64)
  4618. {
  4619. commonHelper.sendCytExpress(exinfo);
  4620. }
  4621. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4622. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4623. }
  4624. else
  4625. {
  4626. string errmsg = commonHelper.KeepChinese(apires);
  4627. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4628. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4629. }
  4630. return;
  4631. }
  4632. returnErrorMsg("找不到订单记录");
  4633. }
  4634. }
  4635. public void set_erp_multidelivery()
  4636. {
  4637. string eids = GetPostString("tids");
  4638. string[] eidList = eids.Split(',');
  4639. if (eidList.Length <= 0)
  4640. {
  4641. returnErrorMsg("发货不能为空");
  4642. return;
  4643. }
  4644. foreach (string ctid in eidList)
  4645. {
  4646. if (ctid.Length <= 0) continue;
  4647. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4648. if (expInfo != null)
  4649. {
  4650. StringBuilder sql = new StringBuilder();
  4651. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4652. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4653. if (dt.Rows.Count > 0)
  4654. {
  4655. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4656. {
  4657. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4658. expInfo.state = "异常";
  4659. expInfo.isMultiDelivery = 1;
  4660. expInfo.Update();
  4661. continue;
  4662. }
  4663. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4664. {
  4665. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4666. expInfo.state = "异常";
  4667. expInfo.Update();
  4668. continue;
  4669. }
  4670. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4671. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4672. bool isInitOrderDeliv = false;
  4673. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4674. {
  4675. isInitOrderDeliv = true;
  4676. expInfo.isMultiDelivery = 1;
  4677. }
  4678. if (ctid.IndexOf("N") != -1)
  4679. {
  4680. StringBuilder sqlbucha = new StringBuilder();
  4681. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4682. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4683. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4684. commonHelper.UpdateRelationOrder(ctid);
  4685. expInfo.delivery_memo = "发货成功";
  4686. expInfo.state = "发货成功";
  4687. expInfo.isMultiDelivery = 1;
  4688. expInfo.Update();
  4689. }
  4690. else
  4691. {
  4692. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4693. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4694. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4695. {
  4696. expInfo.delivery_memo = "发货成功";
  4697. expInfo.state = "发货成功";
  4698. expInfo.isMultiDelivery = 1;
  4699. expInfo.Update();
  4700. commonHelper.UpdateRelationOrder(ctid);
  4701. CeErpSukuraData.createInfo(ctid, 4);
  4702. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4703. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4704. }
  4705. else
  4706. {
  4707. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4708. expInfo.state = "异常";
  4709. expInfo.Update();
  4710. }
  4711. }
  4712. }
  4713. }
  4714. }
  4715. returnSuccessMsg("操作完成");
  4716. }
  4717. public void reset_erp_memoopt()
  4718. {
  4719. if (UrlPostParmsCheck("ctid"))
  4720. {
  4721. string eid = GetPostString("ctid");
  4722. CeErpTradeCell entity = null;
  4723. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4724. if (entity != null)
  4725. {
  4726. string stropt = "";
  4727. if (entity.MemoOpt == 1)
  4728. {
  4729. stropt = "“改稿”";
  4730. }
  4731. else if (entity.MemoOpt == 2)
  4732. {
  4733. stropt = "“定稿”";
  4734. }
  4735. else if (entity.MemoOpt == 3)
  4736. {
  4737. stropt = "“完成查货”";
  4738. CeErpSukuraData.createInfo(entity.ctid, 6);
  4739. }
  4740. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4741. entity.UpdateTime = DateTime.Now;
  4742. entity.MemoOpt = 0;
  4743. entity.Update();
  4744. returnSuccessMsg("操作成功!");
  4745. return;
  4746. }
  4747. returnErrorMsg("找不到记录");
  4748. }
  4749. }
  4750. public void get_erp_deliveryunusual()
  4751. {
  4752. DataStruct dStruct = GetPostStruct();
  4753. List<string> lw = new List<string>();
  4754. string tid = GetPostString("ctid");
  4755. if (tid.Length > 0)
  4756. {
  4757. string select_tid = getTidByCtid(tid);
  4758. lw.Add(string.Format("tid='{0}'", select_tid));
  4759. }
  4760. string shopname = GetPostString("shopname");
  4761. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4762. string buyernick = GetPostString("buyer_nick");
  4763. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4764. string customer = GetPostString("customer");
  4765. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4766. string design = GetPostString("design");
  4767. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4768. string sellermemo = GetPostString("seller_memo");
  4769. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4770. string supplier = GetPostString("supplier");
  4771. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4772. string date1 = GetPostString("date1");
  4773. string date2 = GetPostString("date2");
  4774. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4775. if (dw.Length > 0) lw.Add(dw);
  4776. string placedate1 = GetPostString("placedate1");
  4777. string placedate2 = GetPostString("placedate2");
  4778. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4779. if (dw_place.Length > 0) lw.Add(dw_place);
  4780. string price1 = GetPostString("price1");
  4781. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4782. string price2 = GetPostString("price2");
  4783. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4784. string unusualCon = GetPostString("unusualcon");
  4785. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4786. string posTag = CurrentUser.UserPost.Post.Code;
  4787. if (posTag == "Supplier")
  4788. {
  4789. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4790. }
  4791. lw.Add(string.Format("OrderState = 6"));
  4792. lw.Add(string.Format("UnusualTag = 5"));
  4793. lw.Add(string.Format("IsRefund<={0}", 1));
  4794. dStruct.Order = "FinishPlaceTime desc";
  4795. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4796. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4797. writeGridDataTableJson(dStruct.TotalCount, dt);
  4798. }
  4799. public void get_erp_deliveryedlist()
  4800. {
  4801. DataStruct dStruct = GetPostStruct();
  4802. List<string> lw = new List<string>();
  4803. string tid = GetPostString("ctid");
  4804. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4805. string shopname = GetPostString("shopname");
  4806. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4807. string buyernick = GetPostString("buyer_nick");
  4808. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4809. string customer = GetPostString("customer");
  4810. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4811. string design = GetPostString("design");
  4812. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4813. string sellermemo = GetPostString("seller_memo");
  4814. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4815. string logistics = GetPostString("logistics");
  4816. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4817. string date1 = GetPostString("date1");
  4818. string date2 = GetPostString("date2");
  4819. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4820. //if (dw.Length > 0) lw.Add(dw);
  4821. string placedate1 = GetPostString("placedate1");
  4822. string placedate2 = GetPostString("placedate2");
  4823. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4824. if (fdw.Length > 0) lw.Add(fdw);
  4825. string devdate1 = GetPostString("deliverydate1");
  4826. string devdate2 = GetPostString("deliverydate2");
  4827. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4828. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4829. string price1 = GetPostString("price1");
  4830. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4831. string price2 = GetPostString("price2");
  4832. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4833. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4834. {
  4835. if (tid.Length > 0)
  4836. {
  4837. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4838. if (tid.Length > 5)
  4839. {
  4840. List<string> tids = getTidByCtidLike(tid);
  4841. if (tids.Count > 0 && tids.Count < 10)
  4842. {
  4843. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4844. }
  4845. }
  4846. lw.Add(tid_sql);
  4847. }
  4848. if (buyernick.Length > 0)
  4849. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4850. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4851. if (dw.Length > 0) lw.Add(dw);
  4852. }
  4853. else
  4854. {
  4855. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4856. }
  4857. string posTag = CurrentUser.UserPost.Post.Code;
  4858. if (posTag == "Supplier")
  4859. {
  4860. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4861. }
  4862. else
  4863. {
  4864. string supplier = GetPostString("supplier");
  4865. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4866. }
  4867. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4868. lw.Add(string.Format("type != 'PDD' "));
  4869. lw.Add(string.Format("IsRefund!={0}", 2));
  4870. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4871. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4872. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4873. /*if (tid.Length > 0)
  4874. {
  4875. List<string> tids = new List<string>();
  4876. if (dt != null && dt.Rows.Count > 0)
  4877. {
  4878. foreach (DataRow item in dt.Rows)
  4879. {
  4880. tids.Add("'" + item["tid"] + "'");
  4881. }
  4882. }
  4883. if (tids.Count > 0)
  4884. {
  4885. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4886. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4887. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4888. dt = WebCache.GetData("view_erptradecell", dStruct);
  4889. }
  4890. }*/
  4891. if (dt != null)
  4892. {
  4893. foreach (DataRow dr in dt.Rows)
  4894. {
  4895. 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();
  4896. }
  4897. }
  4898. writeGridDataTableJson(dStruct.TotalCount, dt);
  4899. }
  4900. public void get_erp_pdddeliveryed()
  4901. {
  4902. DataStruct dStruct = GetPostStruct();
  4903. List<string> lw = new List<string>();
  4904. string tid = GetPostString("ctid");
  4905. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4906. string shopname = GetPostString("shopname");
  4907. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4908. string buyernick = GetPostString("buyer_nick");
  4909. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4910. string customer = GetPostString("customer");
  4911. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4912. string design = GetPostString("design");
  4913. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4914. string sellermemo = GetPostString("seller_memo");
  4915. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4916. string logistics = GetPostString("logistics");
  4917. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4918. string date1 = GetPostString("date1");
  4919. string date2 = GetPostString("date2");
  4920. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4921. //if (dw.Length > 0) lw.Add(dw);
  4922. string placedate1 = GetPostString("placedate1");
  4923. string placedate2 = GetPostString("placedate2");
  4924. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4925. if (fdw.Length > 0) lw.Add(fdw);
  4926. string devdate1 = GetPostString("deliverydate1");
  4927. string devdate2 = GetPostString("deliverydate2");
  4928. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4929. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4930. string price1 = GetPostString("price1");
  4931. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4932. string price2 = GetPostString("price2");
  4933. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4934. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4935. {
  4936. if (tid.Length > 0)
  4937. {
  4938. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4939. if (tid.Length > 5)
  4940. {
  4941. List<string> tids = getTidByCtidLike(tid);
  4942. if (tids.Count > 0 && tids.Count < 10)
  4943. {
  4944. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4945. }
  4946. }
  4947. lw.Add(tid_sql);
  4948. }
  4949. if (buyernick.Length > 0)
  4950. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4951. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4952. if (dw.Length > 0) lw.Add(dw);
  4953. }
  4954. else
  4955. {
  4956. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  4957. }
  4958. string posTag = CurrentUser.UserPost.Post.Code;
  4959. if (posTag == "Supplier")
  4960. {
  4961. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4962. }
  4963. else
  4964. {
  4965. string supplier = GetPostString("supplier");
  4966. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4967. }
  4968. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4969. lw.Add(string.Format("type = 'PDD' "));
  4970. lw.Add(string.Format("IsRefund!={0}", 2));
  4971. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4972. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4973. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4974. /* if (tid.Length > 0)
  4975. {
  4976. List<string> tids = new List<string>();
  4977. if (dt != null && dt.Rows.Count > 0)
  4978. {
  4979. foreach (DataRow item in dt.Rows)
  4980. {
  4981. tids.Add("'" + item["tid"] + "'");
  4982. }
  4983. }
  4984. if (tids.Count > 0)
  4985. {
  4986. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4987. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4988. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4989. dt = WebCache.GetData("view_erptradecell", dStruct);
  4990. }
  4991. }*/
  4992. foreach (DataRow dr in dt.Rows)
  4993. {
  4994. 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();
  4995. }
  4996. writeGridDataTableJson(dStruct.TotalCount, dt);
  4997. }
  4998. public void get_erp_jddeliveryed()
  4999. {
  5000. DataStruct dStruct = GetPostStruct();
  5001. List<string> lw = new List<string>();
  5002. string tid = GetPostString("ctid");
  5003. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5004. string shopname = GetPostString("shopname");
  5005. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5006. string buyernick = GetPostString("buyer_nick");
  5007. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5008. string customer = GetPostString("customer");
  5009. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5010. string design = GetPostString("design");
  5011. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5012. string sellermemo = GetPostString("seller_memo");
  5013. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5014. string date1 = GetPostString("date1");
  5015. string date2 = GetPostString("date2");
  5016. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5017. //if (dw.Length > 0) lw.Add(dw);
  5018. string placedate1 = GetPostString("placedate1");
  5019. string placedate2 = GetPostString("placedate2");
  5020. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5021. if (fdw.Length > 0) lw.Add(fdw);
  5022. string devdate1 = GetPostString("deliverydate1");
  5023. string devdate2 = GetPostString("deliverydate2");
  5024. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5025. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5026. string price1 = GetPostString("price1");
  5027. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5028. string price2 = GetPostString("price2");
  5029. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5030. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5031. {
  5032. if (tid.Length > 0)
  5033. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5034. if (buyernick.Length > 0)
  5035. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5036. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5037. if (dw.Length > 0) lw.Add(dw);
  5038. }
  5039. else
  5040. {
  5041. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5042. }
  5043. string posTag = CurrentUser.UserPost.Post.Code;
  5044. if (posTag == "Supplier")
  5045. {
  5046. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5047. }
  5048. else
  5049. {
  5050. string supplier = GetPostString("supplier");
  5051. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5052. }
  5053. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5054. lw.Add(string.Format("type = 'JD' "));
  5055. lw.Add(string.Format("IsRefund!={0}", 2));
  5056. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5057. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5058. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5059. foreach (DataRow dr in dt.Rows)
  5060. {
  5061. 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();
  5062. }
  5063. writeGridDataTableJson(dStruct.TotalCount, dt);
  5064. }
  5065. public void get_erp_allplacelist()
  5066. {
  5067. DataStruct dStruct = GetPostStruct();
  5068. List<string> lw = new List<string>();
  5069. string tid = GetPostString("ctid");
  5070. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5071. string shopname = GetPostString("shopname");
  5072. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5073. string buyernick = GetPostString("buyer_nick");
  5074. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5075. string customer = GetPostString("customer");
  5076. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5077. string design = GetPostString("design");
  5078. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5079. string sellermemo = GetPostString("seller_memo");
  5080. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5081. string supplier = GetPostString("supplier");
  5082. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5083. string date1 = GetPostString("date1");
  5084. string date2 = GetPostString("date2");
  5085. string pldate1 = GetPostString("placedate1");
  5086. string pldate2 = GetPostString("placedate2");
  5087. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5088. //if (dw.Length > 0) lw.Add(dw);
  5089. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5090. {
  5091. if (tid.Length > 0)
  5092. {
  5093. string select_tid = getTidByCtid(tid);
  5094. lw.Add(string.Format("tid='{0}'", select_tid));
  5095. }
  5096. if (buyernick.Length > 0)
  5097. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5098. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5099. if (dw.Length > 0) lw.Add(dw);
  5100. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5101. if (dw_place.Length > 0) lw.Add(dw_place);
  5102. }
  5103. else
  5104. {
  5105. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5106. {
  5107. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5108. }
  5109. }
  5110. string price1 = GetPostString("price1");
  5111. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5112. string price2 = GetPostString("price2");
  5113. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5114. string posTag = CurrentUser.UserPost.Post.Code;
  5115. if (posTag == "Supplier")
  5116. {
  5117. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5118. }
  5119. lw.Add(string.Format("OrderState >= 6"));
  5120. lw.Add(string.Format("IsSample != 2 "));
  5121. //lw.Add(string.Format("isDianziOrder = 0 "));
  5122. lw.Add(string.Format("SupplierId > 0 "));
  5123. //lw.Add(string.Format("IsRefund<={0}", 1));
  5124. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5125. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5126. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5127. foreach (DataRow dr in dt.Rows)
  5128. {
  5129. 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();
  5130. }
  5131. writeGridDataTableJson(dStruct.TotalCount, dt);
  5132. }
  5133. public void get_erp_financeallplacelist()
  5134. {
  5135. DataStruct dStruct = GetPostStruct();
  5136. List<string> lw = new List<string>();
  5137. string tid = GetPostString("ctid");
  5138. string shopname = GetPostString("shopname");
  5139. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5140. string buyernick = GetPostString("buyer_nick");
  5141. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5142. string customer = GetPostString("customer");
  5143. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5144. string design = GetPostString("design");
  5145. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5146. string sellermemo = GetPostString("seller_memo");
  5147. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5148. string supplier = GetPostString("supplier");
  5149. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5150. string date1 = GetPostString("date1");
  5151. string date2 = GetPostString("date2");
  5152. string pldate1 = GetPostString("placedate1");
  5153. string pldate2 = GetPostString("placedate2");
  5154. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5155. {
  5156. if (tid.Length > 0)
  5157. {
  5158. string select_tid = getTidByCtid(tid);
  5159. lw.Add(string.Format("tid='{0}'", select_tid));
  5160. }
  5161. if (buyernick.Length > 0)
  5162. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5163. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5164. if (dw.Length > 0) lw.Add(dw);
  5165. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5166. if (dw_place.Length > 0) lw.Add(dw_place);
  5167. }
  5168. else
  5169. {
  5170. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5171. {
  5172. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5173. }
  5174. }
  5175. string price1 = GetPostString("price1");
  5176. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5177. string price2 = GetPostString("price2");
  5178. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5179. string posTag = CurrentUser.UserPost.Post.Code;
  5180. if (posTag == "Supplier")
  5181. {
  5182. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5183. }
  5184. //lw.Add(string.Format("OrderState >= 6"));
  5185. lw.Add(string.Format("IsSample != 2 "));
  5186. lw.Add(string.Format("isDianziOrder = 0 "));
  5187. //lw.Add(string.Format("IsRefund<={0}", 1));
  5188. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5189. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5190. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5191. foreach (DataRow dr in dt.Rows)
  5192. {
  5193. 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();
  5194. }
  5195. writeGridDataTableJson(dStruct.TotalCount, dt);
  5196. }
  5197. public void get_erp_expresslist()
  5198. {
  5199. int listtype = GetInt("ltype");
  5200. DataStruct dStruct = GetPostStruct();
  5201. List<string> lw = new List<string>();
  5202. string tid = GetPostString("tid");
  5203. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5204. string outsid = GetPostString("out_sid");
  5205. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5206. string importer = GetPostString("ImportUserName");
  5207. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5208. string file = GetPostString("import_file");
  5209. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5210. string printman = GetPostString("printman");
  5211. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5212. string date1 = GetPostString("date1");
  5213. string date2 = GetPostString("date2");
  5214. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5215. if (dw.Length > 0) lw.Add(dw);
  5216. string fdate1 = GetPostString("finishdate1");
  5217. string fdate2 = GetPostString("finishdate2");
  5218. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5219. if (fdw.Length > 0) lw.Add(fdw);
  5220. string supplierId = GetPostString("supplierId");
  5221. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5222. if (listtype == 1)
  5223. {
  5224. lw.Add(string.Format("importUserId !=0"));
  5225. }
  5226. string posTag = CurrentUser.UserPost.Post.Code;
  5227. if (posTag == "Supplier")
  5228. {
  5229. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5230. }
  5231. if (dStruct.PageSize != 100000)
  5232. {
  5233. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5234. }
  5235. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5236. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5237. writeGridDataTableJson(dStruct.TotalCount, dt);
  5238. }
  5239. public void set_erp_buchaorderdelivery()
  5240. {
  5241. if (UrlPostParmsCheck("ctid"))
  5242. {
  5243. string eid = GetPostString("ctid");
  5244. CeErpTradeCell entity = null;
  5245. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5246. if (entity != null)
  5247. {
  5248. if (entity.IsSample != 2)
  5249. {
  5250. returnErrorMsg("补差价单才能标记为已发货");
  5251. return;
  5252. }
  5253. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5254. entity.OrderState = 7;
  5255. entity.Update();
  5256. returnSuccessMsg("操作成功!");
  5257. return;
  5258. }
  5259. returnErrorMsg("找不到记录");
  5260. }
  5261. }
  5262. public void get_stdtemplates()
  5263. {
  5264. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5265. //string res = taobaoHelper.test();
  5266. string res = apiHelper.API_PrintTemplate();
  5267. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5268. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5269. {
  5270. int sidx = res.IndexOf("error_code");
  5271. int eidx = res.IndexOf("success");
  5272. string msg = res.Substring(sidx, eidx - sidx);
  5273. returnErrorMsg(msg);
  5274. return;
  5275. }
  5276. if (res.Length <= 0)
  5277. {
  5278. returnErrorMsg("模板数据为空!");
  5279. return;
  5280. }
  5281. ReturnSuccess(res);
  5282. }
  5283. public void cancel_print_order()
  5284. {
  5285. if (UrlPostParmsCheck("ctid"))
  5286. {
  5287. string ctid = GetPostString("ctid");
  5288. CeErpTradeCell entity = null;
  5289. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5290. if (entity != null)
  5291. {
  5292. string res = "";
  5293. string code = entity.LastBillWaybillCode;
  5294. if (code == "")
  5295. {
  5296. code = entity.OutSid;
  5297. }
  5298. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5299. XLog.SaveLog(0, "取消面单" + res);
  5300. }
  5301. }
  5302. }
  5303. public void set_erp_printwaybill()
  5304. {
  5305. if (UrlPostParmsCheck("ctid"))
  5306. {
  5307. string ctid = GetPostString("ctid");
  5308. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5309. string cpName = GetPostString("cpname");
  5310. string isTogether = GetPostString("together");
  5311. //var res_obj = new
  5312. //{
  5313. // restype = 1,
  5314. // 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\"}"
  5315. //};
  5316. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5317. //ReturnSuccess(ro_json);
  5318. //return;
  5319. bool isUseLastWayBillCode = false;
  5320. CeErpTradeCell entity = null;
  5321. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5322. if (entity != null)
  5323. {
  5324. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5325. {
  5326. isUseLastWayBillCode = true;
  5327. }
  5328. if (entity.OrderState == 7 && "2".Equals(isTogether))
  5329. {
  5330. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5331. return;
  5332. }
  5333. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5334. {
  5335. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5336. return;
  5337. }
  5338. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5339. {
  5340. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5341. return;
  5342. }
  5343. }
  5344. string res = "";
  5345. Api_waybill_code_response_Obj fullObj = null;
  5346. string pData_str = "";
  5347. string curUseWayBillCode = "";
  5348. if (isUseLastWayBillCode == false)
  5349. {
  5350. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5351. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5352. if (res.IndexOf("failure") != -1)
  5353. {
  5354. //int idx = res.IndexOf("sub_message");
  5355. //int idx2 = res.IndexOf("flag");
  5356. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5357. string errMsgNeed = commonHelper.KeepChinese(res);
  5358. var res_objd = new
  5359. {
  5360. restype = 0,
  5361. data = "获取面单失败" + errMsgNeed
  5362. };
  5363. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5364. returnSuccess(ro_jsond);
  5365. if (res.IndexOf("停发") != -1)
  5366. {
  5367. entity.UnusualCon = "物流停发";
  5368. entity.Update();
  5369. }
  5370. //returnErrorMsg("获取面单失败,"+emsg);
  5371. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5372. return;
  5373. }
  5374. else if (res.IndexOf("errorMsg") != -1)
  5375. {
  5376. //int idx = res.IndexOf("errorMsg");
  5377. //int idx2 = res.IndexOf("}]}");
  5378. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5379. string errMsgNeed = commonHelper.KeepChinese(res);
  5380. var res_objf = new
  5381. {
  5382. restype = 0,
  5383. data = "获取面单失败2" + errMsgNeed
  5384. };
  5385. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5386. if (res.IndexOf("停发") != -1)
  5387. {
  5388. entity.UnusualCon = "物流停发";
  5389. entity.Update();
  5390. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5391. if (trade != null)
  5392. {
  5393. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5394. }
  5395. }
  5396. returnSuccess(ro_jsonf);
  5397. //returnErrorMsg("获取面单失败," + emsg);
  5398. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5399. return;
  5400. }
  5401. try
  5402. {
  5403. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5404. //res = res.Replace(" ", "");
  5405. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5406. }
  5407. catch (Exception ex)
  5408. {
  5409. XLog.SaveLog(0, "生成fullObj" + res);
  5410. var res_objf = new
  5411. {
  5412. restype = 0,
  5413. data = "生成fullObj发生错误" + ex.Message
  5414. };
  5415. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5416. returnSuccess(ro_jsonf);
  5417. return;
  5418. }
  5419. if (fullObj.response.data.content.Count > 0)
  5420. {
  5421. ContentItem codeObj = fullObj.response.data.content[0];
  5422. if (cpCode.IndexOf("SFFQ-") != -1)
  5423. {
  5424. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5425. }
  5426. else
  5427. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5428. curUseWayBillCode = codeObj.waybillCode;
  5429. }
  5430. else
  5431. {
  5432. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5433. var res_objf = new
  5434. {
  5435. restype = 0,
  5436. data = "生成fullObj找不到快递单号waybillCode"
  5437. };
  5438. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5439. returnSuccess(ro_jsonf);
  5440. return;
  5441. }
  5442. }
  5443. else
  5444. {
  5445. //使用上次打印的快递单号
  5446. if (cpCode == "SFFQ-LY")
  5447. {
  5448. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5449. }
  5450. else
  5451. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5452. curUseWayBillCode = entity.LastBillWaybillCode;
  5453. }
  5454. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5455. {
  5456. var res_obje = new
  5457. {
  5458. restype = 0,
  5459. data = "获取加密打印数据失败"
  5460. };
  5461. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5462. returnSuccess(ro_jsone);
  5463. entity.LastBillCpCode = cpCode;
  5464. entity.LastBillWaybillCode = curUseWayBillCode;
  5465. entity.Update();
  5466. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5467. //returnErrorMsg("获取加密打印数据失败");
  5468. return;
  5469. }
  5470. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5471. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5472. string btnType = "";
  5473. string errorMsg = "";
  5474. if (entity != null)
  5475. {
  5476. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5477. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5478. //cpcode是 YTO-CAINIAO
  5479. //string comCode = cpCode.Split('-')[0].ToString();
  5480. string apires = "";
  5481. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5482. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5483. {
  5484. if (ctid.IndexOf("N") != -1)
  5485. {
  5486. apires = "发货成功";
  5487. }
  5488. else
  5489. {
  5490. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5491. }
  5492. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5493. //打单后发货
  5494. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5495. {
  5496. try
  5497. {
  5498. btnType = "待发货";
  5499. entity.OutSid = curUseWayBillCode;
  5500. entity.OrderState = 7;
  5501. entity.IsUrgency = false;
  5502. entity.LastBillCpCode = "";
  5503. entity.LastBillWaybillCode = "";
  5504. entity.FinishDeliveryTime = DateTime.Now;
  5505. entity.IsReturn = 0;
  5506. entity.MemoOpt = 0;
  5507. entity.UpdateTime = DateTime.Now;
  5508. entity.Update();
  5509. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5510. //还要插入快递信息到 快递信息表
  5511. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5512. exinfo.tid = entity.ctid;
  5513. exinfo.out_sid = curUseWayBillCode;
  5514. exinfo.company_code = cpCode;
  5515. exinfo.company_name = cpName;
  5516. exinfo.supplierUserName = supplierName;
  5517. exinfo.deliveryType = "发货成功";
  5518. exinfo.print_time = DateTime.Now;
  5519. exinfo.printUser = CurrentUser.UserName;
  5520. exinfo.postData = pData_str;
  5521. exinfo.Create();
  5522. commonHelper.UpdateRelationOrder(entity.ctid);
  5523. CeErpSukuraData.createInfo(ctid, 4);
  5524. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5525. if (entity.SupplierId == 64)
  5526. {
  5527. commonHelper.sendCytExpress(exinfo);
  5528. }
  5529. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5530. if (!string.IsNullOrEmpty(isTogether))
  5531. {
  5532. if (Convert.ToInt32(isTogether) > 0)
  5533. {
  5534. StringBuilder sqlsb = new StringBuilder();
  5535. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5536. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5537. }
  5538. }
  5539. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5540. }
  5541. catch (Exception ex)
  5542. {
  5543. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5544. }
  5545. }
  5546. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5547. {
  5548. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5549. if (entity.OrderState == 6)
  5550. {
  5551. entity.OrderState = 7;
  5552. }
  5553. entity.UpdateTime = DateTime.Now;
  5554. entity.FinishDeliveryTime = DateTime.Now;
  5555. btnType = "已发货";
  5556. entity.Update();
  5557. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5558. exinfo.tid = entity.ctid;
  5559. exinfo.out_sid = curUseWayBillCode;
  5560. exinfo.company_code = cpCode;
  5561. exinfo.company_name = cpName;
  5562. exinfo.supplierUserName = supplierName;
  5563. exinfo.deliveryType = "发货成功";
  5564. exinfo.print_time = DateTime.Now;
  5565. exinfo.printUser = CurrentUser.UserName;
  5566. exinfo.postData = pData_str;
  5567. exinfo.Create();
  5568. commonHelper.UpdateRelationOrder(entity.ctid);
  5569. CeErpSukuraData.createInfo(entity.ctid, 4);
  5570. if (entity.SupplierId == 64)
  5571. {
  5572. commonHelper.sendCytExpress(exinfo);
  5573. }
  5574. if (!string.IsNullOrEmpty(isTogether))
  5575. {
  5576. if (Convert.ToInt32(isTogether) > 0)
  5577. {
  5578. StringBuilder sqlsb = new StringBuilder();
  5579. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}',FinishDeliveryTime=GETDATE(),UpdateTime=GETDATE() where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5580. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5581. }
  5582. }
  5583. //不处理
  5584. }
  5585. else
  5586. {
  5587. entity.UpdateTime = DateTime.Now;
  5588. entity.LastBillCpCode = cpCode;
  5589. entity.LastBillWaybillCode = curUseWayBillCode;
  5590. entity.Update();
  5591. string errmsg = commonHelper.KeepChinese(apires);
  5592. var res_objz = new
  5593. {
  5594. restype = 0,
  5595. data = "打单后发货失败"
  5596. };
  5597. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5598. returnSuccess(ro_jsonz);
  5599. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5600. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5601. return;
  5602. }
  5603. }
  5604. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5605. {
  5606. StringBuilder allSql = new StringBuilder();
  5607. allSql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,tid from view_ErpTradeCell where SupplierId={0} and orderstate=6 and IsSample = 0", entity.SupplierId);
  5608. if (string.IsNullOrEmpty(mainEn.receiverId))
  5609. {
  5610. allSql.AppendFormat(" and (tid='{0}');", entity.tid);
  5611. }
  5612. else
  5613. {
  5614. //查询同车间同状态下的收货地址相同的单子
  5615. allSql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}') );", entity.tid, mainEn.receiverId, entity.IsSF);
  5616. }
  5617. DataTable dt = DbHelper.DbConn.ExecuteDataset(allSql.ToString()).Tables[0];
  5618. List<string> list = new List<string>();
  5619. List<string> send_list = new List<string>();
  5620. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5621. CeErpTrade ceErpTrade = new CeErpTrade();
  5622. foreach (DataRow row in dt.Rows)
  5623. {
  5624. list.Add("'" + row["ctid"] + "'");
  5625. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5626. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5627. if (ctid.IndexOf("N") != -1)
  5628. {
  5629. apires = "发货成功";
  5630. }
  5631. else
  5632. {
  5633. if (!send_list.Contains(ceErpTrade.tid))
  5634. {
  5635. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5636. }
  5637. else
  5638. {
  5639. apires = "发货成功";
  5640. }
  5641. }
  5642. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5643. {
  5644. send_list.Add(ceErpTrade.tid);
  5645. try
  5646. {
  5647. btnType = "待发货";
  5648. ceErpTradeCell.OutSid = curUseWayBillCode;
  5649. ceErpTradeCell.OrderState = 7;
  5650. ceErpTradeCell.IsUrgency = false;
  5651. ceErpTradeCell.LastBillCpCode = "";
  5652. ceErpTradeCell.LastBillWaybillCode = "";
  5653. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5654. ceErpTradeCell.IsReturn = 0;
  5655. ceErpTradeCell.MemoOpt = 0;
  5656. ceErpTradeCell.UpdateTime = DateTime.Now;
  5657. ceErpTradeCell.Update();
  5658. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5659. //还要插入快递信息到 快递信息表
  5660. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5661. exinfo.tid = ceErpTradeCell.ctid;
  5662. exinfo.out_sid = curUseWayBillCode;
  5663. exinfo.company_code = cpCode;
  5664. exinfo.company_name = cpName;
  5665. exinfo.supplierUserName = supplierName;
  5666. exinfo.deliveryType = "发货成功";
  5667. exinfo.print_time = DateTime.Now;
  5668. exinfo.printUser = CurrentUser.UserName;
  5669. exinfo.postData = pData_str;
  5670. exinfo.Create();
  5671. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5672. CeErpSukuraData.createInfo(ctid, 4);
  5673. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5674. if (ceErpTradeCell.SupplierId == 64)
  5675. {
  5676. commonHelper.sendCytExpress(exinfo);
  5677. }
  5678. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5679. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5680. }
  5681. catch (Exception ex)
  5682. {
  5683. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5684. }
  5685. }
  5686. else
  5687. {
  5688. ceErpTradeCell.UpdateTime = DateTime.Now;
  5689. ceErpTradeCell.LastBillCpCode = cpCode;
  5690. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5691. ceErpTradeCell.Update();
  5692. string errmsg = commonHelper.KeepChinese(apires);
  5693. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5694. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5695. }
  5696. }
  5697. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5698. }
  5699. }
  5700. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5701. var res_obj = new
  5702. {
  5703. restype = 1,
  5704. data = pData_str,
  5705. errorMsg
  5706. };
  5707. string ro_json = JsonConvert.SerializeObject(res_obj);
  5708. ReturnSuccess(ro_json);
  5709. return;
  5710. }
  5711. }
  5712. private string GetUTF8String(byte[] vs)
  5713. {
  5714. throw new NotImplementedException();
  5715. }
  5716. public void set_erp_printwaybill_cn()
  5717. {
  5718. if (UrlPostParmsCheck("ctid"))
  5719. {
  5720. string ctid = GetPostString("ctid");
  5721. string cpCode = GetPostString("cpcode");
  5722. string cpName = GetPostString("cpname");
  5723. string tempUrl = GetPostString("tempurl");
  5724. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5725. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5726. //string res = taobaoHelper.test();
  5727. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5728. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5729. {
  5730. int sidx = res.IndexOf("errorMsg");
  5731. int eidx = res.IndexOf("}");
  5732. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5733. var res_objzxx = new
  5734. {
  5735. restype = 0,
  5736. data = msg
  5737. };
  5738. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5739. returnSuccess(ro_jsonzxx);
  5740. //returnErrorMsg(msg);
  5741. return;
  5742. }
  5743. int idx = res.IndexOf("waybillCode");
  5744. int idx2 = res.IndexOf("printData");
  5745. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5746. string eid = GetPostString("ctid");
  5747. CeErpTradeCell entity = null;
  5748. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5749. if (entity != null)
  5750. {
  5751. string osid = entity.OutSid;
  5752. entity.OutSid = osid + "," + outsid;
  5753. entity.FinishDeliveryTime = DateTime.Now;
  5754. entity.OrderState = 7;
  5755. entity.UpdateTime = DateTime.Now;
  5756. entity.IsReturn = 0;
  5757. entity.Update();
  5758. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5759. exinfo.tid = entity.ctid;
  5760. exinfo.out_sid = outsid;
  5761. exinfo.company_code = cpCode;
  5762. exinfo.company_name = cpName;
  5763. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5764. exinfo.deliveryType = "发货成功";
  5765. exinfo.print_time = DateTime.Now;
  5766. exinfo.printUser = CurrentUser.UserName;
  5767. exinfo.Create();
  5768. if (entity.SupplierId == 64)
  5769. {
  5770. commonHelper.sendCytExpress(exinfo);
  5771. }
  5772. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5773. }
  5774. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5775. var res_objz = new
  5776. {
  5777. restype = 1,
  5778. data = res
  5779. };
  5780. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5781. returnSuccess(ro_jsonz);
  5782. //ReturnSuccess(res);
  5783. }
  5784. }
  5785. ////打单,打印面单 获取面单号
  5786. //public void set_erp_printwaybill()
  5787. //{
  5788. // if (UrlPostParmsCheck("ctid"))
  5789. // {
  5790. // string ctid = GetPostString("ctid");
  5791. // string cpCode = GetPostString("cpcode");
  5792. // string tempUrl = GetPostString("tempurl");
  5793. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5794. // //string res = taobaoHelper.test();
  5795. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5796. // if (res.IndexOf("error_response") != -1)
  5797. // {
  5798. // int sidx = res.IndexOf("sub_msg");
  5799. // int eidx = res.IndexOf("request_id");
  5800. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5801. // returnErrorMsg(msg);
  5802. // return;
  5803. // }
  5804. // int idx = res.IndexOf("waybill_code");
  5805. // int idx2 = res.IndexOf("}]}");
  5806. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5807. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5808. // ReturnSuccess(res);
  5809. // }
  5810. //}
  5811. public void cancel_erp_aftersale()
  5812. {
  5813. if (UrlPostParmsCheck("ctid"))
  5814. {
  5815. string eid = GetPostString("ctid");
  5816. CeErpTradeCell entity = null;
  5817. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5818. if (entity != null)
  5819. {
  5820. //有过处理的售后,取消也不能删除 售 字,保留
  5821. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5822. {
  5823. entity.AfterSaleState = 4;
  5824. }
  5825. else
  5826. entity.AfterSaleState = 0;
  5827. entity.UpdateTime = DateTime.Now;
  5828. entity.Update();
  5829. returnSuccessMsg("操作成功!");
  5830. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5831. return;
  5832. }
  5833. returnErrorMsg("找不到订单记录");
  5834. }
  5835. }
  5836. public void get_erp_aftersalelist()
  5837. {
  5838. DataStruct dStruct = GetPostStruct();
  5839. List<string> lw = new List<string>();
  5840. int st = GetInt("st");
  5841. string tid = GetPostString("ctid");
  5842. if (st == 3)
  5843. {
  5844. if (tid.Length > 0)
  5845. {
  5846. string select_tid = getTidByCtid(tid);
  5847. lw.Add(string.Format("tid='{0}'", select_tid));
  5848. }
  5849. }
  5850. else
  5851. {
  5852. if (tid.Length > 0)
  5853. {
  5854. string select_tid = getTidByCtid(tid);
  5855. lw.Add(string.Format("tid='{0}'", select_tid));
  5856. }
  5857. }
  5858. string shopname = GetPostString("shopname");
  5859. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5860. string buyernick = GetPostString("buyer_nick");
  5861. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5862. string sellermemo = GetPostString("seller_memo");
  5863. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5864. string orderState = GetPostString("orderState");
  5865. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5866. string afterState = GetPostString("afterstate");
  5867. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5868. string date1 = GetPostString("date1");
  5869. string date2 = GetPostString("date2");
  5870. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5871. if (dw.Length > 0) lw.Add(dw);
  5872. string price1 = GetPostString("price1");
  5873. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5874. string price2 = GetPostString("price2");
  5875. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5876. //lw.Add(string.Format("IsRefund!={0}", 1));
  5877. string reason = GetPostString("reason");
  5878. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5879. string method = GetPostString("method");
  5880. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5881. string handler = GetPostString("handler");
  5882. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5883. string handledate1 = GetPostString("handledate1");
  5884. string handledate2 = GetPostString("handledate2");
  5885. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5886. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5887. string finish1 = GetPostString("finishdate1");
  5888. string finish2 = GetPostString("finishdate2");
  5889. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5890. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5891. string afterdate1 = GetPostString("afterdate1");
  5892. string afterdate2 = GetPostString("afterdate2");
  5893. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5894. if (afterDate.Length > 0) lw.Add(afterDate);
  5895. string supplier = GetPostString("supplier");
  5896. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5897. string responsible = GetPostString("responsibleman");
  5898. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5899. string customer = GetPostString("customer");
  5900. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5901. string design = GetPostString("design");
  5902. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5903. string afterMemoType = GetPostString("aftermemotype");
  5904. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5905. string posCode = CurrentUser.UserPost.Post.Code;
  5906. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5907. //{
  5908. // string vstate = GetPostString("vstate");
  5909. // if (vstate.Length > 0)
  5910. // {
  5911. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5912. // }
  5913. // if (posCode == "Supplier")
  5914. // {
  5915. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5916. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5917. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5918. // }
  5919. // else
  5920. // {
  5921. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5922. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5923. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5924. // {
  5925. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5926. // }
  5927. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5928. // {
  5929. // int orgid = CurrentUser.UserPost.OrgID;
  5930. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5931. // }
  5932. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5933. // {
  5934. // string shopid = CurrentUser.User.pemShop;
  5935. // lw.Add(string.Format("shopId in ({0})", shopid));
  5936. // }
  5937. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5938. // //{
  5939. // // int org_id = CurrentUser.UserPost.OrgID;
  5940. // // lw.Add(string.Format("OrgID={0}", org_id));
  5941. // //}
  5942. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5943. // }
  5944. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5945. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5946. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5947. //}
  5948. if (st == 5)
  5949. {
  5950. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5951. {
  5952. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5953. {
  5954. string shopid = CurrentUser.User.pemShop;
  5955. lw.Add(string.Format("shopId in ({0})", shopid));
  5956. }
  5957. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5958. {
  5959. int mrOrgid = CurrentUser.UserPost.OrgID;
  5960. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5961. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5962. }
  5963. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5964. //{
  5965. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5966. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5967. //}
  5968. else
  5969. {
  5970. string userIdStr = "";
  5971. if (posCode == "CustomerService")
  5972. {
  5973. userIdStr = CurrentUser.UserID + "_k";
  5974. }
  5975. else if (posCode == "Designer" || posCode == "wxDesigner")
  5976. {
  5977. userIdStr = CurrentUser.UserID + "_s";
  5978. }
  5979. else if (posCode == "Place")
  5980. {
  5981. userIdStr = CurrentUser.UserID + "_x";
  5982. }
  5983. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5984. }
  5985. }
  5986. string placedate1 = GetPostString("placedate1");
  5987. string placedate2 = GetPostString("placedate2");
  5988. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5989. if (dwplace.Length > 0) lw.Add(dwplace);
  5990. string supState = GetPostString("supState");
  5991. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5992. string searchType = GetPostString("searchType");
  5993. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5994. {
  5995. lw.Add(string.Format("BackNum>1"));
  5996. }
  5997. lw.Add(string.Format("AfterSaleState>0"));
  5998. if (ex_psize > 0)
  5999. {
  6000. if (CurrentUser.UserPost.Post.Code == "Finance")
  6001. dStruct.Order = "pay_time desc";
  6002. else
  6003. dStruct.Order = "HandleTime desc";
  6004. }
  6005. else
  6006. dStruct.Order = "HandleTime desc";
  6007. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6008. DataTable dt = WebCache.GetData("view_test", dStruct);
  6009. writeGridDataTableJson(dStruct.TotalCount, dt);
  6010. }
  6011. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6012. //{
  6013. // lw.Add(string.Format("AfterSaleState=4"));
  6014. // string code = CurrentUser.UserPost.Post.Code;
  6015. // if (code == "CustomerService")
  6016. // {
  6017. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6018. // }
  6019. // else if (code == "Designer" || code == "DesignerMr")
  6020. // {
  6021. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6022. // }
  6023. // else if (code == "Place" || code == "PlaceMr")
  6024. // {
  6025. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6026. // }
  6027. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6028. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6029. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6030. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6031. //}
  6032. //else //处理中的售后,待处理和处理中合并
  6033. //{
  6034. // if (afterState.Length <= 0)
  6035. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6036. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6037. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6038. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6039. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6040. //}
  6041. }
  6042. public void get_erp_disagreeftersalelist()
  6043. {
  6044. DataStruct dStruct = GetPostStruct();
  6045. List<string> lw = new List<string>();
  6046. int st = 2;
  6047. string tid = GetPostString("ctid");
  6048. if (tid.Length > 0)
  6049. {
  6050. string select_tid = getTidByCtid(tid);
  6051. lw.Add(string.Format("tid='{0}'", select_tid));
  6052. }
  6053. string shopname = GetPostString("shopname");
  6054. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6055. string buyernick = GetPostString("buyer_nick");
  6056. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6057. string sellermemo = GetPostString("seller_memo");
  6058. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6059. string orderState = GetPostString("orderState");
  6060. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6061. string afterState = GetPostString("afterstate");
  6062. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6063. string date1 = GetPostString("date1");
  6064. string date2 = GetPostString("date2");
  6065. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6066. if (dw.Length > 0) lw.Add(dw);
  6067. string price1 = GetPostString("price1");
  6068. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6069. string price2 = GetPostString("price2");
  6070. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6071. //lw.Add(string.Format("IsRefund!={0}", 1));
  6072. string reason = GetPostString("reason");
  6073. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6074. string method = GetPostString("method");
  6075. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6076. string handler = GetPostString("handler");
  6077. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6078. string handledate1 = GetPostString("handledate1");
  6079. string handledate2 = GetPostString("handledate2");
  6080. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6081. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6082. string afterdate1 = GetPostString("afterdate1");
  6083. string afterdate2 = GetPostString("afterdate2");
  6084. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6085. if (afterDate.Length > 0) lw.Add(afterDate);
  6086. string backdate1 = GetPostString("backdate1");
  6087. string backdate2 = GetPostString("backdate2");
  6088. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6089. if (backDate.Length > 0) lw.Add(backDate);
  6090. string supplier = GetPostString("supplier");
  6091. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6092. string responsible = GetPostString("responsibleman");
  6093. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6094. string customer = GetPostString("customer");
  6095. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6096. string design = GetPostString("design");
  6097. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6098. string afterSaleMemo = GetPostString("afterSaleMemo");
  6099. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6100. string afterMemoType = GetPostString("aftermemotype");
  6101. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6102. string aftersakereason = GetPostString("aftersakereason");
  6103. if (aftersakereason.Length > 0)
  6104. {
  6105. if (aftersakereason == "1")
  6106. {
  6107. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6108. }
  6109. if (aftersakereason == "2")
  6110. {
  6111. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6112. }
  6113. }
  6114. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6115. string poscode = CurrentUser.UserPost.Post.Code;
  6116. if (poscode != "SysAdmin")
  6117. {
  6118. string shopid = CurrentUser.User.pemShop;
  6119. lw.Add(string.Format("shopId in ({0})", shopid));
  6120. }
  6121. string searchType = GetPostString("searchType");
  6122. if (searchType == "wait")
  6123. {
  6124. lw.Add(string.Format("HandleTime is null"));
  6125. }
  6126. if (searchType == "handling")
  6127. {
  6128. lw.Add(string.Format("HandleTime is not null "));
  6129. }
  6130. if (searchType == "back" || searchType == "puBack")
  6131. {
  6132. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6133. }
  6134. if (searchType == "reBack")
  6135. {
  6136. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6137. }
  6138. if (searchType == "moreBack")
  6139. {
  6140. lw.Add(string.Format("backNum > 1"));
  6141. }
  6142. lw.Add(string.Format("(AfterSaleState=5)"));
  6143. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6144. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6145. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6146. writeGridDataTableJson(dStruct.TotalCount, dt);
  6147. }
  6148. public void get_erp_handlingaftersalelist()
  6149. {
  6150. DataStruct dStruct = GetPostStruct();
  6151. List<string> lw = new List<string>();
  6152. int st = 2;
  6153. string tid = GetPostString("ctid");
  6154. if (tid.Length > 0)
  6155. {
  6156. string select_tid = getTidByCtid(tid);
  6157. lw.Add(string.Format("tid='{0}'", select_tid));
  6158. }
  6159. string shopname = GetPostString("shopname");
  6160. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6161. string buyernick = GetPostString("buyer_nick");
  6162. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6163. string sellermemo = GetPostString("seller_memo");
  6164. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6165. string orderState = GetPostString("orderState");
  6166. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6167. string afterState = GetPostString("afterstate");
  6168. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6169. string date1 = GetPostString("date1");
  6170. string date2 = GetPostString("date2");
  6171. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6172. if (dw.Length > 0) lw.Add(dw);
  6173. string price1 = GetPostString("price1");
  6174. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6175. string price2 = GetPostString("price2");
  6176. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6177. //lw.Add(string.Format("IsRefund!={0}", 1));
  6178. string reason = GetPostString("reason");
  6179. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6180. string method = GetPostString("method");
  6181. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6182. string handler = GetPostString("handler");
  6183. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6184. string handledate1 = GetPostString("handledate1");
  6185. string handledate2 = GetPostString("handledate2");
  6186. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6187. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6188. string afterdate1 = GetPostString("afterdate1");
  6189. string afterdate2 = GetPostString("afterdate2");
  6190. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6191. if (afterDate.Length > 0) lw.Add(afterDate);
  6192. string supplier = GetPostString("supplier");
  6193. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6194. string responsible = GetPostString("responsibleman");
  6195. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6196. string customer = GetPostString("customer");
  6197. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6198. string design = GetPostString("design");
  6199. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6200. string afterSaleMemo = GetPostString("afterSaleMemo");
  6201. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6202. string afterMemoType = GetPostString("aftermemotype");
  6203. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6204. string afterresult = GetPostString("afterresult");
  6205. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6206. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6207. string poscode = CurrentUser.UserPost.Post.Code;
  6208. if (poscode != "SysAdmin")
  6209. {
  6210. string shopid = CurrentUser.User.pemShop;
  6211. lw.Add(string.Format("shopId in ({0})", shopid));
  6212. }
  6213. string searchType = GetPostString("searchType");
  6214. if (searchType == "wait")
  6215. {
  6216. lw.Add(string.Format("HandleTime is null"));
  6217. }
  6218. if (searchType == "documentary")
  6219. {
  6220. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6221. }
  6222. if (searchType == "handling")
  6223. {
  6224. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6225. }
  6226. if (searchType == "back" || searchType == "puBack")
  6227. {
  6228. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6229. }
  6230. if (searchType == "reBack")
  6231. {
  6232. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6233. }
  6234. if (afterState.Length <= 0)
  6235. {
  6236. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6237. }
  6238. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6239. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6240. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6241. writeGridDataTableJson(dStruct.TotalCount, dt);
  6242. }
  6243. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6244. //public void get_erp_back_handlingaftersalelist()
  6245. //{
  6246. // DataStruct dStruct = GetPostStruct();
  6247. // List<string> lw = new List<string>();
  6248. // string tid = GetPostString("ctid");
  6249. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6250. // string shopname = GetPostString("shopname");
  6251. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6252. // string buyernick = GetPostString("buyer_nick");
  6253. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6254. // string sellermemo = GetPostString("seller_memo");
  6255. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6256. // string orderState = GetPostString("orderState");
  6257. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6258. // string afterState = GetPostString("afterstate");
  6259. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6260. // string date1 = GetPostString("date1");
  6261. // string date2 = GetPostString("date2");
  6262. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6263. // if (dw.Length > 0) lw.Add(dw);
  6264. // string price1 = GetPostString("price1");
  6265. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6266. // string price2 = GetPostString("price2");
  6267. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6268. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6269. // string reason = GetPostString("reason");
  6270. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6271. // string method = GetPostString("method");
  6272. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6273. // string handler = GetPostString("handler");
  6274. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6275. // string handledate1 = GetPostString("handledate1");
  6276. // string handledate2 = GetPostString("handledate2");
  6277. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6278. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6279. // string afterdate1 = GetPostString("afterdate1");
  6280. // string afterdate2 = GetPostString("afterdate2");
  6281. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6282. // if (afterDate.Length > 0) lw.Add(afterDate);
  6283. // string supplier = GetPostString("supplier");
  6284. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6285. // string responsible = GetPostString("responsibleman");
  6286. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6287. // string customer = GetPostString("customer");
  6288. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6289. // string design = GetPostString("design");
  6290. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6291. // string afterMemoType = GetPostString("aftermemotype");
  6292. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6293. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6294. // if (afterState.Length <= 0)
  6295. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6296. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6297. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6298. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6299. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6300. //}
  6301. public void get_erp_aftersaleverifylist()
  6302. {
  6303. DataStruct dStruct = GetPostStruct();
  6304. List<string> lw = new List<string>();
  6305. string tid = GetPostString("ctid");
  6306. if (tid.Length > 0)
  6307. {
  6308. string select_tid = getTidByCtid(tid);
  6309. lw.Add(string.Format("tid='{0}'", select_tid));
  6310. }
  6311. string shopname = GetPostString("shopname");
  6312. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6313. string buyernick = GetPostString("buyer_nick");
  6314. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6315. string sellermemo = GetPostString("seller_memo");
  6316. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6317. string orderState = GetPostString("orderState");
  6318. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6319. //lw.Add(string.Format("IsRefund!={0}", 1));
  6320. string reason = GetPostString("reason");
  6321. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6322. string method = GetPostString("method");
  6323. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6324. string handler = GetPostString("handler");
  6325. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6326. string handledate1 = GetPostString("handledate1");
  6327. string handledate2 = GetPostString("handledate2");
  6328. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6329. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6330. string finish1 = GetPostString("finishdate1");
  6331. string finish2 = GetPostString("finishdate2");
  6332. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6333. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6334. string supplier = GetPostString("supplier");
  6335. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6336. string responsible = GetPostString("responsibleman");
  6337. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6338. string posCode = CurrentUser.UserPost.Post.Code;
  6339. string vstate = GetPostString("vstate");
  6340. if (vstate.Length > 0)
  6341. {
  6342. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6343. }
  6344. if (posCode == "Supplier")
  6345. {
  6346. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6347. lw.Add(string.Format("VerifyState = 0"));
  6348. lw.Add("type = 1");
  6349. lw.Add(string.Format("AfterSaleState={0}", 3));
  6350. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6351. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6352. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6353. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6354. writeGridDataTableJson(dStruct.TotalCount, dt);
  6355. }
  6356. else if (posCode == "logistics")
  6357. {
  6358. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6359. lw.Add(string.Format("VerifyState = 0"));
  6360. lw.Add("type = 2");
  6361. lw.Add(string.Format("AfterSaleState={0}", 3));
  6362. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6363. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6364. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6365. writeGridDataTableJson(dStruct.TotalCount, dt);
  6366. }
  6367. else
  6368. {
  6369. lw.Add(string.Format("(AfterSaleState = 3)"));
  6370. string reasonState = GetPostString("reasonState");
  6371. lw.Add("type = 0");
  6372. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6373. || posCode == "Summarize" || posCode == "Finance")
  6374. {
  6375. if (reasonState == "2")
  6376. {
  6377. lw.Add("VerifyState = 3");
  6378. }
  6379. else if (reasonState == "1")
  6380. {
  6381. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6382. }
  6383. else
  6384. {
  6385. lw.Add("VerifyState in (0,3)");
  6386. }
  6387. //不加条件,可以看全部
  6388. }
  6389. 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")
  6390. {
  6391. int orgid = CurrentUser.UserPost.OrgID;
  6392. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6393. if (string.IsNullOrEmpty(manageOrgId))
  6394. {
  6395. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6396. }
  6397. else
  6398. {
  6399. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6400. }
  6401. if (reasonState == "1")
  6402. {
  6403. lw.Add("VerifyState = 3");
  6404. }
  6405. else if (reasonState == "2")
  6406. {
  6407. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6408. }
  6409. else
  6410. {
  6411. }
  6412. }
  6413. else
  6414. {
  6415. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6416. }
  6417. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6418. //{
  6419. // int org_id = CurrentUser.UserPost.OrgID;
  6420. // lw.Add(string.Format("OrgID={0}", org_id));
  6421. //}
  6422. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6423. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6424. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6425. writeGridDataTableJson(dStruct.TotalCount, dt);
  6426. }
  6427. }
  6428. public void get_erp_finishaftersalelist()
  6429. {
  6430. DataStruct dStruct = GetPostStruct();
  6431. List<string> lw = new List<string>();
  6432. int st = 4;
  6433. string tid = GetPostString("ctid");
  6434. if (tid.Length > 0)
  6435. {
  6436. string select_tid = getTidByCtid(tid);
  6437. lw.Add(string.Format("tid='{0}'", select_tid));
  6438. }
  6439. string shopname = GetPostString("shopname");
  6440. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6441. //lw.Add(string.Format("IsRefund!={0}", 1));
  6442. string reason = GetPostString("reason");
  6443. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6444. string method = GetPostString("method");
  6445. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6446. string buyernick = GetPostString("buyer_nick");
  6447. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6448. string handler = GetPostString("handler");
  6449. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6450. string handledate1 = GetPostString("handledate1");
  6451. string handledate2 = GetPostString("handledate2");
  6452. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6453. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6454. string finish1 = GetPostString("finishdate1");
  6455. string finish2 = GetPostString("finishdate2");
  6456. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6457. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6458. string supplier = GetPostString("supplier");
  6459. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6460. string responsible = GetPostString("responsibleman");
  6461. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6462. string vstate = GetPostString("vstate");
  6463. if (vstate.Length > 0)
  6464. {
  6465. if ("3".Equals(vstate))
  6466. {
  6467. lw.Add(string.Format("IsTem=1"));
  6468. }
  6469. else
  6470. {
  6471. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6472. }
  6473. }
  6474. lw.Add(string.Format("AfterSaleState=4"));
  6475. string code = CurrentUser.UserPost.Post.Code;
  6476. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6477. {
  6478. //不加条件,可以看全部
  6479. }
  6480. else if (code == "Supplier")
  6481. {
  6482. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6483. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6484. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6485. }
  6486. else if (code == "logistics")
  6487. {
  6488. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6489. lw.Add("type = 2");
  6490. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6491. }
  6492. 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")
  6493. {
  6494. int orgid = CurrentUser.UserPost.OrgID;
  6495. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6496. if (string.IsNullOrEmpty(manageOrgIds))
  6497. {
  6498. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6499. }
  6500. else
  6501. {
  6502. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6503. }
  6504. }
  6505. else
  6506. {
  6507. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6508. }
  6509. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6510. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6511. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6512. writeGridDataTableJson(dStruct.TotalCount, dt);
  6513. }
  6514. public void handle_erp_aftersale()
  6515. {
  6516. if (UrlPostParmsCheck("ctid"))
  6517. {
  6518. string eid = GetPostString("ctid");
  6519. string responStr = GetPostString("AfterSaleResponsible");
  6520. if (responStr.Length <= 0)
  6521. {
  6522. returnErrorMsg("售后责任人不能为空");
  6523. return;
  6524. }
  6525. bool isDesign = false;
  6526. double designFree = 0.00;
  6527. int responsibleId = 0;
  6528. CeErpTradeCell entity = null;
  6529. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6530. if (entity != null)
  6531. {
  6532. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6533. string afterMethod = GetPostString("AfterSaleMethod");
  6534. if (isNeedNewOrder == 1)
  6535. {
  6536. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6537. bool ishav = true;
  6538. if (newentity == null)
  6539. {
  6540. newentity = entity.Clone() as CeErpTradeCell;
  6541. ishav = false;
  6542. newentity.ctid = "S_" + entity.ctid;
  6543. newentity.OrderState = 0;
  6544. //唯一标识
  6545. newentity.OrderSn = newentity.ctid;
  6546. string orderSn = dataHelper.getSaleOrderSn();
  6547. if (orderSn != "")
  6548. {
  6549. newentity.OrderSn = orderSn;
  6550. }
  6551. }
  6552. newentity.UpdateTime = DateTime.Now;
  6553. newentity.AfterSaleState = 0;
  6554. newentity.AfterSaleMethod = afterMethod;
  6555. if (!ishav)
  6556. {
  6557. string memo_str = newentity.seller_memo;
  6558. memo_str = memo_str.Replace("(", "(");
  6559. memo_str = memo_str.Replace(")", ")");
  6560. int sIndex = memo_str.IndexOf("(");
  6561. int eIndex = memo_str.IndexOf(")");
  6562. if (sIndex == -1 || eIndex == -1)
  6563. {
  6564. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6565. return;
  6566. }
  6567. string first = memo_str.Substring(0, sIndex + 1);
  6568. string memoCtid = newentity.OrderSn;
  6569. //if (memoCtid.IndexOf("C") != -1)
  6570. //{
  6571. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6572. //if (CIdx.IndexOf("+") != -1)
  6573. //{
  6574. //CIdx = "C" + CIdx.Split('+')[1];
  6575. //}
  6576. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6577. //}
  6578. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6579. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6580. string newMemo = first + memoCtid + last;
  6581. newentity.seller_memo = newMemo;
  6582. newentity.FinishPlaceTime = null;
  6583. newentity.UnusualTag = 0;
  6584. newentity.UnusualCon = "";
  6585. newentity.UnusualTime = null;
  6586. newentity.AfterSaleMemo = "";
  6587. newentity.AfterSaleMethod = afterMethod;
  6588. newentity.AfterSalePreTime = null;
  6589. newentity.AfterSaleReason = "";
  6590. newentity.AfterSaleResponsible = "";
  6591. newentity.AfterSaleState = 0;
  6592. newentity.AfterSaleTime = null;
  6593. newentity.AfterSaleUserId = 0;
  6594. newentity.AfterSaleSupplierState = 0;
  6595. newentity.LastBillWaybillCode = "";
  6596. newentity.LastBillCpCode = "";
  6597. newentity.FinishAfterSaleTime = null;
  6598. newentity.HandleTime = null;
  6599. newentity.IsSF = 0;
  6600. newentity.IsOldCustomer = 0;
  6601. newentity.UrgencyTime = null;
  6602. newentity.ResponsibleUserId = "";
  6603. newentity.IsVerifyToSupplier = false;
  6604. newentity.payment = 0;
  6605. newentity.CheckMemo = "";
  6606. newentity.OutSid = "";
  6607. newentity.CheckOrderTime = null;
  6608. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6609. }
  6610. newentity.isAfterSaleOrder = 1;
  6611. newentity.IsRefund = 0;
  6612. string receiveMobile = GetPostString("receiver_mobile");
  6613. if (receiveMobile.Length > 0)
  6614. {
  6615. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6616. if (trade != null)
  6617. {
  6618. trade.receiver_name = GetPostString("receiver_name");
  6619. trade.receiver_mobile = receiveMobile;
  6620. trade.receiver_state = GetPostString("receiver_state");
  6621. trade.receiver_city = GetPostString("receiver_city");
  6622. trade.receiver_district = GetPostString("receiver_district");
  6623. trade.receiver_address = GetPostString("receiver_address");
  6624. newentity.IsOffLineOrder = 1;
  6625. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6626. }
  6627. }
  6628. string st = GetPostString("ToState");
  6629. if (st.Length > 0)
  6630. {
  6631. if (newentity.OrderState <= 3)
  6632. {
  6633. newentity.WaitDesignTime = DateTime.Now;
  6634. newentity.StartDesignTime = null;
  6635. newentity.FinishDesignTime = null;
  6636. newentity.OrderState = 3;
  6637. if (st == "下单员")
  6638. {
  6639. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6640. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6641. {
  6642. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6643. }
  6644. }
  6645. else
  6646. {
  6647. newentity.WaitDesignTime = DateTime.Now;
  6648. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6649. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6650. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6651. {
  6652. DataRow user = dt1.Rows[0];
  6653. //找主管
  6654. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6655. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6656. if (dt != null && dt.Rows.Count > 0)
  6657. {
  6658. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6659. newentity.DesignUserId = designMr;
  6660. string key = "aftersale_order_" + designMr;
  6661. if (RedisHelper.HasKey(key))
  6662. {
  6663. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6664. list.Add(newentity.ctid);
  6665. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6666. }
  6667. }
  6668. //账号正常
  6669. if (user["State"].ToString() == "0")
  6670. {
  6671. newentity.DesignUserId = entity.DesignUserId;
  6672. string key = "aftersale_order_" + entity.DesignUserId;
  6673. if (RedisHelper.HasKey(key))
  6674. {
  6675. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6676. list.Add(newentity.ctid);
  6677. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6678. }
  6679. }
  6680. }
  6681. }
  6682. }
  6683. if (entity.IsXianHuo == 1)
  6684. {
  6685. newentity.OrderState = 6;
  6686. entity.FinishPlaceTime = DateTime.Now;
  6687. }
  6688. }
  6689. if (ishav)
  6690. {
  6691. newentity.Update();
  6692. }
  6693. else
  6694. {
  6695. newentity.Create();
  6696. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6697. newCellExtend.ctid = newentity.ctid;
  6698. newCellExtend.orderFrom = 20;
  6699. newCellExtend.orderType = 30;
  6700. if (st == "下单员")
  6701. {
  6702. }
  6703. else
  6704. {
  6705. newCellExtend.ReprintTime = DateTime.Now;
  6706. }
  6707. newCellExtend.Create();
  6708. }
  6709. if (st != "下单员")
  6710. {
  6711. if (entity.DispatchSort == 2)
  6712. {
  6713. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(newentity);
  6714. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6715. }
  6716. }
  6717. }
  6718. //处理售后扩展
  6719. string resIdStr = GetPostString("ResponsibleUserId");
  6720. string refundFees = GetPostString("refundFrees");
  6721. int IsComplain = GetPostInt("isComplain");
  6722. int IsBad = GetPostInt("isBad");
  6723. string IsOriginal = GetPostString("isOriginal");
  6724. double diffResultPrice = GetPostDouble("diffResultPrice");
  6725. string textResult = GetPostString("textResult");
  6726. string supplierResponsible = GetPostString("supplierResponsible");
  6727. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6728. if (ceErpTradeAfterSaleExtend == null)
  6729. {
  6730. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6731. ceErpTradeAfterSaleExtend.tid = eid;
  6732. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6733. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6734. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6735. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6736. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6737. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6738. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6739. ceErpTradeAfterSaleExtend.Create();
  6740. }
  6741. else
  6742. {
  6743. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6744. {
  6745. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6746. }
  6747. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6748. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6749. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6750. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6751. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6752. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6753. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6754. ceErpTradeAfterSaleExtend.Update();
  6755. }
  6756. int gysid = GetPostInt("ResponsibleSupId");
  6757. if (entity.AfterSaleUserId == 0)
  6758. {
  6759. entity.AfterSaleUserId = CurrentUser.UserID;
  6760. }
  6761. entity.ResponsibleUserId = resIdStr;
  6762. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6763. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6764. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6765. {
  6766. CeErpTradeResponsible.DelByTid(eid, -1);
  6767. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6768. int backNum = 0;
  6769. if (number != null)
  6770. {
  6771. backNum = number.BackNum;
  6772. }
  6773. char[] separator = { ',' };
  6774. string[] sArray = resIdStr.Split(separator);
  6775. string[] refundFreeList = { };
  6776. if (refundFees.Length > 0)
  6777. {
  6778. refundFreeList = refundFees.Split(separator);
  6779. }
  6780. int index = -1;
  6781. foreach (string i in sArray)
  6782. {
  6783. index++;
  6784. if (i.Length <= 0) continue;
  6785. char[] separator2 = { '_' };
  6786. string idstr = i.Split(separator2)[0];
  6787. string idtype = i.Split(separator2)[1];
  6788. double refudFree = 0;
  6789. if (refundFreeList.Length > 0)
  6790. {
  6791. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6792. }
  6793. if (idtype == "s")
  6794. {
  6795. isDesign = true;
  6796. designFree = refudFree;
  6797. }
  6798. int userId = Convert.ToInt32(idstr);
  6799. int type = 0;
  6800. if (idtype == "g")
  6801. {
  6802. type = 1;
  6803. }
  6804. if (idtype == "w")
  6805. {
  6806. type = 2;
  6807. }
  6808. if (idtype == "t")
  6809. {
  6810. type = 3;
  6811. }
  6812. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6813. if (ceErpTradeResponsible == null)
  6814. {
  6815. ceErpTradeResponsible = new CeErpTradeResponsible();
  6816. ceErpTradeResponsible.tid = eid;
  6817. ceErpTradeResponsible.UserId = userId;
  6818. ceErpTradeResponsible.createdTime = DateTime.Now;
  6819. ceErpTradeResponsible.type = type;
  6820. if (type == 1)
  6821. {
  6822. ceErpTradeResponsible.IsSup = 1;
  6823. }
  6824. if (type == 2)
  6825. {
  6826. ceErpTradeResponsible.IsFlow = 1;
  6827. }
  6828. }
  6829. ceErpTradeResponsible.RefundFee = refudFree;
  6830. ceErpTradeResponsible.VerifyState = 0;
  6831. if (userId == 2125 || idtype == "w")
  6832. {
  6833. ceErpTradeResponsible.VerifyState = 1;
  6834. }
  6835. if (idtype == "w" && userId == 101)
  6836. {
  6837. ceErpTradeResponsible.VerifyState = 0;
  6838. }
  6839. if (ceErpTradeResponsible.ID > 0)
  6840. {
  6841. ceErpTradeResponsible.Update();
  6842. }
  6843. else
  6844. {
  6845. ceErpTradeResponsible.Create();
  6846. }
  6847. if (isDesign)
  6848. {
  6849. responsibleId = ceErpTradeResponsible.ID;
  6850. }
  6851. }
  6852. CeErpTradeResponsible.NumByTid(backNum, eid);
  6853. }
  6854. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6855. if (ceErpTradeCellExtend != null)
  6856. {
  6857. ceErpTradeCellExtend.returnVisit = 0;
  6858. ceErpTradeCellExtend.Update();
  6859. }
  6860. if (entity.HandleTime != null)
  6861. {
  6862. if (entity.AfterSaleState == 1)
  6863. {
  6864. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6865. }
  6866. else
  6867. {
  6868. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6869. }
  6870. }
  6871. else
  6872. {
  6873. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6874. entity.HandleTime = DateTime.Now;
  6875. }
  6876. bool isCompale = false;
  6877. if (entity.AfterSaleState == 5)
  6878. {
  6879. isCompale = true;
  6880. entity.AfterSaleState = 3;
  6881. }
  6882. entity.AfterSaleSupplierState = 0;
  6883. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6884. {
  6885. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6886. }
  6887. string sImgs = GetPostString("img");
  6888. entity.AfterSaleSupplierImg = sImgs;
  6889. entity.supRefundType = GetPostString("supRefundType");
  6890. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6891. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6892. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6893. entity.AfterSaleMemoType = GetPostString("MemoType");
  6894. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6895. {
  6896. //entity.AfterSaleSupplierState = 2;
  6897. }
  6898. string df = GetPostString("DeductFee");
  6899. if (df == "")
  6900. {
  6901. df = "0";
  6902. }
  6903. string rf = GetPostString("RefundFee");
  6904. if (rf == "")
  6905. {
  6906. rf = "0";
  6907. }
  6908. string pm = GetPostString("AfterSalePayment");
  6909. if (pm == "")
  6910. {
  6911. pm = "0";
  6912. }
  6913. entity.AfterSalePayment = Convert.ToDouble(pm);
  6914. entity.DeductFee = Convert.ToDouble(df);
  6915. entity.RefundFee = Convert.ToDouble(rf);
  6916. entity.UpdateTime = DateTime.Now;
  6917. entity.Update();
  6918. string toState = GetPostString("ToState");
  6919. string original = GetPostString("isOriginal");
  6920. ApiVo apiVo = new ApiVo();
  6921. apiVo.orderNumber = entity.ctid;
  6922. apiVo.actionName = "afterDesign";
  6923. apiVo.orderRemarks = entity.AfterSaleMethod;
  6924. apiVo.reasonRemarks = entity.AfterSaleReason;
  6925. apiVo.isDesign = isDesign;
  6926. apiVo.designFree = designFree;
  6927. apiVo.responsibleId = responsibleId;
  6928. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6929. if (toState == "设计师")
  6930. {
  6931. apiVo.isOriginal = Convert.ToBoolean(original);
  6932. }
  6933. designHelper.API_WorkCore(apiVo);//afterDesign
  6934. CeErpMethod methodSql = new CeErpMethod();
  6935. methodSql.con = entity.AfterSaleMethod;
  6936. methodSql.addTime = DateTime.Now;
  6937. methodSql.Create();
  6938. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6939. CeErpMethod.ExecuteNonQuery(delsql);
  6940. if (isCompale)
  6941. {
  6942. aftersale_data_change(entity.ctid);
  6943. }
  6944. returnSuccessMsg("操作成功!");
  6945. return;
  6946. }
  6947. returnErrorMsg("找不到订单记录");
  6948. }
  6949. }
  6950. public void ins_erp_toresponsible()
  6951. {
  6952. if (UrlPostParmsCheck("ctid"))
  6953. {
  6954. string eid = GetPostString("ctid");
  6955. CeErpTradeCell entity = null;
  6956. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6957. if (entity != null)
  6958. {
  6959. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6960. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6961. {
  6962. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6963. return;
  6964. }
  6965. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6966. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6967. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6968. if (entity.AfterSalePreTime == null)
  6969. {
  6970. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6971. {
  6972. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6973. }
  6974. }
  6975. entity.AfterSalePreTime = DateTime.Now;
  6976. //预完成给售后主管审核客户问题直接完成
  6977. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6978. {
  6979. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6980. {
  6981. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6982. }
  6983. }
  6984. ceErpTradeAfterSaleExtend.Update();
  6985. entity.AfterSaleState = 2;
  6986. entity.UpdateTime = DateTime.Now;
  6987. entity.Update();
  6988. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6989. aftersale_data_change(entity.ctid);
  6990. returnSuccessMsg("操作成功!");
  6991. return;
  6992. }
  6993. returnErrorMsg("找不到订单记录");
  6994. }
  6995. }
  6996. public void cancel_erp_aftersaleanddelnew()
  6997. {
  6998. if (UrlPostParmsCheck("ctid"))
  6999. {
  7000. string eid = GetPostString("ctid");
  7001. CeErpTradeCell entity = null;
  7002. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7003. if (entity != null)
  7004. {
  7005. entity.AfterSaleState = 0;
  7006. entity.AfterSaleReason = "";
  7007. entity.AfterSaleMethod = "";
  7008. entity.AfterSaleMemo = "";
  7009. entity.AfterSaleResponsible = "";
  7010. entity.ResponsibleUserId = "";
  7011. entity.DeductFee = 0;
  7012. entity.RefundFee = 0;
  7013. entity.IsArbitrate = 0;
  7014. CeErpTradeResponsible.DelByTid(eid, -1);
  7015. entity.Update();
  7016. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7017. if (after != null)
  7018. {
  7019. if (after.OrderState < 5)
  7020. CeErpTradeCell.DelByCtid("S_" + eid);
  7021. }
  7022. returnSuccessMsg("操作成功!");
  7023. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7024. return;
  7025. }
  7026. returnErrorMsg("找不到订单记录");
  7027. }
  7028. }
  7029. public void get_erp_aftersale_pregather()
  7030. {
  7031. List<string> lw = new List<string>();
  7032. int st = GetInt("st");
  7033. string tid = GetPostString("ctid");
  7034. if (tid.Length > 0)
  7035. {
  7036. string select_tid = getTidByCtid(tid);
  7037. lw.Add(string.Format("tid='{0}'", select_tid));
  7038. }
  7039. string shopname = GetPostString("shopname");
  7040. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7041. string buyernick = GetPostString("buyer_nick");
  7042. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7043. string sellermemo = GetPostString("seller_memo");
  7044. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7045. string orderState = GetPostString("orderState");
  7046. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7047. string reason = GetPostString("reason");
  7048. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7049. string method = GetPostString("method");
  7050. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7051. string handler = GetPostString("handler");
  7052. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7053. string handledate1 = GetPostString("handledate1");
  7054. string handledate2 = GetPostString("handledate2");
  7055. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7056. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7057. string supplier = GetPostString("supplier");
  7058. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7059. string responsible = GetPostString("responsibleman");
  7060. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7061. string customer = GetPostString("customer");
  7062. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7063. string design = GetPostString("design");
  7064. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7065. string afterMemoType = GetPostString("aftermemotype");
  7066. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7067. string afterSaleMemo = GetPostString("afterSaleMemo");
  7068. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7069. string afterresult = GetPostString("afterresult");
  7070. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7071. string poscode = CurrentUser.UserPost.Post.Code;
  7072. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7073. {
  7074. string shopid = CurrentUser.User.pemShop;
  7075. lw.Add(string.Format("shopId in ({0})", shopid));
  7076. }
  7077. var mainwhere = string.Join(" and ", lw.ToArray());
  7078. string ro_json = "";
  7079. string type = GetPostString("gather_type");
  7080. int number = 0;
  7081. if (poscode == "AfterSale")
  7082. {
  7083. //处理中
  7084. if (type == "Handling")
  7085. {
  7086. 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) : ""));
  7087. DataTable dt = null;
  7088. try
  7089. {
  7090. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7091. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7092. }
  7093. catch (Exception e)
  7094. {
  7095. dt = new DataTable();
  7096. }
  7097. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7098. return;
  7099. }
  7100. if (type == "Wait")
  7101. {
  7102. //待处理
  7103. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7104. DataTable dt1 = null;
  7105. try
  7106. {
  7107. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7108. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7109. }
  7110. catch (Exception e)
  7111. {
  7112. dt1 = new DataTable();
  7113. }
  7114. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7115. return;
  7116. }
  7117. if (type == "back")
  7118. {
  7119. //打回
  7120. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7121. DataTable dt2 = null;
  7122. try
  7123. {
  7124. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7125. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7126. }
  7127. catch (Exception e)
  7128. {
  7129. dt2 = new DataTable();
  7130. }
  7131. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7132. return;
  7133. }
  7134. if (type == "preCompletion")
  7135. {
  7136. //预完成
  7137. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7138. DataTable dt3 = null;
  7139. try
  7140. {
  7141. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7142. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7143. }
  7144. catch (Exception e)
  7145. {
  7146. dt3 = new DataTable();
  7147. }
  7148. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7149. return;
  7150. }
  7151. if (type == "documentary")
  7152. {
  7153. //跟单中
  7154. 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) : ""));
  7155. DataTable dt4 = null;
  7156. try
  7157. {
  7158. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7159. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7160. }
  7161. catch (Exception e)
  7162. {
  7163. dt4 = new DataTable();
  7164. }
  7165. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7166. return;
  7167. }
  7168. if (type == "reBack")
  7169. {
  7170. //被打回
  7171. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7172. DataTable dt1 = null;
  7173. try
  7174. {
  7175. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7176. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7177. }
  7178. catch (Exception e)
  7179. {
  7180. dt1 = new DataTable();
  7181. }
  7182. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7183. return;
  7184. }
  7185. }
  7186. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7187. {
  7188. if (type == "puBack")
  7189. {
  7190. //退回
  7191. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7192. DataTable dt = null;
  7193. try
  7194. {
  7195. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7196. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7197. }
  7198. catch (Exception e)
  7199. {
  7200. dt = new DataTable();
  7201. }
  7202. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7203. return;
  7204. }
  7205. if (type == "reBack")
  7206. {
  7207. //打回
  7208. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7209. DataTable dt1 = null;
  7210. try
  7211. {
  7212. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7213. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7214. }
  7215. catch (Exception e)
  7216. {
  7217. dt1 = new DataTable();
  7218. }
  7219. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7220. return;
  7221. }
  7222. if (type == "examEd")
  7223. {
  7224. //已审核
  7225. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7226. DataTable dt2 = null;
  7227. try
  7228. {
  7229. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7230. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7231. }
  7232. catch (Exception e)
  7233. {
  7234. dt2 = new DataTable();
  7235. }
  7236. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7237. return;
  7238. }
  7239. if (type == "waitExam")
  7240. {
  7241. //待审核
  7242. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7243. DataTable dt3 = null;
  7244. try
  7245. {
  7246. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7247. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7248. }
  7249. catch (Exception e)
  7250. {
  7251. dt3 = new DataTable();
  7252. }
  7253. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7254. return;
  7255. }
  7256. if (type == "Handling")
  7257. {
  7258. //处理中
  7259. 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) : ""));
  7260. DataTable dt4 = null;
  7261. try
  7262. {
  7263. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7264. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7265. }
  7266. catch (Exception e)
  7267. {
  7268. dt4 = new DataTable();
  7269. }
  7270. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7271. return;
  7272. }
  7273. if (type == "Wait")
  7274. {
  7275. //待处理
  7276. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7277. DataTable dt5 = null;
  7278. try
  7279. {
  7280. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7281. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7282. }
  7283. catch (Exception e)
  7284. {
  7285. dt5 = new DataTable();
  7286. }
  7287. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7288. return;
  7289. }
  7290. if (type == "documentary")
  7291. {
  7292. //跟单中
  7293. 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) : ""));
  7294. DataTable dt6 = null;
  7295. try
  7296. {
  7297. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7298. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7299. }
  7300. catch (Exception e)
  7301. {
  7302. dt6 = new DataTable();
  7303. }
  7304. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7305. return;
  7306. }
  7307. }
  7308. returnSuccess(ro_json);
  7309. }
  7310. public void end_erp_aftersale()
  7311. {
  7312. if (UrlPostParmsCheck("ctid"))
  7313. {
  7314. string eid = GetPostString("ctid");
  7315. CeErpTradeCell entity = null;
  7316. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7317. if (entity != null)
  7318. {
  7319. string stype = GetPostString("stype");
  7320. string typeStr = stype;
  7321. entity.AfterSaleState = 4;
  7322. entity.FinishAfterSaleTime = DateTime.Now;
  7323. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7324. entity.Update();
  7325. ApiVo apiVo = new ApiVo();
  7326. apiVo.orderNumber = entity.ctid;
  7327. apiVo.actionName = "afterOver";
  7328. designHelper.API_WorkCore(apiVo); //afterOver
  7329. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7330. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7331. CeErpSukuraData.createInfo(entity.ctid, 8);
  7332. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7333. returnSuccessMsg("操作成功!");
  7334. return;
  7335. }
  7336. returnErrorMsg("找不到订单记录");
  7337. }
  7338. }
  7339. public void ins_erp_finishaftersale()
  7340. {
  7341. if (UrlPostParmsCheck("id"))
  7342. {
  7343. string eid = GetPostString("id");
  7344. CeErpTradeResponsible entity = null;
  7345. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7346. if (entity != null)
  7347. {
  7348. entity.VerifyState = 1;
  7349. entity.VerifyTime = DateTime.Now;
  7350. entity.Update();
  7351. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7352. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7353. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7354. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7355. if (dt.Rows.Count <= 0)
  7356. {
  7357. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7358. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7359. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7360. CeErpSukuraData.createInfo(entity.tid, 8);
  7361. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7362. {
  7363. CeErpDesignerBill.Del(entity.tid);
  7364. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7365. }
  7366. }
  7367. returnSuccessMsg("操作成功!");
  7368. return;
  7369. }
  7370. returnErrorMsg("找不到订单记录");
  7371. }
  7372. }
  7373. public void upd_erp_arbitrateaftersale()
  7374. {
  7375. if (UrlPostParmsCheck("id"))
  7376. {
  7377. string eid = GetPostString("id");
  7378. CeErpTradeResponsible entity = null;
  7379. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7380. if (entity != null)
  7381. {
  7382. entity.IsArbitrate = 1;
  7383. entity.ArbitradeMemo = GetPostString("reason");
  7384. entity.VerifyState = 2;
  7385. entity.Update();
  7386. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7387. if (tradecell != null)
  7388. {
  7389. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7390. tradecell.IsArbitrate = 1;
  7391. tradecell.Update();
  7392. }
  7393. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7394. returnSuccessMsg("操作成功!");
  7395. return;
  7396. }
  7397. returnErrorMsg("找不到订单记录");
  7398. }
  7399. }
  7400. public void upd_erp_backaftersale()
  7401. {
  7402. if (UrlPostParmsCheck("tid"))
  7403. {
  7404. string eid = GetPostString("tid");
  7405. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7406. int backNum = 0;
  7407. if (number != null)
  7408. {
  7409. backNum = number.BackNum;
  7410. }
  7411. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7412. CeErpTradeCell entity = null;
  7413. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7414. if (entity != null)
  7415. {
  7416. entity.AfterSaleBackReason = GetPostString("backreason");
  7417. entity.AfterSaleState = 1;
  7418. entity.AfterSaleSupplierState = 0;
  7419. entity.UpdateTime = DateTime.Now;
  7420. entity.Update();
  7421. returnSuccessMsg("操作成功!");
  7422. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7423. return;
  7424. }
  7425. returnErrorMsg("找不到订单记录");
  7426. }
  7427. }
  7428. public void get_erp_supplieraftersalelist()
  7429. {
  7430. DataStruct dStruct = GetPostStruct();
  7431. List<string> lw = new List<string>();
  7432. string tid = GetPostString("ctid");
  7433. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7434. string shopname = GetPostString("shopname");
  7435. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7436. string buyernick = GetPostString("buyer_nick");
  7437. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7438. string sellermemo = GetPostString("seller_memo");
  7439. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7440. string orderState = GetPostString("orderState");
  7441. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7442. string afterState = GetPostString("afterstate");
  7443. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7444. string date1 = GetPostString("date1");
  7445. string date2 = GetPostString("date2");
  7446. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7447. if (dw.Length > 0) lw.Add(dw);
  7448. string price1 = GetPostString("price1");
  7449. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7450. string price2 = GetPostString("price2");
  7451. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7452. string reason = GetPostString("reason");
  7453. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7454. string method = GetPostString("method");
  7455. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7456. string handledate1 = GetPostString("handledate1");
  7457. string handledate2 = GetPostString("handledate2");
  7458. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7459. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7460. string handler = GetPostString("handler");
  7461. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7462. string afterdate1 = GetPostString("afterdate1");
  7463. string afterdate2 = GetPostString("afterdate2");
  7464. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7465. if (afterDate.Length > 0) lw.Add(afterDate);
  7466. string customer = GetPostString("customer");
  7467. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7468. string design = GetPostString("design");
  7469. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7470. string afterMemoType = GetPostString("aftermemotype");
  7471. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7472. string vstate = GetPostString("vstate");
  7473. if (vstate.Length > 0)
  7474. {
  7475. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7476. }
  7477. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7478. string supplier = GetPostString("supplier");
  7479. int supid = commonHelper.getSupplierIDByName(supplier);
  7480. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7481. string posCode = CurrentUser.UserPost.Post.Code;
  7482. if (posCode == "Supplier")
  7483. {
  7484. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7485. }
  7486. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7487. {
  7488. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7489. }
  7490. else
  7491. {
  7492. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7493. }
  7494. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7495. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7496. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7497. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7498. writeGridDataTableJson(dStruct.TotalCount, dt);
  7499. }
  7500. public void upd_erp_supverifyaftersale()
  7501. {
  7502. if (UrlPostParmsCheck("id"))
  7503. {
  7504. string id = GetPostString("id");
  7505. int st = GetPostInt("afterstate");
  7506. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7507. CeErpTradeCell entity = null;
  7508. if (ceErpTradeResponsible != null)
  7509. {
  7510. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7511. }
  7512. string afmemo = GetPostString("supmemo");
  7513. string image = GetPostString("image");
  7514. if (entity != null)
  7515. {
  7516. entity.AfterSaleSupplierState = st;
  7517. entity.AfterSaleSupplierMemo = afmemo;
  7518. if (st == 1)
  7519. {
  7520. ceErpTradeResponsible.VerifyState = 1;
  7521. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7522. ceErpTradeResponsible.Update();
  7523. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7524. if (isAll)
  7525. {
  7526. entity.AfterSaleState = 4;
  7527. entity.FinishAfterSaleTime = DateTime.Now;
  7528. }
  7529. }
  7530. else
  7531. {
  7532. CeErpTradeResponsible.dateByTid(entity.ctid);
  7533. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7534. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7535. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7536. if (num <= 1)
  7537. {
  7538. entity.AfterSaleState = 1;
  7539. }
  7540. else
  7541. {
  7542. entity.AfterSaleState = 5;
  7543. }
  7544. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7545. if (ceErpTradeAfterSaleExtend != null)
  7546. {
  7547. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7548. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7549. ceErpTradeAfterSaleExtend.Update();
  7550. }
  7551. else
  7552. {
  7553. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7554. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7555. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7556. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7557. ceErpTradeAfterSaleExtend.Create();
  7558. }
  7559. }
  7560. if (entity.AfterSaleState == 4)
  7561. {
  7562. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7563. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7564. {
  7565. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7566. }
  7567. ApiVo apiVo = new ApiVo();
  7568. apiVo.orderNumber = entity.ctid;
  7569. apiVo.actionName = "afterOver";
  7570. designHelper.API_WorkCore(apiVo); //afterOver
  7571. }
  7572. entity.UpdateTime = DateTime.Now;
  7573. entity.Update();
  7574. returnSuccessMsg("操作成功!");
  7575. CeErpSukuraData.createInfo(entity.ctid, 8);
  7576. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7577. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7578. return;
  7579. }
  7580. returnErrorMsg("找不到订单记录");
  7581. }
  7582. }
  7583. public void upd_erp_masteraftersale()
  7584. {
  7585. if (UrlPostParmsCheck("id"))
  7586. {
  7587. string id = GetPostString("id");
  7588. int st = GetPostInt("afterstate");
  7589. string afmemo = GetPostString("supmemo");
  7590. string image = GetPostString("image");
  7591. string textResult = GetPostString("textResult");
  7592. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7593. if (ceErpTradeResponsible != null)
  7594. {
  7595. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7596. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7597. ceErpTradeResponsible.Update();
  7598. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7599. if (entity != null)
  7600. {
  7601. entity.AfterSaleSupplierState = st;
  7602. entity.AfterSaleSupplierMemo = afmemo;
  7603. if (st == 1)
  7604. {
  7605. }
  7606. else
  7607. {
  7608. CeErpTradeResponsible.dateByTid(entity.ctid);
  7609. //退回到售后
  7610. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7611. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7612. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7613. if (num <= 1)
  7614. {
  7615. entity.AfterSaleState = 1;
  7616. }
  7617. else
  7618. {
  7619. entity.AfterSaleState = 5;
  7620. }
  7621. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7622. if (ceErpTradeAfterSaleExtend != null)
  7623. {
  7624. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7625. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7626. ceErpTradeAfterSaleExtend.Update();
  7627. }
  7628. else
  7629. {
  7630. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7631. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7632. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7633. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7634. ceErpTradeAfterSaleExtend.Create();
  7635. }
  7636. }
  7637. entity.UpdateTime = DateTime.Now;
  7638. entity.Update();
  7639. returnSuccessMsg("操作成功!");
  7640. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7641. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7642. return;
  7643. }
  7644. }
  7645. returnErrorMsg("找不到订单记录");
  7646. }
  7647. }
  7648. public void upd_erp_personaftersale()
  7649. {
  7650. if (UrlPostParmsCheck("id"))
  7651. {
  7652. //林小连
  7653. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7654. {
  7655. upd_erp_masteraftersale();
  7656. return;
  7657. }
  7658. string id = GetPostString("id");
  7659. int st = GetPostInt("afterstate");
  7660. string afmemo = GetPostString("supmemo");
  7661. string image = GetPostString("image");
  7662. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7663. if (ceErpTradeResponsible != null)
  7664. {
  7665. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7666. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7667. ceErpTradeResponsible.Update();
  7668. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7669. if (entity != null)
  7670. {
  7671. entity.AfterSaleSupplierMemo = afmemo;
  7672. entity.AfterSaleSupplierState = st;
  7673. if (st == 1)
  7674. {
  7675. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7676. if (isAll)
  7677. {
  7678. entity.AfterSaleState = 4;
  7679. entity.FinishAfterSaleTime = DateTime.Now;
  7680. }
  7681. }
  7682. else
  7683. {
  7684. CeErpTradeResponsible.dateByTid(entity.ctid);
  7685. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7686. if (ceErpTradeAfterSaleExtend != null)
  7687. {
  7688. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7689. ceErpTradeAfterSaleExtend.Update();
  7690. }
  7691. else
  7692. {
  7693. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7694. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7695. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7696. ceErpTradeAfterSaleExtend.Create();
  7697. }
  7698. //退回到主管
  7699. //entity.AfterSaleState = 2;
  7700. }
  7701. if (entity.AfterSaleState == 4)
  7702. {
  7703. ApiVo apiVo = new ApiVo();
  7704. apiVo.orderNumber = entity.ctid;
  7705. apiVo.actionName = "afterOver";
  7706. designHelper.API_WorkCore(apiVo); //afterOver
  7707. }
  7708. entity.UpdateTime = DateTime.Now;
  7709. entity.Update();
  7710. returnSuccessMsg("操作成功!");
  7711. CeErpSukuraData.createInfo(entity.ctid, 8);
  7712. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7713. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7714. return;
  7715. }
  7716. }
  7717. returnErrorMsg("找不到订单记录");
  7718. }
  7719. }
  7720. public void set_erp_supplierrefundtag()
  7721. {
  7722. if (UrlPostParmsCheck("ctid"))
  7723. {
  7724. string eid = GetPostString("ctid");
  7725. CeErpTradeCell entity = null;
  7726. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7727. if (entity != null)
  7728. {
  7729. entity.IsSupplierRefund = GetPostInt("tag");
  7730. entity.Update();
  7731. returnSuccessMsg("操作成功!");
  7732. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7733. return;
  7734. }
  7735. returnErrorMsg("找不到订单记录");
  7736. }
  7737. }
  7738. public void get_erp_refundlist()
  7739. {
  7740. DataStruct dStruct = GetPostStruct();
  7741. List<string> lw = new List<string>();
  7742. string tid = GetPostString("tid");
  7743. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7744. //string rid = GetPostString("refund_id");
  7745. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7746. string shopname = GetPostString("shopname");
  7747. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7748. string buyernick = GetPostString("buyer_nick");
  7749. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7750. string customer = GetPostString("customer");
  7751. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7752. string design = GetPostString("design");
  7753. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7754. string sellermemo = GetPostString("seller_memo");
  7755. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7756. //string date1 = GetPostString("date1");
  7757. //string date2 = GetPostString("date2");
  7758. //string dateType = GetPostString("dateType");
  7759. //if (dateType.Length > 0)
  7760. //{
  7761. // if (dateType == "1001") dateType = "0";
  7762. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7763. // if (searchDT.Count == 2)
  7764. // {
  7765. // date1 = searchDT[0].ToString();
  7766. // date2 = searchDT[1].ToString();
  7767. // }
  7768. //}
  7769. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7770. //if (dw.Length > 0) lw.Add(dw);
  7771. string redate1 = GetPostString("refunddate1");
  7772. string redate2 = GetPostString("refunddate2");
  7773. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7774. if (dwdate.Length > 0) lw.Add(dwdate);
  7775. string price1 = GetPostString("price1");
  7776. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7777. string price2 = GetPostString("price2");
  7778. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7779. string ispartrefund = GetPostString("ispartrefund");
  7780. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7781. string refundState = GetPostString("refundvstate");
  7782. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7783. int st = GetInt("st");
  7784. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7785. {
  7786. string responsible = GetPostString("responsibleman");
  7787. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7788. lw.Add(string.Format("RefundState>={0}", st));
  7789. string code = CurrentUser.UserPost.Post.Code;
  7790. if (code == "CustomerService")
  7791. {
  7792. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7793. }
  7794. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7795. {
  7796. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7797. }
  7798. else if (code == "Place" || code == "PlaceMr")
  7799. {
  7800. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7801. }
  7802. dStruct.Order = "RefundState asc,created desc";
  7803. }
  7804. else if (st == 10)
  7805. {
  7806. string responsible = GetPostString("responsibleman");
  7807. if (responsible == "空白")
  7808. {
  7809. lw.Add(string.Format("ResponsibleUserName = ''"));
  7810. }
  7811. else if (responsible.Length > 0)
  7812. {
  7813. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7814. }
  7815. lw.Add(string.Format("RefundState>=0"));
  7816. dStruct.Order = "created desc";
  7817. }
  7818. else
  7819. {
  7820. string responsible = GetPostString("responsibleman");
  7821. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7822. lw.Add(string.Format("RefundState={0}", st));
  7823. dStruct.Order = "created desc";
  7824. }
  7825. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7826. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7827. dt.Columns.Add("refund_fees");
  7828. foreach (DataRow dr in dt.Rows)
  7829. {
  7830. String status = dr["status"].ToString();
  7831. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7832. {
  7833. dr["refund_fees"] = dr["refund_fee"];
  7834. }
  7835. else
  7836. {
  7837. dr["refund_fees"] = "0.0";
  7838. }
  7839. }
  7840. writeGridDataTableJson(dStruct.TotalCount, dt);
  7841. }
  7842. public void get_erp_refunddesignlist()
  7843. {
  7844. DataStruct dStruct = GetPostStruct();
  7845. List<string> lw = new List<string>();
  7846. string tid = GetPostString("tid");
  7847. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7848. string shopname = GetPostString("shopname");
  7849. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7850. string buyernick = GetPostString("buyer_nick");
  7851. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7852. string customer = GetPostString("customer");
  7853. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7854. string design = GetPostString("design");
  7855. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7856. string sellermemo = GetPostString("seller_memo");
  7857. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7858. string redate1 = GetPostString("refunddate1");
  7859. string redate2 = GetPostString("refunddate2");
  7860. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7861. if (dwdate.Length > 0) lw.Add(dwdate);
  7862. string price1 = GetPostString("price1");
  7863. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7864. string price2 = GetPostString("price2");
  7865. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7866. string ispartrefund = GetPostString("ispartrefund");
  7867. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7868. string designerorg = GetPostString("designerorg");
  7869. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7870. string refundState = GetPostString("refundState");
  7871. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7872. int myOrgid = CurrentUser.UserPost.OrgID;
  7873. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7874. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7875. {
  7876. if (CurrentUser.User.TeamIds.Length > 0)
  7877. {
  7878. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7879. }
  7880. else
  7881. {
  7882. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7883. }
  7884. }
  7885. else if ("SysAdmin".Equals(myOrgCode))
  7886. {
  7887. }
  7888. else
  7889. {
  7890. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7891. {
  7892. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7893. }
  7894. else
  7895. {
  7896. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7897. }
  7898. }
  7899. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7900. dStruct.Order = "created desc";
  7901. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7902. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7903. dt.Columns.Add("refund_fees");
  7904. foreach (DataRow dr in dt.Rows)
  7905. {
  7906. String status = dr["status"].ToString();
  7907. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7908. {
  7909. dr["refund_fees"] = dr["refund_fee"];
  7910. }
  7911. else
  7912. {
  7913. dr["refund_fees"] = "0.0";
  7914. }
  7915. }
  7916. writeGridDataTableJson(dStruct.TotalCount, dt);
  7917. }
  7918. public void handle_erp_refundtag()
  7919. {
  7920. if (UrlPostParmsCheck("refund_id"))
  7921. {
  7922. string eid = GetPostString("refund_id");
  7923. string respMan = GetPostString("ResponsibleName");
  7924. if (respMan.Length <= 0)
  7925. {
  7926. returnErrorMsg("责任人不能为空");
  7927. return;
  7928. }
  7929. CeErpTradeRefund entity = null;
  7930. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7931. if (entity != null)
  7932. {
  7933. entity.ResponsibleUserName = respMan;
  7934. string userid = GetPostString("ResponsibleUserId");
  7935. if (userid.Length > 0)
  7936. {
  7937. entity.ResponsibleUserId = userid;
  7938. }
  7939. entity.Memo = GetPostString("Memo");
  7940. if (respMan.IndexOf("客服") != -1 ||
  7941. respMan.IndexOf("设计师") != -1 ||
  7942. respMan.IndexOf("下单员") != -1)
  7943. {
  7944. entity.RefundState = 2;
  7945. }
  7946. else
  7947. {
  7948. entity.RefundState = 3;
  7949. }
  7950. entity.modified = DateTime.Now;
  7951. entity.Update();
  7952. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7953. returnSuccessMsg("操作成功!");
  7954. return;
  7955. }
  7956. returnErrorMsg("找不到订单记录");
  7957. }
  7958. }
  7959. public void handle_erp_designrefundtag()
  7960. {
  7961. if (UrlPostParmsCheck("refund_id"))
  7962. {
  7963. string eid = GetPostString("refund_id");
  7964. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7965. if (ceErpTradeCellExtend == null)
  7966. {
  7967. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7968. ceErpTradeCellExtend.ctid = eid;
  7969. }
  7970. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7971. if (ceErpTradeCellExtend.ID > 0)
  7972. {
  7973. ceErpTradeCellExtend.Update();
  7974. }
  7975. else
  7976. {
  7977. ceErpTradeCellExtend.Create();
  7978. }
  7979. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7980. returnSuccessMsg("操作成功!");
  7981. return;
  7982. }
  7983. returnErrorMsg("找不到订单记录");
  7984. }
  7985. public void upd_erp_refundverify()
  7986. {
  7987. if (UrlPostParmsCheck("refund_id"))
  7988. {
  7989. string eid = GetPostString("refund_id");
  7990. CeErpTradeRefund entity = null;
  7991. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7992. if (entity != null)
  7993. {
  7994. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7995. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7996. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7997. {
  7998. entity.RefundState = 2;
  7999. }
  8000. else
  8001. {
  8002. entity.RefundState = 3;
  8003. }
  8004. entity.Update();
  8005. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8006. returnSuccessMsg("操作成功!");
  8007. return;
  8008. }
  8009. returnErrorMsg("找不到订单记录");
  8010. }
  8011. }
  8012. public void upd_erp_refundapprove()
  8013. {
  8014. if (UrlPostParmsCheck("refund_id"))
  8015. {
  8016. string eid = GetPostString("refund_id");
  8017. CeErpTradeRefund entity = null;
  8018. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8019. if (entity != null)
  8020. {
  8021. int apr = GetPostInt("approve");
  8022. if (apr == 0)
  8023. {
  8024. entity.RefundState = 1;
  8025. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8026. }
  8027. else if (apr == 1)
  8028. {
  8029. entity.RefundState = 3;
  8030. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8031. }
  8032. entity.modified = DateTime.Now;
  8033. entity.Update();
  8034. returnSuccessMsg("操作成功!");
  8035. return;
  8036. }
  8037. returnErrorMsg("找不到订单记录");
  8038. }
  8039. }
  8040. public void get_erp_billlist()
  8041. {
  8042. DataStruct dStruct = GetPostStruct();
  8043. List<string> lw = new List<string>();
  8044. string title = GetPostString("title");
  8045. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8046. string tid = GetPostString("tid");
  8047. string tids = GetPostString("tids");
  8048. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8049. if (tids.Length > 0)
  8050. {
  8051. tids = "'" + tids + "'";
  8052. tids = tids.Replace(",", "','");
  8053. lw.Add(string.Format("tid in ({0})", tids));
  8054. }
  8055. string shopname = GetPostString("shopname");
  8056. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8057. string buyernick = GetPostString("buyer_nick");
  8058. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8059. string customer = GetPostString("customer");
  8060. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8061. string date1 = GetPostString("date1");
  8062. string date2 = GetPostString("date2");
  8063. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8064. if (dw.Length > 0) lw.Add(dw);
  8065. string price1 = GetPostString("price1");
  8066. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8067. string price2 = GetPostString("price2");
  8068. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8069. string returndate1 = GetPostString("returndate1");
  8070. string returndate2 = GetPostString("returndate2");
  8071. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8072. if (dw1.Length > 0) lw.Add(dw1);
  8073. string billtype = GetPostString("billtype");
  8074. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8075. string billstate = GetPostString("billstate");
  8076. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8077. string usershop = CurrentUser.User.pemShop;
  8078. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8079. dStruct.Order = "createTime desc";
  8080. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8081. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8082. //foreach (DataRow dr in dt.Rows)
  8083. //{
  8084. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8085. //}
  8086. writeGridDataTableJson(dStruct.TotalCount, dt);
  8087. }
  8088. public void modify_erp_billinfo()
  8089. {
  8090. if (UrlPostParmsCheck("ID"))
  8091. {
  8092. string eid = GetPostString("ID");
  8093. CeErpBill bill_entity = null;
  8094. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8095. if (bill_entity != null)
  8096. {
  8097. bill_entity.tid = GetPostString("tid");
  8098. bill_entity.title = GetPostString("title");
  8099. bill_entity.tax = GetPostString("tax");
  8100. bill_entity.bank = GetPostString("bank");
  8101. bill_entity.bankac = GetPostString("bankac");
  8102. bill_entity.address = GetPostString("address");
  8103. bill_entity.phone = GetPostString("phone");
  8104. bill_entity.price = GetPostString("price");
  8105. bill_entity.productId = GetPostInt("ProductName");
  8106. bill_entity.num = GetPostInt("num");
  8107. bill_entity.unit = GetPostString("unit");
  8108. bill_entity.type = GetPostString("type");
  8109. bill_entity.sendType = GetPostString("SendType");
  8110. bill_entity.email = GetPostString("email");
  8111. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8112. bill_entity.shopName = GetPostString("ShopName");
  8113. bill_entity.applymemo = GetPostString("applymemo");
  8114. bill_entity.modifyTime = DateTime.Now;
  8115. bill_entity.createTime = DateTime.Now;
  8116. bill_entity.state = 0;
  8117. bill_entity.Update();
  8118. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8119. returnSuccessMsg("发票修改成功!");
  8120. return;
  8121. }
  8122. returnErrorMsg("找不到对应记录");
  8123. }
  8124. }
  8125. public void set_erp_invoicing()
  8126. {
  8127. if (UrlPostParmsCheck("id"))
  8128. {
  8129. try
  8130. {
  8131. string eid = GetPostString("id");
  8132. CeErpBill bill_entity = null;
  8133. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8134. if (bill_entity != null)
  8135. {
  8136. int ComId = GetPostInt("ComId");
  8137. //string memo = GetPostString("Memo");
  8138. int allInfo = GetPostInt("allinfo");
  8139. string clert = CurrentUser.User.Name;
  8140. //string detailValue = GetPostString("detailvalue");
  8141. string billId = bill_entity.billOrderId;
  8142. string[] billIdList = billId.Split(',');
  8143. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8144. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8145. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8146. {
  8147. billCount += 1;
  8148. }
  8149. if (billId.Length <= 0 || billIdList.Length != billCount)
  8150. {
  8151. bill_entity.billOrderId = "";
  8152. string prebill = "ltb";
  8153. for (int idx = 1; idx <= billCount; idx++)
  8154. {
  8155. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8156. string billoid = prebill + idx + dtstr;
  8157. bill_entity.billOrderId += billoid;
  8158. if (idx < billCount)
  8159. {
  8160. bill_entity.billOrderId += ",";
  8161. }
  8162. }
  8163. }
  8164. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8165. if (bill_entity.state == 5)
  8166. {
  8167. string errMsg = bill_entity.failerror;
  8168. string[] errlist = errMsg.Split('|');
  8169. string[] errTags = new string[errlist.Length];
  8170. for (int itag = 0; itag < errlist.Length; itag++)
  8171. {
  8172. if (errlist[itag].Length <= 0) continue;
  8173. errTags[itag] = errlist[itag].Split('&')[0];
  8174. }
  8175. for (int iii = 0; iii < errTags.Length; iii++)
  8176. {
  8177. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8178. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8179. if (billOrderList.Length >= erroBillOrderTag)
  8180. {
  8181. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8182. if (needModifyBillId.Length <= 19)
  8183. {
  8184. needModifyBillId = needModifyBillId + "1";
  8185. }
  8186. else
  8187. {
  8188. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8189. last = last + 1;
  8190. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8191. }
  8192. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8193. }
  8194. }
  8195. }
  8196. bool isHaveBillSucces = false;
  8197. string totalRes = "";
  8198. bill_entity.failerror = "";
  8199. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8200. {
  8201. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8202. totalRes += res;
  8203. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8204. {
  8205. isHaveBillSucces = true;
  8206. bill_entity.comId = ComId;
  8207. bill_entity.state = 1;
  8208. bill_entity.executeTime = DateTime.Now;
  8209. bill_entity.executeUser = clert;
  8210. }
  8211. else
  8212. {
  8213. bill_entity.state = 5;
  8214. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8215. }
  8216. }
  8217. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8218. bill_entity.Update();
  8219. if (isHaveBillSucces)
  8220. {
  8221. StringBuilder sql = new StringBuilder();
  8222. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8223. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8224. }
  8225. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8226. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8227. {
  8228. returnErrorMsg("开票失败");
  8229. }
  8230. else
  8231. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8232. return;
  8233. }
  8234. returnErrorMsg("找不到对应记录");
  8235. }
  8236. catch (Exception ex)
  8237. {
  8238. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8239. returnErrorMsg("操作失败");
  8240. }
  8241. }
  8242. }
  8243. public void get_erp_invoicing_back()
  8244. {
  8245. if (UrlPostParmsCheck("id"))
  8246. {
  8247. try
  8248. {
  8249. string id = GetPostString("id");
  8250. CeErpBill entiy = CeErpBill.Get(id);
  8251. if (entiy != null)
  8252. {
  8253. if (entiy.state == 0)
  8254. {
  8255. returnErrorMsg("发票还未开具");
  8256. return;
  8257. }
  8258. string[] billOrderList = entiy.billOrderId.Split(',');
  8259. int iTag = 0;
  8260. entiy.fplsh = "";
  8261. entiy.fpdm = "";
  8262. entiy.fphm = "";
  8263. foreach (string billOrderId in billOrderList)
  8264. {
  8265. iTag++;
  8266. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8267. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8268. {
  8269. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8270. try
  8271. {
  8272. Invoicing_get_response_Obj iObj = null;
  8273. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8274. if (iObj != null)
  8275. {
  8276. entiy.state = 2;
  8277. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8278. entiy.fpdm += iObj.list[0].c_fpdm;
  8279. entiy.fphm += iObj.list[0].c_fphm;
  8280. if (iTag < billOrderList.Length)
  8281. {
  8282. entiy.fplsh += ",";
  8283. entiy.fpdm += ",";
  8284. entiy.fphm += ",";
  8285. }
  8286. entiy.Update();
  8287. }
  8288. StringBuilder sql = new StringBuilder();
  8289. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8290. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8291. returnSuccessMsg("开票成功");
  8292. }
  8293. catch (Exception ex)
  8294. {
  8295. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8296. }
  8297. return;
  8298. }
  8299. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8300. {
  8301. var res_obj = new
  8302. {
  8303. data = "开票中"
  8304. };
  8305. string ro_json = JsonConvert.SerializeObject(res_obj);
  8306. returnSuccess(ro_json);
  8307. return;
  8308. }
  8309. else
  8310. {
  8311. int eidx = res.IndexOf("c_resultmsg");
  8312. int lidx = res.IndexOf("c_status");
  8313. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8314. entiy.state = 5;
  8315. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8316. entiy.Update();
  8317. returnErrorMsg("开票失败");
  8318. return;
  8319. }
  8320. }
  8321. }
  8322. }
  8323. catch (Exception ex)
  8324. {
  8325. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8326. }
  8327. return;
  8328. }
  8329. }
  8330. public void get_erp_invoicing()
  8331. {
  8332. if (UrlPostParmsCheck("id"))
  8333. {
  8334. try
  8335. {
  8336. string id = GetPostString("id");
  8337. CeErpBill entiy = CeErpBill.Get(id);
  8338. if (entiy != null)
  8339. {
  8340. if (entiy.state == 0)
  8341. {
  8342. returnErrorMsg("发票还未开具");
  8343. return;
  8344. }
  8345. if (entiy.sendType == "纸质发票")
  8346. {
  8347. if (entiy.img.Length <= 0)
  8348. {
  8349. returnErrorMsg("查无纸质发票");
  8350. return;
  8351. }
  8352. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8353. returnSuccess(returnres);
  8354. return;
  8355. }
  8356. string[] billOrderList = entiy.billOrderId.Split(',');
  8357. int iTag = 0;
  8358. string fpUrl = "";
  8359. entiy.fplsh = "";
  8360. entiy.fpdm = "";
  8361. entiy.fphm = "";
  8362. foreach (string billOrderId in billOrderList)
  8363. {
  8364. iTag++;
  8365. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8366. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8367. {
  8368. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8369. Invoicing_get_response_Obj iObj = null;
  8370. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8371. if (iObj != null)
  8372. {
  8373. //entiy.state = 2;
  8374. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8375. entiy.fpdm += iObj.list[0].c_fpdm;
  8376. entiy.fphm += iObj.list[0].c_fphm;
  8377. if (iTag < billOrderList.Length)
  8378. {
  8379. entiy.fplsh += ",";
  8380. entiy.fpdm += ",";
  8381. entiy.fphm += ",";
  8382. }
  8383. entiy.Update();
  8384. fpUrl += iObj.list[0].c_url + ",";
  8385. }
  8386. //returnSuccess(res);
  8387. StringBuilder sql = new StringBuilder();
  8388. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8389. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8390. }
  8391. else
  8392. {
  8393. int eidx = res.IndexOf("c_resultmsg");
  8394. //int lidx = res.IndexOf("c_status");
  8395. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8396. //开票失败
  8397. entiy.state = 5;
  8398. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8399. entiy.Update();
  8400. returnErrorMsg("开票失败");
  8401. return;
  8402. }
  8403. }
  8404. var returnObj = new
  8405. {
  8406. data = fpUrl
  8407. };
  8408. string ro_json = JsonConvert.SerializeObject(returnObj);
  8409. returnSuccess(ro_json);
  8410. }
  8411. }
  8412. catch (Exception ex)
  8413. {
  8414. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8415. }
  8416. return;
  8417. }
  8418. }
  8419. public void save_erp_billimg()
  8420. {
  8421. if (UrlPostParmsCheck("id"))
  8422. {
  8423. string eid = GetPostString("id");
  8424. CeErpBill bill_entity = null;
  8425. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8426. if (bill_entity != null)
  8427. {
  8428. bill_entity.img = GetPostString("img");
  8429. bill_entity.executeTime = DateTime.Now;
  8430. bill_entity.state = 2;
  8431. bill_entity.Update();
  8432. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8433. returnSuccessMsg("保存成功");
  8434. }
  8435. return;
  8436. }
  8437. }
  8438. public void upd_erp_billreturnback()
  8439. {
  8440. if (UrlPostParmsCheck("id"))
  8441. {
  8442. int eid = GetPostInt("id");
  8443. CeErpBill bill_entity = null;
  8444. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8445. if (bill_entity != null)
  8446. {
  8447. bill_entity.state = 3;
  8448. bill_entity.returnReason = GetPostString("reason");
  8449. bill_entity.Update();
  8450. returnSuccessMsg("驳回成功!");
  8451. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8452. }
  8453. return;
  8454. }
  8455. }
  8456. public void cancel_erp_bill()
  8457. {
  8458. if (UrlPostParmsCheck("id"))
  8459. {
  8460. int eid = GetPostInt("id");
  8461. int detailValue = GetPostInt("detailvalue");
  8462. CeErpBill bill_entity = null;
  8463. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8464. string cres = "";
  8465. string gres = "";
  8466. if (bill_entity != null)
  8467. {
  8468. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8469. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8470. {
  8471. int iTag = 0;
  8472. bill_entity.fplsh = "";
  8473. bill_entity.fpdm = "";
  8474. bill_entity.fphm = "";
  8475. foreach (string billOrderId in billOrderList)
  8476. {
  8477. iTag++;
  8478. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8479. if (gres.IndexOf("success") != -1)
  8480. {
  8481. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8482. Invoicing_get_response_Obj iObj = null;
  8483. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8484. if (iObj != null)
  8485. {
  8486. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8487. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8488. bill_entity.fphm += iObj.list[0].c_fphm;
  8489. if (iTag < billOrderList.Length)
  8490. {
  8491. bill_entity.fplsh += ",";
  8492. bill_entity.fpdm += ",";
  8493. bill_entity.fphm += ",";
  8494. }
  8495. bill_entity.Update();
  8496. }
  8497. }
  8498. else
  8499. {
  8500. returnErrorMsg(gres);
  8501. return;
  8502. }
  8503. }
  8504. }
  8505. if (bill_entity.sendType == "纸质发票")
  8506. {
  8507. //作废
  8508. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8509. //if (DateTime.Now.Month == extime.Month)
  8510. //{
  8511. //cres = taobaoHelper.cancel_invoicing(eid);
  8512. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8513. //{
  8514. bill_entity.state = 4;//已作废
  8515. bill_entity.Update();
  8516. returnSuccessMsg("发票已作废");
  8517. return;
  8518. //}
  8519. //else
  8520. //{
  8521. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8522. // bill_entity.Update();
  8523. // returnErrorMsg(cres);
  8524. // return;
  8525. //}
  8526. //}
  8527. //else
  8528. //{
  8529. // returnErrorMsg("纸质发票只能作废本月的发票");
  8530. // return;
  8531. //}
  8532. }
  8533. //红冲
  8534. int redTag = 0;
  8535. string[] fpdmList = bill_entity.fpdm.Split(',');
  8536. string[] fphmList = bill_entity.fphm.Split(',');
  8537. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8538. {
  8539. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8540. return;
  8541. }
  8542. foreach (string billOrderId in billOrderList)
  8543. {
  8544. redTag++;
  8545. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8546. cres += onecres;
  8547. cres += ",";
  8548. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8549. {
  8550. bill_entity.state = 4;//已作废
  8551. //bill_entity.Update();
  8552. //returnSuccessMsg("发票已红冲");
  8553. }
  8554. else if (onecres.IndexOf("重复冲红") != -1)
  8555. {
  8556. bill_entity.state = 4;//已作废
  8557. //bill_entity.Update();
  8558. //returnSuccessMsg("发票已红冲");
  8559. }
  8560. else
  8561. {
  8562. string errmsg = commonHelper.KeepChinese(onecres);
  8563. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8564. }
  8565. }
  8566. bill_entity.Update();
  8567. if (cres.IndexOf("失败") != -1)
  8568. returnErrorMsg("红冲失败");
  8569. else
  8570. returnSuccessMsg("发票已红冲");
  8571. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8572. return;
  8573. }
  8574. return;
  8575. }
  8576. }
  8577. public void del_erp_billorder()
  8578. {
  8579. if (UrlPostParmsCheck("id"))
  8580. {
  8581. string eid = GetPostString("id");
  8582. CeErpBill.Del(eid);
  8583. CeErpBill bill = CeErpBill.Get(eid);
  8584. if (bill != null)
  8585. {
  8586. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8587. }
  8588. returnSuccessMsg("删除成功");
  8589. }
  8590. }
  8591. public void finish_erp_bill()
  8592. {
  8593. if (UrlPostParmsCheck("ids"))
  8594. {
  8595. string eids = GetPostString("ids");
  8596. string[] list = eids.Split(',');
  8597. foreach (string eid in list)
  8598. {
  8599. CeErpBill bill = CeErpBill.Get(eid);
  8600. if (bill != null)
  8601. {
  8602. bill.state = 2;
  8603. bill.Update();
  8604. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8605. }
  8606. }
  8607. returnSuccessMsg("操作成功");
  8608. }
  8609. }
  8610. public void get_erp_returncash()
  8611. {
  8612. DataStruct dStruct = GetPostStruct();
  8613. List<string> lw = new List<string>();
  8614. string tid = GetPostString("tid");
  8615. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8616. string shopname = GetPostString("shopname");
  8617. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8618. string buyernick = GetPostString("buyer_nick");
  8619. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8620. string customer = GetPostString("customer");
  8621. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8622. string returndate1 = GetPostString("returndate1");
  8623. string returndate2 = GetPostString("returndate2");
  8624. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8625. if (dw.Length > 0) lw.Add(dw);
  8626. string finishDate1 = GetPostString("finishdate1");
  8627. string finishDate2 = GetPostString("finishdate2");
  8628. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8629. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8630. string returntype = GetPostString("returntype");
  8631. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8632. string returnvstate = GetPostString("returnvstate");
  8633. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8634. dStruct.Order = "created desc";
  8635. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8636. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8637. writeGridDataTableJson(dStruct.TotalCount, dt);
  8638. }
  8639. public void get_erp_staygoods()
  8640. {
  8641. DataStruct dStruct = GetPostStruct();
  8642. List<string> lw = new List<string>();
  8643. string tid = GetPostString("tid");
  8644. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8645. string shopname = GetPostString("shopname");
  8646. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8647. string wangwang = GetPostString("wangwang");
  8648. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8649. string customer = GetPostString("customer");
  8650. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8651. string returndate1 = GetPostString("returndate1");
  8652. string returndate2 = GetPostString("returndate2");
  8653. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8654. if (dw.Length > 0) lw.Add(dw);
  8655. string finishDate1 = GetPostString("finishdate1");
  8656. string finishDate2 = GetPostString("finishdate2");
  8657. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8658. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8659. string returnvstate = GetPostString("returnvstate");
  8660. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8661. string persuadetype = GetPostString("persuadetype");
  8662. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8663. string customerOrg = GetPostString("customerOrg");
  8664. if (customerOrg.Length > 0)
  8665. {
  8666. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8667. }
  8668. dStruct.Order = "creata_time desc";
  8669. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8670. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8671. writeGridDataTableJson(dStruct.TotalCount, dt);
  8672. }
  8673. public void upd_erp_staygoods()
  8674. {
  8675. if (UrlPostParmsCheck("id"))
  8676. {
  8677. int eid = GetPostInt("id");
  8678. CeErpStayGoods entity = null;
  8679. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8680. if (entity != null)
  8681. {
  8682. entity.audit_type = 1;
  8683. entity.audit_time = DateTime.Now;
  8684. entity.audit_u_id = CurrentUser.UserID;
  8685. entity.audit_u_name = CurrentUser.UserName;
  8686. entity.Update();
  8687. returnSuccessMsg("审核成功!");
  8688. return;
  8689. }
  8690. returnErrorMsg("找不到订单记录");
  8691. }
  8692. }
  8693. public void upd_erp_stayGoodsback()
  8694. {
  8695. if (UrlPostParmsCheck("id"))
  8696. {
  8697. int eid = GetPostInt("id");
  8698. CeErpStayGoods entity = null;
  8699. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8700. if (entity != null)
  8701. {
  8702. entity.audit_text = GetPostString("reason");
  8703. entity.audit_type = 2;
  8704. entity.audit_time = DateTime.Now;
  8705. entity.audit_u_id = CurrentUser.UserID;
  8706. entity.audit_u_name = CurrentUser.UserName;
  8707. entity.Update();
  8708. returnSuccessMsg("退回成功!");
  8709. return;
  8710. }
  8711. returnErrorMsg("找不到订单记录");
  8712. }
  8713. }
  8714. public void upd_erp_returncashverify()
  8715. {
  8716. if (UrlPostParmsCheck("ID"))
  8717. {
  8718. int eid = GetPostInt("ID");
  8719. CeErpReturnCash entity = null;
  8720. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8721. if (entity != null)
  8722. {
  8723. entity.cashstate = 1;
  8724. entity.verifytime = DateTime.Now;
  8725. entity.verifyuserid = CurrentUser.UserID;
  8726. entity.Update();
  8727. returnSuccessMsg("审核成功!");
  8728. return;
  8729. }
  8730. returnErrorMsg("找不到订单记录");
  8731. }
  8732. }
  8733. public void upd_all_erp_returncashverify()
  8734. {
  8735. if (UrlPostParmsCheck("ID"))
  8736. {
  8737. String[] list = GetPostString("ID").Split(',');
  8738. CeErpReturnCash entity = null;
  8739. for (int i = 0; i < list.Length; i++)
  8740. {
  8741. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8742. if (entity != null)
  8743. {
  8744. if (entity.cashstate == 1)
  8745. {
  8746. returnErrorMsg("已审核过的订单不需要在审核!");
  8747. return;
  8748. }
  8749. entity.cashstate = 1;
  8750. entity.verifytime = DateTime.Now;
  8751. entity.verifyuserid = CurrentUser.UserID;
  8752. entity.Update();
  8753. }
  8754. }
  8755. returnSuccessMsg("审核成功!");
  8756. return;
  8757. }
  8758. }
  8759. public void upd_erp_returncashback()
  8760. {
  8761. if (UrlPostParmsCheck("ID"))
  8762. {
  8763. int eid = GetPostInt("ID");
  8764. CeErpReturnCash entity = null;
  8765. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8766. if (entity != null)
  8767. {
  8768. entity.backreason = GetPostString("reason");
  8769. entity.cashstate = 2;
  8770. entity.verifytime = DateTime.Now;
  8771. entity.verifyuserid = CurrentUser.UserID;
  8772. entity.Update();
  8773. returnSuccessMsg("退回成功!");
  8774. return;
  8775. }
  8776. returnErrorMsg("找不到订单记录");
  8777. }
  8778. }
  8779. public void upd_erp_returnprice()
  8780. {
  8781. if (UrlPostParmsCheck("ID"))
  8782. {
  8783. int eid = GetPostInt("ID");
  8784. CeErpReturnCash entity = null;
  8785. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8786. if (entity != null)
  8787. {
  8788. if (entity.cashstate == 1)
  8789. {
  8790. returnErrorMsg("审核通过了不能改");
  8791. return;
  8792. }
  8793. entity.returnprice = GetPostDouble("returnprice");
  8794. entity.Update();
  8795. returnSuccessMsg("修改成功!");
  8796. return;
  8797. }
  8798. returnErrorMsg("找不到订单记录");
  8799. }
  8800. }
  8801. public void del_erp_returncash()
  8802. {
  8803. if (UrlPostParmsCheck("ID"))
  8804. {
  8805. int eid = GetPostInt("ID");
  8806. CeErpReturnCash.Del(eid);
  8807. returnSuccessMsg("操作成功");
  8808. return;
  8809. }
  8810. }
  8811. public void test_for_do_sql()
  8812. {
  8813. string sql = GetPostString("sqlstr");
  8814. if (sql.Length > 0)
  8815. {
  8816. try
  8817. {
  8818. DbHelper.DbConn.ExecuteNonQuery(sql);
  8819. var res_obj = new
  8820. {
  8821. data = "成功",
  8822. };
  8823. string ro_json = JsonConvert.SerializeObject(res_obj);
  8824. returnSuccess(ro_json);
  8825. }
  8826. catch (Exception ex)
  8827. {
  8828. var res_obj = new
  8829. {
  8830. data = ex.Message,
  8831. };
  8832. string ro_json = JsonConvert.SerializeObject(res_obj);
  8833. returnSuccess(ro_json);
  8834. }
  8835. }
  8836. }
  8837. public void get_user_info()
  8838. {
  8839. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8840. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8841. }
  8842. public void get_total_data()
  8843. {
  8844. int userId = CurrentUser.UserID;
  8845. string sql = "";
  8846. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8847. {
  8848. 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);
  8849. }
  8850. else
  8851. {
  8852. 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 " +
  8853. "(select ID from CE_ErpUser where ID = {0}) d " +
  8854. "left join " +
  8855. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8856. ") a on d.ID = a.id left join " +
  8857. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8858. ") b on a.id = b.id1 left join" +
  8859. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8860. ") c on a.id = c.id2;", userId);
  8861. }
  8862. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8863. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8864. }
  8865. public void get_date_area_total_data2()
  8866. {
  8867. int userId = CurrentUser.UserID;
  8868. string date_type = GetPostString("timetype");
  8869. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8870. string sql = "";
  8871. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8872. {
  8873. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8874. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8875. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8876. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8877. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8878. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8879. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8880. ") a on e.ID = a.id left join " +
  8881. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8882. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8883. ") b on a.id = b.id1 " +
  8884. "left join " +
  8885. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8886. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8887. ") c on a.id = c.id2 " +
  8888. "left join " +
  8889. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8890. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8891. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8892. }
  8893. else
  8894. {
  8895. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8896. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8897. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8898. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8899. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8900. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8901. ") a on e.ID = a.id left join " +
  8902. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8903. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8904. ") c on a.id = c.id2 " +
  8905. "left join " +
  8906. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8907. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8908. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8909. }
  8910. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8911. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8912. }
  8913. public void get_date_area_total_data()
  8914. {
  8915. int userId = CurrentUser.UserID;
  8916. string date_type = GetPostString("timetype");
  8917. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8918. string date1 = searchDT[0].ToString();
  8919. string date2 = searchDT[1].ToString();
  8920. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8921. {
  8922. SqlParameter[] sqlParameter ={
  8923. new SqlParameter("@userId", SqlDbType.Int,4),
  8924. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8925. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8926. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8927. };
  8928. sqlParameter[0].Value = userId;
  8929. sqlParameter[1].Value = date1;
  8930. sqlParameter[2].Value = date2;
  8931. sqlParameter[3].Direction = ParameterDirection.Output;
  8932. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8933. string res = sqlParameter[3].Value.ToString();
  8934. var res_obj = new
  8935. {
  8936. data = res
  8937. };
  8938. string ro_json = JsonConvert.SerializeObject(res_obj);
  8939. returnSuccess(ro_json);
  8940. }
  8941. else
  8942. {
  8943. SqlParameter[] sqlParameter ={
  8944. new SqlParameter("@userId", SqlDbType.Int,4),
  8945. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8946. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8947. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8948. };
  8949. sqlParameter[0].Value = userId;
  8950. sqlParameter[1].Value = date1;
  8951. sqlParameter[2].Value = date2;
  8952. sqlParameter[3].Direction = ParameterDirection.Output;
  8953. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8954. string res = sqlParameter[3].Value.ToString();
  8955. var res_obj = new
  8956. {
  8957. data = res
  8958. };
  8959. string ro_json = JsonConvert.SerializeObject(res_obj);
  8960. returnSuccess(ro_json);
  8961. }
  8962. //writeGridDataViewJson(dt.Rows.Count, dv);
  8963. }
  8964. public void get_order_list()
  8965. {
  8966. string strFields = GetPostString("paraFields");
  8967. string strOrder = GetPostString("paraOrder");
  8968. string strWhere = GetPostString("paraWhere");
  8969. string strPageSize = GetPostString("paraPageSize");
  8970. DataStruct dStruct = GetPostStruct();
  8971. dStruct.PageSize = int.Parse(strPageSize);
  8972. dStruct.Fileds = strFields;
  8973. dStruct.Order = strOrder;
  8974. dStruct.MainWhere = strWhere;
  8975. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8976. writeGridDataTableJson(dStruct.TotalCount, dt);
  8977. }
  8978. ////获取待开始订单列表
  8979. //public void get_wait_design_order_list()
  8980. //{
  8981. // string date_type = GetPostString("date_type");
  8982. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8983. // DataStruct dStruct = GetPostStruct();
  8984. // dStruct.PageSize = 1000;
  8985. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8986. // List<string> lw = new List<string>();
  8987. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8988. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8989. // dStruct.Order = "WaitDesignTime asc";
  8990. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8991. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8992. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8993. //}
  8994. //获取完成单量排名
  8995. public void get_finish_order_count_ranking()
  8996. {
  8997. /* string date_type = GetPostString("date_type");
  8998. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8999. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9000. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9001. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9002. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9003. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9004. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9005. writeGridDataTableJson(0, new DataTable());
  9006. }
  9007. public void get_finish_order_amount_ranking()
  9008. {
  9009. /*string date_type = GetPostString("date_type");
  9010. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9011. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9012. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9013. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9014. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9015. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9016. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9017. writeGridDataTableJson(0, new DataTable());
  9018. }
  9019. public void get_finish_refund_count_ranking()
  9020. {
  9021. string date_type = GetPostString("date_type");
  9022. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9023. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9024. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9025. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9026. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9027. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9028. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9029. writeGridDataTableJson(dt.Rows.Count, dt);
  9030. }
  9031. public void get_finish_refund_amount_ranking()
  9032. {
  9033. string date_type = GetPostString("date_type");
  9034. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9035. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9036. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9037. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9038. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9039. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9040. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9041. writeGridDataTableJson(dt.Rows.Count, dt);
  9042. }
  9043. public void set_erp_finishorder_director()
  9044. {
  9045. if (UrlPostParmsCheck("ctid"))
  9046. {
  9047. string eid = GetPostString("ctid");
  9048. CeErpTradeCell entity = null;
  9049. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9050. if (entity != null)
  9051. {
  9052. entity.OrderState = 8;
  9053. entity.Update();
  9054. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9055. returnSuccessMsg("操作成功!");
  9056. return;
  9057. }
  9058. returnErrorMsg("找不到记录");
  9059. }
  9060. }
  9061. public void get_erp_placeregistlist()
  9062. {
  9063. DataStruct dStruct = GetPostStruct();
  9064. List<string> lw = new List<string>();
  9065. string outsid = GetPostString("outsid");
  9066. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9067. string memo = GetPostString("memo");
  9068. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9069. string filename = GetPostString("filename");
  9070. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9071. string islate = GetPostString("islate");
  9072. if (islate.Length > 0)
  9073. {
  9074. if (islate == "1")
  9075. lw.Add(string.Format("OutLate>0"));
  9076. else
  9077. lw.Add(string.Format("OutLate=0"));
  9078. }
  9079. string placedate1 = GetPostString("placedate1");
  9080. string placedate2 = GetPostString("placedate2");
  9081. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9082. if (dw.Length > 0) lw.Add(dw);
  9083. string deliveryDate1 = GetPostString("deliverydate1");
  9084. string deliveryDate2 = GetPostString("deliverydate2");
  9085. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9086. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9087. dStruct.Order = "ID desc";
  9088. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9089. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9090. writeGridDataTableJson(dStruct.TotalCount, dt);
  9091. }
  9092. public void ins_erp_placeregist()
  9093. {
  9094. if (UrlPostParmsCheck("id"))
  9095. {
  9096. string eid = GetPostString("id");
  9097. CeErpPlaceRegister entity = null;
  9098. if (eid == "0")//新增
  9099. {
  9100. entity = new CeErpPlaceRegister();
  9101. string xdTime = GetPostString("placeTime");
  9102. if (xdTime.Length > 0)
  9103. {
  9104. entity.PlactTime = Convert.ToDateTime(xdTime);
  9105. }
  9106. string fhTime = GetPostString("deliveryTime");
  9107. if (fhTime.Length > 0)
  9108. {
  9109. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9110. }
  9111. string preTime = GetPostString("preOutTime");
  9112. if (preTime.Length > 0)
  9113. {
  9114. entity.PreOutTime = Convert.ToDateTime(preTime);
  9115. }
  9116. entity.DeliveryCount = GetPostInt("deliveryCount");
  9117. entity.ReceiveCount = GetPostInt("receiveCount");
  9118. entity.OutSid = GetPostString("outSid");
  9119. entity.FileName = GetPostString("fileName");
  9120. entity.Memo = GetPostString("memo");
  9121. entity.AddUserId = CurrentUser.UserID;
  9122. entity.CreateTime = DateTime.Now;
  9123. entity.Img = GetPostString("img");
  9124. entity.Supplier = GetPostInt("supplier");
  9125. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9126. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9127. {
  9128. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9129. DateTime dt2 = (DateTime)entity.PreOutTime;
  9130. TimeSpan span = dt1.Subtract(dt2);
  9131. if (span.Days > 0)
  9132. {
  9133. entity.OutLate = span.Days;
  9134. }
  9135. }
  9136. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9137. entity.Create();
  9138. returnSuccessMsg("添加成功!");
  9139. return;
  9140. }
  9141. else //修改
  9142. {
  9143. entity = CeErpPlaceRegister.Get(eid);
  9144. if (entity != null)
  9145. {
  9146. string xdTime = GetPostString("placeTime");
  9147. if (xdTime.Length > 0)
  9148. {
  9149. entity.PlactTime = Convert.ToDateTime(xdTime);
  9150. }
  9151. string fhTime = GetPostString("deliveryTime");
  9152. if (fhTime.Length > 0)
  9153. {
  9154. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9155. }
  9156. string preTime = GetPostString("preOutTime");
  9157. if (preTime.Length > 0)
  9158. {
  9159. entity.PreOutTime = Convert.ToDateTime(preTime);
  9160. }
  9161. entity.DeliveryCount = GetPostInt("deliveryCount");
  9162. entity.ReceiveCount = GetPostInt("receiveCount");
  9163. if (entity.DeliveryCount == entity.ReceiveCount)
  9164. {
  9165. entity.CurState = "已完成";
  9166. }
  9167. else
  9168. {
  9169. entity.CurState = "未完成";
  9170. }
  9171. entity.OutSid = GetPostString("outSid");
  9172. entity.FileName = GetPostString("fileName");
  9173. entity.Memo = GetPostString("memo");
  9174. entity.Img = GetPostString("img");
  9175. entity.Supplier = GetPostInt("supplier");
  9176. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9177. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9178. {
  9179. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9180. DateTime dt2 = (DateTime)entity.PreOutTime;
  9181. TimeSpan span = dt1.Subtract(dt2);
  9182. if (span.Days > 0)
  9183. {
  9184. entity.OutLate = span.Days;
  9185. }
  9186. }
  9187. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9188. entity.Update();
  9189. returnSuccessMsg("修改成功");
  9190. return;
  9191. }
  9192. returnErrorMsg("找不到对应的记录");
  9193. return;
  9194. }
  9195. }
  9196. returnErrorMsg("缺少必要参数");
  9197. }
  9198. public void del_erp_placeregist()
  9199. {
  9200. string eid = GetPostString("id");
  9201. CeErpPlaceRegister.Del(eid);
  9202. returnSuccessMsg("删除成功!");
  9203. return;
  9204. }
  9205. public void ins_erp_placeregistbyorder()
  9206. {
  9207. string ctid = GetPostString("ctid");
  9208. if (ctid.Length > 0)
  9209. {
  9210. StringBuilder sql = new StringBuilder();
  9211. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9212. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9213. if (dt.Rows.Count > 0)
  9214. {
  9215. foreach (DataRow dr in dt.Rows)
  9216. {
  9217. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9218. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9219. entity.AddUserId = CurrentUser.UserID;
  9220. entity.tid = dr["tid"].ToString();
  9221. entity.Did = Convert.ToString(dr["ctid"]);
  9222. entity.splitTag = dr["SplitTag"].ToString();
  9223. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9224. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9225. if (pre_ctid.Length > 0)
  9226. {
  9227. sellmemo = sellmemo.Replace(pre_ctid, "");
  9228. }
  9229. sellmemo = sellmemo.Replace("[", "");
  9230. sellmemo = sellmemo.Replace("]", "");
  9231. entity.FileName = sellmemo;
  9232. string count = dr["ProductCount"].ToString();
  9233. int usecount = commonHelper.getIntCountFromString(count);
  9234. entity.DeliveryCount = usecount;
  9235. entity.CurState = "未完成";
  9236. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9237. {
  9238. entity.Supplier = 24;//dl手提袋定制
  9239. }
  9240. else
  9241. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9242. entity.CreateTime = DateTime.Now;
  9243. entity.Create();
  9244. }
  9245. returnSuccessMsg("操作成功");
  9246. return;
  9247. }
  9248. returnErrorMsg("没有找到对应订单");
  9249. return;
  9250. }
  9251. returnErrorMsg("缺少订单编号");
  9252. return;
  9253. }
  9254. public void get_erp_persuadelist()
  9255. {
  9256. DataStruct dStruct = GetPostStruct();
  9257. List<string> lw = new List<string>();
  9258. string ctid = GetPostString("ctid");
  9259. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9260. string shopname = GetPostString("shopname");
  9261. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9262. string buyernick = GetPostString("buyer_nick");
  9263. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9264. string customer = GetPostString("customer");
  9265. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9266. string returndate1 = GetPostString("returndate1");
  9267. string returndate2 = GetPostString("returndate2");
  9268. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9269. if (dw.Length > 0) lw.Add(dw);
  9270. string finishDate1 = GetPostString("finishdate1");
  9271. string finishDate2 = GetPostString("finishdate2");
  9272. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9273. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9274. string persuadetype = GetPostString("persuadetype");
  9275. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9276. string returnvstate = GetPostString("returnvstate");
  9277. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9278. dStruct.Order = "created desc";
  9279. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9280. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9281. writeGridDataTableJson(dStruct.TotalCount, dt);
  9282. }
  9283. public void upd_erp_returnpersuadeback()
  9284. {
  9285. if (UrlPostParmsCheck("ID"))
  9286. {
  9287. int eid = GetPostInt("ID");
  9288. CeErpPersuade entity = null;
  9289. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9290. if (entity != null)
  9291. {
  9292. entity.backreason = GetPostString("reason");
  9293. entity.pstate = 2;
  9294. entity.verifytime = DateTime.Now;
  9295. entity.verifyuserid = CurrentUser.UserID;
  9296. entity.Update();
  9297. returnSuccessMsg("退回成功!");
  9298. return;
  9299. }
  9300. returnErrorMsg("找不到订单记录");
  9301. }
  9302. }
  9303. public void upd_erp_returnpersuadeverify()
  9304. {
  9305. if (UrlPostParmsCheck("ID"))
  9306. {
  9307. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9308. {
  9309. returnErrorMsg("暂无权限审核");
  9310. return;
  9311. }
  9312. int eid = GetPostInt("ID");
  9313. CeErpPersuade entity = null;
  9314. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9315. if (entity != null)
  9316. {
  9317. entity.pstate = 1;
  9318. entity.verifytime = DateTime.Now;
  9319. entity.verifyuserid = CurrentUser.UserID;
  9320. entity.Update();
  9321. returnSuccessMsg("审核成功!");
  9322. return;
  9323. }
  9324. returnErrorMsg("找不到订单记录");
  9325. }
  9326. }
  9327. public void del_erp_persuade()
  9328. {
  9329. if (UrlPostParmsCheck("ID"))
  9330. {
  9331. int eid = GetPostInt("ID");
  9332. CeErpPersuade.Del(eid);
  9333. returnSuccessMsg("操作成功");
  9334. return;
  9335. }
  9336. }
  9337. public void get_erp_oldcustoupload()
  9338. {
  9339. DataStruct dStruct = GetPostStruct();
  9340. List<string> lw = new List<string>();
  9341. string buyernick = GetPostString("buyer_nick");
  9342. if (buyernick.Length > 0)
  9343. {
  9344. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9345. }
  9346. else
  9347. return;
  9348. dStruct.Order = "pay_time desc";
  9349. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9350. DataTable dt = null;
  9351. dt = WebCache.GetData("view_erptradecell", dStruct);
  9352. writeGridDataTableJson(dStruct.TotalCount, dt);
  9353. }
  9354. public void get_erp_checkorderlist()
  9355. {
  9356. DataStruct dStruct = GetPostStruct();
  9357. List<string> lw = new List<string>();
  9358. string tid = GetPostString("ctid");
  9359. if (tid.Length > 0)
  9360. {
  9361. string select_tid = getTidByCtid(tid);
  9362. lw.Add(string.Format("tid='{0}'", select_tid));
  9363. }
  9364. string shopname = GetPostString("shopname");
  9365. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9366. string buyernick = GetPostString("buyer_nick");
  9367. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9368. string customer = GetPostString("customer");
  9369. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9370. string design = GetPostString("design");
  9371. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9372. string orderState = GetPostString("orderState");
  9373. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9374. string address = GetPostString("address");
  9375. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9376. string sellermemo = GetPostString("seller_memo");
  9377. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9378. string supplier = GetPostString("supplier");
  9379. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9380. {
  9381. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9382. }
  9383. else
  9384. {
  9385. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9386. }
  9387. string date1 = GetPostString("date1");
  9388. string date2 = GetPostString("date2");
  9389. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9390. if (dw.Length > 0) lw.Add(dw);
  9391. string placedate1 = GetPostString("placedate1");
  9392. string placedate2 = GetPostString("placedate2");
  9393. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9394. if (fdw.Length > 0) lw.Add(fdw);
  9395. string price1 = GetPostString("price1");
  9396. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9397. string price2 = GetPostString("price2");
  9398. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9399. string checkst = GetPostString("checkstate");
  9400. if (checkst.Length > 0 && "10".Equals(checkst))
  9401. {
  9402. lw.Add(string.Format("CheckOut>0"));
  9403. }
  9404. else
  9405. {
  9406. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9407. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9408. }
  9409. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9410. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9411. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9412. writeGridDataTableJson(dStruct.TotalCount, dt);
  9413. }
  9414. public void ins_erp_startCheck()
  9415. {
  9416. if (UrlPostParmsCheck("ctid"))
  9417. {
  9418. string eid = GetPostString("ctid");
  9419. CeErpTradeCell entity = null;
  9420. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9421. if (entity != null)
  9422. {
  9423. entity.MemoOpt = 4;
  9424. entity.UpdateTime = DateTime.Now;
  9425. entity.Update();
  9426. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9427. CeErpSukuraData.createInfo(entity.ctid, 6);
  9428. returnSuccessMsg("操作成功!");
  9429. return;
  9430. }
  9431. returnErrorMsg("找不到记录");
  9432. }
  9433. }
  9434. public void upd_erp_sendXlw()
  9435. {
  9436. if (UrlPostParmsCheck("ctid"))
  9437. {
  9438. string eid = GetPostString("ctid");
  9439. CeErpTradeCell entity = null;
  9440. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9441. if (entity != null)
  9442. {
  9443. if (entity.IsSendGift == 1)
  9444. {
  9445. returnErrorMsg("请勿重复标记");
  9446. return;
  9447. }
  9448. entity.IsSendGift = 1;
  9449. entity.Update();
  9450. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9451. returnSuccessMsg("操作成功!");
  9452. return;
  9453. }
  9454. returnErrorMsg("找不到记录");
  9455. }
  9456. }
  9457. public void cancel_sendXlw()
  9458. {
  9459. if (UrlPostParmsCheck("ctid"))
  9460. {
  9461. string eid = GetPostString("ctid");
  9462. CeErpTradeCell entity = null;
  9463. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9464. if (entity != null)
  9465. {
  9466. if (entity.IsSendGift == 0)
  9467. {
  9468. returnErrorMsg("未标记小礼物");
  9469. return;
  9470. }
  9471. entity.IsSendGift = 0;
  9472. entity.Update();
  9473. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9474. returnSuccessMsg("操作成功!");
  9475. return;
  9476. }
  9477. returnErrorMsg("找不到记录");
  9478. }
  9479. }
  9480. public void get_erp_designbill()
  9481. {
  9482. DataStruct dStruct = GetPostStruct();
  9483. List<string> lw = new List<string>();
  9484. int isMy = GetInt("my");
  9485. if (isMy == 1)
  9486. {
  9487. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9488. }
  9489. string tid = GetPostString("tid");
  9490. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9491. string userName = GetPostString("design");
  9492. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9493. string price1 = GetPostString("price1");
  9494. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9495. string price2 = GetPostString("price2");
  9496. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9497. string rePrice1 = GetPostString("rePrice1");
  9498. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9499. string rePrice2 = GetPostString("rePrice2");
  9500. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9501. string designerType = GetPostString("designerType");
  9502. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9503. string orderState = GetPostString("orderState");
  9504. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9505. string endTime1 = GetPostString("endTime1");
  9506. string endTime2 = GetPostString("endTime2");
  9507. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9508. if (dw.Length > 0) lw.Add(dw);
  9509. string isDk = GetPostString("isDk");
  9510. if (isDk == "1")
  9511. {
  9512. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9513. }
  9514. else if (isDk == "0")
  9515. {
  9516. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9517. }
  9518. dStruct.Order = "oid, create_time desc";
  9519. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9520. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9521. writeGridDataTableJson(dStruct.TotalCount, dt);
  9522. }
  9523. public void upd_erp_designerbill()
  9524. {
  9525. if (UrlPostParmsCheck("ID"))
  9526. {
  9527. string eid = GetPostString("ID");
  9528. CeErpDesignerBill entity = null;
  9529. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9530. if (entity != null)
  9531. {
  9532. if (GetPostDouble("designerpirce") > 0)
  9533. {
  9534. entity.realPrice = GetPostDouble("designerpirce");
  9535. entity.update_time = DateTime.Now;
  9536. entity.update_u_id = CurrentUser.UserID;
  9537. entity.update_u_name = CurrentUser.UserName;
  9538. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9539. entity.Update();
  9540. returnSuccessMsg("操作成功!");
  9541. return;
  9542. }
  9543. else
  9544. {
  9545. entity.price = GetPostDouble("price");
  9546. entity.update_time = DateTime.Now;
  9547. entity.update_u_id = CurrentUser.UserID;
  9548. entity.update_u_name = CurrentUser.UserName;
  9549. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9550. entity.Update();
  9551. returnSuccessMsg("操作成功!");
  9552. return;
  9553. }
  9554. }
  9555. returnErrorMsg("找不到记录");
  9556. }
  9557. }
  9558. public void audit_erp_designerbill()
  9559. {
  9560. if (UrlPostParmsCheck("ID"))
  9561. {
  9562. string eid = GetPostString("ID");
  9563. CeErpDesignerBill entity = null;
  9564. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9565. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9566. if (entity != null)
  9567. {
  9568. entity.realPrice = GetPostDouble("designerpirce");
  9569. entity.update_time = DateTime.Now;
  9570. entity.update_u_id = CurrentUser.UserID;
  9571. entity.update_u_name = CurrentUser.UserName;
  9572. entity.isAudit = 1;
  9573. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9574. entity.Update();
  9575. if (orderEntity != null)
  9576. {
  9577. orderEntity.IsReadTag = 3;
  9578. orderEntity.Update();
  9579. }
  9580. returnSuccessMsg("操作成功!");
  9581. return;
  9582. }
  9583. returnErrorMsg("找不到记录");
  9584. }
  9585. }
  9586. public void all_audit_erp_designerbill()
  9587. {
  9588. if (UrlPostParmsCheck("idList"))
  9589. {
  9590. string[] list = GetPostString("idList").Split(',');
  9591. CeErpDesignerBill entity = null;
  9592. for (int i = 0; i < list.Length; i++)
  9593. {
  9594. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9595. if (entity == null) return;
  9596. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9597. if (orderEntity == null) return;
  9598. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9599. entity.update_time = DateTime.Now;
  9600. entity.update_u_id = CurrentUser.UserID;
  9601. entity.update_u_name = CurrentUser.UserName;
  9602. entity.isAudit = 1;
  9603. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9604. entity.Update();
  9605. orderEntity.IsReadTag = 3;
  9606. orderEntity.Update();
  9607. }
  9608. returnSuccessMsg("操作成功!");
  9609. return;
  9610. }
  9611. }
  9612. public void get_erp_sameorders()
  9613. {
  9614. if (UrlPostParmsCheck("ctid"))
  9615. {
  9616. string eid = GetPostString("ctid");
  9617. CeErpTradeCell entity = null;
  9618. entity = CeErpTradeCell.GetByCtid(eid);
  9619. if (entity != null)
  9620. {
  9621. StringBuilder sql = new StringBuilder();
  9622. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9623. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9624. var res = new
  9625. {
  9626. data = dt.Rows.Count
  9627. };
  9628. string ro_jsond = JsonConvert.SerializeObject(res);
  9629. returnSuccess(ro_jsond);
  9630. return;
  9631. }
  9632. returnErrorMsg("未找到订单");
  9633. return;
  9634. }
  9635. returnErrorMsg("缺少必要的参数");
  9636. }
  9637. public void get_erp_islasthavesameorder()
  9638. {
  9639. if (UrlPostParmsCheck("ctid"))
  9640. {
  9641. string eid = GetPostString("ctid");
  9642. string[] ctidList = eid.Split(',');
  9643. StringBuilder sql = new StringBuilder();
  9644. string tisCtid = "";
  9645. foreach (string ctid in ctidList)
  9646. {
  9647. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9648. if (entity != null)
  9649. {
  9650. sql = new StringBuilder();
  9651. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9652. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9653. if (dth.Rows.Count > 0)
  9654. {
  9655. tisCtid += entity.ctid;
  9656. tisCtid += ",";
  9657. }
  9658. }
  9659. }
  9660. if (tisCtid.Length > 0)
  9661. {
  9662. var res = new
  9663. {
  9664. data = tisCtid
  9665. };
  9666. string ro_jsond = JsonConvert.SerializeObject(res);
  9667. returnSuccess(ro_jsond);
  9668. }
  9669. else
  9670. {
  9671. var res = new
  9672. {
  9673. data = ""
  9674. };
  9675. string ro_jsond = JsonConvert.SerializeObject(res);
  9676. returnSuccess(ro_jsond);
  9677. }
  9678. return;
  9679. }
  9680. returnErrorMsg("缺少必要的参数");
  9681. }
  9682. public void file_client_down_url()
  9683. {
  9684. if (!UrlPostParmsCheck("userId"))
  9685. {
  9686. returnErrorMsg("缺少必要的参数");
  9687. }
  9688. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9689. }
  9690. public void checkout_form_data()
  9691. {
  9692. if (!UrlPostParmsCheck("tid"))
  9693. {
  9694. returnErrorMsg("缺少必要的参数");
  9695. }
  9696. string tid = GetPostString("tid");
  9697. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9698. if (ceErpOrderFormData != null)
  9699. {
  9700. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9701. returnSuccess(ro_jsond);
  9702. return;
  9703. }
  9704. returnErrorMsg("尚未有文件!");
  9705. }
  9706. public void back_supplier_audit()
  9707. {
  9708. int userId = CurrentUser.UserID;
  9709. StringBuilder sql = new StringBuilder();
  9710. 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);
  9711. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9712. if (dt.Rows.Count > 0)
  9713. {
  9714. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9715. }
  9716. else
  9717. {
  9718. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9719. }
  9720. }
  9721. public void back_supplier_query()
  9722. {
  9723. string eid = GetPostString("ctid");
  9724. if (eid != "")
  9725. {
  9726. StringBuilder sql = new StringBuilder();
  9727. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9728. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9729. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9730. }
  9731. else
  9732. {
  9733. returnErrorMsg("找不到订单记录");
  9734. return;
  9735. }
  9736. }
  9737. public void verified_to_order()
  9738. {
  9739. int userId = CurrentUser.UserID;
  9740. StringBuilder sql = new StringBuilder();
  9741. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9742. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9743. if (dt.Rows.Count > 0)
  9744. {
  9745. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9746. }
  9747. else
  9748. {
  9749. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9750. }
  9751. }
  9752. public void upd_supplier_audit()
  9753. {
  9754. if (UrlPostParmsCheck("ctid"))
  9755. {
  9756. string eid = GetPostString("ctid");
  9757. string reason = GetPostString("returnreason");
  9758. CeErpTradeCell entity = null;
  9759. CeWithdraw withdraw = null;
  9760. withdraw = CeWithdraw.GetByTid(eid);
  9761. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9762. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9763. {
  9764. if (withdraw != null)
  9765. {
  9766. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9767. {
  9768. returnSuccessMsg("您没有权限操作!");
  9769. return;
  9770. }
  9771. else
  9772. {
  9773. if (reason.Equals("1"))
  9774. {
  9775. if (entity.OrderState == -1)
  9776. {
  9777. if (entity.FinishPlaceTime == null)
  9778. {
  9779. entity.OrderState = 2;
  9780. }
  9781. else
  9782. {
  9783. entity.OrderState = 6;
  9784. }
  9785. }
  9786. entity.Update();
  9787. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9788. if (withdraw != null)
  9789. {
  9790. withdraw.status = int.Parse(reason);
  9791. withdraw.Update();
  9792. }
  9793. returnSuccessMsg("操作成功!");
  9794. return;
  9795. }
  9796. else
  9797. {
  9798. withdraw.status = int.Parse(reason);
  9799. withdraw.acknowledgingtime = DateTime.Now;
  9800. withdraw.Update();
  9801. returnSuccessMsg("查看详细请点击线下订单查询");
  9802. return;
  9803. }
  9804. }
  9805. }
  9806. // 第一个字符是 'N'
  9807. }
  9808. if (eid[0] != 'N')
  9809. {
  9810. }
  9811. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9812. {
  9813. entity.IsVerifyToSupplier = false;
  9814. entity.IsReturn = 1;
  9815. entity.ReturnTime = DateTime.Now;
  9816. entity.ReturnReason = reason;
  9817. if (entity.OrderState == 6)
  9818. {
  9819. entity.OrderState = 5;
  9820. }
  9821. entity.Update();
  9822. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9823. if (withdraw != null)
  9824. {
  9825. withdraw.status = int.Parse(reason);
  9826. withdraw.Update();
  9827. }
  9828. returnSuccessMsg("操作成功!");
  9829. return;
  9830. }
  9831. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9832. {
  9833. ;
  9834. if (withdraw != null)
  9835. {
  9836. withdraw.status = int.Parse(reason);
  9837. withdraw.acknowledgingtime = DateTime.Now;
  9838. withdraw.Update();
  9839. returnSuccessMsg("供应商取消撤回!");
  9840. return;
  9841. }
  9842. }
  9843. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9844. {
  9845. if (entity.OrderState == -1)
  9846. {
  9847. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9848. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  9849. {
  9850. returnErrorMsg("订单spu没有确认无法通过审核!");
  9851. return;
  9852. }
  9853. if (entity.FinishPlaceTime == null)
  9854. {
  9855. entity.OrderState = 2;
  9856. }
  9857. else
  9858. {
  9859. entity.OrderState = 3;
  9860. }
  9861. commonHelper.getCytPrice(entity);
  9862. }
  9863. entity.Update();
  9864. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9865. if (withdraw != null)
  9866. {
  9867. withdraw.status = int.Parse(reason);
  9868. withdraw.Update();
  9869. }
  9870. returnSuccessMsg("操作成功!");
  9871. return;
  9872. }
  9873. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9874. {
  9875. if (withdraw == null)
  9876. {
  9877. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9878. return;
  9879. }
  9880. }
  9881. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9882. {
  9883. if (withdraw != null)
  9884. {
  9885. withdraw.status = int.Parse(reason);
  9886. withdraw.acknowledgingtime = DateTime.Now;
  9887. withdraw.Update();
  9888. returnSuccessMsg("查看详细请点击线下订单查询");
  9889. return;
  9890. }
  9891. }
  9892. return;
  9893. }
  9894. }
  9895. //校验报价
  9896. public void refund_order_tip()
  9897. {
  9898. int userid = CurrentUser.UserID;
  9899. int sectionId = CurrentUser.UserPost.OrgID;
  9900. StringBuilder sql = new StringBuilder();
  9901. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9902. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9903. List<string> ids = new List<string>();
  9904. if (dth.Rows.Count > 0)
  9905. {
  9906. foreach (DataRow dr in dth.Rows)
  9907. {
  9908. ids.Add(dr["ID"].ToString());
  9909. }
  9910. try
  9911. {
  9912. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9913. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9914. }
  9915. catch (Exception ex)
  9916. {
  9917. }
  9918. }
  9919. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9920. }
  9921. public void refund_order_Design()
  9922. {
  9923. int userid = CurrentUser.UserID;
  9924. int sectionId = CurrentUser.UserPost.OrgID;
  9925. StringBuilder sql = new StringBuilder();
  9926. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9927. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9928. List<string> ids = new List<string>();
  9929. if (dth.Rows.Count > 0)
  9930. {
  9931. foreach (DataRow dr in dth.Rows)
  9932. {
  9933. ids.Add(dr["ID"].ToString());
  9934. }
  9935. try
  9936. {
  9937. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9938. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9939. }
  9940. catch (Exception ex)
  9941. {
  9942. }
  9943. }
  9944. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9945. }
  9946. public void change_order_info()
  9947. {
  9948. int userid = CurrentUser.UserID;
  9949. StringBuilder sql = new StringBuilder();
  9950. 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);
  9951. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9952. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9953. }
  9954. public void change_win_mome()
  9955. {
  9956. if (UrlPostParmsCheck("id,ctid"))
  9957. {
  9958. string id = GetPostString("id");
  9959. string ctid = GetPostString("ctid");
  9960. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9961. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9962. if (ce == null || ceErpMessageTip == null)
  9963. {
  9964. returnSuccessMsg("未找到对应的订单!");
  9965. return;
  9966. }
  9967. if (ce.OrderState >= 5)
  9968. {
  9969. returnSuccessMsg("已上传文件无法修改!");
  9970. return;
  9971. }
  9972. int type = GetPostInt("type");
  9973. string content = GetPostString("content");
  9974. if (type == 0)
  9975. {
  9976. content = content.Replace("(", "(");
  9977. content = content.Replace(")", ")");
  9978. string check = MidStrEx(content, "(", ")").Trim();
  9979. if (string.IsNullOrEmpty(check))
  9980. {
  9981. returnSuccessMsg("文件名格式不正确");
  9982. return;
  9983. }
  9984. }
  9985. ce.seller_memo = content;
  9986. ce.Update();
  9987. ceErpMessageTip.isVisit = true;
  9988. ceErpMessageTip.Update();
  9989. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9990. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9991. ApiVo apiVo = new ApiVo();
  9992. apiVo.orderNumber = ce.ctid;
  9993. apiVo.actionName = "demandDesign";
  9994. apiVo.orderRemarks = content;
  9995. apiVo.demandExamine = type + 1;
  9996. designHelper.API_WorkCore(apiVo);//demandDesign
  9997. returnSuccessMsg("修改成功!");
  9998. }
  9999. }
  10000. public static string MidStrEx(string sourse, string startstr, string endstr)
  10001. {
  10002. string result = string.Empty;
  10003. int startindex, endindex;
  10004. try
  10005. {
  10006. startindex = sourse.IndexOf(startstr);
  10007. if (startindex == -1)
  10008. return result;
  10009. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10010. endindex = tmpstr.IndexOf(endstr);
  10011. if (endindex == -1)
  10012. return result;
  10013. result = tmpstr.Remove(endindex);
  10014. }
  10015. catch (Exception ex)
  10016. {
  10017. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10018. }
  10019. return result;
  10020. }
  10021. public void refund_order_list()
  10022. {
  10023. int userid = CurrentUser.UserID;
  10024. int sectionId = CurrentUser.UserPost.OrgID;
  10025. StringBuilder sql = new StringBuilder();
  10026. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10027. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10028. DataStruct dStruct = GetPostStruct();
  10029. DataTable dt = null;
  10030. List<string> ids = new List<string>();
  10031. List<string> tids = new List<string>();
  10032. if (dth.Rows.Count > 0)
  10033. {
  10034. foreach (DataRow dr in dth.Rows)
  10035. {
  10036. tids.Add("'" + dr["tid"].ToString() + "'");
  10037. ids.Add(dr["id"].ToString());
  10038. }
  10039. try
  10040. {
  10041. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10042. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10043. List<string> lw = new List<string>();
  10044. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10045. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10046. dt = WebCache.GetData("view_orderlist", dStruct);
  10047. }
  10048. catch (Exception ex)
  10049. {
  10050. }
  10051. }
  10052. writeGridDataTableJson(dStruct.TotalCount, dt);
  10053. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10054. }
  10055. //新增
  10056. public void order_batch_downloads()
  10057. {
  10058. string ceid = GetPostString("tid");
  10059. String[] tid = ceid.Split(',');
  10060. order_batch_caiyingtong(tid);
  10061. /* (string success, string errors) = UploadFiles(tid);
  10062. returnSuccessMsg(success + errors);*/
  10063. return;
  10064. }
  10065. //报价接口
  10066. public void Get_To_Quote()
  10067. {
  10068. string ceid = GetPostString("ctid");
  10069. if (ceid != null)
  10070. {
  10071. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10072. if (entity != null)
  10073. {
  10074. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10075. {
  10076. return;
  10077. }
  10078. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10079. double price = 0;
  10080. if (cp == null)
  10081. {
  10082. JObject jsonObject12 = new JObject
  10083. {
  10084. { "UserId", "77886" },
  10085. { "Pwd", "lt666888" },
  10086. { "Filename", entity.seller_memo }
  10087. };
  10088. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10089. JObject jsonObjects1 = JObject.Parse(response1);
  10090. string ms1g = (string)jsonObjects1["msg"];
  10091. if (ms1g == "报价成功")
  10092. {
  10093. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10094. string data = (string)jsonObject1["price"];
  10095. 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 + "');";
  10096. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10097. returnSuccessMsg("获取报价成功:" + data);
  10098. price = Convert.ToDouble(data);
  10099. }
  10100. else
  10101. {
  10102. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10103. return;
  10104. }
  10105. }
  10106. String[] beizhu = entity.seller_memo.Split('-');
  10107. String chanp = "";
  10108. if (beizhu.Length > 0)
  10109. {
  10110. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10111. }
  10112. else
  10113. {
  10114. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10115. }
  10116. JObject jsonObject = new JObject
  10117. {
  10118. { "UserId", "77886" },
  10119. { "Pwd", "lt666888" },
  10120. { "Filename", chanp }
  10121. };
  10122. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10123. JObject jsonObjects = JObject.Parse(response);
  10124. string msg = (string)jsonObjects["msg"];
  10125. if (msg == "报价成功")
  10126. {
  10127. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10128. string data = (string)jsonObject1["price"];
  10129. 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 + "');";
  10130. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10131. returnSuccessMsg("获取报价成功:" + data);
  10132. price = Convert.ToDouble(data);
  10133. }
  10134. else
  10135. {
  10136. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10137. return;
  10138. }
  10139. if (price > 0)
  10140. {
  10141. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10142. if (ceErpTradeCellExtend == null)
  10143. {
  10144. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10145. ceErpTradeCellExtend.ctid = entity.ctid;
  10146. ceErpTradeCellExtend.payment_cyt = price;
  10147. ceErpTradeCellExtend.Create();
  10148. }
  10149. else
  10150. {
  10151. ceErpTradeCellExtend.payment_cyt = price;
  10152. ceErpTradeCellExtend.Update();
  10153. }
  10154. }
  10155. return;
  10156. }
  10157. }
  10158. else
  10159. {
  10160. returnErrorMsg("请至少选择一条数据");
  10161. return;
  10162. }
  10163. }
  10164. //新增
  10165. public void order_To_Supplier()
  10166. {
  10167. string ceid = GetPostString("tid");
  10168. String[] tid = ceid.Split(',');
  10169. if (tid.Length > 0)
  10170. {
  10171. try
  10172. {
  10173. for (int i = 0; i < tid.Length; i++)
  10174. {
  10175. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10176. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10177. entity.SupplierId = suid;
  10178. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10179. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10180. entity.Update();
  10181. }
  10182. }
  10183. catch (Exception ex)
  10184. {
  10185. returnErrorMsg("自动匹配供应商失败");
  10186. return;
  10187. }
  10188. }
  10189. else
  10190. {
  10191. returnErrorMsg("请至少选择一条数据");
  10192. return;
  10193. }
  10194. returnSuccessMsg("自动匹配供应商成功");
  10195. return;
  10196. }
  10197. public (string, string) UploadFiles(string[] urls)
  10198. {
  10199. string success = "";
  10200. string errors = "";
  10201. int userid = CurrentUser.UserID;
  10202. foreach (string url in urls)
  10203. {
  10204. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10205. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10206. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10207. {
  10208. JObject jsonObject = new JObject
  10209. {
  10210. { "Userid", "77886" },
  10211. { "pwd", "cyt86435015" },
  10212. { "content", base64FileContent },
  10213. { "ext", Path.GetExtension(fileName) }
  10214. };
  10215. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10216. JObject jsonObjects = JObject.Parse(response);
  10217. string msg = (string)jsonObjects["msg"];
  10218. if (msg.Equals("上传成功"))
  10219. {
  10220. success += url + " 上传成功";
  10221. }
  10222. else
  10223. {
  10224. errors += url + " 上传失败";
  10225. }
  10226. }
  10227. else
  10228. {
  10229. errors += url + " 格式出现问题";
  10230. }
  10231. }
  10232. if (urls.Length == 0)
  10233. {
  10234. return (success, errors);
  10235. }
  10236. return (success, errors);
  10237. }
  10238. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10239. {
  10240. return true; //总是接受
  10241. }
  10242. public static string HttpPost(string url, string param = null)
  10243. {
  10244. HttpWebRequest request;
  10245. //如果是发送HTTPS请求
  10246. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10247. {
  10248. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10249. request = WebRequest.Create(url) as HttpWebRequest;
  10250. request.ProtocolVersion = HttpVersion.Version10;
  10251. }
  10252. else
  10253. {
  10254. request = WebRequest.Create(url) as HttpWebRequest;
  10255. }
  10256. request.Method = "POST";
  10257. request.ContentType = "application/json";
  10258. request.Accept = "*/*";
  10259. request.Timeout = 120000;
  10260. request.AllowAutoRedirect = false;
  10261. StreamWriter requestStream = null;
  10262. WebResponse response = null;
  10263. string responseStr = null;
  10264. try
  10265. {
  10266. requestStream = new StreamWriter(request.GetRequestStream());
  10267. requestStream.Write(param);
  10268. requestStream.Close();
  10269. response = request.GetResponse();
  10270. if (response != null)
  10271. {
  10272. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10273. responseStr = reader.ReadToEnd();
  10274. reader.Close();
  10275. }
  10276. }
  10277. catch (Exception ex)
  10278. {
  10279. return ex.Message;
  10280. }
  10281. finally
  10282. {
  10283. request = null;
  10284. requestStream = null;
  10285. response = null;
  10286. }
  10287. return responseStr;
  10288. }
  10289. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10290. {
  10291. string base64FileContent;
  10292. string fileName;
  10293. using (WebClient webClient = new WebClient())
  10294. {
  10295. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10296. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10297. {
  10298. using (Stream stream = response.GetResponseStream())
  10299. {
  10300. using (MemoryStream memoryStream = new MemoryStream())
  10301. {
  10302. stream.CopyTo(memoryStream);
  10303. byte[] fileBytes = memoryStream.ToArray();
  10304. base64FileContent = Convert.ToBase64String(fileBytes);
  10305. fileName = response.Headers["Content-Disposition"];
  10306. if (!string.IsNullOrEmpty(fileName))
  10307. {
  10308. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10309. if (index >= 0)
  10310. {
  10311. fileName = fileName.Substring(index + 9).Trim('\"');
  10312. }
  10313. }
  10314. else
  10315. {
  10316. fileName = Path.GetFileName(downloadUrl);
  10317. }
  10318. }
  10319. }
  10320. }
  10321. }
  10322. return (fileName, base64FileContent);
  10323. }
  10324. //新增
  10325. public void order_batch_caiyingtong(string[] downloadUrls)
  10326. {
  10327. try
  10328. {
  10329. //遍历文件
  10330. DataStruct dStruct = GetPostStruct();
  10331. DataTable dt = null;
  10332. int userid = CurrentUser.UserID;
  10333. List<string> ids = new List<string>();//失败组
  10334. List<string> tids = new List<string>();
  10335. using (WebClient webClient = new WebClient())
  10336. {
  10337. foreach (var url in downloadUrls)
  10338. {
  10339. try
  10340. {
  10341. tids.Add("'" + url + "'");
  10342. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10343. if (entity != null)
  10344. {
  10345. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10346. if (cp == null)
  10347. {
  10348. JObject jsonObject = new JObject
  10349. {
  10350. { "Userid", "77886" },
  10351. { "pwd", "lt666888" },
  10352. { "Filename",entity.seller_memo }
  10353. };
  10354. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10355. JObject jsonObjects = JObject.Parse(response);
  10356. string msg = (string)jsonObjects["msg"];
  10357. if (msg == "报价成功")
  10358. {
  10359. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10360. DownloadAndConvertToBase64(url1);
  10361. }
  10362. else
  10363. {
  10364. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10365. }
  10366. }
  10367. else
  10368. {
  10369. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10370. JObject jsonObject = new JObject
  10371. {
  10372. { "Userid", "77886" },
  10373. { "pwd", "lt666888" },
  10374. { "Filename",chanp }
  10375. };
  10376. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10377. JObject jsonObjects = JObject.Parse(response);
  10378. string msg = (string)jsonObjects["msg"];
  10379. if (msg == "报价成功")
  10380. {
  10381. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10382. DownloadAndConvertToBase64(url1);
  10383. }
  10384. else
  10385. {
  10386. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10387. }
  10388. }
  10389. }
  10390. // 上传文件到FTP
  10391. }
  10392. catch (Exception ex)
  10393. {
  10394. Console.WriteLine($"An error occurred: {ex.Message}");
  10395. }
  10396. }
  10397. List<string> lw = new List<string>();
  10398. lw.Add(string.Format("( OrderState < 6 )"));
  10399. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10400. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10401. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10402. if (dt.Rows.Count > 0)
  10403. {
  10404. foreach (DataRow dr in dt.Rows)
  10405. {
  10406. ids.Add(dr["ctid"].ToString());
  10407. }
  10408. }
  10409. String ErrorMsgs = "";
  10410. foreach (String id in ids)
  10411. {
  10412. ErrorMsgs += id + ",";
  10413. }
  10414. if (ErrorMsgs.Length > 1)
  10415. {
  10416. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10417. }
  10418. if (ErrorMsgs.Length < 1)
  10419. {
  10420. ErrorMsgs = "上传成功";
  10421. returnSuccessMsg(ErrorMsgs);
  10422. }
  10423. else
  10424. {
  10425. returnErrorMsg("以下订单" + ErrorMsgs);
  10426. }
  10427. }
  10428. // 删除文件夹及其内容
  10429. /* Directory.Delete(localDirectory, true);*/
  10430. }
  10431. catch { }
  10432. }
  10433. public void get_center_data()
  10434. {
  10435. int userId = CurrentUser.UserID;
  10436. string postCode = CurrentUser.UserPost.Post.Code;
  10437. List<string> lw = new List<string>();
  10438. List<string> ww = new List<string>();
  10439. DateTime currentTime = DateTime.Now;
  10440. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10441. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10442. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10443. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10444. string sql = " SELECT ";
  10445. string startTime = "2023-10-01 11:22:31";
  10446. //设计
  10447. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10448. {
  10449. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10450. 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));
  10451. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10452. 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));
  10453. }
  10454. //客服
  10455. else if (postCode == "CustomerService" || postCode == "Director")
  10456. {
  10457. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10458. 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));
  10459. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10460. 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));
  10461. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10462. 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));
  10463. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10464. 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));
  10465. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10466. 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));
  10467. }
  10468. //售后
  10469. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10470. {
  10471. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10472. 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));
  10473. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10474. 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));
  10475. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10476. 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));
  10477. }
  10478. //下单部
  10479. else if (postCode == "Place" || postCode == "PlaceMr")
  10480. {
  10481. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10482. 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));
  10483. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10484. 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));
  10485. }
  10486. //车间
  10487. else if (postCode == "Supplier")
  10488. {
  10489. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10490. 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));
  10491. }
  10492. DataTable dt = new DataTable();
  10493. if (lw.Count > 0)
  10494. {
  10495. sql += string.Join(" , ", lw);
  10496. sql += " FROM ";
  10497. sql += string.Join(" , ", ww);
  10498. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10499. }
  10500. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10501. }
  10502. public void get_center_data_list()
  10503. {
  10504. int userId = CurrentUser.UserID;
  10505. string postCode = CurrentUser.UserPost.Post.Code;
  10506. string shopIds = CurrentUser.User.pemShop;
  10507. DataStruct dStruct = GetPostStruct();
  10508. List<string> lw = new List<string>();
  10509. DateTime currentTime = DateTime.Now;
  10510. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10511. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10512. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10513. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10514. string startTime = "2023-10-01 11:22:31";
  10515. int order_type = GetPostInt("order_type");
  10516. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10517. {
  10518. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10519. if (order_type == 0)
  10520. {
  10521. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10522. }
  10523. else if (order_type == 3)
  10524. {
  10525. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10526. }
  10527. else
  10528. {
  10529. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10530. }
  10531. }
  10532. //客服
  10533. if (postCode == "CustomerService" || postCode == "Director")
  10534. {
  10535. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10536. if (order_type == 0)
  10537. {
  10538. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10539. }
  10540. else if (order_type == 1)
  10541. {
  10542. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10543. }
  10544. else if (order_type == 2)
  10545. {
  10546. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10547. }
  10548. else if (order_type == 3)
  10549. {
  10550. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10551. }
  10552. else if (order_type == 4)
  10553. {
  10554. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10555. }
  10556. else
  10557. {
  10558. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10559. }
  10560. }
  10561. //售后
  10562. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10563. {
  10564. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10565. if (shopIds != "")
  10566. {
  10567. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10568. }
  10569. if (order_type == 2)
  10570. {
  10571. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10572. }
  10573. else if (order_type == 4)
  10574. {
  10575. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10576. }
  10577. else if (order_type == 5)
  10578. {
  10579. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10580. }
  10581. else
  10582. {
  10583. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10584. }
  10585. }
  10586. //下单部
  10587. if (postCode == "Place" || postCode == "PlaceMr")
  10588. {
  10589. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10590. if (shopIds != "")
  10591. {
  10592. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10593. }
  10594. else if (order_type == 1)
  10595. {
  10596. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10597. }
  10598. else if (order_type == 2)
  10599. {
  10600. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10601. }
  10602. else
  10603. {
  10604. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10605. }
  10606. }
  10607. //车间
  10608. if (postCode == "Supplier")
  10609. {
  10610. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10611. if (order_type == 5)
  10612. {
  10613. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10614. }
  10615. else
  10616. {
  10617. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10618. }
  10619. }
  10620. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10621. dStruct.Fileds = "tid,ctid";
  10622. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10623. writeGridDataTableJson(dStruct.TotalCount, dt);
  10624. }
  10625. public void aftersale_audit_master()
  10626. {
  10627. if (UrlPostParmsCheck("ctid"))
  10628. {
  10629. string ctid = GetPostString("ctid");
  10630. if (ctid.Length > 0)
  10631. {
  10632. bool result = aftersale_data_change(ctid);
  10633. if (result)
  10634. {
  10635. returnSuccessMsg("修改成功!");
  10636. return;
  10637. }
  10638. }
  10639. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10640. }
  10641. }
  10642. public void aftersale_batch_audit_master()
  10643. {
  10644. if (UrlPostParmsCheck("ctids"))
  10645. {
  10646. string ctids = GetPostString("ctids");
  10647. if (ctids.Length > 0)
  10648. {
  10649. List<string> list = new List<string>();
  10650. string[] ctid_list = ctids.Split(',');
  10651. foreach (var item in ctid_list)
  10652. {
  10653. bool result = aftersale_data_change(item);
  10654. if (!result)
  10655. {
  10656. list.Add(item);
  10657. }
  10658. }
  10659. if (list.Count > 0)
  10660. {
  10661. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10662. return;
  10663. }
  10664. returnSuccessMsg("修改成功!");
  10665. return;
  10666. }
  10667. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10668. }
  10669. }
  10670. public bool aftersale_data_change(string ctid)
  10671. {
  10672. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10673. if (ceErpTradeCell != null)
  10674. {
  10675. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10676. ceErpTradeCell.AfterSaleSupplierState = 0;
  10677. StringBuilder sql = new StringBuilder();
  10678. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10679. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10680. CeErpTradeResponsible.DelByTid(ctid, 0);
  10681. 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 == "不理赔")
  10682. {
  10683. CeErpTradeResponsible.DelByTid(ctid, 1);
  10684. ceErpTradeCell.AfterSaleSupplierState = 1;
  10685. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10686. ceErpTradeCell.AfterSaleState = 4;
  10687. }
  10688. else
  10689. {
  10690. ceErpTradeCell.AfterSaleState = 3;
  10691. }
  10692. bool needCyt = false;
  10693. if (dt != null)
  10694. {
  10695. if (dt.Rows.Count == 1)
  10696. {
  10697. bool isEnd = false;
  10698. foreach (DataRow dr in dt.Rows)
  10699. {
  10700. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10701. {
  10702. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10703. isEnd = true;
  10704. }
  10705. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10706. {
  10707. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10708. isEnd = true;
  10709. }
  10710. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10711. {
  10712. needCyt = true;
  10713. }
  10714. }
  10715. if (isEnd)
  10716. {
  10717. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10718. ceErpTradeCell.AfterSaleState = 4;
  10719. ceErpTradeCell.AfterSaleSupplierState = 1;
  10720. }
  10721. }
  10722. else
  10723. {
  10724. bool isAll = true;
  10725. foreach (DataRow dr in dt.Rows)
  10726. {
  10727. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10728. {
  10729. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10730. continue;
  10731. }
  10732. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10733. {
  10734. string path = "";
  10735. int OrgID = 0;
  10736. if (!Convert.IsDBNull(dr["OrgPath"]))
  10737. {
  10738. path = dr["OrgPath"].ToString();
  10739. }
  10740. if (!Convert.IsDBNull(dr["OrgID"]))
  10741. {
  10742. OrgID = Convert.ToInt32(dr["OrgID"]);
  10743. }
  10744. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10745. {
  10746. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10747. continue;
  10748. }
  10749. }
  10750. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10751. {
  10752. needCyt = true;
  10753. }
  10754. isAll = false;
  10755. }
  10756. if (isAll)
  10757. {
  10758. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10759. ceErpTradeCell.AfterSaleState = 4;
  10760. ceErpTradeCell.AfterSaleSupplierState = 1;
  10761. }
  10762. }
  10763. }
  10764. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10765. {
  10766. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10767. }
  10768. if (ceErpTradeCell.AfterSaleState == 4)
  10769. {
  10770. ApiVo apiVo = new ApiVo();
  10771. apiVo.orderNumber = ceErpTradeCell.ctid;
  10772. apiVo.actionName = "afterOver";
  10773. designHelper.API_WorkCore(apiVo); //afterOver
  10774. }
  10775. ceErpTradeCell.Update();
  10776. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10777. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10778. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10779. return true;
  10780. }
  10781. return false;
  10782. }
  10783. public void get_erp_wechatorder()
  10784. {
  10785. DataStruct dStruct = GetPostStruct();
  10786. List<string> lw = new List<string>();
  10787. string tid = GetPostString("tid");
  10788. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10789. string shopname = GetPostString("shopname");
  10790. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10791. string buyernick = GetPostString("buyer_nick");
  10792. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10793. string customer = GetPostString("customer");
  10794. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10795. string returndate1 = GetPostString("returndate1");
  10796. string returndate2 = GetPostString("returndate2");
  10797. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10798. if (dw.Length > 0) lw.Add(dw);
  10799. string finishDate1 = GetPostString("finishdate1");
  10800. string finishDate2 = GetPostString("finishdate2");
  10801. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10802. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10803. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10804. dStruct.Order = "created desc";
  10805. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10806. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10807. writeGridDataTableJson(dStruct.TotalCount, dt);
  10808. }
  10809. public void get_erp_wechatlist_sumprice()
  10810. {
  10811. DataStruct dStruct = GetPostStruct();
  10812. List<string> lw = new List<string>();
  10813. string tid = GetPostString("tid");
  10814. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10815. string shopname = GetPostString("shopname");
  10816. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10817. string buyernick = GetPostString("buyer_nick");
  10818. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10819. string customer = GetPostString("customer");
  10820. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10821. string returndate1 = GetPostString("returndate1");
  10822. string returndate2 = GetPostString("returndate2");
  10823. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10824. if (dw.Length > 0) lw.Add(dw);
  10825. string finishDate1 = GetPostString("finishdate1");
  10826. string finishDate2 = GetPostString("finishdate2");
  10827. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10828. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10829. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10830. string mainWhere = string.Join(" and ", lw.ToArray());
  10831. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10832. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10833. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10834. decimal total = 0;
  10835. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10836. {
  10837. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10838. }
  10839. var res = new
  10840. {
  10841. data = total
  10842. };
  10843. string ro_jsond = JsonConvert.SerializeObject(res);
  10844. returnSuccess(ro_jsond);
  10845. return;
  10846. }
  10847. public void get_erp_qr_waitdeliverylist()
  10848. {
  10849. DataStruct dStruct = GetPostStruct();
  10850. List<string> lw = new List<string>();
  10851. string tid = GetPostString("ctid");
  10852. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10853. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10854. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10855. var res_objz = new
  10856. {
  10857. restype = 1,
  10858. data = dt
  10859. };
  10860. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10861. returnSuccess(ro_jsonz);
  10862. }
  10863. public void get_erp_yield_list()
  10864. {
  10865. DataStruct dStruct = GetPostStruct();
  10866. List<string> lw = new List<string>();
  10867. string tid = GetPostString("ctid");
  10868. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10869. string shopname = GetPostString("shopname");
  10870. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10871. string buyernick = GetPostString("buyer_nick");
  10872. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10873. //if (tid.Length == 0 && buyernick.Length == 0)
  10874. //{
  10875. // lw.Add(string.Format("IsRefund<={0}", 1));
  10876. //}
  10877. string customer = GetPostString("customer");
  10878. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10879. string design = GetPostString("design");
  10880. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10881. string orderState = GetPostString("orderState");
  10882. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10883. string address = GetPostString("address");
  10884. 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));
  10885. string sellermemo = GetPostString("seller_memo");
  10886. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10887. string supplier = GetPostString("supplier");
  10888. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10889. string OrderArea = GetPostString("order_area");
  10890. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10891. string placedate1 = GetPostString("placedate1");
  10892. string placedate2 = GetPostString("placedate2");
  10893. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10894. if (fdw.Length > 0) lw.Add(fdw);
  10895. string price1 = GetPostString("price1");
  10896. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10897. string price2 = GetPostString("price2");
  10898. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10899. string unusualCon = GetPostString("unusualcon");
  10900. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10901. string posTag = CurrentUser.UserPost.Post.Code;
  10902. if (posTag == "Supplier")
  10903. {
  10904. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10905. }
  10906. lw.Add(string.Format("OrderState = 6 "));
  10907. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10908. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10909. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10910. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10911. writeGridDataTableJson(dStruct.TotalCount, dt);
  10912. }
  10913. public void change_erp_sup_state()
  10914. {
  10915. if (UrlPostParmsCheck("ctid"))
  10916. {
  10917. string ctid = GetPostString("ctid");
  10918. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10919. if (ceErpTradeCell != null)
  10920. {
  10921. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10922. if (ceErpTradeCellExtend == null)
  10923. {
  10924. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10925. ceErpTradeCellExtend.ctid = ctid;
  10926. ceErpTradeCellExtend.SupState = 1;
  10927. ceErpTradeCellExtend.Create();
  10928. }
  10929. else
  10930. {
  10931. ceErpTradeCellExtend.SupState = 1;
  10932. ceErpTradeCellExtend.Update();
  10933. }
  10934. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10935. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10936. return;
  10937. }
  10938. returnErrorMsg("找不到订单");
  10939. }
  10940. }
  10941. public void supplier_all_downs()
  10942. {
  10943. if (UrlPostParmsCheck("tids"))
  10944. {
  10945. string tids = GetPostString("tids");
  10946. if (tids != null && tids.Length > 0)
  10947. {
  10948. StringBuilder sql = new StringBuilder();
  10949. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10950. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10951. sql = new StringBuilder();
  10952. 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, "下载设计文件");
  10953. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10954. string[] list = tids.Split(',');
  10955. foreach (string ctid in list)
  10956. {
  10957. CeErpSukuraData.createInfo(ctid, 3);
  10958. }
  10959. designHelper.api_approveDesign(tids); //approveDesign
  10960. returnSuccessMsg("下载成功!");
  10961. return;
  10962. }
  10963. returnErrorMsg("下载订单更新失败");
  10964. }
  10965. }
  10966. public void uploaderFileSuccess()
  10967. {
  10968. if (UrlPostParmsCheck("fileName"))
  10969. {
  10970. string fileName = GetPostString("fileName");
  10971. ApiVo apiVo = new ApiVo();
  10972. apiVo.orderNumber = fileName;
  10973. apiVo.actionName = "finishDesign";
  10974. designHelper.API_WorkCore(apiVo);//finishDesign
  10975. returnSuccessMsg("");
  10976. }
  10977. }
  10978. public void get_sample2_order()
  10979. {
  10980. if (UrlPostParmsCheck("ctid"))
  10981. {
  10982. string ctid = GetPostString("ctid");
  10983. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10984. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10985. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10986. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10987. double total = 0.0;
  10988. double order_price = 0.0;
  10989. if (dt_bu.Rows.Count > 0)
  10990. {
  10991. foreach (DataRow dr in dt_bu.Rows)
  10992. {
  10993. total += Convert.ToDouble(dr["payment"]);
  10994. }
  10995. }
  10996. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10997. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10998. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10999. string tid = ctid.Replace("S_", "");
  11000. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11001. double paymant = 0.0;
  11002. if (entity != null)
  11003. {
  11004. paymant = entity.payment;
  11005. }
  11006. string return_reason = "";
  11007. if (dt_after != null && dt_after.Rows.Count > 0)
  11008. {
  11009. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11010. }
  11011. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11012. }
  11013. }
  11014. public void get_erp_design_status()
  11015. {
  11016. string designName = GetPostString("designName");
  11017. DataStruct dStruct = GetPostStruct();
  11018. if (designName.Length > 0)
  11019. {
  11020. 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";
  11021. sql_user += " and Name like '%" + designName + "%'";
  11022. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11023. List<string> ids_list = new List<string>();
  11024. if (user_table.Rows.Count > 0)
  11025. {
  11026. foreach (DataRow item in user_table.Rows)
  11027. {
  11028. ids_list.Add(item["id"].ToString());
  11029. string ids_s = item["TeamIds"].ToString();
  11030. if (ids_s.Length > 0)
  11031. {
  11032. ids_list.AddRange(ids_s.Split(','));
  11033. }
  11034. }
  11035. }
  11036. HashSet<string> set = new HashSet<string>(ids_list);
  11037. ids_list = set.ToList();
  11038. if (ids_list.Count > 0)
  11039. {
  11040. 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));
  11041. dStruct.MainWhere = sql;
  11042. DataTable dt = null;
  11043. dt = WebCache.GetData("view_ErpUser", dStruct);
  11044. writeGridDataTableJson(dStruct.TotalCount, dt);
  11045. }
  11046. }
  11047. }
  11048. public void change_erp_order_price()
  11049. {
  11050. string ctid = GetPostString("ctid");
  11051. double price = GetPostDouble("price");
  11052. if (ctid.Length > 0)
  11053. {
  11054. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11055. if (ceErpTradeCellExtend == null)
  11056. {
  11057. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11058. ceErpTradeCellExtend.ctid = ctid;
  11059. ceErpTradeCellExtend.payment_cyt = price;
  11060. ceErpTradeCellExtend.Create();
  11061. }
  11062. else
  11063. {
  11064. ceErpTradeCellExtend.payment_cyt = price;
  11065. ceErpTradeCellExtend.Update();
  11066. }
  11067. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11068. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11069. {
  11070. ceErpDataSendOrderInfo.isSync = false;
  11071. ceErpDataSendOrderInfo.Update();
  11072. }
  11073. if (ceErpDataSendOrderInfo == null)
  11074. {
  11075. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11076. ceErpDataSendOrderInfo.isSync = false;
  11077. ceErpDataSendOrderInfo.ctid = ctid;
  11078. ceErpDataSendOrderInfo.Create();
  11079. }
  11080. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11081. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11082. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11083. if (dth != null && dth.Rows.Count > 0)
  11084. {
  11085. dataSendOrderBean dataSendOrderBean = null;
  11086. foreach (DataRow item in dth.Rows)
  11087. {
  11088. try
  11089. {
  11090. dataSendOrderBean = new dataSendOrderBean();
  11091. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11092. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11093. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11094. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11095. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11096. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11097. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11098. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11099. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11100. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11101. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11102. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11103. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11104. if (result != null)
  11105. {
  11106. if ("0".Equals(result.errcode))
  11107. {
  11108. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11109. }
  11110. else
  11111. {
  11112. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11113. }
  11114. }
  11115. }
  11116. catch (Exception ex)
  11117. {
  11118. }
  11119. }
  11120. }
  11121. returnSuccessMsg("修改成功!");
  11122. return;
  11123. }
  11124. returnErrorMsg("找不到订单");
  11125. }
  11126. public void find_he_together()
  11127. {
  11128. string ctid = GetPostString("ctid");
  11129. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11130. List<string> list = new List<string>();
  11131. if (ceErpTradeCell != null)
  11132. {
  11133. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11134. {
  11135. 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);
  11136. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11137. if (table != null && table.Rows.Count > 0)
  11138. {
  11139. foreach (TableRow row in table.Rows)
  11140. {
  11141. }
  11142. }
  11143. }
  11144. }
  11145. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11146. }
  11147. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11148. {
  11149. //chy----19
  11150. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11151. //GD-CYT-----64
  11152. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11153. //ZHX----3
  11154. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11155. //JK----97
  11156. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11157. //ZT----70
  11158. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11159. //LHCY-----98
  11160. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11161. //XD-----90
  11162. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11163. //CYCY-----14
  11164. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11165. };
  11166. //其他改名
  11167. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11168. {
  11169. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11170. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11171. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11172. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11173. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11174. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11175. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11176. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11177. };
  11178. //不统计
  11179. List<int> no_suppliers = new List<int>()
  11180. {
  11181. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11182. };
  11183. //配件单
  11184. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11185. {
  11186. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11187. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11188. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11189. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11190. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11191. {"旗杆",new List<string>(){ "班旗" } },
  11192. {"牙签",new List<string>(){ "不干胶" } }
  11193. };
  11194. public void get_place_order_data()
  11195. {
  11196. string date1 = GetPostString("date1");
  11197. string date2 = GetPostString("date2");
  11198. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11199. DateTime start = DateTime.Parse(starttime);
  11200. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11201. DateTime end = DateTime.Parse(endtime);
  11202. if (date1 != null && date1.Length > 0)
  11203. {
  11204. DateTime dateTime = DateTime.Parse(date1);
  11205. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11206. start = DateTime.Parse(starttime);
  11207. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11208. end = DateTime.Parse(endtime);
  11209. }
  11210. if (date2 != null && date2.Length > 0)
  11211. {
  11212. DateTime dateTime = DateTime.Parse(date2);
  11213. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11214. end = DateTime.Parse(endtime);
  11215. }
  11216. 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);
  11217. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11218. //不干胶-----1,卡片-----29
  11219. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11220. foreach (DataRow row in data.Rows)
  11221. {
  11222. int productId = Convert.ToInt32(row["ProductId"]);
  11223. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11224. if (no_suppliers.Contains(supplierId))
  11225. {
  11226. continue;
  11227. }
  11228. string seller_memo = row["seller_memo"].ToString();
  11229. bool ispj = false;//是否配件单
  11230. bool isfirst = true;//第一个配
  11231. maps.Keys.ForEach(key =>
  11232. {
  11233. //备注包含配件
  11234. if (seller_memo.Contains(key) && isfirst)
  11235. {
  11236. List<string> list = maps[key];
  11237. ispj = true;
  11238. isfirst = false;
  11239. for (int i = 0; i < list.Count; i++)
  11240. {
  11241. if (seller_memo.Contains(list[i]))
  11242. {
  11243. ispj = false;
  11244. break;
  11245. }
  11246. }
  11247. }
  11248. });
  11249. if (ispj)
  11250. {
  11251. continue;
  11252. }
  11253. seller_memo = seller_memo.Replace("UV", "uv");
  11254. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11255. //吊牌归到卡片
  11256. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11257. seller_memo = seller_memo.Replace("卡套", "卡片");
  11258. seller_memo = seller_memo.Replace("封套", "卡片");
  11259. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11260. seller_memo = seller_memo.Replace("腰封", "卡片");
  11261. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11262. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11263. seller_memo = seller_memo.Replace("横幅", "条幅");
  11264. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11265. string map_key = "";
  11266. string type = "";
  11267. if (supplierMap.ContainsKey(supplierId))
  11268. {
  11269. foreach (var kvp in supplierMap[supplierId])
  11270. {
  11271. if (seller_memo.Contains(kvp.Key))
  11272. {
  11273. map_key = kvp.Value;
  11274. type = kvp.Value;
  11275. break;
  11276. }
  11277. }
  11278. }
  11279. if (map_key == "")
  11280. {
  11281. type = "其他";
  11282. map_key = "其他";
  11283. }
  11284. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11285. {
  11286. map_key = suppliers[supplierId];
  11287. }
  11288. if (supplierId == 70)
  11289. {
  11290. supplierId = 70;
  11291. }
  11292. map_key += "_" + row["SupplierName"].ToString();
  11293. Dictionary<string, int> map = null;
  11294. if (other_map.ContainsKey(map_key))
  11295. {
  11296. other_map.TryGetValue(map_key, out map);
  11297. }
  11298. else
  11299. {
  11300. map = new Dictionary<string, int>();
  11301. map.Add("dayDev", 0);//当天出货
  11302. map.Add("dayTotal", 0);//下单总数
  11303. map.Add("payTotal", 0);//500以上
  11304. map.Add("today", 0);//当天出货数量
  11305. map.Add("unusua", 0);//异常数
  11306. other_map.Add(map_key, map);
  11307. other_map.TryGetValue(map_key, out map);
  11308. }
  11309. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11310. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11311. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11312. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11313. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11314. {
  11315. map["dayTotal"]++;
  11316. if (supplierId == 97)
  11317. {
  11318. supplierId = 97;
  11319. }
  11320. }
  11321. if (Convert.ToDecimal(row["payment"]) >= 500)
  11322. {
  11323. map["payTotal"]++;
  11324. }
  11325. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11326. {
  11327. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11328. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11329. {
  11330. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11331. {
  11332. map["today"]++;
  11333. }
  11334. }
  11335. else
  11336. {
  11337. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11338. {
  11339. map["today"]++;
  11340. }
  11341. else
  11342. {
  11343. if (supplierId == 119)
  11344. {
  11345. Debug.WriteLine(row["seller_memo"].ToString());
  11346. }
  11347. }
  11348. }
  11349. }
  11350. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11351. {
  11352. map["unusua"]++;
  11353. }
  11354. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11355. //GD-CYT-----64
  11356. DateTime two = palceTimeStart.AddHours(14);
  11357. DateTime three = palceTimeStart.AddHours(15);
  11358. DateTime four = palceTimeStart.AddHours(16);
  11359. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11360. {
  11361. //下午四点前 500-1000
  11362. string count = row["ProductCount"].ToString();
  11363. if (count != null && count.Length > 0)
  11364. {
  11365. int productCount = commonHelper.getPlaceProductCount(count);
  11366. if (productCount >= 500 && productCount <= 1000)
  11367. {
  11368. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11369. {
  11370. map["dayDev"]++;
  11371. }
  11372. }
  11373. }
  11374. }
  11375. //UV
  11376. else if ("uv".Equals(type))
  11377. {
  11378. //ZT----70
  11379. //ZHX----3
  11380. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11381. {
  11382. map["dayDev"]++;
  11383. }
  11384. //JK----97
  11385. //HZX----105
  11386. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11387. {
  11388. map["dayDev"]++;
  11389. if (supplierId == 97)
  11390. {
  11391. supplierId = 97;
  11392. }
  11393. }
  11394. }
  11395. //帆布---52|条幅---27
  11396. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11397. {
  11398. //LHCY-----98
  11399. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11400. {
  11401. map["dayDev"]++;
  11402. }
  11403. }
  11404. //条幅
  11405. else if ("条幅".Equals(type))
  11406. {
  11407. //XD-----90
  11408. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11409. {
  11410. map["dayDev"]++;
  11411. }
  11412. }
  11413. //桌布
  11414. else if ("桌布".Equals(type))
  11415. {
  11416. //XD-----90
  11417. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11418. {
  11419. map["dayDev"]++;
  11420. }
  11421. }
  11422. //DL---10
  11423. //AYTW---119
  11424. //FS-CYT-DY ----80
  11425. //JK----97
  11426. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11427. {
  11428. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11429. {
  11430. map["dayDev"]++;
  11431. }
  11432. }
  11433. }
  11434. DataTable dt = new DataTable();
  11435. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11436. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11437. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11438. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11439. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11440. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11441. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11442. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11443. other_map.Keys.ForEach(key =>
  11444. {
  11445. DataRow dr = dt.NewRow();
  11446. Dictionary<string, int> map = other_map[key];
  11447. string[] key_list = key.Split('_');
  11448. dr[0] = key_list[0];
  11449. dr[1] = key_list[1];
  11450. if (key_list.Length > 2)
  11451. {
  11452. dr[1] += "(" + key_list[2] + ")";
  11453. }
  11454. dr[2] = map["dayTotal"];
  11455. dr[3] = map["payTotal"];
  11456. dr[4] = map["today"];
  11457. dr[5] = map["unusua"];
  11458. dr[6] = map["dayDev"];
  11459. double rate = 0.00;
  11460. if (map["dayDev"] > 0)
  11461. {
  11462. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11463. }
  11464. dr[7] = rate.ToString();
  11465. dt.Rows.Add(dr);
  11466. });
  11467. DataView dv = new DataView(dt);
  11468. dv.Sort = "SupplierName";
  11469. //dv.Sort = "AllOrder desc";
  11470. DataTable dtNew = dv.ToTable();
  11471. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11472. }
  11473. public void check_order_desing_info()
  11474. {
  11475. string ctid = GetPostString("ctid");
  11476. if (!string.IsNullOrEmpty(ctid))
  11477. {
  11478. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11479. if (ceErpTradeCell != null)
  11480. {
  11481. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11482. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11483. return;
  11484. }
  11485. returnErrorMsg("找不到订单");
  11486. return;
  11487. }
  11488. returnErrorMsg("找不到订单");
  11489. }
  11490. public void get_timeout_detail()
  11491. {
  11492. string poscode = CurrentUser.UserPost.Post.Code;
  11493. DataStruct dStruct = GetPostStruct();
  11494. List<string> lw = new List<string>();
  11495. string id = GetPostString("id");
  11496. string pay_date1 = GetPostString("pay_date1");
  11497. string pay_date2 = GetPostString("pay_date2");
  11498. int type = GetPostInt("type");
  11499. if (type == 0)
  11500. {
  11501. if (pay_date1.Length > 0)
  11502. {
  11503. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11504. }
  11505. if (pay_date2.Length > 0)
  11506. {
  11507. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11508. }
  11509. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11510. }
  11511. if (type == 1)
  11512. {
  11513. if (pay_date1.Length > 0)
  11514. {
  11515. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11516. }
  11517. if (pay_date2.Length > 0)
  11518. {
  11519. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11520. }
  11521. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11522. }
  11523. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11524. DataTable dt = null;
  11525. dt = WebCache.GetData("view_orderlist", dStruct);
  11526. writeGridDataTableJson(dStruct.TotalCount, dt);
  11527. }
  11528. public void saveUrgentChargePrice()
  11529. {
  11530. string ctid = GetPostString("ctid");
  11531. if (!string.IsNullOrEmpty(ctid))
  11532. {
  11533. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11534. if (ceErpTradeCell != null)
  11535. {
  11536. double price = GetPostDouble("price");
  11537. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11538. if (ceErpTradeCellExtend == null)
  11539. {
  11540. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11541. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11542. }
  11543. ceErpTradeCellExtend.urgentCharge = price;
  11544. if (ceErpTradeCellExtend.ID > 0)
  11545. {
  11546. ceErpTradeCellExtend.Update();
  11547. }
  11548. else
  11549. {
  11550. ceErpTradeCellExtend.Save();
  11551. }
  11552. returnSuccessMsg("修改成功!");
  11553. return;
  11554. }
  11555. returnErrorMsg("找不到订单");
  11556. return;
  11557. }
  11558. returnErrorMsg("找不到订单");
  11559. }
  11560. public void finish_erp_order()
  11561. {
  11562. string ctid = GetPostString("ctid");
  11563. if (!string.IsNullOrEmpty(ctid))
  11564. {
  11565. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11566. {
  11567. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11568. if (ceErpTradeCell != null)
  11569. {
  11570. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11571. ceErpTradeCell.Update();
  11572. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11573. returnSuccessMsg("修改成功!");
  11574. return;
  11575. }
  11576. }
  11577. }
  11578. returnErrorMsg("找不到订单");
  11579. }
  11580. public void get_trade_order_list()
  11581. {
  11582. string tid = GetPostString("tid");
  11583. if (!string.IsNullOrEmpty(tid))
  11584. {
  11585. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11586. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11587. writeGridDataTableJson(data.Rows.Count, data);
  11588. return;
  11589. }
  11590. returnErrorMsg("找不到订单");
  11591. }
  11592. public void save_cell_spu()
  11593. {
  11594. string ctid = GetPostString("ctid");
  11595. string spu_id = GetPostString("spu_id");
  11596. if (!string.IsNullOrEmpty(ctid))
  11597. {
  11598. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11599. if (ceErpTradeCellExtend == null)
  11600. {
  11601. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11602. ceErpTradeCellExtend.ctid = ctid;
  11603. }
  11604. ceErpTradeCellExtend.spu_id = spu_id;
  11605. if (!string.IsNullOrEmpty(spu_id))
  11606. {
  11607. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11608. string result = designHelper.API_CheckOrderTo(ceErpTradeCellExtend.ctid, ceErpTradeCellExtend.spu_id, ceErpTradeCell.ShopId);
  11609. ceErpTradeCellExtend.ToType = result;
  11610. List<int> products = new List<int>() { 4, 13, 19, 24, 28, 32, 40, 51, 57, 1971, 2319, 2377, 2521, 2524, 2533, 2538, 2542, 2554, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, 2568, 2569, 2570, 2571, 2572, 2619, 2625, 2634, 2636, 2637, 2638, 2645, 2646 };
  11611. if (products.Contains(ceErpTradeCell.ProductId) || ceErpTradeCell.seller_memo.IndexOf("手绘") > -1 || ceErpTradeCell.seller_memo.IndexOf("电子稿") > -1 || ceErpTradeCell.isDianziOrder > 0)
  11612. {
  11613. ceErpTradeCellExtend.ToType = "外协";
  11614. }
  11615. if ("外协".Equals(ceErpTradeCellExtend.ToType))
  11616. {
  11617. string sql_pay = "update CE_ErpTradeCell with(rowlock) set DispatchSort=2 where ctid='" + ctid + "';";
  11618. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  11619. }
  11620. }
  11621. if (ceErpTradeCellExtend.ID == 0)
  11622. {
  11623. ceErpTradeCellExtend.Create();
  11624. }
  11625. else
  11626. {
  11627. ceErpTradeCellExtend.Update();
  11628. }
  11629. returnSuccessMsg("修改成功!");
  11630. return;
  11631. }
  11632. returnErrorMsg("找不到订单");
  11633. }
  11634. public void change_express_info()
  11635. {
  11636. string ctid = GetPostString("ctid");
  11637. string transNo = GetPostString("transNo");
  11638. string transCom = GetPostString("transCom");
  11639. if (!string.IsNullOrEmpty(ctid))
  11640. {
  11641. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11642. if (ceErpTradeCellExtend == null)
  11643. {
  11644. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11645. ceErpTradeCellExtend.ctid = ctid;
  11646. }
  11647. ceErpTradeCellExtend.modExpressNo = transNo;
  11648. ceErpTradeCellExtend.modExpressCom = transCom;
  11649. ceErpTradeCellExtend.readMod = 2;
  11650. if (ceErpTradeCellExtend.ID == 0)
  11651. {
  11652. ceErpTradeCellExtend.Create();
  11653. }
  11654. else
  11655. {
  11656. ceErpTradeCellExtend.Update();
  11657. }
  11658. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11659. returnSuccessMsg("修改成功!");
  11660. return;
  11661. }
  11662. returnErrorMsg("找不到订单");
  11663. }
  11664. public void get_change_express_list()
  11665. {
  11666. DataStruct dStruct = GetPostStruct();
  11667. List<string> lw = new List<string>();
  11668. int st = 2;
  11669. string tid = GetPostString("ctid");
  11670. if (tid.Length > 0)
  11671. {
  11672. string select_tid = getTidByCtid(tid);
  11673. lw.Add(string.Format("tid='{0}'", select_tid));
  11674. }
  11675. string shopname = GetPostString("shopname");
  11676. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11677. string buyernick = GetPostString("buyer_nick");
  11678. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11679. string sellermemo = GetPostString("seller_memo");
  11680. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11681. string supplier = GetPostString("supplier");
  11682. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11683. string customer = GetPostString("customer");
  11684. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11685. string design = GetPostString("design");
  11686. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11687. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11688. string poscode = CurrentUser.UserPost.Post.Code;
  11689. if (poscode != "SysAdmin")
  11690. {
  11691. string shopid = CurrentUser.User.pemShop;
  11692. lw.Add(string.Format("shopId in ({0})", shopid));
  11693. }
  11694. lw.Add("readMod = 2");
  11695. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11696. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11697. writeGridDataTableJson(dStruct.TotalCount, dt);
  11698. }
  11699. public void deal_express_complete()
  11700. {
  11701. string ctid = GetPostString("ctid");
  11702. if (!string.IsNullOrEmpty(ctid))
  11703. {
  11704. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11705. if (ceErpTradeCellExtend == null)
  11706. {
  11707. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11708. ceErpTradeCellExtend.ctid = ctid;
  11709. }
  11710. ceErpTradeCellExtend.readMod = 1;
  11711. if (ceErpTradeCellExtend.ID == 0)
  11712. {
  11713. ceErpTradeCellExtend.Create();
  11714. }
  11715. else
  11716. {
  11717. ceErpTradeCellExtend.Update();
  11718. }
  11719. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11720. returnSuccessMsg("修改成功!");
  11721. return;
  11722. }
  11723. returnErrorMsg("找不到订单");
  11724. }
  11725. public void aftersale_return_visit()
  11726. {
  11727. string ctid = GetPostString("ctid");
  11728. if (!string.IsNullOrEmpty(ctid))
  11729. {
  11730. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11731. if (ceErpTradeCellExtend == null)
  11732. {
  11733. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11734. ceErpTradeCellExtend.ctid = ctid;
  11735. }
  11736. ceErpTradeCellExtend.returnVisit = 1;
  11737. if (ceErpTradeCellExtend.ID == 0)
  11738. {
  11739. ceErpTradeCellExtend.Create();
  11740. }
  11741. else
  11742. {
  11743. ceErpTradeCellExtend.Update();
  11744. }
  11745. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11746. if (ceErpTradeAfterSaleExtend != null)
  11747. {
  11748. ceErpTradeAfterSaleExtend.TextResult = "";
  11749. ceErpTradeAfterSaleExtend.Update();
  11750. }
  11751. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11752. returnSuccessMsg("修改成功!");
  11753. return;
  11754. }
  11755. returnErrorMsg("找不到订单");
  11756. }
  11757. public void orderPlaceInfo()
  11758. {
  11759. string ctids = GetPostString("ctids");
  11760. string[] list = ctids.Split(',');
  11761. foreach (string ctid in list)
  11762. {
  11763. CeErpSukuraData.createInfo(ctid, 3);
  11764. }
  11765. StringBuilder sql = new StringBuilder();
  11766. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11767. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11768. designHelper.api_approveDesign(ctids); //approveDesign
  11769. returnSuccessMsg("");
  11770. }
  11771. public void get_issue_list()
  11772. {
  11773. DataStruct dStruct = GetPostStruct();
  11774. List<string> lw = new List<string>();
  11775. int st = 2;
  11776. string tid = GetPostString("ctid");
  11777. if (tid.Length > 0)
  11778. {
  11779. string select_tid = getTidByCtid(tid);
  11780. lw.Add(string.Format("tid='{0}'", select_tid));
  11781. }
  11782. string shopname = GetPostString("shopname");
  11783. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11784. string buyernick = GetPostString("buyer_nick");
  11785. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11786. string sellermemo = GetPostString("seller_memo");
  11787. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11788. string supplier = GetPostString("supplier");
  11789. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11790. string customer = GetPostString("customer");
  11791. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11792. string design = GetPostString("design");
  11793. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11794. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11795. string poscode = CurrentUser.UserPost.Post.Code;
  11796. if (poscode != "SysAdmin")
  11797. {
  11798. string shopid = CurrentUser.User.pemShop;
  11799. lw.Add(string.Format("shopId in ({0})", shopid));
  11800. }
  11801. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11802. {
  11803. lw.Add("IssueState = 1");
  11804. }
  11805. lw.Add("IssueState > 0");
  11806. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11807. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11808. writeGridDataTableJson(dStruct.TotalCount, dt);
  11809. }
  11810. public void saveIssueContent()
  11811. {
  11812. string ctid = GetPostString("ctid");
  11813. if (!string.IsNullOrEmpty(ctid))
  11814. {
  11815. string content = GetPostString("content");
  11816. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11817. if (ceErpTradeAfterSaleExtend == null)
  11818. {
  11819. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11820. ceErpTradeAfterSaleExtend.tid = ctid;
  11821. }
  11822. ceErpTradeAfterSaleExtend.IssueContent = content;
  11823. ceErpTradeAfterSaleExtend.IssueState = 1;
  11824. if (ceErpTradeAfterSaleExtend.ID > 0)
  11825. {
  11826. ceErpTradeAfterSaleExtend.Update();
  11827. }
  11828. else
  11829. {
  11830. ceErpTradeAfterSaleExtend.Create();
  11831. }
  11832. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11833. returnSuccessMsg("添加成功!");
  11834. return;
  11835. }
  11836. returnErrorMsg("找不到订单");
  11837. }
  11838. public void dealIssueContent()
  11839. {
  11840. string ctid = GetPostString("ctid");
  11841. if (!string.IsNullOrEmpty(ctid))
  11842. {
  11843. string content = GetPostString("content");
  11844. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11845. if (ceErpTradeAfterSaleExtend != null)
  11846. {
  11847. ceErpTradeAfterSaleExtend.IssueState = 2;
  11848. ceErpTradeAfterSaleExtend.Update();
  11849. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11850. returnSuccessMsg("修改完成!");
  11851. return;
  11852. }
  11853. }
  11854. returnErrorMsg("找不到订单");
  11855. }
  11856. public void set_tid_attachments()
  11857. {
  11858. string tid = GetPostString("tid");
  11859. string atta = GetPostString("atta");
  11860. if (!string.IsNullOrEmpty(tid))
  11861. {
  11862. if (string.IsNullOrEmpty(atta))
  11863. {
  11864. returnErrorMsg("文件地址为空");
  11865. return;
  11866. }
  11867. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11868. if (ceErpTradeCell != null)
  11869. {
  11870. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11871. if (ceErpTrade == null)
  11872. {
  11873. returnErrorMsg("找不到订单");
  11874. return;
  11875. }
  11876. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11877. bool isSend = false;
  11878. if (dt != null && dt.Rows.Count > 0)
  11879. {
  11880. foreach (DataRow row in dt.Rows)
  11881. {
  11882. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11883. {
  11884. isSend = true;
  11885. }
  11886. }
  11887. if (isSend)
  11888. {
  11889. returnErrorMsg("已发货无法修改");
  11890. return;
  11891. }
  11892. ceErpTrade.Attachments = atta;
  11893. ceErpTrade.Update();
  11894. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11895. returnSuccessMsg("上传成功!");
  11896. return;
  11897. }
  11898. }
  11899. }
  11900. returnErrorMsg("找不到订单");
  11901. }
  11902. public void get_tid_attachments()
  11903. {
  11904. string tid = GetPostString("tid");
  11905. if (!string.IsNullOrEmpty(tid))
  11906. {
  11907. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11908. if (ceErpTradeCell != null)
  11909. {
  11910. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11911. if (ceErpTrade == null)
  11912. {
  11913. returnErrorMsg("找不到订单");
  11914. return;
  11915. }
  11916. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11917. return;
  11918. }
  11919. }
  11920. returnErrorMsg("找不到订单");
  11921. }
  11922. public void check_erp_sameorders()
  11923. {
  11924. if (UrlPostParmsCheck("ctid"))
  11925. {
  11926. string eid = GetPostString("ctid");
  11927. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11928. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11929. if (entity != null && ceErpTrade != null)
  11930. {
  11931. if (entity.OrderState > 6)
  11932. {
  11933. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11934. return;
  11935. }
  11936. StringBuilder sql = new StringBuilder();
  11937. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo from view_ErpTradeCell where SupplierId={0} and orderstate=6 and IsSample = 0", entity.SupplierId);
  11938. if (string.IsNullOrEmpty(ceErpTrade.receiverId))
  11939. {
  11940. sql.AppendFormat(" and (tid='{0}');", entity.tid);
  11941. }
  11942. else
  11943. {
  11944. sql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}'));", entity.tid, ceErpTrade.receiverId, entity.IsSF);
  11945. }
  11946. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11947. List<string> ids = new List<string>();
  11948. if (dt != null && dt.Rows.Count > 1)
  11949. {
  11950. bool needhe = true;
  11951. foreach (DataRow dr in dt.Rows)
  11952. {
  11953. ids.Add("'" + dr["ctid"] + "'");
  11954. /* //备注有合包
  11955. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  11956. {
  11957. needhe = true;
  11958. }
  11959. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  11960. {
  11961. needhe = true;
  11962. }
  11963. //顺丰快递
  11964. if (Convert.ToInt32(dr["IsSF"]) > 0)
  11965. {
  11966. needhe = true;
  11967. }*/
  11968. }
  11969. if (!needhe)
  11970. {
  11971. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11972. return;
  11973. }
  11974. sql = new StringBuilder();
  11975. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11976. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  11977. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  11978. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11979. foreach (DataRow dr in dt.Rows)
  11980. {
  11981. dr["dstate"] = 0;
  11982. dr["dnumber"] = 0;
  11983. foreach (DataRow row in dt1.Rows)
  11984. {
  11985. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  11986. {
  11987. dr["dstate"] = 2;
  11988. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  11989. }
  11990. }
  11991. if (eid.Equals(dr["ctid"].ToString()))
  11992. {
  11993. dr["dstate"] = 1;
  11994. }
  11995. }
  11996. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  11997. return;
  11998. }
  11999. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12000. return;
  12001. }
  12002. returnErrorMsg("未找到订单");
  12003. return;
  12004. }
  12005. returnErrorMsg("缺少必要的参数");
  12006. }
  12007. public void get_mark_number()
  12008. {
  12009. string eid = GetPostString("ctid");
  12010. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12011. if (entity != null)
  12012. {
  12013. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12014. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12015. int current = 1;
  12016. if (ceErpDeliverMark == null)
  12017. {
  12018. StringBuilder sql = new StringBuilder();
  12019. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo from view_ErpTradeCell where SupplierId={0} and orderstate=6 and IsSample = 0", entity.SupplierId);
  12020. if (string.IsNullOrEmpty(ceErpTrade.receiverId))
  12021. {
  12022. sql.AppendFormat(" and (tid='{0}');", entity.tid);
  12023. }
  12024. else
  12025. {
  12026. sql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}'));", entity.tid, ceErpTrade.receiverId, entity.IsSF);
  12027. }
  12028. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12029. List<string> ids = new List<string>();
  12030. if (dt != null && dt.Rows.Count > 1)
  12031. {
  12032. foreach (DataRow dr in dt.Rows)
  12033. {
  12034. ids.Add("'" + dr["ctid"] + "'");
  12035. }
  12036. //查询已有的编号
  12037. sql = new StringBuilder();
  12038. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12039. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12040. if (dt1 == null || dt1.Rows.Count == 0)
  12041. {
  12042. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12043. List<int> list_number = new List<int>();
  12044. foreach (DataRow row in numbers.Rows)
  12045. {
  12046. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12047. }
  12048. //查询空余编号
  12049. for (int i = 0; i < list_number.Count + 2; i++)
  12050. {
  12051. if (!list_number.Contains(current))
  12052. {
  12053. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12054. //防止查询过程中有新数据生成
  12055. if (ceErpDeliverMark1 == null)
  12056. {
  12057. break;
  12058. }
  12059. }
  12060. current++;
  12061. }
  12062. }
  12063. else
  12064. {
  12065. foreach (DataRow row in dt1.Rows)
  12066. {
  12067. current = Convert.ToInt32(row["markNumber"]);
  12068. }
  12069. }
  12070. ceErpDeliverMark = new CeErpDeliverMark();
  12071. ceErpDeliverMark.ctid = eid;
  12072. ceErpDeliverMark.createtime = DateTime.Now;
  12073. if (ceErpTrade != null)
  12074. {
  12075. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12076. }
  12077. ceErpDeliverMark.markNumber = current;
  12078. ceErpDeliverMark.Create();
  12079. }
  12080. }
  12081. else
  12082. {
  12083. current = ceErpDeliverMark.markNumber;
  12084. }
  12085. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12086. return;
  12087. }
  12088. }
  12089. public void aftersaleCytSend()
  12090. {
  12091. string ctid = GetPostString("ctid");
  12092. if (!string.IsNullOrEmpty(ctid))
  12093. {
  12094. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12095. if (ceErpTradeCell != null)
  12096. {
  12097. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12098. }
  12099. returnSuccessMsg("推送成功");
  12100. return;
  12101. }
  12102. returnErrorMsg("缺少必要的参数");
  12103. }
  12104. public void packOrderInfo()
  12105. {
  12106. string ctids = GetPostString("ctids");
  12107. if (!string.IsNullOrEmpty(ctids))
  12108. {
  12109. string[] ctid_list = ctids.Split(',');
  12110. if (ctid_list.Length > 20)
  12111. {
  12112. returnErrorMsg("单次下载次数不能超过20个");
  12113. return;
  12114. }
  12115. StringBuilder sql = new StringBuilder();
  12116. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  12117. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12118. int supplierId = 0;
  12119. StringBuilder insterSql = new StringBuilder();
  12120. for (int i = 0; i < dt.Rows.Count; i++)
  12121. {
  12122. DataRow row = dt.Rows[i];
  12123. if (i == 0)
  12124. {
  12125. supplierId = Convert.ToInt32(row["SupplierId"]);
  12126. }
  12127. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12128. {
  12129. returnErrorMsg("同车间的订单才能一起打包");
  12130. return;
  12131. }
  12132. int orderState = Convert.ToInt32(row["OrderState"]);
  12133. if (orderState != 5)
  12134. {
  12135. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12136. return;
  12137. }
  12138. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12139. }
  12140. CeErpPackData ceErpPackData = new CeErpPackData();
  12141. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + ".zip";
  12142. ceErpPackData.supplierId = supplierId;
  12143. ceErpPackData.createtime = DateTime.Now;
  12144. ceErpPackData.createBy = CurrentUser.UserID;
  12145. ceErpPackData.createName = CurrentUser.UserName;
  12146. ceErpPackData.Create();
  12147. if (ceErpPackData.ID > 0)
  12148. {
  12149. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12150. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12151. }
  12152. returnSuccessMsg("打包成功");
  12153. return;
  12154. }
  12155. returnErrorMsg("缺少必要的参数");
  12156. }
  12157. public void get_pack_list()
  12158. {
  12159. DataStruct dStruct = GetPostStruct();
  12160. List<string> lw = new List<string>();
  12161. string supplier = GetPostString("supplier");
  12162. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12163. string posTag = CurrentUser.UserPost.Post.Code;
  12164. if (posTag == "Supplier")
  12165. {
  12166. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12167. }
  12168. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12169. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12170. writeGridDataTableJson(dStruct.TotalCount, dt);
  12171. }
  12172. public void get_supplier_product_time_list()
  12173. {
  12174. DataStruct dStruct = GetPostStruct();
  12175. List<string> lw = new List<string>();
  12176. string supplier = GetPostString("supplier");
  12177. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12178. string posTag = CurrentUser.UserPost.Post.Code;
  12179. if (posTag != "SysAdmin")
  12180. {
  12181. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12182. }
  12183. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12184. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12185. writeGridDataTableJson(dStruct.TotalCount, dt);
  12186. }
  12187. public void saveSupplierProductTime()
  12188. {
  12189. string productId = GetPostString("productId");
  12190. if (string.IsNullOrEmpty(productId))
  12191. {
  12192. returnErrorMsg("缺少必要的参数");
  12193. return;
  12194. }
  12195. string productName = GetPostString("productName");
  12196. int supplierId = GetPostInt("supplierId");
  12197. if (supplierId == 0)
  12198. {
  12199. returnErrorMsg("缺少必要的参数");
  12200. return;
  12201. }
  12202. int quantity = GetPostInt("quantity");
  12203. int sendDay = GetPostInt("sendTime");
  12204. string supplierName = GetPostString("supplierName");
  12205. string craft = GetPostString("craft");
  12206. string deadLine = GetPostString("deadLine");
  12207. string dayDeadLine = GetPostString("dayDeadLine");
  12208. try
  12209. {
  12210. int eid = GetPostInt("eid");
  12211. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12212. if (ceErpSupplierProductTime == null)
  12213. {
  12214. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12215. }
  12216. ceErpSupplierProductTime.productId = productId;
  12217. ceErpSupplierProductTime.productName = productName;
  12218. ceErpSupplierProductTime.supplierId = supplierId;
  12219. ceErpSupplierProductTime.supplierName = supplierName;
  12220. ceErpSupplierProductTime.craft = craft;
  12221. ceErpSupplierProductTime.sendDay = sendDay;
  12222. ceErpSupplierProductTime.quantity = quantity;
  12223. if (!string.IsNullOrEmpty(deadLine))
  12224. {
  12225. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12226. }
  12227. if (!string.IsNullOrEmpty(dayDeadLine))
  12228. {
  12229. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12230. }
  12231. if (ceErpSupplierProductTime.ID == 0)
  12232. {
  12233. ceErpSupplierProductTime.Save();
  12234. }
  12235. else
  12236. {
  12237. ceErpSupplierProductTime.Update();
  12238. }
  12239. }
  12240. catch (Exception e)
  12241. {
  12242. }
  12243. returnSuccessMsg("保存成功");
  12244. return;
  12245. }
  12246. public void delSupplierProductTime()
  12247. {
  12248. int eid = GetPostInt("eid");
  12249. if (eid > 0)
  12250. {
  12251. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12252. if (ceErpSupplierProductTime == null)
  12253. {
  12254. returnErrorMsg("查无数据");
  12255. return;
  12256. }
  12257. ceErpSupplierProductTime.Delete();
  12258. returnSuccessMsg("保存成功");
  12259. return;
  12260. }
  12261. returnErrorMsg("缺少必要的参数");
  12262. }
  12263. public void getExpressInfo()
  12264. {
  12265. string ctid = GetPostString("ctid");
  12266. if (!string.IsNullOrEmpty(ctid))
  12267. {
  12268. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12269. if (ceErpTradeCell != null)
  12270. {
  12271. string outSid = ceErpTradeCell.OutSid;
  12272. if (outSid.Length > 0)
  12273. {
  12274. 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);
  12275. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12276. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12277. return;
  12278. }
  12279. }
  12280. returnErrorMsg("查无记录");
  12281. return;
  12282. }
  12283. returnErrorMsg("缺少必要的参数");
  12284. }
  12285. public void getExpressPostData()
  12286. {
  12287. string express = GetPostString("express");
  12288. if (!string.IsNullOrEmpty(express))
  12289. {
  12290. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12291. if (ceErpExpressInfo != null)
  12292. {
  12293. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12294. return;
  12295. }
  12296. }
  12297. returnErrorMsg("缺少必要的参数");
  12298. }
  12299. }
  12300. }