sync.order.cs 649 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using BizCom.Enum;
  50. namespace SiteCore.Handler
  51. {
  52. public partial class sync
  53. {
  54. public void get_erp_orderlist()
  55. {
  56. string poscode = CurrentUser.UserPost.Post.Code;
  57. DataStruct dStruct = GetPostStruct();
  58. //string a = SecurityHelper.DecryptSymmetric("YDaPXIhsKgw=");
  59. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\水标售价(1).xlsx");
  60. //apiHelper.Api_SyncOrderByTime("598825");
  61. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  62. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  63. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  64. //banniuApiHelper.sendLogisticsInfo(null);
  65. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  66. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  67. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  68. //int sid = commonHelper.autoDistributeToSupplier(entity);
  69. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  70. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1752654175000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1752826970000,\"lines\":[{\"latestDeliveryTime\":1752826970000,\"mark2\":[],\"num\":23,\"outerId\":\"DGCP\",\"payment\":460.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2200806677467/O1CN01Wlpmej251wOGAuYd2_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":20.0,\"refOlId\":\"4634728491992436446\",\"refSkuId\":\"0\",\"refSpuId\":\"617207822351\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":20.0,\"singleFee\":20.0,\"spuOuterId\":\"DGCP\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"蛋糕logo插牌定制烘焙店插卡插排生日小卡片装饰甜品标签插件设计\",\"totalFee\":460.0,\"totalPrice\":460.0,\"totalSellPrice\":460.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1752658857000,\"openBuyerId\":\"AAHqRHraABkUZRPgSx1P9I8b\",\"openBuyerNick\":\"b**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1752654168000,\"payTime\":1752654170000,\"payment\":460.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"佛山市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"禅城区\",\"receiverId\":\"882d7aaecddc7a9698cc36e36a46ba24$\",\"receiverState\":\"广东省\",\"receiverTown\":\"石湾镇街道\",\"refOid\":\"4634728491992436446\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"60x12mm-2款各500张-插卡-350克铜板纸-直角单面烫金模切-bowie_s-英子-240元-(纯烫金)-老客户204.02.20,40x40mm-2000张-插卡-350克铜板纸-方形直角裁切-bowie_s-英子-220元--老客户2024.02.20\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":460.0,\"totalPrice\":460.0,\"totalSellPrice\":460.0,\"type\":\"SALE\"}}");
  71. //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}}");
  72. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  73. //commonHelper.loginGetOrder(2152);
  74. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  75. //preSalesHelper.dealMessageInfo("{\"bizOrder\":{\"id\":235819,\"parentId\":null,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderNo\":\"4624034580248409502\",\"shopId\":4,\"shopCode\":\"aolifu\",\"customerId\":345874,\"customerServiceId\":3184,\"thirdOrderId\":\"4624034580248409502\",\"orderPlatform\":\"TMALL\",\"openBuyerId\":\"AAEORHraABkUZRHgSx6ksuhU\",\"openBuyerNick\":\"tb278604202340\",\"openSellerNick\":\"奥丽芙旗舰店\",\"productUrl\":null,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"payAmount\":125.0,\"unrefundedAmount\":125.0,\"discountAmount\":5.0,\"csDiscountAmount\":-35.0,\"num\":13,\"province\":\"山西省\",\"city\":\"吕梁市\",\"area\":\"孝义市\",\"receiverTown\":\"孝义市\",\"address\":null,\"thirdReceiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"receiverName\":null,\"receiverMobile\":null,\"weChatId\":null,\"phone\":null,\"designContent\":\"\",\"designPics\":\"[]\",\"weChatQrPics\":\"[]\",\"addressFileUrl\":\"\",\"thirdFlag\":\"NONE\",\"remark\":null,\"sellerRemark\":\"\",\"buyerRemark\":\"\",\"timeoutRemark\":null,\"discountRemark\":null,\"status\":\"NOT_SHIPPED\",\"refundStatus\":0,\"internalStatus\":2,\"auditStatus\":null,\"auditUserId\":null,\"auditor\":null,\"customTag\":null,\"isRepurchase\":false,\"isOffline\":false,\"paymentFile\":null,\"orderTime\":\"2025-07-10 14:46:13\",\"modifyTime\":\"2025-07-10 14:46:37\",\"payTime\":\"2025-07-10 14:46:37\",\"confirmTime\":\"2025-07-10 14:51:23\",\"auditTime\":null,\"shippingTime\":null,\"finishTime\":null,\"erpCustomerServiceId\":3319,\"openBuyerID\":\"AAEORHraABkUZRHgSx6ksuhU\",\"orderFrom\":\"10\",\"receiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"bizOrderItems\":[{\"id\":310334,\"orderId\":235819,\"thirdOrderItemId\":\"4624034580248409502\",\"thirdSpuId\":\"740203900330\",\"thirdSkuId\":\"0\",\"title\":\"pvc贴纸定制防水不干胶圆形贴标自粘商标logo广告二维码标签印刷\",\"specification\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2433960672/O1CN01D0ZzzR1GppCHSoBjD_!!4611686018427382496-0-item_pic.jpg\",\"price\":10.0,\"sellPrice\":9.62,\"amount\":9.62,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"totalAmount\":125.0,\"num\":13,\"refundStatus\":\"NO_REFUND\"}],\"bizOrderSplits\":[{\"id\":151557,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328848\",\"splitNo\":\"C1_4624034580248409502\",\"splitInfoNo\":\"C2+1\",\"splitAmount\":52.64,\"quoteRecordId\":520208,\"quoteAmount\":40.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328848)-[C2+1]-80x20mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328848\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":40.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":80.00,\"width\":20.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"80x20mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":40.00,\"numberType\":\"\",\"isDianziOrder\":0},{\"id\":151558,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328853\",\"splitNo\":\"C2_4624034580248409502\",\"splitInfoNo\":\"C2+2\",\"splitAmount\":72.36,\"quoteRecordId\":520209,\"quoteAmount\":55.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328853)-[C2+2]-90x50mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328853\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":55.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":90.00,\"width\":50.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"90x50mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":55.00,\"numberType\":\"\",\"isDianziOrder\":0}]}}");
  76. List<string> lw = new List<string>();
  77. string tid = GetPostString("ctid");
  78. string date1 = GetPostString("date1");
  79. //12-1 修改
  80. string urgent = GetPostString("urgent");
  81. string back = GetPostString("back");
  82. string offlineSearch = GetPostString("offlineSearch");
  83. int paramsCount = 0;
  84. if (!string.IsNullOrWhiteSpace(urgent))
  85. {
  86. if (urgent.Equals("true"))
  87. {
  88. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  89. }
  90. }
  91. if (!string.IsNullOrWhiteSpace(back))
  92. {
  93. if (back.Equals("true"))
  94. {
  95. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  96. }
  97. }
  98. if (!string.IsNullOrWhiteSpace(offlineSearch))
  99. {
  100. if (offlineSearch.Equals("true"))
  101. {
  102. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  103. }
  104. }
  105. //end
  106. string date2 = GetPostString("date2");
  107. string buyernick = GetPostString("buyer_nick");
  108. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  109. {
  110. if (tid.Length <= 0 && buyernick.Length <= 0)
  111. {
  112. return;
  113. }
  114. }
  115. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  116. {
  117. if (tid.Length > 0)
  118. {
  119. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  120. if (ceErpTradeCell != null)
  121. {
  122. tid = ceErpTradeCell.tid;
  123. }
  124. List<string> select_tid = getTidByCtidMore(tid);
  125. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  126. }
  127. if (buyernick.Length > 0)
  128. {
  129. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  130. }
  131. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  132. if (dw.Length > 0)
  133. {
  134. lw.Add(dw);
  135. }
  136. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  137. {
  138. string usershop = CurrentUser.User.pemShop;
  139. lw.Add(string.Format("ShopId in ({0})", usershop));
  140. }
  141. }
  142. else
  143. {
  144. if (ex_psize == 0)
  145. {
  146. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  147. }
  148. if (PKey != "admin" && poscode != "SysAdmin")
  149. {
  150. string usershop = CurrentUser.User.pemShop;
  151. lw.Add(string.Format("ShopId in ({0})", usershop));
  152. paramsCount++;
  153. }
  154. }
  155. string uploaddate1 = GetPostString("uploaddate1");
  156. string uploaddate2 = GetPostString("uploaddate2");
  157. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  158. if (update.Length > 0) lw.Add(update);
  159. string deliverydate1 = GetPostString("deliverydate1");
  160. string deliverydate2 = GetPostString("deliverydate2");
  161. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  162. if (deliverydate.Length > 0)
  163. {
  164. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  165. };
  166. string shopname = GetPostString("shopname");
  167. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  168. string addwechat = GetPostString("addwechat");
  169. if (addwechat.Length > 0)
  170. {
  171. int addWt = Convert.ToInt32(addwechat);
  172. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  173. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  174. }
  175. string customer = GetPostString("customer");
  176. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  177. string design = GetPostString("design");
  178. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  179. string orderState = GetPostString("orderState");
  180. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  181. string address = GetPostString("address");
  182. 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));
  183. string sellermemo = GetPostString("seller_memo");
  184. if (sellermemo.Length > 0)
  185. {
  186. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  187. }
  188. string backReason = GetPostString("backReason");
  189. if (backReason.Length > 0)
  190. {
  191. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  192. }
  193. string apdate1 = GetPostString("apdate1");
  194. string apdate2 = GetPostString("apdate2");
  195. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  196. if (dwap.Length > 0) lw.Add(dwap);
  197. string price1 = GetPostString("price1");
  198. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  199. string price2 = GetPostString("price2");
  200. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  201. string isoldcustomer = GetPostString("isoldcus");
  202. string spudata = GetPostString("spudata");
  203. if ("0".Equals(spudata))
  204. {
  205. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  206. }
  207. if ("1".Equals(spudata))
  208. {
  209. lw.Add(string.Format("spu_id <> ''"));
  210. }
  211. string finishdate1 = GetPostString("finishdate1");
  212. string finishdate2 = GetPostString("finishdate2");
  213. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  214. bool isFinish = false;
  215. if (finishdate.Length > 0)
  216. {
  217. lw.Add(finishdate);
  218. isFinish = true;
  219. paramsCount++;
  220. }
  221. if (isoldcustomer.Length > 0)
  222. {
  223. if ("2".Equals(isoldcustomer))
  224. {
  225. lw.Add(string.Format("VipCustomer=1"));
  226. }
  227. else
  228. {
  229. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  230. }
  231. }
  232. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  233. if (ex_psize > 0)
  234. {
  235. int UserID = CurrentUser.UserID;
  236. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  237. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  238. {
  239. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  240. }
  241. dStruct.Order = "pay_time desc";
  242. }
  243. string isNew = GetPostString("isNew");
  244. if (isNew == "true")
  245. {
  246. lw.Add(string.Format("IsNew = {0}", 1));
  247. }
  248. string overtime = GetPostString("overtime");
  249. if (overtime == "1")
  250. {
  251. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  252. }
  253. String usePost = CurrentUser.UserPost.Post.Code;
  254. if (usePost.Equals("Operation") == true)
  255. {
  256. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  257. }
  258. else
  259. {
  260. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  261. }
  262. //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";
  263. if (dStruct.PageSize == 100000)
  264. {
  265. dStruct.Order = "";
  266. }
  267. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  268. DataTable dt = null;
  269. string tablename = "view_orderlist";
  270. if (isFinish)
  271. {
  272. tablename = "view_orderlist_end";
  273. }
  274. dt = WebCache.GetData(tablename, dStruct);
  275. if (dt != null && dt.Rows.Count > 0)
  276. {
  277. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  278. foreach (DataRow dr in dt.Rows)
  279. {
  280. try
  281. {
  282. if (dr["refund_fees"] != null)
  283. {
  284. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  285. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  286. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  287. if (payment == refund_fees)
  288. {
  289. dr["refund_fees"] = Math.Round(refund_fees, 2);
  290. }
  291. else if (refund_fees == total_fee)
  292. {
  293. dr["refund_fees"] = payment;
  294. }
  295. else
  296. {
  297. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  298. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  299. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  300. }
  301. }
  302. // 对象操作
  303. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  304. ceErpTradeCell.ctid = dr["ctid"].ToString();
  305. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  306. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  307. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  308. if (dStruct.PageSize != 100000)
  309. {
  310. if (dr["DispatchSort"].ToString() == "2")
  311. {
  312. dr["gongchuang"] = 200;
  313. }
  314. else if ("外协".Equals(dr["ToType"].ToString()))
  315. {
  316. dr["gongchuang"] = 200;
  317. }
  318. else if ("内部".Equals(dr["ToType"].ToString()))
  319. {
  320. dr["gongchuang"] = -1;
  321. }
  322. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  323. {
  324. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  325. dr["gongchuang"] = response.code;
  326. }
  327. }
  328. }
  329. catch (NullReferenceException ex)
  330. {
  331. // 处理空引用异常
  332. dr["refund_fees"] = "0.00";
  333. }
  334. }
  335. }
  336. writeGridDataTableJson(dStruct.TotalCount, dt);
  337. }
  338. public void get_erp_orderlist_sumprice()
  339. {
  340. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  341. return;
  342. List<string> lw = new List<string>();
  343. string tid = GetPostString("ctid");
  344. string date1 = GetPostString("date1");
  345. string date2 = GetPostString("date2");
  346. if (tid.Length > 0 || date1.Length > 0)
  347. {
  348. lw.Add(string.Format("ctid like '%{0}%'", tid));
  349. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  350. if (dw.Length > 0) lw.Add(dw);
  351. }
  352. else
  353. {
  354. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  355. }
  356. string shopname = GetPostString("shopname");
  357. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  358. string buyernick = GetPostString("buyer_nick");
  359. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  360. string customer = GetPostString("customer");
  361. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  362. string design = GetPostString("design");
  363. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  364. string orderState = GetPostString("orderState");
  365. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  366. string address = GetPostString("address");
  367. 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));
  368. string sellermemo = GetPostString("seller_memo");
  369. if (sellermemo.Length > 0)
  370. {
  371. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  372. }
  373. string apdate1 = GetPostString("apdate1");
  374. string apdate2 = GetPostString("apdate2");
  375. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  376. if (dwap.Length > 0) lw.Add(dwap);
  377. string price1 = GetPostString("price1");
  378. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  379. string price2 = GetPostString("price2");
  380. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  381. string isoldcustomer = GetPostString("isoldcus");
  382. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  383. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  384. if (PKey != "admin")
  385. {
  386. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  387. lw.Add(string.Format("shopId in ({0})", usershop));
  388. }
  389. //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";
  390. string mainWhere = string.Join(" and ", lw.ToArray());
  391. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  392. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  393. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  394. decimal total = 0;
  395. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  396. {
  397. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  398. }
  399. var res = new
  400. {
  401. data = total
  402. };
  403. string ro_jsond = JsonConvert.SerializeObject(res);
  404. returnSuccess(ro_jsond);
  405. return;
  406. }
  407. public void get_erp_CustomerServiceGather()
  408. {
  409. string userWhere = "", orderWhere = "";
  410. List<string> lw = new List<string>();
  411. string customer = GetPostString("customer");
  412. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  413. string shopname = GetPostString("shopname");
  414. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  415. string date1 = GetPostString("date1");
  416. string date2 = GetPostString("date2");
  417. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  418. if (dw.Length > 0) lw.Add(dw);
  419. orderWhere = string.Join(" and ", lw.ToArray());
  420. 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 " +
  421. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  422. "left join " +
  423. "( " +
  424. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  425. ") as b on a.ID = b.CustomerUserId " +
  426. "left join " +
  427. "( " +
  428. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  429. ") as d on a.ID = d.CustomerUserId " +
  430. "left join " +
  431. "( " +
  432. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  433. ") as e on a.ID = e.CustomerUserId " +
  434. "left join " +
  435. "( " +
  436. " select CustomerUserId, RefundCount, RefundSum from " +
  437. " ( " +
  438. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  439. " from CE_ErpTradeRefund a " +
  440. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  441. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  442. " group by CustomerUserId " +
  443. " ) as a " +
  444. ") as f on a.ID = f.CustomerUserId " +
  445. "where a.PostCode = 'CustomerService'",
  446. userWhere, orderWhere);
  447. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  448. writeGridDataTableJson(dt.Rows.Count, dt);
  449. //writeGridDataTableJson(dt.Rows.Count, dt);
  450. }
  451. //设计汇总
  452. public void get_erp_DesignerGather()
  453. {
  454. string userWhere = "", orderWhere = "";
  455. List<string> lw = new List<string>();
  456. string Designer = GetPostString("designer");
  457. int org = GetPostInt("org");
  458. if (Designer.Length > 0)
  459. {
  460. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  461. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  462. }
  463. else if (org > 0)
  464. {
  465. userWhere = string.Format(" where OrgID ={0}", org);
  466. }
  467. string shopname = GetPostString("shopname");
  468. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  469. string state = GetPostString("state");
  470. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  471. string OrderArea = GetPostString("order_area");
  472. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  473. string date1 = GetPostString("date1");
  474. string date2 = GetPostString("date2");
  475. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  476. if (dw.Length > 0) lw.Add(dw);
  477. string UpDate1 = GetPostString("UpDate1");
  478. string UpDate2 = GetPostString("UpDate2");
  479. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  480. if (dw.Length > 0) lw.Add(dw);
  481. orderWhere = string.Join(" and ", lw.ToArray());
  482. 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 (" +
  483. "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 " +
  484. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  485. "left join " +
  486. "( " +
  487. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  488. ") as b on a.ID = b.DesignUserId " +
  489. "left join " +
  490. "( " +
  491. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  492. ") as d on a.ID = d.DesignUserId " +
  493. "left join " +
  494. "( " +
  495. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  496. ") as e on a.ID = e.DesignUserId " +
  497. "left join " +
  498. "( " +
  499. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  500. ") as g on a.ID = g.DesignUserId " +
  501. "left join " +
  502. "( " +
  503. " select CustomerUserId, RefundCount, RefundSum from " +
  504. " ( " +
  505. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  506. " from CE_ErpTradeRefund a " +
  507. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  508. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  509. " group by CustomerUserId " +
  510. " ) as a " +
  511. ") as f on a.ID = f.CustomerUserId " +
  512. "where a.PostCode = 'Designer') as z",
  513. userWhere, orderWhere);
  514. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  515. writeGridDataTableJson(dt.Rows.Count, dt);
  516. }
  517. //删除tradecell的订单
  518. public void del_erp_cellorder()
  519. {
  520. if (UrlPostParmsCheck("ctid"))
  521. {
  522. string eid = GetPostString("ctid");
  523. CeErpTradeCell.DelByCtid(eid);
  524. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  525. returnSuccessMsg("删除成功");
  526. }
  527. }
  528. public void clear_erp_refundstate()
  529. {
  530. if (UrlPostParmsCheck("ids"))
  531. {
  532. string eids = GetPostString("ids");
  533. string[] ctidList = eids.Split(',');
  534. foreach (string ctid in ctidList)
  535. {
  536. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  537. if (entity != null)
  538. {
  539. entity.IsRefund = 0;
  540. entity.Update();
  541. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  542. }
  543. else
  544. continue;
  545. }
  546. returnSuccessMsg("操作成功");
  547. return;
  548. }
  549. returnErrorMsg("缺少必要参数");
  550. }
  551. public void set_erp_urgency()
  552. {
  553. if (UrlPostParmsCheck("ctid"))
  554. {
  555. string eid = GetPostString("ctid");
  556. CeErpTradeCell entity = null;
  557. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  558. if (entity != null)
  559. {
  560. double prices = commonHelper.calculationPrice(entity);
  561. if (prices <= 100)
  562. {
  563. returnErrorMsg("此订单金额不足100元,无法加急。");
  564. return;
  565. }
  566. string utime = GetPostString("urgencytime");
  567. if (utime.Length > 0)
  568. {
  569. entity.UrgencyTime = Convert.ToDateTime(utime);
  570. }
  571. else
  572. {
  573. returnErrorMsg("请选择加急时间");
  574. return;
  575. }
  576. if (entity.OrderState <= 4)
  577. {
  578. //entity.seller_memo = entity.seller_memo + "-加急";
  579. string smemo = entity.seller_memo;
  580. int kindex = smemo.IndexOf(")");
  581. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  582. if (lastoneStr != "-")
  583. {
  584. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  585. }
  586. string prememo = smemo.Substring(0, kindex + 2);
  587. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  588. int lastkindex = lastmemo.IndexOf("(");
  589. DateTime urgtime = Convert.ToDateTime(utime);
  590. string newlastmemo = "";
  591. if (lastkindex == 0)
  592. {
  593. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  594. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  595. }
  596. else
  597. {
  598. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  599. }
  600. entity.seller_memo = prememo + newlastmemo;
  601. }
  602. entity.IsUrgency = true;
  603. entity.UpdateTime = DateTime.Now;
  604. entity.Update();
  605. ApiVo apiVo = new ApiVo();
  606. apiVo.orderNumber = entity.ctid;
  607. apiVo.actionName = "changeDesign";
  608. apiVo.orderRemarks = entity.seller_memo;
  609. apiVo.remarkSign = 3;
  610. designHelper.API_WorkCore(apiVo); //changeDesign
  611. CeErpSukuraData.createInfo(entity.ctid, 7);
  612. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  613. returnSuccessMsg("设置成功!");
  614. return;
  615. }
  616. returnErrorMsg("找不到记录");
  617. }
  618. }
  619. public void set_erp_reset()
  620. {
  621. if (UrlPostParmsCheck("ctid"))
  622. {
  623. string eid = GetPostString("ctid");
  624. CeErpTradeCell entity = null;
  625. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  626. if (entity != null)
  627. {
  628. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  629. {
  630. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  631. {
  632. returnErrorMsg("财务要求已下单已发货无法重置");
  633. return;
  634. }
  635. }
  636. entity.IsUrgency = false;
  637. entity.seller_memo = "";
  638. entity.OtherMemo = "";
  639. entity.OrderState = 0;
  640. entity.IsReturn = 0;
  641. //entity.IsRefund = 0;
  642. entity.MemoOpt = 0;
  643. entity.AfterSaleState = 0;
  644. entity.AfterSaleResponsible = "";
  645. entity.AfterSaleUserId = 0;
  646. entity.IsNeedBill = 0;
  647. entity.CustomerUserId = 0;
  648. entity.DesignUserId = 0;
  649. entity.SupplierId = 0;
  650. entity.PlaceUserId = 0;
  651. entity.ptid = "";
  652. entity.IsSample = 0;
  653. entity.IsXianHuo = 0;
  654. entity.isDianziOrder = 0;
  655. entity.DispatchSort = 0;
  656. entity.IsVerifyToSupplier = false;
  657. entity.FinishPlaceTime = null;
  658. entity.Update();
  659. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  660. if (trade != null)
  661. {
  662. trade.seller_memo = "";
  663. trade.Update();
  664. }
  665. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  666. returnSuccessMsg("重置成功!");
  667. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  668. if (desginBill != null)
  669. {
  670. desginBill.isDel = 1;
  671. desginBill.Update();
  672. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  673. }
  674. ApiVo apiVo = new ApiVo();
  675. apiVo.orderNumber = entity.ctid;
  676. apiVo.actionName = "resetDesign";
  677. designHelper.API_WorkCore(apiVo);//resetDesign
  678. return;
  679. }
  680. returnErrorMsg("找不到记录");
  681. }
  682. }
  683. public void save_erp_sellermemo()
  684. {
  685. if (UrlPostParmsCheck("ctid"))
  686. {
  687. string ctid = GetPostString("ctid");
  688. CeErpTradeCell entity = null;
  689. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  690. if (entity != null)
  691. {
  692. string memo = GetPostString("seller_memo");
  693. memo = memo.Replace(" ", "");
  694. if (memo.Contains("补差"))
  695. {
  696. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  697. return;
  698. }
  699. List<string> bitList = new List<string>
  700. {
  701. "\\","/",":","*","?", "\"","<" ,">","|"
  702. };
  703. bool isIn = false;
  704. foreach (string bit in bitList)
  705. {
  706. if (memo.Contains(bit))
  707. {
  708. isIn = true;
  709. }
  710. }
  711. if (isIn)
  712. {
  713. returnErrorMsg("不能使用 一些符合作为文件名");
  714. return;
  715. }
  716. if (entity.seller_memo != memo)
  717. {
  718. if (entity.IsSample == 2)
  719. {
  720. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  721. return;
  722. }
  723. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  724. {
  725. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  726. {
  727. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  728. return;
  729. }
  730. /*if (CurrentUser.UserPost.Post.Code != "Place")
  731. {
  732. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  733. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  734. {
  735. returnErrorMsg("售前系统订单无法再此修改!");
  736. return;
  737. }
  738. }*/
  739. }
  740. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  741. }
  742. commonHelper.getCytPrice(entity);
  743. int memoopt = GetPostInt("MemoOpt");
  744. Boolean ismemoopt = false;
  745. if (memoopt > 0)
  746. {
  747. string stropt = "";
  748. if (memoopt == 1)
  749. {
  750. stropt = "“改稿”";
  751. ismemoopt = true;
  752. }
  753. else if (memoopt == 2)
  754. {
  755. stropt = "“定稿”";
  756. }
  757. else if (memoopt == 3)
  758. {
  759. stropt = "“查货”";
  760. CeErpSukuraData.createInfo(entity.ctid, 6);
  761. }
  762. entity.MemoOpt = Convert.ToInt32(memoopt);
  763. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  764. }
  765. if (entity.OrderState < 5)
  766. {
  767. memo = memo.Replace("(", "(");
  768. memo = memo.Replace(")", ")");
  769. }
  770. if (entity.OrderState < 3)
  771. {
  772. entity.DispatchSort = 0;
  773. }
  774. entity.seller_memo = memo;
  775. entity.UpdateTime = DateTime.Now;
  776. entity.Update();
  777. ApiVo apiVo = new ApiVo();
  778. apiVo.orderNumber = entity.ctid;
  779. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  780. apiVo.orderRemarks = memo;
  781. apiVo.remarkSign = memoopt;
  782. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  783. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  784. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  785. {
  786. dataHelper.api_orderBack(entity.ctid, "0", "");
  787. }
  788. if (entity.seller_memo.Contains("改稿"))
  789. {
  790. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  791. }
  792. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  793. returnSuccessMsg("保存成功!");
  794. return;
  795. }
  796. returnErrorMsg("找不到记录");
  797. }
  798. }
  799. public void ins_erp_checkorder()
  800. {
  801. if (UrlPostParmsCheck("ctid"))
  802. {
  803. string ctid = GetPostString("ctid");
  804. CeErpTradeCell entity = null;
  805. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  806. if (entity != null)
  807. {
  808. if (entity.OrderState < 6)
  809. {
  810. returnErrorMsg("下单完成后才可查货");
  811. return;
  812. }
  813. /*if (entity.OrderState > 6)
  814. {
  815. returnErrorMsg("订单已发货");
  816. return;
  817. }*/
  818. if (entity.FinishPlaceTime != null)
  819. {
  820. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  821. {
  822. returnErrorMsg("下单时间不足,无法查货");
  823. return;
  824. }
  825. }
  826. entity.MemoOpt = 3;
  827. entity.CheckOrderTime = DateTime.Now;
  828. entity.UpdateTime = DateTime.Now;
  829. entity.Update();
  830. CeErpSukuraData.createInfo(entity.ctid, 6);
  831. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  832. returnSuccessMsg("操作成功!");
  833. return;
  834. }
  835. returnErrorMsg("找不到记录");
  836. }
  837. }
  838. public void save_erp_othermemo()
  839. {
  840. if (UrlPostParmsCheck("ctid"))
  841. {
  842. string ctid = GetPostString("ctid");
  843. CeErpTradeCell entity = null;
  844. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  845. if (entity != null)
  846. {
  847. entity.OtherMemo = GetPostString("otherMemo");
  848. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  849. {
  850. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  851. StringBuilder sql = new StringBuilder();
  852. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  853. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  854. if (dt != null && dt.Rows.Count > 0)
  855. {
  856. foreach (DataRow dr in dt.Rows)
  857. {
  858. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  859. {
  860. //品类一直
  861. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  862. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  863. if (ceErpSampleCustomer == null)
  864. {
  865. ceErpSampleCustomer = new CeErpSampleCustomer();
  866. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  867. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  868. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  869. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  870. ceErpSampleCustomer.shopId = entity.ShopId;
  871. }
  872. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  873. ceErpSampleCustomer.lastTid = entity.tid;
  874. if (ceErpSampleCustomer.ID > 0)
  875. {
  876. ceErpSampleCustomer.Update();
  877. }
  878. else
  879. {
  880. ceErpSampleCustomer.Create();
  881. }
  882. }
  883. }
  884. }
  885. }
  886. //if (entity.IsOldCustomer == 1)
  887. //{
  888. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  889. //{
  890. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  891. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  892. //}
  893. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  894. //{
  895. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  896. // {
  897. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  898. // {
  899. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  900. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  901. // }
  902. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  903. // {
  904. // entity.OrderState = 2;
  905. // entity.DesignUserId = 0;
  906. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  907. // }
  908. // else
  909. // {
  910. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  911. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  912. // }
  913. // }
  914. //}
  915. //}
  916. entity.UpdateTime = DateTime.Now;
  917. entity.Update();
  918. returnSuccessMsg("保存成功!");
  919. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  920. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  921. if (entity.OtherMemo.Contains("改稿"))
  922. {
  923. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  924. }
  925. return;
  926. }
  927. returnErrorMsg("找不到记录");
  928. }
  929. }
  930. public void save_erp_customermemo()
  931. {
  932. if (UrlPostParmsCheck("ctid"))
  933. {
  934. string ctid = GetPostString("ctid");
  935. CeErpTradeCell entity = null;
  936. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  937. if (entity != null)
  938. {
  939. entity.UpdateTime = DateTime.Now;
  940. entity.CustomerMemo = GetPostString("CustomerMemo");
  941. entity.Update();
  942. ApiVo apiVo = new ApiVo();
  943. apiVo.orderNumber = entity.ctid;
  944. apiVo.actionName = "followRemarks";
  945. apiVo.orderRemarks = entity.CustomerMemo;
  946. designHelper.API_WorkCore(apiVo);//followRemarks
  947. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  948. returnSuccessMsg("保存成功!");
  949. return;
  950. }
  951. returnErrorMsg("找不到记录");
  952. }
  953. }
  954. public void upd_erp_addmemotag()
  955. {
  956. if (UrlPostParmsCheck("ctid"))
  957. {
  958. ;
  959. string eid = GetPostString("ctid");
  960. string sfTagstr = GetPostString("memotag");
  961. CeErpTradeCell entity = null;
  962. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  963. if (entity != null)
  964. {
  965. ApiVo apiVo = new ApiVo();
  966. if (entity.OrderState == 0)
  967. {
  968. returnErrorMsg("请先领单");
  969. return;
  970. }
  971. //撤销顺丰
  972. if (sfTagstr == "撤销顺丰")
  973. {
  974. entity.IsSF = 0;
  975. string reMsg = "";
  976. string oldmemo = entity.seller_memo;
  977. if (entity.OrderState < 5)
  978. {
  979. oldmemo = oldmemo.Replace("顺丰到付", "");
  980. oldmemo = oldmemo.Replace("顺丰寄付", "");
  981. entity.seller_memo = oldmemo;
  982. }
  983. else
  984. {
  985. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  986. {
  987. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  988. }
  989. }
  990. entity.Update();
  991. apiVo.orderNumber = entity.ctid;
  992. apiVo.actionName = "orderRemarks";
  993. apiVo.orderRemarks = entity.seller_memo;
  994. apiVo.isSf = entity.IsSF.ToString();
  995. designHelper.API_WorkCore(apiVo);//orderRemarks
  996. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  997. returnSuccessMsg("撤销成功!" + reMsg);
  998. return;
  999. }
  1000. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1001. {
  1002. //string oldmemo = entity.seller_memo;
  1003. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1004. string sfStr = GetPostString("memotag");
  1005. string smemo = entity.seller_memo;
  1006. int kindex = smemo.IndexOf(")");
  1007. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1008. if (lastoneStr != "-")
  1009. {
  1010. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1011. }
  1012. string prememo = smemo.Substring(0, kindex + 2);
  1013. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1014. int lastkindex = lastmemo.IndexOf("(");
  1015. string newlastmemo = "";
  1016. if (lastkindex == 0)
  1017. {
  1018. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1019. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1020. }
  1021. else
  1022. {
  1023. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1024. }
  1025. entity.seller_memo = prememo + newlastmemo;
  1026. }
  1027. string sfTagMSg = "";
  1028. if (sfTagstr == "顺丰寄付")
  1029. {
  1030. entity.IsSF = 1;
  1031. sfTagMSg = "顺丰寄付";
  1032. }
  1033. else if (sfTagstr == "顺丰到付")
  1034. {
  1035. entity.IsSF = 2;
  1036. sfTagMSg = "顺丰到付";
  1037. }
  1038. entity.Update();
  1039. apiVo = new ApiVo();
  1040. apiVo.orderNumber = entity.ctid;
  1041. apiVo.actionName = "orderRemarks";
  1042. apiVo.orderRemarks = entity.seller_memo;
  1043. apiVo.isSf = entity.IsSF.ToString();
  1044. designHelper.API_WorkCore(apiVo);//orderRemarks
  1045. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1046. returnSuccessMsg("标记成功!");
  1047. return;
  1048. }
  1049. returnErrorMsg("找不到记录");
  1050. }
  1051. }
  1052. public void upd_erp_ordertag()
  1053. {
  1054. if (UrlPostParmsCheck("ctid"))
  1055. {
  1056. string eid = GetPostString("ctid");
  1057. CeErpTradeCell entity = null;
  1058. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1059. if (entity != null)
  1060. {
  1061. int tag = GetPostInt("wechattag");
  1062. //if(tag==4 && entity.IsSample == 2)
  1063. //{
  1064. // returnErrorMsg("补差价单不能标记微信单");
  1065. // return;
  1066. //}
  1067. entity.wechatTag = tag;
  1068. entity.Update();
  1069. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1070. if (tag == 1)
  1071. {
  1072. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1073. if (cash == null)
  1074. {
  1075. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1076. cash = new CeErpReturnCash();
  1077. cash.tid = entity.tid;
  1078. cash.seller_nick = main.seller_nick;
  1079. cash.payment = trade.payment;
  1080. cash.buyer_nick = main.buyer_nick;
  1081. cash.cashstate = 0;
  1082. cash.rtype = "微信返现";
  1083. cash.returnprice = 0;
  1084. cash.created = DateTime.Now;
  1085. cash.con = "订单标记微信单";
  1086. cash.img = "";
  1087. cash.applyuserid = CurrentUser.UserID;
  1088. cash.Create();
  1089. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1090. }
  1091. else
  1092. {
  1093. cash.cashstate = 0;
  1094. cash.Update();
  1095. }
  1096. CeErpSukuraData.createInfo(entity.ctid, 9);
  1097. }
  1098. else if (tag == 2)
  1099. {
  1100. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1101. if (cash == null)
  1102. {
  1103. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1104. cash = new CeErpReturnCash();
  1105. cash.tid = entity.tid;
  1106. cash.seller_nick = main.seller_nick;
  1107. cash.payment = trade.payment;
  1108. cash.buyer_nick = main.buyer_nick;
  1109. cash.cashstate = 0;
  1110. cash.rtype = "推购返现";
  1111. cash.returnprice = 5;
  1112. cash.created = DateTime.Now;
  1113. cash.con = "订单标记推购单";
  1114. cash.img = "";
  1115. cash.applyuserid = CurrentUser.UserID;
  1116. cash.Create();
  1117. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1118. }
  1119. else
  1120. {
  1121. cash.cashstate = 0;
  1122. cash.Update();
  1123. }
  1124. CeErpSukuraData.createInfo(entity.ctid, 9);
  1125. }
  1126. else if (tag == 3)
  1127. {
  1128. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1129. if (pers == null)
  1130. {
  1131. pers = new CeErpPersuade();
  1132. pers.ctid = entity.ctid;
  1133. pers.pstate = 0;
  1134. pers.created = DateTime.Now;
  1135. pers.applyuserid = CurrentUser.UserID;
  1136. pers.Create();
  1137. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1138. }
  1139. else
  1140. {
  1141. pers.pstate = 0;
  1142. pers.Update();
  1143. }
  1144. }
  1145. else if (tag == 4 || tag == 5)
  1146. {
  1147. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1148. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1149. if (pers == null)
  1150. {
  1151. pers = CeErpStayGoods.GetByTid(entity.tid);
  1152. }
  1153. if (pers == null)
  1154. {
  1155. pers = new CeErpStayGoods();
  1156. pers.t_id = entity.tid;
  1157. pers.ctid = entity.ctid;
  1158. pers.status = "待审核";
  1159. pers.audit_type = 0;
  1160. if (tag == 4)
  1161. {
  1162. pers.stay_type = "微信推购";
  1163. }
  1164. else
  1165. {
  1166. pers.stay_type = "旺旺推购";
  1167. }
  1168. if (entity.IsXianHuo == 0)
  1169. {
  1170. pers.product_id = entity.ProductId;
  1171. }
  1172. pers.wangwang = main.buyer_nick;
  1173. pers.shop_name = main.seller_nick;
  1174. pers.creata_time = DateTime.Now;
  1175. pers.create_u_id = CurrentUser.UserID;
  1176. pers.create_u_name = CurrentUser.UserName;
  1177. pers.Create();
  1178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1179. }
  1180. else
  1181. {
  1182. pers.ctid = entity.ctid;
  1183. pers.audit_type = 0;
  1184. pers.Update();
  1185. }
  1186. CeErpSukuraData.createInfo(entity.ctid, 10);
  1187. }
  1188. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1189. returnSuccessMsg("标记成功!");
  1190. return;
  1191. }
  1192. returnErrorMsg("找不到记录");
  1193. }
  1194. }
  1195. public void upd_erp_ordertag_cancel()
  1196. {
  1197. if (UrlPostParmsCheck("ctid"))
  1198. {
  1199. string eid = GetPostString("ctid");
  1200. CeErpTradeCell entity = null;
  1201. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1202. if (entity != null)
  1203. {
  1204. entity.wechatTag = 0;
  1205. entity.Update();
  1206. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1207. if (pers != null)
  1208. {
  1209. pers.status = "取消推购";
  1210. pers.audit_type = 3;
  1211. pers.Update();
  1212. }
  1213. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1214. returnSuccessMsg("标记成功!");
  1215. return;
  1216. }
  1217. returnErrorMsg("找不到记录");
  1218. }
  1219. }
  1220. public void upd_erp_addweichattag()
  1221. {
  1222. if (UrlPostParmsCheck("ctid"))
  1223. {
  1224. ;
  1225. string eid = GetPostString("ctid");
  1226. CeErpTradeCell entity = null;
  1227. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1228. if (entity != null)
  1229. {
  1230. if (entity.IsAddWechat > 0)
  1231. {
  1232. returnErrorMsg("此单已经标记过了");
  1233. return;
  1234. }
  1235. 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);
  1236. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1237. if (dt.Rows.Count > 0)
  1238. {
  1239. entity.IsAddWechat = 2;
  1240. }
  1241. else
  1242. {
  1243. entity.IsAddWechat = 1;
  1244. }
  1245. entity.Update();
  1246. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1247. returnSuccessMsg("标记成功!");
  1248. return;
  1249. }
  1250. returnErrorMsg("找不到记录");
  1251. }
  1252. }
  1253. public void upd_erp_getmyorder()
  1254. {
  1255. if (UrlPostParmsCheck("ctid"))
  1256. {
  1257. string eid = GetPostString("ctid");
  1258. CeErpTradeCell entity = null;
  1259. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1260. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1261. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1262. {
  1263. returnErrorMsg("台湾客户需填写身份证号!");
  1264. return;
  1265. }
  1266. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1267. {
  1268. returnErrorMsg("偏远地区需要填写物流费!");
  1269. return;
  1270. }
  1271. if (entity != null)
  1272. {
  1273. if (entity.ctid.IndexOf("C") != -1)
  1274. {
  1275. StringBuilder sql = new StringBuilder();
  1276. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1277. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1278. if (dt.Rows.Count > 0)
  1279. {
  1280. decimal total = 0;
  1281. foreach (DataRow dr in dt.Rows)
  1282. {
  1283. total += Convert.ToDecimal(dr["payment"]);
  1284. }
  1285. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1286. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1287. {
  1288. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1289. return;
  1290. }
  1291. }
  1292. }
  1293. if (entity.OrderState == -1)
  1294. {
  1295. returnErrorMsg("待审核订单无法领取!");
  1296. return;
  1297. }
  1298. entity.CustomerUserId = CurrentUser.UserID;
  1299. if (entity.OrderState < 2)
  1300. {
  1301. entity.OrderState = 2;
  1302. if (entity.ShopId != 0)
  1303. {
  1304. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1305. }
  1306. }
  1307. entity.UpdateTime = DateTime.Now;
  1308. entity.Update();
  1309. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1310. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1311. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1312. {
  1313. dataHelper.api_orderBack(entity.ctid, "0", "");
  1314. }
  1315. returnSuccessMsg("领单成功!");
  1316. return;
  1317. }
  1318. returnErrorMsg("找不到记录");
  1319. }
  1320. }
  1321. public void getmyorder_from_init()
  1322. {
  1323. if (UrlPostParmsCheck("ctid"))
  1324. {
  1325. string eid = GetPostString("ctid");
  1326. CeErpTradeCell entity = null;
  1327. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1328. if (entity != null)
  1329. {
  1330. string sellerMemo = GetPostString("sellerMemo");
  1331. if (sellerMemo.Length > 0)
  1332. {
  1333. entity.seller_memo = sellerMemo;
  1334. }
  1335. string oterhMemo = GetPostString("otherMemo");
  1336. if (oterhMemo.Length > 0)
  1337. {
  1338. entity.OtherMemo = oterhMemo;
  1339. }
  1340. int urg = GetPostInt("urgency");
  1341. entity.IsUrgency = (urg == 1 ? true : false);
  1342. int wechat = GetPostInt("wechat");
  1343. int command = GetPostInt("command");
  1344. if (wechat == 1)
  1345. {
  1346. entity.wechatTag = 1;
  1347. }
  1348. if (command == 1)
  1349. {
  1350. entity.wechatTag = 2;
  1351. }
  1352. string pPro = GetPostString("pprofession");
  1353. if (pPro.Length > 0)
  1354. {
  1355. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1356. string spro = GetPostString("profession");
  1357. if (spro.Length > 0)
  1358. {
  1359. entity.ProfessionId = Convert.ToInt32(spro);
  1360. }
  1361. }
  1362. string proId = GetPostString("productId");
  1363. if (proId.Length > 0)
  1364. {
  1365. entity.ProductId = Convert.ToInt32(proId);
  1366. }
  1367. entity.Material = GetPostString("material");
  1368. entity.Craft = GetPostString("craft");
  1369. entity.CustomerUserId = CurrentUser.UserID;
  1370. if (entity.OrderState < 2)
  1371. {
  1372. entity.OrderState = 2;
  1373. if (entity.ShopId != 0)
  1374. {
  1375. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1376. }
  1377. }
  1378. entity.Update();
  1379. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1380. returnSuccessMsg("领单成功!");
  1381. return;
  1382. }
  1383. returnErrorMsg("找不到记录");
  1384. }
  1385. }
  1386. public void upd_erp_setrelationorder()
  1387. {
  1388. if (UrlPostParmsCheck("ctid"))
  1389. {
  1390. ;
  1391. string eid = GetPostString("ctid");
  1392. string ftid = GetPostString("ftid");
  1393. CeErpTradeCell entity = null;
  1394. CeErpTradeCell fentity = null;
  1395. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1396. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1397. if (fentity == null)
  1398. {
  1399. returnErrorMsg("找不到关联的主订单");
  1400. return;
  1401. }
  1402. if (entity != null)
  1403. {
  1404. if (entity.OrderState >= 5)
  1405. {
  1406. returnErrorMsg("本单已经设计完成无法关联");
  1407. return;
  1408. }
  1409. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1410. {
  1411. returnErrorMsg("线下单续审核后才能关联!");
  1412. return;
  1413. }
  1414. entity.ptid = ftid;
  1415. entity.OrderState = fentity.OrderState;
  1416. //entity.status = fentity.status;
  1417. entity.CustomerUserId = fentity.CustomerUserId;
  1418. entity.DesignUserId = fentity.DesignUserId;
  1419. entity.seller_memo = "补差价单:" + ftid;
  1420. entity.IsSample = 2;
  1421. entity.Update();
  1422. ApiVo apiVo = new ApiVo();
  1423. apiVo.orderNumber = ftid;
  1424. apiVo.payment = entity.payment;
  1425. apiVo.actionName = "repairDesign";
  1426. designHelper.API_WorkCore(apiVo);//repairDesign
  1427. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1428. returnSuccessMsg("关联成功!");
  1429. return;
  1430. }
  1431. else
  1432. returnErrorMsg("找不到记录");
  1433. }
  1434. }
  1435. public void download_erp_neworder()
  1436. {
  1437. string seller = GetPostString("seller_nick");
  1438. string tid = GetPostString("tid");
  1439. if (seller.Length <= 0 || tid.Length <= 0)
  1440. {
  1441. returnErrorMsg("数据错误");
  1442. }
  1443. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1444. //{
  1445. // returnErrorMsg("找不到店铺Sessionkey");
  1446. //}
  1447. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1448. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1449. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1450. if (res.IndexOf("refOid") == -1)
  1451. {
  1452. returnErrorMsg("下载订单数据失败");
  1453. return;
  1454. }
  1455. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1456. returnSuccessMsg("下载完成");
  1457. //tmcHelper.createNewOrder(res);
  1458. //CeErpTrade entr = null;
  1459. //entr = CeErpTrade.Get(tid);
  1460. //if (entr != null)
  1461. //{
  1462. // returnSuccess("下载成功");
  1463. // //下载成功之后,Cell表生成对应的订单;
  1464. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1465. //}
  1466. //else
  1467. //{
  1468. // returnErrorMsg("下载失败或者创建订单失败");
  1469. //}
  1470. }
  1471. public void set_erp_atersale()
  1472. {
  1473. if (UrlPostParmsCheck("ctid"))
  1474. {
  1475. string eid = GetPostString("ctid");
  1476. string reason = GetPostString("AfterSaleReason");
  1477. CeErpTradeCell entity = null;
  1478. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1479. if (entity != null)
  1480. {
  1481. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1482. {
  1483. returnErrorMsg("此订单已经在售后");
  1484. return;
  1485. }
  1486. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1487. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1488. entity.AfterSaleTime = DateTime.Now;
  1489. entity.Update();
  1490. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1491. returnSuccessMsg("转售后成功!");
  1492. return;
  1493. }
  1494. returnErrorMsg("找不到记录");
  1495. }
  1496. }
  1497. public void set_erp_withdraw()
  1498. {
  1499. if (UrlPostParmsCheck("ctid"))
  1500. {
  1501. try
  1502. {
  1503. string eid = GetPostString("ctid");//商品id
  1504. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1505. CeWithdraw ceWithdrawSelect = null;
  1506. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1507. if (ceWithdrawSelect != null)
  1508. {
  1509. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1510. {
  1511. ceWithdrawSelect.status = -1;
  1512. ceWithdrawSelect.Update();
  1513. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1514. returnSuccessMsg("重新发起审核成功");
  1515. return;
  1516. }
  1517. else
  1518. {
  1519. returnSuccessMsg("请勿重复申请!");
  1520. return;
  1521. }
  1522. }
  1523. else
  1524. {
  1525. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1526. if (string.IsNullOrEmpty(CustomerUserId))
  1527. {
  1528. CustomerUserId = "-1";
  1529. }
  1530. int Userid = CurrentUser.UserID;//用户id
  1531. CeWithdraw ceWithdraw = new CeWithdraw();
  1532. ceWithdraw.tid = eid;
  1533. ceWithdraw.userid = Userid;
  1534. ceWithdraw.providerid = CustomerUserId;
  1535. ceWithdraw.status = 3;
  1536. ceWithdraw.creationtime = DateTime.Now;
  1537. ceWithdraw.Create();
  1538. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1539. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1540. return;
  1541. }
  1542. }
  1543. catch
  1544. {
  1545. returnErrorMsg("申请撤回订单失败");
  1546. return;
  1547. }
  1548. }
  1549. }
  1550. public void ins_erp_billinfo()
  1551. {
  1552. if (UrlPostParmsCheck("ctid"))
  1553. {
  1554. string eid = GetPostString("ctid");
  1555. CeErpTradeCell entity = null;
  1556. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1557. if (entity != null)
  1558. {
  1559. CeErpBill bill = CeErpBill.GetByTid(eid);
  1560. bool isHave = false;
  1561. if (bill != null)
  1562. {
  1563. isHave = true;
  1564. if (bill.state != 4)
  1565. {
  1566. returnErrorMsg("此单已经申请过发票了");
  1567. return;
  1568. }
  1569. }
  1570. if (entity.IsNeedBill == 0)
  1571. {
  1572. entity.IsNeedBill = 1;
  1573. }
  1574. entity.Update();
  1575. string errjson = "";
  1576. try
  1577. {
  1578. CeErpBill bill_entity = new CeErpBill();
  1579. bill_entity.tid = entity.tid;
  1580. bill_entity.title = GetPostString("title");
  1581. string taxstr = GetPostString("tax");
  1582. taxstr = taxstr.Replace(" ", "");
  1583. bill_entity.tax = taxstr;
  1584. bill_entity.bank = GetPostString("bank");
  1585. string bankacstr = GetPostString("bankac");
  1586. bankacstr = bankacstr.Replace(" ", "");
  1587. bill_entity.bankac = bankacstr;
  1588. bill_entity.address = GetPostString("address");
  1589. bill_entity.phone = GetPostString("phone");
  1590. bill_entity.price = GetPostString("price");
  1591. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1592. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1593. {
  1594. billCount += 1;
  1595. }
  1596. string prebill = "ltb";
  1597. for (int idx = 1; idx <= billCount; idx++)
  1598. {
  1599. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1600. string billoid = prebill + idx + dtstr;
  1601. bill_entity.billOrderId += billoid;
  1602. if (idx < billCount)
  1603. {
  1604. bill_entity.billOrderId += ",";
  1605. }
  1606. }
  1607. bill_entity.productId = GetPostInt("ProductName");
  1608. bill_entity.num = GetPostInt("num");
  1609. bill_entity.unit = GetPostString("unit");
  1610. bill_entity.type = GetPostString("type");
  1611. bill_entity.sendType = GetPostString("SendType");
  1612. bill_entity.email = GetPostString("email");
  1613. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1614. bill_entity.shopName = GetPostString("ShopName");
  1615. bill_entity.applymemo = GetPostString("applyMemo");
  1616. bill_entity.createTime = DateTime.Now;
  1617. bill_entity.state = 0;
  1618. bill_entity.userId = CurrentUser.UserID;
  1619. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1620. bill_entity.Create();
  1621. }
  1622. catch (Exception ex)
  1623. {
  1624. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1625. returnErrorMsg("创建发票出错!");
  1626. return;
  1627. }
  1628. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1629. returnSuccessMsg("发票申请成功!");
  1630. return;
  1631. }
  1632. returnErrorMsg("找不到记录");
  1633. }
  1634. }
  1635. public void ins_erp_neworder()
  1636. {
  1637. if (UrlPostParmsCheck("receiver_name"))
  1638. {
  1639. CeErpTrade entity = new CeErpTrade();
  1640. string plat_form = GetPostString("platform");
  1641. string preStr = "N_";
  1642. if (plat_form == "拼多多")
  1643. {
  1644. preStr = "P_";
  1645. }
  1646. else if (plat_form == "阿里巴巴")
  1647. {
  1648. preStr = "A_";
  1649. }
  1650. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1651. entity.seller_nick = GetPostString("seller_nick");
  1652. entity.buyer_nick = GetPostString("buyer_nick");
  1653. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1654. entity.total_fee = entity.payment;
  1655. entity.pay_time = DateTime.Now;
  1656. entity.status = "NOT_SHIPPED";
  1657. entity.receiver_name = GetPostString("receiver_name");
  1658. entity.receiver_mobile = GetPostString("receiver_mobile");
  1659. entity.receiver_state = GetPostString("receiver_state");
  1660. entity.receiver_city = GetPostString("receiver_city");
  1661. entity.receiver_district = GetPostString("receiver_district");
  1662. entity.receiver_address = GetPostString("receiver_address");
  1663. if (entity.receiver_state == "" || entity.receiver_city == "")
  1664. {
  1665. returnErrorMsg("收件地址不能为空");
  1666. return;
  1667. }
  1668. int shopId = 0;
  1669. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1670. if (nShop != null)
  1671. {
  1672. shopId = nShop.ID;
  1673. }
  1674. if (shopId != 34 && entity.payment == 0)
  1675. {
  1676. returnErrorMsg("公司自用的单金额才能为0");
  1677. return;
  1678. }
  1679. entity.Create();
  1680. CeErpTradeCell entitycell = new CeErpTradeCell();
  1681. entitycell.ctid = entity.tid;
  1682. entitycell.tid = entity.tid;
  1683. entitycell.ShopId = shopId;
  1684. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1685. entitycell.OrderState = 0;
  1686. entitycell.pay_time = entity.pay_time;
  1687. entitycell.IsOffLineOrder = 1;
  1688. entitycell.Create();
  1689. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1690. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1691. return;
  1692. }
  1693. }
  1694. public void ins_erp_neworder2()
  1695. {
  1696. if (UrlPostParmsCheck("receiver_name"))
  1697. {
  1698. //string plat_form = GetPostString("platform");
  1699. string preStr = "X_";
  1700. string memo = GetPostString("memo");
  1701. string productId = GetPostString("productId");
  1702. string primg = GetPostString("proofimg");
  1703. string sellerNick = GetPostString("seller_nick");
  1704. string addFrom = GetPostString("addfrom");
  1705. if (addFrom == "1")
  1706. {
  1707. preStr = "N_";
  1708. }
  1709. int shopId = 0;
  1710. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1711. if (nShop != null)
  1712. {
  1713. shopId = nShop.ID;
  1714. }
  1715. else
  1716. {
  1717. returnErrorMsg("找不到对应店铺");
  1718. return;
  1719. }
  1720. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1721. {
  1722. returnErrorMsg("必须上传付款凭证");
  1723. return;
  1724. }
  1725. CeErpTrade entity = new CeErpTrade();
  1726. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1727. entity.seller_nick = sellerNick;
  1728. entity.buyer_nick = GetPostString("buyer_nick");
  1729. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1730. entity.total_fee = entity.payment;
  1731. entity.pay_time = DateTime.Now;
  1732. entity.status = "NOT_SHIPPED";
  1733. entity.receiver_name = GetPostString("receiver_name");
  1734. entity.receiver_mobile = GetPostString("receiver_mobile");
  1735. entity.receiver_state = GetPostString("receiver_state");
  1736. entity.receiver_city = GetPostString("receiver_city");
  1737. entity.receiver_district = GetPostString("receiver_district");
  1738. entity.receiver_address = GetPostString("receiver_address");
  1739. entity.seller_memo = memo;
  1740. entity.orderFrom = 20;
  1741. entity.orderType = 15;
  1742. if (entity.receiver_state == "" || entity.receiver_city == "")
  1743. {
  1744. returnErrorMsg("收件地址不能为空");
  1745. return;
  1746. }
  1747. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1748. {
  1749. returnErrorMsg("公司自用的单金额才能为0");
  1750. return;
  1751. }
  1752. entity.Create();
  1753. string toWhere = GetPostString("towhere");
  1754. CeErpTradeCell entitycell = new CeErpTradeCell();
  1755. entitycell.ctid = entity.tid;
  1756. //唯一标识
  1757. entitycell.OrderSn = entity.tid;
  1758. string orderSn = dataHelper.getSaleOrderSn();
  1759. if (orderSn != "")
  1760. {
  1761. entitycell.OrderSn = orderSn;
  1762. }
  1763. entitycell.tid = entity.tid;
  1764. //if (preStr == "X_")
  1765. //{
  1766. entitycell.IsOffLineOrder = 1;
  1767. //}
  1768. entitycell.CustomerUserId = CurrentUser.UserID;
  1769. entitycell.PayProofImg = primg;
  1770. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1771. entitycell.ProductId = Convert.ToInt32(productId);
  1772. entitycell.ShopId = shopId;
  1773. entitycell.UpdateTime = DateTime.Now;
  1774. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1775. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1776. {
  1777. entitycell.IsXianHuo = 1;
  1778. }
  1779. entitycell.pay_time = entity.pay_time;
  1780. if (toWhere == "1")
  1781. {
  1782. entitycell.OrderState = 2;
  1783. }
  1784. else
  1785. {
  1786. entitycell.OrderState = 6;
  1787. entitycell.FinishPlaceTime = entitycell.pay_time;
  1788. }
  1789. if (shopId == 94)
  1790. {
  1791. entitycell.OrderState = 4;
  1792. entitycell.WaitDesignTime = entitycell.pay_time;
  1793. entitycell.StartDesignTime = entitycell.pay_time;
  1794. entitycell.DesignUserId = 218;
  1795. }
  1796. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1797. {
  1798. entitycell.OrderState = -1;//修改12-5
  1799. CeWithdraw ceWithdraw = new CeWithdraw();
  1800. ceWithdraw.tid = entity.tid;
  1801. ceWithdraw.providerid = "-1";
  1802. ceWithdraw.status = -1;
  1803. ceWithdraw.creationtime = DateTime.Now;
  1804. ceWithdraw.userid = 1337;
  1805. ceWithdraw.Create();
  1806. }
  1807. entitycell.Create();
  1808. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1809. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1810. {
  1811. addPlaceRegist(entitycell, CurrentUser.UserID);
  1812. }
  1813. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1814. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1815. return;
  1816. }
  1817. }
  1818. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1819. {
  1820. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1821. entity.PlactTime = tradecell.pay_time;
  1822. entity.AddUserId = userid;
  1823. entity.FileName = tradecell.seller_memo;
  1824. entity.Supplier = 24;
  1825. entity.CreateTime = DateTime.Now;
  1826. entity.Did = tradecell.ctid;
  1827. entity.tid = tradecell.tid;
  1828. entity.splitTag = tradecell.SplitTag;
  1829. entity.CurState = "未完成";
  1830. entity.Create();
  1831. }
  1832. public void get_erp_offlinelist()
  1833. {
  1834. DataStruct dStruct = GetPostStruct();
  1835. List<string> lw = new List<string>();
  1836. string tid = GetPostString("ctid");
  1837. string date1 = GetPostString("date1");
  1838. string date2 = GetPostString("date2");
  1839. if (tid.Length > 0 || date1.Length > 0)
  1840. {
  1841. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1842. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1843. if (dw.Length > 0) lw.Add(dw);
  1844. }
  1845. else
  1846. {
  1847. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1848. }
  1849. string shopname = GetPostString("shopname");
  1850. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1851. string buyernick = GetPostString("buyer_nick");
  1852. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1853. string customer = GetPostString("customer");
  1854. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1855. string design = GetPostString("design");
  1856. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1857. string orderState = GetPostString("orderState");
  1858. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1859. string address = GetPostString("address");
  1860. 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));
  1861. string sellermemo = GetPostString("seller_memo");
  1862. if (sellermemo.Length > 0)
  1863. {
  1864. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1865. }
  1866. string price1 = GetPostString("price1");
  1867. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1868. string price2 = GetPostString("price2");
  1869. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1870. //if (PKey != "admin")
  1871. //{
  1872. // string usershop = CurrentUser.User.pemShop;
  1873. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1874. //}
  1875. //if (ex_psize > 0)
  1876. //{
  1877. dStruct.Order = "pay_time desc";
  1878. //}
  1879. //else
  1880. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1881. lw.Add(string.Format("IsOffLineOrder=1"));
  1882. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1883. DataTable dt = null;
  1884. dt = WebCache.GetData("view_erptradecell", dStruct);
  1885. writeGridDataTableJson(dStruct.TotalCount, dt);
  1886. }
  1887. public void get_erp_returncashrecord()
  1888. {
  1889. DataStruct dStruct = GetPostStruct();
  1890. List<string> lw = new List<string>();
  1891. string tid = GetPostString("ctid");
  1892. if (tid.Length > 0)
  1893. {
  1894. lw.Add(string.Format("tid like '%{0}%'", tid));
  1895. dStruct.Order = "id desc";
  1896. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1897. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1898. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1899. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1900. return;
  1901. }
  1902. returnErrorMsg("id数据错误!");
  1903. }
  1904. public void ins_erp_returncashrecord()
  1905. {
  1906. if (UrlPostParmsCheck("tid"))
  1907. {
  1908. string tid = GetPostString("tid");
  1909. string retype = GetPostString("type");
  1910. StringBuilder sql = new StringBuilder();
  1911. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1912. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1913. if (dt.Rows.Count > 0)
  1914. {
  1915. returnErrorMsg("相同返现类型记录已存在");
  1916. return;
  1917. }
  1918. CeErpReturnCash entity = new CeErpReturnCash();
  1919. entity.tid = tid;
  1920. entity.seller_nick = GetPostString("seller_nick");
  1921. string pment = GetPostString("payment");
  1922. if (pment.Length > 0)
  1923. {
  1924. entity.payment = Convert.ToDouble(pment);
  1925. }
  1926. entity.buyer_nick = GetPostString("buyer_nick");
  1927. entity.cashstate = 0;
  1928. entity.rtype = retype;
  1929. string rPrice = GetPostString("returnprice");
  1930. if (rPrice.Length > 0)
  1931. {
  1932. entity.returnprice = Convert.ToDouble(rPrice);
  1933. }
  1934. entity.created = DateTime.Now;
  1935. entity.con = GetPostString("con");
  1936. entity.img = GetPostString("img");
  1937. entity.applyuserid = CurrentUser.UserID;
  1938. entity.Create();
  1939. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1940. returnSuccessMsg("操作成功!");
  1941. return;
  1942. }
  1943. }
  1944. public void set_erp_predelivery()
  1945. {
  1946. if (UrlPostParmsCheck("ctid"))
  1947. {
  1948. string eid = GetPostString("ctid");
  1949. CeErpTradeCell entity = null;
  1950. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1951. if (entity != null)
  1952. {
  1953. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1954. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1955. //{
  1956. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1957. // return;
  1958. //}
  1959. entity.IsPreDelivery = 1;
  1960. entity.Update();
  1961. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1962. returnSuccessMsg("预发货成功!");
  1963. return;
  1964. //string shop = GetPostString("seller_nick");
  1965. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1966. //string comName = GetPostString("comName");
  1967. //string comCode = GetPostString("comCode");
  1968. //string outSid = GetPostString("outSid");//运单号
  1969. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1970. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1971. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1972. //string apires = "";
  1973. //if (deliveryType == "虚拟发货")
  1974. //{
  1975. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1976. //}
  1977. //else
  1978. //{
  1979. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1980. //}
  1981. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1982. ////{
  1983. //if (apires.IndexOf("发货成功") != -1)
  1984. //{
  1985. // if (deliveryType != "虚拟发货")
  1986. // {
  1987. // //还要插入快递信息到 快递信息表
  1988. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1989. // exinfo.tid = eid;
  1990. // exinfo.out_sid = outSid;
  1991. // exinfo.company_code = comCode;
  1992. // exinfo.company_name = comName;
  1993. // exinfo.delivery_memo = deliveryMemo;
  1994. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1995. // exinfo.deliveryType = deliveryType;
  1996. // exinfo.Create();
  1997. // }
  1998. // returnSuccessMsg("发货成功!");
  1999. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2000. //}
  2001. //else
  2002. //{
  2003. // returnErrorMsg("淘宝发货失败!!");
  2004. //}
  2005. //return;
  2006. }
  2007. returnErrorMsg("找不到订单记录");
  2008. }
  2009. }
  2010. public void get_erp_unusuallist()
  2011. {
  2012. DataStruct dStruct = GetPostStruct();
  2013. List<string> lw = new List<string>();
  2014. string tid = GetPostString("ctid");
  2015. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2016. string shopname = GetPostString("shopname");
  2017. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2018. string buyernick = GetPostString("buyer_nick");
  2019. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2020. string ResponsibleMan = GetPostString("responsible");
  2021. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2022. string date1 = GetPostString("date1");
  2023. string date2 = GetPostString("date2");
  2024. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2025. if (dw.Length > 0) lw.Add(dw);
  2026. string price1 = GetPostString("price1");
  2027. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2028. string price2 = GetPostString("price2");
  2029. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2030. string orderState = GetPostString("orderState");
  2031. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2032. string sellermemo = GetPostString("seller_memo");
  2033. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2034. lw.Add(string.Format("UnusualTag > 0"));
  2035. lw.Add(string.Format("IsRefund<={0}", 1));
  2036. dStruct.Order = "pay_time desc";
  2037. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2038. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2039. writeGridDataTableJson(dStruct.TotalCount, dt);
  2040. }
  2041. public void set_erp_unusualtonomal()
  2042. {
  2043. if (UrlPostParmsCheck("ctid"))
  2044. {
  2045. string eid = GetPostString("ctid");
  2046. CeErpTradeCell entity = null;
  2047. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2048. if (entity != null)
  2049. {
  2050. entity.UnusualTag = -1;
  2051. entity.Update();
  2052. returnSuccessMsg("忽略成功!");
  2053. return;
  2054. }
  2055. returnErrorMsg("找不到记录");
  2056. }
  2057. }
  2058. public void ins_erp_unusualreason()
  2059. {
  2060. if (UrlPostParmsCheck("ctid"))
  2061. {
  2062. string eid = GetPostString("ctid");
  2063. CeErpTradeCell entity = null;
  2064. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2065. if (entity != null)
  2066. {
  2067. entity.MemoOpt = 4;
  2068. entity.UnusualCon = GetPostString("con");
  2069. entity.Update();
  2070. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2071. if (trade != null)
  2072. {
  2073. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2074. }
  2075. //查货是否超时
  2076. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2077. if (ceErpTradeCellExtend == null)
  2078. {
  2079. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2080. ceErpTradeCellExtend.ctid = entity.ctid;
  2081. }
  2082. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2083. {
  2084. ceErpTradeCellExtend.CheckOut += 1;
  2085. }
  2086. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2087. if (ceErpTradeCellExtend.ID > 0)
  2088. {
  2089. ceErpTradeCellExtend.Update();
  2090. }
  2091. else
  2092. {
  2093. ceErpTradeCellExtend.Create();
  2094. }
  2095. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2096. returnSuccessMsg("操作成功!");
  2097. return;
  2098. }
  2099. returnErrorMsg("找不到记录");
  2100. }
  2101. }
  2102. public void upd_erp_sampleorder()
  2103. {
  2104. if (UrlPostParmsCheck("ctid"))
  2105. {
  2106. string eid = GetPostString("ctid");
  2107. string[] eArr = eid.Split(',');
  2108. if (eArr.Length > 1)
  2109. {
  2110. List<string> eLst = new List<string>();
  2111. for (int i = 0; i < eArr.Length; i++)
  2112. {
  2113. eLst.Add("'" + eArr[i] + "'");
  2114. }
  2115. eid = string.Join(",", eLst.ToArray());
  2116. }
  2117. else
  2118. {
  2119. eid = "'" + eid + "'";
  2120. }
  2121. StringBuilder sql = new StringBuilder();
  2122. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2123. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2124. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2125. if (dt.Rows.Count > 0)
  2126. {
  2127. string errmsg = "";
  2128. foreach (DataRow dr in dt.Rows)
  2129. {
  2130. StringBuilder sqlsb = new StringBuilder();
  2131. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2132. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2133. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2134. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2135. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2136. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2137. {
  2138. continue;
  2139. }
  2140. else
  2141. {
  2142. string emsg = commonHelper.KeepChinese(apires);
  2143. errmsg += emsg;
  2144. }
  2145. }
  2146. if (errmsg.Length > 0)
  2147. {
  2148. returnErrorMsg(errmsg);
  2149. return;
  2150. }
  2151. returnSuccessMsg("操作成功");
  2152. return;
  2153. }
  2154. returnErrorMsg("找不到记录");
  2155. }
  2156. }
  2157. public void upd_erp_transcustomer()
  2158. {
  2159. if (UrlPostParmsCheck("ctid"))
  2160. {
  2161. string eid = GetPostString("ctid");
  2162. int userid = GetPostInt("CustomerUserId");
  2163. CeErpTradeCell entity = null;
  2164. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2165. if (entity != null)
  2166. {
  2167. //string[] mlist = entity.seller_memo.Split('-');
  2168. //string sql = "select * from view_erpuser where id=" + userid;
  2169. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2170. //if (dt != null && dt.Rows.Count > 0)
  2171. //{
  2172. // string nmemo = "";
  2173. // for(int i = 0; i < mlist.Length - 1; i++)
  2174. // {
  2175. // nmemo += mlist[i];
  2176. // nmemo += "-";
  2177. // }
  2178. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2179. // entity.seller_memo = nmemo;
  2180. //}
  2181. entity.CustomerUserId = userid;
  2182. entity.Update();
  2183. returnSuccessMsg("操作成功!");
  2184. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2185. return;
  2186. }
  2187. returnErrorMsg("找不到记录");
  2188. }
  2189. }
  2190. public void upd_erp_transdesigner()
  2191. {
  2192. if (UrlPostParmsCheck("ctid"))
  2193. {
  2194. string eids = GetPostString("ctid");
  2195. string[] ctidList = eids.Split(',');
  2196. int userid = GetPostInt("DesignUserId");
  2197. foreach (string ctid in ctidList)
  2198. {
  2199. CeErpTradeCell entity = null;
  2200. CeErpDesignerBill entitys = null;
  2201. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2202. entitys = CeErpDesignerBill.GetByTid(ctid);
  2203. if (entity != null)
  2204. {
  2205. if (entity.OrderState > 4)
  2206. {
  2207. continue;
  2208. }
  2209. //存在退款不能流转
  2210. if (entity.IsRefund > 0)
  2211. {
  2212. continue;
  2213. }
  2214. entity.DesignUserId = userid;
  2215. entity.WaitDesignTime = DateTime.Now;
  2216. entity.Update();
  2217. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2218. }
  2219. }
  2220. returnSuccessMsg("操作成功!");
  2221. }
  2222. }
  2223. public void upd_erp_distributedesigner()
  2224. {
  2225. if (UrlPostParmsCheck("ctid"))
  2226. {
  2227. string eid = GetPostString("ctid");
  2228. int userid = GetPostInt("DesignUserId");
  2229. string[] idlist = eid.Split(',');
  2230. if (idlist.Length <= 0)
  2231. {
  2232. returnErrorMsg("订单不能为空");
  2233. return;
  2234. }
  2235. foreach (string ctid in idlist)
  2236. {
  2237. CeErpTradeCell entity = null;
  2238. CeErpDesignerBill entitys = null;
  2239. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2240. else continue;
  2241. if (entity != null)
  2242. {
  2243. if (userid == 2125 || userid == 3542)
  2244. { }
  2245. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2246. {
  2247. returnErrorMsg("金额错误的订单无法指派");
  2248. return;
  2249. }
  2250. if (entity.OrderState >= 5)
  2251. {
  2252. returnErrorMsg("已经设计完成无法指派");
  2253. return;
  2254. }
  2255. if (entity.OrderState == -1)
  2256. {
  2257. returnErrorMsg("审核中的订单无法指派");
  2258. return;
  2259. }
  2260. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2261. {
  2262. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2263. return;
  2264. }
  2265. //157赖橙帆 159林晨 73 静之颖
  2266. 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)
  2267. {
  2268. returnErrorMsg("指派设计共创无法再次指派!");
  2269. return;
  2270. }
  2271. entity.OrderState = 3;
  2272. if (entity.SupplierId == 0)
  2273. {
  2274. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2275. entity.SupplierId = suid;
  2276. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2277. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2278. }
  2279. if (userid == 2125 && entity.seller_memo != "")
  2280. {
  2281. apiDesign.API_GetPrintData_CreateOrder(entity);
  2282. }
  2283. if (userid == 3542 && entity.seller_memo != "")
  2284. {
  2285. string userPost = CurrentUser.UserPost.Post.Code;
  2286. if (CurrentUser.UserID == 73)
  2287. {
  2288. userPost = "SysAdmin";
  2289. }
  2290. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2291. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2292. if (response.msg != "设计共创:成功")
  2293. {
  2294. returnErrorMsg(response.msg);
  2295. return;
  2296. }
  2297. entity.DispatchSort = 2;
  2298. }
  2299. else
  2300. {
  2301. if (entity.DispatchSort == 2)
  2302. {
  2303. ApiVo apiVo = new ApiVo();
  2304. apiVo.actionName = "closeDesign";
  2305. apiVo.orderNumber = entity.ctid;
  2306. designHelper.API_WorkCore(apiVo);//closeDesign
  2307. }
  2308. entity.DispatchSort = 0;
  2309. }
  2310. entity.DesignUserId = userid;
  2311. entity.WaitDesignTime = DateTime.Now;
  2312. entity.UpdateTime = DateTime.Now;
  2313. entity.Update();
  2314. string name = commonHelper.getUserNameById(userid);
  2315. commonHelper.UpdateRelationOrder(entity.ctid);
  2316. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2317. }
  2318. }
  2319. returnSuccessMsg("操作成功!");
  2320. return;
  2321. }
  2322. }
  2323. public string getTidByCtid(string ctid)
  2324. {
  2325. string tid = "";
  2326. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2327. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2328. if (dataTable != null && dataTable.Rows.Count > 0)
  2329. {
  2330. tid = dataTable.Rows[0]["tid"].ToString();
  2331. }
  2332. return tid;
  2333. }
  2334. public List<string> getTidByCtidMore(string ctid)
  2335. {
  2336. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or tid = '{0}' or orderSn = '{0}' or ( ParentSplitNo = '{0}' and IsSample =2) or (ptid = '{0}' and IsSample =2 ))", ctid);
  2337. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2338. List<string> list = new List<string>();
  2339. if (dataTable != null && dataTable.Rows.Count > 0)
  2340. {
  2341. foreach (DataRow item in dataTable.Rows)
  2342. {
  2343. list.Add("'" + item["tid"].ToString() + "'");
  2344. }
  2345. }
  2346. return list;
  2347. }
  2348. public List<string> getTidByCtidLike(string ctid)
  2349. {
  2350. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2351. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2352. List<string> list = new List<string>();
  2353. if (dataTable != null && dataTable.Rows.Count > 0)
  2354. {
  2355. foreach (DataRow item in dataTable.Rows)
  2356. {
  2357. list.Add("'" + item["tid"].ToString() + "'");
  2358. }
  2359. }
  2360. return list;
  2361. }
  2362. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2363. {
  2364. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2365. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2366. List<string> list = new List<string>();
  2367. if (dataTable != null && dataTable.Rows.Count > 0)
  2368. {
  2369. foreach (DataRow item in dataTable.Rows)
  2370. {
  2371. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2372. {
  2373. continue;
  2374. }
  2375. list.Add("'" + item["receiverId"].ToString() + "'");
  2376. }
  2377. }
  2378. return list;
  2379. }
  2380. public void get_erp_myorderlist()
  2381. {
  2382. DataStruct dStruct = GetPostStruct();
  2383. List<string> lw = new List<string>();
  2384. string tid = GetPostString("ctid");
  2385. if (tid.Length > 0)
  2386. {
  2387. string select_tid = getTidByCtid(tid);
  2388. lw.Add(string.Format("tid='{0}'", select_tid));
  2389. }
  2390. else
  2391. {
  2392. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2393. }
  2394. //12-1 修改
  2395. string urgent = GetPostString("urgent");
  2396. string back = GetPostString("back");
  2397. string offlineSearch = GetPostString("offlineSearch");
  2398. if (!string.IsNullOrWhiteSpace(urgent))
  2399. {
  2400. if (urgent.Equals("true"))
  2401. {
  2402. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2403. }
  2404. }
  2405. if (!string.IsNullOrWhiteSpace(back))
  2406. {
  2407. if (back.Equals("true"))
  2408. {
  2409. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2410. }
  2411. }
  2412. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2413. {
  2414. if (offlineSearch.Equals("true"))
  2415. {
  2416. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2417. }
  2418. }
  2419. //end
  2420. string shopname = GetPostString("shopname");
  2421. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2422. string buyernick = GetPostString("buyer_nick");
  2423. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2424. string design = GetPostString("design");
  2425. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2426. string orderState = GetPostString("orderState");
  2427. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2428. string sellermemo = GetPostString("seller_memo");
  2429. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2430. string date1 = GetPostString("date1");
  2431. string date2 = GetPostString("date2");
  2432. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2433. if (dw.Length > 0) lw.Add(dw);
  2434. string price1 = GetPostString("price1");
  2435. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2436. string price2 = GetPostString("price2");
  2437. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2438. string urgency = GetPostString("urgency");
  2439. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2440. string after = GetPostString("after");
  2441. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2442. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2443. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2444. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2445. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2446. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2447. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2448. if (dt != null && dt.Rows.Count > 0)
  2449. {
  2450. foreach (DataRow dr in dt.Rows)
  2451. {
  2452. try
  2453. {
  2454. // 对象操作
  2455. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2456. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2457. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2458. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2459. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2460. if (dStruct.PageSize != 100000)
  2461. {
  2462. if (dr["DispatchSort"].ToString() == "2")
  2463. {
  2464. dr["gongchuang"] = 200;
  2465. }
  2466. else if ("外协".Equals(dr["ToType"].ToString()))
  2467. {
  2468. dr["gongchuang"] = 200;
  2469. }
  2470. else if ("内部".Equals(dr["ToType"].ToString()))
  2471. {
  2472. dr["gongchuang"] = -1;
  2473. }
  2474. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2475. {
  2476. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2477. dr["gongchuang"] = response.code;
  2478. }
  2479. }
  2480. }
  2481. catch (NullReferenceException ex)
  2482. {
  2483. }
  2484. }
  2485. }
  2486. writeGridDataTableJson(dStruct.TotalCount, dt);
  2487. }
  2488. public void get_erp_myreturnorderlist()
  2489. {
  2490. DataStruct dStruct = GetPostStruct();
  2491. List<string> lw = new List<string>();
  2492. string tid = GetPostString("ctid");
  2493. if (tid.Length > 0)
  2494. {
  2495. string select_tid = getTidByCtid(tid);
  2496. lw.Add(string.Format("tid='{0}'", select_tid));
  2497. }
  2498. else
  2499. {
  2500. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2501. }
  2502. string shopname = GetPostString("shopname");
  2503. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2504. string buyernick = GetPostString("buyer_nick");
  2505. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2506. string design = GetPostString("design");
  2507. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2508. string orderState = GetPostString("orderState");
  2509. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2510. string sellermemo = GetPostString("seller_memo");
  2511. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2512. string date1 = GetPostString("date1");
  2513. string date2 = GetPostString("date2");
  2514. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2515. if (dw.Length > 0) lw.Add(dw);
  2516. string price1 = GetPostString("price1");
  2517. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2518. string price2 = GetPostString("price2");
  2519. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2520. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2521. {
  2522. lw.Add(string.Format("CusOrgID = 94"));
  2523. }
  2524. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2525. {
  2526. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2527. }
  2528. else
  2529. {
  2530. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2531. }
  2532. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2533. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2534. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2535. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2536. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2537. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2538. if (dt != null && dt.Rows.Count > 0)
  2539. {
  2540. foreach (DataRow dr in dt.Rows)
  2541. {
  2542. try
  2543. {
  2544. // 对象操作
  2545. if (dStruct.PageSize != 100000)
  2546. {
  2547. if (dr["DispatchSort"].ToString() == "2")
  2548. {
  2549. dr["gongchuang"] = 200;
  2550. }
  2551. else if ("外协".Equals(dr["ToType"].ToString()))
  2552. {
  2553. dr["gongchuang"] = 200;
  2554. }
  2555. else if ("内部".Equals(dr["ToType"].ToString()))
  2556. {
  2557. dr["gongchuang"] = -1;
  2558. }
  2559. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2560. {
  2561. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2562. dr["gongchuang"] = response.code;
  2563. }
  2564. }
  2565. }
  2566. catch (NullReferenceException ex)
  2567. {
  2568. // 处理空引用异常
  2569. }
  2570. }
  2571. }
  2572. writeGridDataTableJson(dStruct.TotalCount, dt);
  2573. }
  2574. public void get_erp_myorderlist_pregather()
  2575. {
  2576. string date1 = GetPostString("date1");
  2577. string date2 = GetPostString("date2");
  2578. int userId = CurrentUser.UserID; //客服id
  2579. string orderWhere = "";
  2580. List<string> lw = new List<string>();
  2581. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2582. if (dw.Length > 0) lw.Add(dw);
  2583. lw.Add(string.Format("CustomerUserId={0}", userId));
  2584. lw.Add(string.Format("OrderState<9"));
  2585. orderWhere = string.Join(" and ", lw.ToArray());
  2586. string orderWhere2 = "";
  2587. List<string> lw2 = new List<string>();
  2588. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2589. if (dw2.Length > 0) lw2.Add(dw2);
  2590. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2591. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2592. string sql = string.Format("select *" +
  2593. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2594. "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 " +
  2595. "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 " +
  2596. "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");
  2597. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2598. //writeGridDataTableJson(dt.Rows.Count, dt);
  2599. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2600. }
  2601. public void upd_erp_publishorder()
  2602. {
  2603. if (UrlPostParmsCheck("ctid"))
  2604. {
  2605. string eid = GetPostString("ctid");
  2606. CeErpTradeCell entity = null;
  2607. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2608. if (entity != null)
  2609. {
  2610. entity.OrderState = 0; //发布后,变为待抢单
  2611. entity.Update();
  2612. commonHelper.UpdateRelationOrder(entity.ctid);
  2613. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2614. returnSuccessMsg("发布成功!");
  2615. return;
  2616. }
  2617. returnErrorMsg("找不到记录");
  2618. }
  2619. }
  2620. public void get_erp_my_tiporder()
  2621. {
  2622. StringBuilder sql = new StringBuilder();
  2623. int userId = 0;
  2624. if (CurrentUser != null) userId = CurrentUser.UserID;
  2625. string posCode = CurrentUser.UserPost.Post.Code;
  2626. string isTipedAfterSaleVerify = GetPostString("af");
  2627. DataTable dt = new DataTable();
  2628. if (posCode != "Supplier")
  2629. {
  2630. if (posCode == "CustomerService" || posCode == "Director")
  2631. {
  2632. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2633. }
  2634. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2635. {
  2636. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2637. }
  2638. else
  2639. {
  2640. string teamIds = CurrentUser.User.TeamIds;
  2641. if (teamIds == "")
  2642. {
  2643. teamIds = "0";
  2644. }
  2645. 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);
  2646. }
  2647. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2648. }
  2649. if (dt.Rows.Count <= 0)
  2650. {
  2651. string key = "aftersale_order_" + userId;
  2652. if (RedisHelper.HasKey(key))
  2653. {
  2654. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2655. dt.Columns.Add("ctid", typeof(string));
  2656. dt.Columns.Add("IsReadTag", typeof(int));
  2657. foreach (var i in list)
  2658. {
  2659. DataRow data = dt.NewRow();
  2660. data["ctid"] = i;
  2661. data["IsReadTag"] = 4;
  2662. dt.Rows.Add(data);
  2663. }
  2664. RedisHelper.StringDelete(key);
  2665. }
  2666. }
  2667. if (dt.Rows.Count <= 0)
  2668. {
  2669. sql = new StringBuilder();
  2670. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2671. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2672. }
  2673. if (posCode == "Supplier")
  2674. {
  2675. string ids = CurrentUser.User.pemVend;
  2676. if (ids != null && ids.Length > 0)
  2677. {
  2678. string[] ids_list = ids.Split(',');
  2679. foreach (var item in ids_list)
  2680. {
  2681. string key = "return_order_" + item;
  2682. if (RedisHelper.HasKey(key))
  2683. {
  2684. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2685. dt.Columns.Add("ctid", typeof(string));
  2686. dt.Columns.Add("IsReadTag", typeof(int));
  2687. foreach (var i in list)
  2688. {
  2689. DataRow data = dt.NewRow();
  2690. data["ctid"] = i;
  2691. data["IsReadTag"] = 1;
  2692. dt.Rows.Add(data);
  2693. }
  2694. RedisHelper.StringDelete(key);
  2695. }
  2696. }
  2697. }
  2698. if (dt.Rows.Count <= 0)
  2699. {
  2700. sql = new StringBuilder();
  2701. 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);
  2702. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2703. }
  2704. }
  2705. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2706. }
  2707. public void reset_erp_tiporder()
  2708. {
  2709. string ids = GetPostString("ids");
  2710. string[] ctidList = ids.Split(',');
  2711. foreach (string ctid in ctidList)
  2712. {
  2713. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2714. if (enty != null)
  2715. {
  2716. enty.IsReadTag = 0;
  2717. enty.Update();
  2718. }
  2719. }
  2720. returnSuccessMsg("成功!");
  2721. return;
  2722. }
  2723. public void get_erp_designlist()
  2724. {
  2725. DataStruct dStruct = GetPostStruct();
  2726. List<string> lw = new List<string>();
  2727. string tid = GetPostString("ctid");
  2728. if (tid.Length > 0)
  2729. {
  2730. string select_tid = getTidByCtid(tid);
  2731. lw.Add(string.Format("tid='{0}'", select_tid));
  2732. }
  2733. string shopname = GetPostString("shopname");
  2734. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2735. string buyernick = GetPostString("buyer_nick");
  2736. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2737. string customer = GetPostString("customer");
  2738. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2739. string design = GetPostString("design");
  2740. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2741. string orderState = GetPostString("orderState");
  2742. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2743. lw.Add(string.Format("OrderState<6"));
  2744. string address = GetPostString("address");
  2745. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2746. string sellermemo = GetPostString("seller_memo");
  2747. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2748. string date1 = GetPostString("date1");
  2749. string date2 = GetPostString("date2");
  2750. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2751. if (dw.Length > 0) lw.Add(dw);
  2752. string apdate1 = GetPostString("apdate1");
  2753. string apdate2 = GetPostString("apdate2");
  2754. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2755. if (dwap.Length > 0) lw.Add(dwap);
  2756. string price1 = GetPostString("price1");
  2757. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2758. string price2 = GetPostString("price2");
  2759. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2760. string designTime = GetPostString("designtime");
  2761. if (designTime.Length > 0)
  2762. {
  2763. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2764. }
  2765. string usershop = CurrentUser.User.pemShop;
  2766. if (usershop.Length > 0)
  2767. {
  2768. lw.Add(string.Format("shopId in ({0})", usershop));
  2769. }
  2770. int myOrgid = CurrentUser.UserPost.OrgID;
  2771. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2772. if (myOrgCode.IndexOf("Designer") != -1)
  2773. {
  2774. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2775. {
  2776. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2777. }
  2778. else
  2779. {
  2780. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2781. }
  2782. }
  2783. else
  2784. {
  2785. string orgId = GetPostString("designerhd");
  2786. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2787. }
  2788. if (tid.Length > 0 || buyernick.Length > 0)
  2789. {
  2790. lw.Add(string.Format("OrderState >= 3"));
  2791. }
  2792. else
  2793. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2794. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2795. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2796. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2797. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2798. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2799. if (dt != null && dt.Rows.Count > 0)
  2800. {
  2801. foreach (DataRow dr in dt.Rows)
  2802. {
  2803. try
  2804. {
  2805. // 对象操作
  2806. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2807. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2808. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2809. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2810. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2811. if (dStruct.PageSize != 100000)
  2812. {
  2813. if (dr["DispatchSort"].ToString() == "2")
  2814. {
  2815. dr["gongchuang"] = 200;
  2816. }
  2817. else if ("外协".Equals(dr["ToType"].ToString()))
  2818. {
  2819. dr["gongchuang"] = 200;
  2820. }
  2821. else if ("内部".Equals(dr["ToType"].ToString()))
  2822. {
  2823. dr["gongchuang"] = -1;
  2824. }
  2825. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2826. {
  2827. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2828. dr["gongchuang"] = response.code;
  2829. }
  2830. }
  2831. }
  2832. catch (NullReferenceException ex)
  2833. {
  2834. }
  2835. }
  2836. }
  2837. writeGridDataTableJson(dStruct.TotalCount, dt);
  2838. }
  2839. public void get_erp_mydesignlist()
  2840. {
  2841. DataStruct dStruct = GetPostStruct();
  2842. List<string> lw = new List<string>();
  2843. string tid = GetPostString("ctid");
  2844. if (tid.Length > 0)
  2845. {
  2846. string select_tid = getTidByCtid(tid);
  2847. lw.Add(string.Format("tid='{0}'", select_tid));
  2848. }
  2849. string shopname = GetPostString("shopname");
  2850. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2851. string buyernick = GetPostString("buyer_nick");
  2852. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2853. string customer = GetPostString("customer");
  2854. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2855. string orderState = GetPostString("orderState");
  2856. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2857. //lw.Add(string.Format("OrderState<6"));
  2858. string date1 = GetPostString("date1");
  2859. string date2 = GetPostString("date2");
  2860. string dw = GetDateWhere("pay_time", date1, date2);
  2861. if (dw.Length > 0) lw.Add(dw);
  2862. string apdate1 = GetPostString("apdate1");
  2863. string apdate2 = GetPostString("apdate2");
  2864. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2865. if (dwap.Length > 0) lw.Add(dwap);
  2866. string price1 = GetPostString("price1");
  2867. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2868. string price2 = GetPostString("price2");
  2869. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2870. string olddownload = GetPostString("olddown");
  2871. if (olddownload == "1")
  2872. {
  2873. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2874. }
  2875. else if (olddownload == "2")
  2876. {
  2877. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2878. }
  2879. string sellermemo = GetPostString("seller_memo");
  2880. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2881. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2882. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2883. {
  2884. if (CurrentUser.User.TeamIds.Length > 0)
  2885. {
  2886. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2887. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2888. else
  2889. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2890. }
  2891. else
  2892. {
  2893. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2894. }
  2895. }
  2896. if (tid.Length <= 0)
  2897. {
  2898. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2899. }
  2900. lw.Add(string.Format("IsReturn!=3"));
  2901. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2902. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2903. string teamids = CurrentUser.User.TeamIds.ToString();
  2904. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2905. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2906. if (dt != null && dt.Rows.Count > 0)
  2907. {
  2908. foreach (DataRow dr in dt.Rows)
  2909. {
  2910. try
  2911. {
  2912. // 对象操作
  2913. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2914. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2915. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2916. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2917. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2918. if (dStruct.PageSize != 100000)
  2919. {
  2920. if (dr["DispatchSort"].ToString() == "2")
  2921. {
  2922. dr["gongchuang"] = 200;
  2923. }
  2924. else if ("外协".Equals(dr["ToType"].ToString()))
  2925. {
  2926. dr["gongchuang"] = 200;
  2927. }
  2928. else if ("内部".Equals(dr["ToType"].ToString()))
  2929. {
  2930. dr["gongchuang"] = -1;
  2931. }
  2932. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2933. {
  2934. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2935. dr["gongchuang"] = response.code;
  2936. }
  2937. }
  2938. }
  2939. catch (NullReferenceException ex)
  2940. {
  2941. }
  2942. }
  2943. }
  2944. writeGridDataTableJson(dStruct.TotalCount, dt);
  2945. }
  2946. public void set_erp_startdesign()
  2947. {
  2948. if (UrlPostParmsCheck("ctid"))
  2949. {
  2950. string eid = GetPostString("ctid");
  2951. CeErpTradeCell entity = null;
  2952. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2953. if (entity != null)
  2954. {
  2955. if (entity.OrderState != 3)
  2956. {
  2957. returnErrorMsg("请刷新,订单已经设计了");
  2958. return;
  2959. }
  2960. entity.StartDesignTime = DateTime.Now;
  2961. entity.OrderState = 4;
  2962. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2963. {
  2964. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2965. entity.SupplierId = suid;
  2966. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2967. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2968. }
  2969. entity.UpdateTime = DateTime.Now;
  2970. //entity.MakeSupplier = suname;
  2971. entity.Update();
  2972. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2973. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2974. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2975. commonHelper.getCytPrice(entity);
  2976. returnSuccessMsg("操作成功!");
  2977. return;
  2978. }
  2979. returnErrorMsg("找不到记录");
  2980. }
  2981. }
  2982. public void ins_erp_designselfmemo()
  2983. {
  2984. if (UrlPostParmsCheck("ctid"))
  2985. {
  2986. string eid = GetPostString("ctid");
  2987. string con = GetPostString("con");
  2988. CeErpTradeCell entity = null;
  2989. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2990. if (entity != null)
  2991. {
  2992. entity.DesignSelfMemo = con;
  2993. entity.Update();
  2994. returnSuccessMsg("操作成功!");
  2995. return;
  2996. }
  2997. returnErrorMsg("找不到记录");
  2998. }
  2999. }
  3000. public void ins_erp_designprice()
  3001. {
  3002. if (UrlPostParmsCheck("ctid"))
  3003. {
  3004. string eid = GetPostString("ctid");
  3005. int uid = CurrentUser.UserID;
  3006. string userName = CurrentUser.UserName;
  3007. CeErpTradeCell entity = null;
  3008. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3009. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3010. if (entitys == null)
  3011. {
  3012. entitys = new CeErpDesignerBill();
  3013. }
  3014. if (entity != null)
  3015. {
  3016. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3017. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3018. entity.StartDesignTime = DateTime.Now;
  3019. entity.OrderState = 4;
  3020. string suname = "";
  3021. if (entity.SupplierId == 0)
  3022. {
  3023. int sid = commonHelper.autoDistributeToSupplier(entity);
  3024. entity.SupplierId = sid;
  3025. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3026. }
  3027. entity.Update();
  3028. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3029. if (ceErpUserPost != null)
  3030. {
  3031. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3032. if (ceErpPost != null)
  3033. {
  3034. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3035. {
  3036. entitys.tid = entity.ctid;
  3037. entitys.oid = entity.tid;
  3038. entitys.uid = uid;
  3039. entitys.userName = userName;
  3040. entitys.designerType = 1;
  3041. entitys.designerTypeText = "内部设计师";
  3042. entitys.price = Convert.ToDouble(GetPostString("price"));
  3043. entitys.designNum = GetPostInt("designNum");
  3044. entitys.modifyNum = GetPostInt("modifyNum");
  3045. entitys.designSize = GetPostString("designSize");
  3046. entitys.modifySize = GetPostString("modifySize");
  3047. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3048. {
  3049. entitys.create_time = DateTime.Now;
  3050. entitys.create_u_id = uid;
  3051. entitys.create_u_name = userName;
  3052. entitys.Save();
  3053. }
  3054. else
  3055. {
  3056. entitys.update_time = DateTime.Now;
  3057. entitys.update_u_id = uid;
  3058. entitys.update_u_name = userName;
  3059. entitys.Update();
  3060. }
  3061. }
  3062. }
  3063. }
  3064. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3065. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3066. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3067. if (suname != "")
  3068. {
  3069. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3070. }
  3071. commonHelper.getCytPrice(entity);
  3072. returnSuccessMsg("操作成功!");
  3073. return;
  3074. }
  3075. returnErrorMsg("找不到记录");
  3076. }
  3077. }
  3078. public void upload_erp_filecomplete()
  3079. {
  3080. if (UrlPostParmsCheck("ctid"))
  3081. {
  3082. string eid = GetPostString("ctid");
  3083. CeErpTradeCell entity = null;
  3084. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3085. if (entity != null)
  3086. {
  3087. entity.OrderState = 5; //设计完成
  3088. entity.Update();
  3089. returnSuccessMsg(eid + "上传成功,设计完成!");
  3090. return;
  3091. }
  3092. returnErrorMsg("找不到订单记录");
  3093. }
  3094. }
  3095. public void get_erp_designovertimelist()
  3096. {
  3097. DataStruct dStruct = GetPostStruct();
  3098. List<string> lw = new List<string>();
  3099. string tid = GetPostString("ctid");
  3100. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3101. string shopname = GetPostString("shopname");
  3102. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3103. string buyernick = GetPostString("buyer_nick");
  3104. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3105. string ResponsibleMan = GetPostString("responsible");
  3106. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3107. string date1 = GetPostString("date1");
  3108. string date2 = GetPostString("date2");
  3109. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3110. if (dw.Length > 0) lw.Add(dw);
  3111. string price1 = GetPostString("price1");
  3112. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3113. string price2 = GetPostString("price2");
  3114. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3115. string orderState = GetPostString("orderState");
  3116. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3117. string sellermemo = GetPostString("seller_memo");
  3118. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3119. lw.Add(string.Format("UnusualTag=3"));
  3120. lw.Add(string.Format("IsRefund<={0}", 1));
  3121. dStruct.Order = "WaitDesignTime desc";
  3122. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3123. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3124. writeGridDataTableJson(dStruct.TotalCount, dt);
  3125. }
  3126. //设计管理 获取抢单大厅列表
  3127. public void get_erp_grabinglist()
  3128. {
  3129. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3130. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3131. bool oldOrder = false;
  3132. if (org != null)
  3133. {
  3134. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3135. }
  3136. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3137. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3138. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3139. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3140. //先处理订单数据
  3141. if (dt.Rows.Count > 0)
  3142. {
  3143. Dictionary<string, int> design = null;
  3144. int count = 0;
  3145. foreach (DataRow row in dt.Rows)
  3146. {
  3147. if (map.ContainsKey(row["ShopId"].ToString()))
  3148. {
  3149. map.TryGetValue(row["ShopId"].ToString(), out design);
  3150. }
  3151. else
  3152. {
  3153. design = new Dictionary<string, int>();
  3154. }
  3155. if (design.ContainsKey(row["ProductId"].ToString()))
  3156. {
  3157. design.TryGetValue(row["ProductId"].ToString(), out count);
  3158. }
  3159. count++;
  3160. design[row["ProductId"].ToString()] = count;
  3161. map[row["ShopId"].ToString()] = design;
  3162. }
  3163. }
  3164. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3165. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3166. //把店铺排序和技能排序分类
  3167. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3168. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3169. if (design_dt.Rows.Count > 0)
  3170. {
  3171. Dictionary<string, string> design = null;
  3172. List<string> shopIds = null;
  3173. foreach (DataRow row in design_dt.Rows)
  3174. {
  3175. if ("0".Equals(row["designId"].ToString()))
  3176. {
  3177. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3178. {
  3179. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3180. }
  3181. else
  3182. {
  3183. shopIds = new List<string>();
  3184. }
  3185. shopIds.Add(row["shopId"].ToString());
  3186. shop_orders[row["orders"].ToString()] = shopIds;
  3187. }
  3188. else
  3189. {
  3190. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3191. {
  3192. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3193. }
  3194. else
  3195. {
  3196. design = new Dictionary<string, string>();
  3197. }
  3198. design[row["orders"].ToString()] = row["designId"].ToString();
  3199. design_orders[row["shopId"].ToString()] = design;
  3200. }
  3201. }
  3202. //处理成key value后根据key排序
  3203. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3204. foreach (List<string> val in shop_orders.Values)
  3205. {
  3206. if (val != null)
  3207. {
  3208. foreach (string key in val)
  3209. {
  3210. if (design_orders.ContainsKey(key.ToString()))
  3211. {
  3212. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3213. }
  3214. }
  3215. }
  3216. }
  3217. }
  3218. //校验哪个优先级有订单
  3219. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3220. foreach (string key in shop_orders.Keys)
  3221. {
  3222. List<string> ids = null;
  3223. shop_orders.TryGetValue(key, out ids);
  3224. //id为shopid
  3225. foreach (string id in ids)
  3226. {
  3227. Dictionary<string, int> list = null;
  3228. Dictionary<string, string> desing = null;
  3229. map.TryGetValue(id, out list);
  3230. design_orders.TryGetValue(id, out desing);
  3231. if (list != null && desing != null)
  3232. {
  3233. foreach (var item in desing)
  3234. {
  3235. int count = 0;
  3236. if (list.ContainsKey(item.Value))
  3237. {
  3238. list.TryGetValue(item.Value, out count);
  3239. if (count > 0)
  3240. {
  3241. designIds[id] = item.Value;
  3242. break;
  3243. }
  3244. }
  3245. }
  3246. }
  3247. }
  3248. if (designIds.Count > 0)
  3249. {
  3250. break;
  3251. }
  3252. }
  3253. DataTable table = new DataTable();
  3254. table.Columns.Add("tid", typeof(string));
  3255. table.Columns.Add("ctid", typeof(string));
  3256. table.Columns.Add("seller_nick", typeof(string));
  3257. table.Columns.Add("productName", typeof(string));
  3258. table.Columns.Add("pay_time", typeof(string));
  3259. table.Columns.Add("seller_memo", typeof(string));
  3260. if (designIds.Count > 0)
  3261. {
  3262. string shopId = "";
  3263. string productId = "";
  3264. foreach (var designInfo in designIds)
  3265. {
  3266. shopId = designInfo.Key;
  3267. productId = designInfo.Value;
  3268. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3269. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3270. if (dt.Rows.Count > 0)
  3271. {
  3272. foreach (DataRow row in dt.Rows)
  3273. {
  3274. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3275. {
  3276. DataRow data = table.NewRow();
  3277. data["ctid"] = row["ctid"].ToString();
  3278. data["tid"] = row["tid"].ToString();
  3279. data["seller_nick"] = ceErpShop.ShopName;
  3280. data["pay_time"] = row["pay_time"].ToString();
  3281. data["seller_memo"] = row["seller_memo"].ToString();
  3282. data["productName"] = ceErpProduct.PType;
  3283. table.Rows.Add(data);
  3284. }
  3285. }
  3286. }
  3287. }
  3288. }
  3289. writeGridDataTableJson(table.Rows.Count, table);
  3290. }
  3291. private object rushLockObject = new object();
  3292. public void set_erp_grabingorder()
  3293. {
  3294. if (UrlPostParmsCheck("ctid"))
  3295. {
  3296. int total = CurrentUser.User.Person.Total;
  3297. int userId = CurrentUser.User.ID;
  3298. int noFinish = CurrentUser.User.Person.NoFinish;
  3299. int finalization = CurrentUser.User.Person.Finalization;
  3300. string eids = GetPostString("ctid");
  3301. string key = "RushKey_" + userId;
  3302. int count = 0;
  3303. if (erpRedis.RedisHelper.KeyExists(key))
  3304. {
  3305. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3306. if (redisCount != null)
  3307. {
  3308. count = Convert.ToInt32(redisCount);
  3309. }
  3310. }
  3311. if (count >= total)
  3312. {
  3313. returnErrorMsg("半小时内已经抢" + total + "单");
  3314. return;
  3315. }
  3316. string[] ctidlist = eids.Split(',');
  3317. if (count + ctidlist.Length > total)
  3318. {
  3319. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3320. return;
  3321. }
  3322. int itag = 0;
  3323. lock (rushLockObject)
  3324. {
  3325. if (ctidlist.Length > 0)
  3326. {
  3327. string[] dtList = new string[ctidlist.Length];
  3328. for (int i = 0; i < ctidlist.Length; i++)
  3329. {
  3330. dtList[i] = "'" + ctidlist[i] + "'";
  3331. }
  3332. 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"));
  3333. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3334. if (dt_user.Rows.Count > 0)
  3335. {
  3336. int doing = 0;//未定稿
  3337. int finish = 0;//已完成
  3338. foreach (DataRow dr in dt_user.Rows)
  3339. {
  3340. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3341. {
  3342. doing++;
  3343. }
  3344. else
  3345. {
  3346. finish++;
  3347. }
  3348. }
  3349. if (doing >= noFinish)
  3350. {
  3351. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3352. return;
  3353. }
  3354. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3355. {
  3356. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3357. return;
  3358. }
  3359. }
  3360. //校验选择单子状态
  3361. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3362. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3363. if (dt.Rows.Count > 0)
  3364. {
  3365. List<string> list = new List<string>();
  3366. foreach (DataRow dr in dt.Rows)
  3367. {
  3368. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3369. {
  3370. list.Add(dr["ctid"].ToString());
  3371. }
  3372. }
  3373. if (list.Count > 0)
  3374. {
  3375. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3376. return;
  3377. }
  3378. }
  3379. foreach (string ctid in ctidlist)
  3380. {
  3381. CeErpTradeCell entity = null;
  3382. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3383. if (entity != null)
  3384. {
  3385. entity.OrderState = 3;
  3386. entity.DesignUserId = CurrentUser.UserID;
  3387. entity.WaitDesignTime = DateTime.Now;
  3388. entity.StartDesignTime = DateTime.Now;
  3389. entity.Update();
  3390. commonHelper.UpdateRelationOrder(entity.ctid);
  3391. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3392. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3393. itag++;
  3394. }
  3395. }
  3396. }
  3397. }
  3398. count += ctidlist.Length;
  3399. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3400. if (itag == 0)
  3401. returnErrorMsg("没有找到相关订单");
  3402. else
  3403. returnSuccessMsg("抢单成功!");
  3404. return;
  3405. }
  3406. }
  3407. public void get_erp_waitorderlist()
  3408. {
  3409. DataStruct dStruct = GetPostStruct();
  3410. List<string> lw = new List<string>();
  3411. string tid = GetPostString("ctid");
  3412. if (tid.Length > 0)
  3413. {
  3414. string select_tid = getTidByCtid(tid);
  3415. lw.Add(string.Format("tid='{0}'", select_tid));
  3416. }
  3417. string shopname = GetPostString("shopname");
  3418. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3419. string buyernick = GetPostString("buyer_nick");
  3420. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3421. string customer = GetPostString("customer");
  3422. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3423. string design = GetPostString("design");
  3424. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3425. string orderState = GetPostString("orderState");
  3426. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3427. string supplier = GetPostString("supplier");
  3428. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3429. string sellermemo = GetPostString("seller_memo");
  3430. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3431. string otherMemo = GetPostString("otherMemo");
  3432. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3433. string address = GetPostString("address");
  3434. 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));
  3435. string date1 = GetPostString("date1");
  3436. string date2 = GetPostString("date2");
  3437. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3438. if (dw.Length > 0) lw.Add(dw);
  3439. string price1 = GetPostString("price1");
  3440. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3441. string price2 = GetPostString("price2");
  3442. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3443. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3444. lw.Add(string.Format("IsSample != 2 "));
  3445. lw.Add(string.Format("OrderState = 5 "));
  3446. lw.Add(string.Format("IsRefund<={0}", 1));
  3447. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3448. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3449. string pagesize = GetPostString("pagesize");
  3450. if (pagesize != null)
  3451. {
  3452. dStruct.PageSize = 200;
  3453. }
  3454. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3455. List<string> tids = new List<string>();
  3456. if (dt != null)
  3457. {
  3458. dt.Columns.Add("compenPrice", typeof(double));
  3459. foreach (DataRow dr in dt.Rows)
  3460. {
  3461. if (Convert.IsDBNull(dr["compenPrice"]))
  3462. {
  3463. dr["compenPrice"] = 0;
  3464. }
  3465. tids.Add("'" + dr["tid"].ToString() + "'");
  3466. 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();
  3467. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3468. {
  3469. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3470. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3471. entity.SupplierId = suid;
  3472. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3473. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3474. entity.Update();
  3475. }
  3476. }
  3477. }
  3478. if (tids.Count > 0)
  3479. {
  3480. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3481. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3482. if (dt_price != null && dt_price.Rows.Count > 0)
  3483. {
  3484. foreach (DataRow dr in dt_price.Rows)
  3485. {
  3486. foreach (DataRow row in dt.Rows)
  3487. {
  3488. if (row["tid"].Equals(dr["ptid"]))
  3489. {
  3490. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3491. break;
  3492. }
  3493. }
  3494. }
  3495. }
  3496. }
  3497. writeGridDataTableJson(dStruct.TotalCount, dt);
  3498. }
  3499. public void get_erp_supplierwaitorderlist()
  3500. {
  3501. DataStruct dStruct = GetPostStruct();
  3502. List<string> lw = new List<string>();
  3503. string tid = GetPostString("ctid");
  3504. if (tid.Length > 0)
  3505. {
  3506. string select_tid = getTidByCtid(tid);
  3507. lw.Add(string.Format("tid='{0}'", select_tid));
  3508. }
  3509. string shopname = GetPostString("shopname");
  3510. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3511. string sellermemo = GetPostString("seller_memo");
  3512. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3513. string date1 = GetPostString("date1");
  3514. string date2 = GetPostString("date2");
  3515. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3516. if (dw.Length > 0) lw.Add(dw);
  3517. lw.Add(string.Format("OrderState = 5 "));
  3518. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3519. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3520. {
  3521. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3522. }
  3523. string supplier = GetPostString("supplier");
  3524. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3525. {
  3526. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3527. }
  3528. lw.Add(string.Format("IsRefund<={0}", 1));
  3529. dStruct.Order = "FinishDesignTime desc";
  3530. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3531. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3532. if (dt != null)
  3533. {
  3534. foreach (DataRow dr in dt.Rows)
  3535. {
  3536. 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();
  3537. }
  3538. }
  3539. writeGridDataTableJson(dStruct.TotalCount, dt);
  3540. }
  3541. public void upd_erp_verifytosupplier()
  3542. {
  3543. if (UrlPostParmsCheck("ctid"))
  3544. {
  3545. string eids = GetPostString("ctid");
  3546. CeErpTradeCell entity = null;
  3547. string[] eidsList = eids.Split(',');
  3548. if (eidsList.Length <= 0)
  3549. {
  3550. returnErrorMsg("订单号不能空");
  3551. return;
  3552. }
  3553. List<string> tLst = new List<string>();
  3554. foreach (string ctidstr in eidsList)
  3555. {
  3556. tLst.Add("'" + ctidstr + "'");
  3557. CeErpDataSendOrderInfo.createObject(ctidstr);
  3558. }
  3559. string needtids = string.Join(",", tLst.ToArray());
  3560. StringBuilder sql = new StringBuilder();
  3561. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3562. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3563. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3564. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3565. returnSuccessMsg("操作成功!");
  3566. return;
  3567. /**foreach (string ctidstr in eidsList)
  3568. {
  3569. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3570. if (entity != null)
  3571. {
  3572. if (entity.SupplierId == 0)
  3573. {
  3574. continue;
  3575. }
  3576. entity.IsVerifyToSupplier = true;
  3577. if (entity.IsReturn == 1) //1是供应商打回
  3578. {
  3579. entity.IsReturn = 0;
  3580. }
  3581. entity.FinishPlaceTime = DateTime.Now;
  3582. entity.PlaceUserId = CurrentUser.UserID;
  3583. entity.Update();
  3584. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3585. }
  3586. }
  3587. returnSuccessMsg("操作成功!");
  3588. return;**/
  3589. }
  3590. }
  3591. public void upd_erp_supplierback()
  3592. {
  3593. if (UrlPostParmsCheck("ctid"))
  3594. {
  3595. string eid = GetPostString("ctid");
  3596. string reason = GetPostString("returnreason");
  3597. CeErpTradeCell entity = null;
  3598. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3599. if (entity != null)
  3600. {
  3601. string message = "操作成功!";
  3602. string isDown = "";
  3603. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3604. {
  3605. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3606. isDown = "被点击下载";
  3607. }
  3608. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3609. {
  3610. string key = "return_order_" + entity.SupplierId;
  3611. List<string> list = new List<string>();
  3612. if (RedisHelper.HasKey(key))
  3613. {
  3614. object data = RedisHelper.StringGet(key);
  3615. list = Convert.ToString(data).Split(',').ToList();
  3616. }
  3617. list.Add(eid);
  3618. RedisHelper.StringSet(key, string.Join(",", list));
  3619. }
  3620. entity.IsVerifyToSupplier = false;
  3621. entity.IsReturn = 1;
  3622. entity.IsHaveNewOrder = 0;
  3623. entity.ReturnTime = DateTime.Now;
  3624. entity.ReturnReason = reason;
  3625. if (entity.OrderState == 6)
  3626. {
  3627. entity.OrderState = 5;
  3628. }
  3629. entity.Update();
  3630. CeErpSukuraData.createInfo(entity.ctid, 5);
  3631. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3632. returnSuccessMsg(message);
  3633. return;
  3634. }
  3635. returnErrorMsg("找不到订单记录");
  3636. }
  3637. }
  3638. public void upd_erp_toaftersaleorder()
  3639. {
  3640. if (UrlPostParmsCheck("ctid"))
  3641. {
  3642. string eid = GetPostString("ctid");
  3643. string reason = GetPostString("returnreason");
  3644. CeErpTradeCell entity = null;
  3645. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3646. if (entity != null)
  3647. {
  3648. if (entity.isAfterSaleOrder != 1)
  3649. {
  3650. returnErrorMsg("带S的售后单才能打回给售后");
  3651. return;
  3652. }
  3653. if (entity.OrderState >= 5)
  3654. {
  3655. returnErrorMsg("已经设计完成了不能打回给售后");
  3656. return;
  3657. }
  3658. entity.OrderState = 0;
  3659. entity.IsReturn = 3;
  3660. entity.ReturnTime = DateTime.Now;
  3661. entity.UpdateTime = DateTime.Now;
  3662. entity.ReturnReason = reason;
  3663. entity.Update();
  3664. CeErpSukuraData.createInfo(entity.ctid, 5);
  3665. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3666. returnSuccessMsg("操作成功!");
  3667. return;
  3668. }
  3669. returnErrorMsg("找不到订单记录");
  3670. }
  3671. }
  3672. public void upd_erp_aftersaletodesign()
  3673. {
  3674. if (UrlPostParmsCheck("ctid"))
  3675. {
  3676. string eid = GetPostString("ctid");
  3677. CeErpTradeCell entity = null;
  3678. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3679. if (entity != null)
  3680. {
  3681. entity.OrderState = 3;
  3682. entity.IsReturn = 0;
  3683. entity.UpdateTime = DateTime.Now;
  3684. entity.Update();
  3685. CeErpSukuraData.createInfo(entity.ctid, 5);
  3686. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3687. returnSuccessMsg("操作成功!");
  3688. return;
  3689. }
  3690. returnErrorMsg("找不到订单记录");
  3691. }
  3692. }
  3693. public void assign_erp_supplier()
  3694. {
  3695. if (UrlPostParmsCheck("ctid"))
  3696. {
  3697. string eids = GetPostString("ctid");
  3698. int sid = GetPostInt("SupplierName");
  3699. string fromTag = GetPostString("tag");
  3700. string[] eidList = eids.Split(',');
  3701. if (eidList.Length <= 0)
  3702. {
  3703. returnErrorMsg("指派不能为空");
  3704. return;
  3705. }
  3706. string errMsg = "";
  3707. string suname = commonHelper.getSupplierNameById(sid);
  3708. foreach (string ctid in eidList)
  3709. {
  3710. CeErpTradeCell entity = null;
  3711. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3712. if (entity != null)
  3713. {
  3714. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3715. {
  3716. errMsg += (ctid + "指派失败!!!");
  3717. continue;
  3718. }
  3719. entity.SupplierId = sid;
  3720. entity.Update();
  3721. commonHelper.UpdateRelationOrder(entity.ctid);
  3722. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3723. if (entity.OrderState >= 6)
  3724. {
  3725. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3726. //{
  3727. // string msl = entity.MakeSupplier;
  3728. // string[] mslist = msl.Split(',');
  3729. // 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);
  3730. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3731. //}
  3732. //else
  3733. //{
  3734. StringBuilder sql = new StringBuilder();
  3735. 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);
  3736. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3737. //}
  3738. }
  3739. }
  3740. else
  3741. {
  3742. continue;
  3743. }
  3744. }
  3745. if (errMsg.Length > 0)
  3746. {
  3747. returnErrorMsg(errMsg);
  3748. return;
  3749. }
  3750. returnSuccessMsg("操作成功!");
  3751. return;
  3752. }
  3753. }
  3754. public void assign_erp_makesupplier()
  3755. {
  3756. if (UrlPostParmsCheck("ctid"))
  3757. {
  3758. string eids = GetPostString("ctid");
  3759. string sname = GetPostString("SupplierName");
  3760. string[] eidList = eids.Split(',');
  3761. if (eidList.Length <= 0)
  3762. {
  3763. returnErrorMsg("指派不能为空");
  3764. return;
  3765. }
  3766. List<string> tLst = new List<string>();
  3767. foreach (string ctid in eidList)
  3768. {
  3769. CeErpTradeCell entity = null;
  3770. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3771. if (entity != null)
  3772. {
  3773. entity.MakeSupplier = sname;
  3774. entity.Update();
  3775. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3776. tLst.Add("'" + ctid + "'");
  3777. }
  3778. else
  3779. {
  3780. continue;
  3781. }
  3782. }
  3783. string ctids = string.Join(",", tLst.ToArray());
  3784. StringBuilder sql2 = new StringBuilder();
  3785. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3786. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3787. returnSuccessMsg("操作成功!");
  3788. return;
  3789. }
  3790. }
  3791. public void ins_erp_returnreason()
  3792. {
  3793. if (UrlPostParmsCheck("ctid"))
  3794. {
  3795. string eid = GetPostString("ctid");
  3796. CeErpTradeCell entity = null;
  3797. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3798. string userpost = CurrentUser.UserPost.Post.Code;
  3799. if (entity != null)
  3800. {
  3801. bool isPlace = false;
  3802. if (entity.OrderState > 6)
  3803. {
  3804. returnErrorMsg("已发货无法打回!");
  3805. return;
  3806. }
  3807. if (entity.OrderState == 6)
  3808. {
  3809. isPlace = true;
  3810. }
  3811. bool isNeedUpdateCell2 = false;
  3812. if (entity.OrderState >= 6)
  3813. {
  3814. isNeedUpdateCell2 = true;
  3815. }
  3816. int returnTag = 2;
  3817. if (userpost == "Supplier")
  3818. {
  3819. returnTag = 1;
  3820. }
  3821. int toType = GetPostInt("totype");
  3822. string fromType = "3";
  3823. if (entity.OrderState < 5)
  3824. {
  3825. fromType = "3";
  3826. }
  3827. else
  3828. {
  3829. fromType = "4";
  3830. }
  3831. if (entity.IsXianHuo == 0)
  3832. {
  3833. if (returnTag == 2)
  3834. {
  3835. if (toType == 1)
  3836. {
  3837. entity.OrderState = 0;
  3838. entity.ReturnUserType = 1;
  3839. string clearman = GetPostString("clearman");
  3840. if (!string.IsNullOrEmpty(clearman))
  3841. {
  3842. entity.DesignUserId = 0;
  3843. }
  3844. }
  3845. else
  3846. {
  3847. entity.OrderState = 3;
  3848. entity.ReturnUserType = 2;
  3849. }
  3850. entity.IsReadTag = 1;
  3851. }
  3852. else if (returnTag == 1)
  3853. {
  3854. entity.OrderState = 5;
  3855. }
  3856. entity.IsVerifyToSupplier = false;
  3857. }
  3858. if (entity.IsXianHuo == 1)
  3859. {
  3860. entity.OrderState = 5;
  3861. }
  3862. entity.UnusualTag = 0;
  3863. entity.UnusualTime = null;
  3864. entity.UnusualCon = "";
  3865. entity.IsReturn = returnTag;
  3866. entity.ReturnTime = DateTime.Now;
  3867. entity.UpdateTime = DateTime.Now;
  3868. entity.ReturnReason = GetPostString("returnreason");
  3869. entity.Update();
  3870. if (entity.OrderState == 3)
  3871. {
  3872. ApiVo apiVo = new ApiVo();
  3873. apiVo.orderNumber = entity.ctid;
  3874. apiVo.actionName = "rebutDesign";
  3875. apiVo.orderRemarks = entity.ReturnReason;
  3876. designHelper.API_WorkCore(apiVo);//rebutDesign
  3877. }
  3878. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3879. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3880. {
  3881. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3882. }
  3883. CeErpSukuraData.createInfo(entity.ctid, 5);
  3884. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3885. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3886. if (isPlace)
  3887. {
  3888. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3889. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3890. if (dth != null && dth.Rows.Count > 0)
  3891. {
  3892. dataSendOrderBean dataSendOrderBean = null;
  3893. foreach (DataRow item in dth.Rows)
  3894. {
  3895. try
  3896. {
  3897. dataSendOrderBean = new dataSendOrderBean();
  3898. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3899. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3900. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3901. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3902. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3903. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3904. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3905. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3906. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3907. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3908. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3909. dataSendOrderBean.Radio1723534706288 = "打回";
  3910. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3911. if (result != null)
  3912. {
  3913. if ("0".Equals(result.errcode))
  3914. {
  3915. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3916. }
  3917. else
  3918. {
  3919. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3920. }
  3921. }
  3922. }
  3923. catch (Exception ex)
  3924. {
  3925. }
  3926. }
  3927. }
  3928. }
  3929. if (isNeedUpdateCell2)
  3930. {
  3931. if (entity.MakeSupplier.IndexOf(",") != -1)
  3932. {
  3933. StringBuilder sql2 = new StringBuilder();
  3934. 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);
  3935. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3936. }
  3937. else
  3938. {
  3939. StringBuilder sql2 = new StringBuilder();
  3940. 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);
  3941. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3942. }
  3943. }
  3944. returnSuccessMsg("操作成功!");
  3945. return;
  3946. }
  3947. returnErrorMsg("找不到订单记录");
  3948. }
  3949. }
  3950. public void cyt_erp_returnreason()
  3951. {
  3952. if (UrlPostParmsCheck("ctid"))
  3953. {
  3954. string eid = GetPostString("ctid");
  3955. CeErpTradeCell entity = null;
  3956. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3957. string userpost = CurrentUser.UserPost.Post.Code;
  3958. if (entity != null)
  3959. {
  3960. if (entity.OrderState > 6)
  3961. {
  3962. returnErrorMsg("已发货无法打回!");
  3963. return;
  3964. }
  3965. JObject jsonObject = new JObject
  3966. {
  3967. { "Userid", "77886" },
  3968. { "Pwd", "lt666888" },
  3969. { "LTOrderId",eid }
  3970. };
  3971. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3972. JObject jsonObjects = JObject.Parse(response);
  3973. string msg = (string)jsonObjects["msg"];
  3974. if (msg != "取消成功")
  3975. {
  3976. returnErrorMsg(msg);
  3977. return;
  3978. }
  3979. bool isNeedUpdateCell2 = false;
  3980. if (entity.OrderState >= 6)
  3981. {
  3982. isNeedUpdateCell2 = true;
  3983. }
  3984. int returnTag = 2;
  3985. if (userpost == "Supplier")
  3986. {
  3987. returnTag = 1;
  3988. }
  3989. if (entity.IsXianHuo == 0)
  3990. {
  3991. if (returnTag == 2)
  3992. {
  3993. int toType = GetPostInt("totype");
  3994. if (toType == 1)
  3995. {
  3996. entity.OrderState = 0;
  3997. entity.ReturnUserType = 1;
  3998. }
  3999. else
  4000. {
  4001. entity.OrderState = 4;
  4002. entity.ReturnUserType = 2;
  4003. }
  4004. entity.IsReadTag = 1;
  4005. }
  4006. else if (returnTag == 1)
  4007. {
  4008. entity.OrderState = 5;
  4009. }
  4010. entity.IsVerifyToSupplier = false;
  4011. }
  4012. entity.UnusualTag = 0;
  4013. entity.UnusualTime = null;
  4014. entity.UnusualCon = "";
  4015. entity.IsReturn = returnTag;
  4016. entity.ReturnTime = DateTime.Now;
  4017. entity.ReturnReason = GetPostString("returnreason");
  4018. entity.Update();
  4019. if (entity.OrderState == 4)
  4020. {
  4021. ApiVo apiVo = new ApiVo();
  4022. apiVo.orderNumber = entity.ctid;
  4023. apiVo.actionName = "rebutDesign";
  4024. apiVo.orderRemarks = entity.ReturnReason;
  4025. designHelper.API_WorkCore(apiVo);//rebutDesign
  4026. }
  4027. CeErpSukuraData.createInfo(entity.ctid, 5);
  4028. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4029. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4030. if (isNeedUpdateCell2)
  4031. {
  4032. if (entity.MakeSupplier.IndexOf(",") != -1)
  4033. {
  4034. StringBuilder sql2 = new StringBuilder();
  4035. 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);
  4036. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4037. }
  4038. else
  4039. {
  4040. StringBuilder sql2 = new StringBuilder();
  4041. 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);
  4042. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4043. }
  4044. }
  4045. returnSuccessMsg("操作成功!");
  4046. return;
  4047. }
  4048. returnErrorMsg("找不到订单记录");
  4049. }
  4050. }
  4051. public void upd_erp_xianhuoreturntag()
  4052. {
  4053. if (UrlPostParmsCheck("ctid"))
  4054. {
  4055. string eids = GetPostString("ctid");
  4056. string[] ctids = eids.Split(',');
  4057. foreach (string ctid in ctids)
  4058. {
  4059. CeErpTradeCell entity = null;
  4060. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4061. if (entity != null)
  4062. {
  4063. entity.IsReturn = 0;
  4064. entity.Update();
  4065. CeErpSukuraData.createInfo(entity.ctid, 5);
  4066. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4067. }
  4068. }
  4069. returnSuccessMsg("操作成功!");
  4070. return;
  4071. }
  4072. }
  4073. public void get_erp_waitdeliverylist()
  4074. {
  4075. DataStruct dStruct = GetPostStruct();
  4076. List<string> lw = new List<string>();
  4077. string tid = GetPostString("ctid");
  4078. if (tid.Length > 0)
  4079. {
  4080. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4081. if (tid.Length > 5)
  4082. {
  4083. List<string> tids = getTidByCtidLike(tid);
  4084. if (tids.Count > 0 && tids.Count < 10)
  4085. {
  4086. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4087. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4088. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4089. {
  4090. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4091. }*/
  4092. }
  4093. }
  4094. lw.Add(tid_sql);
  4095. }
  4096. string shopname = GetPostString("shopname");
  4097. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4098. string buyernick = GetPostString("buyer_nick");
  4099. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4100. //if (tid.Length == 0 && buyernick.Length == 0)
  4101. //{
  4102. // lw.Add(string.Format("IsRefund<={0}", 1));
  4103. //}
  4104. string customer = GetPostString("customer");
  4105. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4106. string design = GetPostString("design");
  4107. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4108. string orderState = GetPostString("orderState");
  4109. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4110. string address = GetPostString("address");
  4111. 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));
  4112. string sellermemo = GetPostString("seller_memo");
  4113. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4114. string supplier = GetPostString("supplier");
  4115. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4116. string OrderArea = GetPostString("order_area");
  4117. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4118. string placedate1 = GetPostString("placedate1");
  4119. string placedate2 = GetPostString("placedate2");
  4120. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4121. if (fdw.Length > 0) lw.Add(fdw);
  4122. string price1 = GetPostString("price1");
  4123. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4124. string price2 = GetPostString("price2");
  4125. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4126. string unusualCon = GetPostString("unusualcon");
  4127. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4128. string otherMemo = GetPostString("otherMemo");
  4129. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4130. string posTag = CurrentUser.UserPost.Post.Code;
  4131. if (posTag == "Supplier")
  4132. {
  4133. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4134. }
  4135. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4136. lw.Add(string.Format("type != 'PDD' "));
  4137. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4138. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4139. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4140. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4141. writeGridDataTableJson(dStruct.TotalCount, dt);
  4142. }
  4143. public void get_erp_changedeliverylist()
  4144. {
  4145. DataStruct dStruct = GetPostStruct();
  4146. List<string> lw = new List<string>();
  4147. string tid = GetPostString("ctid");
  4148. if (tid.Length > 0)
  4149. {
  4150. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4151. if (tid.Length > 5)
  4152. {
  4153. List<string> tids = getTidByCtidLike(tid);
  4154. if (tids.Count > 0 && tids.Count < 10)
  4155. {
  4156. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4157. }
  4158. }
  4159. lw.Add(tid_sql);
  4160. }
  4161. string shopname = GetPostString("shopname");
  4162. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4163. string buyernick = GetPostString("buyer_nick");
  4164. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4165. //if (tid.Length == 0 && buyernick.Length == 0)
  4166. //{
  4167. // lw.Add(string.Format("IsRefund<={0}", 1));
  4168. //}
  4169. string customer = GetPostString("customer");
  4170. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4171. string design = GetPostString("design");
  4172. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4173. string orderState = GetPostString("orderState");
  4174. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4175. string address = GetPostString("address");
  4176. 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));
  4177. string sellermemo = GetPostString("seller_memo");
  4178. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4179. string supplier = GetPostString("supplier");
  4180. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4181. string OrderArea = GetPostString("order_area");
  4182. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4183. string placedate1 = GetPostString("placedate1");
  4184. string placedate2 = GetPostString("placedate2");
  4185. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4186. if (fdw.Length > 0) lw.Add(fdw);
  4187. string price1 = GetPostString("price1");
  4188. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4189. string price2 = GetPostString("price2");
  4190. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4191. string unusualCon = GetPostString("unusualcon");
  4192. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4193. string otherMemo = GetPostString("otherMemo");
  4194. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4195. string posTag = CurrentUser.UserPost.Post.Code;
  4196. if (posTag == "Supplier")
  4197. {
  4198. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4199. }
  4200. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4201. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4202. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4203. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4204. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4205. /*if (tid.Length > 0)
  4206. {
  4207. List<string> tids = new List<string>();
  4208. if (dt != null && dt.Rows.Count > 0)
  4209. {
  4210. foreach (DataRow item in dt.Rows)
  4211. {
  4212. tids.Add("'" + item["tid"] + "'");
  4213. }
  4214. }
  4215. if (tids.Count > 0)
  4216. {
  4217. lw.RemoveAt(0);
  4218. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4219. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4220. dt = WebCache.GetData("view_erptradecell", dStruct);
  4221. }
  4222. }*/
  4223. writeGridDataTableJson(dStruct.TotalCount, dt);
  4224. }
  4225. public void get_erp_pddderiving()
  4226. {
  4227. DataStruct dStruct = GetPostStruct();
  4228. List<string> lw = new List<string>();
  4229. string tid = GetPostString("ctid");
  4230. if (tid.Length > 0)
  4231. {
  4232. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4233. if (tid.Length > 5)
  4234. {
  4235. List<string> tids = getTidByCtidLike(tid);
  4236. if (tids.Count > 0 && tids.Count < 10)
  4237. {
  4238. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4239. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4240. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4241. {
  4242. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4243. }*/
  4244. }
  4245. }
  4246. lw.Add(tid_sql);
  4247. }
  4248. string shopname = GetPostString("shopname");
  4249. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4250. string buyernick = GetPostString("buyer_nick");
  4251. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4252. //if (tid.Length == 0 && buyernick.Length == 0)
  4253. //{
  4254. // lw.Add(string.Format("IsRefund<={0}", 1));
  4255. //}
  4256. string customer = GetPostString("customer");
  4257. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4258. string design = GetPostString("design");
  4259. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4260. string orderState = GetPostString("orderState");
  4261. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4262. string address = GetPostString("address");
  4263. 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));
  4264. string sellermemo = GetPostString("seller_memo");
  4265. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4266. string supplier = GetPostString("supplier");
  4267. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4268. string OrderArea = GetPostString("order_area");
  4269. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4270. string placedate1 = GetPostString("placedate1");
  4271. string placedate2 = GetPostString("placedate2");
  4272. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4273. if (fdw.Length > 0) lw.Add(fdw);
  4274. string price1 = GetPostString("price1");
  4275. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4276. string price2 = GetPostString("price2");
  4277. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4278. string unusualCon = GetPostString("unusualcon");
  4279. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4280. string posTag = CurrentUser.UserPost.Post.Code;
  4281. if (posTag == "Supplier")
  4282. {
  4283. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4284. }
  4285. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4286. lw.Add(string.Format("type = 'PDD' "));
  4287. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4288. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4289. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4290. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4291. /*if (tid.Length > 0)
  4292. {
  4293. List<string> tids = new List<string>();
  4294. if (dt != null && dt.Rows.Count > 0)
  4295. {
  4296. foreach (DataRow item in dt.Rows)
  4297. {
  4298. tids.Add("'" + item["tid"] + "'");
  4299. }
  4300. }
  4301. if (tids.Count > 0)
  4302. {
  4303. lw.RemoveAt(0);
  4304. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4305. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4306. dt = WebCache.GetData("view_erptradecell", dStruct);
  4307. }
  4308. }*/
  4309. writeGridDataTableJson(dStruct.TotalCount, dt);
  4310. }
  4311. public void get_erp_jdderiving()
  4312. {
  4313. DataStruct dStruct = GetPostStruct();
  4314. List<string> lw = new List<string>();
  4315. string tid = GetPostString("ctid");
  4316. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4317. string shopname = GetPostString("shopname");
  4318. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4319. string buyernick = GetPostString("buyer_nick");
  4320. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4321. //if (tid.Length == 0 && buyernick.Length == 0)
  4322. //{
  4323. // lw.Add(string.Format("IsRefund<={0}", 1));
  4324. //}
  4325. string customer = GetPostString("customer");
  4326. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4327. string design = GetPostString("design");
  4328. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4329. string orderState = GetPostString("orderState");
  4330. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4331. string address = GetPostString("address");
  4332. 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));
  4333. string sellermemo = GetPostString("seller_memo");
  4334. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4335. string supplier = GetPostString("supplier");
  4336. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4337. string OrderArea = GetPostString("order_area");
  4338. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4339. string placedate1 = GetPostString("placedate1");
  4340. string placedate2 = GetPostString("placedate2");
  4341. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4342. if (fdw.Length > 0) lw.Add(fdw);
  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. string unusualCon = GetPostString("unusualcon");
  4348. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4349. string posTag = CurrentUser.UserPost.Post.Code;
  4350. if (posTag == "Supplier")
  4351. {
  4352. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4353. }
  4354. lw.Add(string.Format("OrderState = 6 "));
  4355. lw.Add(string.Format("type = 'JD' "));
  4356. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4357. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4358. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4359. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4360. writeGridDataTableJson(dStruct.TotalCount, dt);
  4361. }
  4362. public void get_erp_demoorderlist()
  4363. {
  4364. DataStruct dStruct = GetPostStruct();
  4365. List<string> lw = new List<string>();
  4366. string tid = GetPostString("ctid");
  4367. if (tid.Length > 0)
  4368. {
  4369. string select_tid = getTidByCtid(tid);
  4370. lw.Add(string.Format("tid='{0}'", select_tid));
  4371. }
  4372. string shopname = GetPostString("shopname");
  4373. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4374. string buyernick = GetPostString("buyer_nick");
  4375. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4376. string customer = GetPostString("customer");
  4377. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4378. string design = GetPostString("design");
  4379. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4380. string orderState = GetPostString("orderState");
  4381. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4382. string address = GetPostString("address");
  4383. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4384. string sellermemo = GetPostString("seller_memo");
  4385. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4386. string supplier = GetPostString("supplier");
  4387. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4388. string OrderArea = GetPostString("order_area");
  4389. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4390. string date1 = GetPostString("date1");
  4391. string date2 = GetPostString("date2");
  4392. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4393. if (dw.Length > 0) lw.Add(dw);
  4394. string price1 = GetPostString("price1");
  4395. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4396. string price2 = GetPostString("price2");
  4397. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4398. string posTag = CurrentUser.UserPost.Post.Code;
  4399. if (posTag == "Supplier")
  4400. {
  4401. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4402. }
  4403. //lw.Add(string.Format("OrderState = 6 "));
  4404. lw.Add(string.Format("IsSample={0}", 3));
  4405. lw.Add(string.Format("IsRefund<={0}", 1));
  4406. dStruct.Order = "pay_time desc";
  4407. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4408. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4409. writeGridDataTableJson(dStruct.TotalCount, dt);
  4410. }
  4411. public void save_erp_checkmemo()
  4412. {
  4413. if (UrlPostParmsCheck("ctid"))
  4414. {
  4415. string ctid = GetPostString("ctid");
  4416. CeErpTradeCell entity = null;
  4417. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4418. if (entity != null)
  4419. {
  4420. entity.CheckMemo = GetPostString("CheckMemo");
  4421. entity.Update();
  4422. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4423. if (trade != null)
  4424. {
  4425. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4426. }
  4427. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4428. returnSuccessMsg("保存成功!");
  4429. return;
  4430. }
  4431. returnErrorMsg("找不到记录");
  4432. }
  4433. }
  4434. public void get_erp_returnlist()
  4435. {
  4436. DataStruct dStruct = GetPostStruct();
  4437. List<string> lw = new List<string>();
  4438. string tid = GetPostString("ctid");
  4439. if (tid.Length > 0)
  4440. {
  4441. string select_tid = getTidByCtid(tid);
  4442. lw.Add(string.Format("tid='{0}'", select_tid));
  4443. }
  4444. string shopname = GetPostString("shopname");
  4445. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4446. string buyernick = GetPostString("buyer_nick");
  4447. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4448. string customer = GetPostString("customer");
  4449. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4450. string design = GetPostString("design");
  4451. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4452. string orderState = GetPostString("orderState");
  4453. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4454. string address = GetPostString("address");
  4455. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4456. string sellermemo = GetPostString("seller_memo");
  4457. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4458. string supplier = GetPostString("supplier");
  4459. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4460. string date1 = GetPostString("date1");
  4461. string date2 = GetPostString("date2");
  4462. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4463. if (dw.Length > 0) lw.Add(dw);
  4464. string bdate1 = GetPostString("backdate1");
  4465. string bdate2 = GetPostString("backdate2");
  4466. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4467. if (dw_back.Length > 0) lw.Add(dw_back);
  4468. string price1 = GetPostString("price1");
  4469. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4470. string price2 = GetPostString("price2");
  4471. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4472. lw.Add(string.Format("IsReturn>0"));
  4473. lw.Add(string.Format("IsXianHuo=0"));
  4474. lw.Add(string.Format("IsReturn!=3"));
  4475. string backtype = GetPostString("backtype");
  4476. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4477. dStruct.Order = "FinishDesignTime desc";
  4478. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4479. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4480. writeGridDataTableJson(dStruct.TotalCount, dt);
  4481. }
  4482. public void get_erp_today_sumreturn()
  4483. {
  4484. DataStruct dStruct = GetPostStruct();
  4485. List<string> lw = new List<string>();
  4486. string bdate1 = GetPostString("returnTimeS");
  4487. string bdate2 = GetPostString("returnTimeE");
  4488. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4489. if (dw_back.Length > 0) lw.Add(dw_back);
  4490. lw.Add(string.Format("IsReturn=0"));
  4491. lw.Add(string.Format("IsXianHuo=0"));
  4492. string mainWhere = string.Join(" and ", lw.ToArray());
  4493. string sql = "";
  4494. if (dw_back.Length > 0)
  4495. {
  4496. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4497. }
  4498. else
  4499. {
  4500. 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 + "'";
  4501. }
  4502. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4503. decimal total = 0, today_finish = 0;
  4504. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4505. {
  4506. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4507. }
  4508. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4509. {
  4510. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4511. }
  4512. var res = new
  4513. {
  4514. data = total,
  4515. data1 = today_finish,
  4516. };
  4517. string ro_jsond = JsonConvert.SerializeObject(res);
  4518. returnSuccess(ro_jsond);
  4519. return;
  4520. }
  4521. public void get_erp_allreturnlist()
  4522. {
  4523. DataStruct dStruct = GetPostStruct();
  4524. List<string> lw = new List<string>();
  4525. string tid = GetPostString("ctid");
  4526. if (tid.Length > 0)
  4527. {
  4528. string select_tid = getTidByCtid(tid);
  4529. lw.Add(string.Format("tid='{0}'", select_tid));
  4530. }
  4531. string shopname = GetPostString("shopname");
  4532. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4533. string buyernick = GetPostString("buyer_nick");
  4534. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4535. string customer = GetPostString("customer");
  4536. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4537. string design = GetPostString("design");
  4538. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4539. string orderState = GetPostString("orderState");
  4540. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4541. string address = GetPostString("address");
  4542. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4543. string sellermemo = GetPostString("seller_memo");
  4544. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4545. string supplier = GetPostString("supplier");
  4546. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4547. string date1 = GetPostString("date1");
  4548. string date2 = GetPostString("date2");
  4549. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4550. if (dw.Length > 0) lw.Add(dw);
  4551. string bdate1 = GetPostString("backdate1");
  4552. string bdate2 = GetPostString("backdate2");
  4553. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4554. if (dw_back.Length > 0) lw.Add(dw_back);
  4555. string price1 = GetPostString("price1");
  4556. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4557. string price2 = GetPostString("price2");
  4558. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4559. string backreason = GetPostString("backreason");
  4560. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4561. lw.Add(string.Format("IsXianHuo=0"));
  4562. lw.Add(string.Format("ReturnTime != ''"));
  4563. string backtype = GetPostString("backtype");
  4564. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4565. dStruct.Order = "FinishDesignTime desc";
  4566. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4567. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4568. writeGridDataTableJson(dStruct.TotalCount, dt);
  4569. }
  4570. public void get_erp_aftersalereturnlist()
  4571. {
  4572. DataStruct dStruct = GetPostStruct();
  4573. List<string> lw = new List<string>();
  4574. string tid = GetPostString("ctid");
  4575. if (tid.Length > 0)
  4576. {
  4577. string select_tid = getTidByCtid(tid);
  4578. lw.Add(string.Format("tid='{0}'", select_tid));
  4579. }
  4580. string shopname = GetPostString("shopname");
  4581. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4582. string buyernick = GetPostString("buyer_nick");
  4583. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4584. string customer = GetPostString("customer");
  4585. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4586. string design = GetPostString("design");
  4587. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4588. string orderState = GetPostString("orderState");
  4589. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4590. string address = GetPostString("address");
  4591. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4592. string sellermemo = GetPostString("seller_memo");
  4593. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4594. string supplier = GetPostString("supplier");
  4595. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4596. string date1 = GetPostString("date1");
  4597. string date2 = GetPostString("date2");
  4598. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4599. if (dw.Length > 0) lw.Add(dw);
  4600. string bdate1 = GetPostString("backdate1");
  4601. string bdate2 = GetPostString("backdate2");
  4602. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4603. if (dw_back.Length > 0) lw.Add(dw_back);
  4604. string price1 = GetPostString("price1");
  4605. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4606. string price2 = GetPostString("price2");
  4607. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4608. lw.Add(string.Format("IsReturn=3"));
  4609. string backtype = GetPostString("backtype");
  4610. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4611. string backreason = GetPostString("backreason");
  4612. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4613. dStruct.Order = "ReturnTime desc";
  4614. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4615. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4616. writeGridDataTableJson(dStruct.TotalCount, dt);
  4617. }
  4618. public void get_erp_xianhuoreturnlist()
  4619. {
  4620. DataStruct dStruct = GetPostStruct();
  4621. List<string> lw = new List<string>();
  4622. string tid = GetPostString("ctid");
  4623. if (tid.Length > 0)
  4624. {
  4625. string select_tid = getTidByCtid(tid);
  4626. lw.Add(string.Format("tid='{0}'", select_tid));
  4627. }
  4628. string shopname = GetPostString("shopname");
  4629. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4630. string buyernick = GetPostString("buyer_nick");
  4631. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4632. string customer = GetPostString("customer");
  4633. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4634. string design = GetPostString("design");
  4635. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4636. string orderState = GetPostString("orderState");
  4637. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4638. string address = GetPostString("address");
  4639. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4640. string sellermemo = GetPostString("seller_memo");
  4641. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4642. string supplier = GetPostString("supplier");
  4643. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4644. string OrderArea = GetPostString("order_area");
  4645. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4646. string date1 = GetPostString("date1");
  4647. string date2 = GetPostString("date2");
  4648. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4649. if (dw.Length > 0) lw.Add(dw);
  4650. string price1 = GetPostString("price1");
  4651. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4652. string price2 = GetPostString("price2");
  4653. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4654. string posTag = CurrentUser.UserPost.Post.Code;
  4655. if (posTag == "Supplier")
  4656. {
  4657. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4658. }
  4659. lw.Add(string.Format("OrderState=6 "));
  4660. lw.Add(string.Format("IsXianHuo=1 "));
  4661. lw.Add(string.Format("IsReturn>0 "));
  4662. lw.Add(string.Format("IsReturn!=3"));
  4663. lw.Add(string.Format("IsRefund<={0}", 1));
  4664. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4665. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4666. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4667. writeGridDataTableJson(dStruct.TotalCount, dt);
  4668. }
  4669. public void set_erp_orderdelivery()
  4670. {
  4671. if (UrlPostParmsCheck("ctid"))
  4672. {
  4673. string eid = GetPostString("ctid");
  4674. CeErpTradeCell entity = null;
  4675. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4676. if (entity != null)
  4677. {
  4678. if (entity.OrderState >= 7)
  4679. {
  4680. returnErrorMsg("此单已发货,无需重复发货");
  4681. return;
  4682. }
  4683. if (entity.OrderState != 6)
  4684. {
  4685. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4686. return;
  4687. }
  4688. string shop = GetPostString("seller_nick");
  4689. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4690. string comName = GetPostString("comName");
  4691. string comCode = GetPostString("comCode");
  4692. string outSid = GetPostString("outSid");
  4693. string deliveryType = GetPostString("deliveryType");
  4694. string deliveryMemo = GetPostString("deliveryMemo");
  4695. outSid = outSid.Trim();
  4696. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4697. if (mainEn == null)
  4698. {
  4699. returnErrorMsg("找不到原始订单记录");
  4700. return;
  4701. }
  4702. bool isInitOrderDeliv = false;
  4703. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4704. {
  4705. isInitOrderDeliv = true;
  4706. }
  4707. string apires = "";
  4708. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4709. 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)
  4710. {
  4711. apires = "发货成功true";
  4712. }
  4713. else
  4714. {
  4715. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4716. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4717. }
  4718. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4719. {
  4720. entity.OrderState = 7;//发货后订单已发货
  4721. entity.OutSid = outSid;
  4722. entity.MemoOpt = 0;
  4723. entity.UpdateTime = DateTime.Now;
  4724. entity.FinishDeliveryTime = DateTime.Now;
  4725. entity.Update();
  4726. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4727. commonHelper.UpdateRelationOrder(entity.ctid);
  4728. //还要插入快递信息到 快递信息表
  4729. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4730. exinfo.tid = eid;
  4731. exinfo.out_sid = outSid;
  4732. exinfo.company_code = comCode;
  4733. exinfo.company_name = comName;
  4734. exinfo.delivery_memo = deliveryMemo;
  4735. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4736. exinfo.deliveryType = deliveryType;
  4737. exinfo.Create();
  4738. returnSuccessMsg("发货操作成功!");
  4739. commonHelper.UpdateRelationOrder(entity.ctid);
  4740. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4741. CeErpSukuraData.createInfo(entity.ctid, 4);
  4742. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4743. {
  4744. commonHelper.sendCytExpress(exinfo);
  4745. }
  4746. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4747. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4748. }
  4749. else
  4750. {
  4751. string errmsg = commonHelper.KeepChinese(apires);
  4752. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4753. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4754. }
  4755. return;
  4756. }
  4757. returnErrorMsg("找不到订单记录");
  4758. }
  4759. }
  4760. public void set_erp_multidelivery()
  4761. {
  4762. string eids = GetPostString("tids");
  4763. string[] eidList = eids.Split(',');
  4764. if (eidList.Length <= 0)
  4765. {
  4766. returnErrorMsg("发货不能为空");
  4767. return;
  4768. }
  4769. foreach (string ctid in eidList)
  4770. {
  4771. if (ctid.Length <= 0) continue;
  4772. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4773. if (expInfo != null)
  4774. {
  4775. StringBuilder sql = new StringBuilder();
  4776. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4777. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4778. if (dt.Rows.Count > 0)
  4779. {
  4780. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4781. {
  4782. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4783. expInfo.state = "异常";
  4784. expInfo.isMultiDelivery = 1;
  4785. expInfo.Update();
  4786. continue;
  4787. }
  4788. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4789. {
  4790. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4791. expInfo.state = "异常";
  4792. expInfo.Update();
  4793. continue;
  4794. }
  4795. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4796. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4797. bool isInitOrderDeliv = false;
  4798. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4799. {
  4800. isInitOrderDeliv = true;
  4801. expInfo.isMultiDelivery = 1;
  4802. }
  4803. if (ctid.IndexOf("N") != -1)
  4804. {
  4805. StringBuilder sqlbucha = new StringBuilder();
  4806. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4807. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4808. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4809. commonHelper.UpdateRelationOrder(ctid);
  4810. expInfo.delivery_memo = "发货成功";
  4811. expInfo.state = "发货成功";
  4812. expInfo.isMultiDelivery = 1;
  4813. expInfo.Update();
  4814. }
  4815. else
  4816. {
  4817. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4818. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4819. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4820. {
  4821. expInfo.delivery_memo = "发货成功";
  4822. expInfo.state = "发货成功";
  4823. expInfo.isMultiDelivery = 1;
  4824. expInfo.Update();
  4825. commonHelper.UpdateRelationOrder(ctid);
  4826. CeErpSukuraData.createInfo(ctid, 4);
  4827. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4828. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4829. }
  4830. else
  4831. {
  4832. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4833. expInfo.state = "异常";
  4834. expInfo.Update();
  4835. }
  4836. }
  4837. }
  4838. }
  4839. }
  4840. returnSuccessMsg("操作完成");
  4841. }
  4842. public void reset_erp_memoopt()
  4843. {
  4844. if (UrlPostParmsCheck("ctid"))
  4845. {
  4846. string eid = GetPostString("ctid");
  4847. CeErpTradeCell entity = null;
  4848. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4849. if (entity != null)
  4850. {
  4851. string stropt = "";
  4852. if (entity.MemoOpt == 1)
  4853. {
  4854. stropt = "“改稿”";
  4855. }
  4856. else if (entity.MemoOpt == 2)
  4857. {
  4858. stropt = "“定稿”";
  4859. }
  4860. else if (entity.MemoOpt == 3)
  4861. {
  4862. stropt = "“完成查货”";
  4863. CeErpSukuraData.createInfo(entity.ctid, 6);
  4864. }
  4865. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4866. entity.UpdateTime = DateTime.Now;
  4867. entity.MemoOpt = 0;
  4868. entity.Update();
  4869. returnSuccessMsg("操作成功!");
  4870. return;
  4871. }
  4872. returnErrorMsg("找不到记录");
  4873. }
  4874. }
  4875. public void get_erp_deliveryunusual()
  4876. {
  4877. DataStruct dStruct = GetPostStruct();
  4878. List<string> lw = new List<string>();
  4879. string tid = GetPostString("ctid");
  4880. if (tid.Length > 0)
  4881. {
  4882. string select_tid = getTidByCtid(tid);
  4883. lw.Add(string.Format("tid='{0}'", select_tid));
  4884. }
  4885. string shopname = GetPostString("shopname");
  4886. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4887. string buyernick = GetPostString("buyer_nick");
  4888. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4889. string customer = GetPostString("customer");
  4890. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4891. string design = GetPostString("design");
  4892. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4893. string sellermemo = GetPostString("seller_memo");
  4894. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4895. string supplier = GetPostString("supplier");
  4896. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4897. string date1 = GetPostString("date1");
  4898. string date2 = GetPostString("date2");
  4899. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4900. if (dw.Length > 0) lw.Add(dw);
  4901. string placedate1 = GetPostString("placedate1");
  4902. string placedate2 = GetPostString("placedate2");
  4903. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4904. if (dw_place.Length > 0) lw.Add(dw_place);
  4905. string price1 = GetPostString("price1");
  4906. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4907. string price2 = GetPostString("price2");
  4908. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4909. string unusualCon = GetPostString("unusualcon");
  4910. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4911. string posTag = CurrentUser.UserPost.Post.Code;
  4912. if (posTag == "Supplier")
  4913. {
  4914. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4915. }
  4916. lw.Add(string.Format("OrderState = 6"));
  4917. lw.Add(string.Format("UnusualTag = 5"));
  4918. lw.Add(string.Format("IsRefund<={0}", 1));
  4919. dStruct.Order = "FinishPlaceTime desc";
  4920. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4921. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4922. writeGridDataTableJson(dStruct.TotalCount, dt);
  4923. }
  4924. public void get_erp_deliveryedlist()
  4925. {
  4926. DataStruct dStruct = GetPostStruct();
  4927. List<string> lw = new List<string>();
  4928. string tid = GetPostString("ctid");
  4929. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4930. string shopname = GetPostString("shopname");
  4931. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4932. string buyernick = GetPostString("buyer_nick");
  4933. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4934. string customer = GetPostString("customer");
  4935. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4936. string design = GetPostString("design");
  4937. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4938. string sellermemo = GetPostString("seller_memo");
  4939. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4940. string logistics = GetPostString("logistics");
  4941. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4942. string date1 = GetPostString("date1");
  4943. string date2 = GetPostString("date2");
  4944. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4945. //if (dw.Length > 0) lw.Add(dw);
  4946. string placedate1 = GetPostString("placedate1");
  4947. string placedate2 = GetPostString("placedate2");
  4948. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4949. if (fdw.Length > 0) lw.Add(fdw);
  4950. string devdate1 = GetPostString("deliverydate1");
  4951. string devdate2 = GetPostString("deliverydate2");
  4952. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4953. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4954. string price1 = GetPostString("price1");
  4955. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4956. string price2 = GetPostString("price2");
  4957. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4958. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4959. {
  4960. if (tid.Length > 0)
  4961. {
  4962. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4963. if (tid.Length > 5)
  4964. {
  4965. List<string> tids = getTidByCtidLike(tid);
  4966. if (tids.Count > 0 && tids.Count < 10)
  4967. {
  4968. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4969. }
  4970. }
  4971. lw.Add(tid_sql);
  4972. }
  4973. if (buyernick.Length > 0)
  4974. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4975. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4976. if (dw.Length > 0) lw.Add(dw);
  4977. }
  4978. else
  4979. {
  4980. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  4981. }
  4982. string posTag = CurrentUser.UserPost.Post.Code;
  4983. if (posTag == "Supplier")
  4984. {
  4985. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4986. }
  4987. else
  4988. {
  4989. string supplier = GetPostString("supplier");
  4990. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4991. }
  4992. lw.Add(string.Format(" OrderState IN (7, 8)"));
  4993. lw.Add(string.Format("type != 'PDD' "));
  4994. lw.Add(string.Format("IsRefund!={0}", 2));
  4995. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4996. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4997. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4998. /*if (tid.Length > 0)
  4999. {
  5000. List<string> tids = new List<string>();
  5001. if (dt != null && dt.Rows.Count > 0)
  5002. {
  5003. foreach (DataRow item in dt.Rows)
  5004. {
  5005. tids.Add("'" + item["tid"] + "'");
  5006. }
  5007. }
  5008. if (tids.Count > 0)
  5009. {
  5010. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5011. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5012. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5013. dt = WebCache.GetData("view_erptradecell", dStruct);
  5014. }
  5015. }*/
  5016. if (dt != null)
  5017. {
  5018. foreach (DataRow dr in dt.Rows)
  5019. {
  5020. 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();
  5021. }
  5022. }
  5023. writeGridDataTableJson(dStruct.TotalCount, dt);
  5024. }
  5025. public void get_erp_pdddeliveryed()
  5026. {
  5027. DataStruct dStruct = GetPostStruct();
  5028. List<string> lw = new List<string>();
  5029. string tid = GetPostString("ctid");
  5030. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5031. string shopname = GetPostString("shopname");
  5032. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5033. string buyernick = GetPostString("buyer_nick");
  5034. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5035. string customer = GetPostString("customer");
  5036. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5037. string design = GetPostString("design");
  5038. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5039. string sellermemo = GetPostString("seller_memo");
  5040. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5041. string logistics = GetPostString("logistics");
  5042. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5043. string date1 = GetPostString("date1");
  5044. string date2 = GetPostString("date2");
  5045. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5046. //if (dw.Length > 0) lw.Add(dw);
  5047. string placedate1 = GetPostString("placedate1");
  5048. string placedate2 = GetPostString("placedate2");
  5049. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5050. if (fdw.Length > 0) lw.Add(fdw);
  5051. string devdate1 = GetPostString("deliverydate1");
  5052. string devdate2 = GetPostString("deliverydate2");
  5053. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5054. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5055. string price1 = GetPostString("price1");
  5056. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5057. string price2 = GetPostString("price2");
  5058. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5059. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5060. {
  5061. if (tid.Length > 0)
  5062. {
  5063. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5064. if (tid.Length > 5)
  5065. {
  5066. List<string> tids = getTidByCtidLike(tid);
  5067. if (tids.Count > 0 && tids.Count < 10)
  5068. {
  5069. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5070. }
  5071. }
  5072. lw.Add(tid_sql);
  5073. }
  5074. if (buyernick.Length > 0)
  5075. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5076. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5077. if (dw.Length > 0) lw.Add(dw);
  5078. }
  5079. else
  5080. {
  5081. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5082. }
  5083. string posTag = CurrentUser.UserPost.Post.Code;
  5084. if (posTag == "Supplier")
  5085. {
  5086. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5087. }
  5088. else
  5089. {
  5090. string supplier = GetPostString("supplier");
  5091. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5092. }
  5093. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5094. lw.Add(string.Format("type = 'PDD' "));
  5095. lw.Add(string.Format("IsRefund!={0}", 2));
  5096. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5097. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5098. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5099. /* if (tid.Length > 0)
  5100. {
  5101. List<string> tids = new List<string>();
  5102. if (dt != null && dt.Rows.Count > 0)
  5103. {
  5104. foreach (DataRow item in dt.Rows)
  5105. {
  5106. tids.Add("'" + item["tid"] + "'");
  5107. }
  5108. }
  5109. if (tids.Count > 0)
  5110. {
  5111. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5112. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5113. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5114. dt = WebCache.GetData("view_erptradecell", dStruct);
  5115. }
  5116. }*/
  5117. foreach (DataRow dr in dt.Rows)
  5118. {
  5119. dr["receiver_address"] = dr["receiver_name"].ToString() + " " + dr["receiver_mobile"].ToString() + " " + dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_district"].ToString() + dr["receiver_address"].ToString();
  5120. }
  5121. writeGridDataTableJson(dStruct.TotalCount, dt);
  5122. }
  5123. public void get_erp_jddeliveryed()
  5124. {
  5125. DataStruct dStruct = GetPostStruct();
  5126. List<string> lw = new List<string>();
  5127. string tid = GetPostString("ctid");
  5128. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5129. string shopname = GetPostString("shopname");
  5130. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5131. string buyernick = GetPostString("buyer_nick");
  5132. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5133. string customer = GetPostString("customer");
  5134. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5135. string design = GetPostString("design");
  5136. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5137. string sellermemo = GetPostString("seller_memo");
  5138. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5139. string date1 = GetPostString("date1");
  5140. string date2 = GetPostString("date2");
  5141. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5142. //if (dw.Length > 0) lw.Add(dw);
  5143. string placedate1 = GetPostString("placedate1");
  5144. string placedate2 = GetPostString("placedate2");
  5145. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5146. if (fdw.Length > 0) lw.Add(fdw);
  5147. string devdate1 = GetPostString("deliverydate1");
  5148. string devdate2 = GetPostString("deliverydate2");
  5149. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5150. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5151. string price1 = GetPostString("price1");
  5152. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5153. string price2 = GetPostString("price2");
  5154. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5155. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5156. {
  5157. if (tid.Length > 0)
  5158. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5159. if (buyernick.Length > 0)
  5160. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5161. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5162. if (dw.Length > 0) lw.Add(dw);
  5163. }
  5164. else
  5165. {
  5166. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5167. }
  5168. string posTag = CurrentUser.UserPost.Post.Code;
  5169. if (posTag == "Supplier")
  5170. {
  5171. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5172. }
  5173. else
  5174. {
  5175. string supplier = GetPostString("supplier");
  5176. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5177. }
  5178. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5179. lw.Add(string.Format("type = 'JD' "));
  5180. lw.Add(string.Format("IsRefund!={0}", 2));
  5181. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5182. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5183. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5184. foreach (DataRow dr in dt.Rows)
  5185. {
  5186. 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();
  5187. }
  5188. writeGridDataTableJson(dStruct.TotalCount, dt);
  5189. }
  5190. public void get_erp_allplacelist()
  5191. {
  5192. DataStruct dStruct = GetPostStruct();
  5193. List<string> lw = new List<string>();
  5194. string tid = GetPostString("ctid");
  5195. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5196. string shopname = GetPostString("shopname");
  5197. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5198. string buyernick = GetPostString("buyer_nick");
  5199. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5200. string customer = GetPostString("customer");
  5201. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5202. string design = GetPostString("design");
  5203. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5204. string sellermemo = GetPostString("seller_memo");
  5205. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5206. string supplier = GetPostString("supplier");
  5207. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5208. string date1 = GetPostString("date1");
  5209. string date2 = GetPostString("date2");
  5210. string pldate1 = GetPostString("placedate1");
  5211. string pldate2 = GetPostString("placedate2");
  5212. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5213. //if (dw.Length > 0) lw.Add(dw);
  5214. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5215. {
  5216. if (tid.Length > 0)
  5217. {
  5218. string select_tid = getTidByCtid(tid);
  5219. lw.Add(string.Format("tid='{0}'", select_tid));
  5220. }
  5221. if (buyernick.Length > 0)
  5222. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5223. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5224. if (dw.Length > 0) lw.Add(dw);
  5225. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5226. if (dw_place.Length > 0) lw.Add(dw_place);
  5227. }
  5228. else
  5229. {
  5230. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5231. {
  5232. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5233. }
  5234. }
  5235. string price1 = GetPostString("price1");
  5236. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5237. string price2 = GetPostString("price2");
  5238. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5239. string posTag = CurrentUser.UserPost.Post.Code;
  5240. if (posTag == "Supplier")
  5241. {
  5242. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5243. }
  5244. lw.Add(string.Format("OrderState >= 6"));
  5245. lw.Add(string.Format("IsSample != 2 "));
  5246. //lw.Add(string.Format("isDianziOrder = 0 "));
  5247. lw.Add(string.Format("SupplierId > 0 "));
  5248. //lw.Add(string.Format("IsRefund<={0}", 1));
  5249. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5250. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5251. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5252. foreach (DataRow dr in dt.Rows)
  5253. {
  5254. 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();
  5255. }
  5256. writeGridDataTableJson(dStruct.TotalCount, dt);
  5257. }
  5258. public void get_erp_financeallplacelist()
  5259. {
  5260. DataStruct dStruct = GetPostStruct();
  5261. List<string> lw = new List<string>();
  5262. string tid = GetPostString("ctid");
  5263. string shopname = GetPostString("shopname");
  5264. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5265. string buyernick = GetPostString("buyer_nick");
  5266. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5267. string customer = GetPostString("customer");
  5268. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5269. string design = GetPostString("design");
  5270. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5271. string sellermemo = GetPostString("seller_memo");
  5272. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5273. string supplier = GetPostString("supplier");
  5274. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5275. string date1 = GetPostString("date1");
  5276. string date2 = GetPostString("date2");
  5277. string pldate1 = GetPostString("placedate1");
  5278. string pldate2 = GetPostString("placedate2");
  5279. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5280. {
  5281. if (tid.Length > 0)
  5282. {
  5283. string select_tid = getTidByCtid(tid);
  5284. lw.Add(string.Format("tid='{0}'", select_tid));
  5285. }
  5286. if (buyernick.Length > 0)
  5287. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5288. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5289. if (dw.Length > 0) lw.Add(dw);
  5290. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5291. if (dw_place.Length > 0) lw.Add(dw_place);
  5292. }
  5293. else
  5294. {
  5295. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5296. {
  5297. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5298. }
  5299. }
  5300. string price1 = GetPostString("price1");
  5301. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5302. string price2 = GetPostString("price2");
  5303. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5304. string posTag = CurrentUser.UserPost.Post.Code;
  5305. if (posTag == "Supplier")
  5306. {
  5307. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5308. }
  5309. //lw.Add(string.Format("OrderState >= 6"));
  5310. lw.Add(string.Format("IsSample != 2 "));
  5311. lw.Add(string.Format("isDianziOrder = 0 "));
  5312. //lw.Add(string.Format("IsRefund<={0}", 1));
  5313. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5314. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5315. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5316. foreach (DataRow dr in dt.Rows)
  5317. {
  5318. 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();
  5319. }
  5320. writeGridDataTableJson(dStruct.TotalCount, dt);
  5321. }
  5322. public void get_erp_expresslist()
  5323. {
  5324. int listtype = GetInt("ltype");
  5325. DataStruct dStruct = GetPostStruct();
  5326. List<string> lw = new List<string>();
  5327. string tid = GetPostString("tid");
  5328. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5329. string outsid = GetPostString("out_sid");
  5330. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5331. string importer = GetPostString("ImportUserName");
  5332. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5333. string file = GetPostString("import_file");
  5334. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5335. string printman = GetPostString("printman");
  5336. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5337. string date1 = GetPostString("date1");
  5338. string date2 = GetPostString("date2");
  5339. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5340. if (dw.Length > 0) lw.Add(dw);
  5341. string fdate1 = GetPostString("finishdate1");
  5342. string fdate2 = GetPostString("finishdate2");
  5343. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5344. if (fdw.Length > 0) lw.Add(fdw);
  5345. string supplierId = GetPostString("supplierId");
  5346. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5347. if (listtype == 1)
  5348. {
  5349. lw.Add(string.Format("importUserId !=0"));
  5350. }
  5351. string posTag = CurrentUser.UserPost.Post.Code;
  5352. if (posTag == "Supplier")
  5353. {
  5354. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5355. }
  5356. if (dStruct.PageSize != 100000)
  5357. {
  5358. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5359. }
  5360. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5361. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5362. writeGridDataTableJson(dStruct.TotalCount, dt);
  5363. }
  5364. public void set_erp_buchaorderdelivery()
  5365. {
  5366. if (UrlPostParmsCheck("ctid"))
  5367. {
  5368. string eid = GetPostString("ctid");
  5369. CeErpTradeCell entity = null;
  5370. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5371. if (entity != null)
  5372. {
  5373. if (entity.IsSample != 2)
  5374. {
  5375. returnErrorMsg("补差价单才能标记为已发货");
  5376. return;
  5377. }
  5378. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5379. entity.OrderState = 7;
  5380. entity.Update();
  5381. returnSuccessMsg("操作成功!");
  5382. return;
  5383. }
  5384. returnErrorMsg("找不到记录");
  5385. }
  5386. }
  5387. public void get_stdtemplates()
  5388. {
  5389. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5390. //string res = taobaoHelper.test();
  5391. string res = apiHelper.API_PrintTemplate();
  5392. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5393. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5394. {
  5395. int sidx = res.IndexOf("error_code");
  5396. int eidx = res.IndexOf("success");
  5397. string msg = res.Substring(sidx, eidx - sidx);
  5398. returnErrorMsg(msg);
  5399. return;
  5400. }
  5401. if (res.Length <= 0)
  5402. {
  5403. returnErrorMsg("模板数据为空!");
  5404. return;
  5405. }
  5406. ReturnSuccess(res);
  5407. }
  5408. public void cancel_print_order()
  5409. {
  5410. if (UrlPostParmsCheck("ctid"))
  5411. {
  5412. string ctid = GetPostString("ctid");
  5413. CeErpTradeCell entity = null;
  5414. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5415. if (entity != null)
  5416. {
  5417. string res = "";
  5418. string code = entity.LastBillWaybillCode;
  5419. if (code == "")
  5420. {
  5421. code = entity.OutSid;
  5422. }
  5423. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5424. XLog.SaveLog(0, "取消面单" + res);
  5425. }
  5426. }
  5427. }
  5428. public void set_erp_printwaybill()
  5429. {
  5430. if (UrlPostParmsCheck("ctid"))
  5431. {
  5432. string ctid = GetPostString("ctid");
  5433. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5434. string cpName = GetPostString("cpname");
  5435. string isTogether = GetPostString("together");
  5436. string printType = GetPostString("printType");
  5437. //var res_obj = new
  5438. //{
  5439. // restype = 1,
  5440. // 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\"}"
  5441. //};
  5442. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5443. //ReturnSuccess(ro_json);
  5444. //return;
  5445. bool isUseLastWayBillCode = false;
  5446. CeErpTradeCell entity = null;
  5447. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5448. if (entity != null)
  5449. {
  5450. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5451. {
  5452. isUseLastWayBillCode = true;
  5453. }
  5454. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5455. {
  5456. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5457. return;
  5458. }
  5459. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5460. {
  5461. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5462. return;
  5463. }
  5464. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5465. {
  5466. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5467. return;
  5468. }
  5469. }
  5470. string res = "";
  5471. Api_waybill_code_response_Obj fullObj = null;
  5472. string pData_str = "";
  5473. string curUseWayBillCode = "";
  5474. if (isUseLastWayBillCode == false)
  5475. {
  5476. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5477. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5478. if (res.IndexOf("failure") != -1)
  5479. {
  5480. //int idx = res.IndexOf("sub_message");
  5481. //int idx2 = res.IndexOf("flag");
  5482. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5483. string errMsgNeed = commonHelper.KeepChinese(res);
  5484. var res_objd = new
  5485. {
  5486. restype = 0,
  5487. data = "获取面单失败" + errMsgNeed
  5488. };
  5489. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5490. returnSuccess(ro_jsond);
  5491. if (res.IndexOf("停发") != -1)
  5492. {
  5493. entity.UnusualCon = "物流停发";
  5494. entity.Update();
  5495. }
  5496. //returnErrorMsg("获取面单失败,"+emsg);
  5497. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5498. return;
  5499. }
  5500. else if (res.IndexOf("errorMsg") != -1)
  5501. {
  5502. //int idx = res.IndexOf("errorMsg");
  5503. //int idx2 = res.IndexOf("}]}");
  5504. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5505. string errMsgNeed = commonHelper.KeepChinese(res);
  5506. var res_objf = new
  5507. {
  5508. restype = 0,
  5509. data = "获取面单失败2" + errMsgNeed
  5510. };
  5511. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5512. if (res.IndexOf("停发") != -1)
  5513. {
  5514. entity.UnusualCon = "物流停发";
  5515. entity.Update();
  5516. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5517. if (trade != null)
  5518. {
  5519. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5520. }
  5521. }
  5522. returnSuccess(ro_jsonf);
  5523. //returnErrorMsg("获取面单失败," + emsg);
  5524. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5525. return;
  5526. }
  5527. try
  5528. {
  5529. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5530. //res = res.Replace(" ", "");
  5531. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5532. }
  5533. catch (Exception ex)
  5534. {
  5535. XLog.SaveLog(0, "生成fullObj" + res);
  5536. var res_objf = new
  5537. {
  5538. restype = 0,
  5539. data = "生成fullObj发生错误" + ex.Message
  5540. };
  5541. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5542. returnSuccess(ro_jsonf);
  5543. return;
  5544. }
  5545. if (fullObj.response.data.content.Count > 0)
  5546. {
  5547. ContentItem codeObj = fullObj.response.data.content[0];
  5548. if (cpCode.IndexOf("SFFQ-") != -1)
  5549. {
  5550. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5551. }
  5552. else
  5553. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5554. curUseWayBillCode = codeObj.waybillCode;
  5555. }
  5556. else
  5557. {
  5558. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5559. var res_objf = new
  5560. {
  5561. restype = 0,
  5562. data = "生成fullObj找不到快递单号waybillCode"
  5563. };
  5564. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5565. returnSuccess(ro_jsonf);
  5566. return;
  5567. }
  5568. }
  5569. else
  5570. {
  5571. //使用上次打印的快递单号
  5572. if (cpCode == "SFFQ-LY")
  5573. {
  5574. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5575. }
  5576. else
  5577. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5578. curUseWayBillCode = entity.LastBillWaybillCode;
  5579. }
  5580. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5581. {
  5582. var res_obje = new
  5583. {
  5584. restype = 0,
  5585. data = "获取加密打印数据失败"
  5586. };
  5587. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5588. returnSuccess(ro_jsone);
  5589. entity.LastBillCpCode = cpCode;
  5590. entity.LastBillWaybillCode = curUseWayBillCode;
  5591. entity.Update();
  5592. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5593. //returnErrorMsg("获取加密打印数据失败");
  5594. return;
  5595. }
  5596. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5597. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5598. string btnType = "";
  5599. string errorMsg = "";
  5600. if (entity != null)
  5601. {
  5602. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5603. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5604. //cpcode是 YTO-CAINIAO
  5605. //string comCode = cpCode.Split('-')[0].ToString();
  5606. string apires = "";
  5607. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5608. //isTogether=2是新的合包弹窗
  5609. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5610. {
  5611. if (ctid.IndexOf("N") != -1)
  5612. {
  5613. apires = "发货成功";
  5614. }
  5615. else
  5616. {
  5617. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5618. }
  5619. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5620. //打单后发货
  5621. StringBuilder sql = new StringBuilder();
  5622. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5623. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5624. {
  5625. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5626. }
  5627. else
  5628. {
  5629. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5630. }
  5631. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5632. foreach (DataRow row in dt.Rows)
  5633. {
  5634. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5635. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5636. {
  5637. try
  5638. {
  5639. btnType = "待发货";
  5640. entity.OutSid = curUseWayBillCode;
  5641. entity.OrderState = 7;
  5642. entity.IsUrgency = false;
  5643. entity.LastBillCpCode = "";
  5644. entity.LastBillWaybillCode = "";
  5645. entity.FinishDeliveryTime = DateTime.Now;
  5646. entity.IsReturn = 0;
  5647. entity.MemoOpt = 0;
  5648. entity.UpdateTime = DateTime.Now;
  5649. entity.Update();
  5650. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5651. //还要插入快递信息到 快递信息表
  5652. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5653. exinfo.tid = entity.ctid;
  5654. exinfo.out_sid = curUseWayBillCode;
  5655. exinfo.company_code = cpCode;
  5656. exinfo.company_name = cpName;
  5657. exinfo.supplierUserName = supplierName;
  5658. exinfo.deliveryType = "发货成功";
  5659. exinfo.print_time = DateTime.Now;
  5660. exinfo.printUser = CurrentUser.UserName;
  5661. exinfo.postData = pData_str;
  5662. exinfo.Create();
  5663. commonHelper.UpdateRelationOrder(entity.ctid);
  5664. CeErpSukuraData.createInfo(ctid, 4);
  5665. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5666. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5667. {
  5668. commonHelper.sendCytExpress(exinfo);
  5669. }
  5670. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5671. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5672. }
  5673. catch (Exception ex)
  5674. {
  5675. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5676. }
  5677. }
  5678. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5679. {
  5680. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5681. if (entity.OrderState == 6)
  5682. {
  5683. entity.OrderState = 7;
  5684. }
  5685. entity.UpdateTime = DateTime.Now;
  5686. entity.FinishDeliveryTime = DateTime.Now;
  5687. btnType = "已发货";
  5688. entity.Update();
  5689. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5690. exinfo.tid = entity.ctid;
  5691. exinfo.out_sid = curUseWayBillCode;
  5692. exinfo.company_code = cpCode;
  5693. exinfo.company_name = cpName;
  5694. exinfo.supplierUserName = supplierName;
  5695. exinfo.deliveryType = "发货成功";
  5696. exinfo.print_time = DateTime.Now;
  5697. exinfo.printUser = CurrentUser.UserName;
  5698. exinfo.postData = pData_str;
  5699. exinfo.Create();
  5700. commonHelper.UpdateRelationOrder(entity.ctid);
  5701. CeErpSukuraData.createInfo(entity.ctid, 4);
  5702. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5703. {
  5704. commonHelper.sendCytExpress(exinfo);
  5705. }
  5706. //不处理
  5707. }
  5708. else
  5709. {
  5710. entity.UpdateTime = DateTime.Now;
  5711. entity.LastBillCpCode = cpCode;
  5712. entity.LastBillWaybillCode = curUseWayBillCode;
  5713. entity.Update();
  5714. string errmsg = commonHelper.KeepChinese(apires);
  5715. var res_objz = new
  5716. {
  5717. restype = 0,
  5718. data = "打单后发货失败"
  5719. };
  5720. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5721. returnSuccess(ro_jsonz);
  5722. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5723. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5724. return;
  5725. }
  5726. }
  5727. }
  5728. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5729. {
  5730. string ctids = GetPostString("ctids");
  5731. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5732. List<string> list = new List<string>();
  5733. List<string> send_list = new List<string>();
  5734. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5735. CeErpTrade ceErpTrade = new CeErpTrade();
  5736. //可合包的合并一起发货
  5737. if (dt == null && string.IsNullOrEmpty(ctids))
  5738. {
  5739. var res_objz = new
  5740. {
  5741. restype = 0,
  5742. data = "打单后发货失败"
  5743. };
  5744. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5745. returnSuccess(ro_jsonz);
  5746. return;
  5747. }
  5748. if (!string.IsNullOrEmpty(ctids))
  5749. {
  5750. StringBuilder sql = new StringBuilder();
  5751. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5752. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5753. }
  5754. foreach (DataRow row in dt.Rows)
  5755. {
  5756. list.Add("'" + row["ctid"] + "'");
  5757. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5758. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5759. if (ctid.IndexOf("N") != -1)
  5760. {
  5761. apires = "发货成功";
  5762. }
  5763. else
  5764. {
  5765. if (!send_list.Contains(ceErpTrade.tid))
  5766. {
  5767. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5768. }
  5769. else
  5770. {
  5771. apires = "发货成功";
  5772. }
  5773. }
  5774. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5775. {
  5776. send_list.Add(ceErpTrade.tid);
  5777. try
  5778. {
  5779. btnType = "待发货";
  5780. ceErpTradeCell.OutSid = curUseWayBillCode;
  5781. ceErpTradeCell.OrderState = 7;
  5782. ceErpTradeCell.IsUrgency = false;
  5783. ceErpTradeCell.LastBillCpCode = "";
  5784. ceErpTradeCell.LastBillWaybillCode = "";
  5785. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5786. ceErpTradeCell.IsReturn = 0;
  5787. ceErpTradeCell.MemoOpt = 0;
  5788. ceErpTradeCell.UpdateTime = DateTime.Now;
  5789. ceErpTradeCell.Update();
  5790. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5791. //还要插入快递信息到 快递信息表
  5792. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5793. exinfo.tid = ceErpTradeCell.ctid;
  5794. exinfo.out_sid = curUseWayBillCode;
  5795. exinfo.company_code = cpCode;
  5796. exinfo.company_name = cpName;
  5797. exinfo.supplierUserName = supplierName;
  5798. exinfo.deliveryType = "发货成功";
  5799. exinfo.print_time = DateTime.Now;
  5800. exinfo.printUser = CurrentUser.UserName;
  5801. exinfo.postData = pData_str;
  5802. exinfo.Create();
  5803. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5804. CeErpSukuraData.createInfo(ctid, 4);
  5805. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5806. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5807. {
  5808. commonHelper.sendCytExpress(exinfo);
  5809. }
  5810. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5811. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5812. }
  5813. catch (Exception ex)
  5814. {
  5815. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5816. }
  5817. }
  5818. else
  5819. {
  5820. ceErpTradeCell.UpdateTime = DateTime.Now;
  5821. ceErpTradeCell.LastBillCpCode = cpCode;
  5822. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5823. ceErpTradeCell.Update();
  5824. string errmsg = commonHelper.KeepChinese(apires);
  5825. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5826. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5827. }
  5828. }
  5829. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5830. }
  5831. }
  5832. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5833. var res_obj = new
  5834. {
  5835. restype = 1,
  5836. data = pData_str,
  5837. errorMsg
  5838. };
  5839. string ro_json = JsonConvert.SerializeObject(res_obj);
  5840. ReturnSuccess(ro_json);
  5841. return;
  5842. }
  5843. }
  5844. private string GetUTF8String(byte[] vs)
  5845. {
  5846. throw new NotImplementedException();
  5847. }
  5848. public void set_erp_printwaybill_cn()
  5849. {
  5850. if (UrlPostParmsCheck("ctid"))
  5851. {
  5852. string ctid = GetPostString("ctid");
  5853. string cpCode = GetPostString("cpcode");
  5854. string cpName = GetPostString("cpname");
  5855. string tempUrl = GetPostString("tempurl");
  5856. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5857. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5858. //string res = taobaoHelper.test();
  5859. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5860. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5861. {
  5862. int sidx = res.IndexOf("errorMsg");
  5863. int eidx = res.IndexOf("}");
  5864. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5865. var res_objzxx = new
  5866. {
  5867. restype = 0,
  5868. data = msg
  5869. };
  5870. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5871. returnSuccess(ro_jsonzxx);
  5872. //returnErrorMsg(msg);
  5873. return;
  5874. }
  5875. int idx = res.IndexOf("waybillCode");
  5876. int idx2 = res.IndexOf("printData");
  5877. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5878. string eid = GetPostString("ctid");
  5879. CeErpTradeCell entity = null;
  5880. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5881. if (entity != null)
  5882. {
  5883. string osid = entity.OutSid;
  5884. entity.OutSid = osid + "," + outsid;
  5885. entity.FinishDeliveryTime = DateTime.Now;
  5886. entity.OrderState = 7;
  5887. entity.UpdateTime = DateTime.Now;
  5888. entity.IsReturn = 0;
  5889. entity.Update();
  5890. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5891. exinfo.tid = entity.ctid;
  5892. exinfo.out_sid = outsid;
  5893. exinfo.company_code = cpCode;
  5894. exinfo.company_name = cpName;
  5895. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5896. exinfo.deliveryType = "发货成功";
  5897. exinfo.print_time = DateTime.Now;
  5898. exinfo.printUser = CurrentUser.UserName;
  5899. exinfo.Create();
  5900. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5901. {
  5902. commonHelper.sendCytExpress(exinfo);
  5903. }
  5904. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5905. }
  5906. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5907. var res_objz = new
  5908. {
  5909. restype = 1,
  5910. data = res
  5911. };
  5912. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5913. returnSuccess(ro_jsonz);
  5914. //ReturnSuccess(res);
  5915. }
  5916. }
  5917. ////打单,打印面单 获取面单号
  5918. //public void set_erp_printwaybill()
  5919. //{
  5920. // if (UrlPostParmsCheck("ctid"))
  5921. // {
  5922. // string ctid = GetPostString("ctid");
  5923. // string cpCode = GetPostString("cpcode");
  5924. // string tempUrl = GetPostString("tempurl");
  5925. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5926. // //string res = taobaoHelper.test();
  5927. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5928. // if (res.IndexOf("error_response") != -1)
  5929. // {
  5930. // int sidx = res.IndexOf("sub_msg");
  5931. // int eidx = res.IndexOf("request_id");
  5932. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5933. // returnErrorMsg(msg);
  5934. // return;
  5935. // }
  5936. // int idx = res.IndexOf("waybill_code");
  5937. // int idx2 = res.IndexOf("}]}");
  5938. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5939. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5940. // ReturnSuccess(res);
  5941. // }
  5942. //}
  5943. public void cancel_erp_aftersale()
  5944. {
  5945. if (UrlPostParmsCheck("ctid"))
  5946. {
  5947. string eid = GetPostString("ctid");
  5948. CeErpTradeCell entity = null;
  5949. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5950. if (entity != null)
  5951. {
  5952. //有过处理的售后,取消也不能删除 售 字,保留
  5953. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5954. {
  5955. entity.AfterSaleState = 4;
  5956. }
  5957. else
  5958. entity.AfterSaleState = 0;
  5959. entity.UpdateTime = DateTime.Now;
  5960. entity.Update();
  5961. returnSuccessMsg("操作成功!");
  5962. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5963. return;
  5964. }
  5965. returnErrorMsg("找不到订单记录");
  5966. }
  5967. }
  5968. public void get_erp_aftersalelist()
  5969. {
  5970. DataStruct dStruct = GetPostStruct();
  5971. List<string> lw = new List<string>();
  5972. int st = GetInt("st");
  5973. string tid = GetPostString("ctid");
  5974. if (st == 3)
  5975. {
  5976. if (tid.Length > 0)
  5977. {
  5978. string select_tid = getTidByCtid(tid);
  5979. lw.Add(string.Format("tid='{0}'", select_tid));
  5980. }
  5981. }
  5982. else
  5983. {
  5984. if (tid.Length > 0)
  5985. {
  5986. string select_tid = getTidByCtid(tid);
  5987. lw.Add(string.Format("tid='{0}'", select_tid));
  5988. }
  5989. }
  5990. string shopname = GetPostString("shopname");
  5991. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5992. string buyernick = GetPostString("buyer_nick");
  5993. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5994. string sellermemo = GetPostString("seller_memo");
  5995. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5996. string orderState = GetPostString("orderState");
  5997. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5998. string afterState = GetPostString("afterstate");
  5999. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6000. string date1 = GetPostString("date1");
  6001. string date2 = GetPostString("date2");
  6002. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6003. if (dw.Length > 0) lw.Add(dw);
  6004. string price1 = GetPostString("price1");
  6005. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6006. string price2 = GetPostString("price2");
  6007. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6008. //lw.Add(string.Format("IsRefund!={0}", 1));
  6009. string reason = GetPostString("reason");
  6010. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6011. string method = GetPostString("method");
  6012. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6013. string handler = GetPostString("handler");
  6014. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6015. string handledate1 = GetPostString("handledate1");
  6016. string handledate2 = GetPostString("handledate2");
  6017. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6018. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6019. string finish1 = GetPostString("finishdate1");
  6020. string finish2 = GetPostString("finishdate2");
  6021. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6022. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6023. string afterdate1 = GetPostString("afterdate1");
  6024. string afterdate2 = GetPostString("afterdate2");
  6025. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6026. if (afterDate.Length > 0) lw.Add(afterDate);
  6027. string supplier = GetPostString("supplier");
  6028. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6029. string responsible = GetPostString("responsibleman");
  6030. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6031. string customer = GetPostString("customer");
  6032. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6033. string design = GetPostString("design");
  6034. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6035. string afterMemoType = GetPostString("aftermemotype");
  6036. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6037. string posCode = CurrentUser.UserPost.Post.Code;
  6038. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6039. //{
  6040. // string vstate = GetPostString("vstate");
  6041. // if (vstate.Length > 0)
  6042. // {
  6043. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6044. // }
  6045. // if (posCode == "Supplier")
  6046. // {
  6047. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6048. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6049. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6050. // }
  6051. // else
  6052. // {
  6053. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6054. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6055. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6056. // {
  6057. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6058. // }
  6059. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6060. // {
  6061. // int orgid = CurrentUser.UserPost.OrgID;
  6062. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6063. // }
  6064. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6065. // {
  6066. // string shopid = CurrentUser.User.pemShop;
  6067. // lw.Add(string.Format("shopId in ({0})", shopid));
  6068. // }
  6069. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6070. // //{
  6071. // // int org_id = CurrentUser.UserPost.OrgID;
  6072. // // lw.Add(string.Format("OrgID={0}", org_id));
  6073. // //}
  6074. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6075. // }
  6076. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6077. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6078. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6079. //}
  6080. if (st == 5)
  6081. {
  6082. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6083. {
  6084. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6085. {
  6086. string shopid = CurrentUser.User.pemShop;
  6087. lw.Add(string.Format("shopId in ({0})", shopid));
  6088. }
  6089. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6090. {
  6091. int mrOrgid = CurrentUser.UserPost.OrgID;
  6092. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6093. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6094. }
  6095. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6096. //{
  6097. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6098. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6099. //}
  6100. else
  6101. {
  6102. string userIdStr = "";
  6103. if (posCode == "CustomerService")
  6104. {
  6105. userIdStr = CurrentUser.UserID + "_k";
  6106. }
  6107. else if (posCode == "Designer" || posCode == "wxDesigner")
  6108. {
  6109. userIdStr = CurrentUser.UserID + "_s";
  6110. }
  6111. else if (posCode == "Place")
  6112. {
  6113. userIdStr = CurrentUser.UserID + "_x";
  6114. }
  6115. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6116. }
  6117. }
  6118. string placedate1 = GetPostString("placedate1");
  6119. string placedate2 = GetPostString("placedate2");
  6120. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6121. if (dwplace.Length > 0) lw.Add(dwplace);
  6122. string supState = GetPostString("supState");
  6123. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6124. string searchType = GetPostString("searchType");
  6125. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6126. {
  6127. lw.Add(string.Format("BackNum>1"));
  6128. }
  6129. lw.Add(string.Format("AfterSaleState>0"));
  6130. if (ex_psize > 0)
  6131. {
  6132. if (CurrentUser.UserPost.Post.Code == "Finance")
  6133. dStruct.Order = "pay_time desc";
  6134. else
  6135. dStruct.Order = "HandleTime desc";
  6136. }
  6137. else
  6138. dStruct.Order = "HandleTime desc";
  6139. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6140. DataTable dt = WebCache.GetData("view_test", dStruct);
  6141. writeGridDataTableJson(dStruct.TotalCount, dt);
  6142. }
  6143. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6144. //{
  6145. // lw.Add(string.Format("AfterSaleState=4"));
  6146. // string code = CurrentUser.UserPost.Post.Code;
  6147. // if (code == "CustomerService")
  6148. // {
  6149. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6150. // }
  6151. // else if (code == "Designer" || code == "DesignerMr")
  6152. // {
  6153. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6154. // }
  6155. // else if (code == "Place" || code == "PlaceMr")
  6156. // {
  6157. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6158. // }
  6159. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6160. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6161. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6162. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6163. //}
  6164. //else //处理中的售后,待处理和处理中合并
  6165. //{
  6166. // if (afterState.Length <= 0)
  6167. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6168. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6169. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6170. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6171. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6172. //}
  6173. }
  6174. public void get_erp_disagreeftersalelist()
  6175. {
  6176. DataStruct dStruct = GetPostStruct();
  6177. List<string> lw = new List<string>();
  6178. int st = 2;
  6179. string tid = GetPostString("ctid");
  6180. if (tid.Length > 0)
  6181. {
  6182. string select_tid = getTidByCtid(tid);
  6183. lw.Add(string.Format("tid='{0}'", select_tid));
  6184. }
  6185. string shopname = GetPostString("shopname");
  6186. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6187. string buyernick = GetPostString("buyer_nick");
  6188. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6189. string sellermemo = GetPostString("seller_memo");
  6190. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6191. string orderState = GetPostString("orderState");
  6192. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6193. string afterState = GetPostString("afterstate");
  6194. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6195. string date1 = GetPostString("date1");
  6196. string date2 = GetPostString("date2");
  6197. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6198. if (dw.Length > 0) lw.Add(dw);
  6199. string price1 = GetPostString("price1");
  6200. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6201. string price2 = GetPostString("price2");
  6202. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6203. //lw.Add(string.Format("IsRefund!={0}", 1));
  6204. string reason = GetPostString("reason");
  6205. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6206. string method = GetPostString("method");
  6207. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6208. string handler = GetPostString("handler");
  6209. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6210. string handledate1 = GetPostString("handledate1");
  6211. string handledate2 = GetPostString("handledate2");
  6212. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6213. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6214. string afterdate1 = GetPostString("afterdate1");
  6215. string afterdate2 = GetPostString("afterdate2");
  6216. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6217. if (afterDate.Length > 0) lw.Add(afterDate);
  6218. string backdate1 = GetPostString("backdate1");
  6219. string backdate2 = GetPostString("backdate2");
  6220. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6221. if (backDate.Length > 0) lw.Add(backDate);
  6222. string supplier = GetPostString("supplier");
  6223. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6224. string responsible = GetPostString("responsibleman");
  6225. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6226. string customer = GetPostString("customer");
  6227. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6228. string design = GetPostString("design");
  6229. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6230. string afterSaleMemo = GetPostString("afterSaleMemo");
  6231. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6232. string afterMemoType = GetPostString("aftermemotype");
  6233. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6234. string aftersakereason = GetPostString("aftersakereason");
  6235. if (aftersakereason.Length > 0)
  6236. {
  6237. if (aftersakereason == "1")
  6238. {
  6239. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6240. }
  6241. if (aftersakereason == "2")
  6242. {
  6243. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6244. }
  6245. }
  6246. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6247. string poscode = CurrentUser.UserPost.Post.Code;
  6248. if (poscode != "SysAdmin")
  6249. {
  6250. string shopid = CurrentUser.User.pemShop;
  6251. lw.Add(string.Format("shopId in ({0})", shopid));
  6252. }
  6253. string searchType = GetPostString("searchType");
  6254. if (searchType == "wait")
  6255. {
  6256. lw.Add(string.Format("HandleTime is null"));
  6257. }
  6258. if (searchType == "handling")
  6259. {
  6260. lw.Add(string.Format("HandleTime is not null "));
  6261. }
  6262. if (searchType == "back" || searchType == "puBack")
  6263. {
  6264. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6265. }
  6266. if (searchType == "reBack")
  6267. {
  6268. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6269. }
  6270. if (searchType == "moreBack")
  6271. {
  6272. lw.Add(string.Format("backNum > 1"));
  6273. }
  6274. lw.Add(string.Format("(AfterSaleState=5)"));
  6275. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6276. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6277. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6278. writeGridDataTableJson(dStruct.TotalCount, dt);
  6279. }
  6280. public void get_erp_handlingaftersalelist()
  6281. {
  6282. DataStruct dStruct = GetPostStruct();
  6283. List<string> lw = new List<string>();
  6284. int st = 2;
  6285. string tid = GetPostString("ctid");
  6286. if (tid.Length > 0)
  6287. {
  6288. string select_tid = getTidByCtid(tid);
  6289. lw.Add(string.Format("tid='{0}'", select_tid));
  6290. }
  6291. string shopname = GetPostString("shopname");
  6292. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6293. string buyernick = GetPostString("buyer_nick");
  6294. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6295. string sellermemo = GetPostString("seller_memo");
  6296. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6297. string orderState = GetPostString("orderState");
  6298. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6299. string afterState = GetPostString("afterstate");
  6300. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6301. string date1 = GetPostString("date1");
  6302. string date2 = GetPostString("date2");
  6303. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6304. if (dw.Length > 0) lw.Add(dw);
  6305. string price1 = GetPostString("price1");
  6306. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6307. string price2 = GetPostString("price2");
  6308. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6309. //lw.Add(string.Format("IsRefund!={0}", 1));
  6310. string reason = GetPostString("reason");
  6311. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6312. string method = GetPostString("method");
  6313. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6314. string handler = GetPostString("handler");
  6315. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6316. string handledate1 = GetPostString("handledate1");
  6317. string handledate2 = GetPostString("handledate2");
  6318. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6319. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6320. string afterdate1 = GetPostString("afterdate1");
  6321. string afterdate2 = GetPostString("afterdate2");
  6322. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6323. if (afterDate.Length > 0) lw.Add(afterDate);
  6324. string supplier = GetPostString("supplier");
  6325. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6326. string responsible = GetPostString("responsibleman");
  6327. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6328. string customer = GetPostString("customer");
  6329. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6330. string design = GetPostString("design");
  6331. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6332. string afterSaleMemo = GetPostString("afterSaleMemo");
  6333. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6334. string afterMemoType = GetPostString("aftermemotype");
  6335. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6336. string afterresult = GetPostString("afterresult");
  6337. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6338. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6339. string poscode = CurrentUser.UserPost.Post.Code;
  6340. if (poscode != "SysAdmin")
  6341. {
  6342. string shopid = CurrentUser.User.pemShop;
  6343. lw.Add(string.Format("shopId in ({0})", shopid));
  6344. }
  6345. string searchType = GetPostString("searchType");
  6346. if (searchType == "wait")
  6347. {
  6348. lw.Add(string.Format("HandleTime is null"));
  6349. }
  6350. if (searchType == "documentary")
  6351. {
  6352. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6353. }
  6354. if (searchType == "handling")
  6355. {
  6356. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6357. }
  6358. if (searchType == "back" || searchType == "puBack")
  6359. {
  6360. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6361. }
  6362. if (searchType == "reBack")
  6363. {
  6364. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6365. }
  6366. if (afterState.Length <= 0)
  6367. {
  6368. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6369. }
  6370. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6371. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6372. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6373. writeGridDataTableJson(dStruct.TotalCount, dt);
  6374. }
  6375. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6376. //public void get_erp_back_handlingaftersalelist()
  6377. //{
  6378. // DataStruct dStruct = GetPostStruct();
  6379. // List<string> lw = new List<string>();
  6380. // string tid = GetPostString("ctid");
  6381. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6382. // string shopname = GetPostString("shopname");
  6383. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6384. // string buyernick = GetPostString("buyer_nick");
  6385. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6386. // string sellermemo = GetPostString("seller_memo");
  6387. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6388. // string orderState = GetPostString("orderState");
  6389. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6390. // string afterState = GetPostString("afterstate");
  6391. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6392. // string date1 = GetPostString("date1");
  6393. // string date2 = GetPostString("date2");
  6394. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6395. // if (dw.Length > 0) lw.Add(dw);
  6396. // string price1 = GetPostString("price1");
  6397. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6398. // string price2 = GetPostString("price2");
  6399. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6400. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6401. // string reason = GetPostString("reason");
  6402. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6403. // string method = GetPostString("method");
  6404. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6405. // string handler = GetPostString("handler");
  6406. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6407. // string handledate1 = GetPostString("handledate1");
  6408. // string handledate2 = GetPostString("handledate2");
  6409. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6410. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6411. // string afterdate1 = GetPostString("afterdate1");
  6412. // string afterdate2 = GetPostString("afterdate2");
  6413. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6414. // if (afterDate.Length > 0) lw.Add(afterDate);
  6415. // string supplier = GetPostString("supplier");
  6416. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6417. // string responsible = GetPostString("responsibleman");
  6418. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6419. // string customer = GetPostString("customer");
  6420. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6421. // string design = GetPostString("design");
  6422. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6423. // string afterMemoType = GetPostString("aftermemotype");
  6424. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6425. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6426. // if (afterState.Length <= 0)
  6427. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6428. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6429. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6430. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6431. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6432. //}
  6433. public void get_erp_aftersaleverifylist()
  6434. {
  6435. DataStruct dStruct = GetPostStruct();
  6436. List<string> lw = new List<string>();
  6437. string tid = GetPostString("ctid");
  6438. if (tid.Length > 0)
  6439. {
  6440. string select_tid = getTidByCtid(tid);
  6441. lw.Add(string.Format("otid='{0}'", select_tid));
  6442. }
  6443. string shopname = GetPostString("shopname");
  6444. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6445. string buyernick = GetPostString("buyer_nick");
  6446. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6447. string sellermemo = GetPostString("seller_memo");
  6448. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6449. string orderState = GetPostString("orderState");
  6450. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6451. //lw.Add(string.Format("IsRefund!={0}", 1));
  6452. string reason = GetPostString("reason");
  6453. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6454. string method = GetPostString("method");
  6455. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6456. string handler = GetPostString("handler");
  6457. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6458. string handledate1 = GetPostString("handledate1");
  6459. string handledate2 = GetPostString("handledate2");
  6460. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6461. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6462. string finish1 = GetPostString("finishdate1");
  6463. string finish2 = GetPostString("finishdate2");
  6464. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6465. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6466. string supplier = GetPostString("supplier");
  6467. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6468. string responsible = GetPostString("responsibleman");
  6469. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6470. string posCode = CurrentUser.UserPost.Post.Code;
  6471. string vstate = GetPostString("vstate");
  6472. if (vstate.Length > 0)
  6473. {
  6474. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6475. }
  6476. if (posCode == "Supplier")
  6477. {
  6478. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6479. lw.Add(string.Format("VerifyState = 0"));
  6480. lw.Add("type = 1");
  6481. lw.Add(string.Format("AfterSaleState={0}", 3));
  6482. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6483. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6484. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6485. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6486. writeGridDataTableJson(dStruct.TotalCount, dt);
  6487. }
  6488. else if (posCode == "logistics")
  6489. {
  6490. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6491. lw.Add(string.Format("VerifyState = 0"));
  6492. lw.Add("type = 2");
  6493. lw.Add(string.Format("AfterSaleState={0}", 3));
  6494. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6495. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6496. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6497. writeGridDataTableJson(dStruct.TotalCount, dt);
  6498. }
  6499. else
  6500. {
  6501. lw.Add(string.Format("(AfterSaleState = 3)"));
  6502. lw.Add("type = 0");
  6503. string reasonState = GetPostString("reasonState");
  6504. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6505. {
  6506. if (reasonState == "2")
  6507. {
  6508. lw.Add("VerifyState = 3");
  6509. }
  6510. else if (reasonState == "1")
  6511. {
  6512. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6513. }
  6514. else
  6515. {
  6516. lw.Add("VerifyState in (0,3)");
  6517. }
  6518. //不加条件,可以看全部
  6519. }
  6520. 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")
  6521. {
  6522. int orgid = CurrentUser.UserPost.OrgID;
  6523. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6524. if (string.IsNullOrEmpty(manageOrgId))
  6525. {
  6526. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6527. }
  6528. else
  6529. {
  6530. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6531. }
  6532. if (reasonState == "1")
  6533. {
  6534. lw.Add("VerifyState = 3");
  6535. }
  6536. else if (reasonState == "2")
  6537. {
  6538. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6539. }
  6540. else
  6541. {
  6542. }
  6543. }
  6544. else
  6545. {
  6546. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6547. }
  6548. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6549. //{
  6550. // int org_id = CurrentUser.UserPost.OrgID;
  6551. // lw.Add(string.Format("OrgID={0}", org_id));
  6552. //}
  6553. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6554. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6555. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6556. writeGridDataTableJson(dStruct.TotalCount, dt);
  6557. }
  6558. }
  6559. public void get_erp_finishaftersalelist()
  6560. {
  6561. DataStruct dStruct = GetPostStruct();
  6562. List<string> lw = new List<string>();
  6563. int st = 4;
  6564. string tid = GetPostString("ctid");
  6565. if (tid.Length > 0)
  6566. {
  6567. string select_tid = getTidByCtid(tid);
  6568. lw.Add(string.Format("otid='{0}'", select_tid));
  6569. }
  6570. string shopname = GetPostString("shopname");
  6571. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6572. //lw.Add(string.Format("IsRefund!={0}", 1));
  6573. string reason = GetPostString("reason");
  6574. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6575. string method = GetPostString("method");
  6576. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6577. string buyernick = GetPostString("buyer_nick");
  6578. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6579. string handler = GetPostString("handler");
  6580. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6581. string handledate1 = GetPostString("handledate1");
  6582. string handledate2 = GetPostString("handledate2");
  6583. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6584. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6585. string finish1 = GetPostString("finishdate1");
  6586. string finish2 = GetPostString("finishdate2");
  6587. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6588. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6589. string supplier = GetPostString("supplier");
  6590. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6591. string responsible = GetPostString("responsibleman");
  6592. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6593. string vstate = GetPostString("vstate");
  6594. if (vstate.Length > 0)
  6595. {
  6596. if ("3".Equals(vstate))
  6597. {
  6598. lw.Add(string.Format("IsTem=1"));
  6599. }
  6600. else
  6601. {
  6602. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6603. }
  6604. }
  6605. lw.Add(string.Format("AfterSaleState=4"));
  6606. string code = CurrentUser.UserPost.Post.Code;
  6607. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6608. {
  6609. //不加条件,可以看全部
  6610. }
  6611. else if (code == "Supplier")
  6612. {
  6613. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6614. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6615. lw.Add("type = 1");
  6616. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6617. }
  6618. else if (code == "logistics")
  6619. {
  6620. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6621. lw.Add("type = 2");
  6622. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6623. }
  6624. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMaster" || CurrentUser.UserPost.Post.Code == "CustomerMr" || CurrentUser.UserPost.Post.Code == "DesignerMr" || CurrentUser.UserPost.Post.Code == "wxDesignerMr" || CurrentUser.UserPost.Post.Code == "Designerhd" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  6625. {
  6626. lw.Add("type = 0");
  6627. int orgid = CurrentUser.UserPost.OrgID;
  6628. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6629. if (string.IsNullOrEmpty(manageOrgIds))
  6630. {
  6631. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6632. }
  6633. else
  6634. {
  6635. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6636. }
  6637. }
  6638. else
  6639. {
  6640. lw.Add("type = 0");
  6641. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6642. }
  6643. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6644. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6645. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6646. writeGridDataTableJson(dStruct.TotalCount, dt);
  6647. }
  6648. public void handle_erp_aftersale()
  6649. {
  6650. if (UrlPostParmsCheck("ctid"))
  6651. {
  6652. string eid = GetPostString("ctid");
  6653. string responStr = GetPostString("AfterSaleResponsible");
  6654. if (responStr.Length <= 0)
  6655. {
  6656. returnErrorMsg("售后责任人不能为空");
  6657. return;
  6658. }
  6659. bool isDesign = false;
  6660. double designFree = 0.00;
  6661. int responsibleId = 0;
  6662. CeErpTradeCell entity = null;
  6663. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6664. if (entity != null)
  6665. {
  6666. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6667. string afterMethod = GetPostString("AfterSaleMethod");
  6668. if (isNeedNewOrder == 1)
  6669. {
  6670. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6671. bool ishav = true;
  6672. if (newentity == null)
  6673. {
  6674. newentity = entity.Clone() as CeErpTradeCell;
  6675. ishav = false;
  6676. newentity.ctid = "S_" + entity.ctid;
  6677. newentity.OrderState = 0;
  6678. //唯一标识
  6679. newentity.OrderSn = newentity.ctid;
  6680. string orderSn = dataHelper.getSaleOrderSn();
  6681. if (orderSn != "")
  6682. {
  6683. newentity.OrderSn = orderSn;
  6684. }
  6685. }
  6686. newentity.UpdateTime = DateTime.Now;
  6687. newentity.AfterSaleState = 0;
  6688. newentity.AfterSaleMethod = afterMethod;
  6689. if (!ishav)
  6690. {
  6691. string memo_str = newentity.seller_memo;
  6692. memo_str = memo_str.Replace("(", "(");
  6693. memo_str = memo_str.Replace(")", ")");
  6694. int sIndex = memo_str.IndexOf("(");
  6695. int eIndex = memo_str.IndexOf(")");
  6696. if (sIndex == -1 || eIndex == -1)
  6697. {
  6698. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6699. return;
  6700. }
  6701. string first = memo_str.Substring(0, sIndex + 1);
  6702. string memoCtid = newentity.OrderSn;
  6703. //if (memoCtid.IndexOf("C") != -1)
  6704. //{
  6705. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6706. //if (CIdx.IndexOf("+") != -1)
  6707. //{
  6708. //CIdx = "C" + CIdx.Split('+')[1];
  6709. //}
  6710. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6711. //}
  6712. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6713. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6714. string newMemo = first + memoCtid + last;
  6715. newentity.seller_memo = newMemo;
  6716. newentity.FinishPlaceTime = null;
  6717. newentity.UnusualTag = 0;
  6718. newentity.UnusualCon = "";
  6719. newentity.UnusualTime = null;
  6720. newentity.AfterSaleMemo = "";
  6721. newentity.AfterSaleMethod = afterMethod;
  6722. newentity.AfterSalePreTime = null;
  6723. newentity.AfterSaleReason = "";
  6724. newentity.AfterSaleResponsible = "";
  6725. newentity.AfterSaleState = 0;
  6726. newentity.AfterSaleTime = null;
  6727. newentity.AfterSaleUserId = 0;
  6728. newentity.AfterSaleSupplierState = 0;
  6729. newentity.LastBillWaybillCode = "";
  6730. newentity.LastBillCpCode = "";
  6731. newentity.FinishAfterSaleTime = null;
  6732. newentity.HandleTime = null;
  6733. newentity.IsSF = 0;
  6734. newentity.IsOldCustomer = 0;
  6735. newentity.UrgencyTime = null;
  6736. newentity.ResponsibleUserId = "";
  6737. newentity.IsVerifyToSupplier = false;
  6738. newentity.payment = 0;
  6739. newentity.CheckMemo = "";
  6740. newentity.OutSid = "";
  6741. newentity.CheckOrderTime = null;
  6742. newentity.MemoOpt = 0;
  6743. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6744. }
  6745. newentity.isAfterSaleOrder = 1;
  6746. newentity.IsRefund = 0;
  6747. string receiveMobile = GetPostString("receiver_mobile");
  6748. if (receiveMobile.Length > 0)
  6749. {
  6750. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6751. if (trade != null)
  6752. {
  6753. trade.receiver_name = GetPostString("receiver_name");
  6754. trade.receiver_mobile = receiveMobile;
  6755. trade.receiver_state = GetPostString("receiver_state");
  6756. trade.receiver_city = GetPostString("receiver_city");
  6757. trade.receiver_district = GetPostString("receiver_district");
  6758. trade.receiver_address = GetPostString("receiver_address");
  6759. newentity.IsOffLineOrder = 1;
  6760. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6761. }
  6762. }
  6763. string st = GetPostString("ToState");
  6764. if (st.Length > 0)
  6765. {
  6766. if (newentity.OrderState <= 3)
  6767. {
  6768. newentity.WaitDesignTime = DateTime.Now;
  6769. newentity.StartDesignTime = null;
  6770. newentity.FinishDesignTime = null;
  6771. newentity.OrderState = 3;
  6772. if (st == "下单员")
  6773. {
  6774. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6775. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6776. {
  6777. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6778. }
  6779. }
  6780. else
  6781. {
  6782. newentity.WaitDesignTime = DateTime.Now;
  6783. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6784. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6785. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6786. {
  6787. DataRow user = dt1.Rows[0];
  6788. //找主管
  6789. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6790. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6791. if (dt != null && dt.Rows.Count > 0)
  6792. {
  6793. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6794. newentity.DesignUserId = designMr;
  6795. string key = "aftersale_order_" + designMr;
  6796. if (RedisHelper.HasKey(key))
  6797. {
  6798. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6799. list.Add(newentity.ctid);
  6800. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6801. }
  6802. }
  6803. //账号正常
  6804. if (user["State"].ToString() == "0")
  6805. {
  6806. newentity.DesignUserId = entity.DesignUserId;
  6807. string key = "aftersale_order_" + entity.DesignUserId;
  6808. if (RedisHelper.HasKey(key))
  6809. {
  6810. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6811. list.Add(newentity.ctid);
  6812. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6813. }
  6814. }
  6815. }
  6816. }
  6817. }
  6818. if (entity.IsXianHuo == 1)
  6819. {
  6820. newentity.OrderState = 6;
  6821. entity.FinishPlaceTime = DateTime.Now;
  6822. }
  6823. }
  6824. if (ishav)
  6825. {
  6826. newentity.Update();
  6827. }
  6828. else
  6829. {
  6830. newentity.Create();
  6831. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6832. newCellExtend.ctid = newentity.ctid;
  6833. newCellExtend.orderFrom = 20;
  6834. newCellExtend.orderType = 30;
  6835. if (st == "下单员")
  6836. {
  6837. }
  6838. else
  6839. {
  6840. newCellExtend.ReprintTime = DateTime.Now;
  6841. }
  6842. newCellExtend.Create();
  6843. }
  6844. if (st != "下单员")
  6845. {
  6846. if (entity.DispatchSort == 2)
  6847. {
  6848. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6849. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6850. }
  6851. }
  6852. }
  6853. //处理售后扩展
  6854. string resIdStr = GetPostString("ResponsibleUserId");
  6855. string refundFees = GetPostString("refundFrees");
  6856. int IsComplain = GetPostInt("isComplain");
  6857. int IsBad = GetPostInt("isBad");
  6858. string IsOriginal = GetPostString("isOriginal");
  6859. double diffResultPrice = GetPostDouble("diffResultPrice");
  6860. string textResult = GetPostString("textResult");
  6861. string supplierResponsible = GetPostString("supplierResponsible");
  6862. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6863. if (ceErpTradeAfterSaleExtend == null)
  6864. {
  6865. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6866. ceErpTradeAfterSaleExtend.tid = eid;
  6867. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6868. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6869. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6870. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6871. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6872. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6873. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6874. ceErpTradeAfterSaleExtend.Create();
  6875. }
  6876. else
  6877. {
  6878. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6879. {
  6880. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6881. }
  6882. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6883. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6884. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6885. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6886. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6887. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6888. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6889. ceErpTradeAfterSaleExtend.Update();
  6890. }
  6891. int gysid = GetPostInt("ResponsibleSupId");
  6892. if (entity.AfterSaleUserId == 0)
  6893. {
  6894. entity.AfterSaleUserId = CurrentUser.UserID;
  6895. }
  6896. entity.ResponsibleUserId = resIdStr;
  6897. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6898. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6899. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6900. {
  6901. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6902. int backNum = 0;
  6903. if (number != null)
  6904. {
  6905. backNum = number.BackNum;
  6906. }
  6907. char[] separator = { ',' };
  6908. string[] sArray = resIdStr.Split(separator);
  6909. string[] refundFreeList = { };
  6910. if (refundFees.Length > 0)
  6911. {
  6912. refundFreeList = refundFees.Split(separator);
  6913. }
  6914. int index = -1;
  6915. List<int> responsibleIds = new List<int>();
  6916. foreach (string i in sArray)
  6917. {
  6918. index++;
  6919. if (i.Length <= 0) continue;
  6920. char[] separator2 = { '_' };
  6921. string idstr = i.Split(separator2)[0];
  6922. string idtype = i.Split(separator2)[1];
  6923. double refudFree = 0;
  6924. if (refundFreeList.Length > 0)
  6925. {
  6926. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6927. }
  6928. if (idtype == "s")
  6929. {
  6930. isDesign = true;
  6931. designFree = refudFree;
  6932. }
  6933. int userId = Convert.ToInt32(idstr);
  6934. int type = 0;
  6935. if (idtype == "g")
  6936. {
  6937. type = 1;
  6938. }
  6939. if (idtype == "w")
  6940. {
  6941. type = 2;
  6942. }
  6943. if (idtype == "t")
  6944. {
  6945. type = 3;
  6946. }
  6947. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6948. if (ceErpTradeResponsible == null)
  6949. {
  6950. ceErpTradeResponsible = new CeErpTradeResponsible();
  6951. ceErpTradeResponsible.tid = eid;
  6952. ceErpTradeResponsible.UserId = userId;
  6953. ceErpTradeResponsible.createdTime = DateTime.Now;
  6954. ceErpTradeResponsible.type = type;
  6955. if (type == 1)
  6956. {
  6957. ceErpTradeResponsible.IsSup = 1;
  6958. }
  6959. if (type == 2)
  6960. {
  6961. ceErpTradeResponsible.IsFlow = 1;
  6962. }
  6963. }
  6964. int state = 0;
  6965. //已认可的不需要再次认可
  6966. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  6967. {
  6968. state = 1;
  6969. }
  6970. ceErpTradeResponsible.RefundFee = refudFree;
  6971. ceErpTradeResponsible.VerifyState = state;
  6972. if (userId == 2125 || idtype == "w")
  6973. {
  6974. ceErpTradeResponsible.VerifyState = 1;
  6975. }
  6976. if (idtype == "w" && userId == 101)
  6977. {
  6978. ceErpTradeResponsible.VerifyState = state;
  6979. }
  6980. if (ceErpTradeResponsible.ID > 0)
  6981. {
  6982. ceErpTradeResponsible.Update();
  6983. }
  6984. else
  6985. {
  6986. ceErpTradeResponsible.Create();
  6987. }
  6988. if (isDesign)
  6989. {
  6990. responsibleId = ceErpTradeResponsible.ID;
  6991. }
  6992. responsibleIds.Add(ceErpTradeResponsible.ID);
  6993. }
  6994. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  6995. CeErpTradeResponsible.NumByTid(backNum, eid);
  6996. }
  6997. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6998. if (ceErpTradeCellExtend != null)
  6999. {
  7000. ceErpTradeCellExtend.returnVisit = 0;
  7001. ceErpTradeCellExtend.Update();
  7002. }
  7003. if (entity.HandleTime != null)
  7004. {
  7005. if (entity.AfterSaleState == 1)
  7006. {
  7007. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7008. }
  7009. else
  7010. {
  7011. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7012. }
  7013. }
  7014. else
  7015. {
  7016. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7017. entity.HandleTime = DateTime.Now;
  7018. }
  7019. bool isCompale = false;
  7020. if (entity.AfterSaleState == 5)
  7021. {
  7022. isCompale = true;
  7023. entity.AfterSaleState = 3;
  7024. }
  7025. entity.AfterSaleSupplierState = 0;
  7026. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7027. {
  7028. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7029. }
  7030. string sImgs = GetPostString("img");
  7031. entity.AfterSaleSupplierImg = sImgs;
  7032. entity.supRefundType = GetPostString("supRefundType");
  7033. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7034. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7035. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7036. entity.AfterSaleMemoType = GetPostString("MemoType");
  7037. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7038. {
  7039. //entity.AfterSaleSupplierState = 2;
  7040. }
  7041. string df = GetPostString("DeductFee");
  7042. if (df == "")
  7043. {
  7044. df = "0";
  7045. }
  7046. string rf = GetPostString("RefundFee");
  7047. if (rf == "")
  7048. {
  7049. rf = "0";
  7050. }
  7051. string pm = GetPostString("AfterSalePayment");
  7052. if (pm == "")
  7053. {
  7054. pm = "0";
  7055. }
  7056. entity.AfterSalePayment = Convert.ToDouble(pm);
  7057. entity.DeductFee = Convert.ToDouble(df);
  7058. entity.RefundFee = Convert.ToDouble(rf);
  7059. entity.UpdateTime = DateTime.Now;
  7060. entity.Update();
  7061. string toState = GetPostString("ToState");
  7062. string original = GetPostString("isOriginal");
  7063. ApiVo apiVo = new ApiVo();
  7064. apiVo.orderNumber = entity.ctid;
  7065. apiVo.actionName = "afterDesign";
  7066. apiVo.orderRemarks = entity.AfterSaleMethod;
  7067. apiVo.reasonRemarks = entity.AfterSaleReason;
  7068. apiVo.isDesign = isDesign;
  7069. apiVo.designFree = designFree;
  7070. apiVo.responsibleId = responsibleId;
  7071. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7072. if (toState == "设计师")
  7073. {
  7074. apiVo.isOriginal = Convert.ToBoolean(original);
  7075. }
  7076. designHelper.API_WorkCore(apiVo);//afterDesign
  7077. CeErpMethod methodSql = new CeErpMethod();
  7078. methodSql.con = entity.AfterSaleMethod;
  7079. methodSql.addTime = DateTime.Now;
  7080. methodSql.Create();
  7081. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7082. CeErpMethod.ExecuteNonQuery(delsql);
  7083. if (isCompale)
  7084. {
  7085. aftersale_data_change(entity.ctid);
  7086. }
  7087. returnSuccessMsg("操作成功!");
  7088. return;
  7089. }
  7090. returnErrorMsg("找不到订单记录");
  7091. }
  7092. }
  7093. public void ins_erp_toresponsible()
  7094. {
  7095. if (UrlPostParmsCheck("ctid"))
  7096. {
  7097. string eid = GetPostString("ctid");
  7098. CeErpTradeCell entity = null;
  7099. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7100. if (entity != null)
  7101. {
  7102. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7103. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7104. {
  7105. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7106. return;
  7107. }
  7108. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7109. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7110. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7111. if (entity.AfterSalePreTime == null)
  7112. {
  7113. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7114. {
  7115. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7116. }
  7117. }
  7118. entity.AfterSalePreTime = DateTime.Now;
  7119. //预完成给售后主管审核客户问题直接完成
  7120. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7121. {
  7122. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7123. {
  7124. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7125. }
  7126. }
  7127. ceErpTradeAfterSaleExtend.Update();
  7128. entity.AfterSaleState = 2;
  7129. entity.UpdateTime = DateTime.Now;
  7130. entity.Update();
  7131. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7132. aftersale_data_change(entity.ctid);
  7133. returnSuccessMsg("操作成功!");
  7134. return;
  7135. }
  7136. returnErrorMsg("找不到订单记录");
  7137. }
  7138. }
  7139. public void cancel_erp_aftersaleanddelnew()
  7140. {
  7141. if (UrlPostParmsCheck("ctid"))
  7142. {
  7143. string eid = GetPostString("ctid");
  7144. CeErpTradeCell entity = null;
  7145. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7146. if (entity != null)
  7147. {
  7148. entity.AfterSaleState = 0;
  7149. entity.AfterSaleReason = "";
  7150. entity.AfterSaleMethod = "";
  7151. entity.AfterSaleMemo = "";
  7152. entity.AfterSaleResponsible = "";
  7153. entity.ResponsibleUserId = "";
  7154. entity.DeductFee = 0;
  7155. entity.RefundFee = 0;
  7156. entity.IsArbitrate = 0;
  7157. CeErpTradeResponsible.DelByTid(eid, -1);
  7158. entity.Update();
  7159. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7160. if (after != null)
  7161. {
  7162. if (after.OrderState < 5)
  7163. CeErpTradeCell.DelByCtid("S_" + eid);
  7164. }
  7165. returnSuccessMsg("操作成功!");
  7166. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7167. return;
  7168. }
  7169. returnErrorMsg("找不到订单记录");
  7170. }
  7171. }
  7172. public void get_erp_aftersale_pregather()
  7173. {
  7174. List<string> lw = new List<string>();
  7175. int st = GetInt("st");
  7176. string tid = GetPostString("ctid");
  7177. if (tid.Length > 0)
  7178. {
  7179. string select_tid = getTidByCtid(tid);
  7180. lw.Add(string.Format("tid='{0}'", select_tid));
  7181. }
  7182. string shopname = GetPostString("shopname");
  7183. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7184. string buyernick = GetPostString("buyer_nick");
  7185. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7186. string sellermemo = GetPostString("seller_memo");
  7187. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7188. string orderState = GetPostString("orderState");
  7189. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7190. string reason = GetPostString("reason");
  7191. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7192. string method = GetPostString("method");
  7193. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7194. string handler = GetPostString("handler");
  7195. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7196. string handledate1 = GetPostString("handledate1");
  7197. string handledate2 = GetPostString("handledate2");
  7198. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7199. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7200. string supplier = GetPostString("supplier");
  7201. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7202. string responsible = GetPostString("responsibleman");
  7203. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7204. string customer = GetPostString("customer");
  7205. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7206. string design = GetPostString("design");
  7207. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7208. string afterMemoType = GetPostString("aftermemotype");
  7209. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7210. string afterSaleMemo = GetPostString("afterSaleMemo");
  7211. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7212. string afterresult = GetPostString("afterresult");
  7213. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7214. string poscode = CurrentUser.UserPost.Post.Code;
  7215. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7216. {
  7217. string shopid = CurrentUser.User.pemShop;
  7218. lw.Add(string.Format("shopId in ({0})", shopid));
  7219. }
  7220. var mainwhere = string.Join(" and ", lw.ToArray());
  7221. string ro_json = "";
  7222. string type = GetPostString("gather_type");
  7223. int number = 0;
  7224. if (poscode == "AfterSale")
  7225. {
  7226. //处理中
  7227. if (type == "Handling")
  7228. {
  7229. 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) : ""));
  7230. DataTable dt = null;
  7231. try
  7232. {
  7233. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7234. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7235. }
  7236. catch (Exception e)
  7237. {
  7238. dt = new DataTable();
  7239. }
  7240. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7241. return;
  7242. }
  7243. if (type == "Wait")
  7244. {
  7245. //待处理
  7246. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7247. DataTable dt1 = null;
  7248. try
  7249. {
  7250. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7251. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7252. }
  7253. catch (Exception e)
  7254. {
  7255. dt1 = new DataTable();
  7256. }
  7257. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7258. return;
  7259. }
  7260. if (type == "back")
  7261. {
  7262. //打回
  7263. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7264. DataTable dt2 = null;
  7265. try
  7266. {
  7267. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7268. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7269. }
  7270. catch (Exception e)
  7271. {
  7272. dt2 = new DataTable();
  7273. }
  7274. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7275. return;
  7276. }
  7277. if (type == "preCompletion")
  7278. {
  7279. //预完成
  7280. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7281. DataTable dt3 = null;
  7282. try
  7283. {
  7284. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7285. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7286. }
  7287. catch (Exception e)
  7288. {
  7289. dt3 = new DataTable();
  7290. }
  7291. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7292. return;
  7293. }
  7294. if (type == "documentary")
  7295. {
  7296. //跟单中
  7297. 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) : ""));
  7298. DataTable dt4 = null;
  7299. try
  7300. {
  7301. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7302. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7303. }
  7304. catch (Exception e)
  7305. {
  7306. dt4 = new DataTable();
  7307. }
  7308. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7309. return;
  7310. }
  7311. if (type == "reBack")
  7312. {
  7313. //被打回
  7314. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7315. DataTable dt1 = null;
  7316. try
  7317. {
  7318. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7319. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7320. }
  7321. catch (Exception e)
  7322. {
  7323. dt1 = new DataTable();
  7324. }
  7325. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7326. return;
  7327. }
  7328. }
  7329. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7330. {
  7331. if (type == "puBack")
  7332. {
  7333. //退回
  7334. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7335. DataTable dt = null;
  7336. try
  7337. {
  7338. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7339. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7340. }
  7341. catch (Exception e)
  7342. {
  7343. dt = new DataTable();
  7344. }
  7345. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7346. return;
  7347. }
  7348. if (type == "reBack")
  7349. {
  7350. //打回
  7351. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7352. DataTable dt1 = null;
  7353. try
  7354. {
  7355. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7356. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7357. }
  7358. catch (Exception e)
  7359. {
  7360. dt1 = new DataTable();
  7361. }
  7362. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7363. return;
  7364. }
  7365. if (type == "examEd")
  7366. {
  7367. //已审核
  7368. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7369. DataTable dt2 = null;
  7370. try
  7371. {
  7372. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7373. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7374. }
  7375. catch (Exception e)
  7376. {
  7377. dt2 = new DataTable();
  7378. }
  7379. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7380. return;
  7381. }
  7382. if (type == "waitExam")
  7383. {
  7384. //待审核
  7385. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7386. DataTable dt3 = null;
  7387. try
  7388. {
  7389. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7390. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7391. }
  7392. catch (Exception e)
  7393. {
  7394. dt3 = new DataTable();
  7395. }
  7396. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7397. return;
  7398. }
  7399. if (type == "Handling")
  7400. {
  7401. //处理中
  7402. 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) : ""));
  7403. DataTable dt4 = null;
  7404. try
  7405. {
  7406. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7407. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7408. }
  7409. catch (Exception e)
  7410. {
  7411. dt4 = new DataTable();
  7412. }
  7413. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7414. return;
  7415. }
  7416. if (type == "Wait")
  7417. {
  7418. //待处理
  7419. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7420. DataTable dt5 = null;
  7421. try
  7422. {
  7423. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7424. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7425. }
  7426. catch (Exception e)
  7427. {
  7428. dt5 = new DataTable();
  7429. }
  7430. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7431. return;
  7432. }
  7433. if (type == "documentary")
  7434. {
  7435. //跟单中
  7436. 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) : ""));
  7437. DataTable dt6 = null;
  7438. try
  7439. {
  7440. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7441. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7442. }
  7443. catch (Exception e)
  7444. {
  7445. dt6 = new DataTable();
  7446. }
  7447. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7448. return;
  7449. }
  7450. }
  7451. returnSuccess(ro_json);
  7452. }
  7453. public void end_erp_aftersale()
  7454. {
  7455. if (UrlPostParmsCheck("ctid"))
  7456. {
  7457. string eid = GetPostString("ctid");
  7458. CeErpTradeCell entity = null;
  7459. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7460. if (entity != null)
  7461. {
  7462. string stype = GetPostString("stype");
  7463. string typeStr = stype;
  7464. entity.AfterSaleState = 4;
  7465. entity.FinishAfterSaleTime = DateTime.Now;
  7466. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7467. entity.Update();
  7468. ApiVo apiVo = new ApiVo();
  7469. apiVo.orderNumber = entity.ctid;
  7470. apiVo.actionName = "afterOver";
  7471. designHelper.API_WorkCore(apiVo); //afterOver
  7472. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7473. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7474. CeErpSukuraData.createInfo(entity.ctid, 8);
  7475. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7476. returnSuccessMsg("操作成功!");
  7477. return;
  7478. }
  7479. returnErrorMsg("找不到订单记录");
  7480. }
  7481. }
  7482. public void ins_erp_finishaftersale()
  7483. {
  7484. if (UrlPostParmsCheck("id"))
  7485. {
  7486. string eid = GetPostString("id");
  7487. CeErpTradeResponsible entity = null;
  7488. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7489. if (entity != null)
  7490. {
  7491. entity.VerifyState = 1;
  7492. entity.VerifyTime = DateTime.Now;
  7493. entity.Update();
  7494. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7495. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7496. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7497. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7498. if (dt.Rows.Count <= 0)
  7499. {
  7500. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7501. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7502. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7503. CeErpSukuraData.createInfo(entity.tid, 8);
  7504. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7505. {
  7506. CeErpDesignerBill.Del(entity.tid);
  7507. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7508. }
  7509. }
  7510. returnSuccessMsg("操作成功!");
  7511. return;
  7512. }
  7513. returnErrorMsg("找不到订单记录");
  7514. }
  7515. }
  7516. public void upd_erp_arbitrateaftersale()
  7517. {
  7518. if (UrlPostParmsCheck("id"))
  7519. {
  7520. string eid = GetPostString("id");
  7521. CeErpTradeResponsible entity = null;
  7522. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7523. if (entity != null)
  7524. {
  7525. entity.IsArbitrate = 1;
  7526. entity.ArbitradeMemo = GetPostString("reason");
  7527. entity.VerifyState = 2;
  7528. entity.Update();
  7529. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7530. if (tradecell != null)
  7531. {
  7532. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7533. tradecell.IsArbitrate = 1;
  7534. tradecell.Update();
  7535. }
  7536. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7537. returnSuccessMsg("操作成功!");
  7538. return;
  7539. }
  7540. returnErrorMsg("找不到订单记录");
  7541. }
  7542. }
  7543. public void upd_erp_backaftersale()
  7544. {
  7545. if (UrlPostParmsCheck("tid"))
  7546. {
  7547. string eid = GetPostString("tid");
  7548. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7549. int backNum = 0;
  7550. if (number != null)
  7551. {
  7552. backNum = number.BackNum;
  7553. }
  7554. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7555. CeErpTradeCell entity = null;
  7556. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7557. if (entity != null)
  7558. {
  7559. entity.AfterSaleBackReason = GetPostString("backreason");
  7560. entity.AfterSaleState = 1;
  7561. entity.AfterSaleSupplierState = 0;
  7562. entity.UpdateTime = DateTime.Now;
  7563. entity.Update();
  7564. returnSuccessMsg("操作成功!");
  7565. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7566. return;
  7567. }
  7568. returnErrorMsg("找不到订单记录");
  7569. }
  7570. }
  7571. public void get_erp_supplieraftersalelist()
  7572. {
  7573. DataStruct dStruct = GetPostStruct();
  7574. List<string> lw = new List<string>();
  7575. string tid = GetPostString("ctid");
  7576. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7577. string shopname = GetPostString("shopname");
  7578. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7579. string buyernick = GetPostString("buyer_nick");
  7580. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7581. string sellermemo = GetPostString("seller_memo");
  7582. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7583. string orderState = GetPostString("orderState");
  7584. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7585. string afterState = GetPostString("afterstate");
  7586. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7587. string date1 = GetPostString("date1");
  7588. string date2 = GetPostString("date2");
  7589. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7590. if (dw.Length > 0) lw.Add(dw);
  7591. string price1 = GetPostString("price1");
  7592. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7593. string price2 = GetPostString("price2");
  7594. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7595. string reason = GetPostString("reason");
  7596. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7597. string method = GetPostString("method");
  7598. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7599. string handledate1 = GetPostString("handledate1");
  7600. string handledate2 = GetPostString("handledate2");
  7601. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7602. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7603. string handler = GetPostString("handler");
  7604. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7605. string afterdate1 = GetPostString("afterdate1");
  7606. string afterdate2 = GetPostString("afterdate2");
  7607. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7608. if (afterDate.Length > 0) lw.Add(afterDate);
  7609. string customer = GetPostString("customer");
  7610. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7611. string design = GetPostString("design");
  7612. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7613. string afterMemoType = GetPostString("aftermemotype");
  7614. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7615. string vstate = GetPostString("vstate");
  7616. if (vstate.Length > 0)
  7617. {
  7618. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7619. }
  7620. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7621. string supplier = GetPostString("supplier");
  7622. int supid = commonHelper.getSupplierIDByName(supplier);
  7623. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7624. string posCode = CurrentUser.UserPost.Post.Code;
  7625. if (posCode == "Supplier")
  7626. {
  7627. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7628. }
  7629. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7630. {
  7631. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7632. }
  7633. else
  7634. {
  7635. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7636. }
  7637. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7638. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7639. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7640. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7641. writeGridDataTableJson(dStruct.TotalCount, dt);
  7642. }
  7643. public void upd_erp_supverifyaftersale()
  7644. {
  7645. if (UrlPostParmsCheck("id"))
  7646. {
  7647. string id = GetPostString("id");
  7648. int st = GetPostInt("afterstate");
  7649. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7650. CeErpTradeCell entity = null;
  7651. if (ceErpTradeResponsible != null)
  7652. {
  7653. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7654. }
  7655. string afmemo = GetPostString("supmemo");
  7656. string image = GetPostString("image");
  7657. if (entity != null)
  7658. {
  7659. entity.AfterSaleSupplierState = st;
  7660. entity.AfterSaleSupplierMemo = afmemo;
  7661. if (st == 1)
  7662. {
  7663. ceErpTradeResponsible.VerifyState = 1;
  7664. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7665. ceErpTradeResponsible.Update();
  7666. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7667. if (isAll)
  7668. {
  7669. entity.AfterSaleState = 4;
  7670. entity.FinishAfterSaleTime = DateTime.Now;
  7671. }
  7672. }
  7673. else
  7674. {
  7675. CeErpTradeResponsible.dateByTid(entity.ctid);
  7676. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7677. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7678. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7679. if (num <= 1)
  7680. {
  7681. entity.AfterSaleState = 1;
  7682. }
  7683. else
  7684. {
  7685. entity.AfterSaleState = 5;
  7686. }
  7687. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7688. if (ceErpTradeAfterSaleExtend != null)
  7689. {
  7690. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7691. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7692. ceErpTradeAfterSaleExtend.Update();
  7693. }
  7694. else
  7695. {
  7696. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7697. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7698. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7699. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7700. ceErpTradeAfterSaleExtend.Create();
  7701. }
  7702. }
  7703. if (entity.AfterSaleState == 4)
  7704. {
  7705. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7706. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7707. {
  7708. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7709. }
  7710. ApiVo apiVo = new ApiVo();
  7711. apiVo.orderNumber = entity.ctid;
  7712. apiVo.actionName = "afterOver";
  7713. designHelper.API_WorkCore(apiVo); //afterOver
  7714. }
  7715. entity.UpdateTime = DateTime.Now;
  7716. entity.Update();
  7717. returnSuccessMsg("操作成功!");
  7718. CeErpSukuraData.createInfo(entity.ctid, 8);
  7719. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7720. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7721. return;
  7722. }
  7723. returnErrorMsg("找不到订单记录");
  7724. }
  7725. }
  7726. public void upd_erp_masteraftersale()
  7727. {
  7728. if (UrlPostParmsCheck("id"))
  7729. {
  7730. string id = GetPostString("id");
  7731. int st = GetPostInt("afterstate");
  7732. string afmemo = GetPostString("supmemo");
  7733. string image = GetPostString("image");
  7734. string textResult = GetPostString("textResult");
  7735. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7736. if (ceErpTradeResponsible != null)
  7737. {
  7738. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7739. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7740. ceErpTradeResponsible.Update();
  7741. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7742. if (entity != null)
  7743. {
  7744. entity.AfterSaleSupplierState = st;
  7745. entity.AfterSaleSupplierMemo = afmemo;
  7746. if (st == 1)
  7747. {
  7748. }
  7749. else
  7750. {
  7751. CeErpTradeResponsible.dateByTid(entity.ctid);
  7752. //退回到售后
  7753. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7754. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7755. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7756. if (num <= 1)
  7757. {
  7758. entity.AfterSaleState = 1;
  7759. }
  7760. else
  7761. {
  7762. entity.AfterSaleState = 5;
  7763. }
  7764. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7765. if (ceErpTradeAfterSaleExtend != null)
  7766. {
  7767. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7768. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7769. ceErpTradeAfterSaleExtend.Update();
  7770. }
  7771. else
  7772. {
  7773. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7774. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7775. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7776. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7777. ceErpTradeAfterSaleExtend.Create();
  7778. }
  7779. }
  7780. entity.UpdateTime = DateTime.Now;
  7781. entity.Update();
  7782. returnSuccessMsg("操作成功!");
  7783. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7784. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7785. return;
  7786. }
  7787. }
  7788. returnErrorMsg("找不到订单记录");
  7789. }
  7790. }
  7791. public void upd_erp_personaftersale()
  7792. {
  7793. if (UrlPostParmsCheck("id"))
  7794. {
  7795. //林小连
  7796. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7797. {
  7798. upd_erp_masteraftersale();
  7799. return;
  7800. }
  7801. string id = GetPostString("id");
  7802. int st = GetPostInt("afterstate");
  7803. string afmemo = GetPostString("supmemo");
  7804. string image = GetPostString("image");
  7805. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7806. if (ceErpTradeResponsible != null)
  7807. {
  7808. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7809. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7810. ceErpTradeResponsible.Update();
  7811. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7812. if (entity != null)
  7813. {
  7814. entity.AfterSaleSupplierMemo = afmemo;
  7815. entity.AfterSaleSupplierState = st;
  7816. if (st == 1)
  7817. {
  7818. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7819. if (isAll)
  7820. {
  7821. entity.AfterSaleState = 4;
  7822. entity.FinishAfterSaleTime = DateTime.Now;
  7823. }
  7824. }
  7825. else
  7826. {
  7827. CeErpTradeResponsible.dateByTid(entity.ctid);
  7828. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7829. if (ceErpTradeAfterSaleExtend != null)
  7830. {
  7831. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7832. ceErpTradeAfterSaleExtend.Update();
  7833. }
  7834. else
  7835. {
  7836. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7837. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7838. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7839. ceErpTradeAfterSaleExtend.Create();
  7840. }
  7841. //退回到主管
  7842. //entity.AfterSaleState = 2;
  7843. }
  7844. if (entity.AfterSaleState == 4)
  7845. {
  7846. ApiVo apiVo = new ApiVo();
  7847. apiVo.orderNumber = entity.ctid;
  7848. apiVo.actionName = "afterOver";
  7849. designHelper.API_WorkCore(apiVo); //afterOver
  7850. }
  7851. entity.UpdateTime = DateTime.Now;
  7852. entity.Update();
  7853. returnSuccessMsg("操作成功!");
  7854. CeErpSukuraData.createInfo(entity.ctid, 8);
  7855. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7856. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7857. return;
  7858. }
  7859. }
  7860. returnErrorMsg("找不到订单记录");
  7861. }
  7862. }
  7863. public void set_erp_supplierrefundtag()
  7864. {
  7865. if (UrlPostParmsCheck("ctid"))
  7866. {
  7867. string eid = GetPostString("ctid");
  7868. CeErpTradeCell entity = null;
  7869. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7870. if (entity != null)
  7871. {
  7872. entity.IsSupplierRefund = GetPostInt("tag");
  7873. entity.Update();
  7874. returnSuccessMsg("操作成功!");
  7875. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7876. return;
  7877. }
  7878. returnErrorMsg("找不到订单记录");
  7879. }
  7880. }
  7881. public void get_erp_refundlist()
  7882. {
  7883. DataStruct dStruct = GetPostStruct();
  7884. List<string> lw = new List<string>();
  7885. string tid = GetPostString("tid");
  7886. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7887. //string rid = GetPostString("refund_id");
  7888. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7889. string shopname = GetPostString("shopname");
  7890. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7891. string buyernick = GetPostString("buyer_nick");
  7892. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7893. string customer = GetPostString("customer");
  7894. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7895. string design = GetPostString("design");
  7896. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7897. string sellermemo = GetPostString("seller_memo");
  7898. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7899. //string date1 = GetPostString("date1");
  7900. //string date2 = GetPostString("date2");
  7901. //string dateType = GetPostString("dateType");
  7902. //if (dateType.Length > 0)
  7903. //{
  7904. // if (dateType == "1001") dateType = "0";
  7905. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7906. // if (searchDT.Count == 2)
  7907. // {
  7908. // date1 = searchDT[0].ToString();
  7909. // date2 = searchDT[1].ToString();
  7910. // }
  7911. //}
  7912. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7913. //if (dw.Length > 0) lw.Add(dw);
  7914. string redate1 = GetPostString("refunddate1");
  7915. string redate2 = GetPostString("refunddate2");
  7916. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7917. if (dwdate.Length > 0) lw.Add(dwdate);
  7918. string price1 = GetPostString("price1");
  7919. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7920. string price2 = GetPostString("price2");
  7921. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7922. string ispartrefund = GetPostString("ispartrefund");
  7923. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7924. string refundState = GetPostString("refundvstate");
  7925. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7926. int st = GetInt("st");
  7927. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7928. {
  7929. string responsible = GetPostString("responsibleman");
  7930. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7931. lw.Add(string.Format("RefundState>={0}", st));
  7932. string code = CurrentUser.UserPost.Post.Code;
  7933. if (code == "CustomerService")
  7934. {
  7935. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7936. }
  7937. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7938. {
  7939. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7940. }
  7941. else if (code == "Place" || code == "PlaceMr")
  7942. {
  7943. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7944. }
  7945. dStruct.Order = "RefundState asc,created desc";
  7946. }
  7947. else if (st == 10)
  7948. {
  7949. string responsible = GetPostString("responsibleman");
  7950. if (responsible == "空白")
  7951. {
  7952. lw.Add(string.Format("ResponsibleUserName = ''"));
  7953. }
  7954. else if (responsible.Length > 0)
  7955. {
  7956. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7957. }
  7958. lw.Add(string.Format("RefundState>=0"));
  7959. dStruct.Order = "created desc";
  7960. }
  7961. else
  7962. {
  7963. string responsible = GetPostString("responsibleman");
  7964. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7965. lw.Add(string.Format("RefundState={0}", st));
  7966. dStruct.Order = "created desc";
  7967. }
  7968. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7969. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7970. dt.Columns.Add("refund_fees");
  7971. foreach (DataRow dr in dt.Rows)
  7972. {
  7973. String status = dr["status"].ToString();
  7974. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7975. {
  7976. dr["refund_fees"] = dr["refund_fee"];
  7977. }
  7978. else
  7979. {
  7980. dr["refund_fees"] = "0.0";
  7981. }
  7982. }
  7983. writeGridDataTableJson(dStruct.TotalCount, dt);
  7984. }
  7985. public void get_erp_refunddesignlist()
  7986. {
  7987. DataStruct dStruct = GetPostStruct();
  7988. List<string> lw = new List<string>();
  7989. string tid = GetPostString("tid");
  7990. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7991. string shopname = GetPostString("shopname");
  7992. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7993. string buyernick = GetPostString("buyer_nick");
  7994. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7995. string customer = GetPostString("customer");
  7996. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7997. string design = GetPostString("design");
  7998. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7999. string sellermemo = GetPostString("seller_memo");
  8000. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8001. string redate1 = GetPostString("refunddate1");
  8002. string redate2 = GetPostString("refunddate2");
  8003. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8004. if (dwdate.Length > 0) lw.Add(dwdate);
  8005. string price1 = GetPostString("price1");
  8006. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8007. string price2 = GetPostString("price2");
  8008. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8009. string ispartrefund = GetPostString("ispartrefund");
  8010. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8011. string designerorg = GetPostString("designerorg");
  8012. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8013. string refundState = GetPostString("refundState");
  8014. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8015. int myOrgid = CurrentUser.UserPost.OrgID;
  8016. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8017. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8018. {
  8019. if (CurrentUser.User.TeamIds.Length > 0)
  8020. {
  8021. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8022. }
  8023. else
  8024. {
  8025. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8026. }
  8027. }
  8028. else if ("SysAdmin".Equals(myOrgCode))
  8029. {
  8030. }
  8031. else
  8032. {
  8033. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8034. {
  8035. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8036. }
  8037. else
  8038. {
  8039. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8040. }
  8041. }
  8042. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8043. dStruct.Order = "created desc";
  8044. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8045. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8046. dt.Columns.Add("refund_fees");
  8047. foreach (DataRow dr in dt.Rows)
  8048. {
  8049. String status = dr["status"].ToString();
  8050. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8051. {
  8052. dr["refund_fees"] = dr["refund_fee"];
  8053. }
  8054. else
  8055. {
  8056. dr["refund_fees"] = "0.0";
  8057. }
  8058. }
  8059. writeGridDataTableJson(dStruct.TotalCount, dt);
  8060. }
  8061. public void handle_erp_refundtag()
  8062. {
  8063. if (UrlPostParmsCheck("refund_id"))
  8064. {
  8065. string eid = GetPostString("refund_id");
  8066. string respMan = GetPostString("ResponsibleName");
  8067. if (respMan.Length <= 0)
  8068. {
  8069. returnErrorMsg("责任人不能为空");
  8070. return;
  8071. }
  8072. CeErpTradeRefund entity = null;
  8073. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8074. if (entity != null)
  8075. {
  8076. entity.ResponsibleUserName = respMan;
  8077. string userid = GetPostString("ResponsibleUserId");
  8078. if (userid.Length > 0)
  8079. {
  8080. entity.ResponsibleUserId = userid;
  8081. }
  8082. entity.Memo = GetPostString("Memo");
  8083. if (respMan.IndexOf("客服") != -1 ||
  8084. respMan.IndexOf("设计师") != -1 ||
  8085. respMan.IndexOf("下单员") != -1)
  8086. {
  8087. entity.RefundState = 2;
  8088. }
  8089. else
  8090. {
  8091. entity.RefundState = 3;
  8092. }
  8093. entity.modified = DateTime.Now;
  8094. entity.Update();
  8095. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8096. returnSuccessMsg("操作成功!");
  8097. return;
  8098. }
  8099. returnErrorMsg("找不到订单记录");
  8100. }
  8101. }
  8102. public void handle_erp_designrefundtag()
  8103. {
  8104. if (UrlPostParmsCheck("refund_id"))
  8105. {
  8106. string eid = GetPostString("refund_id");
  8107. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8108. if (ceErpTradeCellExtend == null)
  8109. {
  8110. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8111. ceErpTradeCellExtend.ctid = eid;
  8112. }
  8113. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8114. if (ceErpTradeCellExtend.ID > 0)
  8115. {
  8116. ceErpTradeCellExtend.Update();
  8117. }
  8118. else
  8119. {
  8120. ceErpTradeCellExtend.Create();
  8121. }
  8122. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8123. returnSuccessMsg("操作成功!");
  8124. return;
  8125. }
  8126. returnErrorMsg("找不到订单记录");
  8127. }
  8128. public void upd_erp_refundverify()
  8129. {
  8130. if (UrlPostParmsCheck("refund_id"))
  8131. {
  8132. string eid = GetPostString("refund_id");
  8133. CeErpTradeRefund entity = null;
  8134. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8135. if (entity != null)
  8136. {
  8137. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8138. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8139. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8140. {
  8141. entity.RefundState = 2;
  8142. }
  8143. else
  8144. {
  8145. entity.RefundState = 3;
  8146. }
  8147. entity.Update();
  8148. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8149. returnSuccessMsg("操作成功!");
  8150. return;
  8151. }
  8152. returnErrorMsg("找不到订单记录");
  8153. }
  8154. }
  8155. public void upd_erp_refundapprove()
  8156. {
  8157. if (UrlPostParmsCheck("refund_id"))
  8158. {
  8159. string eid = GetPostString("refund_id");
  8160. CeErpTradeRefund entity = null;
  8161. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8162. if (entity != null)
  8163. {
  8164. int apr = GetPostInt("approve");
  8165. if (apr == 0)
  8166. {
  8167. entity.RefundState = 1;
  8168. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8169. }
  8170. else if (apr == 1)
  8171. {
  8172. entity.RefundState = 3;
  8173. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8174. }
  8175. entity.modified = DateTime.Now;
  8176. entity.Update();
  8177. returnSuccessMsg("操作成功!");
  8178. return;
  8179. }
  8180. returnErrorMsg("找不到订单记录");
  8181. }
  8182. }
  8183. public void get_erp_billlist()
  8184. {
  8185. DataStruct dStruct = GetPostStruct();
  8186. List<string> lw = new List<string>();
  8187. string title = GetPostString("title");
  8188. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8189. string tid = GetPostString("tid");
  8190. string tids = GetPostString("tids");
  8191. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8192. if (tids.Length > 0)
  8193. {
  8194. tids = "'" + tids + "'";
  8195. tids = tids.Replace(",", "','");
  8196. lw.Add(string.Format("tid in ({0})", tids));
  8197. }
  8198. string shopname = GetPostString("shopname");
  8199. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8200. string buyernick = GetPostString("buyer_nick");
  8201. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8202. string customer = GetPostString("customer");
  8203. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8204. string date1 = GetPostString("date1");
  8205. string date2 = GetPostString("date2");
  8206. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8207. if (dw.Length > 0) lw.Add(dw);
  8208. string price1 = GetPostString("price1");
  8209. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8210. string price2 = GetPostString("price2");
  8211. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8212. string returndate1 = GetPostString("returndate1");
  8213. string returndate2 = GetPostString("returndate2");
  8214. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8215. if (dw1.Length > 0) lw.Add(dw1);
  8216. string billtype = GetPostString("billtype");
  8217. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8218. string billstate = GetPostString("billstate");
  8219. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8220. string usershop = CurrentUser.User.pemShop;
  8221. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8222. dStruct.Order = "createTime desc";
  8223. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8224. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8225. //foreach (DataRow dr in dt.Rows)
  8226. //{
  8227. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8228. //}
  8229. writeGridDataTableJson(dStruct.TotalCount, dt);
  8230. }
  8231. public void modify_erp_billinfo()
  8232. {
  8233. if (UrlPostParmsCheck("ID"))
  8234. {
  8235. string eid = GetPostString("ID");
  8236. CeErpBill bill_entity = null;
  8237. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8238. if (bill_entity != null)
  8239. {
  8240. bill_entity.tid = GetPostString("tid");
  8241. bill_entity.title = GetPostString("title");
  8242. bill_entity.tax = GetPostString("tax");
  8243. bill_entity.bank = GetPostString("bank");
  8244. bill_entity.bankac = GetPostString("bankac");
  8245. bill_entity.address = GetPostString("address");
  8246. bill_entity.phone = GetPostString("phone");
  8247. bill_entity.price = GetPostString("price");
  8248. bill_entity.productId = GetPostInt("ProductName");
  8249. bill_entity.num = GetPostInt("num");
  8250. bill_entity.unit = GetPostString("unit");
  8251. bill_entity.type = GetPostString("type");
  8252. bill_entity.sendType = GetPostString("SendType");
  8253. bill_entity.email = GetPostString("email");
  8254. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8255. bill_entity.shopName = GetPostString("ShopName");
  8256. bill_entity.applymemo = GetPostString("applymemo");
  8257. bill_entity.modifyTime = DateTime.Now;
  8258. bill_entity.createTime = DateTime.Now;
  8259. bill_entity.state = 0;
  8260. bill_entity.Update();
  8261. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8262. returnSuccessMsg("发票修改成功!");
  8263. return;
  8264. }
  8265. returnErrorMsg("找不到对应记录");
  8266. }
  8267. }
  8268. public void set_erp_invoicing()
  8269. {
  8270. if (UrlPostParmsCheck("id"))
  8271. {
  8272. try
  8273. {
  8274. string eid = GetPostString("id");
  8275. CeErpBill bill_entity = null;
  8276. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8277. if (bill_entity != null)
  8278. {
  8279. int ComId = GetPostInt("ComId");
  8280. //string memo = GetPostString("Memo");
  8281. int allInfo = GetPostInt("allinfo");
  8282. string clert = CurrentUser.User.Name;
  8283. //string detailValue = GetPostString("detailvalue");
  8284. string billId = bill_entity.billOrderId;
  8285. string[] billIdList = billId.Split(',');
  8286. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8287. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8288. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8289. {
  8290. billCount += 1;
  8291. }
  8292. if (billId.Length <= 0 || billIdList.Length != billCount)
  8293. {
  8294. bill_entity.billOrderId = "";
  8295. string prebill = "ltb";
  8296. for (int idx = 1; idx <= billCount; idx++)
  8297. {
  8298. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8299. string billoid = prebill + idx + dtstr;
  8300. bill_entity.billOrderId += billoid;
  8301. if (idx < billCount)
  8302. {
  8303. bill_entity.billOrderId += ",";
  8304. }
  8305. }
  8306. }
  8307. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8308. if (bill_entity.state == 5)
  8309. {
  8310. string errMsg = bill_entity.failerror;
  8311. string[] errlist = errMsg.Split('|');
  8312. string[] errTags = new string[errlist.Length];
  8313. for (int itag = 0; itag < errlist.Length; itag++)
  8314. {
  8315. if (errlist[itag].Length <= 0) continue;
  8316. errTags[itag] = errlist[itag].Split('&')[0];
  8317. }
  8318. for (int iii = 0; iii < errTags.Length; iii++)
  8319. {
  8320. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8321. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8322. if (billOrderList.Length >= erroBillOrderTag)
  8323. {
  8324. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8325. if (needModifyBillId.Length <= 19)
  8326. {
  8327. needModifyBillId = needModifyBillId + "1";
  8328. }
  8329. else
  8330. {
  8331. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8332. last = last + 1;
  8333. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8334. }
  8335. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8336. }
  8337. }
  8338. }
  8339. bool isHaveBillSucces = false;
  8340. string totalRes = "";
  8341. bill_entity.failerror = "";
  8342. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8343. {
  8344. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8345. totalRes += res;
  8346. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8347. {
  8348. isHaveBillSucces = true;
  8349. bill_entity.comId = ComId;
  8350. bill_entity.state = 1;
  8351. bill_entity.executeTime = DateTime.Now;
  8352. bill_entity.executeUser = clert;
  8353. }
  8354. else
  8355. {
  8356. bill_entity.state = 5;
  8357. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8358. }
  8359. }
  8360. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8361. bill_entity.Update();
  8362. if (isHaveBillSucces)
  8363. {
  8364. StringBuilder sql = new StringBuilder();
  8365. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8366. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8367. }
  8368. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8369. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8370. {
  8371. returnErrorMsg("开票失败");
  8372. }
  8373. else
  8374. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8375. return;
  8376. }
  8377. returnErrorMsg("找不到对应记录");
  8378. }
  8379. catch (Exception ex)
  8380. {
  8381. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8382. returnErrorMsg("操作失败");
  8383. }
  8384. }
  8385. }
  8386. public void get_erp_invoicing_back()
  8387. {
  8388. if (UrlPostParmsCheck("id"))
  8389. {
  8390. try
  8391. {
  8392. string id = GetPostString("id");
  8393. CeErpBill entiy = CeErpBill.Get(id);
  8394. if (entiy != null)
  8395. {
  8396. if (entiy.state == 0)
  8397. {
  8398. returnErrorMsg("发票还未开具");
  8399. return;
  8400. }
  8401. string[] billOrderList = entiy.billOrderId.Split(',');
  8402. int iTag = 0;
  8403. entiy.fplsh = "";
  8404. entiy.fpdm = "";
  8405. entiy.fphm = "";
  8406. foreach (string billOrderId in billOrderList)
  8407. {
  8408. iTag++;
  8409. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8410. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8411. {
  8412. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8413. try
  8414. {
  8415. Invoicing_get_response_Obj iObj = null;
  8416. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8417. if (iObj != null)
  8418. {
  8419. entiy.state = 2;
  8420. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8421. entiy.fpdm += iObj.list[0].c_fpdm;
  8422. entiy.fphm += iObj.list[0].c_fphm;
  8423. if (iTag < billOrderList.Length)
  8424. {
  8425. entiy.fplsh += ",";
  8426. entiy.fpdm += ",";
  8427. entiy.fphm += ",";
  8428. }
  8429. entiy.Update();
  8430. }
  8431. StringBuilder sql = new StringBuilder();
  8432. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8433. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8434. returnSuccessMsg("开票成功");
  8435. }
  8436. catch (Exception ex)
  8437. {
  8438. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8439. }
  8440. return;
  8441. }
  8442. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8443. {
  8444. var res_obj = new
  8445. {
  8446. data = "开票中"
  8447. };
  8448. string ro_json = JsonConvert.SerializeObject(res_obj);
  8449. returnSuccess(ro_json);
  8450. return;
  8451. }
  8452. else
  8453. {
  8454. int eidx = res.IndexOf("c_resultmsg");
  8455. int lidx = res.IndexOf("c_status");
  8456. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8457. entiy.state = 5;
  8458. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8459. entiy.Update();
  8460. returnErrorMsg("开票失败");
  8461. return;
  8462. }
  8463. }
  8464. }
  8465. }
  8466. catch (Exception ex)
  8467. {
  8468. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8469. }
  8470. return;
  8471. }
  8472. }
  8473. public void get_erp_invoicing()
  8474. {
  8475. if (UrlPostParmsCheck("id"))
  8476. {
  8477. try
  8478. {
  8479. string id = GetPostString("id");
  8480. CeErpBill entiy = CeErpBill.Get(id);
  8481. if (entiy != null)
  8482. {
  8483. if (entiy.state == 0)
  8484. {
  8485. returnErrorMsg("发票还未开具");
  8486. return;
  8487. }
  8488. if (entiy.sendType == "纸质发票")
  8489. {
  8490. if (entiy.img.Length <= 0)
  8491. {
  8492. returnErrorMsg("查无纸质发票");
  8493. return;
  8494. }
  8495. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8496. returnSuccess(returnres);
  8497. return;
  8498. }
  8499. string[] billOrderList = entiy.billOrderId.Split(',');
  8500. int iTag = 0;
  8501. string fpUrl = "";
  8502. entiy.fplsh = "";
  8503. entiy.fpdm = "";
  8504. entiy.fphm = "";
  8505. foreach (string billOrderId in billOrderList)
  8506. {
  8507. iTag++;
  8508. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8509. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8510. {
  8511. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8512. Invoicing_get_response_Obj iObj = null;
  8513. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8514. if (iObj != null)
  8515. {
  8516. //entiy.state = 2;
  8517. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8518. entiy.fpdm += iObj.list[0].c_fpdm;
  8519. entiy.fphm += iObj.list[0].c_fphm;
  8520. if (iTag < billOrderList.Length)
  8521. {
  8522. entiy.fplsh += ",";
  8523. entiy.fpdm += ",";
  8524. entiy.fphm += ",";
  8525. }
  8526. entiy.Update();
  8527. fpUrl += iObj.list[0].c_url + ",";
  8528. }
  8529. //returnSuccess(res);
  8530. StringBuilder sql = new StringBuilder();
  8531. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8532. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8533. }
  8534. else
  8535. {
  8536. int eidx = res.IndexOf("c_resultmsg");
  8537. //int lidx = res.IndexOf("c_status");
  8538. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8539. //开票失败
  8540. entiy.state = 5;
  8541. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8542. entiy.Update();
  8543. returnErrorMsg("开票失败");
  8544. return;
  8545. }
  8546. }
  8547. var returnObj = new
  8548. {
  8549. data = fpUrl
  8550. };
  8551. string ro_json = JsonConvert.SerializeObject(returnObj);
  8552. returnSuccess(ro_json);
  8553. }
  8554. }
  8555. catch (Exception ex)
  8556. {
  8557. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8558. }
  8559. return;
  8560. }
  8561. }
  8562. public void save_erp_billimg()
  8563. {
  8564. if (UrlPostParmsCheck("id"))
  8565. {
  8566. string eid = GetPostString("id");
  8567. CeErpBill bill_entity = null;
  8568. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8569. if (bill_entity != null)
  8570. {
  8571. bill_entity.img = GetPostString("img");
  8572. bill_entity.executeTime = DateTime.Now;
  8573. bill_entity.state = 2;
  8574. bill_entity.Update();
  8575. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8576. returnSuccessMsg("保存成功");
  8577. }
  8578. return;
  8579. }
  8580. }
  8581. public void upd_erp_billreturnback()
  8582. {
  8583. if (UrlPostParmsCheck("id"))
  8584. {
  8585. int eid = GetPostInt("id");
  8586. CeErpBill bill_entity = null;
  8587. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8588. if (bill_entity != null)
  8589. {
  8590. bill_entity.state = 3;
  8591. bill_entity.returnReason = GetPostString("reason");
  8592. bill_entity.Update();
  8593. returnSuccessMsg("驳回成功!");
  8594. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8595. }
  8596. return;
  8597. }
  8598. }
  8599. public void cancel_erp_bill()
  8600. {
  8601. if (UrlPostParmsCheck("id"))
  8602. {
  8603. int eid = GetPostInt("id");
  8604. int detailValue = GetPostInt("detailvalue");
  8605. CeErpBill bill_entity = null;
  8606. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8607. string cres = "";
  8608. string gres = "";
  8609. if (bill_entity != null)
  8610. {
  8611. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8612. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8613. {
  8614. int iTag = 0;
  8615. bill_entity.fplsh = "";
  8616. bill_entity.fpdm = "";
  8617. bill_entity.fphm = "";
  8618. foreach (string billOrderId in billOrderList)
  8619. {
  8620. iTag++;
  8621. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8622. if (gres.IndexOf("success") != -1)
  8623. {
  8624. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8625. Invoicing_get_response_Obj iObj = null;
  8626. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8627. if (iObj != null)
  8628. {
  8629. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8630. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8631. bill_entity.fphm += iObj.list[0].c_fphm;
  8632. if (iTag < billOrderList.Length)
  8633. {
  8634. bill_entity.fplsh += ",";
  8635. bill_entity.fpdm += ",";
  8636. bill_entity.fphm += ",";
  8637. }
  8638. bill_entity.Update();
  8639. }
  8640. }
  8641. else
  8642. {
  8643. returnErrorMsg(gres);
  8644. return;
  8645. }
  8646. }
  8647. }
  8648. if (bill_entity.sendType == "纸质发票")
  8649. {
  8650. //作废
  8651. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8652. //if (DateTime.Now.Month == extime.Month)
  8653. //{
  8654. //cres = taobaoHelper.cancel_invoicing(eid);
  8655. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8656. //{
  8657. bill_entity.state = 4;//已作废
  8658. bill_entity.Update();
  8659. returnSuccessMsg("发票已作废");
  8660. return;
  8661. //}
  8662. //else
  8663. //{
  8664. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8665. // bill_entity.Update();
  8666. // returnErrorMsg(cres);
  8667. // return;
  8668. //}
  8669. //}
  8670. //else
  8671. //{
  8672. // returnErrorMsg("纸质发票只能作废本月的发票");
  8673. // return;
  8674. //}
  8675. }
  8676. //红冲
  8677. int redTag = 0;
  8678. string[] fpdmList = bill_entity.fpdm.Split(',');
  8679. string[] fphmList = bill_entity.fphm.Split(',');
  8680. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8681. {
  8682. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8683. return;
  8684. }
  8685. foreach (string billOrderId in billOrderList)
  8686. {
  8687. redTag++;
  8688. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8689. cres += onecres;
  8690. cres += ",";
  8691. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8692. {
  8693. bill_entity.state = 4;//已作废
  8694. //bill_entity.Update();
  8695. //returnSuccessMsg("发票已红冲");
  8696. }
  8697. else if (onecres.IndexOf("重复冲红") != -1)
  8698. {
  8699. bill_entity.state = 4;//已作废
  8700. //bill_entity.Update();
  8701. //returnSuccessMsg("发票已红冲");
  8702. }
  8703. else
  8704. {
  8705. string errmsg = commonHelper.KeepChinese(onecres);
  8706. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8707. }
  8708. }
  8709. bill_entity.Update();
  8710. if (cres.IndexOf("失败") != -1)
  8711. returnErrorMsg("红冲失败");
  8712. else
  8713. returnSuccessMsg("发票已红冲");
  8714. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8715. return;
  8716. }
  8717. return;
  8718. }
  8719. }
  8720. public void del_erp_billorder()
  8721. {
  8722. if (UrlPostParmsCheck("id"))
  8723. {
  8724. string eid = GetPostString("id");
  8725. CeErpBill.Del(eid);
  8726. CeErpBill bill = CeErpBill.Get(eid);
  8727. if (bill != null)
  8728. {
  8729. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8730. }
  8731. returnSuccessMsg("删除成功");
  8732. }
  8733. }
  8734. public void finish_erp_bill()
  8735. {
  8736. if (UrlPostParmsCheck("ids"))
  8737. {
  8738. string eids = GetPostString("ids");
  8739. string[] list = eids.Split(',');
  8740. foreach (string eid in list)
  8741. {
  8742. CeErpBill bill = CeErpBill.Get(eid);
  8743. if (bill != null)
  8744. {
  8745. bill.state = 2;
  8746. bill.Update();
  8747. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8748. }
  8749. }
  8750. returnSuccessMsg("操作成功");
  8751. }
  8752. }
  8753. public void get_erp_returncash()
  8754. {
  8755. DataStruct dStruct = GetPostStruct();
  8756. List<string> lw = new List<string>();
  8757. string tid = GetPostString("tid");
  8758. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8759. string shopname = GetPostString("shopname");
  8760. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8761. string buyernick = GetPostString("buyer_nick");
  8762. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8763. string customer = GetPostString("customer");
  8764. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8765. string returndate1 = GetPostString("returndate1");
  8766. string returndate2 = GetPostString("returndate2");
  8767. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8768. if (dw.Length > 0) lw.Add(dw);
  8769. string finishDate1 = GetPostString("finishdate1");
  8770. string finishDate2 = GetPostString("finishdate2");
  8771. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8772. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8773. string returntype = GetPostString("returntype");
  8774. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8775. string returnvstate = GetPostString("returnvstate");
  8776. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8777. dStruct.Order = "created desc";
  8778. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8779. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8780. writeGridDataTableJson(dStruct.TotalCount, dt);
  8781. }
  8782. public void get_erp_staygoods()
  8783. {
  8784. DataStruct dStruct = GetPostStruct();
  8785. List<string> lw = new List<string>();
  8786. string tid = GetPostString("tid");
  8787. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8788. string shopname = GetPostString("shopname");
  8789. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8790. string wangwang = GetPostString("wangwang");
  8791. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8792. string customer = GetPostString("customer");
  8793. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8794. string returndate1 = GetPostString("returndate1");
  8795. string returndate2 = GetPostString("returndate2");
  8796. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8797. if (dw.Length > 0) lw.Add(dw);
  8798. string finishDate1 = GetPostString("finishdate1");
  8799. string finishDate2 = GetPostString("finishdate2");
  8800. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8801. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8802. string returnvstate = GetPostString("returnvstate");
  8803. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8804. string persuadetype = GetPostString("persuadetype");
  8805. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8806. string customerOrg = GetPostString("customerOrg");
  8807. if (customerOrg.Length > 0)
  8808. {
  8809. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8810. }
  8811. dStruct.Order = "creata_time desc";
  8812. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8813. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8814. writeGridDataTableJson(dStruct.TotalCount, dt);
  8815. }
  8816. public void upd_erp_staygoods()
  8817. {
  8818. if (UrlPostParmsCheck("id"))
  8819. {
  8820. int eid = GetPostInt("id");
  8821. CeErpStayGoods entity = null;
  8822. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8823. if (entity != null)
  8824. {
  8825. entity.audit_type = 1;
  8826. entity.audit_time = DateTime.Now;
  8827. entity.audit_u_id = CurrentUser.UserID;
  8828. entity.audit_u_name = CurrentUser.UserName;
  8829. entity.Update();
  8830. returnSuccessMsg("审核成功!");
  8831. return;
  8832. }
  8833. returnErrorMsg("找不到订单记录");
  8834. }
  8835. }
  8836. public void upd_erp_stayGoodsback()
  8837. {
  8838. if (UrlPostParmsCheck("id"))
  8839. {
  8840. int eid = GetPostInt("id");
  8841. CeErpStayGoods entity = null;
  8842. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8843. if (entity != null)
  8844. {
  8845. entity.audit_text = GetPostString("reason");
  8846. entity.audit_type = 2;
  8847. entity.audit_time = DateTime.Now;
  8848. entity.audit_u_id = CurrentUser.UserID;
  8849. entity.audit_u_name = CurrentUser.UserName;
  8850. entity.Update();
  8851. returnSuccessMsg("退回成功!");
  8852. return;
  8853. }
  8854. returnErrorMsg("找不到订单记录");
  8855. }
  8856. }
  8857. public void upd_erp_returncashverify()
  8858. {
  8859. if (UrlPostParmsCheck("ID"))
  8860. {
  8861. int eid = GetPostInt("ID");
  8862. CeErpReturnCash entity = null;
  8863. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8864. if (entity != null)
  8865. {
  8866. entity.cashstate = 1;
  8867. entity.verifytime = DateTime.Now;
  8868. entity.verifyuserid = CurrentUser.UserID;
  8869. entity.Update();
  8870. returnSuccessMsg("审核成功!");
  8871. return;
  8872. }
  8873. returnErrorMsg("找不到订单记录");
  8874. }
  8875. }
  8876. public void upd_all_erp_returncashverify()
  8877. {
  8878. if (UrlPostParmsCheck("ID"))
  8879. {
  8880. String[] list = GetPostString("ID").Split(',');
  8881. CeErpReturnCash entity = null;
  8882. for (int i = 0; i < list.Length; i++)
  8883. {
  8884. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8885. if (entity != null)
  8886. {
  8887. if (entity.cashstate == 1)
  8888. {
  8889. returnErrorMsg("已审核过的订单不需要在审核!");
  8890. return;
  8891. }
  8892. entity.cashstate = 1;
  8893. entity.verifytime = DateTime.Now;
  8894. entity.verifyuserid = CurrentUser.UserID;
  8895. entity.Update();
  8896. }
  8897. }
  8898. returnSuccessMsg("审核成功!");
  8899. return;
  8900. }
  8901. }
  8902. public void upd_erp_returncashback()
  8903. {
  8904. if (UrlPostParmsCheck("ID"))
  8905. {
  8906. int eid = GetPostInt("ID");
  8907. CeErpReturnCash entity = null;
  8908. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8909. if (entity != null)
  8910. {
  8911. entity.backreason = GetPostString("reason");
  8912. entity.cashstate = 2;
  8913. entity.verifytime = DateTime.Now;
  8914. entity.verifyuserid = CurrentUser.UserID;
  8915. entity.Update();
  8916. returnSuccessMsg("退回成功!");
  8917. return;
  8918. }
  8919. returnErrorMsg("找不到订单记录");
  8920. }
  8921. }
  8922. public void upd_erp_returnprice()
  8923. {
  8924. if (UrlPostParmsCheck("ID"))
  8925. {
  8926. int eid = GetPostInt("ID");
  8927. CeErpReturnCash entity = null;
  8928. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8929. if (entity != null)
  8930. {
  8931. if (entity.cashstate == 1)
  8932. {
  8933. returnErrorMsg("审核通过了不能改");
  8934. return;
  8935. }
  8936. entity.returnprice = GetPostDouble("returnprice");
  8937. entity.Update();
  8938. returnSuccessMsg("修改成功!");
  8939. return;
  8940. }
  8941. returnErrorMsg("找不到订单记录");
  8942. }
  8943. }
  8944. public void del_erp_returncash()
  8945. {
  8946. if (UrlPostParmsCheck("ID"))
  8947. {
  8948. int eid = GetPostInt("ID");
  8949. CeErpReturnCash.Del(eid);
  8950. returnSuccessMsg("操作成功");
  8951. return;
  8952. }
  8953. }
  8954. public void test_for_do_sql()
  8955. {
  8956. string sql = GetPostString("sqlstr");
  8957. if (sql.Length > 0)
  8958. {
  8959. try
  8960. {
  8961. DbHelper.DbConn.ExecuteNonQuery(sql);
  8962. var res_obj = new
  8963. {
  8964. data = "成功",
  8965. };
  8966. string ro_json = JsonConvert.SerializeObject(res_obj);
  8967. returnSuccess(ro_json);
  8968. }
  8969. catch (Exception ex)
  8970. {
  8971. var res_obj = new
  8972. {
  8973. data = ex.Message,
  8974. };
  8975. string ro_json = JsonConvert.SerializeObject(res_obj);
  8976. returnSuccess(ro_json);
  8977. }
  8978. }
  8979. }
  8980. public void get_user_info()
  8981. {
  8982. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8983. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8984. }
  8985. public void get_total_data()
  8986. {
  8987. int userId = CurrentUser.UserID;
  8988. string sql = "";
  8989. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8990. {
  8991. 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);
  8992. }
  8993. else
  8994. {
  8995. 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 " +
  8996. "(select ID from CE_ErpUser where ID = {0}) d " +
  8997. "left join " +
  8998. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8999. ") a on d.ID = a.id left join " +
  9000. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9001. ") b on a.id = b.id1 left join" +
  9002. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9003. ") c on a.id = c.id2;", userId);
  9004. }
  9005. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9006. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9007. }
  9008. public void get_date_area_total_data2()
  9009. {
  9010. int userId = CurrentUser.UserID;
  9011. string date_type = GetPostString("timetype");
  9012. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9013. string sql = "";
  9014. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9015. {
  9016. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9017. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9018. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9019. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9020. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9021. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9022. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9023. ") a on e.ID = a.id left join " +
  9024. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9025. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9026. ") b on a.id = b.id1 " +
  9027. "left join " +
  9028. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9029. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9030. ") c on a.id = c.id2 " +
  9031. "left join " +
  9032. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9033. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9034. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9035. }
  9036. else
  9037. {
  9038. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9039. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9040. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9041. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9042. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9043. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9044. ") a on e.ID = a.id left join " +
  9045. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9046. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9047. ") c on a.id = c.id2 " +
  9048. "left join " +
  9049. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9050. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9051. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9052. }
  9053. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9054. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9055. }
  9056. public void get_date_area_total_data()
  9057. {
  9058. int userId = CurrentUser.UserID;
  9059. string date_type = GetPostString("timetype");
  9060. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9061. string date1 = searchDT[0].ToString();
  9062. string date2 = searchDT[1].ToString();
  9063. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9064. {
  9065. SqlParameter[] sqlParameter ={
  9066. new SqlParameter("@userId", SqlDbType.Int,4),
  9067. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9068. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9069. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9070. };
  9071. sqlParameter[0].Value = userId;
  9072. sqlParameter[1].Value = date1;
  9073. sqlParameter[2].Value = date2;
  9074. sqlParameter[3].Direction = ParameterDirection.Output;
  9075. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9076. string res = sqlParameter[3].Value.ToString();
  9077. var res_obj = new
  9078. {
  9079. data = res
  9080. };
  9081. string ro_json = JsonConvert.SerializeObject(res_obj);
  9082. returnSuccess(ro_json);
  9083. }
  9084. else
  9085. {
  9086. SqlParameter[] sqlParameter ={
  9087. new SqlParameter("@userId", SqlDbType.Int,4),
  9088. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9089. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9090. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9091. };
  9092. sqlParameter[0].Value = userId;
  9093. sqlParameter[1].Value = date1;
  9094. sqlParameter[2].Value = date2;
  9095. sqlParameter[3].Direction = ParameterDirection.Output;
  9096. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9097. string res = sqlParameter[3].Value.ToString();
  9098. var res_obj = new
  9099. {
  9100. data = res
  9101. };
  9102. string ro_json = JsonConvert.SerializeObject(res_obj);
  9103. returnSuccess(ro_json);
  9104. }
  9105. //writeGridDataViewJson(dt.Rows.Count, dv);
  9106. }
  9107. public void get_order_list()
  9108. {
  9109. string strFields = GetPostString("paraFields");
  9110. string strOrder = GetPostString("paraOrder");
  9111. string strWhere = GetPostString("paraWhere");
  9112. string strPageSize = GetPostString("paraPageSize");
  9113. DataStruct dStruct = GetPostStruct();
  9114. dStruct.PageSize = int.Parse(strPageSize);
  9115. dStruct.Fileds = strFields;
  9116. dStruct.Order = strOrder;
  9117. dStruct.MainWhere = strWhere;
  9118. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9119. writeGridDataTableJson(dStruct.TotalCount, dt);
  9120. }
  9121. ////获取待开始订单列表
  9122. //public void get_wait_design_order_list()
  9123. //{
  9124. // string date_type = GetPostString("date_type");
  9125. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9126. // DataStruct dStruct = GetPostStruct();
  9127. // dStruct.PageSize = 1000;
  9128. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9129. // List<string> lw = new List<string>();
  9130. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9131. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9132. // dStruct.Order = "WaitDesignTime asc";
  9133. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9134. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9135. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9136. //}
  9137. //获取完成单量排名
  9138. public void get_finish_order_count_ranking()
  9139. {
  9140. /* string date_type = GetPostString("date_type");
  9141. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9142. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9143. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9144. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9145. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9146. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9147. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9148. writeGridDataTableJson(0, new DataTable());
  9149. }
  9150. public void get_finish_order_amount_ranking()
  9151. {
  9152. /*string date_type = GetPostString("date_type");
  9153. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9154. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9155. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9156. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9157. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9158. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9159. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9160. writeGridDataTableJson(0, new DataTable());
  9161. }
  9162. public void get_finish_refund_count_ranking()
  9163. {
  9164. string date_type = GetPostString("date_type");
  9165. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9166. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9167. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9168. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9169. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9170. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9171. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9172. writeGridDataTableJson(dt.Rows.Count, dt);
  9173. }
  9174. public void get_finish_refund_amount_ranking()
  9175. {
  9176. string date_type = GetPostString("date_type");
  9177. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9178. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9179. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9180. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9181. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9182. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9183. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9184. writeGridDataTableJson(dt.Rows.Count, dt);
  9185. }
  9186. public void set_erp_finishorder_director()
  9187. {
  9188. if (UrlPostParmsCheck("ctid"))
  9189. {
  9190. string eid = GetPostString("ctid");
  9191. CeErpTradeCell entity = null;
  9192. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9193. if (entity != null)
  9194. {
  9195. entity.OrderState = 8;
  9196. entity.Update();
  9197. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9198. returnSuccessMsg("操作成功!");
  9199. return;
  9200. }
  9201. returnErrorMsg("找不到记录");
  9202. }
  9203. }
  9204. public void get_erp_placeregistlist()
  9205. {
  9206. DataStruct dStruct = GetPostStruct();
  9207. List<string> lw = new List<string>();
  9208. string outsid = GetPostString("outsid");
  9209. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9210. string memo = GetPostString("memo");
  9211. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9212. string filename = GetPostString("filename");
  9213. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9214. string islate = GetPostString("islate");
  9215. if (islate.Length > 0)
  9216. {
  9217. if (islate == "1")
  9218. lw.Add(string.Format("OutLate>0"));
  9219. else
  9220. lw.Add(string.Format("OutLate=0"));
  9221. }
  9222. string placedate1 = GetPostString("placedate1");
  9223. string placedate2 = GetPostString("placedate2");
  9224. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9225. if (dw.Length > 0) lw.Add(dw);
  9226. string deliveryDate1 = GetPostString("deliverydate1");
  9227. string deliveryDate2 = GetPostString("deliverydate2");
  9228. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9229. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9230. dStruct.Order = "ID desc";
  9231. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9232. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9233. writeGridDataTableJson(dStruct.TotalCount, dt);
  9234. }
  9235. public void ins_erp_placeregist()
  9236. {
  9237. if (UrlPostParmsCheck("id"))
  9238. {
  9239. string eid = GetPostString("id");
  9240. CeErpPlaceRegister entity = null;
  9241. if (eid == "0")//新增
  9242. {
  9243. entity = new CeErpPlaceRegister();
  9244. string xdTime = GetPostString("placeTime");
  9245. if (xdTime.Length > 0)
  9246. {
  9247. entity.PlactTime = Convert.ToDateTime(xdTime);
  9248. }
  9249. string fhTime = GetPostString("deliveryTime");
  9250. if (fhTime.Length > 0)
  9251. {
  9252. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9253. }
  9254. string preTime = GetPostString("preOutTime");
  9255. if (preTime.Length > 0)
  9256. {
  9257. entity.PreOutTime = Convert.ToDateTime(preTime);
  9258. }
  9259. entity.DeliveryCount = GetPostInt("deliveryCount");
  9260. entity.ReceiveCount = GetPostInt("receiveCount");
  9261. entity.OutSid = GetPostString("outSid");
  9262. entity.FileName = GetPostString("fileName");
  9263. entity.Memo = GetPostString("memo");
  9264. entity.AddUserId = CurrentUser.UserID;
  9265. entity.CreateTime = DateTime.Now;
  9266. entity.Img = GetPostString("img");
  9267. entity.Supplier = GetPostInt("supplier");
  9268. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9269. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9270. {
  9271. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9272. DateTime dt2 = (DateTime)entity.PreOutTime;
  9273. TimeSpan span = dt1.Subtract(dt2);
  9274. if (span.Days > 0)
  9275. {
  9276. entity.OutLate = span.Days;
  9277. }
  9278. }
  9279. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9280. entity.Create();
  9281. returnSuccessMsg("添加成功!");
  9282. return;
  9283. }
  9284. else //修改
  9285. {
  9286. entity = CeErpPlaceRegister.Get(eid);
  9287. if (entity != null)
  9288. {
  9289. string xdTime = GetPostString("placeTime");
  9290. if (xdTime.Length > 0)
  9291. {
  9292. entity.PlactTime = Convert.ToDateTime(xdTime);
  9293. }
  9294. string fhTime = GetPostString("deliveryTime");
  9295. if (fhTime.Length > 0)
  9296. {
  9297. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9298. }
  9299. string preTime = GetPostString("preOutTime");
  9300. if (preTime.Length > 0)
  9301. {
  9302. entity.PreOutTime = Convert.ToDateTime(preTime);
  9303. }
  9304. entity.DeliveryCount = GetPostInt("deliveryCount");
  9305. entity.ReceiveCount = GetPostInt("receiveCount");
  9306. if (entity.DeliveryCount == entity.ReceiveCount)
  9307. {
  9308. entity.CurState = "已完成";
  9309. }
  9310. else
  9311. {
  9312. entity.CurState = "未完成";
  9313. }
  9314. entity.OutSid = GetPostString("outSid");
  9315. entity.FileName = GetPostString("fileName");
  9316. entity.Memo = GetPostString("memo");
  9317. entity.Img = GetPostString("img");
  9318. entity.Supplier = GetPostInt("supplier");
  9319. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9320. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9321. {
  9322. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9323. DateTime dt2 = (DateTime)entity.PreOutTime;
  9324. TimeSpan span = dt1.Subtract(dt2);
  9325. if (span.Days > 0)
  9326. {
  9327. entity.OutLate = span.Days;
  9328. }
  9329. }
  9330. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9331. entity.Update();
  9332. returnSuccessMsg("修改成功");
  9333. return;
  9334. }
  9335. returnErrorMsg("找不到对应的记录");
  9336. return;
  9337. }
  9338. }
  9339. returnErrorMsg("缺少必要参数");
  9340. }
  9341. public void del_erp_placeregist()
  9342. {
  9343. string eid = GetPostString("id");
  9344. CeErpPlaceRegister.Del(eid);
  9345. returnSuccessMsg("删除成功!");
  9346. return;
  9347. }
  9348. public void ins_erp_placeregistbyorder()
  9349. {
  9350. string ctid = GetPostString("ctid");
  9351. if (ctid.Length > 0)
  9352. {
  9353. StringBuilder sql = new StringBuilder();
  9354. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9355. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9356. if (dt.Rows.Count > 0)
  9357. {
  9358. foreach (DataRow dr in dt.Rows)
  9359. {
  9360. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9361. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9362. entity.AddUserId = CurrentUser.UserID;
  9363. entity.tid = dr["tid"].ToString();
  9364. entity.Did = Convert.ToString(dr["ctid"]);
  9365. entity.splitTag = dr["SplitTag"].ToString();
  9366. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9367. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9368. if (pre_ctid.Length > 0)
  9369. {
  9370. sellmemo = sellmemo.Replace(pre_ctid, "");
  9371. }
  9372. sellmemo = sellmemo.Replace("[", "");
  9373. sellmemo = sellmemo.Replace("]", "");
  9374. entity.FileName = sellmemo;
  9375. string count = dr["ProductCount"].ToString();
  9376. int usecount = commonHelper.getIntCountFromString(count);
  9377. entity.DeliveryCount = usecount;
  9378. entity.CurState = "未完成";
  9379. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9380. {
  9381. entity.Supplier = 24;//dl手提袋定制
  9382. }
  9383. else
  9384. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9385. entity.CreateTime = DateTime.Now;
  9386. entity.Create();
  9387. }
  9388. returnSuccessMsg("操作成功");
  9389. return;
  9390. }
  9391. returnErrorMsg("没有找到对应订单");
  9392. return;
  9393. }
  9394. returnErrorMsg("缺少订单编号");
  9395. return;
  9396. }
  9397. public void get_erp_persuadelist()
  9398. {
  9399. DataStruct dStruct = GetPostStruct();
  9400. List<string> lw = new List<string>();
  9401. string ctid = GetPostString("ctid");
  9402. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9403. string shopname = GetPostString("shopname");
  9404. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9405. string buyernick = GetPostString("buyer_nick");
  9406. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9407. string customer = GetPostString("customer");
  9408. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9409. string returndate1 = GetPostString("returndate1");
  9410. string returndate2 = GetPostString("returndate2");
  9411. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9412. if (dw.Length > 0) lw.Add(dw);
  9413. string finishDate1 = GetPostString("finishdate1");
  9414. string finishDate2 = GetPostString("finishdate2");
  9415. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9416. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9417. string persuadetype = GetPostString("persuadetype");
  9418. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9419. string returnvstate = GetPostString("returnvstate");
  9420. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9421. dStruct.Order = "created desc";
  9422. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9423. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9424. writeGridDataTableJson(dStruct.TotalCount, dt);
  9425. }
  9426. public void upd_erp_returnpersuadeback()
  9427. {
  9428. if (UrlPostParmsCheck("ID"))
  9429. {
  9430. int eid = GetPostInt("ID");
  9431. CeErpPersuade entity = null;
  9432. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9433. if (entity != null)
  9434. {
  9435. entity.backreason = GetPostString("reason");
  9436. entity.pstate = 2;
  9437. entity.verifytime = DateTime.Now;
  9438. entity.verifyuserid = CurrentUser.UserID;
  9439. entity.Update();
  9440. returnSuccessMsg("退回成功!");
  9441. return;
  9442. }
  9443. returnErrorMsg("找不到订单记录");
  9444. }
  9445. }
  9446. public void upd_erp_returnpersuadeverify()
  9447. {
  9448. if (UrlPostParmsCheck("ID"))
  9449. {
  9450. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9451. {
  9452. returnErrorMsg("暂无权限审核");
  9453. return;
  9454. }
  9455. int eid = GetPostInt("ID");
  9456. CeErpPersuade entity = null;
  9457. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9458. if (entity != null)
  9459. {
  9460. entity.pstate = 1;
  9461. entity.verifytime = DateTime.Now;
  9462. entity.verifyuserid = CurrentUser.UserID;
  9463. entity.Update();
  9464. returnSuccessMsg("审核成功!");
  9465. return;
  9466. }
  9467. returnErrorMsg("找不到订单记录");
  9468. }
  9469. }
  9470. public void del_erp_persuade()
  9471. {
  9472. if (UrlPostParmsCheck("ID"))
  9473. {
  9474. int eid = GetPostInt("ID");
  9475. CeErpPersuade.Del(eid);
  9476. returnSuccessMsg("操作成功");
  9477. return;
  9478. }
  9479. }
  9480. public void get_erp_oldcustoupload()
  9481. {
  9482. DataStruct dStruct = GetPostStruct();
  9483. List<string> lw = new List<string>();
  9484. string buyernick = GetPostString("buyer_nick");
  9485. if (buyernick.Length > 0)
  9486. {
  9487. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9488. }
  9489. else
  9490. return;
  9491. dStruct.Order = "pay_time desc";
  9492. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9493. DataTable dt = null;
  9494. dt = WebCache.GetData("view_erptradecell", dStruct);
  9495. writeGridDataTableJson(dStruct.TotalCount, dt);
  9496. }
  9497. public void get_erp_checkorderlist()
  9498. {
  9499. DataStruct dStruct = GetPostStruct();
  9500. List<string> lw = new List<string>();
  9501. string tid = GetPostString("ctid");
  9502. if (tid.Length > 0)
  9503. {
  9504. string select_tid = getTidByCtid(tid);
  9505. lw.Add(string.Format("tid='{0}'", select_tid));
  9506. }
  9507. string shopname = GetPostString("shopname");
  9508. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9509. string buyernick = GetPostString("buyer_nick");
  9510. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9511. string customer = GetPostString("customer");
  9512. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9513. string design = GetPostString("design");
  9514. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9515. string orderState = GetPostString("orderState");
  9516. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9517. string address = GetPostString("address");
  9518. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9519. string sellermemo = GetPostString("seller_memo");
  9520. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9521. string supplier = GetPostString("supplier");
  9522. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9523. {
  9524. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9525. }
  9526. else
  9527. {
  9528. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9529. }
  9530. string date1 = GetPostString("date1");
  9531. string date2 = GetPostString("date2");
  9532. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9533. if (dw.Length > 0) lw.Add(dw);
  9534. string placedate1 = GetPostString("placedate1");
  9535. string placedate2 = GetPostString("placedate2");
  9536. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9537. if (fdw.Length > 0) lw.Add(fdw);
  9538. string price1 = GetPostString("price1");
  9539. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9540. string price2 = GetPostString("price2");
  9541. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9542. string checkst = GetPostString("checkstate");
  9543. if (checkst.Length > 0 && "10".Equals(checkst))
  9544. {
  9545. lw.Add(string.Format("CheckOut>0"));
  9546. }
  9547. else
  9548. {
  9549. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9550. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9551. }
  9552. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9553. {
  9554. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9555. }
  9556. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9557. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9558. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9559. writeGridDataTableJson(dStruct.TotalCount, dt);
  9560. }
  9561. public void ins_erp_startCheck()
  9562. {
  9563. if (UrlPostParmsCheck("ctid"))
  9564. {
  9565. string eid = GetPostString("ctid");
  9566. CeErpTradeCell entity = null;
  9567. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9568. if (entity != null)
  9569. {
  9570. entity.MemoOpt = 4;
  9571. entity.UpdateTime = DateTime.Now;
  9572. entity.Update();
  9573. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9574. CeErpSukuraData.createInfo(entity.ctid, 6);
  9575. returnSuccessMsg("操作成功!");
  9576. return;
  9577. }
  9578. returnErrorMsg("找不到记录");
  9579. }
  9580. }
  9581. public void upd_erp_sendXlw()
  9582. {
  9583. if (UrlPostParmsCheck("ctid"))
  9584. {
  9585. string eid = GetPostString("ctid");
  9586. CeErpTradeCell entity = null;
  9587. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9588. if (entity != null)
  9589. {
  9590. if (entity.IsSendGift == 1)
  9591. {
  9592. returnErrorMsg("请勿重复标记");
  9593. return;
  9594. }
  9595. entity.IsSendGift = 1;
  9596. entity.Update();
  9597. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9598. returnSuccessMsg("操作成功!");
  9599. return;
  9600. }
  9601. returnErrorMsg("找不到记录");
  9602. }
  9603. }
  9604. public void cancel_sendXlw()
  9605. {
  9606. if (UrlPostParmsCheck("ctid"))
  9607. {
  9608. string eid = GetPostString("ctid");
  9609. CeErpTradeCell entity = null;
  9610. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9611. if (entity != null)
  9612. {
  9613. if (entity.IsSendGift == 0)
  9614. {
  9615. returnErrorMsg("未标记小礼物");
  9616. return;
  9617. }
  9618. entity.IsSendGift = 0;
  9619. entity.Update();
  9620. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9621. returnSuccessMsg("操作成功!");
  9622. return;
  9623. }
  9624. returnErrorMsg("找不到记录");
  9625. }
  9626. }
  9627. public void get_erp_designbill()
  9628. {
  9629. DataStruct dStruct = GetPostStruct();
  9630. List<string> lw = new List<string>();
  9631. int isMy = GetInt("my");
  9632. if (isMy == 1)
  9633. {
  9634. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9635. }
  9636. string tid = GetPostString("tid");
  9637. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9638. string userName = GetPostString("design");
  9639. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9640. string price1 = GetPostString("price1");
  9641. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9642. string price2 = GetPostString("price2");
  9643. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9644. string rePrice1 = GetPostString("rePrice1");
  9645. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9646. string rePrice2 = GetPostString("rePrice2");
  9647. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9648. string designerType = GetPostString("designerType");
  9649. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9650. string orderState = GetPostString("orderState");
  9651. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9652. string endTime1 = GetPostString("endTime1");
  9653. string endTime2 = GetPostString("endTime2");
  9654. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9655. if (dw.Length > 0) lw.Add(dw);
  9656. string isDk = GetPostString("isDk");
  9657. if (isDk == "1")
  9658. {
  9659. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9660. }
  9661. else if (isDk == "0")
  9662. {
  9663. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9664. }
  9665. dStruct.Order = "oid, create_time desc";
  9666. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9667. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9668. writeGridDataTableJson(dStruct.TotalCount, dt);
  9669. }
  9670. public void upd_erp_designerbill()
  9671. {
  9672. if (UrlPostParmsCheck("ID"))
  9673. {
  9674. string eid = GetPostString("ID");
  9675. CeErpDesignerBill entity = null;
  9676. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9677. if (entity != null)
  9678. {
  9679. if (GetPostDouble("designerpirce") > 0)
  9680. {
  9681. entity.realPrice = GetPostDouble("designerpirce");
  9682. entity.update_time = DateTime.Now;
  9683. entity.update_u_id = CurrentUser.UserID;
  9684. entity.update_u_name = CurrentUser.UserName;
  9685. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9686. entity.Update();
  9687. returnSuccessMsg("操作成功!");
  9688. return;
  9689. }
  9690. else
  9691. {
  9692. entity.price = GetPostDouble("price");
  9693. entity.update_time = DateTime.Now;
  9694. entity.update_u_id = CurrentUser.UserID;
  9695. entity.update_u_name = CurrentUser.UserName;
  9696. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9697. entity.Update();
  9698. returnSuccessMsg("操作成功!");
  9699. return;
  9700. }
  9701. }
  9702. returnErrorMsg("找不到记录");
  9703. }
  9704. }
  9705. public void audit_erp_designerbill()
  9706. {
  9707. if (UrlPostParmsCheck("ID"))
  9708. {
  9709. string eid = GetPostString("ID");
  9710. CeErpDesignerBill entity = null;
  9711. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9712. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9713. if (entity != null)
  9714. {
  9715. entity.realPrice = GetPostDouble("designerpirce");
  9716. entity.update_time = DateTime.Now;
  9717. entity.update_u_id = CurrentUser.UserID;
  9718. entity.update_u_name = CurrentUser.UserName;
  9719. entity.isAudit = 1;
  9720. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9721. entity.Update();
  9722. if (orderEntity != null)
  9723. {
  9724. orderEntity.IsReadTag = 3;
  9725. orderEntity.Update();
  9726. }
  9727. returnSuccessMsg("操作成功!");
  9728. return;
  9729. }
  9730. returnErrorMsg("找不到记录");
  9731. }
  9732. }
  9733. public void all_audit_erp_designerbill()
  9734. {
  9735. if (UrlPostParmsCheck("idList"))
  9736. {
  9737. string[] list = GetPostString("idList").Split(',');
  9738. CeErpDesignerBill entity = null;
  9739. for (int i = 0; i < list.Length; i++)
  9740. {
  9741. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9742. if (entity == null) return;
  9743. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9744. if (orderEntity == null) return;
  9745. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9746. entity.update_time = DateTime.Now;
  9747. entity.update_u_id = CurrentUser.UserID;
  9748. entity.update_u_name = CurrentUser.UserName;
  9749. entity.isAudit = 1;
  9750. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9751. entity.Update();
  9752. orderEntity.IsReadTag = 3;
  9753. orderEntity.Update();
  9754. }
  9755. returnSuccessMsg("操作成功!");
  9756. return;
  9757. }
  9758. }
  9759. public void get_erp_sameorders()
  9760. {
  9761. if (UrlPostParmsCheck("ctid"))
  9762. {
  9763. string eid = GetPostString("ctid");
  9764. CeErpTradeCell entity = null;
  9765. entity = CeErpTradeCell.GetByCtid(eid);
  9766. if (entity != null)
  9767. {
  9768. StringBuilder sql = new StringBuilder();
  9769. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9770. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9771. var res = new
  9772. {
  9773. data = dt.Rows.Count
  9774. };
  9775. string ro_jsond = JsonConvert.SerializeObject(res);
  9776. returnSuccess(ro_jsond);
  9777. return;
  9778. }
  9779. returnErrorMsg("未找到订单");
  9780. return;
  9781. }
  9782. returnErrorMsg("缺少必要的参数");
  9783. }
  9784. public void get_erp_islasthavesameorder()
  9785. {
  9786. if (UrlPostParmsCheck("ctid"))
  9787. {
  9788. string eid = GetPostString("ctid");
  9789. string[] ctidList = eid.Split(',');
  9790. StringBuilder sql = new StringBuilder();
  9791. string tisCtid = "";
  9792. foreach (string ctid in ctidList)
  9793. {
  9794. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9795. if (entity != null)
  9796. {
  9797. sql = new StringBuilder();
  9798. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9799. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9800. if (dth.Rows.Count > 0)
  9801. {
  9802. tisCtid += entity.ctid;
  9803. tisCtid += ",";
  9804. }
  9805. }
  9806. }
  9807. if (tisCtid.Length > 0)
  9808. {
  9809. var res = new
  9810. {
  9811. data = tisCtid
  9812. };
  9813. string ro_jsond = JsonConvert.SerializeObject(res);
  9814. returnSuccess(ro_jsond);
  9815. }
  9816. else
  9817. {
  9818. var res = new
  9819. {
  9820. data = ""
  9821. };
  9822. string ro_jsond = JsonConvert.SerializeObject(res);
  9823. returnSuccess(ro_jsond);
  9824. }
  9825. return;
  9826. }
  9827. returnErrorMsg("缺少必要的参数");
  9828. }
  9829. public void file_client_down_url()
  9830. {
  9831. if (!UrlPostParmsCheck("userId"))
  9832. {
  9833. returnErrorMsg("缺少必要的参数");
  9834. }
  9835. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9836. }
  9837. public void checkout_form_data()
  9838. {
  9839. if (!UrlPostParmsCheck("tid"))
  9840. {
  9841. returnErrorMsg("缺少必要的参数");
  9842. }
  9843. string tid = GetPostString("tid");
  9844. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9845. if (ceErpOrderFormData != null)
  9846. {
  9847. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9848. returnSuccess(ro_jsond);
  9849. return;
  9850. }
  9851. returnErrorMsg("尚未有文件!");
  9852. }
  9853. public void back_supplier_audit()
  9854. {
  9855. int userId = CurrentUser.UserID;
  9856. StringBuilder sql = new StringBuilder();
  9857. 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);
  9858. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9859. if (dt.Rows.Count > 0)
  9860. {
  9861. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9862. }
  9863. else
  9864. {
  9865. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9866. }
  9867. }
  9868. public void back_supplier_query()
  9869. {
  9870. string eid = GetPostString("ctid");
  9871. if (eid != "")
  9872. {
  9873. StringBuilder sql = new StringBuilder();
  9874. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9875. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9876. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9877. }
  9878. else
  9879. {
  9880. returnErrorMsg("找不到订单记录");
  9881. return;
  9882. }
  9883. }
  9884. public void verified_to_order()
  9885. {
  9886. int userId = CurrentUser.UserID;
  9887. StringBuilder sql = new StringBuilder();
  9888. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9889. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9890. if (dt.Rows.Count > 0)
  9891. {
  9892. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9893. }
  9894. else
  9895. {
  9896. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9897. }
  9898. }
  9899. public void upd_supplier_audit()
  9900. {
  9901. if (UrlPostParmsCheck("ctid"))
  9902. {
  9903. string eid = GetPostString("ctid");
  9904. string reason = GetPostString("returnreason");
  9905. CeErpTradeCell entity = null;
  9906. CeWithdraw withdraw = null;
  9907. withdraw = CeWithdraw.GetByTid(eid);
  9908. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9909. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9910. {
  9911. if (withdraw != null)
  9912. {
  9913. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9914. {
  9915. returnSuccessMsg("您没有权限操作!");
  9916. return;
  9917. }
  9918. else
  9919. {
  9920. if (reason.Equals("1"))
  9921. {
  9922. if (entity.OrderState == -1)
  9923. {
  9924. if (entity.FinishPlaceTime == null)
  9925. {
  9926. entity.OrderState = 2;
  9927. }
  9928. else
  9929. {
  9930. entity.OrderState = 6;
  9931. }
  9932. }
  9933. entity.Update();
  9934. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9935. if (withdraw != null)
  9936. {
  9937. withdraw.status = int.Parse(reason);
  9938. withdraw.Update();
  9939. }
  9940. returnSuccessMsg("操作成功!");
  9941. return;
  9942. }
  9943. else
  9944. {
  9945. withdraw.status = int.Parse(reason);
  9946. withdraw.acknowledgingtime = DateTime.Now;
  9947. withdraw.Update();
  9948. returnSuccessMsg("查看详细请点击线下订单查询");
  9949. return;
  9950. }
  9951. }
  9952. }
  9953. // 第一个字符是 'N'
  9954. }
  9955. if (eid[0] != 'N')
  9956. {
  9957. }
  9958. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9959. {
  9960. entity.IsVerifyToSupplier = false;
  9961. entity.IsReturn = 1;
  9962. entity.ReturnTime = DateTime.Now;
  9963. entity.ReturnReason = reason;
  9964. if (entity.OrderState == 6)
  9965. {
  9966. entity.OrderState = 5;
  9967. }
  9968. entity.Update();
  9969. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9970. if (withdraw != null)
  9971. {
  9972. withdraw.status = int.Parse(reason);
  9973. withdraw.Update();
  9974. }
  9975. returnSuccessMsg("操作成功!");
  9976. return;
  9977. }
  9978. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9979. {
  9980. ;
  9981. if (withdraw != null)
  9982. {
  9983. withdraw.status = int.Parse(reason);
  9984. withdraw.acknowledgingtime = DateTime.Now;
  9985. withdraw.Update();
  9986. returnSuccessMsg("供应商取消撤回!");
  9987. return;
  9988. }
  9989. }
  9990. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9991. {
  9992. if (entity.OrderState == -1)
  9993. {
  9994. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  9995. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9996. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  9997. {
  9998. returnErrorMsg("台湾客户需填写身份证!");
  9999. return;
  10000. }
  10001. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0)
  10002. {
  10003. returnErrorMsg("偏远地区需要填写物流费!");
  10004. return;
  10005. }
  10006. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10007. {
  10008. returnErrorMsg("订单spu没有确认无法通过审核!");
  10009. return;
  10010. }
  10011. if (entity.FinishPlaceTime == null)
  10012. {
  10013. entity.OrderState = 2;
  10014. }
  10015. else
  10016. {
  10017. entity.OrderState = 3;
  10018. }
  10019. commonHelper.getCytPrice(entity);
  10020. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10021. }
  10022. entity.Update();
  10023. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10024. if (withdraw != null)
  10025. {
  10026. withdraw.status = int.Parse(reason);
  10027. withdraw.Update();
  10028. }
  10029. returnSuccessMsg("操作成功!");
  10030. return;
  10031. }
  10032. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10033. {
  10034. if (withdraw == null)
  10035. {
  10036. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10037. return;
  10038. }
  10039. }
  10040. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10041. {
  10042. if (withdraw != null)
  10043. {
  10044. withdraw.status = int.Parse(reason);
  10045. withdraw.acknowledgingtime = DateTime.Now;
  10046. withdraw.Update();
  10047. returnSuccessMsg("查看详细请点击线下订单查询");
  10048. return;
  10049. }
  10050. }
  10051. return;
  10052. }
  10053. }
  10054. //校验报价
  10055. public void refund_order_tip()
  10056. {
  10057. int userid = CurrentUser.UserID;
  10058. int sectionId = CurrentUser.UserPost.OrgID;
  10059. StringBuilder sql = new StringBuilder();
  10060. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10061. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10062. List<string> ids = new List<string>();
  10063. if (dth.Rows.Count > 0)
  10064. {
  10065. foreach (DataRow dr in dth.Rows)
  10066. {
  10067. ids.Add(dr["ID"].ToString());
  10068. }
  10069. try
  10070. {
  10071. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10072. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10073. }
  10074. catch (Exception ex)
  10075. {
  10076. }
  10077. }
  10078. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10079. }
  10080. public void refund_order_Design()
  10081. {
  10082. int userid = CurrentUser.UserID;
  10083. int sectionId = CurrentUser.UserPost.OrgID;
  10084. StringBuilder sql = new StringBuilder();
  10085. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10086. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10087. List<string> ids = new List<string>();
  10088. if (dth.Rows.Count > 0)
  10089. {
  10090. foreach (DataRow dr in dth.Rows)
  10091. {
  10092. ids.Add(dr["ID"].ToString());
  10093. }
  10094. try
  10095. {
  10096. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10097. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10098. }
  10099. catch (Exception ex)
  10100. {
  10101. }
  10102. }
  10103. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10104. }
  10105. public void change_order_info()
  10106. {
  10107. int userid = CurrentUser.UserID;
  10108. StringBuilder sql = new StringBuilder();
  10109. 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);
  10110. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10111. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10112. }
  10113. public void change_win_mome()
  10114. {
  10115. if (UrlPostParmsCheck("id,ctid"))
  10116. {
  10117. string id = GetPostString("id");
  10118. string ctid = GetPostString("ctid");
  10119. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10120. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10121. if (ce == null || ceErpMessageTip == null)
  10122. {
  10123. returnSuccessMsg("未找到对应的订单!");
  10124. return;
  10125. }
  10126. if (ce.OrderState >= 5)
  10127. {
  10128. ceErpMessageTip.isVisit = true;
  10129. ceErpMessageTip.Update();
  10130. returnSuccessMsg("已上传文件无法修改!");
  10131. return;
  10132. }
  10133. int type = GetPostInt("type");
  10134. string content = GetPostString("content");
  10135. if (type == 0)
  10136. {
  10137. content = content.Replace("(", "(");
  10138. content = content.Replace(")", ")");
  10139. string check = MidStrEx(content, "(", ")").Trim();
  10140. if (string.IsNullOrEmpty(check))
  10141. {
  10142. returnSuccessMsg("文件名格式不正确");
  10143. return;
  10144. }
  10145. }
  10146. ce.seller_memo = content;
  10147. ce.Update();
  10148. ceErpMessageTip.isVisit = true;
  10149. ceErpMessageTip.Update();
  10150. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10151. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10152. ApiVo apiVo = new ApiVo();
  10153. apiVo.orderNumber = ce.ctid;
  10154. apiVo.actionName = "demandDesign";
  10155. apiVo.orderRemarks = content;
  10156. apiVo.demandExamine = type + 1;
  10157. designHelper.API_WorkCore(apiVo);//demandDesign
  10158. returnSuccessMsg("修改成功!");
  10159. }
  10160. }
  10161. public static string MidStrEx(string sourse, string startstr, string endstr)
  10162. {
  10163. string result = string.Empty;
  10164. int startindex, endindex;
  10165. try
  10166. {
  10167. startindex = sourse.IndexOf(startstr);
  10168. if (startindex == -1)
  10169. return result;
  10170. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10171. endindex = tmpstr.IndexOf(endstr);
  10172. if (endindex == -1)
  10173. return result;
  10174. result = tmpstr.Remove(endindex);
  10175. }
  10176. catch (Exception ex)
  10177. {
  10178. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10179. }
  10180. return result;
  10181. }
  10182. public void refund_order_list()
  10183. {
  10184. int userid = CurrentUser.UserID;
  10185. int sectionId = CurrentUser.UserPost.OrgID;
  10186. StringBuilder sql = new StringBuilder();
  10187. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10188. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10189. DataStruct dStruct = GetPostStruct();
  10190. DataTable dt = null;
  10191. List<string> ids = new List<string>();
  10192. List<string> tids = new List<string>();
  10193. if (dth.Rows.Count > 0)
  10194. {
  10195. foreach (DataRow dr in dth.Rows)
  10196. {
  10197. tids.Add("'" + dr["tid"].ToString() + "'");
  10198. ids.Add(dr["id"].ToString());
  10199. }
  10200. try
  10201. {
  10202. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10203. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10204. List<string> lw = new List<string>();
  10205. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10206. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10207. dt = WebCache.GetData("view_orderlist", dStruct);
  10208. }
  10209. catch (Exception ex)
  10210. {
  10211. }
  10212. }
  10213. writeGridDataTableJson(dStruct.TotalCount, dt);
  10214. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10215. }
  10216. //新增
  10217. public void order_batch_downloads()
  10218. {
  10219. string ceid = GetPostString("tid");
  10220. String[] tid = ceid.Split(',');
  10221. order_batch_caiyingtong(tid);
  10222. /* (string success, string errors) = UploadFiles(tid);
  10223. returnSuccessMsg(success + errors);*/
  10224. return;
  10225. }
  10226. //报价接口
  10227. public void Get_To_Quote()
  10228. {
  10229. string ceid = GetPostString("ctid");
  10230. if (ceid != null)
  10231. {
  10232. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10233. if (entity != null)
  10234. {
  10235. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10236. {
  10237. return;
  10238. }
  10239. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10240. double price = 0;
  10241. if (cp == null)
  10242. {
  10243. JObject jsonObject12 = new JObject
  10244. {
  10245. { "UserId", "77886" },
  10246. { "Pwd", "lt666888" },
  10247. { "Filename", entity.seller_memo }
  10248. };
  10249. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10250. JObject jsonObjects1 = JObject.Parse(response1);
  10251. string ms1g = (string)jsonObjects1["msg"];
  10252. if (ms1g == "报价成功")
  10253. {
  10254. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10255. string data = (string)jsonObject1["price"];
  10256. 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 + "');";
  10257. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10258. returnSuccessMsg("获取报价成功:" + data);
  10259. price = Convert.ToDouble(data);
  10260. }
  10261. else
  10262. {
  10263. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10264. return;
  10265. }
  10266. }
  10267. String[] beizhu = entity.seller_memo.Split('-');
  10268. String chanp = "";
  10269. if (beizhu.Length > 0)
  10270. {
  10271. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10272. }
  10273. else
  10274. {
  10275. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10276. }
  10277. JObject jsonObject = new JObject
  10278. {
  10279. { "UserId", "77886" },
  10280. { "Pwd", "lt666888" },
  10281. { "Filename", chanp }
  10282. };
  10283. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10284. JObject jsonObjects = JObject.Parse(response);
  10285. string msg = (string)jsonObjects["msg"];
  10286. if (msg == "报价成功")
  10287. {
  10288. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10289. string data = (string)jsonObject1["price"];
  10290. 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 + "');";
  10291. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10292. returnSuccessMsg("获取报价成功:" + data);
  10293. price = Convert.ToDouble(data);
  10294. }
  10295. else
  10296. {
  10297. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10298. return;
  10299. }
  10300. if (price > 0)
  10301. {
  10302. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10303. if (ceErpTradeCellExtend == null)
  10304. {
  10305. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10306. ceErpTradeCellExtend.ctid = entity.ctid;
  10307. ceErpTradeCellExtend.payment_cyt = price;
  10308. ceErpTradeCellExtend.Create();
  10309. }
  10310. else
  10311. {
  10312. ceErpTradeCellExtend.payment_cyt = price;
  10313. ceErpTradeCellExtend.Update();
  10314. }
  10315. }
  10316. return;
  10317. }
  10318. }
  10319. else
  10320. {
  10321. returnErrorMsg("请至少选择一条数据");
  10322. return;
  10323. }
  10324. }
  10325. //新增
  10326. public void order_To_Supplier()
  10327. {
  10328. string ceid = GetPostString("tid");
  10329. String[] tid = ceid.Split(',');
  10330. if (tid.Length > 0)
  10331. {
  10332. try
  10333. {
  10334. for (int i = 0; i < tid.Length; i++)
  10335. {
  10336. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10337. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10338. entity.SupplierId = suid;
  10339. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10340. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10341. entity.Update();
  10342. }
  10343. }
  10344. catch (Exception ex)
  10345. {
  10346. returnErrorMsg("自动匹配供应商失败");
  10347. return;
  10348. }
  10349. }
  10350. else
  10351. {
  10352. returnErrorMsg("请至少选择一条数据");
  10353. return;
  10354. }
  10355. returnSuccessMsg("自动匹配供应商成功");
  10356. return;
  10357. }
  10358. public (string, string) UploadFiles(string[] urls)
  10359. {
  10360. string success = "";
  10361. string errors = "";
  10362. int userid = CurrentUser.UserID;
  10363. foreach (string url in urls)
  10364. {
  10365. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10366. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10367. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10368. {
  10369. JObject jsonObject = new JObject
  10370. {
  10371. { "Userid", "77886" },
  10372. { "pwd", "cyt86435015" },
  10373. { "content", base64FileContent },
  10374. { "ext", Path.GetExtension(fileName) }
  10375. };
  10376. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10377. JObject jsonObjects = JObject.Parse(response);
  10378. string msg = (string)jsonObjects["msg"];
  10379. if (msg.Equals("上传成功"))
  10380. {
  10381. success += url + " 上传成功";
  10382. }
  10383. else
  10384. {
  10385. errors += url + " 上传失败";
  10386. }
  10387. }
  10388. else
  10389. {
  10390. errors += url + " 格式出现问题";
  10391. }
  10392. }
  10393. if (urls.Length == 0)
  10394. {
  10395. return (success, errors);
  10396. }
  10397. return (success, errors);
  10398. }
  10399. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10400. {
  10401. return true; //总是接受
  10402. }
  10403. public static string HttpPost(string url, string param = null)
  10404. {
  10405. HttpWebRequest request;
  10406. //如果是发送HTTPS请求
  10407. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10408. {
  10409. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10410. request = WebRequest.Create(url) as HttpWebRequest;
  10411. request.ProtocolVersion = HttpVersion.Version10;
  10412. }
  10413. else
  10414. {
  10415. request = WebRequest.Create(url) as HttpWebRequest;
  10416. }
  10417. request.Method = "POST";
  10418. request.ContentType = "application/json";
  10419. request.Accept = "*/*";
  10420. request.Timeout = 120000;
  10421. request.AllowAutoRedirect = false;
  10422. StreamWriter requestStream = null;
  10423. WebResponse response = null;
  10424. string responseStr = null;
  10425. try
  10426. {
  10427. requestStream = new StreamWriter(request.GetRequestStream());
  10428. requestStream.Write(param);
  10429. requestStream.Close();
  10430. response = request.GetResponse();
  10431. if (response != null)
  10432. {
  10433. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10434. responseStr = reader.ReadToEnd();
  10435. reader.Close();
  10436. }
  10437. }
  10438. catch (Exception ex)
  10439. {
  10440. return ex.Message;
  10441. }
  10442. finally
  10443. {
  10444. request = null;
  10445. requestStream = null;
  10446. response = null;
  10447. }
  10448. return responseStr;
  10449. }
  10450. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10451. {
  10452. string base64FileContent;
  10453. string fileName;
  10454. using (WebClient webClient = new WebClient())
  10455. {
  10456. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10457. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10458. {
  10459. using (Stream stream = response.GetResponseStream())
  10460. {
  10461. using (MemoryStream memoryStream = new MemoryStream())
  10462. {
  10463. stream.CopyTo(memoryStream);
  10464. byte[] fileBytes = memoryStream.ToArray();
  10465. base64FileContent = Convert.ToBase64String(fileBytes);
  10466. fileName = response.Headers["Content-Disposition"];
  10467. if (!string.IsNullOrEmpty(fileName))
  10468. {
  10469. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10470. if (index >= 0)
  10471. {
  10472. fileName = fileName.Substring(index + 9).Trim('\"');
  10473. }
  10474. }
  10475. else
  10476. {
  10477. fileName = Path.GetFileName(downloadUrl);
  10478. }
  10479. }
  10480. }
  10481. }
  10482. }
  10483. return (fileName, base64FileContent);
  10484. }
  10485. //新增
  10486. public void order_batch_caiyingtong(string[] downloadUrls)
  10487. {
  10488. try
  10489. {
  10490. //遍历文件
  10491. DataStruct dStruct = GetPostStruct();
  10492. DataTable dt = null;
  10493. int userid = CurrentUser.UserID;
  10494. List<string> ids = new List<string>();//失败组
  10495. List<string> tids = new List<string>();
  10496. using (WebClient webClient = new WebClient())
  10497. {
  10498. foreach (var url in downloadUrls)
  10499. {
  10500. try
  10501. {
  10502. tids.Add("'" + url + "'");
  10503. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10504. if (entity != null)
  10505. {
  10506. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10507. if (cp == null)
  10508. {
  10509. JObject jsonObject = new JObject
  10510. {
  10511. { "Userid", "77886" },
  10512. { "pwd", "lt666888" },
  10513. { "Filename",entity.seller_memo }
  10514. };
  10515. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10516. JObject jsonObjects = JObject.Parse(response);
  10517. string msg = (string)jsonObjects["msg"];
  10518. if (msg == "报价成功")
  10519. {
  10520. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10521. DownloadAndConvertToBase64(url1);
  10522. }
  10523. else
  10524. {
  10525. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10526. }
  10527. }
  10528. else
  10529. {
  10530. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10531. JObject jsonObject = new JObject
  10532. {
  10533. { "Userid", "77886" },
  10534. { "pwd", "lt666888" },
  10535. { "Filename",chanp }
  10536. };
  10537. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10538. JObject jsonObjects = JObject.Parse(response);
  10539. string msg = (string)jsonObjects["msg"];
  10540. if (msg == "报价成功")
  10541. {
  10542. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10543. DownloadAndConvertToBase64(url1);
  10544. }
  10545. else
  10546. {
  10547. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10548. }
  10549. }
  10550. }
  10551. // 上传文件到FTP
  10552. }
  10553. catch (Exception ex)
  10554. {
  10555. Console.WriteLine($"An error occurred: {ex.Message}");
  10556. }
  10557. }
  10558. List<string> lw = new List<string>();
  10559. lw.Add(string.Format("( OrderState < 6 )"));
  10560. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10561. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10562. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10563. if (dt.Rows.Count > 0)
  10564. {
  10565. foreach (DataRow dr in dt.Rows)
  10566. {
  10567. ids.Add(dr["ctid"].ToString());
  10568. }
  10569. }
  10570. String ErrorMsgs = "";
  10571. foreach (String id in ids)
  10572. {
  10573. ErrorMsgs += id + ",";
  10574. }
  10575. if (ErrorMsgs.Length > 1)
  10576. {
  10577. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10578. }
  10579. if (ErrorMsgs.Length < 1)
  10580. {
  10581. ErrorMsgs = "上传成功";
  10582. returnSuccessMsg(ErrorMsgs);
  10583. }
  10584. else
  10585. {
  10586. returnErrorMsg("以下订单" + ErrorMsgs);
  10587. }
  10588. }
  10589. // 删除文件夹及其内容
  10590. /* Directory.Delete(localDirectory, true);*/
  10591. }
  10592. catch { }
  10593. }
  10594. public void get_center_data()
  10595. {
  10596. int userId = CurrentUser.UserID;
  10597. string postCode = CurrentUser.UserPost.Post.Code;
  10598. List<string> lw = new List<string>();
  10599. List<string> ww = new List<string>();
  10600. DateTime currentTime = DateTime.Now;
  10601. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10602. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10603. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10604. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10605. string sql = " SELECT ";
  10606. string startTime = "2023-10-01 11:22:31";
  10607. //设计
  10608. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10609. {
  10610. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10611. 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));
  10612. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10613. 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));
  10614. }
  10615. //客服
  10616. else if (postCode == "CustomerService" || postCode == "Director")
  10617. {
  10618. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10619. 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));
  10620. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10621. 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));
  10622. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10623. 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));
  10624. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10625. 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));
  10626. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10627. 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));
  10628. }
  10629. //售后
  10630. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10631. {
  10632. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10633. 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));
  10634. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10635. 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));
  10636. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10637. 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));
  10638. }
  10639. //下单部
  10640. else if (postCode == "Place" || postCode == "PlaceMr")
  10641. {
  10642. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10643. 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));
  10644. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10645. 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));
  10646. }
  10647. //车间
  10648. else if (postCode == "Supplier")
  10649. {
  10650. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10651. 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));
  10652. }
  10653. DataTable dt = new DataTable();
  10654. if (lw.Count > 0)
  10655. {
  10656. sql += string.Join(" , ", lw);
  10657. sql += " FROM ";
  10658. sql += string.Join(" , ", ww);
  10659. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10660. }
  10661. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10662. }
  10663. public void get_center_data_list()
  10664. {
  10665. int userId = CurrentUser.UserID;
  10666. string postCode = CurrentUser.UserPost.Post.Code;
  10667. string shopIds = CurrentUser.User.pemShop;
  10668. DataStruct dStruct = GetPostStruct();
  10669. List<string> lw = new List<string>();
  10670. DateTime currentTime = DateTime.Now;
  10671. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10672. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10673. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10674. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10675. string startTime = "2023-10-01 11:22:31";
  10676. int order_type = GetPostInt("order_type");
  10677. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10678. {
  10679. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10680. if (order_type == 0)
  10681. {
  10682. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10683. }
  10684. else if (order_type == 3)
  10685. {
  10686. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10687. }
  10688. else
  10689. {
  10690. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10691. }
  10692. }
  10693. //客服
  10694. if (postCode == "CustomerService" || postCode == "Director")
  10695. {
  10696. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10697. if (order_type == 0)
  10698. {
  10699. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10700. }
  10701. else if (order_type == 1)
  10702. {
  10703. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10704. }
  10705. else if (order_type == 2)
  10706. {
  10707. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10708. }
  10709. else if (order_type == 3)
  10710. {
  10711. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10712. }
  10713. else if (order_type == 4)
  10714. {
  10715. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10716. }
  10717. else
  10718. {
  10719. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10720. }
  10721. }
  10722. //售后
  10723. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10724. {
  10725. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10726. if (shopIds != "")
  10727. {
  10728. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10729. }
  10730. if (order_type == 2)
  10731. {
  10732. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10733. }
  10734. else if (order_type == 4)
  10735. {
  10736. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10737. }
  10738. else if (order_type == 5)
  10739. {
  10740. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10741. }
  10742. else
  10743. {
  10744. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10745. }
  10746. }
  10747. //下单部
  10748. if (postCode == "Place" || postCode == "PlaceMr")
  10749. {
  10750. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10751. if (shopIds != "")
  10752. {
  10753. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10754. }
  10755. else if (order_type == 1)
  10756. {
  10757. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10758. }
  10759. else if (order_type == 2)
  10760. {
  10761. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10762. }
  10763. else
  10764. {
  10765. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10766. }
  10767. }
  10768. //车间
  10769. if (postCode == "Supplier")
  10770. {
  10771. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10772. if (order_type == 5)
  10773. {
  10774. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10775. }
  10776. else
  10777. {
  10778. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10779. }
  10780. }
  10781. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10782. dStruct.Fileds = "tid,ctid";
  10783. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10784. writeGridDataTableJson(dStruct.TotalCount, dt);
  10785. }
  10786. public void aftersale_audit_master()
  10787. {
  10788. if (UrlPostParmsCheck("ctid"))
  10789. {
  10790. string ctid = GetPostString("ctid");
  10791. if (ctid.Length > 0)
  10792. {
  10793. bool result = aftersale_data_change(ctid);
  10794. if (result)
  10795. {
  10796. returnSuccessMsg("修改成功!");
  10797. return;
  10798. }
  10799. }
  10800. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10801. }
  10802. }
  10803. public void aftersale_batch_audit_master()
  10804. {
  10805. if (UrlPostParmsCheck("ctids"))
  10806. {
  10807. string ctids = GetPostString("ctids");
  10808. if (ctids.Length > 0)
  10809. {
  10810. List<string> list = new List<string>();
  10811. string[] ctid_list = ctids.Split(',');
  10812. foreach (var item in ctid_list)
  10813. {
  10814. bool result = aftersale_data_change(item);
  10815. if (!result)
  10816. {
  10817. list.Add(item);
  10818. }
  10819. }
  10820. if (list.Count > 0)
  10821. {
  10822. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10823. return;
  10824. }
  10825. returnSuccessMsg("修改成功!");
  10826. return;
  10827. }
  10828. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10829. }
  10830. }
  10831. public bool aftersale_data_change(string ctid)
  10832. {
  10833. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10834. if (ceErpTradeCell != null)
  10835. {
  10836. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10837. ceErpTradeCell.AfterSaleSupplierState = 0;
  10838. StringBuilder sql = new StringBuilder();
  10839. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10840. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10841. CeErpTradeResponsible.DelByTid(ctid, 0);
  10842. 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 == "不理赔")
  10843. {
  10844. CeErpTradeResponsible.DelByTid(ctid, 1);
  10845. ceErpTradeCell.AfterSaleSupplierState = 1;
  10846. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10847. ceErpTradeCell.AfterSaleState = 4;
  10848. }
  10849. else
  10850. {
  10851. ceErpTradeCell.AfterSaleState = 3;
  10852. }
  10853. bool needCyt = false;
  10854. if (dt != null)
  10855. {
  10856. if (dt.Rows.Count == 1)
  10857. {
  10858. bool isEnd = false;
  10859. foreach (DataRow dr in dt.Rows)
  10860. {
  10861. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10862. {
  10863. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10864. isEnd = true;
  10865. }
  10866. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10867. {
  10868. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10869. isEnd = true;
  10870. }
  10871. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10872. {
  10873. needCyt = true;
  10874. }
  10875. }
  10876. if (isEnd)
  10877. {
  10878. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10879. ceErpTradeCell.AfterSaleState = 4;
  10880. ceErpTradeCell.AfterSaleSupplierState = 1;
  10881. }
  10882. }
  10883. else
  10884. {
  10885. bool isAll = true;
  10886. foreach (DataRow dr in dt.Rows)
  10887. {
  10888. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10889. {
  10890. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10891. continue;
  10892. }
  10893. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10894. {
  10895. string path = "";
  10896. int OrgID = 0;
  10897. if (!Convert.IsDBNull(dr["OrgPath"]))
  10898. {
  10899. path = dr["OrgPath"].ToString();
  10900. }
  10901. if (!Convert.IsDBNull(dr["OrgID"]))
  10902. {
  10903. OrgID = Convert.ToInt32(dr["OrgID"]);
  10904. }
  10905. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10906. {
  10907. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10908. continue;
  10909. }
  10910. }
  10911. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10912. {
  10913. needCyt = true;
  10914. }
  10915. isAll = false;
  10916. }
  10917. if (isAll)
  10918. {
  10919. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10920. ceErpTradeCell.AfterSaleState = 4;
  10921. ceErpTradeCell.AfterSaleSupplierState = 1;
  10922. }
  10923. }
  10924. }
  10925. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10926. {
  10927. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10928. }
  10929. if (ceErpTradeCell.AfterSaleState == 4)
  10930. {
  10931. ApiVo apiVo = new ApiVo();
  10932. apiVo.orderNumber = ceErpTradeCell.ctid;
  10933. apiVo.actionName = "afterOver";
  10934. designHelper.API_WorkCore(apiVo); //afterOver
  10935. }
  10936. ceErpTradeCell.Update();
  10937. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10938. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10939. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10940. return true;
  10941. }
  10942. return false;
  10943. }
  10944. public void get_erp_wechatorder()
  10945. {
  10946. DataStruct dStruct = GetPostStruct();
  10947. List<string> lw = new List<string>();
  10948. string tid = GetPostString("tid");
  10949. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10950. string shopname = GetPostString("shopname");
  10951. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10952. string buyernick = GetPostString("buyer_nick");
  10953. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10954. string customer = GetPostString("customer");
  10955. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10956. string returndate1 = GetPostString("returndate1");
  10957. string returndate2 = GetPostString("returndate2");
  10958. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10959. if (dw.Length > 0) lw.Add(dw);
  10960. string finishDate1 = GetPostString("finishdate1");
  10961. string finishDate2 = GetPostString("finishdate2");
  10962. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10963. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10964. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10965. dStruct.Order = "created desc";
  10966. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10967. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10968. writeGridDataTableJson(dStruct.TotalCount, dt);
  10969. }
  10970. public void get_erp_wechatlist_sumprice()
  10971. {
  10972. DataStruct dStruct = GetPostStruct();
  10973. List<string> lw = new List<string>();
  10974. string tid = GetPostString("tid");
  10975. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10976. string shopname = GetPostString("shopname");
  10977. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10978. string buyernick = GetPostString("buyer_nick");
  10979. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10980. string customer = GetPostString("customer");
  10981. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10982. string returndate1 = GetPostString("returndate1");
  10983. string returndate2 = GetPostString("returndate2");
  10984. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10985. if (dw.Length > 0) lw.Add(dw);
  10986. string finishDate1 = GetPostString("finishdate1");
  10987. string finishDate2 = GetPostString("finishdate2");
  10988. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10989. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10990. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10991. string mainWhere = string.Join(" and ", lw.ToArray());
  10992. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10993. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10994. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10995. decimal total = 0;
  10996. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10997. {
  10998. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10999. }
  11000. var res = new
  11001. {
  11002. data = total
  11003. };
  11004. string ro_jsond = JsonConvert.SerializeObject(res);
  11005. returnSuccess(ro_jsond);
  11006. return;
  11007. }
  11008. public void get_erp_qr_waitdeliverylist()
  11009. {
  11010. DataStruct dStruct = GetPostStruct();
  11011. List<string> lw = new List<string>();
  11012. string tid = GetPostString("ctid");
  11013. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11015. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11016. var res_objz = new
  11017. {
  11018. restype = 1,
  11019. data = dt
  11020. };
  11021. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11022. returnSuccess(ro_jsonz);
  11023. }
  11024. public void get_erp_yield_list()
  11025. {
  11026. DataStruct dStruct = GetPostStruct();
  11027. List<string> lw = new List<string>();
  11028. string tid = GetPostString("ctid");
  11029. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11030. string shopname = GetPostString("shopname");
  11031. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11032. string buyernick = GetPostString("buyer_nick");
  11033. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11034. //if (tid.Length == 0 && buyernick.Length == 0)
  11035. //{
  11036. // lw.Add(string.Format("IsRefund<={0}", 1));
  11037. //}
  11038. string customer = GetPostString("customer");
  11039. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11040. string design = GetPostString("design");
  11041. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11042. string orderState = GetPostString("orderState");
  11043. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11044. string address = GetPostString("address");
  11045. 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));
  11046. string sellermemo = GetPostString("seller_memo");
  11047. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11048. string supplier = GetPostString("supplier");
  11049. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11050. string OrderArea = GetPostString("order_area");
  11051. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11052. string placedate1 = GetPostString("placedate1");
  11053. string placedate2 = GetPostString("placedate2");
  11054. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11055. if (fdw.Length > 0) lw.Add(fdw);
  11056. string price1 = GetPostString("price1");
  11057. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11058. string price2 = GetPostString("price2");
  11059. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11060. string unusualCon = GetPostString("unusualcon");
  11061. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11062. string posTag = CurrentUser.UserPost.Post.Code;
  11063. if (posTag == "Supplier")
  11064. {
  11065. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11066. }
  11067. lw.Add(string.Format("OrderState = 6 "));
  11068. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11069. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11070. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11071. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11072. writeGridDataTableJson(dStruct.TotalCount, dt);
  11073. }
  11074. public void change_erp_sup_state()
  11075. {
  11076. if (UrlPostParmsCheck("ctid"))
  11077. {
  11078. string ctid = GetPostString("ctid");
  11079. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11080. if (ceErpTradeCell != null)
  11081. {
  11082. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11083. if (ceErpTradeCellExtend == null)
  11084. {
  11085. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11086. ceErpTradeCellExtend.ctid = ctid;
  11087. ceErpTradeCellExtend.SupState = 1;
  11088. ceErpTradeCellExtend.Create();
  11089. }
  11090. else
  11091. {
  11092. ceErpTradeCellExtend.SupState = 1;
  11093. ceErpTradeCellExtend.Update();
  11094. }
  11095. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11096. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11097. return;
  11098. }
  11099. returnErrorMsg("找不到订单");
  11100. }
  11101. }
  11102. public void supplier_all_downs()
  11103. {
  11104. if (UrlPostParmsCheck("tids"))
  11105. {
  11106. string tids = GetPostString("tids");
  11107. if (tids != null && tids.Length > 0)
  11108. {
  11109. StringBuilder sql = new StringBuilder();
  11110. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11111. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11112. sql = new StringBuilder();
  11113. 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, "下载设计文件");
  11114. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11115. string[] list = tids.Split(',');
  11116. foreach (string ctid in list)
  11117. {
  11118. CeErpSukuraData.createInfo(ctid, 3);
  11119. }
  11120. designHelper.api_approveDesign(tids); //approveDesign
  11121. returnSuccessMsg("下载成功!");
  11122. return;
  11123. }
  11124. returnErrorMsg("下载订单更新失败");
  11125. }
  11126. }
  11127. public void uploaderFileSuccess()
  11128. {
  11129. if (UrlPostParmsCheck("fileName"))
  11130. {
  11131. string fileName = GetPostString("fileName");
  11132. ApiVo apiVo = new ApiVo();
  11133. apiVo.orderNumber = fileName;
  11134. apiVo.actionName = "finishDesign";
  11135. designHelper.API_WorkCore(apiVo);//finishDesign
  11136. returnSuccessMsg("");
  11137. }
  11138. }
  11139. public void get_sample2_order()
  11140. {
  11141. if (UrlPostParmsCheck("ctid"))
  11142. {
  11143. string ctid = GetPostString("ctid");
  11144. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11145. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11146. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11147. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11148. double total = 0.0;
  11149. double order_price = 0.0;
  11150. if (dt_bu.Rows.Count > 0)
  11151. {
  11152. foreach (DataRow dr in dt_bu.Rows)
  11153. {
  11154. total += Convert.ToDouble(dr["payment"]);
  11155. }
  11156. }
  11157. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11158. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11159. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11160. string tid = ctid.Replace("S_", "");
  11161. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11162. double paymant = 0.0;
  11163. if (entity != null)
  11164. {
  11165. paymant = entity.payment;
  11166. }
  11167. string return_reason = "";
  11168. if (dt_after != null && dt_after.Rows.Count > 0)
  11169. {
  11170. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11171. }
  11172. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11173. }
  11174. }
  11175. public void get_erp_design_status()
  11176. {
  11177. string designName = GetPostString("designName");
  11178. DataStruct dStruct = GetPostStruct();
  11179. if (designName.Length > 0)
  11180. {
  11181. 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";
  11182. sql_user += " and Name like '%" + designName + "%'";
  11183. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11184. List<string> ids_list = new List<string>();
  11185. if (user_table.Rows.Count > 0)
  11186. {
  11187. foreach (DataRow item in user_table.Rows)
  11188. {
  11189. ids_list.Add(item["id"].ToString());
  11190. string ids_s = item["TeamIds"].ToString();
  11191. if (ids_s.Length > 0)
  11192. {
  11193. ids_list.AddRange(ids_s.Split(','));
  11194. }
  11195. }
  11196. }
  11197. HashSet<string> set = new HashSet<string>(ids_list);
  11198. ids_list = set.ToList();
  11199. if (ids_list.Count > 0)
  11200. {
  11201. 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));
  11202. dStruct.MainWhere = sql;
  11203. DataTable dt = null;
  11204. dt = WebCache.GetData("view_ErpUser", dStruct);
  11205. writeGridDataTableJson(dStruct.TotalCount, dt);
  11206. }
  11207. }
  11208. }
  11209. public void change_erp_order_price()
  11210. {
  11211. string ctid = GetPostString("ctid");
  11212. double price = GetPostDouble("price");
  11213. if (ctid.Length > 0)
  11214. {
  11215. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11216. if (ceErpTradeCellExtend == null)
  11217. {
  11218. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11219. ceErpTradeCellExtend.ctid = ctid;
  11220. ceErpTradeCellExtend.payment_cyt = price;
  11221. ceErpTradeCellExtend.Create();
  11222. }
  11223. else
  11224. {
  11225. ceErpTradeCellExtend.payment_cyt = price;
  11226. ceErpTradeCellExtend.Update();
  11227. }
  11228. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11229. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11230. {
  11231. ceErpDataSendOrderInfo.isSync = false;
  11232. ceErpDataSendOrderInfo.Update();
  11233. }
  11234. if (ceErpDataSendOrderInfo == null)
  11235. {
  11236. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11237. ceErpDataSendOrderInfo.isSync = false;
  11238. ceErpDataSendOrderInfo.ctid = ctid;
  11239. ceErpDataSendOrderInfo.Create();
  11240. }
  11241. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11242. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11243. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11244. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11245. {
  11246. dataSendOrderBean dataSendOrderBean = null;
  11247. foreach (DataRow item in dth.Rows)
  11248. {
  11249. try
  11250. {
  11251. dataSendOrderBean = new dataSendOrderBean();
  11252. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11253. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11254. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11255. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11256. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11257. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11258. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11259. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11260. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11261. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11262. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11263. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11264. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11265. if (result != null)
  11266. {
  11267. if ("0".Equals(result.errcode))
  11268. {
  11269. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11270. }
  11271. else
  11272. {
  11273. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11274. }
  11275. }
  11276. }
  11277. catch (Exception ex)
  11278. {
  11279. }
  11280. }
  11281. }
  11282. returnSuccessMsg("修改成功!");
  11283. return;
  11284. }
  11285. returnErrorMsg("找不到订单");
  11286. }
  11287. public void find_he_together()
  11288. {
  11289. string ctid = GetPostString("ctid");
  11290. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11291. List<string> list = new List<string>();
  11292. if (ceErpTradeCell != null)
  11293. {
  11294. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11295. {
  11296. 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);
  11297. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11298. if (table != null && table.Rows.Count > 0)
  11299. {
  11300. foreach (TableRow row in table.Rows)
  11301. {
  11302. }
  11303. }
  11304. }
  11305. }
  11306. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11307. }
  11308. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11309. {
  11310. //chy----19
  11311. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11312. //GD-CYT-----64
  11313. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11314. //ZHX----3
  11315. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11316. //JK----97
  11317. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11318. //ZT----70
  11319. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11320. //LHCY-----98
  11321. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11322. //XD-----90
  11323. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11324. //CYCY-----14
  11325. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11326. };
  11327. //其他改名
  11328. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11329. {
  11330. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11331. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11332. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11333. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11334. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11335. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11336. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11337. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11338. };
  11339. //不统计
  11340. List<int> no_suppliers = new List<int>()
  11341. {
  11342. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11343. };
  11344. //配件单
  11345. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11346. {
  11347. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11348. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11349. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11350. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11351. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11352. {"旗杆",new List<string>(){ "班旗" } },
  11353. {"牙签",new List<string>(){ "不干胶" } }
  11354. };
  11355. public void get_place_order_data()
  11356. {
  11357. string date1 = GetPostString("date1");
  11358. string date2 = GetPostString("date2");
  11359. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11360. DateTime start = DateTime.Parse(starttime);
  11361. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11362. DateTime end = DateTime.Parse(endtime);
  11363. if (date1 != null && date1.Length > 0)
  11364. {
  11365. DateTime dateTime = DateTime.Parse(date1);
  11366. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11367. start = DateTime.Parse(starttime);
  11368. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11369. end = DateTime.Parse(endtime);
  11370. }
  11371. if (date2 != null && date2.Length > 0)
  11372. {
  11373. DateTime dateTime = DateTime.Parse(date2);
  11374. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11375. end = DateTime.Parse(endtime);
  11376. }
  11377. 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);
  11378. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11379. //不干胶-----1,卡片-----29
  11380. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11381. foreach (DataRow row in data.Rows)
  11382. {
  11383. int productId = Convert.ToInt32(row["ProductId"]);
  11384. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11385. if (no_suppliers.Contains(supplierId))
  11386. {
  11387. continue;
  11388. }
  11389. string seller_memo = row["seller_memo"].ToString();
  11390. bool ispj = false;//是否配件单
  11391. bool isfirst = true;//第一个配
  11392. maps.Keys.ForEach(key =>
  11393. {
  11394. //备注包含配件
  11395. if (seller_memo.Contains(key) && isfirst)
  11396. {
  11397. List<string> list = maps[key];
  11398. ispj = true;
  11399. isfirst = false;
  11400. for (int i = 0; i < list.Count; i++)
  11401. {
  11402. if (seller_memo.Contains(list[i]))
  11403. {
  11404. ispj = false;
  11405. break;
  11406. }
  11407. }
  11408. }
  11409. });
  11410. if (ispj)
  11411. {
  11412. continue;
  11413. }
  11414. seller_memo = seller_memo.Replace("UV", "uv");
  11415. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11416. //吊牌归到卡片
  11417. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11418. seller_memo = seller_memo.Replace("卡套", "卡片");
  11419. seller_memo = seller_memo.Replace("封套", "卡片");
  11420. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11421. seller_memo = seller_memo.Replace("腰封", "卡片");
  11422. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11423. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11424. seller_memo = seller_memo.Replace("横幅", "条幅");
  11425. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11426. string map_key = "";
  11427. string type = "";
  11428. if (supplierMap.ContainsKey(supplierId))
  11429. {
  11430. foreach (var kvp in supplierMap[supplierId])
  11431. {
  11432. if (seller_memo.Contains(kvp.Key))
  11433. {
  11434. map_key = kvp.Value;
  11435. type = kvp.Value;
  11436. break;
  11437. }
  11438. }
  11439. }
  11440. if (map_key == "")
  11441. {
  11442. type = "其他";
  11443. map_key = "其他";
  11444. }
  11445. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11446. {
  11447. map_key = suppliers[supplierId];
  11448. }
  11449. if (supplierId == 70)
  11450. {
  11451. supplierId = 70;
  11452. }
  11453. map_key += "_" + row["SupplierName"].ToString();
  11454. Dictionary<string, int> map = null;
  11455. if (other_map.ContainsKey(map_key))
  11456. {
  11457. other_map.TryGetValue(map_key, out map);
  11458. }
  11459. else
  11460. {
  11461. map = new Dictionary<string, int>();
  11462. map.Add("dayDev", 0);//当天出货
  11463. map.Add("dayTotal", 0);//下单总数
  11464. map.Add("payTotal", 0);//500以上
  11465. map.Add("today", 0);//当天出货数量
  11466. map.Add("unusua", 0);//异常数
  11467. other_map.Add(map_key, map);
  11468. other_map.TryGetValue(map_key, out map);
  11469. }
  11470. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11471. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11472. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11473. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11474. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11475. {
  11476. map["dayTotal"]++;
  11477. if (supplierId == 97)
  11478. {
  11479. supplierId = 97;
  11480. }
  11481. }
  11482. if (Convert.ToDecimal(row["payment"]) >= 500)
  11483. {
  11484. map["payTotal"]++;
  11485. }
  11486. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11487. {
  11488. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11489. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11490. {
  11491. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11492. {
  11493. map["today"]++;
  11494. }
  11495. }
  11496. else
  11497. {
  11498. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11499. {
  11500. map["today"]++;
  11501. }
  11502. else
  11503. {
  11504. if (supplierId == 119)
  11505. {
  11506. Debug.WriteLine(row["seller_memo"].ToString());
  11507. }
  11508. }
  11509. }
  11510. }
  11511. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11512. {
  11513. map["unusua"]++;
  11514. }
  11515. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11516. //GD-CYT-----64
  11517. DateTime two = palceTimeStart.AddHours(14);
  11518. DateTime three = palceTimeStart.AddHours(15);
  11519. DateTime four = palceTimeStart.AddHours(16);
  11520. DateTime six = palceTimeStart.AddHours(18);
  11521. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11522. {
  11523. //下午四点前 500-1000
  11524. string count = row["ProductCount"].ToString();
  11525. if (count != null && count.Length > 0)
  11526. {
  11527. int productCount = commonHelper.getPlaceProductCount(count);
  11528. if (productCount >= 500 && productCount <= 1000)
  11529. {
  11530. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11531. {
  11532. map["dayDev"]++;
  11533. }
  11534. }
  11535. }
  11536. }
  11537. //UV
  11538. else if ("uv".Equals(type))
  11539. {
  11540. //ZT----70
  11541. //ZHX----3
  11542. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11543. {
  11544. map["dayDev"]++;
  11545. }
  11546. //JK----97
  11547. //HZX----105
  11548. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11549. {
  11550. map["dayDev"]++;
  11551. }
  11552. }
  11553. //帆布---52|条幅---27
  11554. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11555. {
  11556. //LHCY-----98
  11557. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11558. {
  11559. map["dayDev"]++;
  11560. }
  11561. }
  11562. //条幅
  11563. else if ("条幅".Equals(type))
  11564. {
  11565. //XD-----90
  11566. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11567. {
  11568. map["dayDev"]++;
  11569. }
  11570. }
  11571. //桌布
  11572. else if ("桌布".Equals(type))
  11573. {
  11574. //XD-----90
  11575. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11576. {
  11577. map["dayDev"]++;
  11578. }
  11579. }
  11580. //DL---10
  11581. //AYTW---119
  11582. //FS-CYT-DY ----80
  11583. //JK----97
  11584. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11585. {
  11586. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11587. {
  11588. map["dayDev"]++;
  11589. }
  11590. }
  11591. // QC---121
  11592. else if (supplierId == 121)
  11593. {
  11594. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11595. {
  11596. map["dayDev"]++;
  11597. }
  11598. }
  11599. }
  11600. DataTable dt = new DataTable();
  11601. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11602. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11603. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11604. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11605. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11606. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11607. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11608. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11609. other_map.Keys.ForEach(key =>
  11610. {
  11611. DataRow dr = dt.NewRow();
  11612. Dictionary<string, int> map = other_map[key];
  11613. string[] key_list = key.Split('_');
  11614. dr[0] = key_list[0];
  11615. dr[1] = key_list[1];
  11616. if (key_list.Length > 2)
  11617. {
  11618. dr[1] += "(" + key_list[2] + ")";
  11619. }
  11620. dr[2] = map["dayTotal"];
  11621. dr[3] = map["payTotal"];
  11622. dr[4] = map["today"];
  11623. dr[5] = map["unusua"];
  11624. dr[6] = map["dayDev"];
  11625. double rate = 0.00;
  11626. if (map["dayDev"] > 0)
  11627. {
  11628. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11629. }
  11630. dr[7] = rate.ToString();
  11631. dt.Rows.Add(dr);
  11632. });
  11633. DataView dv = new DataView(dt);
  11634. dv.Sort = "SupplierName";
  11635. //dv.Sort = "AllOrder desc";
  11636. DataTable dtNew = dv.ToTable();
  11637. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11638. }
  11639. public void check_order_desing_info()
  11640. {
  11641. string ctid = GetPostString("ctid");
  11642. if (!string.IsNullOrEmpty(ctid))
  11643. {
  11644. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11645. if (ceErpTradeCell != null)
  11646. {
  11647. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11648. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11649. return;
  11650. }
  11651. returnErrorMsg("找不到订单");
  11652. return;
  11653. }
  11654. returnErrorMsg("找不到订单");
  11655. }
  11656. public void get_timeout_detail()
  11657. {
  11658. string poscode = CurrentUser.UserPost.Post.Code;
  11659. DataStruct dStruct = GetPostStruct();
  11660. List<string> lw = new List<string>();
  11661. string id = GetPostString("id");
  11662. string pay_date1 = GetPostString("pay_date1");
  11663. string pay_date2 = GetPostString("pay_date2");
  11664. int type = GetPostInt("type");
  11665. if (type == 0)
  11666. {
  11667. if (pay_date1.Length > 0)
  11668. {
  11669. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11670. }
  11671. if (pay_date2.Length > 0)
  11672. {
  11673. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11674. }
  11675. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11676. }
  11677. if (type == 1)
  11678. {
  11679. if (pay_date1.Length > 0)
  11680. {
  11681. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11682. }
  11683. if (pay_date2.Length > 0)
  11684. {
  11685. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11686. }
  11687. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11688. }
  11689. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11690. DataTable dt = null;
  11691. dt = WebCache.GetData("view_orderlist", dStruct);
  11692. writeGridDataTableJson(dStruct.TotalCount, dt);
  11693. }
  11694. public void saveUrgentChargePrice()
  11695. {
  11696. string ctid = GetPostString("ctid");
  11697. if (!string.IsNullOrEmpty(ctid))
  11698. {
  11699. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11700. if (ceErpTradeCell != null)
  11701. {
  11702. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11703. if (prices <= 100)
  11704. {
  11705. returnErrorMsg("此订单金额不足100元,无法加急。");
  11706. return;
  11707. }
  11708. double price = GetPostDouble("price");
  11709. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11710. if (ceErpTradeCellExtend == null)
  11711. {
  11712. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11713. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11714. }
  11715. ceErpTradeCellExtend.urgentCharge = price;
  11716. if (ceErpTradeCellExtend.ID > 0)
  11717. {
  11718. ceErpTradeCellExtend.Update();
  11719. }
  11720. else
  11721. {
  11722. ceErpTradeCellExtend.Save();
  11723. }
  11724. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11725. returnSuccessMsg("修改成功!");
  11726. return;
  11727. }
  11728. returnErrorMsg("找不到订单");
  11729. return;
  11730. }
  11731. returnErrorMsg("找不到订单");
  11732. }
  11733. public void finish_erp_order()
  11734. {
  11735. string ctid = GetPostString("ctid");
  11736. if (!string.IsNullOrEmpty(ctid))
  11737. {
  11738. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11739. {
  11740. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11741. if (ceErpTradeCell != null)
  11742. {
  11743. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11744. ceErpTradeCell.Update();
  11745. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11746. returnSuccessMsg("修改成功!");
  11747. return;
  11748. }
  11749. }
  11750. }
  11751. returnErrorMsg("找不到订单");
  11752. }
  11753. public void get_trade_order_list()
  11754. {
  11755. string tid = GetPostString("tid");
  11756. if (!string.IsNullOrEmpty(tid))
  11757. {
  11758. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11759. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11760. writeGridDataTableJson(data.Rows.Count, data);
  11761. return;
  11762. }
  11763. returnErrorMsg("找不到订单");
  11764. }
  11765. public void save_cell_spu()
  11766. {
  11767. string ctid = GetPostString("ctid");
  11768. string spu_id = GetPostString("spu_id");
  11769. if (!string.IsNullOrEmpty(ctid))
  11770. {
  11771. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11772. if (ceErpTradeCellExtend == null)
  11773. {
  11774. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11775. ceErpTradeCellExtend.ctid = ctid;
  11776. }
  11777. ceErpTradeCellExtend.spu_id = spu_id;
  11778. if (!string.IsNullOrEmpty(spu_id))
  11779. {
  11780. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11781. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11782. }
  11783. if (ceErpTradeCellExtend.ID == 0)
  11784. {
  11785. ceErpTradeCellExtend.Create();
  11786. }
  11787. else
  11788. {
  11789. ceErpTradeCellExtend.Update();
  11790. }
  11791. returnSuccessMsg("修改成功!");
  11792. return;
  11793. }
  11794. returnErrorMsg("找不到订单");
  11795. }
  11796. public void change_express_info()
  11797. {
  11798. string ctid = GetPostString("ctid");
  11799. string transNo = GetPostString("transNo");
  11800. string transCom = GetPostString("transCom");
  11801. if (!string.IsNullOrEmpty(ctid))
  11802. {
  11803. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11804. if (ceErpTradeCellExtend == null)
  11805. {
  11806. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11807. ceErpTradeCellExtend.ctid = ctid;
  11808. }
  11809. ceErpTradeCellExtend.modExpressNo = transNo;
  11810. ceErpTradeCellExtend.modExpressCom = transCom;
  11811. ceErpTradeCellExtend.readMod = 2;
  11812. if (ceErpTradeCellExtend.ID == 0)
  11813. {
  11814. ceErpTradeCellExtend.Create();
  11815. }
  11816. else
  11817. {
  11818. ceErpTradeCellExtend.Update();
  11819. }
  11820. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11821. returnSuccessMsg("修改成功!");
  11822. return;
  11823. }
  11824. returnErrorMsg("找不到订单");
  11825. }
  11826. public void get_change_express_list()
  11827. {
  11828. DataStruct dStruct = GetPostStruct();
  11829. List<string> lw = new List<string>();
  11830. int st = 2;
  11831. string tid = GetPostString("ctid");
  11832. if (tid.Length > 0)
  11833. {
  11834. string select_tid = getTidByCtid(tid);
  11835. lw.Add(string.Format("tid='{0}'", select_tid));
  11836. }
  11837. string shopname = GetPostString("shopname");
  11838. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11839. string buyernick = GetPostString("buyer_nick");
  11840. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11841. string sellermemo = GetPostString("seller_memo");
  11842. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11843. string supplier = GetPostString("supplier");
  11844. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11845. string customer = GetPostString("customer");
  11846. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11847. string design = GetPostString("design");
  11848. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11849. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11850. string poscode = CurrentUser.UserPost.Post.Code;
  11851. if (poscode != "SysAdmin")
  11852. {
  11853. string shopid = CurrentUser.User.pemShop;
  11854. lw.Add(string.Format("shopId in ({0})", shopid));
  11855. }
  11856. lw.Add("readMod = 2");
  11857. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11858. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11859. writeGridDataTableJson(dStruct.TotalCount, dt);
  11860. }
  11861. public void deal_express_complete()
  11862. {
  11863. string ctid = GetPostString("ctid");
  11864. if (!string.IsNullOrEmpty(ctid))
  11865. {
  11866. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11867. if (ceErpTradeCellExtend == null)
  11868. {
  11869. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11870. ceErpTradeCellExtend.ctid = ctid;
  11871. }
  11872. ceErpTradeCellExtend.readMod = 1;
  11873. if (ceErpTradeCellExtend.ID == 0)
  11874. {
  11875. ceErpTradeCellExtend.Create();
  11876. }
  11877. else
  11878. {
  11879. ceErpTradeCellExtend.Update();
  11880. }
  11881. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11882. returnSuccessMsg("修改成功!");
  11883. return;
  11884. }
  11885. returnErrorMsg("找不到订单");
  11886. }
  11887. public void aftersale_return_visit()
  11888. {
  11889. string ctid = GetPostString("ctid");
  11890. if (!string.IsNullOrEmpty(ctid))
  11891. {
  11892. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11893. if (ceErpTradeCellExtend == null)
  11894. {
  11895. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11896. ceErpTradeCellExtend.ctid = ctid;
  11897. }
  11898. ceErpTradeCellExtend.returnVisit = 1;
  11899. if (ceErpTradeCellExtend.ID == 0)
  11900. {
  11901. ceErpTradeCellExtend.Create();
  11902. }
  11903. else
  11904. {
  11905. ceErpTradeCellExtend.Update();
  11906. }
  11907. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11908. if (ceErpTradeAfterSaleExtend != null)
  11909. {
  11910. ceErpTradeAfterSaleExtend.TextResult = "";
  11911. ceErpTradeAfterSaleExtend.Update();
  11912. }
  11913. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11914. returnSuccessMsg("修改成功!");
  11915. return;
  11916. }
  11917. returnErrorMsg("找不到订单");
  11918. }
  11919. public void orderPlaceInfo()
  11920. {
  11921. string ctids = GetPostString("ctids");
  11922. string[] list = ctids.Split(',');
  11923. foreach (string ctid in list)
  11924. {
  11925. CeErpSukuraData.createInfo(ctid, 3);
  11926. }
  11927. StringBuilder sql = new StringBuilder();
  11928. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11929. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11930. designHelper.api_approveDesign(ctids); //approveDesign
  11931. returnSuccessMsg("");
  11932. }
  11933. public void get_issue_list()
  11934. {
  11935. DataStruct dStruct = GetPostStruct();
  11936. List<string> lw = new List<string>();
  11937. int st = 2;
  11938. string tid = GetPostString("ctid");
  11939. if (tid.Length > 0)
  11940. {
  11941. string select_tid = getTidByCtid(tid);
  11942. lw.Add(string.Format("tid='{0}'", select_tid));
  11943. }
  11944. string shopname = GetPostString("shopname");
  11945. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11946. string buyernick = GetPostString("buyer_nick");
  11947. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11948. string sellermemo = GetPostString("seller_memo");
  11949. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11950. string supplier = GetPostString("supplier");
  11951. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11952. string customer = GetPostString("customer");
  11953. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11954. string design = GetPostString("design");
  11955. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11956. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11957. string poscode = CurrentUser.UserPost.Post.Code;
  11958. if (poscode != "SysAdmin")
  11959. {
  11960. string shopid = CurrentUser.User.pemShop;
  11961. lw.Add(string.Format("shopId in ({0})", shopid));
  11962. }
  11963. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  11964. {
  11965. lw.Add("IssueState = 1");
  11966. }
  11967. else
  11968. {
  11969. string iisstate = GetPostString("iisstate");
  11970. if ("1".Equals(iisstate))
  11971. {
  11972. lw.Add("IssueState =1");
  11973. }
  11974. else if ("2".Equals(iisstate))
  11975. {
  11976. lw.Add("IssueState = 2");
  11977. }
  11978. else
  11979. {
  11980. lw.Add("IssueState > 0");
  11981. }
  11982. }
  11983. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11984. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11985. writeGridDataTableJson(dStruct.TotalCount, dt);
  11986. }
  11987. public void saveIssueContent()
  11988. {
  11989. string ctid = GetPostString("ctid");
  11990. if (!string.IsNullOrEmpty(ctid))
  11991. {
  11992. string content = GetPostString("content");
  11993. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11994. if (ceErpTradeAfterSaleExtend == null)
  11995. {
  11996. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11997. ceErpTradeAfterSaleExtend.tid = ctid;
  11998. }
  11999. ceErpTradeAfterSaleExtend.IssueContent = content;
  12000. ceErpTradeAfterSaleExtend.IssueState = 1;
  12001. if (ceErpTradeAfterSaleExtend.ID > 0)
  12002. {
  12003. ceErpTradeAfterSaleExtend.Update();
  12004. }
  12005. else
  12006. {
  12007. ceErpTradeAfterSaleExtend.Create();
  12008. }
  12009. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12010. returnSuccessMsg("添加成功!");
  12011. return;
  12012. }
  12013. returnErrorMsg("找不到订单");
  12014. }
  12015. public void dealIssueContent()
  12016. {
  12017. string ctid = GetPostString("ctid");
  12018. if (!string.IsNullOrEmpty(ctid))
  12019. {
  12020. string content = GetPostString("content");
  12021. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12022. if (ceErpTradeAfterSaleExtend != null)
  12023. {
  12024. ceErpTradeAfterSaleExtend.IssueState = 2;
  12025. ceErpTradeAfterSaleExtend.Update();
  12026. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12027. returnSuccessMsg("修改完成!");
  12028. return;
  12029. }
  12030. }
  12031. returnErrorMsg("找不到订单");
  12032. }
  12033. public void set_tid_attachments()
  12034. {
  12035. string tid = GetPostString("tid");
  12036. string atta = GetPostString("atta");
  12037. if (!string.IsNullOrEmpty(tid))
  12038. {
  12039. if (string.IsNullOrEmpty(atta))
  12040. {
  12041. returnErrorMsg("文件地址为空");
  12042. return;
  12043. }
  12044. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12045. if (ceErpTradeCell != null)
  12046. {
  12047. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12048. if (ceErpTrade == null)
  12049. {
  12050. returnErrorMsg("找不到订单");
  12051. return;
  12052. }
  12053. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12054. bool isSend = false;
  12055. if (dt != null && dt.Rows.Count > 0)
  12056. {
  12057. foreach (DataRow row in dt.Rows)
  12058. {
  12059. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12060. {
  12061. isSend = true;
  12062. }
  12063. }
  12064. if (isSend)
  12065. {
  12066. returnErrorMsg("已发货无法修改");
  12067. return;
  12068. }
  12069. ceErpTrade.Attachments = atta;
  12070. ceErpTrade.Update();
  12071. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12072. returnSuccessMsg("上传成功!");
  12073. return;
  12074. }
  12075. }
  12076. }
  12077. returnErrorMsg("找不到订单");
  12078. }
  12079. public void get_tid_attachments()
  12080. {
  12081. string tid = GetPostString("tid");
  12082. if (!string.IsNullOrEmpty(tid))
  12083. {
  12084. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12085. if (ceErpTradeCell != null)
  12086. {
  12087. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12088. if (ceErpTrade == null)
  12089. {
  12090. returnErrorMsg("找不到订单");
  12091. return;
  12092. }
  12093. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12094. return;
  12095. }
  12096. }
  12097. returnErrorMsg("找不到订单");
  12098. }
  12099. public void check_erp_sameorders()
  12100. {
  12101. if (UrlPostParmsCheck("ctid"))
  12102. {
  12103. string eid = GetPostString("ctid");
  12104. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12105. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12106. if (entity != null && ceErpTrade != null)
  12107. {
  12108. if (entity.OrderState > 6)
  12109. {
  12110. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12111. return;
  12112. }
  12113. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12114. List<string> ids = new List<string>();
  12115. if (dt != null && dt.Rows.Count > 1)
  12116. {
  12117. bool needhe = true;
  12118. foreach (DataRow dr in dt.Rows)
  12119. {
  12120. ids.Add("'" + dr["ctid"] + "'");
  12121. /* //备注有合包
  12122. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12123. {
  12124. needhe = true;
  12125. }
  12126. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12127. {
  12128. needhe = true;
  12129. }
  12130. //顺丰快递
  12131. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12132. {
  12133. needhe = true;
  12134. }*/
  12135. }
  12136. if (!needhe)
  12137. {
  12138. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12139. return;
  12140. }
  12141. StringBuilder sql = new StringBuilder();
  12142. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12143. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12144. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12145. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12146. foreach (DataRow dr in dt.Rows)
  12147. {
  12148. dr["dstate"] = 0;
  12149. dr["dnumber"] = 0;
  12150. foreach (DataRow row in dt1.Rows)
  12151. {
  12152. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12153. {
  12154. dr["dstate"] = 2;
  12155. dr["default"] = 1;
  12156. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12157. }
  12158. }
  12159. if (eid.Equals(dr["ctid"].ToString()))
  12160. {
  12161. dr["dstate"] = 1;
  12162. dr["default"] = 1;
  12163. }
  12164. }
  12165. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12166. return;
  12167. }
  12168. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12169. return;
  12170. }
  12171. returnErrorMsg("未找到订单");
  12172. return;
  12173. }
  12174. returnErrorMsg("缺少必要的参数");
  12175. }
  12176. public void get_mark_number()
  12177. {
  12178. string eid = GetPostString("ctid");
  12179. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12180. if (entity != null)
  12181. {
  12182. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12183. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12184. int current = 1;
  12185. if (ceErpDeliverMark == null)
  12186. {
  12187. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12188. List<string> ids = new List<string>();
  12189. if (dt != null && dt.Rows.Count > 1)
  12190. {
  12191. foreach (DataRow dr in dt.Rows)
  12192. {
  12193. ids.Add("'" + dr["ctid"] + "'");
  12194. }
  12195. //查询已有的编号
  12196. StringBuilder sql = new StringBuilder();
  12197. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12198. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12199. if (dt1 == null || dt1.Rows.Count == 0)
  12200. {
  12201. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12202. List<int> list_number = new List<int>();
  12203. foreach (DataRow row in numbers.Rows)
  12204. {
  12205. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12206. }
  12207. //查询空余编号
  12208. for (int i = 0; i < list_number.Count + 2; i++)
  12209. {
  12210. if (!list_number.Contains(current))
  12211. {
  12212. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12213. //防止查询过程中有新数据生成
  12214. if (ceErpDeliverMark1 == null)
  12215. {
  12216. break;
  12217. }
  12218. }
  12219. current++;
  12220. }
  12221. }
  12222. else
  12223. {
  12224. foreach (DataRow row in dt1.Rows)
  12225. {
  12226. current = Convert.ToInt32(row["markNumber"]);
  12227. }
  12228. }
  12229. ceErpDeliverMark = new CeErpDeliverMark();
  12230. ceErpDeliverMark.ctid = eid;
  12231. ceErpDeliverMark.createtime = DateTime.Now;
  12232. if (ceErpTrade != null)
  12233. {
  12234. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12235. }
  12236. ceErpDeliverMark.markNumber = current;
  12237. ceErpDeliverMark.Create();
  12238. }
  12239. }
  12240. else
  12241. {
  12242. current = ceErpDeliverMark.markNumber;
  12243. }
  12244. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12245. return;
  12246. }
  12247. }
  12248. public void aftersaleCytSend()
  12249. {
  12250. string ctid = GetPostString("ctid");
  12251. if (!string.IsNullOrEmpty(ctid))
  12252. {
  12253. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12254. if (ceErpTradeCell != null)
  12255. {
  12256. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12257. }
  12258. returnSuccessMsg("推送成功");
  12259. return;
  12260. }
  12261. returnErrorMsg("缺少必要的参数");
  12262. }
  12263. public void packOrderInfo()
  12264. {
  12265. string ctids = GetPostString("ctids");
  12266. if (!string.IsNullOrEmpty(ctids))
  12267. {
  12268. string[] ctid_list = ctids.Split(',');
  12269. if (ctid_list.Length > 20)
  12270. {
  12271. returnErrorMsg("单次下载次数不能超过20个");
  12272. return;
  12273. }
  12274. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12275. StringBuilder sql = new StringBuilder();
  12276. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12277. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12278. int supplierId = 0;
  12279. StringBuilder insterSql = new StringBuilder();
  12280. for (int i = 0; i < dt.Rows.Count; i++)
  12281. {
  12282. DataRow row = dt.Rows[i];
  12283. if (i == 0)
  12284. {
  12285. supplierId = Convert.ToInt32(row["SupplierId"]);
  12286. }
  12287. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12288. {
  12289. returnErrorMsg("同车间的订单才能一起打包");
  12290. return;
  12291. }
  12292. int orderState = Convert.ToInt32(row["OrderState"]);
  12293. if (orderState != 5)
  12294. {
  12295. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12296. return;
  12297. }
  12298. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12299. }
  12300. CeErpPackData ceErpPackData = new CeErpPackData();
  12301. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12302. ceErpPackData.supplierId = supplierId;
  12303. ceErpPackData.createtime = DateTime.Now;
  12304. ceErpPackData.createBy = CurrentUser.UserID;
  12305. ceErpPackData.createName = CurrentUser.UserName;
  12306. ceErpPackData.Create();
  12307. if (ceErpPackData.ID > 0)
  12308. {
  12309. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12310. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12311. }
  12312. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12313. returnSuccessMsg("打包成功");
  12314. return;
  12315. }
  12316. returnErrorMsg("缺少必要的参数");
  12317. }
  12318. public void rePackOrderInfo()
  12319. {
  12320. string id = GetPostString("id");
  12321. if (!string.IsNullOrEmpty(id))
  12322. {
  12323. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12324. if (ceErpPackData == null)
  12325. {
  12326. returnSuccessMsg("查无数据");
  12327. return;
  12328. }
  12329. ceErpPackData.upStatus = 0;
  12330. ceErpPackData.message = "";
  12331. ceErpPackData.Update();
  12332. returnSuccessMsg("打包成功");
  12333. return;
  12334. }
  12335. returnErrorMsg("缺少必要的参数");
  12336. }
  12337. public void backPackOrderInfo()
  12338. {
  12339. string id = GetPostString("id");
  12340. if (!string.IsNullOrEmpty(id))
  12341. {
  12342. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12343. if (ceErpPackData == null)
  12344. {
  12345. returnSuccessMsg("查无数据");
  12346. return;
  12347. }
  12348. ceErpPackData.upStatus = 4;
  12349. ceErpPackData.Update();
  12350. List<string> list = new List<string>();
  12351. StringBuilder sql = new StringBuilder();
  12352. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12353. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12354. for (int i = 0; i < dt.Rows.Count; i++)
  12355. {
  12356. DataRow row = dt.Rows[i];
  12357. list.Add("'" + row["ctid"].ToString() + "'");
  12358. }
  12359. string textCtids = string.Join(",", list);
  12360. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=5,IsVerifyToSupplier=0,IsReturn=1,ReturnTime=GETDATE(),ReturnReason='无法打包' where ctid in ({0}) and OrderState=6", textCtids));
  12361. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", textCtids, (int)OrderState.下单完成, 0, "无法打包退回"));
  12362. returnSuccessMsg("退回成功");
  12363. return;
  12364. }
  12365. returnErrorMsg("缺少必要的参数");
  12366. }
  12367. public void addPackDownNum()
  12368. {
  12369. string id = GetPostString("id");
  12370. if (!string.IsNullOrEmpty(id))
  12371. {
  12372. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12373. returnSuccessMsg("下载成功");
  12374. return;
  12375. }
  12376. returnErrorMsg("缺少必要的参数");
  12377. }
  12378. public void get_pack_list()
  12379. {
  12380. DataStruct dStruct = GetPostStruct();
  12381. List<string> lw = new List<string>();
  12382. string supplier = GetPostString("supplier");
  12383. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12384. string posTag = CurrentUser.UserPost.Post.Code;
  12385. if (posTag == "Supplier")
  12386. {
  12387. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12388. }
  12389. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12390. dStruct.Order = "createtime desc";
  12391. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12392. writeGridDataTableJson(dStruct.TotalCount, dt);
  12393. }
  12394. public void get_pack_order_list()
  12395. {
  12396. string packId = GetPostString("packId");
  12397. if (string.IsNullOrEmpty(packId))
  12398. {
  12399. returnErrorMsg("缺少必要的参数");
  12400. return;
  12401. }
  12402. StringBuilder sql = new StringBuilder();
  12403. sql.AppendFormat("select c.ctid,c.seller_memo,i.message from CE_ErpPackDataItem i left join CE_ErpTradeCell c on i.ctid=c.ctid where i.packId = {0}", packId);
  12404. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12405. if (dt == null || dt.Rows.Count == 0)
  12406. {
  12407. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12408. return;
  12409. }
  12410. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12411. return;
  12412. }
  12413. public void get_supplier_product_time_list()
  12414. {
  12415. DataStruct dStruct = GetPostStruct();
  12416. List<string> lw = new List<string>();
  12417. string supplier = GetPostString("supplier");
  12418. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12419. string posTag = CurrentUser.UserPost.Post.Code;
  12420. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12421. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12422. writeGridDataTableJson(dStruct.TotalCount, dt);
  12423. }
  12424. public void saveSupplierProductTime()
  12425. {
  12426. string productId = GetPostString("productId");
  12427. if (string.IsNullOrEmpty(productId))
  12428. {
  12429. returnErrorMsg("缺少必要的参数");
  12430. return;
  12431. }
  12432. string productName = GetPostString("productName");
  12433. int supplierId = GetPostInt("supplierId");
  12434. if (supplierId == 0)
  12435. {
  12436. returnErrorMsg("缺少必要的参数");
  12437. return;
  12438. }
  12439. int quantity = GetPostInt("quantity");
  12440. int sendDay = GetPostInt("sendTime");
  12441. string supplierName = GetPostString("supplierName");
  12442. string craft = GetPostString("craft");
  12443. string deadLine = GetPostString("deadLine");
  12444. string dayDeadLine = GetPostString("dayDeadLine");
  12445. try
  12446. {
  12447. int eid = GetPostInt("eid");
  12448. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12449. if (ceErpSupplierProductTime == null)
  12450. {
  12451. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12452. }
  12453. ceErpSupplierProductTime.productId = productId;
  12454. ceErpSupplierProductTime.productName = productName;
  12455. ceErpSupplierProductTime.supplierId = supplierId;
  12456. ceErpSupplierProductTime.supplierName = supplierName;
  12457. ceErpSupplierProductTime.craft = craft;
  12458. ceErpSupplierProductTime.sendDay = sendDay;
  12459. ceErpSupplierProductTime.quantity = quantity;
  12460. if (!string.IsNullOrEmpty(deadLine))
  12461. {
  12462. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12463. }
  12464. if (!string.IsNullOrEmpty(dayDeadLine))
  12465. {
  12466. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12467. }
  12468. if (ceErpSupplierProductTime.ID == 0)
  12469. {
  12470. ceErpSupplierProductTime.Save();
  12471. }
  12472. else
  12473. {
  12474. ceErpSupplierProductTime.Update();
  12475. }
  12476. }
  12477. catch (Exception e)
  12478. {
  12479. }
  12480. returnSuccessMsg("保存成功");
  12481. return;
  12482. }
  12483. public void delSupplierProductTime()
  12484. {
  12485. int eid = GetPostInt("eid");
  12486. if (eid > 0)
  12487. {
  12488. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12489. if (ceErpSupplierProductTime == null)
  12490. {
  12491. returnErrorMsg("查无数据");
  12492. return;
  12493. }
  12494. ceErpSupplierProductTime.Delete();
  12495. returnSuccessMsg("保存成功");
  12496. return;
  12497. }
  12498. returnErrorMsg("缺少必要的参数");
  12499. }
  12500. public void getExpressInfo()
  12501. {
  12502. string ctid = GetPostString("ctid");
  12503. if (!string.IsNullOrEmpty(ctid))
  12504. {
  12505. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12506. if (ceErpTradeCell != null)
  12507. {
  12508. string outSid = ceErpTradeCell.OutSid;
  12509. if (outSid.Length > 0)
  12510. {
  12511. 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);
  12512. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12513. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12514. return;
  12515. }
  12516. }
  12517. returnErrorMsg("查无记录");
  12518. return;
  12519. }
  12520. returnErrorMsg("缺少必要的参数");
  12521. }
  12522. public void getExpressPostData()
  12523. {
  12524. string express = GetPostString("express");
  12525. if (!string.IsNullOrEmpty(express))
  12526. {
  12527. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12528. if (ceErpExpressInfo != null)
  12529. {
  12530. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12531. return;
  12532. }
  12533. }
  12534. returnErrorMsg("缺少必要的参数");
  12535. }
  12536. public void checkSupplierOrder()
  12537. {
  12538. string ctids = GetPostString("ctids");
  12539. if (ctids != null)
  12540. {
  12541. List<string> list = new List<string>();
  12542. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12543. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12544. for (int i = 0; i < dt.Rows.Count; i++)
  12545. {
  12546. DataRow row = dt.Rows[i];
  12547. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12548. {
  12549. continue;
  12550. }
  12551. list.Add(row["seller_memo"].ToString());
  12552. }
  12553. if (list.Count > 0)
  12554. {
  12555. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", "'" + ctids.Replace(",", "','") + "'", (int)OrderState.下单完成, CurrentUser.UserID, "点击下载按钮"));
  12556. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12557. return;
  12558. }
  12559. }
  12560. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12561. return;
  12562. }
  12563. public void addPersonId()
  12564. {
  12565. string tid = GetPostString("tid");
  12566. string personId = GetPostString("personId");
  12567. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12568. if (ceErpTrade != null)
  12569. {
  12570. ceErpTrade.receiver_zip = personId;
  12571. ceErpTrade.Update();
  12572. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12573. returnSuccessMsg("保存成功");
  12574. return;
  12575. }
  12576. returnErrorMsg("缺少必要的参数");
  12577. }
  12578. public void addDeliveryPaymant()
  12579. {
  12580. string tid = GetPostString("tid");
  12581. string paymant = GetPostString("paymant");
  12582. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12583. if (ceErpTrade != null)
  12584. {
  12585. if (!string.IsNullOrEmpty(paymant))
  12586. {
  12587. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12588. }
  12589. ceErpTrade.Update();
  12590. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12591. returnSuccessMsg("保存成功");
  12592. return;
  12593. }
  12594. returnErrorMsg("缺少必要的参数");
  12595. }
  12596. }
  12597. }