sync.order.cs 594 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910
  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. namespace SiteCore.Handler
  47. {
  48. public partial class sync
  49. {
  50. public void get_erp_orderlist()
  51. {
  52. string poscode = CurrentUser.UserPost.Post.Code;
  53. DataStruct dStruct = GetPostStruct();
  54. //apiHelper.Api_SyncOrderByTime("598825");
  55. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  56. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  57. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  58. //banniuApiHelper.sendLogisticsInfo(null);
  59. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  60. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  61. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  62. //int sid = commonHelper.autoDistributeToSupplier(entity);
  63. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  64. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1743037314000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1743210111000,\"lines\":[{\"mark2\":[],\"num\":2,\"outerId\":\"JSBHUVZYT\",\"payment\":100.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2200806677467/O1CN01FNM4MW251wJNQ0RTV_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":50.0,\"refOlId\":\"4279817918999398627\",\"refSkuId\":\"0\",\"refSpuId\":\"743796792540\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":50.0,\"singleFee\":50.0,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【活动价】镜子贴纸定制婚礼迎宾牌装饰静电贴镜面玻璃窗户字母转印贴画墙贴\",\"totalFee\":100.0,\"totalPrice\":100.0,\"totalSellPrice\":100.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1743040267000,\"openBuyerId\":\"AAEXRHraABkUZRPgSx1Mbz6h\",\"openBuyerNick\":\"天**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1743037310000,\"payTime\":1743037311000,\"payment\":100.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"齐齐哈尔市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"建华区\",\"receiverId\":\"82f9bfecd2ef7df766b42edd73faa2f3$\",\"receiverState\":\"黑龙江省\",\"receiverTown\":\"文化街道\",\"refOid\":\"4279817918999398627\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"500x640mm-1张-uv静电膜-模切-单面印刷-天意5516-昕昕-50,580x585mm-1张-uv静电膜-模切-单面印刷-天意5516-昕昕-50\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":100.0,\"totalPrice\":100.0,\"totalSellPrice\":100.0,\"type\":\"SALE\"}}");
  65. //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}}");
  66. List<string> lw = new List<string>();
  67. string tid = GetPostString("ctid");
  68. string date1 = GetPostString("date1");
  69. //12-1 修改
  70. string urgent = GetPostString("urgent");
  71. string back = GetPostString("back");
  72. string offlineSearch = GetPostString("offlineSearch");
  73. int paramsCount = 0;
  74. if (!string.IsNullOrWhiteSpace(urgent))
  75. {
  76. if (urgent.Equals("true"))
  77. {
  78. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  79. }
  80. }
  81. if (!string.IsNullOrWhiteSpace(back))
  82. {
  83. if (back.Equals("true"))
  84. {
  85. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  86. }
  87. }
  88. if (!string.IsNullOrWhiteSpace(offlineSearch))
  89. {
  90. if (offlineSearch.Equals("true"))
  91. {
  92. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  93. }
  94. }
  95. //end
  96. string date2 = GetPostString("date2");
  97. string buyernick = GetPostString("buyer_nick");
  98. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  99. {
  100. if (tid.Length <= 0 && buyernick.Length <= 0)
  101. {
  102. return;
  103. }
  104. }
  105. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  106. {
  107. if (tid.Length > 0)
  108. {
  109. string select_tid = getTidByCtid(tid);
  110. lw.Add(string.Format("tid='{0}'", select_tid));
  111. }
  112. if (buyernick.Length > 0)
  113. {
  114. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  115. }
  116. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  117. if (dw.Length > 0)
  118. {
  119. lw.Add(dw);
  120. }
  121. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  122. {
  123. string usershop = CurrentUser.User.pemShop;
  124. lw.Add(string.Format("ShopId in ({0})", usershop));
  125. }
  126. }
  127. else
  128. {
  129. if (ex_psize == 0)
  130. {
  131. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  132. }
  133. if (PKey != "admin")
  134. {
  135. string usershop = CurrentUser.User.pemShop;
  136. lw.Add(string.Format("ShopId in ({0})", usershop));
  137. paramsCount++;
  138. }
  139. }
  140. string uploaddate1 = GetPostString("uploaddate1");
  141. string uploaddate2 = GetPostString("uploaddate2");
  142. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  143. if (update.Length > 0) lw.Add(update);
  144. string deliverydate1 = GetPostString("deliverydate1");
  145. string deliverydate2 = GetPostString("deliverydate2");
  146. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  147. if (deliverydate.Length > 0)
  148. {
  149. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  150. };
  151. string shopname = GetPostString("shopname");
  152. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  153. string addwechat = GetPostString("addwechat");
  154. if (addwechat.Length > 0)
  155. {
  156. int addWt = Convert.ToInt32(addwechat);
  157. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  158. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  159. }
  160. string customer = GetPostString("customer");
  161. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  162. string design = GetPostString("design");
  163. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  164. string orderState = GetPostString("orderState");
  165. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  166. string address = GetPostString("address");
  167. 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));
  168. string sellermemo = GetPostString("seller_memo");
  169. if (sellermemo.Length > 0)
  170. {
  171. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  172. }
  173. string backReason = GetPostString("backReason");
  174. if (backReason.Length > 0)
  175. {
  176. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  177. }
  178. string apdate1 = GetPostString("apdate1");
  179. string apdate2 = GetPostString("apdate2");
  180. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  181. if (dwap.Length > 0) lw.Add(dwap);
  182. string price1 = GetPostString("price1");
  183. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  184. string price2 = GetPostString("price2");
  185. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  186. string isoldcustomer = GetPostString("isoldcus");
  187. string finishdate1 = GetPostString("finishdate1");
  188. string finishdate2 = GetPostString("finishdate2");
  189. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  190. bool isFinish = false;
  191. if (finishdate.Length > 0)
  192. {
  193. lw.Add(finishdate);
  194. isFinish = true;
  195. paramsCount++;
  196. }
  197. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  198. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  199. if (ex_psize > 0)
  200. {
  201. int UserID = CurrentUser.UserID;
  202. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  203. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  204. {
  205. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  206. }
  207. dStruct.Order = "pay_time desc";
  208. }
  209. string isNew = GetPostString("isNew");
  210. if (isNew == "true")
  211. {
  212. lw.Add(string.Format("IsNew = {0}", 1));
  213. }
  214. string overtime = GetPostString("overtime");
  215. if (overtime == "1")
  216. {
  217. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  218. }
  219. String usePost = CurrentUser.UserPost.Post.Code;
  220. if (usePost.Equals("Operation") == true)
  221. {
  222. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  223. }
  224. else
  225. {
  226. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  227. }
  228. //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";
  229. if (dStruct.PageSize == 100000)
  230. {
  231. dStruct.Order = "";
  232. }
  233. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  234. DataTable dt = null;
  235. string tablename = "view_orderlist";
  236. if (isFinish)
  237. {
  238. tablename = "view_orderlist_end";
  239. }
  240. dt = WebCache.GetData(tablename, dStruct);
  241. if (dt != null && dt.Rows.Count > 0)
  242. {
  243. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  244. foreach (DataRow dr in dt.Rows)
  245. {
  246. try
  247. {
  248. if (dr["refund_fees"] != null)
  249. {
  250. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  251. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  252. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  253. if (payment == refund_fees)
  254. {
  255. dr["refund_fees"] = Math.Round(refund_fees, 2);
  256. }
  257. else if (refund_fees == total_fee)
  258. {
  259. dr["refund_fees"] = payment;
  260. }
  261. else
  262. {
  263. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  264. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  265. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  266. }
  267. }
  268. // 对象操作
  269. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  270. ceErpTradeCell.ctid = dr["ctid"].ToString();
  271. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  272. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  273. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  274. if (dStruct.PageSize != 100000)
  275. {
  276. if (dr["DispatchSort"].ToString() == "2")
  277. {
  278. dr["gongchuang"] = 200;
  279. }
  280. else
  281. {
  282. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  283. dr["gongchuang"] = response.code;
  284. }
  285. }
  286. }
  287. catch (NullReferenceException ex)
  288. {
  289. // 处理空引用异常
  290. dr["refund_fees"] = "0.00";
  291. }
  292. }
  293. }
  294. writeGridDataTableJson(dStruct.TotalCount, dt);
  295. }
  296. public void get_erp_orderlist_sumprice()
  297. {
  298. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  299. return;
  300. List<string> lw = new List<string>();
  301. string tid = GetPostString("ctid");
  302. string date1 = GetPostString("date1");
  303. string date2 = GetPostString("date2");
  304. if (tid.Length > 0 || date1.Length > 0)
  305. {
  306. lw.Add(string.Format("ctid like '%{0}%'", tid));
  307. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  308. if (dw.Length > 0) lw.Add(dw);
  309. }
  310. else
  311. {
  312. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  313. }
  314. string shopname = GetPostString("shopname");
  315. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  316. string buyernick = GetPostString("buyer_nick");
  317. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  318. string customer = GetPostString("customer");
  319. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  320. string design = GetPostString("design");
  321. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  322. string orderState = GetPostString("orderState");
  323. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  324. string address = GetPostString("address");
  325. 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));
  326. string sellermemo = GetPostString("seller_memo");
  327. if (sellermemo.Length > 0)
  328. {
  329. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  330. }
  331. string apdate1 = GetPostString("apdate1");
  332. string apdate2 = GetPostString("apdate2");
  333. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  334. if (dwap.Length > 0) lw.Add(dwap);
  335. string price1 = GetPostString("price1");
  336. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  337. string price2 = GetPostString("price2");
  338. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  339. string isoldcustomer = GetPostString("isoldcus");
  340. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  341. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  342. if (PKey != "admin")
  343. {
  344. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  345. lw.Add(string.Format("shopId in ({0})", usershop));
  346. }
  347. //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";
  348. string mainWhere = string.Join(" and ", lw.ToArray());
  349. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  350. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  351. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  352. decimal total = 0;
  353. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  354. {
  355. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  356. }
  357. var res = new
  358. {
  359. data = total
  360. };
  361. string ro_jsond = JsonConvert.SerializeObject(res);
  362. returnSuccess(ro_jsond);
  363. return;
  364. }
  365. public void get_erp_CustomerServiceGather()
  366. {
  367. string userWhere = "", orderWhere = "";
  368. List<string> lw = new List<string>();
  369. string customer = GetPostString("customer");
  370. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  371. string shopname = GetPostString("shopname");
  372. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  373. string date1 = GetPostString("date1");
  374. string date2 = GetPostString("date2");
  375. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  376. if (dw.Length > 0) lw.Add(dw);
  377. orderWhere = string.Join(" and ", lw.ToArray());
  378. 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 " +
  379. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  380. "left join " +
  381. "( " +
  382. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  383. ") as b on a.ID = b.CustomerUserId " +
  384. "left join " +
  385. "( " +
  386. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  387. ") as d on a.ID = d.CustomerUserId " +
  388. "left join " +
  389. "( " +
  390. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  391. ") as e on a.ID = e.CustomerUserId " +
  392. "left join " +
  393. "( " +
  394. " select CustomerUserId, RefundCount, RefundSum from " +
  395. " ( " +
  396. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  397. " from CE_ErpTradeRefund a " +
  398. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  399. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  400. " group by CustomerUserId " +
  401. " ) as a " +
  402. ") as f on a.ID = f.CustomerUserId " +
  403. "where a.PostCode = 'CustomerService'",
  404. userWhere, orderWhere);
  405. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  406. writeGridDataTableJson(dt.Rows.Count, dt);
  407. //writeGridDataTableJson(dt.Rows.Count, dt);
  408. }
  409. //设计汇总
  410. public void get_erp_DesignerGather()
  411. {
  412. string userWhere = "", orderWhere = "";
  413. List<string> lw = new List<string>();
  414. string Designer = GetPostString("designer");
  415. int org = GetPostInt("org");
  416. if (Designer.Length > 0)
  417. {
  418. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  419. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  420. }
  421. else if (org > 0)
  422. {
  423. userWhere = string.Format(" where OrgID ={0}", org);
  424. }
  425. string shopname = GetPostString("shopname");
  426. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  427. string state = GetPostString("state");
  428. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  429. string OrderArea = GetPostString("order_area");
  430. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  431. string date1 = GetPostString("date1");
  432. string date2 = GetPostString("date2");
  433. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  434. if (dw.Length > 0) lw.Add(dw);
  435. string UpDate1 = GetPostString("UpDate1");
  436. string UpDate2 = GetPostString("UpDate2");
  437. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  438. if (dw.Length > 0) lw.Add(dw);
  439. orderWhere = string.Join(" and ", lw.ToArray());
  440. 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 (" +
  441. "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 " +
  442. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  443. "left join " +
  444. "( " +
  445. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  446. ") as b on a.ID = b.DesignUserId " +
  447. "left join " +
  448. "( " +
  449. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  450. ") as d on a.ID = d.DesignUserId " +
  451. "left join " +
  452. "( " +
  453. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  454. ") as e on a.ID = e.DesignUserId " +
  455. "left join " +
  456. "( " +
  457. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  458. ") as g on a.ID = g.DesignUserId " +
  459. "left join " +
  460. "( " +
  461. " select CustomerUserId, RefundCount, RefundSum from " +
  462. " ( " +
  463. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  464. " from CE_ErpTradeRefund a " +
  465. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  466. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  467. " group by CustomerUserId " +
  468. " ) as a " +
  469. ") as f on a.ID = f.CustomerUserId " +
  470. "where a.PostCode = 'Designer') as z",
  471. userWhere, orderWhere);
  472. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  473. writeGridDataTableJson(dt.Rows.Count, dt);
  474. }
  475. //删除tradecell的订单
  476. public void del_erp_cellorder()
  477. {
  478. if (UrlPostParmsCheck("ctid"))
  479. {
  480. string eid = GetPostString("ctid");
  481. CeErpTradeCell.DelByCtid(eid);
  482. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  483. returnSuccessMsg("删除成功");
  484. }
  485. }
  486. public void clear_erp_refundstate()
  487. {
  488. if (UrlPostParmsCheck("ids"))
  489. {
  490. string eids = GetPostString("ids");
  491. string[] ctidList = eids.Split(',');
  492. foreach (string ctid in ctidList)
  493. {
  494. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  495. if (entity != null)
  496. {
  497. entity.IsRefund = 0;
  498. entity.Update();
  499. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  500. }
  501. else
  502. continue;
  503. }
  504. returnSuccessMsg("操作成功");
  505. return;
  506. }
  507. returnErrorMsg("缺少必要参数");
  508. }
  509. public void set_erp_urgency()
  510. {
  511. if (UrlPostParmsCheck("ctid"))
  512. {
  513. string eid = GetPostString("ctid");
  514. CeErpTradeCell entity = null;
  515. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  516. if (entity != null)
  517. {
  518. string utime = GetPostString("urgencytime");
  519. if (utime.Length > 0)
  520. {
  521. entity.UrgencyTime = Convert.ToDateTime(utime);
  522. }
  523. else
  524. {
  525. returnErrorMsg("请选择加急时间");
  526. return;
  527. }
  528. if (entity.OrderState <= 4)
  529. {
  530. //entity.seller_memo = entity.seller_memo + "-加急";
  531. string smemo = entity.seller_memo;
  532. int kindex = smemo.IndexOf(")");
  533. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  534. if (lastoneStr != "-")
  535. {
  536. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  537. }
  538. string prememo = smemo.Substring(0, kindex + 2);
  539. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  540. int lastkindex = lastmemo.IndexOf("(");
  541. DateTime urgtime = Convert.ToDateTime(utime);
  542. string newlastmemo = "";
  543. if (lastkindex == 0)
  544. {
  545. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  546. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  547. }
  548. else
  549. {
  550. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  551. }
  552. entity.seller_memo = prememo + newlastmemo;
  553. }
  554. entity.IsUrgency = true;
  555. entity.Update();
  556. ApiVo apiVo = new ApiVo();
  557. apiVo.orderNumber = entity.ctid;
  558. apiVo.actionName = "changeDesign";
  559. apiVo.orderRemarks = entity.seller_memo;
  560. apiVo.remarkSign = 3;
  561. designHelper.API_WorkCore(apiVo); //changeDesign
  562. CeErpSukuraData.createInfo(entity.ctid, 7);
  563. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  564. returnSuccessMsg("设置成功!");
  565. return;
  566. }
  567. returnErrorMsg("找不到记录");
  568. }
  569. }
  570. public void set_erp_reset()
  571. {
  572. if (UrlPostParmsCheck("ctid"))
  573. {
  574. string eid = GetPostString("ctid");
  575. CeErpTradeCell entity = null;
  576. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  577. if (entity != null)
  578. {
  579. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  580. {
  581. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  582. {
  583. returnErrorMsg("财务要求已下单已发货无法重置");
  584. return;
  585. }
  586. }
  587. entity.IsUrgency = false;
  588. entity.seller_memo = "";
  589. entity.OtherMemo = "";
  590. entity.OrderState = 0;
  591. entity.IsReturn = 0;
  592. //entity.IsRefund = 0;
  593. entity.MemoOpt = 0;
  594. entity.AfterSaleState = 0;
  595. entity.AfterSaleResponsible = "";
  596. entity.AfterSaleUserId = 0;
  597. entity.IsNeedBill = 0;
  598. entity.CustomerUserId = 0;
  599. entity.DesignUserId = 0;
  600. entity.SupplierId = 0;
  601. entity.PlaceUserId = 0;
  602. entity.ptid = "";
  603. entity.IsSample = 0;
  604. entity.IsXianHuo = 0;
  605. entity.isDianziOrder = 0;
  606. entity.DispatchSort = 0;
  607. entity.FinishPlaceTime = null;
  608. entity.Update();
  609. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  610. if (trade != null)
  611. {
  612. trade.seller_memo = "";
  613. trade.Update();
  614. }
  615. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  616. returnSuccessMsg("重置成功!");
  617. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  618. if (desginBill != null)
  619. {
  620. desginBill.isDel = 1;
  621. desginBill.Update();
  622. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  623. }
  624. ApiVo apiVo = new ApiVo();
  625. apiVo.orderNumber = entity.ctid;
  626. apiVo.actionName = "resetDesign";
  627. designHelper.API_WorkCore(apiVo);//resetDesign
  628. return;
  629. }
  630. returnErrorMsg("找不到记录");
  631. }
  632. }
  633. public void save_erp_sellermemo()
  634. {
  635. if (UrlPostParmsCheck("ctid"))
  636. {
  637. string ctid = GetPostString("ctid");
  638. CeErpTradeCell entity = null;
  639. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  640. if (entity != null)
  641. {
  642. string memo = GetPostString("seller_memo");
  643. memo = memo.Replace(" ", "");
  644. if (memo.Contains("补差"))
  645. {
  646. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  647. return;
  648. }
  649. if (entity.seller_memo != memo)
  650. {
  651. if (entity.IsSample == 2)
  652. {
  653. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  654. return;
  655. }
  656. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  657. {
  658. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  659. {
  660. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  661. return;
  662. }
  663. }
  664. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  665. }
  666. commonHelper.getCytPrice(entity);
  667. int memoopt = GetPostInt("MemoOpt");
  668. Boolean ismemoopt = false;
  669. if (memoopt > 0)
  670. {
  671. string stropt = "";
  672. if (memoopt == 1)
  673. {
  674. stropt = "“改稿”";
  675. ismemoopt = true;
  676. }
  677. else if (memoopt == 2)
  678. {
  679. stropt = "“定稿”";
  680. }
  681. else if (memoopt == 3)
  682. {
  683. stropt = "“查货”";
  684. CeErpSukuraData.createInfo(entity.ctid, 6);
  685. }
  686. entity.MemoOpt = Convert.ToInt32(memoopt);
  687. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  688. }
  689. if (entity.OrderState < 5)
  690. {
  691. memo = memo.Replace("(", "(");
  692. memo = memo.Replace(")", ")");
  693. }
  694. entity.seller_memo = memo;
  695. entity.Update();
  696. ApiVo apiVo = new ApiVo();
  697. apiVo.orderNumber = entity.ctid;
  698. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  699. apiVo.orderRemarks = memo;
  700. apiVo.remarkSign = memoopt;
  701. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  702. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  703. returnSuccessMsg("保存成功!");
  704. return;
  705. }
  706. returnErrorMsg("找不到记录");
  707. }
  708. }
  709. public void ins_erp_checkorder()
  710. {
  711. if (UrlPostParmsCheck("ctid"))
  712. {
  713. string ctid = GetPostString("ctid");
  714. CeErpTradeCell entity = null;
  715. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  716. if (entity != null)
  717. {
  718. if (entity.OrderState < 6)
  719. {
  720. returnErrorMsg("下单完成后才可查货");
  721. return;
  722. }
  723. /*if (entity.OrderState > 6)
  724. {
  725. returnErrorMsg("订单已发货");
  726. return;
  727. }*/
  728. if (entity.FinishPlaceTime != null)
  729. {
  730. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  731. {
  732. returnErrorMsg("下单时间不足,无法查货");
  733. return;
  734. }
  735. }
  736. entity.MemoOpt = 3;
  737. entity.CheckOrderTime = DateTime.Now;
  738. entity.Update();
  739. CeErpSukuraData.createInfo(entity.ctid, 6);
  740. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  741. returnSuccessMsg("操作成功!");
  742. return;
  743. }
  744. returnErrorMsg("找不到记录");
  745. }
  746. }
  747. public void save_erp_othermemo()
  748. {
  749. if (UrlPostParmsCheck("ctid"))
  750. {
  751. string ctid = GetPostString("ctid");
  752. CeErpTradeCell entity = null;
  753. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  754. if (entity != null)
  755. {
  756. entity.OtherMemo = GetPostString("otherMemo");
  757. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  758. {
  759. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  760. StringBuilder sql = new StringBuilder();
  761. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  762. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  763. if (dt != null && dt.Rows.Count > 0)
  764. {
  765. foreach (DataRow dr in dt.Rows)
  766. {
  767. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  768. {
  769. //品类一直
  770. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  771. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  772. if (ceErpSampleCustomer == null)
  773. {
  774. ceErpSampleCustomer = new CeErpSampleCustomer();
  775. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  776. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  777. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  778. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  779. ceErpSampleCustomer.shopId = entity.ShopId;
  780. }
  781. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  782. ceErpSampleCustomer.lastTid = entity.tid;
  783. if (ceErpSampleCustomer.ID > 0)
  784. {
  785. ceErpSampleCustomer.Update();
  786. }
  787. else
  788. {
  789. ceErpSampleCustomer.Create();
  790. }
  791. }
  792. }
  793. }
  794. }
  795. //if (entity.IsOldCustomer == 1)
  796. //{
  797. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  798. //{
  799. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  800. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  801. //}
  802. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  803. //{
  804. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  805. // {
  806. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  807. // {
  808. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  809. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  810. // }
  811. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  812. // {
  813. // entity.OrderState = 2;
  814. // entity.DesignUserId = 0;
  815. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  816. // }
  817. // else
  818. // {
  819. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  820. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  821. // }
  822. // }
  823. //}
  824. //}
  825. entity.Update();
  826. returnSuccessMsg("保存成功!");
  827. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  828. return;
  829. }
  830. returnErrorMsg("找不到记录");
  831. }
  832. }
  833. public void save_erp_customermemo()
  834. {
  835. if (UrlPostParmsCheck("ctid"))
  836. {
  837. string ctid = GetPostString("ctid");
  838. CeErpTradeCell entity = null;
  839. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  840. if (entity != null)
  841. {
  842. entity.CustomerMemo = GetPostString("CustomerMemo");
  843. entity.Update();
  844. ApiVo apiVo = new ApiVo();
  845. apiVo.orderNumber = entity.ctid;
  846. apiVo.actionName = "followRemarks";
  847. apiVo.orderRemarks = entity.CustomerMemo;
  848. designHelper.API_WorkCore(apiVo);//followRemarks
  849. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  850. returnSuccessMsg("保存成功!");
  851. return;
  852. }
  853. returnErrorMsg("找不到记录");
  854. }
  855. }
  856. public void upd_erp_addmemotag()
  857. {
  858. if (UrlPostParmsCheck("ctid"))
  859. {
  860. ;
  861. string eid = GetPostString("ctid");
  862. string sfTagstr = GetPostString("memotag");
  863. CeErpTradeCell entity = null;
  864. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  865. if (entity != null)
  866. {
  867. if (entity.OrderState == 0)
  868. {
  869. returnErrorMsg("请先领单");
  870. return;
  871. }
  872. //撤销顺丰
  873. if (sfTagstr == "撤销顺丰")
  874. {
  875. entity.IsSF = 0;
  876. string reMsg = "";
  877. string oldmemo = entity.seller_memo;
  878. if (entity.OrderState < 5)
  879. {
  880. oldmemo = oldmemo.Replace("顺丰到付", "");
  881. oldmemo = oldmemo.Replace("顺丰寄付", "");
  882. entity.seller_memo = oldmemo;
  883. }
  884. else
  885. {
  886. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  887. {
  888. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  889. }
  890. }
  891. entity.Update();
  892. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  893. api.orderNumber = entity.ctid;
  894. api.actionName = "followRemarks";
  895. api.orderRemarks = entity.seller_memo;
  896. api.isSf = entity.IsSF.ToString();
  897. designHelper.API_WorkCore(api);//followRemarks
  898. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  899. returnSuccessMsg("撤销成功!" + reMsg);
  900. return;
  901. }
  902. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  903. {
  904. //string oldmemo = entity.seller_memo;
  905. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  906. string sfStr = GetPostString("memotag");
  907. string smemo = entity.seller_memo;
  908. int kindex = smemo.IndexOf(")");
  909. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  910. if (lastoneStr != "-")
  911. {
  912. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  913. }
  914. string prememo = smemo.Substring(0, kindex + 2);
  915. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  916. int lastkindex = lastmemo.IndexOf("(");
  917. string newlastmemo = "";
  918. if (lastkindex == 0)
  919. {
  920. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  921. newlastmemo = "(" + sfStr + "." + useLastmemo;
  922. }
  923. else
  924. {
  925. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  926. }
  927. entity.seller_memo = prememo + newlastmemo;
  928. }
  929. string sfTagMSg = "";
  930. if (sfTagstr == "顺丰寄付")
  931. {
  932. entity.IsSF = 1;
  933. sfTagMSg = "顺丰寄付";
  934. }
  935. else if (sfTagstr == "顺丰到付")
  936. {
  937. entity.IsSF = 2;
  938. sfTagMSg = "顺丰到付";
  939. }
  940. entity.Update();
  941. ApiVo apiVo = new ApiVo();
  942. apiVo.orderNumber = entity.ctid;
  943. apiVo.actionName = "orderRemarks";
  944. apiVo.orderRemarks = entity.seller_memo;
  945. apiVo.isSf = entity.IsSF.ToString();
  946. designHelper.API_WorkCore(apiVo);//orderRemarks
  947. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  948. returnSuccessMsg("标记成功!");
  949. return;
  950. }
  951. returnErrorMsg("找不到记录");
  952. }
  953. }
  954. public void upd_erp_ordertag()
  955. {
  956. if (UrlPostParmsCheck("ctid"))
  957. {
  958. string eid = GetPostString("ctid");
  959. CeErpTradeCell entity = null;
  960. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  961. if (entity != null)
  962. {
  963. int tag = GetPostInt("wechattag");
  964. //if(tag==4 && entity.IsSample == 2)
  965. //{
  966. // returnErrorMsg("补差价单不能标记微信单");
  967. // return;
  968. //}
  969. entity.wechatTag = tag;
  970. entity.Update();
  971. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  972. if (tag == 1)
  973. {
  974. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  975. if (cash == null)
  976. {
  977. CeErpTrade main = CeErpTrade.Get(entity.tid);
  978. cash = new CeErpReturnCash();
  979. cash.tid = entity.tid;
  980. cash.seller_nick = main.seller_nick;
  981. cash.payment = trade.payment;
  982. cash.buyer_nick = main.buyer_nick;
  983. cash.cashstate = 0;
  984. cash.rtype = "微信返现";
  985. cash.returnprice = 0;
  986. cash.created = DateTime.Now;
  987. cash.con = "订单标记微信单";
  988. cash.img = "";
  989. cash.applyuserid = CurrentUser.UserID;
  990. cash.Create();
  991. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  992. }
  993. else
  994. {
  995. cash.cashstate = 0;
  996. cash.Update();
  997. }
  998. CeErpSukuraData.createInfo(entity.ctid, 9);
  999. }
  1000. else if (tag == 2)
  1001. {
  1002. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1003. if (cash == null)
  1004. {
  1005. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1006. cash = new CeErpReturnCash();
  1007. cash.tid = entity.tid;
  1008. cash.seller_nick = main.seller_nick;
  1009. cash.payment = trade.payment;
  1010. cash.buyer_nick = main.buyer_nick;
  1011. cash.cashstate = 0;
  1012. cash.rtype = "推购返现";
  1013. cash.returnprice = 5;
  1014. cash.created = DateTime.Now;
  1015. cash.con = "订单标记推购单";
  1016. cash.img = "";
  1017. cash.applyuserid = CurrentUser.UserID;
  1018. cash.Create();
  1019. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1020. }
  1021. else
  1022. {
  1023. cash.cashstate = 0;
  1024. cash.Update();
  1025. }
  1026. CeErpSukuraData.createInfo(entity.ctid, 9);
  1027. }
  1028. else if (tag == 3)
  1029. {
  1030. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1031. if (pers == null)
  1032. {
  1033. pers = new CeErpPersuade();
  1034. pers.ctid = entity.ctid;
  1035. pers.pstate = 0;
  1036. pers.created = DateTime.Now;
  1037. pers.applyuserid = CurrentUser.UserID;
  1038. pers.Create();
  1039. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1040. }
  1041. else
  1042. {
  1043. pers.pstate = 0;
  1044. pers.Update();
  1045. }
  1046. }
  1047. else if (tag == 4 || tag == 5)
  1048. {
  1049. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1050. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1051. if (pers == null)
  1052. {
  1053. pers = new CeErpStayGoods();
  1054. pers.t_id = entity.tid;
  1055. pers.status = "待审核";
  1056. pers.audit_type = 0;
  1057. if (tag == 4)
  1058. {
  1059. pers.stay_type = "微信推购";
  1060. }
  1061. else
  1062. {
  1063. pers.stay_type = "旺旺推购";
  1064. }
  1065. if (entity.IsXianHuo == 0)
  1066. {
  1067. pers.product_id = entity.ProductId;
  1068. }
  1069. pers.wangwang = main.buyer_nick;
  1070. pers.shop_name = main.seller_nick;
  1071. pers.creata_time = DateTime.Now;
  1072. pers.create_u_id = CurrentUser.UserID;
  1073. pers.create_u_name = CurrentUser.UserName;
  1074. pers.Create();
  1075. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1076. }
  1077. else
  1078. {
  1079. pers.audit_type = 0;
  1080. pers.Update();
  1081. }
  1082. CeErpSukuraData.createInfo(entity.ctid, 10);
  1083. }
  1084. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1085. returnSuccessMsg("标记成功!");
  1086. return;
  1087. }
  1088. returnErrorMsg("找不到记录");
  1089. }
  1090. }
  1091. public void upd_erp_ordertag_cancel()
  1092. {
  1093. if (UrlPostParmsCheck("ctid"))
  1094. {
  1095. string eid = GetPostString("ctid");
  1096. CeErpTradeCell entity = null;
  1097. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1098. if (entity != null)
  1099. {
  1100. entity.wechatTag = 0;
  1101. entity.Update();
  1102. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1103. if (pers != null)
  1104. {
  1105. pers.status = "取消推购";
  1106. pers.audit_type = 3;
  1107. pers.Update();
  1108. }
  1109. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1110. returnSuccessMsg("标记成功!");
  1111. return;
  1112. }
  1113. returnErrorMsg("找不到记录");
  1114. }
  1115. }
  1116. public void upd_erp_addweichattag()
  1117. {
  1118. if (UrlPostParmsCheck("ctid"))
  1119. {
  1120. ;
  1121. string eid = GetPostString("ctid");
  1122. CeErpTradeCell entity = null;
  1123. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1124. if (entity != null)
  1125. {
  1126. if (entity.IsAddWechat > 0)
  1127. {
  1128. returnErrorMsg("此单已经标记过了");
  1129. return;
  1130. }
  1131. 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);
  1132. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1133. if (dt.Rows.Count > 0)
  1134. {
  1135. entity.IsAddWechat = 2;
  1136. }
  1137. else
  1138. {
  1139. entity.IsAddWechat = 1;
  1140. }
  1141. entity.Update();
  1142. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1143. returnSuccessMsg("标记成功!");
  1144. return;
  1145. }
  1146. returnErrorMsg("找不到记录");
  1147. }
  1148. }
  1149. public void upd_erp_getmyorder()
  1150. {
  1151. if (UrlPostParmsCheck("ctid"))
  1152. {
  1153. ;
  1154. string eid = GetPostString("ctid");
  1155. CeErpTradeCell entity = null;
  1156. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1157. if (entity != null)
  1158. {
  1159. if (entity.ctid.IndexOf("C") != -1)
  1160. {
  1161. StringBuilder sql = new StringBuilder();
  1162. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1163. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1164. if (dt.Rows.Count > 0)
  1165. {
  1166. decimal total = 0;
  1167. foreach (DataRow dr in dt.Rows)
  1168. {
  1169. total += Convert.ToDecimal(dr["payment"]);
  1170. }
  1171. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1172. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1173. {
  1174. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1175. return;
  1176. }
  1177. }
  1178. }
  1179. entity.CustomerUserId = CurrentUser.UserID;
  1180. if (entity.OrderState < 2)
  1181. {
  1182. entity.OrderState = 2;
  1183. if (entity.ShopId != 0)
  1184. {
  1185. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1186. }
  1187. }
  1188. entity.Update();
  1189. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1190. returnSuccessMsg("领单成功!");
  1191. return;
  1192. }
  1193. returnErrorMsg("找不到记录");
  1194. }
  1195. }
  1196. public void getmyorder_from_init()
  1197. {
  1198. if (UrlPostParmsCheck("ctid"))
  1199. {
  1200. string eid = GetPostString("ctid");
  1201. CeErpTradeCell entity = null;
  1202. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1203. if (entity != null)
  1204. {
  1205. string sellerMemo = GetPostString("sellerMemo");
  1206. if (sellerMemo.Length > 0)
  1207. {
  1208. entity.seller_memo = sellerMemo;
  1209. }
  1210. string oterhMemo = GetPostString("otherMemo");
  1211. if (oterhMemo.Length > 0)
  1212. {
  1213. entity.OtherMemo = oterhMemo;
  1214. }
  1215. int urg = GetPostInt("urgency");
  1216. entity.IsUrgency = (urg == 1 ? true : false);
  1217. int wechat = GetPostInt("wechat");
  1218. int command = GetPostInt("command");
  1219. if (wechat == 1)
  1220. {
  1221. entity.wechatTag = 1;
  1222. }
  1223. if (command == 1)
  1224. {
  1225. entity.wechatTag = 2;
  1226. }
  1227. string pPro = GetPostString("pprofession");
  1228. if (pPro.Length > 0)
  1229. {
  1230. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1231. string spro = GetPostString("profession");
  1232. if (spro.Length > 0)
  1233. {
  1234. entity.ProfessionId = Convert.ToInt32(spro);
  1235. }
  1236. }
  1237. string proId = GetPostString("productId");
  1238. if (proId.Length > 0)
  1239. {
  1240. entity.ProductId = Convert.ToInt32(proId);
  1241. }
  1242. entity.Material = GetPostString("material");
  1243. entity.Craft = GetPostString("craft");
  1244. entity.CustomerUserId = CurrentUser.UserID;
  1245. if (entity.OrderState < 2)
  1246. {
  1247. entity.OrderState = 2;
  1248. if (entity.ShopId != 0)
  1249. {
  1250. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1251. }
  1252. }
  1253. entity.Update();
  1254. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1255. returnSuccessMsg("领单成功!");
  1256. return;
  1257. }
  1258. returnErrorMsg("找不到记录");
  1259. }
  1260. }
  1261. public void upd_erp_setrelationorder()
  1262. {
  1263. if (UrlPostParmsCheck("ctid"))
  1264. {
  1265. ;
  1266. string eid = GetPostString("ctid");
  1267. string ftid = GetPostString("ftid");
  1268. CeErpTradeCell entity = null;
  1269. CeErpTradeCell fentity = null;
  1270. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1271. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1272. if (fentity == null)
  1273. {
  1274. returnErrorMsg("找不到关联的主订单");
  1275. return;
  1276. }
  1277. if (entity != null)
  1278. {
  1279. if (entity.OrderState >= 5)
  1280. {
  1281. returnErrorMsg("本单已经设计完成无法关联");
  1282. return;
  1283. }
  1284. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1285. {
  1286. returnErrorMsg("线下单续审核后才能关联!");
  1287. return;
  1288. }
  1289. entity.ptid = ftid;
  1290. entity.OrderState = fentity.OrderState;
  1291. //entity.status = fentity.status;
  1292. entity.CustomerUserId = fentity.CustomerUserId;
  1293. entity.DesignUserId = fentity.DesignUserId;
  1294. entity.seller_memo = "补差价单:" + ftid;
  1295. entity.IsSample = 2;
  1296. entity.Update();
  1297. ApiVo apiVo = new ApiVo();
  1298. apiVo.orderNumber = ftid;
  1299. apiVo.payment = entity.payment;
  1300. apiVo.actionName = "repairDesign";
  1301. designHelper.API_WorkCore(apiVo);//repairDesign
  1302. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1303. returnSuccessMsg("关联成功!");
  1304. return;
  1305. }
  1306. else
  1307. returnErrorMsg("找不到记录");
  1308. }
  1309. }
  1310. public void download_erp_neworder()
  1311. {
  1312. string seller = GetPostString("seller_nick");
  1313. string tid = GetPostString("tid");
  1314. if (seller.Length <= 0 || tid.Length <= 0)
  1315. {
  1316. returnErrorMsg("数据错误");
  1317. }
  1318. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1319. //{
  1320. // returnErrorMsg("找不到店铺Sessionkey");
  1321. //}
  1322. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1323. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1324. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1325. if (res.IndexOf("refOid") == -1)
  1326. {
  1327. returnErrorMsg("下载订单数据失败");
  1328. return;
  1329. }
  1330. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1331. returnSuccessMsg("下载完成");
  1332. //tmcHelper.createNewOrder(res);
  1333. //CeErpTrade entr = null;
  1334. //entr = CeErpTrade.Get(tid);
  1335. //if (entr != null)
  1336. //{
  1337. // returnSuccess("下载成功");
  1338. // //下载成功之后,Cell表生成对应的订单;
  1339. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1340. //}
  1341. //else
  1342. //{
  1343. // returnErrorMsg("下载失败或者创建订单失败");
  1344. //}
  1345. }
  1346. public void set_erp_atersale()
  1347. {
  1348. if (UrlPostParmsCheck("ctid"))
  1349. {
  1350. string eid = GetPostString("ctid");
  1351. string reason = GetPostString("AfterSaleReason");
  1352. CeErpTradeCell entity = null;
  1353. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1354. if (entity != null)
  1355. {
  1356. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1357. {
  1358. returnErrorMsg("此订单已经在售后");
  1359. return;
  1360. }
  1361. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1362. //entity.AfterSaleReason = reason;
  1363. entity.AfterSaleTime = DateTime.Now;
  1364. entity.Update();
  1365. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1366. returnSuccessMsg("转售后成功!");
  1367. return;
  1368. }
  1369. returnErrorMsg("找不到记录");
  1370. }
  1371. }
  1372. public void set_erp_withdraw()
  1373. {
  1374. if (UrlPostParmsCheck("ctid"))
  1375. {
  1376. try
  1377. {
  1378. string eid = GetPostString("ctid");//商品id
  1379. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1380. CeWithdraw ceWithdrawSelect = null;
  1381. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1382. if (ceWithdrawSelect != null)
  1383. {
  1384. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1385. {
  1386. ceWithdrawSelect.status = -1;
  1387. ceWithdrawSelect.Update();
  1388. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1389. returnSuccessMsg("重新发起审核成功");
  1390. return;
  1391. }
  1392. else
  1393. {
  1394. returnSuccessMsg("请勿重复申请!");
  1395. return;
  1396. }
  1397. }
  1398. else
  1399. {
  1400. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1401. if (string.IsNullOrEmpty(CustomerUserId))
  1402. {
  1403. CustomerUserId = "-1";
  1404. }
  1405. int Userid = CurrentUser.UserID;//用户id
  1406. CeWithdraw ceWithdraw = new CeWithdraw();
  1407. ceWithdraw.tid = eid;
  1408. ceWithdraw.userid = Userid;
  1409. ceWithdraw.providerid = CustomerUserId;
  1410. ceWithdraw.status = 3;
  1411. ceWithdraw.creationtime = DateTime.Now;
  1412. ceWithdraw.Create();
  1413. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1414. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1415. return;
  1416. }
  1417. }
  1418. catch
  1419. {
  1420. returnErrorMsg("申请撤回订单失败");
  1421. return;
  1422. }
  1423. }
  1424. }
  1425. public void ins_erp_billinfo()
  1426. {
  1427. if (UrlPostParmsCheck("ctid"))
  1428. {
  1429. string eid = GetPostString("ctid");
  1430. CeErpTradeCell entity = null;
  1431. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1432. if (entity != null)
  1433. {
  1434. CeErpBill bill = CeErpBill.GetByTid(eid);
  1435. bool isHave = false;
  1436. if (bill != null)
  1437. {
  1438. isHave = true;
  1439. if (bill.state != 4)
  1440. {
  1441. returnErrorMsg("此单已经申请过发票了");
  1442. return;
  1443. }
  1444. }
  1445. if (entity.IsNeedBill == 0)
  1446. {
  1447. entity.IsNeedBill = 1;
  1448. }
  1449. entity.Update();
  1450. string errjson = "";
  1451. try
  1452. {
  1453. CeErpBill bill_entity = new CeErpBill();
  1454. bill_entity.tid = entity.tid;
  1455. bill_entity.title = GetPostString("title");
  1456. string taxstr = GetPostString("tax");
  1457. taxstr = taxstr.Replace(" ", "");
  1458. bill_entity.tax = taxstr;
  1459. bill_entity.bank = GetPostString("bank");
  1460. string bankacstr = GetPostString("bankac");
  1461. bankacstr = bankacstr.Replace(" ", "");
  1462. bill_entity.bankac = bankacstr;
  1463. bill_entity.address = GetPostString("address");
  1464. bill_entity.phone = GetPostString("phone");
  1465. bill_entity.price = GetPostString("price");
  1466. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1467. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1468. {
  1469. billCount += 1;
  1470. }
  1471. string prebill = "ltb";
  1472. for (int idx = 1; idx <= billCount; idx++)
  1473. {
  1474. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1475. string billoid = prebill + idx + dtstr;
  1476. bill_entity.billOrderId += billoid;
  1477. if (idx < billCount)
  1478. {
  1479. bill_entity.billOrderId += ",";
  1480. }
  1481. }
  1482. bill_entity.productId = GetPostInt("ProductName");
  1483. bill_entity.num = GetPostInt("num");
  1484. bill_entity.unit = GetPostString("unit");
  1485. bill_entity.type = GetPostString("type");
  1486. bill_entity.sendType = GetPostString("SendType");
  1487. bill_entity.email = GetPostString("email");
  1488. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1489. bill_entity.shopName = GetPostString("ShopName");
  1490. bill_entity.applymemo = GetPostString("applyMemo");
  1491. bill_entity.createTime = DateTime.Now;
  1492. bill_entity.state = 0;
  1493. bill_entity.userId = CurrentUser.UserID;
  1494. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1495. bill_entity.Create();
  1496. }
  1497. catch (Exception ex)
  1498. {
  1499. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1500. returnErrorMsg("创建发票出错!");
  1501. return;
  1502. }
  1503. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1504. returnSuccessMsg("发票申请成功!");
  1505. return;
  1506. }
  1507. returnErrorMsg("找不到记录");
  1508. }
  1509. }
  1510. public void ins_erp_neworder()
  1511. {
  1512. if (UrlPostParmsCheck("receiver_name"))
  1513. {
  1514. CeErpTrade entity = new CeErpTrade();
  1515. string plat_form = GetPostString("platform");
  1516. string preStr = "N_";
  1517. if (plat_form == "拼多多")
  1518. {
  1519. preStr = "P_";
  1520. }
  1521. else if (plat_form == "阿里巴巴")
  1522. {
  1523. preStr = "A_";
  1524. }
  1525. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1526. entity.seller_nick = GetPostString("seller_nick");
  1527. entity.buyer_nick = GetPostString("buyer_nick");
  1528. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1529. entity.total_fee = entity.payment;
  1530. entity.pay_time = DateTime.Now;
  1531. entity.status = "NOT_SHIPPED";
  1532. entity.receiver_name = GetPostString("receiver_name");
  1533. entity.receiver_mobile = GetPostString("receiver_mobile");
  1534. entity.receiver_state = GetPostString("receiver_state");
  1535. entity.receiver_city = GetPostString("receiver_city");
  1536. entity.receiver_district = GetPostString("receiver_district");
  1537. entity.receiver_address = GetPostString("receiver_address");
  1538. if (entity.receiver_state == "" || entity.receiver_city == "")
  1539. {
  1540. returnErrorMsg("收件地址不能为空");
  1541. return;
  1542. }
  1543. int shopId = 0;
  1544. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1545. if (nShop != null)
  1546. {
  1547. shopId = nShop.ID;
  1548. }
  1549. if (shopId != 34 && entity.payment == 0)
  1550. {
  1551. returnErrorMsg("公司自用的单金额才能为0");
  1552. return;
  1553. }
  1554. entity.Create();
  1555. CeErpTradeCell entitycell = new CeErpTradeCell();
  1556. entitycell.ctid = entity.tid;
  1557. entitycell.tid = entity.tid;
  1558. entitycell.ShopId = shopId;
  1559. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1560. entitycell.OrderState = 0;
  1561. entitycell.pay_time = entity.pay_time;
  1562. entitycell.IsOffLineOrder = 1;
  1563. entitycell.Create();
  1564. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1565. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1566. return;
  1567. }
  1568. }
  1569. public void ins_erp_neworder2()
  1570. {
  1571. if (UrlPostParmsCheck("receiver_name"))
  1572. {
  1573. //string plat_form = GetPostString("platform");
  1574. string preStr = "X_";
  1575. string memo = GetPostString("memo");
  1576. string productId = GetPostString("productId");
  1577. string primg = GetPostString("proofimg");
  1578. string sellerNick = GetPostString("seller_nick");
  1579. string addFrom = GetPostString("addfrom");
  1580. if (addFrom == "1")
  1581. {
  1582. preStr = "N_";
  1583. }
  1584. int shopId = 0;
  1585. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1586. if (nShop != null)
  1587. {
  1588. shopId = nShop.ID;
  1589. }
  1590. else
  1591. {
  1592. returnErrorMsg("找不到对应店铺");
  1593. return;
  1594. }
  1595. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1596. {
  1597. returnErrorMsg("必须上传付款凭证");
  1598. return;
  1599. }
  1600. CeErpTrade entity = new CeErpTrade();
  1601. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1602. entity.seller_nick = sellerNick;
  1603. entity.buyer_nick = GetPostString("buyer_nick");
  1604. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1605. entity.total_fee = entity.payment;
  1606. entity.pay_time = DateTime.Now;
  1607. entity.status = "NOT_SHIPPED";
  1608. entity.receiver_name = GetPostString("receiver_name");
  1609. entity.receiver_mobile = GetPostString("receiver_mobile");
  1610. entity.receiver_state = GetPostString("receiver_state");
  1611. entity.receiver_city = GetPostString("receiver_city");
  1612. entity.receiver_district = GetPostString("receiver_district");
  1613. entity.receiver_address = GetPostString("receiver_address");
  1614. entity.seller_memo = memo;
  1615. entity.orderFrom = 20;
  1616. entity.orderType = 15;
  1617. if (entity.receiver_state == "" || entity.receiver_city == "")
  1618. {
  1619. returnErrorMsg("收件地址不能为空");
  1620. return;
  1621. }
  1622. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1623. {
  1624. returnErrorMsg("公司自用的单金额才能为0");
  1625. return;
  1626. }
  1627. entity.Create();
  1628. string toWhere = GetPostString("towhere");
  1629. CeErpTradeCell entitycell = new CeErpTradeCell();
  1630. entitycell.ctid = entity.tid;
  1631. //唯一标识
  1632. entitycell.OrderSn = entity.tid;
  1633. string orderSn = dataHelper.getSaleOrderSn();
  1634. if (orderSn != "")
  1635. {
  1636. entitycell.OrderSn = orderSn;
  1637. }
  1638. entitycell.tid = entity.tid;
  1639. //if (preStr == "X_")
  1640. //{
  1641. entitycell.IsOffLineOrder = 1;
  1642. //}
  1643. entitycell.CustomerUserId = CurrentUser.UserID;
  1644. entitycell.PayProofImg = primg;
  1645. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1646. entitycell.ProductId = Convert.ToInt32(productId);
  1647. entitycell.ShopId = shopId;
  1648. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1649. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1650. {
  1651. entitycell.IsXianHuo = 1;
  1652. }
  1653. entitycell.pay_time = entity.pay_time;
  1654. if (toWhere == "1")
  1655. {
  1656. entitycell.OrderState = 2;
  1657. }
  1658. else
  1659. {
  1660. entitycell.OrderState = 6;
  1661. entitycell.FinishPlaceTime = entitycell.pay_time;
  1662. }
  1663. if (shopId == 94)
  1664. {
  1665. entitycell.OrderState = 4;
  1666. entitycell.WaitDesignTime = entitycell.pay_time;
  1667. entitycell.StartDesignTime = entitycell.pay_time;
  1668. entitycell.DesignUserId = 218;
  1669. }
  1670. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1671. {
  1672. entitycell.OrderState = -1;//修改12-5
  1673. CeWithdraw ceWithdraw = new CeWithdraw();
  1674. ceWithdraw.tid = entity.tid;
  1675. ceWithdraw.providerid = "-1";
  1676. ceWithdraw.status = -1;
  1677. ceWithdraw.creationtime = DateTime.Now;
  1678. ceWithdraw.userid = 1337;
  1679. ceWithdraw.Create();
  1680. }
  1681. entitycell.Create();
  1682. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1683. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1684. {
  1685. addPlaceRegist(entitycell, CurrentUser.UserID);
  1686. }
  1687. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1688. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1689. return;
  1690. }
  1691. }
  1692. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1693. {
  1694. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1695. entity.PlactTime = tradecell.pay_time;
  1696. entity.AddUserId = userid;
  1697. entity.FileName = tradecell.seller_memo;
  1698. entity.Supplier = 24;
  1699. entity.CreateTime = DateTime.Now;
  1700. entity.Did = tradecell.ctid;
  1701. entity.tid = tradecell.tid;
  1702. entity.splitTag = tradecell.SplitTag;
  1703. entity.CurState = "未完成";
  1704. entity.Create();
  1705. }
  1706. public void get_erp_offlinelist()
  1707. {
  1708. DataStruct dStruct = GetPostStruct();
  1709. List<string> lw = new List<string>();
  1710. string tid = GetPostString("ctid");
  1711. string date1 = GetPostString("date1");
  1712. string date2 = GetPostString("date2");
  1713. if (tid.Length > 0 || date1.Length > 0)
  1714. {
  1715. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1716. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1717. if (dw.Length > 0) lw.Add(dw);
  1718. }
  1719. else
  1720. {
  1721. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1722. }
  1723. string shopname = GetPostString("shopname");
  1724. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1725. string buyernick = GetPostString("buyer_nick");
  1726. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1727. string customer = GetPostString("customer");
  1728. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1729. string design = GetPostString("design");
  1730. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1731. string orderState = GetPostString("orderState");
  1732. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1733. string address = GetPostString("address");
  1734. 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));
  1735. string sellermemo = GetPostString("seller_memo");
  1736. if (sellermemo.Length > 0)
  1737. {
  1738. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1739. }
  1740. string price1 = GetPostString("price1");
  1741. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1742. string price2 = GetPostString("price2");
  1743. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1744. //if (PKey != "admin")
  1745. //{
  1746. // string usershop = CurrentUser.User.pemShop;
  1747. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1748. //}
  1749. //if (ex_psize > 0)
  1750. //{
  1751. dStruct.Order = "pay_time desc";
  1752. //}
  1753. //else
  1754. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1755. lw.Add(string.Format("IsOffLineOrder=1"));
  1756. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1757. DataTable dt = null;
  1758. dt = WebCache.GetData("view_erptradecell", dStruct);
  1759. writeGridDataTableJson(dStruct.TotalCount, dt);
  1760. }
  1761. public void get_erp_returncashrecord()
  1762. {
  1763. DataStruct dStruct = GetPostStruct();
  1764. List<string> lw = new List<string>();
  1765. string tid = GetPostString("ctid");
  1766. if (tid.Length > 0)
  1767. {
  1768. lw.Add(string.Format("tid like '%{0}%'", tid));
  1769. dStruct.Order = "id desc";
  1770. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1771. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1772. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1773. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1774. return;
  1775. }
  1776. returnErrorMsg("id数据错误!");
  1777. }
  1778. public void ins_erp_returncashrecord()
  1779. {
  1780. if (UrlPostParmsCheck("tid"))
  1781. {
  1782. string tid = GetPostString("tid");
  1783. string retype = GetPostString("type");
  1784. StringBuilder sql = new StringBuilder();
  1785. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1786. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1787. if (dt.Rows.Count > 0)
  1788. {
  1789. returnErrorMsg("相同返现类型记录已存在");
  1790. return;
  1791. }
  1792. CeErpReturnCash entity = new CeErpReturnCash();
  1793. entity.tid = tid;
  1794. entity.seller_nick = GetPostString("seller_nick");
  1795. string pment = GetPostString("payment");
  1796. if (pment.Length > 0)
  1797. {
  1798. entity.payment = Convert.ToDouble(pment);
  1799. }
  1800. entity.buyer_nick = GetPostString("buyer_nick");
  1801. entity.cashstate = 0;
  1802. entity.rtype = retype;
  1803. string rPrice = GetPostString("returnprice");
  1804. if (rPrice.Length > 0)
  1805. {
  1806. entity.returnprice = Convert.ToDouble(rPrice);
  1807. }
  1808. entity.created = DateTime.Now;
  1809. entity.con = GetPostString("con");
  1810. entity.img = GetPostString("img");
  1811. entity.applyuserid = CurrentUser.UserID;
  1812. entity.Create();
  1813. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1814. returnSuccessMsg("操作成功!");
  1815. return;
  1816. }
  1817. }
  1818. public void set_erp_predelivery()
  1819. {
  1820. if (UrlPostParmsCheck("ctid"))
  1821. {
  1822. string eid = GetPostString("ctid");
  1823. CeErpTradeCell entity = null;
  1824. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1825. if (entity != null)
  1826. {
  1827. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1828. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1829. //{
  1830. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1831. // return;
  1832. //}
  1833. entity.IsPreDelivery = 1;
  1834. entity.Update();
  1835. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1836. returnSuccessMsg("预发货成功!");
  1837. return;
  1838. //string shop = GetPostString("seller_nick");
  1839. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1840. //string comName = GetPostString("comName");
  1841. //string comCode = GetPostString("comCode");
  1842. //string outSid = GetPostString("outSid");//运单号
  1843. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1844. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1845. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1846. //string apires = "";
  1847. //if (deliveryType == "虚拟发货")
  1848. //{
  1849. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1850. //}
  1851. //else
  1852. //{
  1853. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1854. //}
  1855. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1856. ////{
  1857. //if (apires.IndexOf("发货成功") != -1)
  1858. //{
  1859. // if (deliveryType != "虚拟发货")
  1860. // {
  1861. // //还要插入快递信息到 快递信息表
  1862. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1863. // exinfo.tid = eid;
  1864. // exinfo.out_sid = outSid;
  1865. // exinfo.company_code = comCode;
  1866. // exinfo.company_name = comName;
  1867. // exinfo.delivery_memo = deliveryMemo;
  1868. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1869. // exinfo.deliveryType = deliveryType;
  1870. // exinfo.Create();
  1871. // }
  1872. // returnSuccessMsg("发货成功!");
  1873. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1874. //}
  1875. //else
  1876. //{
  1877. // returnErrorMsg("淘宝发货失败!!");
  1878. //}
  1879. //return;
  1880. }
  1881. returnErrorMsg("找不到订单记录");
  1882. }
  1883. }
  1884. public void get_erp_unusuallist()
  1885. {
  1886. DataStruct dStruct = GetPostStruct();
  1887. List<string> lw = new List<string>();
  1888. string tid = GetPostString("ctid");
  1889. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1890. string shopname = GetPostString("shopname");
  1891. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1892. string buyernick = GetPostString("buyer_nick");
  1893. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1894. string ResponsibleMan = GetPostString("responsible");
  1895. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1896. string date1 = GetPostString("date1");
  1897. string date2 = GetPostString("date2");
  1898. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1899. if (dw.Length > 0) lw.Add(dw);
  1900. string price1 = GetPostString("price1");
  1901. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1902. string price2 = GetPostString("price2");
  1903. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1904. string orderState = GetPostString("orderState");
  1905. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1906. string sellermemo = GetPostString("seller_memo");
  1907. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1908. lw.Add(string.Format("UnusualTag > 0"));
  1909. lw.Add(string.Format("IsRefund<={0}", 1));
  1910. dStruct.Order = "pay_time desc";
  1911. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1912. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1913. writeGridDataTableJson(dStruct.TotalCount, dt);
  1914. }
  1915. public void set_erp_unusualtonomal()
  1916. {
  1917. if (UrlPostParmsCheck("ctid"))
  1918. {
  1919. string eid = GetPostString("ctid");
  1920. CeErpTradeCell entity = null;
  1921. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1922. if (entity != null)
  1923. {
  1924. entity.UnusualTag = -1;
  1925. entity.Update();
  1926. returnSuccessMsg("忽略成功!");
  1927. return;
  1928. }
  1929. returnErrorMsg("找不到记录");
  1930. }
  1931. }
  1932. public void ins_erp_unusualreason()
  1933. {
  1934. if (UrlPostParmsCheck("ctid"))
  1935. {
  1936. string eid = GetPostString("ctid");
  1937. CeErpTradeCell entity = null;
  1938. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1939. if (entity != null)
  1940. {
  1941. entity.MemoOpt = 4;
  1942. entity.UnusualCon = GetPostString("con");
  1943. entity.Update();
  1944. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1945. if (trade != null)
  1946. {
  1947. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1948. }
  1949. //查货是否超时
  1950. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1951. if (ceErpTradeCellExtend == null)
  1952. {
  1953. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1954. ceErpTradeCellExtend.ctid = entity.ctid;
  1955. }
  1956. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1957. {
  1958. ceErpTradeCellExtend.CheckOut += 1;
  1959. }
  1960. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1961. if (ceErpTradeCellExtend.ID > 0)
  1962. {
  1963. ceErpTradeCellExtend.Update();
  1964. }
  1965. else
  1966. {
  1967. ceErpTradeCellExtend.Create();
  1968. }
  1969. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1970. returnSuccessMsg("操作成功!");
  1971. return;
  1972. }
  1973. returnErrorMsg("找不到记录");
  1974. }
  1975. }
  1976. public void upd_erp_sampleorder()
  1977. {
  1978. if (UrlPostParmsCheck("ctid"))
  1979. {
  1980. string eid = GetPostString("ctid");
  1981. string[] eArr = eid.Split(',');
  1982. if (eArr.Length > 1)
  1983. {
  1984. List<string> eLst = new List<string>();
  1985. for (int i = 0; i < eArr.Length; i++)
  1986. {
  1987. eLst.Add("'" + eArr[i] + "'");
  1988. }
  1989. eid = string.Join(",", eLst.ToArray());
  1990. }
  1991. else
  1992. {
  1993. eid = "'" + eid + "'";
  1994. }
  1995. StringBuilder sql = new StringBuilder();
  1996. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1997. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1998. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1999. if (dt.Rows.Count > 0)
  2000. {
  2001. string errmsg = "";
  2002. foreach (DataRow dr in dt.Rows)
  2003. {
  2004. StringBuilder sqlsb = new StringBuilder();
  2005. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2006. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2007. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2008. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2009. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2010. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2011. {
  2012. continue;
  2013. }
  2014. else
  2015. {
  2016. string emsg = commonHelper.KeepChinese(apires);
  2017. errmsg += emsg;
  2018. }
  2019. }
  2020. if (errmsg.Length > 0)
  2021. {
  2022. returnErrorMsg(errmsg);
  2023. return;
  2024. }
  2025. returnSuccessMsg("操作成功");
  2026. return;
  2027. }
  2028. returnErrorMsg("找不到记录");
  2029. }
  2030. }
  2031. public void upd_erp_transcustomer()
  2032. {
  2033. if (UrlPostParmsCheck("ctid"))
  2034. {
  2035. string eid = GetPostString("ctid");
  2036. int userid = GetPostInt("CustomerUserId");
  2037. CeErpTradeCell entity = null;
  2038. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2039. if (entity != null)
  2040. {
  2041. //string[] mlist = entity.seller_memo.Split('-');
  2042. //string sql = "select * from view_erpuser where id=" + userid;
  2043. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2044. //if (dt != null && dt.Rows.Count > 0)
  2045. //{
  2046. // string nmemo = "";
  2047. // for(int i = 0; i < mlist.Length - 1; i++)
  2048. // {
  2049. // nmemo += mlist[i];
  2050. // nmemo += "-";
  2051. // }
  2052. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2053. // entity.seller_memo = nmemo;
  2054. //}
  2055. entity.CustomerUserId = userid;
  2056. entity.Update();
  2057. returnSuccessMsg("操作成功!");
  2058. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2059. return;
  2060. }
  2061. returnErrorMsg("找不到记录");
  2062. }
  2063. }
  2064. public void upd_erp_transdesigner()
  2065. {
  2066. if (UrlPostParmsCheck("ctid"))
  2067. {
  2068. string eids = GetPostString("ctid");
  2069. string[] ctidList = eids.Split(',');
  2070. int userid = GetPostInt("DesignUserId");
  2071. foreach (string ctid in ctidList)
  2072. {
  2073. CeErpTradeCell entity = null;
  2074. CeErpDesignerBill entitys = null;
  2075. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2076. entitys = CeErpDesignerBill.GetByTid(ctid);
  2077. if (entity != null)
  2078. {
  2079. if (entity.OrderState > 4)
  2080. {
  2081. continue;
  2082. }
  2083. //存在退款不能流转
  2084. if (entity.IsRefund > 0)
  2085. {
  2086. continue;
  2087. }
  2088. entity.DesignUserId = userid;
  2089. entity.WaitDesignTime = DateTime.Now;
  2090. entity.Update();
  2091. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2092. }
  2093. }
  2094. returnSuccessMsg("操作成功!");
  2095. }
  2096. }
  2097. public void upd_erp_distributedesigner()
  2098. {
  2099. if (UrlPostParmsCheck("ctid"))
  2100. {
  2101. string eid = GetPostString("ctid");
  2102. int userid = GetPostInt("DesignUserId");
  2103. string[] idlist = eid.Split(',');
  2104. if (idlist.Length <= 0)
  2105. {
  2106. returnErrorMsg("订单不能为空");
  2107. return;
  2108. }
  2109. foreach (string ctid in idlist)
  2110. {
  2111. CeErpTradeCell entity = null;
  2112. CeErpDesignerBill entitys = null;
  2113. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2114. else continue;
  2115. if (entity != null)
  2116. {
  2117. if (userid == 2125 || userid == 3542)
  2118. { }
  2119. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2120. {
  2121. returnErrorMsg("金额错误的订单无法指派");
  2122. return;
  2123. }
  2124. if (entity.OrderState >= 5)
  2125. {
  2126. returnErrorMsg("已经设计完成无法指派");
  2127. return;
  2128. }
  2129. if (entity.OrderState == -1)
  2130. {
  2131. returnErrorMsg("审核中的订单无法指派");
  2132. return;
  2133. }
  2134. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2135. {
  2136. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2137. return;
  2138. }
  2139. //157赖橙帆 159林晨
  2140. 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)
  2141. {
  2142. returnErrorMsg("指派设计共创无法再次指派!");
  2143. return;
  2144. }
  2145. entity.OrderState = 3;
  2146. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2147. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2148. {
  2149. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2150. entity.SupplierId = suid;
  2151. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2152. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2153. }
  2154. if (userid == 2125 && entity.seller_memo != "")
  2155. {
  2156. apiDesign.API_GetPrintData_CreateOrder(entity);
  2157. }
  2158. if (userid == 3542 && entity.seller_memo != "")
  2159. {
  2160. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2161. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2162. if (response.msg != "设计共创:成功")
  2163. {
  2164. returnErrorMsg(response.msg);
  2165. return;
  2166. }
  2167. entity.DispatchSort = 2;
  2168. }
  2169. else
  2170. {
  2171. if (entity.DispatchSort == 2)
  2172. {
  2173. ApiVo apiVo = new ApiVo();
  2174. apiVo.actionName = "closeDesign";
  2175. apiVo.orderNumber = entity.ctid;
  2176. designHelper.API_WorkCore(apiVo);//closeDesign
  2177. }
  2178. entity.DispatchSort = 0;
  2179. }
  2180. entity.DesignUserId = userid;
  2181. entity.WaitDesignTime = DateTime.Now;
  2182. entity.Update();
  2183. string name = commonHelper.getUserNameById(userid);
  2184. commonHelper.UpdateRelationOrder(entity.ctid);
  2185. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2186. }
  2187. }
  2188. returnSuccessMsg("操作成功!");
  2189. return;
  2190. }
  2191. }
  2192. public string getTidByCtid(string ctid)
  2193. {
  2194. string tid = "";
  2195. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2196. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2197. if (dataTable != null && dataTable.Rows.Count > 0)
  2198. {
  2199. tid = dataTable.Rows[0]["tid"].ToString();
  2200. }
  2201. return tid;
  2202. }
  2203. public List<string> getTidByCtidLike(string ctid)
  2204. {
  2205. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2206. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2207. List<string> list = new List<string>();
  2208. if (dataTable != null && dataTable.Rows.Count > 0)
  2209. {
  2210. foreach (DataRow item in dataTable.Rows)
  2211. {
  2212. list.Add("'" + item["tid"].ToString() + "'");
  2213. }
  2214. }
  2215. return list;
  2216. }
  2217. public void get_erp_myorderlist()
  2218. {
  2219. DataStruct dStruct = GetPostStruct();
  2220. List<string> lw = new List<string>();
  2221. string tid = GetPostString("ctid");
  2222. if (tid.Length > 0)
  2223. {
  2224. string select_tid = getTidByCtid(tid);
  2225. lw.Add(string.Format("tid='{0}'", select_tid));
  2226. }
  2227. else
  2228. {
  2229. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2230. }
  2231. //12-1 修改
  2232. string urgent = GetPostString("urgent");
  2233. string back = GetPostString("back");
  2234. string offlineSearch = GetPostString("offlineSearch");
  2235. if (!string.IsNullOrWhiteSpace(urgent))
  2236. {
  2237. if (urgent.Equals("true"))
  2238. {
  2239. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2240. }
  2241. }
  2242. if (!string.IsNullOrWhiteSpace(back))
  2243. {
  2244. if (back.Equals("true"))
  2245. {
  2246. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2247. }
  2248. }
  2249. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2250. {
  2251. if (offlineSearch.Equals("true"))
  2252. {
  2253. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2254. }
  2255. }
  2256. //end
  2257. string shopname = GetPostString("shopname");
  2258. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2259. string buyernick = GetPostString("buyer_nick");
  2260. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2261. string design = GetPostString("design");
  2262. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2263. string orderState = GetPostString("orderState");
  2264. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2265. string sellermemo = GetPostString("seller_memo");
  2266. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2267. string date1 = GetPostString("date1");
  2268. string date2 = GetPostString("date2");
  2269. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2270. if (dw.Length > 0) lw.Add(dw);
  2271. string price1 = GetPostString("price1");
  2272. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2273. string price2 = GetPostString("price2");
  2274. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2275. string urgency = GetPostString("urgency");
  2276. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2277. string after = GetPostString("after");
  2278. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2279. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2280. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2281. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2282. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2283. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2284. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2285. if (dt != null && dt.Rows.Count > 0)
  2286. {
  2287. foreach (DataRow dr in dt.Rows)
  2288. {
  2289. try
  2290. {
  2291. // 对象操作
  2292. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2293. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2294. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2295. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2296. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2297. if (dStruct.PageSize != 100000)
  2298. {
  2299. if (dr["DispatchSort"].ToString() == "2")
  2300. {
  2301. dr["gongchuang"] = 200;
  2302. }
  2303. else
  2304. {
  2305. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2306. dr["gongchuang"] = response.code;
  2307. }
  2308. }
  2309. }
  2310. catch (NullReferenceException ex)
  2311. {
  2312. }
  2313. }
  2314. }
  2315. writeGridDataTableJson(dStruct.TotalCount, dt);
  2316. }
  2317. public void get_erp_myreturnorderlist()
  2318. {
  2319. DataStruct dStruct = GetPostStruct();
  2320. List<string> lw = new List<string>();
  2321. string tid = GetPostString("ctid");
  2322. if (tid.Length > 0)
  2323. {
  2324. string select_tid = getTidByCtid(tid);
  2325. lw.Add(string.Format("tid='{0}'", select_tid));
  2326. }
  2327. else
  2328. {
  2329. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2330. }
  2331. string shopname = GetPostString("shopname");
  2332. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2333. string buyernick = GetPostString("buyer_nick");
  2334. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2335. string design = GetPostString("design");
  2336. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2337. string orderState = GetPostString("orderState");
  2338. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2339. string sellermemo = GetPostString("seller_memo");
  2340. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2341. string date1 = GetPostString("date1");
  2342. string date2 = GetPostString("date2");
  2343. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2344. if (dw.Length > 0) lw.Add(dw);
  2345. string price1 = GetPostString("price1");
  2346. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2347. string price2 = GetPostString("price2");
  2348. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2349. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2350. {
  2351. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2352. }
  2353. else
  2354. {
  2355. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2356. }
  2357. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2358. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2359. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2360. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2361. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2362. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2363. if (dt != null && dt.Rows.Count > 0)
  2364. {
  2365. foreach (DataRow dr in dt.Rows)
  2366. {
  2367. try
  2368. {
  2369. // 对象操作
  2370. if (dStruct.PageSize != 100000)
  2371. {
  2372. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2373. dr["gongchuang"] = response.code;
  2374. }
  2375. }
  2376. catch (NullReferenceException ex)
  2377. {
  2378. // 处理空引用异常
  2379. }
  2380. }
  2381. }
  2382. writeGridDataTableJson(dStruct.TotalCount, dt);
  2383. }
  2384. public void get_erp_myorderlist_pregather()
  2385. {
  2386. string date1 = GetPostString("date1");
  2387. string date2 = GetPostString("date2");
  2388. int userId = CurrentUser.UserID; //客服id
  2389. string orderWhere = "";
  2390. List<string> lw = new List<string>();
  2391. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2392. if (dw.Length > 0) lw.Add(dw);
  2393. lw.Add(string.Format("CustomerUserId={0}", userId));
  2394. lw.Add(string.Format("OrderState<9"));
  2395. orderWhere = string.Join(" and ", lw.ToArray());
  2396. string orderWhere2 = "";
  2397. List<string> lw2 = new List<string>();
  2398. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2399. if (dw2.Length > 0) lw2.Add(dw2);
  2400. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2401. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2402. string sql = string.Format("select *" +
  2403. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2404. "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 " +
  2405. "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 " +
  2406. "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");
  2407. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2408. //writeGridDataTableJson(dt.Rows.Count, dt);
  2409. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2410. }
  2411. public void upd_erp_publishorder()
  2412. {
  2413. if (UrlPostParmsCheck("ctid"))
  2414. {
  2415. string eid = GetPostString("ctid");
  2416. CeErpTradeCell entity = null;
  2417. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2418. if (entity != null)
  2419. {
  2420. entity.OrderState = 0; //发布后,变为待抢单
  2421. entity.Update();
  2422. commonHelper.UpdateRelationOrder(entity.ctid);
  2423. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2424. returnSuccessMsg("发布成功!");
  2425. return;
  2426. }
  2427. returnErrorMsg("找不到记录");
  2428. }
  2429. }
  2430. public void get_erp_my_tiporder()
  2431. {
  2432. StringBuilder sql = new StringBuilder();
  2433. int userId = 0;
  2434. if (CurrentUser != null) userId = CurrentUser.UserID;
  2435. string posCode = CurrentUser.UserPost.Post.Code;
  2436. string isTipedAfterSaleVerify = GetPostString("af");
  2437. DataTable dt = new DataTable();
  2438. if (posCode != "Supplier")
  2439. {
  2440. if (posCode == "CustomerService" || posCode == "Director")
  2441. {
  2442. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2443. }
  2444. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2445. {
  2446. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2447. }
  2448. else
  2449. {
  2450. string teamIds = CurrentUser.User.TeamIds;
  2451. if (teamIds == "")
  2452. {
  2453. teamIds = "0";
  2454. }
  2455. 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);
  2456. }
  2457. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2458. }
  2459. if (dt.Rows.Count <= 0)
  2460. {
  2461. string key = "aftersale_order_" + userId;
  2462. if (RedisHelper.HasKey(key))
  2463. {
  2464. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2465. dt.Columns.Add("ctid", typeof(string));
  2466. dt.Columns.Add("IsReadTag", typeof(int));
  2467. foreach (var i in list)
  2468. {
  2469. DataRow data = dt.NewRow();
  2470. data["ctid"] = i;
  2471. data["IsReadTag"] = 4;
  2472. dt.Rows.Add(data);
  2473. }
  2474. RedisHelper.StringDelete(key);
  2475. }
  2476. }
  2477. if (dt.Rows.Count <= 0)
  2478. {
  2479. sql = new StringBuilder();
  2480. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2481. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2482. }
  2483. if (posCode == "Supplier")
  2484. {
  2485. string ids = CurrentUser.User.pemVend;
  2486. if (ids != null && ids.Length > 0)
  2487. {
  2488. string[] ids_list = ids.Split(',');
  2489. foreach (var item in ids_list)
  2490. {
  2491. string key = "return_order_" + item;
  2492. if (RedisHelper.HasKey(key))
  2493. {
  2494. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2495. dt.Columns.Add("ctid", typeof(string));
  2496. dt.Columns.Add("IsReadTag", typeof(int));
  2497. foreach (var i in list)
  2498. {
  2499. DataRow data = dt.NewRow();
  2500. data["ctid"] = i;
  2501. data["IsReadTag"] = 1;
  2502. dt.Rows.Add(data);
  2503. }
  2504. RedisHelper.StringDelete(key);
  2505. }
  2506. }
  2507. }
  2508. if (dt.Rows.Count <= 0)
  2509. {
  2510. sql = new StringBuilder();
  2511. 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);
  2512. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2513. }
  2514. }
  2515. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2516. }
  2517. public void reset_erp_tiporder()
  2518. {
  2519. string ids = GetPostString("ids");
  2520. string[] ctidList = ids.Split(',');
  2521. foreach (string ctid in ctidList)
  2522. {
  2523. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2524. if (enty != null)
  2525. {
  2526. enty.IsReadTag = 0;
  2527. enty.Update();
  2528. }
  2529. }
  2530. returnSuccessMsg("成功!");
  2531. return;
  2532. }
  2533. public void get_erp_designlist()
  2534. {
  2535. DataStruct dStruct = GetPostStruct();
  2536. List<string> lw = new List<string>();
  2537. string tid = GetPostString("ctid");
  2538. if (tid.Length > 0)
  2539. {
  2540. string select_tid = getTidByCtid(tid);
  2541. lw.Add(string.Format("tid='{0}'", select_tid));
  2542. }
  2543. string shopname = GetPostString("shopname");
  2544. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2545. string buyernick = GetPostString("buyer_nick");
  2546. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2547. string customer = GetPostString("customer");
  2548. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2549. string design = GetPostString("design");
  2550. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2551. string orderState = GetPostString("orderState");
  2552. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2553. lw.Add(string.Format("OrderState<6"));
  2554. string address = GetPostString("address");
  2555. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2556. string sellermemo = GetPostString("seller_memo");
  2557. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2558. string date1 = GetPostString("date1");
  2559. string date2 = GetPostString("date2");
  2560. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2561. if (dw.Length > 0) lw.Add(dw);
  2562. string apdate1 = GetPostString("apdate1");
  2563. string apdate2 = GetPostString("apdate2");
  2564. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2565. if (dwap.Length > 0) lw.Add(dwap);
  2566. string price1 = GetPostString("price1");
  2567. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2568. string price2 = GetPostString("price2");
  2569. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2570. string designTime = GetPostString("designtime");
  2571. if (designTime.Length > 0)
  2572. {
  2573. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2574. }
  2575. string usershop = CurrentUser.User.pemShop;
  2576. if (usershop.Length > 0)
  2577. {
  2578. lw.Add(string.Format("shopId in ({0})", usershop));
  2579. }
  2580. int myOrgid = CurrentUser.UserPost.OrgID;
  2581. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2582. if (myOrgCode.IndexOf("Designer") != -1)
  2583. {
  2584. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2585. {
  2586. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2587. }
  2588. else
  2589. {
  2590. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2591. }
  2592. }
  2593. else
  2594. {
  2595. string orgId = GetPostString("designerhd");
  2596. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2597. }
  2598. if (tid.Length > 0 || buyernick.Length > 0)
  2599. {
  2600. lw.Add(string.Format("OrderState >= 3"));
  2601. }
  2602. else
  2603. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2604. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2605. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2606. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2607. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2608. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2609. if (dt != null && dt.Rows.Count > 0)
  2610. {
  2611. foreach (DataRow dr in dt.Rows)
  2612. {
  2613. try
  2614. {
  2615. // 对象操作
  2616. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2617. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2618. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2619. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2620. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2621. if (dStruct.PageSize != 100000)
  2622. {
  2623. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2624. dr["gongchuang"] = response.code;
  2625. }
  2626. }
  2627. catch (NullReferenceException ex)
  2628. {
  2629. }
  2630. }
  2631. }
  2632. writeGridDataTableJson(dStruct.TotalCount, dt);
  2633. }
  2634. public void get_erp_mydesignlist()
  2635. {
  2636. DataStruct dStruct = GetPostStruct();
  2637. List<string> lw = new List<string>();
  2638. string tid = GetPostString("ctid");
  2639. if (tid.Length > 0)
  2640. {
  2641. string select_tid = getTidByCtid(tid);
  2642. lw.Add(string.Format("tid='{0}'", select_tid));
  2643. }
  2644. string shopname = GetPostString("shopname");
  2645. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2646. string buyernick = GetPostString("buyer_nick");
  2647. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2648. string customer = GetPostString("customer");
  2649. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2650. string orderState = GetPostString("orderState");
  2651. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2652. //lw.Add(string.Format("OrderState<6"));
  2653. string date1 = GetPostString("date1");
  2654. string date2 = GetPostString("date2");
  2655. string dw = GetDateWhere("pay_time", date1, date2);
  2656. if (dw.Length > 0) lw.Add(dw);
  2657. string apdate1 = GetPostString("apdate1");
  2658. string apdate2 = GetPostString("apdate2");
  2659. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2660. if (dwap.Length > 0) lw.Add(dwap);
  2661. string price1 = GetPostString("price1");
  2662. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2663. string price2 = GetPostString("price2");
  2664. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2665. string olddownload = GetPostString("olddown");
  2666. if (olddownload == "1")
  2667. {
  2668. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2669. }
  2670. else if (olddownload == "2")
  2671. {
  2672. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2673. }
  2674. string sellermemo = GetPostString("seller_memo");
  2675. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2676. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2677. if (CurrentUser.User.TeamIds.Length > 0)
  2678. {
  2679. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2680. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2681. else
  2682. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2683. }
  2684. else
  2685. {
  2686. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2687. }
  2688. if (tid.Length <= 0)
  2689. {
  2690. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2691. }
  2692. lw.Add(string.Format("IsReturn!=3"));
  2693. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2694. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2695. string teamids = CurrentUser.User.TeamIds.ToString();
  2696. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2697. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2698. if (dt != null && dt.Rows.Count > 0)
  2699. {
  2700. foreach (DataRow dr in dt.Rows)
  2701. {
  2702. try
  2703. {
  2704. // 对象操作
  2705. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2706. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2707. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2708. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2709. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2710. if (dStruct.PageSize != 100000)
  2711. {
  2712. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2713. dr["gongchuang"] = response.code;
  2714. }
  2715. }
  2716. catch (NullReferenceException ex)
  2717. {
  2718. }
  2719. }
  2720. }
  2721. writeGridDataTableJson(dStruct.TotalCount, dt);
  2722. }
  2723. public void set_erp_startdesign()
  2724. {
  2725. if (UrlPostParmsCheck("ctid"))
  2726. {
  2727. string eid = GetPostString("ctid");
  2728. CeErpTradeCell entity = null;
  2729. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2730. if (entity != null)
  2731. {
  2732. if (entity.OrderState != 3)
  2733. {
  2734. returnErrorMsg("请刷新,订单已经设计了");
  2735. return;
  2736. }
  2737. entity.StartDesignTime = DateTime.Now;
  2738. entity.OrderState = 4;
  2739. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2740. {
  2741. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2742. entity.SupplierId = suid;
  2743. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2744. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2745. }
  2746. //entity.MakeSupplier = suname;
  2747. entity.Update();
  2748. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2749. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2750. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2751. commonHelper.getCytPrice(entity);
  2752. returnSuccessMsg("操作成功!");
  2753. return;
  2754. }
  2755. returnErrorMsg("找不到记录");
  2756. }
  2757. }
  2758. public void ins_erp_designselfmemo()
  2759. {
  2760. if (UrlPostParmsCheck("ctid"))
  2761. {
  2762. string eid = GetPostString("ctid");
  2763. string con = GetPostString("con");
  2764. CeErpTradeCell entity = null;
  2765. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2766. if (entity != null)
  2767. {
  2768. entity.DesignSelfMemo = con;
  2769. entity.Update();
  2770. returnSuccessMsg("操作成功!");
  2771. return;
  2772. }
  2773. returnErrorMsg("找不到记录");
  2774. }
  2775. }
  2776. public void ins_erp_designprice()
  2777. {
  2778. if (UrlPostParmsCheck("ctid"))
  2779. {
  2780. string eid = GetPostString("ctid");
  2781. int uid = CurrentUser.UserID;
  2782. string userName = CurrentUser.UserName;
  2783. CeErpTradeCell entity = null;
  2784. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2785. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2786. if (entitys == null)
  2787. {
  2788. entitys = new CeErpDesignerBill();
  2789. }
  2790. if (entity != null)
  2791. {
  2792. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2793. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2794. entity.StartDesignTime = DateTime.Now;
  2795. entity.OrderState = 4;
  2796. string suname = "";
  2797. if (entity.SupplierId == 0)
  2798. {
  2799. int sid = commonHelper.autoDistributeToSupplier(entity);
  2800. entity.SupplierId = sid;
  2801. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2802. }
  2803. entity.Update();
  2804. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2805. if (ceErpUserPost != null)
  2806. {
  2807. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2808. if (ceErpPost != null)
  2809. {
  2810. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2811. {
  2812. entitys.tid = entity.ctid;
  2813. entitys.oid = entity.tid;
  2814. entitys.uid = uid;
  2815. entitys.userName = userName;
  2816. entitys.designerType = 1;
  2817. entitys.designerTypeText = "内部设计师";
  2818. entitys.price = Convert.ToDouble(GetPostString("price"));
  2819. entitys.designNum = GetPostInt("designNum");
  2820. entitys.modifyNum = GetPostInt("modifyNum");
  2821. entitys.designSize = GetPostString("designSize");
  2822. entitys.modifySize = GetPostString("modifySize");
  2823. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2824. {
  2825. entitys.create_time = DateTime.Now;
  2826. entitys.create_u_id = uid;
  2827. entitys.create_u_name = userName;
  2828. entitys.Save();
  2829. }
  2830. else
  2831. {
  2832. entitys.update_time = DateTime.Now;
  2833. entitys.update_u_id = uid;
  2834. entitys.update_u_name = userName;
  2835. entitys.Update();
  2836. }
  2837. }
  2838. }
  2839. }
  2840. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2841. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2842. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2843. if (suname != "")
  2844. {
  2845. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2846. }
  2847. commonHelper.getCytPrice(entity);
  2848. returnSuccessMsg("操作成功!");
  2849. return;
  2850. }
  2851. returnErrorMsg("找不到记录");
  2852. }
  2853. }
  2854. public void upload_erp_filecomplete()
  2855. {
  2856. if (UrlPostParmsCheck("ctid"))
  2857. {
  2858. string eid = GetPostString("ctid");
  2859. CeErpTradeCell entity = null;
  2860. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2861. if (entity != null)
  2862. {
  2863. entity.OrderState = 5; //设计完成
  2864. entity.Update();
  2865. returnSuccessMsg(eid + "上传成功,设计完成!");
  2866. return;
  2867. }
  2868. returnErrorMsg("找不到订单记录");
  2869. }
  2870. }
  2871. public void get_erp_designovertimelist()
  2872. {
  2873. DataStruct dStruct = GetPostStruct();
  2874. List<string> lw = new List<string>();
  2875. string tid = GetPostString("ctid");
  2876. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2877. string shopname = GetPostString("shopname");
  2878. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2879. string buyernick = GetPostString("buyer_nick");
  2880. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2881. string ResponsibleMan = GetPostString("responsible");
  2882. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2883. string date1 = GetPostString("date1");
  2884. string date2 = GetPostString("date2");
  2885. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2886. if (dw.Length > 0) lw.Add(dw);
  2887. string price1 = GetPostString("price1");
  2888. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2889. string price2 = GetPostString("price2");
  2890. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2891. string orderState = GetPostString("orderState");
  2892. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2893. string sellermemo = GetPostString("seller_memo");
  2894. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2895. lw.Add(string.Format("UnusualTag=3"));
  2896. lw.Add(string.Format("IsRefund<={0}", 1));
  2897. dStruct.Order = "WaitDesignTime desc";
  2898. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2899. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2900. writeGridDataTableJson(dStruct.TotalCount, dt);
  2901. }
  2902. //设计管理 获取抢单大厅列表
  2903. public void get_erp_grabinglist()
  2904. {
  2905. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2906. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2907. bool oldOrder = false;
  2908. if (org != null)
  2909. {
  2910. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2911. }
  2912. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2913. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2914. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2915. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2916. //先处理订单数据
  2917. if (dt.Rows.Count > 0)
  2918. {
  2919. Dictionary<string, int> design = null;
  2920. int count = 0;
  2921. foreach (DataRow row in dt.Rows)
  2922. {
  2923. if (map.ContainsKey(row["ShopId"].ToString()))
  2924. {
  2925. map.TryGetValue(row["ShopId"].ToString(), out design);
  2926. }
  2927. else
  2928. {
  2929. design = new Dictionary<string, int>();
  2930. }
  2931. if (design.ContainsKey(row["ProductId"].ToString()))
  2932. {
  2933. design.TryGetValue(row["ProductId"].ToString(), out count);
  2934. }
  2935. count++;
  2936. design[row["ProductId"].ToString()] = count;
  2937. map[row["ShopId"].ToString()] = design;
  2938. }
  2939. }
  2940. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2941. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2942. //把店铺排序和技能排序分类
  2943. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2944. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2945. if (design_dt.Rows.Count > 0)
  2946. {
  2947. Dictionary<string, string> design = null;
  2948. List<string> shopIds = null;
  2949. foreach (DataRow row in design_dt.Rows)
  2950. {
  2951. if ("0".Equals(row["designId"].ToString()))
  2952. {
  2953. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2954. {
  2955. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2956. }
  2957. else
  2958. {
  2959. shopIds = new List<string>();
  2960. }
  2961. shopIds.Add(row["shopId"].ToString());
  2962. shop_orders[row["orders"].ToString()] = shopIds;
  2963. }
  2964. else
  2965. {
  2966. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2967. {
  2968. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2969. }
  2970. else
  2971. {
  2972. design = new Dictionary<string, string>();
  2973. }
  2974. design[row["orders"].ToString()] = row["designId"].ToString();
  2975. design_orders[row["shopId"].ToString()] = design;
  2976. }
  2977. }
  2978. //处理成key value后根据key排序
  2979. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2980. foreach (List<string> val in shop_orders.Values)
  2981. {
  2982. if (val != null)
  2983. {
  2984. foreach (string key in val)
  2985. {
  2986. if (design_orders.ContainsKey(key.ToString()))
  2987. {
  2988. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2989. }
  2990. }
  2991. }
  2992. }
  2993. }
  2994. //校验哪个优先级有订单
  2995. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2996. foreach (string key in shop_orders.Keys)
  2997. {
  2998. List<string> ids = null;
  2999. shop_orders.TryGetValue(key, out ids);
  3000. //id为shopid
  3001. foreach (string id in ids)
  3002. {
  3003. Dictionary<string, int> list = null;
  3004. Dictionary<string, string> desing = null;
  3005. map.TryGetValue(id, out list);
  3006. design_orders.TryGetValue(id, out desing);
  3007. if (list != null && desing != null)
  3008. {
  3009. foreach (var item in desing)
  3010. {
  3011. int count = 0;
  3012. if (list.ContainsKey(item.Value))
  3013. {
  3014. list.TryGetValue(item.Value, out count);
  3015. if (count > 0)
  3016. {
  3017. designIds[id] = item.Value;
  3018. break;
  3019. }
  3020. }
  3021. }
  3022. }
  3023. }
  3024. if (designIds.Count > 0)
  3025. {
  3026. break;
  3027. }
  3028. }
  3029. DataTable table = new DataTable();
  3030. table.Columns.Add("tid", typeof(string));
  3031. table.Columns.Add("ctid", typeof(string));
  3032. table.Columns.Add("seller_nick", typeof(string));
  3033. table.Columns.Add("productName", typeof(string));
  3034. table.Columns.Add("pay_time", typeof(string));
  3035. table.Columns.Add("seller_memo", typeof(string));
  3036. if (designIds.Count > 0)
  3037. {
  3038. string shopId = "";
  3039. string productId = "";
  3040. foreach (var designInfo in designIds)
  3041. {
  3042. shopId = designInfo.Key;
  3043. productId = designInfo.Value;
  3044. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3045. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3046. if (dt.Rows.Count > 0)
  3047. {
  3048. foreach (DataRow row in dt.Rows)
  3049. {
  3050. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3051. {
  3052. DataRow data = table.NewRow();
  3053. data["ctid"] = row["ctid"].ToString();
  3054. data["tid"] = row["tid"].ToString();
  3055. data["seller_nick"] = ceErpShop.ShopName;
  3056. data["pay_time"] = row["pay_time"].ToString();
  3057. data["seller_memo"] = row["seller_memo"].ToString();
  3058. data["productName"] = ceErpProduct.PType;
  3059. table.Rows.Add(data);
  3060. }
  3061. }
  3062. }
  3063. }
  3064. }
  3065. writeGridDataTableJson(table.Rows.Count, table);
  3066. }
  3067. private object rushLockObject = new object();
  3068. public void set_erp_grabingorder()
  3069. {
  3070. if (UrlPostParmsCheck("ctid"))
  3071. {
  3072. int total = CurrentUser.User.Person.Total;
  3073. int userId = CurrentUser.User.ID;
  3074. int noFinish = CurrentUser.User.Person.NoFinish;
  3075. int finalization = CurrentUser.User.Person.Finalization;
  3076. string eids = GetPostString("ctid");
  3077. string key = "RushKey_" + userId;
  3078. int count = 0;
  3079. if (erpRedis.RedisHelper.KeyExists(key))
  3080. {
  3081. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3082. if (redisCount != null)
  3083. {
  3084. count = Convert.ToInt32(redisCount);
  3085. }
  3086. }
  3087. if (count >= total)
  3088. {
  3089. returnErrorMsg("半小时内已经抢" + total + "单");
  3090. return;
  3091. }
  3092. string[] ctidlist = eids.Split(',');
  3093. if (count + ctidlist.Length > total)
  3094. {
  3095. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3096. return;
  3097. }
  3098. int itag = 0;
  3099. lock (rushLockObject)
  3100. {
  3101. if (ctidlist.Length > 0)
  3102. {
  3103. string[] dtList = new string[ctidlist.Length];
  3104. for (int i = 0; i < ctidlist.Length; i++)
  3105. {
  3106. dtList[i] = "'" + ctidlist[i] + "'";
  3107. }
  3108. 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"));
  3109. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3110. if (dt_user.Rows.Count > 0)
  3111. {
  3112. int doing = 0;//未定稿
  3113. int finish = 0;//已完成
  3114. foreach (DataRow dr in dt_user.Rows)
  3115. {
  3116. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3117. {
  3118. doing++;
  3119. }
  3120. else
  3121. {
  3122. finish++;
  3123. }
  3124. }
  3125. if (doing >= noFinish)
  3126. {
  3127. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3128. return;
  3129. }
  3130. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3131. {
  3132. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3133. return;
  3134. }
  3135. }
  3136. //校验选择单子状态
  3137. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3138. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3139. if (dt.Rows.Count > 0)
  3140. {
  3141. List<string> list = new List<string>();
  3142. foreach (DataRow dr in dt.Rows)
  3143. {
  3144. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3145. {
  3146. list.Add(dr["ctid"].ToString());
  3147. }
  3148. }
  3149. if (list.Count > 0)
  3150. {
  3151. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3152. return;
  3153. }
  3154. }
  3155. foreach (string ctid in ctidlist)
  3156. {
  3157. CeErpTradeCell entity = null;
  3158. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3159. if (entity != null)
  3160. {
  3161. entity.OrderState = 3;
  3162. entity.DesignUserId = CurrentUser.UserID;
  3163. entity.WaitDesignTime = DateTime.Now;
  3164. entity.StartDesignTime = DateTime.Now;
  3165. entity.Update();
  3166. commonHelper.UpdateRelationOrder(entity.ctid);
  3167. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3168. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3169. itag++;
  3170. }
  3171. }
  3172. }
  3173. }
  3174. count += ctidlist.Length;
  3175. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3176. if (itag == 0)
  3177. returnErrorMsg("没有找到相关订单");
  3178. else
  3179. returnSuccessMsg("抢单成功!");
  3180. return;
  3181. }
  3182. }
  3183. public void get_erp_waitorderlist()
  3184. {
  3185. DataStruct dStruct = GetPostStruct();
  3186. List<string> lw = new List<string>();
  3187. string tid = GetPostString("ctid");
  3188. if (tid.Length > 0)
  3189. {
  3190. string select_tid = getTidByCtid(tid);
  3191. lw.Add(string.Format("tid='{0}'", select_tid));
  3192. }
  3193. string shopname = GetPostString("shopname");
  3194. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3195. string buyernick = GetPostString("buyer_nick");
  3196. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3197. string customer = GetPostString("customer");
  3198. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3199. string design = GetPostString("design");
  3200. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3201. string orderState = GetPostString("orderState");
  3202. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3203. string supplier = GetPostString("supplier");
  3204. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3205. string sellermemo = GetPostString("seller_memo");
  3206. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3207. string otherMemo = GetPostString("otherMemo");
  3208. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3209. string address = GetPostString("address");
  3210. 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));
  3211. string date1 = GetPostString("date1");
  3212. string date2 = GetPostString("date2");
  3213. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3214. if (dw.Length > 0) lw.Add(dw);
  3215. string price1 = GetPostString("price1");
  3216. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3217. string price2 = GetPostString("price2");
  3218. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3219. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3220. lw.Add(string.Format("IsSample != 2 "));
  3221. lw.Add(string.Format("OrderState = 5 "));
  3222. lw.Add(string.Format("IsRefund<={0}", 1));
  3223. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3224. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3225. string pagesize = GetPostString("pagesize");
  3226. if (pagesize != null)
  3227. {
  3228. dStruct.PageSize = 200;
  3229. }
  3230. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3231. if (dt != null)
  3232. {
  3233. foreach (DataRow dr in dt.Rows)
  3234. {
  3235. 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();
  3236. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3237. {
  3238. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3239. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3240. entity.SupplierId = suid;
  3241. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3242. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3243. entity.Update();
  3244. }
  3245. }
  3246. }
  3247. writeGridDataTableJson(dStruct.TotalCount, dt);
  3248. }
  3249. public void get_erp_supplierwaitorderlist()
  3250. {
  3251. DataStruct dStruct = GetPostStruct();
  3252. List<string> lw = new List<string>();
  3253. string tid = GetPostString("ctid");
  3254. if (tid.Length > 0)
  3255. {
  3256. string select_tid = getTidByCtid(tid);
  3257. lw.Add(string.Format("tid='{0}'", select_tid));
  3258. }
  3259. string shopname = GetPostString("shopname");
  3260. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3261. string sellermemo = GetPostString("seller_memo");
  3262. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3263. string date1 = GetPostString("date1");
  3264. string date2 = GetPostString("date2");
  3265. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3266. if (dw.Length > 0) lw.Add(dw);
  3267. lw.Add(string.Format("OrderState = 5 "));
  3268. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3269. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3270. {
  3271. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3272. }
  3273. string supplier = GetPostString("supplier");
  3274. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3275. {
  3276. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3277. }
  3278. lw.Add(string.Format("IsRefund<={0}", 1));
  3279. dStruct.Order = "FinishDesignTime desc";
  3280. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3281. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3282. if (dt != null)
  3283. {
  3284. foreach (DataRow dr in dt.Rows)
  3285. {
  3286. 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();
  3287. }
  3288. }
  3289. writeGridDataTableJson(dStruct.TotalCount, dt);
  3290. }
  3291. public void upd_erp_verifytosupplier()
  3292. {
  3293. if (UrlPostParmsCheck("ctid"))
  3294. {
  3295. string eids = GetPostString("ctid");
  3296. CeErpTradeCell entity = null;
  3297. string[] eidsList = eids.Split(',');
  3298. if (eidsList.Length <= 0)
  3299. {
  3300. returnErrorMsg("订单号不能空");
  3301. return;
  3302. }
  3303. List<string> tLst = new List<string>();
  3304. foreach (string ctidstr in eidsList)
  3305. {
  3306. tLst.Add("'" + ctidstr + "'");
  3307. CeErpDataSendOrderInfo.createObject(ctidstr);
  3308. }
  3309. string needtids = string.Join(",", tLst.ToArray());
  3310. StringBuilder sql = new StringBuilder();
  3311. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3312. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3313. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3314. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3315. returnSuccessMsg("操作成功!");
  3316. return;
  3317. /**foreach (string ctidstr in eidsList)
  3318. {
  3319. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3320. if (entity != null)
  3321. {
  3322. if (entity.SupplierId == 0)
  3323. {
  3324. continue;
  3325. }
  3326. entity.IsVerifyToSupplier = true;
  3327. if (entity.IsReturn == 1) //1是供应商打回
  3328. {
  3329. entity.IsReturn = 0;
  3330. }
  3331. entity.FinishPlaceTime = DateTime.Now;
  3332. entity.PlaceUserId = CurrentUser.UserID;
  3333. entity.Update();
  3334. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3335. }
  3336. }
  3337. returnSuccessMsg("操作成功!");
  3338. return;**/
  3339. }
  3340. }
  3341. public void upd_erp_supplierback()
  3342. {
  3343. if (UrlPostParmsCheck("ctid"))
  3344. {
  3345. string eid = GetPostString("ctid");
  3346. string reason = GetPostString("returnreason");
  3347. CeErpTradeCell entity = null;
  3348. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3349. if (entity != null)
  3350. {
  3351. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3352. {
  3353. string key = "return_order_" + entity.SupplierId;
  3354. List<string> list = new List<string>();
  3355. if (RedisHelper.HasKey(key))
  3356. {
  3357. object data = RedisHelper.StringGet(key);
  3358. list = Convert.ToString(data).Split(',').ToList();
  3359. }
  3360. list.Add(eid);
  3361. RedisHelper.StringSet(key, string.Join(",", list));
  3362. }
  3363. entity.IsVerifyToSupplier = false;
  3364. entity.IsReturn = 1;
  3365. entity.ReturnTime = DateTime.Now;
  3366. entity.ReturnReason = reason;
  3367. if (entity.OrderState == 6)
  3368. {
  3369. entity.OrderState = 5;
  3370. }
  3371. entity.Update();
  3372. CeErpSukuraData.createInfo(entity.ctid, 5);
  3373. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3374. returnSuccessMsg("操作成功!");
  3375. return;
  3376. }
  3377. returnErrorMsg("找不到订单记录");
  3378. }
  3379. }
  3380. public void upd_erp_toaftersaleorder()
  3381. {
  3382. if (UrlPostParmsCheck("ctid"))
  3383. {
  3384. string eid = GetPostString("ctid");
  3385. string reason = GetPostString("returnreason");
  3386. CeErpTradeCell entity = null;
  3387. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3388. if (entity != null)
  3389. {
  3390. if (entity.isAfterSaleOrder != 1)
  3391. {
  3392. returnErrorMsg("带S的售后单才能打回给售后");
  3393. return;
  3394. }
  3395. if (entity.OrderState >= 5)
  3396. {
  3397. returnErrorMsg("已经设计完成了不能打回给售后");
  3398. return;
  3399. }
  3400. entity.OrderState = 0;
  3401. entity.IsReturn = 3;
  3402. entity.ReturnTime = DateTime.Now;
  3403. entity.ReturnReason = reason;
  3404. entity.Update();
  3405. CeErpSukuraData.createInfo(entity.ctid, 5);
  3406. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3407. returnSuccessMsg("操作成功!");
  3408. return;
  3409. }
  3410. returnErrorMsg("找不到订单记录");
  3411. }
  3412. }
  3413. public void upd_erp_aftersaletodesign()
  3414. {
  3415. if (UrlPostParmsCheck("ctid"))
  3416. {
  3417. string eid = GetPostString("ctid");
  3418. CeErpTradeCell entity = null;
  3419. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3420. if (entity != null)
  3421. {
  3422. entity.OrderState = 3;
  3423. entity.IsReturn = 0;
  3424. entity.Update();
  3425. CeErpSukuraData.createInfo(entity.ctid, 5);
  3426. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3427. returnSuccessMsg("操作成功!");
  3428. return;
  3429. }
  3430. returnErrorMsg("找不到订单记录");
  3431. }
  3432. }
  3433. public void assign_erp_supplier()
  3434. {
  3435. if (UrlPostParmsCheck("ctid"))
  3436. {
  3437. string eids = GetPostString("ctid");
  3438. int sid = GetPostInt("SupplierName");
  3439. string fromTag = GetPostString("tag");
  3440. string[] eidList = eids.Split(',');
  3441. if (eidList.Length <= 0)
  3442. {
  3443. returnErrorMsg("指派不能为空");
  3444. return;
  3445. }
  3446. string errMsg = "";
  3447. string suname = commonHelper.getSupplierNameById(sid);
  3448. foreach (string ctid in eidList)
  3449. {
  3450. CeErpTradeCell entity = null;
  3451. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3452. if (entity != null)
  3453. {
  3454. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3455. {
  3456. errMsg += (ctid + "指派失败!!!");
  3457. continue;
  3458. }
  3459. entity.SupplierId = sid;
  3460. entity.Update();
  3461. commonHelper.UpdateRelationOrder(entity.ctid);
  3462. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3463. if (entity.OrderState >= 6)
  3464. {
  3465. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3466. //{
  3467. // string msl = entity.MakeSupplier;
  3468. // string[] mslist = msl.Split(',');
  3469. // 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);
  3470. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3471. //}
  3472. //else
  3473. //{
  3474. StringBuilder sql = new StringBuilder();
  3475. 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);
  3476. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3477. //}
  3478. }
  3479. }
  3480. else
  3481. {
  3482. continue;
  3483. }
  3484. }
  3485. if (errMsg.Length > 0)
  3486. {
  3487. returnErrorMsg(errMsg);
  3488. return;
  3489. }
  3490. returnSuccessMsg("操作成功!");
  3491. return;
  3492. }
  3493. }
  3494. public void assign_erp_makesupplier()
  3495. {
  3496. if (UrlPostParmsCheck("ctid"))
  3497. {
  3498. string eids = GetPostString("ctid");
  3499. string sname = GetPostString("SupplierName");
  3500. string[] eidList = eids.Split(',');
  3501. if (eidList.Length <= 0)
  3502. {
  3503. returnErrorMsg("指派不能为空");
  3504. return;
  3505. }
  3506. List<string> tLst = new List<string>();
  3507. foreach (string ctid in eidList)
  3508. {
  3509. CeErpTradeCell entity = null;
  3510. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3511. if (entity != null)
  3512. {
  3513. entity.MakeSupplier = sname;
  3514. entity.Update();
  3515. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3516. tLst.Add("'" + ctid + "'");
  3517. }
  3518. else
  3519. {
  3520. continue;
  3521. }
  3522. }
  3523. string ctids = string.Join(",", tLst.ToArray());
  3524. StringBuilder sql2 = new StringBuilder();
  3525. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3526. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3527. returnSuccessMsg("操作成功!");
  3528. return;
  3529. }
  3530. }
  3531. public void ins_erp_returnreason()
  3532. {
  3533. if (UrlPostParmsCheck("ctid"))
  3534. {
  3535. string eid = GetPostString("ctid");
  3536. CeErpTradeCell entity = null;
  3537. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3538. string userpost = CurrentUser.UserPost.Post.Code;
  3539. if (entity != null)
  3540. {
  3541. bool isPlace = false;
  3542. if (entity.OrderState > 6)
  3543. {
  3544. returnErrorMsg("已发货无法打回!");
  3545. return;
  3546. }
  3547. if (entity.OrderState == 6)
  3548. {
  3549. isPlace = true;
  3550. }
  3551. bool isNeedUpdateCell2 = false;
  3552. if (entity.OrderState >= 6)
  3553. {
  3554. isNeedUpdateCell2 = true;
  3555. }
  3556. int returnTag = 2;
  3557. if (userpost == "Supplier")
  3558. {
  3559. returnTag = 1;
  3560. }
  3561. int toType = GetPostInt("totype");
  3562. string fromType = "3";
  3563. if (entity.OrderState < 5)
  3564. {
  3565. fromType = "3";
  3566. }
  3567. else
  3568. {
  3569. fromType = "4";
  3570. }
  3571. if (entity.IsXianHuo == 0)
  3572. {
  3573. if (returnTag == 2)
  3574. {
  3575. if (toType == 1)
  3576. {
  3577. entity.OrderState = 0;
  3578. entity.ReturnUserType = 1;
  3579. string clearman = GetPostString("clearman");
  3580. if (!string.IsNullOrEmpty(clearman))
  3581. {
  3582. entity.DesignUserId = 0;
  3583. }
  3584. }
  3585. else
  3586. {
  3587. entity.OrderState = 3;
  3588. entity.ReturnUserType = 2;
  3589. }
  3590. entity.IsReadTag = 1;
  3591. }
  3592. else if (returnTag == 1)
  3593. {
  3594. entity.OrderState = 5;
  3595. }
  3596. entity.IsVerifyToSupplier = false;
  3597. }
  3598. if (entity.IsXianHuo == 1)
  3599. {
  3600. entity.OrderState = 5;
  3601. }
  3602. entity.UnusualTag = 0;
  3603. entity.UnusualTime = null;
  3604. entity.UnusualCon = "";
  3605. entity.IsReturn = returnTag;
  3606. entity.ReturnTime = DateTime.Now;
  3607. entity.ReturnReason = GetPostString("returnreason");
  3608. entity.Update();
  3609. if (entity.OrderState == 3)
  3610. {
  3611. ApiVo apiVo = new ApiVo();
  3612. apiVo.orderNumber = entity.ctid;
  3613. apiVo.actionName = "rebutDesign";
  3614. apiVo.orderRemarks = entity.ReturnReason;
  3615. designHelper.API_WorkCore(apiVo);//rebutDesign
  3616. }
  3617. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3618. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3619. {
  3620. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3621. }
  3622. CeErpSukuraData.createInfo(entity.ctid, 5);
  3623. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3624. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3625. if (isPlace)
  3626. {
  3627. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3628. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3629. if (dth != null && dth.Rows.Count > 0)
  3630. {
  3631. dataSendOrderBean dataSendOrderBean = null;
  3632. foreach (DataRow item in dth.Rows)
  3633. {
  3634. try
  3635. {
  3636. dataSendOrderBean = new dataSendOrderBean();
  3637. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3638. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3639. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3640. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3641. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3642. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3643. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3644. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3645. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3646. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3647. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3648. dataSendOrderBean.Radio1723534706288 = "打回";
  3649. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3650. if (result != null)
  3651. {
  3652. if ("0".Equals(result.errcode))
  3653. {
  3654. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3655. }
  3656. else
  3657. {
  3658. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3659. }
  3660. }
  3661. }
  3662. catch (Exception ex)
  3663. {
  3664. }
  3665. }
  3666. }
  3667. }
  3668. if (isNeedUpdateCell2)
  3669. {
  3670. if (entity.MakeSupplier.IndexOf(",") != -1)
  3671. {
  3672. StringBuilder sql2 = new StringBuilder();
  3673. 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);
  3674. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3675. }
  3676. else
  3677. {
  3678. StringBuilder sql2 = new StringBuilder();
  3679. 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);
  3680. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3681. }
  3682. }
  3683. returnSuccessMsg("操作成功!");
  3684. return;
  3685. }
  3686. returnErrorMsg("找不到订单记录");
  3687. }
  3688. }
  3689. public void cyt_erp_returnreason()
  3690. {
  3691. if (UrlPostParmsCheck("ctid"))
  3692. {
  3693. string eid = GetPostString("ctid");
  3694. CeErpTradeCell entity = null;
  3695. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3696. string userpost = CurrentUser.UserPost.Post.Code;
  3697. if (entity != null)
  3698. {
  3699. if (entity.OrderState > 6)
  3700. {
  3701. returnErrorMsg("已发货无法打回!");
  3702. return;
  3703. }
  3704. JObject jsonObject = new JObject
  3705. {
  3706. { "Userid", "77886" },
  3707. { "Pwd", "lt666888" },
  3708. { "LTOrderId",eid }
  3709. };
  3710. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3711. JObject jsonObjects = JObject.Parse(response);
  3712. string msg = (string)jsonObjects["msg"];
  3713. if (msg != "取消成功")
  3714. {
  3715. returnErrorMsg(msg);
  3716. return;
  3717. }
  3718. bool isNeedUpdateCell2 = false;
  3719. if (entity.OrderState >= 6)
  3720. {
  3721. isNeedUpdateCell2 = true;
  3722. }
  3723. int returnTag = 2;
  3724. if (userpost == "Supplier")
  3725. {
  3726. returnTag = 1;
  3727. }
  3728. if (entity.IsXianHuo == 0)
  3729. {
  3730. if (returnTag == 2)
  3731. {
  3732. int toType = GetPostInt("totype");
  3733. if (toType == 1)
  3734. {
  3735. entity.OrderState = 0;
  3736. entity.ReturnUserType = 1;
  3737. }
  3738. else
  3739. {
  3740. entity.OrderState = 4;
  3741. entity.ReturnUserType = 2;
  3742. }
  3743. entity.IsReadTag = 1;
  3744. }
  3745. else if (returnTag == 1)
  3746. {
  3747. entity.OrderState = 5;
  3748. }
  3749. entity.IsVerifyToSupplier = false;
  3750. }
  3751. entity.UnusualTag = 0;
  3752. entity.UnusualTime = null;
  3753. entity.UnusualCon = "";
  3754. entity.IsReturn = returnTag;
  3755. entity.ReturnTime = DateTime.Now;
  3756. entity.ReturnReason = GetPostString("returnreason");
  3757. entity.Update();
  3758. if (entity.OrderState == 4)
  3759. {
  3760. ApiVo apiVo = new ApiVo();
  3761. apiVo.orderNumber = entity.ctid;
  3762. apiVo.actionName = "rebutDesign";
  3763. apiVo.orderRemarks = entity.ReturnReason;
  3764. designHelper.API_WorkCore(apiVo);//rebutDesign
  3765. }
  3766. CeErpSukuraData.createInfo(entity.ctid, 5);
  3767. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3768. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3769. if (isNeedUpdateCell2)
  3770. {
  3771. if (entity.MakeSupplier.IndexOf(",") != -1)
  3772. {
  3773. StringBuilder sql2 = new StringBuilder();
  3774. 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);
  3775. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3776. }
  3777. else
  3778. {
  3779. StringBuilder sql2 = new StringBuilder();
  3780. 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);
  3781. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3782. }
  3783. }
  3784. returnSuccessMsg("操作成功!");
  3785. return;
  3786. }
  3787. returnErrorMsg("找不到订单记录");
  3788. }
  3789. }
  3790. public void upd_erp_xianhuoreturntag()
  3791. {
  3792. if (UrlPostParmsCheck("ctid"))
  3793. {
  3794. string eids = GetPostString("ctid");
  3795. string[] ctids = eids.Split(',');
  3796. foreach (string ctid in ctids)
  3797. {
  3798. CeErpTradeCell entity = null;
  3799. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3800. if (entity != null)
  3801. {
  3802. entity.IsReturn = 0;
  3803. entity.Update();
  3804. CeErpSukuraData.createInfo(entity.ctid, 5);
  3805. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3806. }
  3807. }
  3808. returnSuccessMsg("操作成功!");
  3809. return;
  3810. }
  3811. }
  3812. public void get_erp_waitdeliverylist()
  3813. {
  3814. DataStruct dStruct = GetPostStruct();
  3815. List<string> lw = new List<string>();
  3816. string tid = GetPostString("ctid");
  3817. if (tid.Length > 0)
  3818. {
  3819. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3820. if (tid.Length > 5)
  3821. {
  3822. List<string> tids = getTidByCtidLike(tid);
  3823. if (tids.Count > 0 && tids.Count < 10)
  3824. {
  3825. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3826. }
  3827. }
  3828. lw.Add(tid_sql);
  3829. }
  3830. string shopname = GetPostString("shopname");
  3831. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3832. string buyernick = GetPostString("buyer_nick");
  3833. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3834. //if (tid.Length == 0 && buyernick.Length == 0)
  3835. //{
  3836. // lw.Add(string.Format("IsRefund<={0}", 1));
  3837. //}
  3838. string customer = GetPostString("customer");
  3839. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3840. string design = GetPostString("design");
  3841. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3842. string orderState = GetPostString("orderState");
  3843. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3844. string address = GetPostString("address");
  3845. 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));
  3846. string sellermemo = GetPostString("seller_memo");
  3847. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3848. string supplier = GetPostString("supplier");
  3849. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3850. string OrderArea = GetPostString("order_area");
  3851. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3852. string placedate1 = GetPostString("placedate1");
  3853. string placedate2 = GetPostString("placedate2");
  3854. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3855. if (fdw.Length > 0) lw.Add(fdw);
  3856. string price1 = GetPostString("price1");
  3857. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3858. string price2 = GetPostString("price2");
  3859. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3860. string unusualCon = GetPostString("unusualcon");
  3861. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3862. string otherMemo = GetPostString("otherMemo");
  3863. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3864. string posTag = CurrentUser.UserPost.Post.Code;
  3865. if (posTag == "Supplier")
  3866. {
  3867. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3868. }
  3869. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3870. lw.Add(string.Format("type != 'PDD' "));
  3871. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3872. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3873. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3874. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3875. writeGridDataTableJson(dStruct.TotalCount, dt);
  3876. }
  3877. public void get_erp_changedeliverylist()
  3878. {
  3879. DataStruct dStruct = GetPostStruct();
  3880. List<string> lw = new List<string>();
  3881. string tid = GetPostString("ctid");
  3882. if (tid.Length > 0)
  3883. {
  3884. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3885. if (tid.Length > 5)
  3886. {
  3887. List<string> tids = getTidByCtidLike(tid);
  3888. if (tids.Count > 0 && tids.Count < 10)
  3889. {
  3890. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3891. }
  3892. }
  3893. lw.Add(tid_sql);
  3894. }
  3895. string shopname = GetPostString("shopname");
  3896. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3897. string buyernick = GetPostString("buyer_nick");
  3898. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3899. //if (tid.Length == 0 && buyernick.Length == 0)
  3900. //{
  3901. // lw.Add(string.Format("IsRefund<={0}", 1));
  3902. //}
  3903. string customer = GetPostString("customer");
  3904. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3905. string design = GetPostString("design");
  3906. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3907. string orderState = GetPostString("orderState");
  3908. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3909. string address = GetPostString("address");
  3910. 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));
  3911. string sellermemo = GetPostString("seller_memo");
  3912. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3913. string supplier = GetPostString("supplier");
  3914. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3915. string OrderArea = GetPostString("order_area");
  3916. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3917. string placedate1 = GetPostString("placedate1");
  3918. string placedate2 = GetPostString("placedate2");
  3919. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3920. if (fdw.Length > 0) lw.Add(fdw);
  3921. string price1 = GetPostString("price1");
  3922. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3923. string price2 = GetPostString("price2");
  3924. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3925. string unusualCon = GetPostString("unusualcon");
  3926. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3927. string otherMemo = GetPostString("otherMemo");
  3928. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3929. string posTag = CurrentUser.UserPost.Post.Code;
  3930. if (posTag == "Supplier")
  3931. {
  3932. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3933. }
  3934. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  3935. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3936. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3937. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3938. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3939. /*if (tid.Length > 0)
  3940. {
  3941. List<string> tids = new List<string>();
  3942. if (dt != null && dt.Rows.Count > 0)
  3943. {
  3944. foreach (DataRow item in dt.Rows)
  3945. {
  3946. tids.Add("'" + item["tid"] + "'");
  3947. }
  3948. }
  3949. if (tids.Count > 0)
  3950. {
  3951. lw.RemoveAt(0);
  3952. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3953. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3954. dt = WebCache.GetData("view_erptradecell", dStruct);
  3955. }
  3956. }*/
  3957. writeGridDataTableJson(dStruct.TotalCount, dt);
  3958. }
  3959. public void get_erp_pddderiving()
  3960. {
  3961. DataStruct dStruct = GetPostStruct();
  3962. List<string> lw = new List<string>();
  3963. string tid = GetPostString("ctid");
  3964. if (tid.Length > 0)
  3965. {
  3966. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3967. if (tid.Length > 5)
  3968. {
  3969. List<string> tids = getTidByCtidLike(tid);
  3970. if (tids.Count > 0 && tids.Count < 10)
  3971. {
  3972. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3973. }
  3974. }
  3975. lw.Add(tid_sql);
  3976. }
  3977. string shopname = GetPostString("shopname");
  3978. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3979. string buyernick = GetPostString("buyer_nick");
  3980. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3981. //if (tid.Length == 0 && buyernick.Length == 0)
  3982. //{
  3983. // lw.Add(string.Format("IsRefund<={0}", 1));
  3984. //}
  3985. string customer = GetPostString("customer");
  3986. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3987. string design = GetPostString("design");
  3988. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3989. string orderState = GetPostString("orderState");
  3990. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3991. string address = GetPostString("address");
  3992. 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));
  3993. string sellermemo = GetPostString("seller_memo");
  3994. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3995. string supplier = GetPostString("supplier");
  3996. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3997. string OrderArea = GetPostString("order_area");
  3998. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3999. string placedate1 = GetPostString("placedate1");
  4000. string placedate2 = GetPostString("placedate2");
  4001. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4002. if (fdw.Length > 0) lw.Add(fdw);
  4003. string price1 = GetPostString("price1");
  4004. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4005. string price2 = GetPostString("price2");
  4006. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4007. string unusualCon = GetPostString("unusualcon");
  4008. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4009. string posTag = CurrentUser.UserPost.Post.Code;
  4010. if (posTag == "Supplier")
  4011. {
  4012. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4013. }
  4014. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4015. lw.Add(string.Format("type = 'PDD' "));
  4016. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4017. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4018. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4019. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4020. /*if (tid.Length > 0)
  4021. {
  4022. List<string> tids = new List<string>();
  4023. if (dt != null && dt.Rows.Count > 0)
  4024. {
  4025. foreach (DataRow item in dt.Rows)
  4026. {
  4027. tids.Add("'" + item["tid"] + "'");
  4028. }
  4029. }
  4030. if (tids.Count > 0)
  4031. {
  4032. lw.RemoveAt(0);
  4033. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4034. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4035. dt = WebCache.GetData("view_erptradecell", dStruct);
  4036. }
  4037. }*/
  4038. writeGridDataTableJson(dStruct.TotalCount, dt);
  4039. }
  4040. public void get_erp_jdderiving()
  4041. {
  4042. DataStruct dStruct = GetPostStruct();
  4043. List<string> lw = new List<string>();
  4044. string tid = GetPostString("ctid");
  4045. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4046. string shopname = GetPostString("shopname");
  4047. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4048. string buyernick = GetPostString("buyer_nick");
  4049. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4050. //if (tid.Length == 0 && buyernick.Length == 0)
  4051. //{
  4052. // lw.Add(string.Format("IsRefund<={0}", 1));
  4053. //}
  4054. string customer = GetPostString("customer");
  4055. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4056. string design = GetPostString("design");
  4057. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4058. string orderState = GetPostString("orderState");
  4059. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4060. string address = GetPostString("address");
  4061. 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));
  4062. string sellermemo = GetPostString("seller_memo");
  4063. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4064. string supplier = GetPostString("supplier");
  4065. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4066. string OrderArea = GetPostString("order_area");
  4067. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4068. string placedate1 = GetPostString("placedate1");
  4069. string placedate2 = GetPostString("placedate2");
  4070. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4071. if (fdw.Length > 0) lw.Add(fdw);
  4072. string price1 = GetPostString("price1");
  4073. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4074. string price2 = GetPostString("price2");
  4075. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4076. string unusualCon = GetPostString("unusualcon");
  4077. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4078. string posTag = CurrentUser.UserPost.Post.Code;
  4079. if (posTag == "Supplier")
  4080. {
  4081. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4082. }
  4083. lw.Add(string.Format("OrderState = 6 "));
  4084. lw.Add(string.Format("type = 'JD' "));
  4085. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4086. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4087. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4088. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4089. writeGridDataTableJson(dStruct.TotalCount, dt);
  4090. }
  4091. public void get_erp_demoorderlist()
  4092. {
  4093. DataStruct dStruct = GetPostStruct();
  4094. List<string> lw = new List<string>();
  4095. string tid = GetPostString("ctid");
  4096. if (tid.Length > 0)
  4097. {
  4098. string select_tid = getTidByCtid(tid);
  4099. lw.Add(string.Format("tid='{0}'", select_tid));
  4100. }
  4101. string shopname = GetPostString("shopname");
  4102. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4103. string buyernick = GetPostString("buyer_nick");
  4104. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4105. string customer = GetPostString("customer");
  4106. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4107. string design = GetPostString("design");
  4108. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4109. string orderState = GetPostString("orderState");
  4110. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4111. string address = GetPostString("address");
  4112. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4113. string sellermemo = GetPostString("seller_memo");
  4114. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4115. string supplier = GetPostString("supplier");
  4116. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4117. string OrderArea = GetPostString("order_area");
  4118. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4119. string date1 = GetPostString("date1");
  4120. string date2 = GetPostString("date2");
  4121. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4122. if (dw.Length > 0) lw.Add(dw);
  4123. string price1 = GetPostString("price1");
  4124. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4125. string price2 = GetPostString("price2");
  4126. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4127. string posTag = CurrentUser.UserPost.Post.Code;
  4128. if (posTag == "Supplier")
  4129. {
  4130. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4131. }
  4132. //lw.Add(string.Format("OrderState = 6 "));
  4133. lw.Add(string.Format("IsSample={0}", 3));
  4134. lw.Add(string.Format("IsRefund<={0}", 1));
  4135. dStruct.Order = "pay_time desc";
  4136. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4137. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4138. writeGridDataTableJson(dStruct.TotalCount, dt);
  4139. }
  4140. public void save_erp_checkmemo()
  4141. {
  4142. if (UrlPostParmsCheck("ctid"))
  4143. {
  4144. string ctid = GetPostString("ctid");
  4145. CeErpTradeCell entity = null;
  4146. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4147. if (entity != null)
  4148. {
  4149. entity.CheckMemo = GetPostString("CheckMemo");
  4150. entity.Update();
  4151. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4152. if (trade != null)
  4153. {
  4154. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4155. }
  4156. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4157. returnSuccessMsg("保存成功!");
  4158. return;
  4159. }
  4160. returnErrorMsg("找不到记录");
  4161. }
  4162. }
  4163. public void get_erp_returnlist()
  4164. {
  4165. DataStruct dStruct = GetPostStruct();
  4166. List<string> lw = new List<string>();
  4167. string tid = GetPostString("ctid");
  4168. if (tid.Length > 0)
  4169. {
  4170. string select_tid = getTidByCtid(tid);
  4171. lw.Add(string.Format("tid='{0}'", select_tid));
  4172. }
  4173. string shopname = GetPostString("shopname");
  4174. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4175. string buyernick = GetPostString("buyer_nick");
  4176. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4177. string customer = GetPostString("customer");
  4178. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4179. string design = GetPostString("design");
  4180. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4181. string orderState = GetPostString("orderState");
  4182. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4183. string address = GetPostString("address");
  4184. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4185. string sellermemo = GetPostString("seller_memo");
  4186. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4187. string supplier = GetPostString("supplier");
  4188. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4189. string date1 = GetPostString("date1");
  4190. string date2 = GetPostString("date2");
  4191. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4192. if (dw.Length > 0) lw.Add(dw);
  4193. string bdate1 = GetPostString("backdate1");
  4194. string bdate2 = GetPostString("backdate2");
  4195. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4196. if (dw_back.Length > 0) lw.Add(dw_back);
  4197. string price1 = GetPostString("price1");
  4198. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4199. string price2 = GetPostString("price2");
  4200. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4201. lw.Add(string.Format("IsReturn>0"));
  4202. lw.Add(string.Format("IsXianHuo=0"));
  4203. lw.Add(string.Format("IsReturn!=3"));
  4204. string backtype = GetPostString("backtype");
  4205. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4206. dStruct.Order = "FinishDesignTime desc";
  4207. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4208. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4209. writeGridDataTableJson(dStruct.TotalCount, dt);
  4210. }
  4211. public void get_erp_today_sumreturn()
  4212. {
  4213. DataStruct dStruct = GetPostStruct();
  4214. List<string> lw = new List<string>();
  4215. string bdate1 = GetPostString("returnTimeS");
  4216. string bdate2 = GetPostString("returnTimeE");
  4217. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4218. if (dw_back.Length > 0) lw.Add(dw_back);
  4219. lw.Add(string.Format("IsReturn=0"));
  4220. lw.Add(string.Format("IsXianHuo=0"));
  4221. string mainWhere = string.Join(" and ", lw.ToArray());
  4222. string sql = "";
  4223. if (dw_back.Length > 0)
  4224. {
  4225. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4226. }
  4227. else
  4228. {
  4229. 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 + "'";
  4230. }
  4231. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4232. decimal total = 0, today_finish = 0;
  4233. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4234. {
  4235. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4236. }
  4237. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4238. {
  4239. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4240. }
  4241. var res = new
  4242. {
  4243. data = total,
  4244. data1 = today_finish,
  4245. };
  4246. string ro_jsond = JsonConvert.SerializeObject(res);
  4247. returnSuccess(ro_jsond);
  4248. return;
  4249. }
  4250. public void get_erp_allreturnlist()
  4251. {
  4252. DataStruct dStruct = GetPostStruct();
  4253. List<string> lw = new List<string>();
  4254. string tid = GetPostString("ctid");
  4255. if (tid.Length > 0)
  4256. {
  4257. string select_tid = getTidByCtid(tid);
  4258. lw.Add(string.Format("tid='{0}'", select_tid));
  4259. }
  4260. string shopname = GetPostString("shopname");
  4261. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4262. string buyernick = GetPostString("buyer_nick");
  4263. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4264. string customer = GetPostString("customer");
  4265. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4266. string design = GetPostString("design");
  4267. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4268. string orderState = GetPostString("orderState");
  4269. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4270. string address = GetPostString("address");
  4271. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4272. string sellermemo = GetPostString("seller_memo");
  4273. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4274. string supplier = GetPostString("supplier");
  4275. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4276. string date1 = GetPostString("date1");
  4277. string date2 = GetPostString("date2");
  4278. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4279. if (dw.Length > 0) lw.Add(dw);
  4280. string bdate1 = GetPostString("backdate1");
  4281. string bdate2 = GetPostString("backdate2");
  4282. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4283. if (dw_back.Length > 0) lw.Add(dw_back);
  4284. string price1 = GetPostString("price1");
  4285. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4286. string price2 = GetPostString("price2");
  4287. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4288. string backreason = GetPostString("backreason");
  4289. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4290. lw.Add(string.Format("IsXianHuo=0"));
  4291. lw.Add(string.Format("ReturnTime != ''"));
  4292. string backtype = GetPostString("backtype");
  4293. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4294. dStruct.Order = "FinishDesignTime desc";
  4295. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4296. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4297. writeGridDataTableJson(dStruct.TotalCount, dt);
  4298. }
  4299. public void get_erp_aftersalereturnlist()
  4300. {
  4301. DataStruct dStruct = GetPostStruct();
  4302. List<string> lw = new List<string>();
  4303. string tid = GetPostString("ctid");
  4304. if (tid.Length > 0)
  4305. {
  4306. string select_tid = getTidByCtid(tid);
  4307. lw.Add(string.Format("tid='{0}'", select_tid));
  4308. }
  4309. string shopname = GetPostString("shopname");
  4310. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4311. string buyernick = GetPostString("buyer_nick");
  4312. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4313. string customer = GetPostString("customer");
  4314. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4315. string design = GetPostString("design");
  4316. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4317. string orderState = GetPostString("orderState");
  4318. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4319. string address = GetPostString("address");
  4320. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4321. string sellermemo = GetPostString("seller_memo");
  4322. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4323. string supplier = GetPostString("supplier");
  4324. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4325. string date1 = GetPostString("date1");
  4326. string date2 = GetPostString("date2");
  4327. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4328. if (dw.Length > 0) lw.Add(dw);
  4329. string bdate1 = GetPostString("backdate1");
  4330. string bdate2 = GetPostString("backdate2");
  4331. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4332. if (dw_back.Length > 0) lw.Add(dw_back);
  4333. string price1 = GetPostString("price1");
  4334. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4335. string price2 = GetPostString("price2");
  4336. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4337. lw.Add(string.Format("IsReturn=3"));
  4338. string backtype = GetPostString("backtype");
  4339. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4340. string backreason = GetPostString("backreason");
  4341. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4342. dStruct.Order = "ReturnTime desc";
  4343. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4344. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4345. writeGridDataTableJson(dStruct.TotalCount, dt);
  4346. }
  4347. public void get_erp_xianhuoreturnlist()
  4348. {
  4349. DataStruct dStruct = GetPostStruct();
  4350. List<string> lw = new List<string>();
  4351. string tid = GetPostString("ctid");
  4352. if (tid.Length > 0)
  4353. {
  4354. string select_tid = getTidByCtid(tid);
  4355. lw.Add(string.Format("tid='{0}'", select_tid));
  4356. }
  4357. string shopname = GetPostString("shopname");
  4358. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4359. string buyernick = GetPostString("buyer_nick");
  4360. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4361. string customer = GetPostString("customer");
  4362. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4363. string design = GetPostString("design");
  4364. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4365. string orderState = GetPostString("orderState");
  4366. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4367. string address = GetPostString("address");
  4368. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4369. string sellermemo = GetPostString("seller_memo");
  4370. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4371. string supplier = GetPostString("supplier");
  4372. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4373. string OrderArea = GetPostString("order_area");
  4374. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4375. string date1 = GetPostString("date1");
  4376. string date2 = GetPostString("date2");
  4377. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4378. if (dw.Length > 0) lw.Add(dw);
  4379. string price1 = GetPostString("price1");
  4380. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4381. string price2 = GetPostString("price2");
  4382. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4383. string posTag = CurrentUser.UserPost.Post.Code;
  4384. if (posTag == "Supplier")
  4385. {
  4386. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4387. }
  4388. lw.Add(string.Format("OrderState=6 "));
  4389. lw.Add(string.Format("IsXianHuo=1 "));
  4390. lw.Add(string.Format("IsReturn>0 "));
  4391. lw.Add(string.Format("IsReturn!=3"));
  4392. lw.Add(string.Format("IsRefund<={0}", 1));
  4393. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4394. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4395. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4396. writeGridDataTableJson(dStruct.TotalCount, dt);
  4397. }
  4398. public void set_erp_orderdelivery()
  4399. {
  4400. if (UrlPostParmsCheck("ctid"))
  4401. {
  4402. string eid = GetPostString("ctid");
  4403. CeErpTradeCell entity = null;
  4404. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4405. if (entity != null)
  4406. {
  4407. if (entity.OrderState >= 7)
  4408. {
  4409. returnErrorMsg("此单已发货,无需重复发货");
  4410. return;
  4411. }
  4412. if (entity.OrderState != 6)
  4413. {
  4414. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4415. return;
  4416. }
  4417. string shop = GetPostString("seller_nick");
  4418. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4419. string comName = GetPostString("comName");
  4420. string comCode = GetPostString("comCode");
  4421. string outSid = GetPostString("outSid");
  4422. string deliveryType = GetPostString("deliveryType");
  4423. string deliveryMemo = GetPostString("deliveryMemo");
  4424. outSid = outSid.Trim();
  4425. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4426. if (mainEn == null)
  4427. {
  4428. returnErrorMsg("找不到原始订单记录");
  4429. return;
  4430. }
  4431. bool isInitOrderDeliv = false;
  4432. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4433. {
  4434. isInitOrderDeliv = true;
  4435. }
  4436. string apires = "";
  4437. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4438. 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)
  4439. {
  4440. apires = "发货成功true";
  4441. }
  4442. else
  4443. {
  4444. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4445. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4446. }
  4447. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4448. {
  4449. entity.OrderState = 7;//发货后订单已发货
  4450. entity.OutSid = outSid;
  4451. entity.MemoOpt = 0;
  4452. entity.FinishDeliveryTime = DateTime.Now;
  4453. entity.Update();
  4454. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4455. commonHelper.UpdateRelationOrder(entity.ctid);
  4456. //还要插入快递信息到 快递信息表
  4457. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4458. exinfo.tid = eid;
  4459. exinfo.out_sid = outSid;
  4460. exinfo.company_code = comCode;
  4461. exinfo.company_name = comName;
  4462. exinfo.delivery_memo = deliveryMemo;
  4463. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4464. exinfo.deliveryType = deliveryType;
  4465. exinfo.Create();
  4466. returnSuccessMsg("发货操作成功!");
  4467. commonHelper.UpdateRelationOrder(entity.ctid);
  4468. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4469. CeErpSukuraData.createInfo(entity.ctid, 4);
  4470. if (entity.SupplierId == 64)
  4471. {
  4472. commonHelper.sendCytExpress(exinfo);
  4473. }
  4474. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4475. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4476. }
  4477. else
  4478. {
  4479. string errmsg = commonHelper.KeepChinese(apires);
  4480. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4481. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4482. }
  4483. return;
  4484. }
  4485. returnErrorMsg("找不到订单记录");
  4486. }
  4487. }
  4488. public void set_erp_multidelivery()
  4489. {
  4490. string eids = GetPostString("tids");
  4491. string[] eidList = eids.Split(',');
  4492. if (eidList.Length <= 0)
  4493. {
  4494. returnErrorMsg("发货不能为空");
  4495. return;
  4496. }
  4497. foreach (string ctid in eidList)
  4498. {
  4499. if (ctid.Length <= 0) continue;
  4500. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4501. if (expInfo != null)
  4502. {
  4503. StringBuilder sql = new StringBuilder();
  4504. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4505. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4506. if (dt.Rows.Count > 0)
  4507. {
  4508. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4509. {
  4510. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4511. expInfo.state = "异常";
  4512. expInfo.isMultiDelivery = 1;
  4513. expInfo.Update();
  4514. continue;
  4515. }
  4516. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4517. {
  4518. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4519. expInfo.state = "异常";
  4520. expInfo.Update();
  4521. continue;
  4522. }
  4523. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4524. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4525. bool isInitOrderDeliv = false;
  4526. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4527. {
  4528. isInitOrderDeliv = true;
  4529. expInfo.isMultiDelivery = 1;
  4530. }
  4531. if (ctid.IndexOf("N") != -1)
  4532. {
  4533. StringBuilder sqlbucha = new StringBuilder();
  4534. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4535. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4536. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4537. commonHelper.UpdateRelationOrder(ctid);
  4538. expInfo.delivery_memo = "发货成功";
  4539. expInfo.state = "发货成功";
  4540. expInfo.isMultiDelivery = 1;
  4541. expInfo.Update();
  4542. }
  4543. else
  4544. {
  4545. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4546. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4547. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4548. {
  4549. expInfo.delivery_memo = "发货成功";
  4550. expInfo.state = "发货成功";
  4551. expInfo.isMultiDelivery = 1;
  4552. expInfo.Update();
  4553. commonHelper.UpdateRelationOrder(ctid);
  4554. CeErpSukuraData.createInfo(ctid, 4);
  4555. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4556. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4557. }
  4558. else
  4559. {
  4560. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4561. expInfo.state = "异常";
  4562. expInfo.Update();
  4563. }
  4564. }
  4565. }
  4566. }
  4567. }
  4568. returnSuccessMsg("操作完成");
  4569. }
  4570. public void reset_erp_memoopt()
  4571. {
  4572. if (UrlPostParmsCheck("ctid"))
  4573. {
  4574. string eid = GetPostString("ctid");
  4575. CeErpTradeCell entity = null;
  4576. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4577. if (entity != null)
  4578. {
  4579. string stropt = "";
  4580. if (entity.MemoOpt == 1)
  4581. {
  4582. stropt = "“改稿”";
  4583. }
  4584. else if (entity.MemoOpt == 2)
  4585. {
  4586. stropt = "“定稿”";
  4587. }
  4588. else if (entity.MemoOpt == 3)
  4589. {
  4590. stropt = "“完成查货”";
  4591. CeErpSukuraData.createInfo(entity.ctid, 6);
  4592. }
  4593. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4594. entity.MemoOpt = 0;
  4595. entity.Update();
  4596. returnSuccessMsg("操作成功!");
  4597. return;
  4598. }
  4599. returnErrorMsg("找不到记录");
  4600. }
  4601. }
  4602. public void get_erp_deliveryunusual()
  4603. {
  4604. DataStruct dStruct = GetPostStruct();
  4605. List<string> lw = new List<string>();
  4606. string tid = GetPostString("ctid");
  4607. if (tid.Length > 0)
  4608. {
  4609. string select_tid = getTidByCtid(tid);
  4610. lw.Add(string.Format("tid='{0}'", select_tid));
  4611. }
  4612. string shopname = GetPostString("shopname");
  4613. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4614. string buyernick = GetPostString("buyer_nick");
  4615. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4616. string customer = GetPostString("customer");
  4617. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4618. string design = GetPostString("design");
  4619. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4620. string sellermemo = GetPostString("seller_memo");
  4621. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4622. string supplier = GetPostString("supplier");
  4623. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4624. string date1 = GetPostString("date1");
  4625. string date2 = GetPostString("date2");
  4626. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4627. if (dw.Length > 0) lw.Add(dw);
  4628. string placedate1 = GetPostString("placedate1");
  4629. string placedate2 = GetPostString("placedate2");
  4630. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4631. if (dw_place.Length > 0) lw.Add(dw_place);
  4632. string price1 = GetPostString("price1");
  4633. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4634. string price2 = GetPostString("price2");
  4635. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4636. string unusualCon = GetPostString("unusualcon");
  4637. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4638. string posTag = CurrentUser.UserPost.Post.Code;
  4639. if (posTag == "Supplier")
  4640. {
  4641. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4642. }
  4643. lw.Add(string.Format("OrderState = 6"));
  4644. lw.Add(string.Format("UnusualTag = 5"));
  4645. lw.Add(string.Format("IsRefund<={0}", 1));
  4646. dStruct.Order = "FinishPlaceTime desc";
  4647. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4648. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4649. writeGridDataTableJson(dStruct.TotalCount, dt);
  4650. }
  4651. public void get_erp_deliveryedlist()
  4652. {
  4653. DataStruct dStruct = GetPostStruct();
  4654. List<string> lw = new List<string>();
  4655. string tid = GetPostString("ctid");
  4656. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4657. string shopname = GetPostString("shopname");
  4658. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4659. string buyernick = GetPostString("buyer_nick");
  4660. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4661. string customer = GetPostString("customer");
  4662. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4663. string design = GetPostString("design");
  4664. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4665. string sellermemo = GetPostString("seller_memo");
  4666. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4667. string logistics = GetPostString("logistics");
  4668. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4669. string date1 = GetPostString("date1");
  4670. string date2 = GetPostString("date2");
  4671. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4672. //if (dw.Length > 0) lw.Add(dw);
  4673. string placedate1 = GetPostString("placedate1");
  4674. string placedate2 = GetPostString("placedate2");
  4675. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4676. if (fdw.Length > 0) lw.Add(fdw);
  4677. string devdate1 = GetPostString("deliverydate1");
  4678. string devdate2 = GetPostString("deliverydate2");
  4679. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4680. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4681. string price1 = GetPostString("price1");
  4682. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4683. string price2 = GetPostString("price2");
  4684. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4685. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4686. {
  4687. if (tid.Length > 0)
  4688. {
  4689. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4690. if (tid.Length > 5)
  4691. {
  4692. List<string> tids = getTidByCtidLike(tid);
  4693. if (tids.Count > 0 && tids.Count < 10)
  4694. {
  4695. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4696. }
  4697. }
  4698. lw.Add(tid_sql);
  4699. }
  4700. if (buyernick.Length > 0)
  4701. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4702. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4703. if (dw.Length > 0) lw.Add(dw);
  4704. }
  4705. else
  4706. {
  4707. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4708. }
  4709. string posTag = CurrentUser.UserPost.Post.Code;
  4710. if (posTag == "Supplier")
  4711. {
  4712. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4713. }
  4714. else
  4715. {
  4716. string supplier = GetPostString("supplier");
  4717. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4718. }
  4719. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4720. lw.Add(string.Format("IsRefund!={0}", 2));
  4721. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4722. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4723. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4724. /*if (tid.Length > 0)
  4725. {
  4726. List<string> tids = new List<string>();
  4727. if (dt != null && dt.Rows.Count > 0)
  4728. {
  4729. foreach (DataRow item in dt.Rows)
  4730. {
  4731. tids.Add("'" + item["tid"] + "'");
  4732. }
  4733. }
  4734. if (tids.Count > 0)
  4735. {
  4736. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4737. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4738. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4739. dt = WebCache.GetData("view_erptradecell", dStruct);
  4740. }
  4741. }*/
  4742. if (dt != null)
  4743. {
  4744. foreach (DataRow dr in dt.Rows)
  4745. {
  4746. 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();
  4747. }
  4748. }
  4749. writeGridDataTableJson(dStruct.TotalCount, dt);
  4750. }
  4751. public void get_erp_pdddeliveryed()
  4752. {
  4753. DataStruct dStruct = GetPostStruct();
  4754. List<string> lw = new List<string>();
  4755. string tid = GetPostString("ctid");
  4756. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4757. string shopname = GetPostString("shopname");
  4758. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4759. string buyernick = GetPostString("buyer_nick");
  4760. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4761. string customer = GetPostString("customer");
  4762. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4763. string design = GetPostString("design");
  4764. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4765. string sellermemo = GetPostString("seller_memo");
  4766. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4767. string logistics = GetPostString("logistics");
  4768. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4769. string date1 = GetPostString("date1");
  4770. string date2 = GetPostString("date2");
  4771. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4772. //if (dw.Length > 0) lw.Add(dw);
  4773. string placedate1 = GetPostString("placedate1");
  4774. string placedate2 = GetPostString("placedate2");
  4775. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4776. if (fdw.Length > 0) lw.Add(fdw);
  4777. string devdate1 = GetPostString("deliverydate1");
  4778. string devdate2 = GetPostString("deliverydate2");
  4779. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4780. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4781. string price1 = GetPostString("price1");
  4782. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4783. string price2 = GetPostString("price2");
  4784. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4785. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4786. {
  4787. if (tid.Length > 0)
  4788. {
  4789. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4790. if (tid.Length > 5)
  4791. {
  4792. List<string> tids = getTidByCtidLike(tid);
  4793. if (tids.Count > 0 && tids.Count < 10)
  4794. {
  4795. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4796. }
  4797. }
  4798. lw.Add(tid_sql);
  4799. }
  4800. if (buyernick.Length > 0)
  4801. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4802. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4803. if (dw.Length > 0) lw.Add(dw);
  4804. }
  4805. else
  4806. {
  4807. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4808. }
  4809. string posTag = CurrentUser.UserPost.Post.Code;
  4810. if (posTag == "Supplier")
  4811. {
  4812. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4813. }
  4814. else
  4815. {
  4816. string supplier = GetPostString("supplier");
  4817. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4818. }
  4819. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4820. lw.Add(string.Format("type = 'PDD' "));
  4821. lw.Add(string.Format("IsRefund!={0}", 2));
  4822. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4823. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4824. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4825. /* if (tid.Length > 0)
  4826. {
  4827. List<string> tids = new List<string>();
  4828. if (dt != null && dt.Rows.Count > 0)
  4829. {
  4830. foreach (DataRow item in dt.Rows)
  4831. {
  4832. tids.Add("'" + item["tid"] + "'");
  4833. }
  4834. }
  4835. if (tids.Count > 0)
  4836. {
  4837. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4838. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4839. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4840. dt = WebCache.GetData("view_erptradecell", dStruct);
  4841. }
  4842. }*/
  4843. foreach (DataRow dr in dt.Rows)
  4844. {
  4845. 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();
  4846. }
  4847. writeGridDataTableJson(dStruct.TotalCount, dt);
  4848. }
  4849. public void get_erp_jddeliveryed()
  4850. {
  4851. DataStruct dStruct = GetPostStruct();
  4852. List<string> lw = new List<string>();
  4853. string tid = GetPostString("ctid");
  4854. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4855. string shopname = GetPostString("shopname");
  4856. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4857. string buyernick = GetPostString("buyer_nick");
  4858. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4859. string customer = GetPostString("customer");
  4860. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4861. string design = GetPostString("design");
  4862. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4863. string sellermemo = GetPostString("seller_memo");
  4864. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4865. string date1 = GetPostString("date1");
  4866. string date2 = GetPostString("date2");
  4867. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4868. //if (dw.Length > 0) lw.Add(dw);
  4869. string placedate1 = GetPostString("placedate1");
  4870. string placedate2 = GetPostString("placedate2");
  4871. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4872. if (fdw.Length > 0) lw.Add(fdw);
  4873. string devdate1 = GetPostString("deliverydate1");
  4874. string devdate2 = GetPostString("deliverydate2");
  4875. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4876. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4877. string price1 = GetPostString("price1");
  4878. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4879. string price2 = GetPostString("price2");
  4880. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4881. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4882. {
  4883. if (tid.Length > 0)
  4884. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4885. if (buyernick.Length > 0)
  4886. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4887. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4888. if (dw.Length > 0) lw.Add(dw);
  4889. }
  4890. else
  4891. {
  4892. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4893. }
  4894. string posTag = CurrentUser.UserPost.Post.Code;
  4895. if (posTag == "Supplier")
  4896. {
  4897. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4898. }
  4899. else
  4900. {
  4901. string supplier = GetPostString("supplier");
  4902. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4903. }
  4904. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4905. lw.Add(string.Format("type = 'JD' "));
  4906. lw.Add(string.Format("IsRefund!={0}", 2));
  4907. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4908. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4909. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4910. foreach (DataRow dr in dt.Rows)
  4911. {
  4912. 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();
  4913. }
  4914. writeGridDataTableJson(dStruct.TotalCount, dt);
  4915. }
  4916. public void get_erp_allplacelist()
  4917. {
  4918. DataStruct dStruct = GetPostStruct();
  4919. List<string> lw = new List<string>();
  4920. string tid = GetPostString("ctid");
  4921. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4922. string shopname = GetPostString("shopname");
  4923. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4924. string buyernick = GetPostString("buyer_nick");
  4925. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4926. string customer = GetPostString("customer");
  4927. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4928. string design = GetPostString("design");
  4929. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4930. string sellermemo = GetPostString("seller_memo");
  4931. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4932. string supplier = GetPostString("supplier");
  4933. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4934. string date1 = GetPostString("date1");
  4935. string date2 = GetPostString("date2");
  4936. string pldate1 = GetPostString("placedate1");
  4937. string pldate2 = GetPostString("placedate2");
  4938. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4939. //if (dw.Length > 0) lw.Add(dw);
  4940. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4941. {
  4942. if (tid.Length > 0)
  4943. {
  4944. string select_tid = getTidByCtid(tid);
  4945. lw.Add(string.Format("tid='{0}'", select_tid));
  4946. }
  4947. if (buyernick.Length > 0)
  4948. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4949. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4950. if (dw.Length > 0) lw.Add(dw);
  4951. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4952. if (dw_place.Length > 0) lw.Add(dw_place);
  4953. }
  4954. else
  4955. {
  4956. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4957. {
  4958. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4959. }
  4960. }
  4961. string price1 = GetPostString("price1");
  4962. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4963. string price2 = GetPostString("price2");
  4964. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4965. string posTag = CurrentUser.UserPost.Post.Code;
  4966. if (posTag == "Supplier")
  4967. {
  4968. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4969. }
  4970. lw.Add(string.Format("OrderState >= 6"));
  4971. lw.Add(string.Format("IsSample != 2 "));
  4972. lw.Add(string.Format("isDianziOrder = 0 "));
  4973. //lw.Add(string.Format("IsRefund<={0}", 1));
  4974. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4975. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4976. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4977. foreach (DataRow dr in dt.Rows)
  4978. {
  4979. 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();
  4980. }
  4981. writeGridDataTableJson(dStruct.TotalCount, dt);
  4982. }
  4983. public void get_erp_financeallplacelist()
  4984. {
  4985. DataStruct dStruct = GetPostStruct();
  4986. List<string> lw = new List<string>();
  4987. string tid = GetPostString("ctid");
  4988. string shopname = GetPostString("shopname");
  4989. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4990. string buyernick = GetPostString("buyer_nick");
  4991. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4992. string customer = GetPostString("customer");
  4993. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4994. string design = GetPostString("design");
  4995. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4996. string sellermemo = GetPostString("seller_memo");
  4997. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4998. string supplier = GetPostString("supplier");
  4999. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5000. string date1 = GetPostString("date1");
  5001. string date2 = GetPostString("date2");
  5002. string pldate1 = GetPostString("placedate1");
  5003. string pldate2 = GetPostString("placedate2");
  5004. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5005. {
  5006. if (tid.Length > 0)
  5007. {
  5008. string select_tid = getTidByCtid(tid);
  5009. lw.Add(string.Format("tid='{0}'", select_tid));
  5010. }
  5011. if (buyernick.Length > 0)
  5012. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5013. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5014. if (dw.Length > 0) lw.Add(dw);
  5015. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5016. if (dw_place.Length > 0) lw.Add(dw_place);
  5017. }
  5018. else
  5019. {
  5020. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5021. {
  5022. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5023. }
  5024. }
  5025. string price1 = GetPostString("price1");
  5026. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5027. string price2 = GetPostString("price2");
  5028. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5029. string posTag = CurrentUser.UserPost.Post.Code;
  5030. if (posTag == "Supplier")
  5031. {
  5032. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5033. }
  5034. //lw.Add(string.Format("OrderState >= 6"));
  5035. lw.Add(string.Format("IsSample != 2 "));
  5036. lw.Add(string.Format("isDianziOrder = 0 "));
  5037. //lw.Add(string.Format("IsRefund<={0}", 1));
  5038. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5039. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5040. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5041. foreach (DataRow dr in dt.Rows)
  5042. {
  5043. 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();
  5044. }
  5045. writeGridDataTableJson(dStruct.TotalCount, dt);
  5046. }
  5047. public void get_erp_expresslist()
  5048. {
  5049. int listtype = GetInt("ltype");
  5050. DataStruct dStruct = GetPostStruct();
  5051. List<string> lw = new List<string>();
  5052. string tid = GetPostString("tid");
  5053. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5054. string outsid = GetPostString("out_sid");
  5055. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5056. string importer = GetPostString("ImportUserName");
  5057. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5058. string file = GetPostString("import_file");
  5059. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5060. string printman = GetPostString("printman");
  5061. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5062. string date1 = GetPostString("date1");
  5063. string date2 = GetPostString("date2");
  5064. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5065. if (dw.Length > 0) lw.Add(dw);
  5066. string fdate1 = GetPostString("finishdate1");
  5067. string fdate2 = GetPostString("finishdate2");
  5068. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5069. if (fdw.Length > 0) lw.Add(fdw);
  5070. string supplierId = GetPostString("supplierId");
  5071. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5072. if (listtype == 1)
  5073. {
  5074. lw.Add(string.Format("importUserId !=0"));
  5075. }
  5076. string posTag = CurrentUser.UserPost.Post.Code;
  5077. if (posTag == "Supplier")
  5078. {
  5079. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5080. }
  5081. if (dStruct.PageSize != 100000)
  5082. {
  5083. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5084. }
  5085. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5086. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5087. writeGridDataTableJson(dStruct.TotalCount, dt);
  5088. }
  5089. public void set_erp_buchaorderdelivery()
  5090. {
  5091. if (UrlPostParmsCheck("ctid"))
  5092. {
  5093. string eid = GetPostString("ctid");
  5094. CeErpTradeCell entity = null;
  5095. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5096. if (entity != null)
  5097. {
  5098. if (entity.IsSample != 2)
  5099. {
  5100. returnErrorMsg("补差价单才能标记为已发货");
  5101. return;
  5102. }
  5103. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5104. entity.OrderState = 7;
  5105. entity.Update();
  5106. returnSuccessMsg("操作成功!");
  5107. return;
  5108. }
  5109. returnErrorMsg("找不到记录");
  5110. }
  5111. }
  5112. public void get_stdtemplates()
  5113. {
  5114. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5115. //string res = taobaoHelper.test();
  5116. string res = apiHelper.API_PrintTemplate();
  5117. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5118. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5119. {
  5120. int sidx = res.IndexOf("error_code");
  5121. int eidx = res.IndexOf("success");
  5122. string msg = res.Substring(sidx, eidx - sidx);
  5123. returnErrorMsg(msg);
  5124. return;
  5125. }
  5126. if (res.Length <= 0)
  5127. {
  5128. returnErrorMsg("模板数据为空!");
  5129. return;
  5130. }
  5131. ReturnSuccess(res);
  5132. }
  5133. public void cancel_print_order()
  5134. {
  5135. if (UrlPostParmsCheck("ctid"))
  5136. {
  5137. string ctid = GetPostString("ctid");
  5138. CeErpTradeCell entity = null;
  5139. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5140. if (entity != null)
  5141. {
  5142. string res = "";
  5143. string code = entity.LastBillWaybillCode;
  5144. if (code == "")
  5145. {
  5146. code = entity.OutSid;
  5147. }
  5148. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5149. XLog.SaveLog(0, "取消面单" + res);
  5150. }
  5151. }
  5152. }
  5153. public void set_erp_printwaybill()
  5154. {
  5155. if (UrlPostParmsCheck("ctid"))
  5156. {
  5157. string ctid = GetPostString("ctid");
  5158. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5159. string cpName = GetPostString("cpname");
  5160. string isTogether = GetPostString("together");
  5161. //var res_obj = new
  5162. //{
  5163. // restype = 1,
  5164. // 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\"}"
  5165. //};
  5166. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5167. //ReturnSuccess(ro_json);
  5168. //return;
  5169. bool isUseLastWayBillCode = false;
  5170. CeErpTradeCell entity = null;
  5171. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5172. if (entity != null)
  5173. {
  5174. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5175. {
  5176. isUseLastWayBillCode = true;
  5177. }
  5178. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5179. {
  5180. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5181. return;
  5182. }
  5183. }
  5184. string res = "";
  5185. Api_waybill_code_response_Obj fullObj = null;
  5186. string pData_str = "";
  5187. string curUseWayBillCode = "";
  5188. if (isUseLastWayBillCode == false)
  5189. {
  5190. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5191. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5192. if (res.IndexOf("failure") != -1)
  5193. {
  5194. //int idx = res.IndexOf("sub_message");
  5195. //int idx2 = res.IndexOf("flag");
  5196. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5197. string errMsgNeed = commonHelper.KeepChinese(res);
  5198. var res_objd = new
  5199. {
  5200. restype = 0,
  5201. data = "获取面单失败" + errMsgNeed
  5202. };
  5203. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5204. returnSuccess(ro_jsond);
  5205. if (res.IndexOf("停发") != -1)
  5206. {
  5207. entity.UnusualCon = "物流停发";
  5208. entity.Update();
  5209. }
  5210. //returnErrorMsg("获取面单失败,"+emsg);
  5211. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5212. return;
  5213. }
  5214. else if (res.IndexOf("errorMsg") != -1)
  5215. {
  5216. //int idx = res.IndexOf("errorMsg");
  5217. //int idx2 = res.IndexOf("}]}");
  5218. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5219. string errMsgNeed = commonHelper.KeepChinese(res);
  5220. var res_objf = new
  5221. {
  5222. restype = 0,
  5223. data = "获取面单失败2" + errMsgNeed
  5224. };
  5225. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5226. if (res.IndexOf("停发") != -1)
  5227. {
  5228. entity.UnusualCon = "物流停发";
  5229. entity.Update();
  5230. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5231. if (trade != null)
  5232. {
  5233. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5234. }
  5235. }
  5236. returnSuccess(ro_jsonf);
  5237. //returnErrorMsg("获取面单失败," + emsg);
  5238. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5239. return;
  5240. }
  5241. try
  5242. {
  5243. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5244. //res = res.Replace(" ", "");
  5245. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5246. }
  5247. catch (Exception ex)
  5248. {
  5249. XLog.SaveLog(0, "生成fullObj" + res);
  5250. var res_objf = new
  5251. {
  5252. restype = 0,
  5253. data = "生成fullObj发生错误" + ex.Message
  5254. };
  5255. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5256. returnSuccess(ro_jsonf);
  5257. return;
  5258. }
  5259. if (fullObj.response.data.content.Count > 0)
  5260. {
  5261. ContentItem codeObj = fullObj.response.data.content[0];
  5262. if (cpCode.IndexOf("SFFQ-") != -1)
  5263. {
  5264. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5265. }
  5266. else
  5267. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5268. curUseWayBillCode = codeObj.waybillCode;
  5269. }
  5270. else
  5271. {
  5272. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5273. var res_objf = new
  5274. {
  5275. restype = 0,
  5276. data = "生成fullObj找不到快递单号waybillCode"
  5277. };
  5278. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5279. returnSuccess(ro_jsonf);
  5280. return;
  5281. }
  5282. }
  5283. else
  5284. {
  5285. //使用上次打印的快递单号
  5286. if (cpCode == "SFFQ-LY")
  5287. {
  5288. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5289. }
  5290. else
  5291. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5292. curUseWayBillCode = entity.LastBillWaybillCode;
  5293. }
  5294. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5295. {
  5296. var res_obje = new
  5297. {
  5298. restype = 0,
  5299. data = "获取加密打印数据失败"
  5300. };
  5301. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5302. returnSuccess(ro_jsone);
  5303. entity.LastBillCpCode = cpCode;
  5304. entity.LastBillWaybillCode = curUseWayBillCode;
  5305. entity.Update();
  5306. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5307. //returnErrorMsg("获取加密打印数据失败");
  5308. return;
  5309. }
  5310. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5311. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5312. string btnType = "";
  5313. if (entity != null)
  5314. {
  5315. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5316. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5317. //cpcode是 YTO-CAINIAO
  5318. //string comCode = cpCode.Split('-')[0].ToString();
  5319. string apires = "";
  5320. if (ctid.IndexOf("N") != -1)
  5321. {
  5322. apires = "发货成功";
  5323. }
  5324. else
  5325. {
  5326. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5327. }
  5328. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5329. //打单后发货
  5330. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5331. {
  5332. try
  5333. {
  5334. btnType = "待发货";
  5335. entity.OutSid = curUseWayBillCode;
  5336. entity.OrderState = 7;
  5337. entity.IsUrgency = false;
  5338. entity.LastBillCpCode = "";
  5339. entity.LastBillWaybillCode = "";
  5340. entity.FinishDeliveryTime = DateTime.Now;
  5341. entity.IsReturn = 0;
  5342. entity.MemoOpt = 0;
  5343. entity.Update();
  5344. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5345. //还要插入快递信息到 快递信息表
  5346. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5347. exinfo.tid = entity.ctid;
  5348. exinfo.out_sid = entity.OutSid;
  5349. exinfo.company_code = cpCode;
  5350. exinfo.company_name = cpName;
  5351. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5352. exinfo.deliveryType = "发货成功";
  5353. exinfo.print_time = DateTime.Now;
  5354. exinfo.printUser = CurrentUser.UserName;
  5355. exinfo.Create();
  5356. commonHelper.UpdateRelationOrder(entity.ctid);
  5357. CeErpSukuraData.createInfo(ctid, 4);
  5358. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5359. if (entity.SupplierId == 64)
  5360. {
  5361. commonHelper.sendCytExpress(exinfo);
  5362. }
  5363. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5364. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5365. if (isTogether == "1")
  5366. {
  5367. StringBuilder sqlsb = new StringBuilder();
  5368. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5369. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5370. }
  5371. }
  5372. catch (Exception ex)
  5373. {
  5374. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5375. }
  5376. }
  5377. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5378. {
  5379. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5380. if (entity.OrderState == 6)
  5381. {
  5382. entity.OrderState = 7;
  5383. }
  5384. entity.FinishDeliveryTime = DateTime.Now;
  5385. btnType = "已发货";
  5386. entity.Update();
  5387. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5388. exinfo.tid = entity.ctid;
  5389. exinfo.out_sid = entity.OutSid;
  5390. exinfo.company_code = cpCode;
  5391. exinfo.company_name = cpName;
  5392. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5393. exinfo.deliveryType = "发货成功";
  5394. exinfo.print_time = DateTime.Now;
  5395. exinfo.printUser = CurrentUser.UserName;
  5396. exinfo.Create();
  5397. commonHelper.UpdateRelationOrder(entity.ctid);
  5398. CeErpSukuraData.createInfo(entity.ctid, 4);
  5399. if (entity.SupplierId == 64)
  5400. {
  5401. commonHelper.sendCytExpress(exinfo);
  5402. }
  5403. if (isTogether == "1")
  5404. {
  5405. StringBuilder sqlsb = new StringBuilder();
  5406. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5407. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5408. }
  5409. //不处理
  5410. }
  5411. else
  5412. {
  5413. entity.LastBillCpCode = cpCode;
  5414. entity.LastBillWaybillCode = curUseWayBillCode;
  5415. entity.Update();
  5416. string errmsg = commonHelper.KeepChinese(apires);
  5417. var res_objz = new
  5418. {
  5419. restype = 0,
  5420. data = "打单后发货失败"
  5421. };
  5422. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5423. returnSuccess(ro_jsonz);
  5424. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5425. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5426. return;
  5427. }
  5428. }
  5429. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5430. var res_obj = new
  5431. {
  5432. restype = 1,
  5433. data = pData_str
  5434. };
  5435. string ro_json = JsonConvert.SerializeObject(res_obj);
  5436. ReturnSuccess(ro_json);
  5437. return;
  5438. }
  5439. }
  5440. private string GetUTF8String(byte[] vs)
  5441. {
  5442. throw new NotImplementedException();
  5443. }
  5444. public void set_erp_printwaybill_cn()
  5445. {
  5446. if (UrlPostParmsCheck("ctid"))
  5447. {
  5448. string ctid = GetPostString("ctid");
  5449. string cpCode = GetPostString("cpcode");
  5450. string cpName = GetPostString("cpname");
  5451. string tempUrl = GetPostString("tempurl");
  5452. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5453. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5454. //string res = taobaoHelper.test();
  5455. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5456. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5457. {
  5458. int sidx = res.IndexOf("errorMsg");
  5459. int eidx = res.IndexOf("}");
  5460. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5461. var res_objzxx = new
  5462. {
  5463. restype = 0,
  5464. data = msg
  5465. };
  5466. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5467. returnSuccess(ro_jsonzxx);
  5468. //returnErrorMsg(msg);
  5469. return;
  5470. }
  5471. int idx = res.IndexOf("waybillCode");
  5472. int idx2 = res.IndexOf("printData");
  5473. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5474. string eid = GetPostString("ctid");
  5475. CeErpTradeCell entity = null;
  5476. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5477. if (entity != null)
  5478. {
  5479. string osid = entity.OutSid;
  5480. entity.OutSid = osid + "," + outsid;
  5481. entity.FinishDeliveryTime = DateTime.Now;
  5482. entity.OrderState = 7;
  5483. entity.IsReturn = 0;
  5484. entity.Update();
  5485. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5486. exinfo.tid = entity.ctid;
  5487. exinfo.out_sid = outsid;
  5488. exinfo.company_code = cpCode;
  5489. exinfo.company_name = cpName;
  5490. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5491. exinfo.deliveryType = "发货成功";
  5492. exinfo.print_time = DateTime.Now;
  5493. exinfo.printUser = CurrentUser.UserName;
  5494. exinfo.Create();
  5495. if (entity.SupplierId == 64)
  5496. {
  5497. commonHelper.sendCytExpress(exinfo);
  5498. }
  5499. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5500. }
  5501. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5502. var res_objz = new
  5503. {
  5504. restype = 1,
  5505. data = res
  5506. };
  5507. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5508. returnSuccess(ro_jsonz);
  5509. //ReturnSuccess(res);
  5510. }
  5511. }
  5512. ////打单,打印面单 获取面单号
  5513. //public void set_erp_printwaybill()
  5514. //{
  5515. // if (UrlPostParmsCheck("ctid"))
  5516. // {
  5517. // string ctid = GetPostString("ctid");
  5518. // string cpCode = GetPostString("cpcode");
  5519. // string tempUrl = GetPostString("tempurl");
  5520. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5521. // //string res = taobaoHelper.test();
  5522. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5523. // if (res.IndexOf("error_response") != -1)
  5524. // {
  5525. // int sidx = res.IndexOf("sub_msg");
  5526. // int eidx = res.IndexOf("request_id");
  5527. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5528. // returnErrorMsg(msg);
  5529. // return;
  5530. // }
  5531. // int idx = res.IndexOf("waybill_code");
  5532. // int idx2 = res.IndexOf("}]}");
  5533. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5534. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5535. // ReturnSuccess(res);
  5536. // }
  5537. //}
  5538. public void cancel_erp_aftersale()
  5539. {
  5540. if (UrlPostParmsCheck("ctid"))
  5541. {
  5542. string eid = GetPostString("ctid");
  5543. CeErpTradeCell entity = null;
  5544. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5545. if (entity != null)
  5546. {
  5547. //有过处理的售后,取消也不能删除 售 字,保留
  5548. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5549. {
  5550. entity.AfterSaleState = 4;
  5551. }
  5552. else
  5553. entity.AfterSaleState = 0;
  5554. entity.Update();
  5555. returnSuccessMsg("操作成功!");
  5556. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5557. return;
  5558. }
  5559. returnErrorMsg("找不到订单记录");
  5560. }
  5561. }
  5562. public void get_erp_aftersalelist()
  5563. {
  5564. DataStruct dStruct = GetPostStruct();
  5565. List<string> lw = new List<string>();
  5566. int st = GetInt("st");
  5567. string tid = GetPostString("ctid");
  5568. if (st == 3)
  5569. {
  5570. if (tid.Length > 0)
  5571. {
  5572. string select_tid = getTidByCtid(tid);
  5573. lw.Add(string.Format("tid='{0}'", select_tid));
  5574. }
  5575. }
  5576. else
  5577. {
  5578. if (tid.Length > 0)
  5579. {
  5580. string select_tid = getTidByCtid(tid);
  5581. lw.Add(string.Format("tid='{0}'", select_tid));
  5582. }
  5583. }
  5584. string shopname = GetPostString("shopname");
  5585. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5586. string buyernick = GetPostString("buyer_nick");
  5587. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5588. string sellermemo = GetPostString("seller_memo");
  5589. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5590. string orderState = GetPostString("orderState");
  5591. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5592. string afterState = GetPostString("afterstate");
  5593. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5594. string date1 = GetPostString("date1");
  5595. string date2 = GetPostString("date2");
  5596. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5597. if (dw.Length > 0) lw.Add(dw);
  5598. string price1 = GetPostString("price1");
  5599. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5600. string price2 = GetPostString("price2");
  5601. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5602. //lw.Add(string.Format("IsRefund!={0}", 1));
  5603. string reason = GetPostString("reason");
  5604. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5605. string method = GetPostString("method");
  5606. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5607. string handler = GetPostString("handler");
  5608. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5609. string handledate1 = GetPostString("handledate1");
  5610. string handledate2 = GetPostString("handledate2");
  5611. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5612. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5613. string finish1 = GetPostString("finishdate1");
  5614. string finish2 = GetPostString("finishdate2");
  5615. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5616. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5617. string afterdate1 = GetPostString("afterdate1");
  5618. string afterdate2 = GetPostString("afterdate2");
  5619. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5620. if (afterDate.Length > 0) lw.Add(afterDate);
  5621. string supplier = GetPostString("supplier");
  5622. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5623. string responsible = GetPostString("responsibleman");
  5624. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5625. string customer = GetPostString("customer");
  5626. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5627. string design = GetPostString("design");
  5628. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5629. string afterMemoType = GetPostString("aftermemotype");
  5630. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5631. string posCode = CurrentUser.UserPost.Post.Code;
  5632. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5633. //{
  5634. // string vstate = GetPostString("vstate");
  5635. // if (vstate.Length > 0)
  5636. // {
  5637. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5638. // }
  5639. // if (posCode == "Supplier")
  5640. // {
  5641. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5642. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5643. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5644. // }
  5645. // else
  5646. // {
  5647. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5648. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5649. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5650. // {
  5651. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5652. // }
  5653. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5654. // {
  5655. // int orgid = CurrentUser.UserPost.OrgID;
  5656. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5657. // }
  5658. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5659. // {
  5660. // string shopid = CurrentUser.User.pemShop;
  5661. // lw.Add(string.Format("shopId in ({0})", shopid));
  5662. // }
  5663. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5664. // //{
  5665. // // int org_id = CurrentUser.UserPost.OrgID;
  5666. // // lw.Add(string.Format("OrgID={0}", org_id));
  5667. // //}
  5668. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5669. // }
  5670. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5671. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5672. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5673. //}
  5674. if (st == 5)
  5675. {
  5676. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5677. {
  5678. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5679. {
  5680. string shopid = CurrentUser.User.pemShop;
  5681. lw.Add(string.Format("shopId in ({0})", shopid));
  5682. }
  5683. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5684. {
  5685. int mrOrgid = CurrentUser.UserPost.OrgID;
  5686. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5687. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5688. }
  5689. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5690. //{
  5691. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5692. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5693. //}
  5694. else
  5695. {
  5696. string userIdStr = "";
  5697. if (posCode == "CustomerService")
  5698. {
  5699. userIdStr = CurrentUser.UserID + "_k";
  5700. }
  5701. else if (posCode == "Designer" || posCode == "wxDesigner")
  5702. {
  5703. userIdStr = CurrentUser.UserID + "_s";
  5704. }
  5705. else if (posCode == "Place")
  5706. {
  5707. userIdStr = CurrentUser.UserID + "_x";
  5708. }
  5709. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5710. }
  5711. }
  5712. string placedate1 = GetPostString("placedate1");
  5713. string placedate2 = GetPostString("placedate2");
  5714. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5715. if (dwplace.Length > 0) lw.Add(dwplace);
  5716. string supState = GetPostString("supState");
  5717. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5718. string searchType = GetPostString("searchType");
  5719. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5720. {
  5721. lw.Add(string.Format("BackNum>1"));
  5722. }
  5723. lw.Add(string.Format("AfterSaleState>0"));
  5724. if (ex_psize > 0)
  5725. {
  5726. if (CurrentUser.UserPost.Post.Code == "Finance")
  5727. dStruct.Order = "pay_time desc";
  5728. else
  5729. dStruct.Order = "HandleTime desc";
  5730. }
  5731. else
  5732. dStruct.Order = "HandleTime desc";
  5733. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5734. DataTable dt = WebCache.GetData("view_test", dStruct);
  5735. writeGridDataTableJson(dStruct.TotalCount, dt);
  5736. }
  5737. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5738. //{
  5739. // lw.Add(string.Format("AfterSaleState=4"));
  5740. // string code = CurrentUser.UserPost.Post.Code;
  5741. // if (code == "CustomerService")
  5742. // {
  5743. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5744. // }
  5745. // else if (code == "Designer" || code == "DesignerMr")
  5746. // {
  5747. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5748. // }
  5749. // else if (code == "Place" || code == "PlaceMr")
  5750. // {
  5751. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5752. // }
  5753. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5754. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5755. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5756. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5757. //}
  5758. //else //处理中的售后,待处理和处理中合并
  5759. //{
  5760. // if (afterState.Length <= 0)
  5761. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5762. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5763. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5764. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5765. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5766. //}
  5767. }
  5768. public void get_erp_disagreeftersalelist()
  5769. {
  5770. DataStruct dStruct = GetPostStruct();
  5771. List<string> lw = new List<string>();
  5772. int st = 2;
  5773. string tid = GetPostString("ctid");
  5774. if (tid.Length > 0)
  5775. {
  5776. string select_tid = getTidByCtid(tid);
  5777. lw.Add(string.Format("tid='{0}'", select_tid));
  5778. }
  5779. string shopname = GetPostString("shopname");
  5780. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5781. string buyernick = GetPostString("buyer_nick");
  5782. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5783. string sellermemo = GetPostString("seller_memo");
  5784. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5785. string orderState = GetPostString("orderState");
  5786. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5787. string afterState = GetPostString("afterstate");
  5788. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5789. string date1 = GetPostString("date1");
  5790. string date2 = GetPostString("date2");
  5791. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5792. if (dw.Length > 0) lw.Add(dw);
  5793. string price1 = GetPostString("price1");
  5794. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5795. string price2 = GetPostString("price2");
  5796. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5797. //lw.Add(string.Format("IsRefund!={0}", 1));
  5798. string reason = GetPostString("reason");
  5799. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5800. string method = GetPostString("method");
  5801. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5802. string handler = GetPostString("handler");
  5803. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5804. string handledate1 = GetPostString("handledate1");
  5805. string handledate2 = GetPostString("handledate2");
  5806. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5807. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5808. string afterdate1 = GetPostString("afterdate1");
  5809. string afterdate2 = GetPostString("afterdate2");
  5810. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5811. if (afterDate.Length > 0) lw.Add(afterDate);
  5812. string backdate1 = GetPostString("backdate1");
  5813. string backdate2 = GetPostString("backdate2");
  5814. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5815. if (backDate.Length > 0) lw.Add(backDate);
  5816. string supplier = GetPostString("supplier");
  5817. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5818. string responsible = GetPostString("responsibleman");
  5819. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5820. string customer = GetPostString("customer");
  5821. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5822. string design = GetPostString("design");
  5823. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5824. string afterSaleMemo = GetPostString("afterSaleMemo");
  5825. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5826. string afterMemoType = GetPostString("aftermemotype");
  5827. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5828. string aftersakereason = GetPostString("aftersakereason");
  5829. if (aftersakereason.Length > 0)
  5830. {
  5831. if (aftersakereason == "1")
  5832. {
  5833. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5834. }
  5835. if (aftersakereason == "2")
  5836. {
  5837. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5838. }
  5839. }
  5840. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5841. string poscode = CurrentUser.UserPost.Post.Code;
  5842. if (poscode != "SysAdmin")
  5843. {
  5844. string shopid = CurrentUser.User.pemShop;
  5845. lw.Add(string.Format("shopId in ({0})", shopid));
  5846. }
  5847. string searchType = GetPostString("searchType");
  5848. if (searchType == "wait")
  5849. {
  5850. lw.Add(string.Format("HandleTime is null"));
  5851. }
  5852. if (searchType == "handling")
  5853. {
  5854. lw.Add(string.Format("HandleTime is not null "));
  5855. }
  5856. if (searchType == "back" || searchType == "puBack")
  5857. {
  5858. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5859. }
  5860. if (searchType == "reBack")
  5861. {
  5862. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5863. }
  5864. if (searchType == "moreBack")
  5865. {
  5866. lw.Add(string.Format("backNum > 1"));
  5867. }
  5868. lw.Add(string.Format("(AfterSaleState=5)"));
  5869. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5870. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5871. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5872. writeGridDataTableJson(dStruct.TotalCount, dt);
  5873. }
  5874. public void get_erp_handlingaftersalelist()
  5875. {
  5876. DataStruct dStruct = GetPostStruct();
  5877. List<string> lw = new List<string>();
  5878. int st = 2;
  5879. string tid = GetPostString("ctid");
  5880. if (tid.Length > 0)
  5881. {
  5882. string select_tid = getTidByCtid(tid);
  5883. lw.Add(string.Format("tid='{0}'", select_tid));
  5884. }
  5885. string shopname = GetPostString("shopname");
  5886. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5887. string buyernick = GetPostString("buyer_nick");
  5888. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5889. string sellermemo = GetPostString("seller_memo");
  5890. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5891. string orderState = GetPostString("orderState");
  5892. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5893. string afterState = GetPostString("afterstate");
  5894. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5895. string date1 = GetPostString("date1");
  5896. string date2 = GetPostString("date2");
  5897. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5898. if (dw.Length > 0) lw.Add(dw);
  5899. string price1 = GetPostString("price1");
  5900. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5901. string price2 = GetPostString("price2");
  5902. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5903. //lw.Add(string.Format("IsRefund!={0}", 1));
  5904. string reason = GetPostString("reason");
  5905. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5906. string method = GetPostString("method");
  5907. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5908. string handler = GetPostString("handler");
  5909. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5910. string handledate1 = GetPostString("handledate1");
  5911. string handledate2 = GetPostString("handledate2");
  5912. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5913. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5914. string afterdate1 = GetPostString("afterdate1");
  5915. string afterdate2 = GetPostString("afterdate2");
  5916. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5917. if (afterDate.Length > 0) lw.Add(afterDate);
  5918. string supplier = GetPostString("supplier");
  5919. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5920. string responsible = GetPostString("responsibleman");
  5921. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5922. string customer = GetPostString("customer");
  5923. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5924. string design = GetPostString("design");
  5925. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5926. string afterSaleMemo = GetPostString("afterSaleMemo");
  5927. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5928. string afterMemoType = GetPostString("aftermemotype");
  5929. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5930. string afterresult = GetPostString("afterresult");
  5931. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5932. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5933. string poscode = CurrentUser.UserPost.Post.Code;
  5934. if (poscode != "SysAdmin")
  5935. {
  5936. string shopid = CurrentUser.User.pemShop;
  5937. lw.Add(string.Format("shopId in ({0})", shopid));
  5938. }
  5939. string searchType = GetPostString("searchType");
  5940. if (searchType == "wait")
  5941. {
  5942. lw.Add(string.Format("HandleTime is null"));
  5943. }
  5944. if (searchType == "documentary")
  5945. {
  5946. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5947. }
  5948. if (searchType == "handling")
  5949. {
  5950. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5951. }
  5952. if (searchType == "back" || searchType == "puBack")
  5953. {
  5954. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5955. }
  5956. if (searchType == "reBack")
  5957. {
  5958. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5959. }
  5960. if (afterState.Length <= 0)
  5961. {
  5962. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5963. }
  5964. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5965. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5966. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5967. writeGridDataTableJson(dStruct.TotalCount, dt);
  5968. }
  5969. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5970. //public void get_erp_back_handlingaftersalelist()
  5971. //{
  5972. // DataStruct dStruct = GetPostStruct();
  5973. // List<string> lw = new List<string>();
  5974. // string tid = GetPostString("ctid");
  5975. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5976. // string shopname = GetPostString("shopname");
  5977. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5978. // string buyernick = GetPostString("buyer_nick");
  5979. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5980. // string sellermemo = GetPostString("seller_memo");
  5981. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5982. // string orderState = GetPostString("orderState");
  5983. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5984. // string afterState = GetPostString("afterstate");
  5985. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5986. // string date1 = GetPostString("date1");
  5987. // string date2 = GetPostString("date2");
  5988. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5989. // if (dw.Length > 0) lw.Add(dw);
  5990. // string price1 = GetPostString("price1");
  5991. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5992. // string price2 = GetPostString("price2");
  5993. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5994. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5995. // string reason = GetPostString("reason");
  5996. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5997. // string method = GetPostString("method");
  5998. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5999. // string handler = GetPostString("handler");
  6000. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6001. // string handledate1 = GetPostString("handledate1");
  6002. // string handledate2 = GetPostString("handledate2");
  6003. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6004. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6005. // string afterdate1 = GetPostString("afterdate1");
  6006. // string afterdate2 = GetPostString("afterdate2");
  6007. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6008. // if (afterDate.Length > 0) lw.Add(afterDate);
  6009. // string supplier = GetPostString("supplier");
  6010. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6011. // string responsible = GetPostString("responsibleman");
  6012. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6013. // string customer = GetPostString("customer");
  6014. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6015. // string design = GetPostString("design");
  6016. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6017. // string afterMemoType = GetPostString("aftermemotype");
  6018. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6019. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6020. // if (afterState.Length <= 0)
  6021. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6022. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6023. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6024. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6025. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6026. //}
  6027. public void get_erp_aftersaleverifylist()
  6028. {
  6029. DataStruct dStruct = GetPostStruct();
  6030. List<string> lw = new List<string>();
  6031. string tid = GetPostString("ctid");
  6032. if (tid.Length > 0)
  6033. {
  6034. string select_tid = getTidByCtid(tid);
  6035. lw.Add(string.Format("tid='{0}'", select_tid));
  6036. }
  6037. string shopname = GetPostString("shopname");
  6038. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6039. string buyernick = GetPostString("buyer_nick");
  6040. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6041. string sellermemo = GetPostString("seller_memo");
  6042. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6043. string orderState = GetPostString("orderState");
  6044. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6045. //lw.Add(string.Format("IsRefund!={0}", 1));
  6046. string reason = GetPostString("reason");
  6047. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6048. string method = GetPostString("method");
  6049. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6050. string handler = GetPostString("handler");
  6051. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6052. string handledate1 = GetPostString("handledate1");
  6053. string handledate2 = GetPostString("handledate2");
  6054. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6055. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6056. string finish1 = GetPostString("finishdate1");
  6057. string finish2 = GetPostString("finishdate2");
  6058. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6059. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6060. string supplier = GetPostString("supplier");
  6061. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6062. string responsible = GetPostString("responsibleman");
  6063. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6064. string posCode = CurrentUser.UserPost.Post.Code;
  6065. string vstate = GetPostString("vstate");
  6066. if (vstate.Length > 0)
  6067. {
  6068. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6069. }
  6070. if (posCode == "Supplier")
  6071. {
  6072. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6073. lw.Add(string.Format("VerifyState = 0"));
  6074. lw.Add("type = 1");
  6075. lw.Add(string.Format("AfterSaleState={0}", 3));
  6076. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6077. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6078. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6079. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6080. writeGridDataTableJson(dStruct.TotalCount, dt);
  6081. }
  6082. else if (posCode == "logistics")
  6083. {
  6084. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6085. lw.Add(string.Format("VerifyState = 0"));
  6086. lw.Add("type = 2");
  6087. lw.Add(string.Format("AfterSaleState={0}", 3));
  6088. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6089. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6090. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6091. writeGridDataTableJson(dStruct.TotalCount, dt);
  6092. }
  6093. else
  6094. {
  6095. lw.Add(string.Format("(AfterSaleState = 3)"));
  6096. string reasonState = GetPostString("reasonState");
  6097. lw.Add("type = 0");
  6098. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6099. || posCode == "Summarize" || posCode == "Finance")
  6100. {
  6101. if (reasonState == "2")
  6102. {
  6103. lw.Add("VerifyState = 3");
  6104. }
  6105. else if (reasonState == "1")
  6106. {
  6107. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6108. }
  6109. else
  6110. {
  6111. lw.Add("VerifyState in (0,3)");
  6112. }
  6113. //不加条件,可以看全部
  6114. }
  6115. 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")
  6116. {
  6117. int orgid = CurrentUser.UserPost.OrgID;
  6118. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6119. if (string.IsNullOrEmpty(manageOrgId))
  6120. {
  6121. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6122. }
  6123. else
  6124. {
  6125. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6126. }
  6127. if (reasonState == "1")
  6128. {
  6129. lw.Add("VerifyState = 3");
  6130. }
  6131. else if (reasonState == "2")
  6132. {
  6133. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6134. }
  6135. else
  6136. {
  6137. }
  6138. }
  6139. else
  6140. {
  6141. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6142. }
  6143. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6144. //{
  6145. // int org_id = CurrentUser.UserPost.OrgID;
  6146. // lw.Add(string.Format("OrgID={0}", org_id));
  6147. //}
  6148. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6149. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6150. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6151. writeGridDataTableJson(dStruct.TotalCount, dt);
  6152. }
  6153. }
  6154. public void get_erp_finishaftersalelist()
  6155. {
  6156. DataStruct dStruct = GetPostStruct();
  6157. List<string> lw = new List<string>();
  6158. int st = 4;
  6159. string tid = GetPostString("ctid");
  6160. if (tid.Length > 0)
  6161. {
  6162. string select_tid = getTidByCtid(tid);
  6163. lw.Add(string.Format("tid='{0}'", select_tid));
  6164. }
  6165. string shopname = GetPostString("shopname");
  6166. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6167. //lw.Add(string.Format("IsRefund!={0}", 1));
  6168. string reason = GetPostString("reason");
  6169. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6170. string method = GetPostString("method");
  6171. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6172. string buyernick = GetPostString("buyer_nick");
  6173. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6174. string handler = GetPostString("handler");
  6175. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6176. string handledate1 = GetPostString("handledate1");
  6177. string handledate2 = GetPostString("handledate2");
  6178. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6179. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6180. string finish1 = GetPostString("finishdate1");
  6181. string finish2 = GetPostString("finishdate2");
  6182. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6183. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6184. string supplier = GetPostString("supplier");
  6185. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6186. string responsible = GetPostString("responsibleman");
  6187. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6188. string vstate = GetPostString("vstate");
  6189. if (vstate.Length > 0)
  6190. {
  6191. if ("3".Equals(vstate))
  6192. {
  6193. lw.Add(string.Format("IsTem=1"));
  6194. }
  6195. else
  6196. {
  6197. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6198. }
  6199. }
  6200. lw.Add(string.Format("AfterSaleState=4"));
  6201. string code = CurrentUser.UserPost.Post.Code;
  6202. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6203. {
  6204. //不加条件,可以看全部
  6205. }
  6206. else if (code == "Supplier")
  6207. {
  6208. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6209. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6210. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6211. }
  6212. else if (code == "logistics")
  6213. {
  6214. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6215. lw.Add("type = 2");
  6216. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6217. }
  6218. 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")
  6219. {
  6220. int orgid = CurrentUser.UserPost.OrgID;
  6221. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6222. if (string.IsNullOrEmpty(manageOrgIds))
  6223. {
  6224. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6225. }
  6226. else
  6227. {
  6228. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6229. }
  6230. }
  6231. else
  6232. {
  6233. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6234. }
  6235. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6236. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6237. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6238. writeGridDataTableJson(dStruct.TotalCount, dt);
  6239. }
  6240. public void handle_erp_aftersale()
  6241. {
  6242. if (UrlPostParmsCheck("ctid"))
  6243. {
  6244. string eid = GetPostString("ctid");
  6245. string responStr = GetPostString("AfterSaleResponsible");
  6246. if (responStr.Length <= 0)
  6247. {
  6248. returnErrorMsg("售后责任人不能为空");
  6249. return;
  6250. }
  6251. bool isDesign = false;
  6252. double designFree = 0.00;
  6253. int responsibleId = 0;
  6254. CeErpTradeCell entity = null;
  6255. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6256. if (entity != null)
  6257. {
  6258. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6259. string afterMethod = GetPostString("AfterSaleMethod");
  6260. if (isNeedNewOrder == 1)
  6261. {
  6262. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6263. bool ishav = true;
  6264. if (newentity == null)
  6265. {
  6266. newentity = entity.Clone() as CeErpTradeCell;
  6267. ishav = false;
  6268. newentity.ctid = "S_" + entity.ctid;
  6269. newentity.OrderState = 0;
  6270. //唯一标识
  6271. newentity.OrderSn = newentity.ctid;
  6272. string orderSn = dataHelper.getSaleOrderSn();
  6273. if (orderSn != "")
  6274. {
  6275. newentity.OrderSn = orderSn;
  6276. }
  6277. }
  6278. newentity.AfterSaleState = 0;
  6279. newentity.AfterSaleMethod = afterMethod;
  6280. if (!ishav)
  6281. {
  6282. string memo_str = newentity.seller_memo;
  6283. memo_str = memo_str.Replace("(", "(");
  6284. memo_str = memo_str.Replace(")", ")");
  6285. int sIndex = memo_str.IndexOf("(");
  6286. int eIndex = memo_str.IndexOf(")");
  6287. if (sIndex == -1 || eIndex == -1)
  6288. {
  6289. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6290. return;
  6291. }
  6292. string first = memo_str.Substring(0, sIndex + 1);
  6293. string memoCtid = newentity.OrderSn;
  6294. //if (memoCtid.IndexOf("C") != -1)
  6295. //{
  6296. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6297. //if (CIdx.IndexOf("+") != -1)
  6298. //{
  6299. //CIdx = "C" + CIdx.Split('+')[1];
  6300. //}
  6301. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6302. //}
  6303. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6304. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6305. string newMemo = first + memoCtid + last;
  6306. newentity.seller_memo = newMemo;
  6307. newentity.FinishPlaceTime = null;
  6308. newentity.UnusualTag = 0;
  6309. newentity.UnusualCon = "";
  6310. newentity.UnusualTime = null;
  6311. newentity.AfterSaleMemo = "";
  6312. newentity.AfterSaleMethod = afterMethod;
  6313. newentity.AfterSalePreTime = null;
  6314. newentity.AfterSaleReason = "";
  6315. newentity.AfterSaleResponsible = "";
  6316. newentity.AfterSaleState = 0;
  6317. newentity.AfterSaleTime = null;
  6318. newentity.AfterSaleUserId = 0;
  6319. newentity.AfterSaleSupplierState = 0;
  6320. newentity.LastBillWaybillCode = "";
  6321. newentity.LastBillCpCode = "";
  6322. newentity.FinishAfterSaleTime = null;
  6323. newentity.HandleTime = null;
  6324. newentity.IsSF = 0;
  6325. newentity.IsOldCustomer = 0;
  6326. newentity.UrgencyTime = null;
  6327. newentity.ResponsibleUserId = "";
  6328. newentity.IsVerifyToSupplier = false;
  6329. newentity.payment = 0;
  6330. newentity.CheckMemo = "";
  6331. newentity.OutSid = "";
  6332. newentity.CheckOrderTime = null;
  6333. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6334. }
  6335. newentity.isAfterSaleOrder = 1;
  6336. newentity.IsRefund = 0;
  6337. string receiveMobile = GetPostString("receiver_mobile");
  6338. if (receiveMobile.Length > 0)
  6339. {
  6340. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6341. if (trade != null)
  6342. {
  6343. trade.receiver_name = GetPostString("receiver_name");
  6344. trade.receiver_mobile = receiveMobile;
  6345. trade.receiver_state = GetPostString("receiver_state");
  6346. trade.receiver_city = GetPostString("receiver_city");
  6347. trade.receiver_district = GetPostString("receiver_district");
  6348. trade.receiver_address = GetPostString("receiver_address");
  6349. newentity.IsOffLineOrder = 1;
  6350. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6351. }
  6352. }
  6353. string st = GetPostString("ToState");
  6354. if (st.Length > 0)
  6355. {
  6356. if (newentity.OrderState <= 3)
  6357. {
  6358. newentity.WaitDesignTime = DateTime.Now;
  6359. newentity.StartDesignTime = null;
  6360. newentity.FinishDesignTime = null;
  6361. newentity.OrderState = 3;
  6362. if (st == "下单员")
  6363. {
  6364. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6365. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6366. {
  6367. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6368. }
  6369. }
  6370. else
  6371. {
  6372. newentity.WaitDesignTime = DateTime.Now;
  6373. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6374. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6375. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6376. {
  6377. DataRow user = dt1.Rows[0];
  6378. //找主管
  6379. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6380. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6381. if (dt != null && dt.Rows.Count > 0)
  6382. {
  6383. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6384. newentity.DesignUserId = designMr;
  6385. string key = "aftersale_order_" + designMr;
  6386. if (RedisHelper.HasKey(key))
  6387. {
  6388. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6389. list.Add(newentity.ctid);
  6390. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6391. }
  6392. }
  6393. //账号正常
  6394. if (user["State"].ToString() == "0")
  6395. {
  6396. newentity.DesignUserId = entity.DesignUserId;
  6397. string key = "aftersale_order_" + entity.DesignUserId;
  6398. if (RedisHelper.HasKey(key))
  6399. {
  6400. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6401. list.Add(newentity.ctid);
  6402. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6403. }
  6404. }
  6405. }
  6406. }
  6407. }
  6408. if (entity.IsXianHuo == 1)
  6409. {
  6410. newentity.OrderState = 6;
  6411. entity.FinishPlaceTime = DateTime.Now;
  6412. }
  6413. }
  6414. if (ishav)
  6415. {
  6416. newentity.Update();
  6417. }
  6418. else
  6419. {
  6420. newentity.Create();
  6421. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6422. newCellExtend.ctid = newentity.ctid;
  6423. newCellExtend.orderFrom = 20;
  6424. newCellExtend.orderType = 30;
  6425. if (st == "下单员")
  6426. {
  6427. }
  6428. else
  6429. {
  6430. newCellExtend.ReprintTime = DateTime.Now;
  6431. }
  6432. newCellExtend.Create();
  6433. }
  6434. if (st != "下单员")
  6435. {
  6436. designHelper.API_GetPrintData_CreateOrder(newentity);
  6437. }
  6438. }
  6439. //处理售后扩展
  6440. string resIdStr = GetPostString("ResponsibleUserId");
  6441. string refundFees = GetPostString("refundFrees");
  6442. int IsComplain = GetPostInt("isComplain");
  6443. int IsBad = GetPostInt("isBad");
  6444. string IsOriginal = GetPostString("isOriginal");
  6445. double diffResultPrice = GetPostDouble("diffResultPrice");
  6446. string textResult = GetPostString("textResult");
  6447. string supplierResponsible = GetPostString("supplierResponsible");
  6448. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6449. if (ceErpTradeAfterSaleExtend == null)
  6450. {
  6451. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6452. ceErpTradeAfterSaleExtend.tid = eid;
  6453. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6454. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6455. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6456. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6457. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6458. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6459. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6460. ceErpTradeAfterSaleExtend.Create();
  6461. }
  6462. else
  6463. {
  6464. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6465. {
  6466. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6467. }
  6468. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6469. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6470. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6471. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6472. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6473. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6474. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6475. ceErpTradeAfterSaleExtend.Update();
  6476. }
  6477. int gysid = GetPostInt("ResponsibleSupId");
  6478. if (entity.AfterSaleUserId == 0)
  6479. {
  6480. entity.AfterSaleUserId = CurrentUser.UserID;
  6481. }
  6482. entity.ResponsibleUserId = resIdStr;
  6483. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6484. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6485. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6486. {
  6487. CeErpTradeResponsible.DelByTid(eid, -1);
  6488. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6489. int backNum = 0;
  6490. if (number != null)
  6491. {
  6492. backNum = number.BackNum;
  6493. }
  6494. char[] separator = { ',' };
  6495. string[] sArray = resIdStr.Split(separator);
  6496. string[] refundFreeList = { };
  6497. if (refundFees.Length > 0)
  6498. {
  6499. refundFreeList = refundFees.Split(separator);
  6500. }
  6501. int index = -1;
  6502. foreach (string i in sArray)
  6503. {
  6504. index++;
  6505. if (i.Length <= 0) continue;
  6506. char[] separator2 = { '_' };
  6507. string idstr = i.Split(separator2)[0];
  6508. string idtype = i.Split(separator2)[1];
  6509. double refudFree = 0;
  6510. if (refundFreeList.Length > 0)
  6511. {
  6512. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6513. }
  6514. if (idtype == "s")
  6515. {
  6516. isDesign = true;
  6517. designFree = refudFree;
  6518. }
  6519. int userId = Convert.ToInt32(idstr);
  6520. int type = 0;
  6521. if (idtype == "g")
  6522. {
  6523. type = 1;
  6524. }
  6525. if (idtype == "w")
  6526. {
  6527. type = 2;
  6528. }
  6529. if (idtype == "t")
  6530. {
  6531. type = 3;
  6532. }
  6533. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6534. if (ceErpTradeResponsible == null)
  6535. {
  6536. ceErpTradeResponsible = new CeErpTradeResponsible();
  6537. ceErpTradeResponsible.tid = eid;
  6538. ceErpTradeResponsible.UserId = userId;
  6539. ceErpTradeResponsible.createdTime = DateTime.Now;
  6540. ceErpTradeResponsible.type = type;
  6541. if (type == 1)
  6542. {
  6543. ceErpTradeResponsible.IsSup = 1;
  6544. }
  6545. if (type == 2)
  6546. {
  6547. ceErpTradeResponsible.IsFlow = 1;
  6548. }
  6549. }
  6550. ceErpTradeResponsible.RefundFee = refudFree;
  6551. ceErpTradeResponsible.VerifyState = 0;
  6552. if (userId == 2125 || idtype == "w")
  6553. {
  6554. ceErpTradeResponsible.VerifyState = 1;
  6555. }
  6556. if (idtype == "w" && userId == 101)
  6557. {
  6558. ceErpTradeResponsible.VerifyState = 0;
  6559. }
  6560. if (ceErpTradeResponsible.ID > 0)
  6561. {
  6562. ceErpTradeResponsible.Update();
  6563. }
  6564. else
  6565. {
  6566. ceErpTradeResponsible.Create();
  6567. }
  6568. if (isDesign)
  6569. {
  6570. responsibleId = ceErpTradeResponsible.ID;
  6571. }
  6572. }
  6573. CeErpTradeResponsible.NumByTid(backNum, eid);
  6574. }
  6575. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6576. if (ceErpTradeCellExtend != null)
  6577. {
  6578. ceErpTradeCellExtend.returnVisit = 0;
  6579. ceErpTradeCellExtend.Update();
  6580. }
  6581. if (entity.HandleTime != null)
  6582. {
  6583. if (entity.AfterSaleState == 1)
  6584. {
  6585. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6586. }
  6587. else
  6588. {
  6589. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6590. }
  6591. }
  6592. else
  6593. {
  6594. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6595. entity.HandleTime = DateTime.Now;
  6596. }
  6597. bool isCompale = false;
  6598. if (entity.AfterSaleState == 5)
  6599. {
  6600. isCompale = true;
  6601. entity.AfterSaleState = 3;
  6602. }
  6603. entity.AfterSaleSupplierState = 0;
  6604. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6605. {
  6606. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6607. }
  6608. string sImgs = GetPostString("img");
  6609. entity.AfterSaleSupplierImg = sImgs;
  6610. entity.supRefundType = GetPostString("supRefundType");
  6611. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6612. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6613. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6614. entity.AfterSaleMemoType = GetPostString("MemoType");
  6615. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6616. {
  6617. //entity.AfterSaleSupplierState = 2;
  6618. }
  6619. string df = GetPostString("DeductFee");
  6620. if (df == "")
  6621. {
  6622. df = "0";
  6623. }
  6624. string rf = GetPostString("RefundFee");
  6625. if (rf == "")
  6626. {
  6627. rf = "0";
  6628. }
  6629. string pm = GetPostString("AfterSalePayment");
  6630. if (pm == "")
  6631. {
  6632. pm = "0";
  6633. }
  6634. entity.AfterSalePayment = Convert.ToDouble(pm);
  6635. entity.DeductFee = Convert.ToDouble(df);
  6636. entity.RefundFee = Convert.ToDouble(rf);
  6637. entity.Update();
  6638. string toState = GetPostString("ToState");
  6639. string original = GetPostString("isOriginal");
  6640. ApiVo apiVo = new ApiVo();
  6641. apiVo.orderNumber = entity.ctid;
  6642. apiVo.actionName = "afterDesign";
  6643. apiVo.orderRemarks = entity.AfterSaleMethod;
  6644. apiVo.reasonRemarks = entity.AfterSaleReason;
  6645. apiVo.isDesign = isDesign;
  6646. apiVo.designFree = designFree;
  6647. apiVo.responsibleId = responsibleId;
  6648. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6649. if (toState == "设计师")
  6650. {
  6651. apiVo.isOriginal = Convert.ToBoolean(original);
  6652. }
  6653. designHelper.API_WorkCore(apiVo);//afterDesign
  6654. CeErpMethod methodSql = new CeErpMethod();
  6655. methodSql.con = entity.AfterSaleMethod;
  6656. methodSql.addTime = DateTime.Now;
  6657. methodSql.Create();
  6658. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6659. CeErpMethod.ExecuteNonQuery(delsql);
  6660. if (isCompale)
  6661. {
  6662. aftersale_data_change(entity.ctid);
  6663. }
  6664. returnSuccessMsg("操作成功!");
  6665. return;
  6666. }
  6667. returnErrorMsg("找不到订单记录");
  6668. }
  6669. }
  6670. public void ins_erp_toresponsible()
  6671. {
  6672. if (UrlPostParmsCheck("ctid"))
  6673. {
  6674. string eid = GetPostString("ctid");
  6675. CeErpTradeCell entity = null;
  6676. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6677. if (entity != null)
  6678. {
  6679. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6680. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6681. {
  6682. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6683. return;
  6684. }
  6685. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6686. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6687. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6688. if (entity.AfterSalePreTime == null)
  6689. {
  6690. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6691. {
  6692. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6693. }
  6694. }
  6695. entity.AfterSalePreTime = DateTime.Now;
  6696. //预完成给售后主管审核客户问题直接完成
  6697. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6698. {
  6699. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6700. {
  6701. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6702. }
  6703. }
  6704. ceErpTradeAfterSaleExtend.Update();
  6705. entity.AfterSaleState = 2;
  6706. entity.Update();
  6707. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6708. aftersale_data_change(entity.ctid);
  6709. returnSuccessMsg("操作成功!");
  6710. return;
  6711. }
  6712. returnErrorMsg("找不到订单记录");
  6713. }
  6714. }
  6715. public void cancel_erp_aftersaleanddelnew()
  6716. {
  6717. if (UrlPostParmsCheck("ctid"))
  6718. {
  6719. string eid = GetPostString("ctid");
  6720. CeErpTradeCell entity = null;
  6721. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6722. if (entity != null)
  6723. {
  6724. entity.AfterSaleState = 0;
  6725. entity.AfterSaleReason = "";
  6726. entity.AfterSaleMethod = "";
  6727. entity.AfterSaleMemo = "";
  6728. entity.AfterSaleResponsible = "";
  6729. entity.ResponsibleUserId = "";
  6730. entity.DeductFee = 0;
  6731. entity.RefundFee = 0;
  6732. entity.IsArbitrate = 0;
  6733. CeErpTradeResponsible.DelByTid(eid, -1);
  6734. entity.Update();
  6735. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6736. if (after != null)
  6737. {
  6738. if (after.OrderState < 5)
  6739. CeErpTradeCell.DelByCtid("S_" + eid);
  6740. }
  6741. returnSuccessMsg("操作成功!");
  6742. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6743. return;
  6744. }
  6745. returnErrorMsg("找不到订单记录");
  6746. }
  6747. }
  6748. public void get_erp_aftersale_pregather()
  6749. {
  6750. List<string> lw = new List<string>();
  6751. int st = GetInt("st");
  6752. string tid = GetPostString("ctid");
  6753. if (tid.Length > 0)
  6754. {
  6755. string select_tid = getTidByCtid(tid);
  6756. lw.Add(string.Format("tid='{0}'", select_tid));
  6757. }
  6758. string shopname = GetPostString("shopname");
  6759. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6760. string buyernick = GetPostString("buyer_nick");
  6761. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6762. string sellermemo = GetPostString("seller_memo");
  6763. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6764. string orderState = GetPostString("orderState");
  6765. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6766. string reason = GetPostString("reason");
  6767. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6768. string method = GetPostString("method");
  6769. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6770. string handler = GetPostString("handler");
  6771. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6772. string handledate1 = GetPostString("handledate1");
  6773. string handledate2 = GetPostString("handledate2");
  6774. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6775. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6776. string supplier = GetPostString("supplier");
  6777. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6778. string responsible = GetPostString("responsibleman");
  6779. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6780. string customer = GetPostString("customer");
  6781. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6782. string design = GetPostString("design");
  6783. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6784. string afterMemoType = GetPostString("aftermemotype");
  6785. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6786. string afterSaleMemo = GetPostString("afterSaleMemo");
  6787. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6788. string afterresult = GetPostString("afterresult");
  6789. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6790. string poscode = CurrentUser.UserPost.Post.Code;
  6791. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6792. {
  6793. string shopid = CurrentUser.User.pemShop;
  6794. lw.Add(string.Format("shopId in ({0})", shopid));
  6795. }
  6796. var mainwhere = string.Join(" and ", lw.ToArray());
  6797. string ro_json = "";
  6798. string type = GetPostString("gather_type");
  6799. int number = 0;
  6800. if (poscode == "AfterSale")
  6801. {
  6802. //处理中
  6803. if (type == "Handling")
  6804. {
  6805. 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) : ""));
  6806. DataTable dt = null;
  6807. try
  6808. {
  6809. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6810. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6811. }
  6812. catch (Exception e)
  6813. {
  6814. dt = new DataTable();
  6815. }
  6816. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6817. return;
  6818. }
  6819. if (type == "Wait")
  6820. {
  6821. //待处理
  6822. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6823. DataTable dt1 = null;
  6824. try
  6825. {
  6826. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6827. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6828. }
  6829. catch (Exception e)
  6830. {
  6831. dt1 = new DataTable();
  6832. }
  6833. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  6834. return;
  6835. }
  6836. if (type == "back")
  6837. {
  6838. //打回
  6839. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6840. DataTable dt2 = null;
  6841. try
  6842. {
  6843. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6844. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  6845. }
  6846. catch (Exception e)
  6847. {
  6848. dt2 = new DataTable();
  6849. }
  6850. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  6851. return;
  6852. }
  6853. if (type == "preCompletion")
  6854. {
  6855. //预完成
  6856. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6857. DataTable dt3 = null;
  6858. try
  6859. {
  6860. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6861. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  6862. }
  6863. catch (Exception e)
  6864. {
  6865. dt3 = new DataTable();
  6866. }
  6867. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  6868. return;
  6869. }
  6870. if (type == "documentary")
  6871. {
  6872. //跟单中
  6873. 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) : ""));
  6874. DataTable dt4 = null;
  6875. try
  6876. {
  6877. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6878. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  6879. }
  6880. catch (Exception e)
  6881. {
  6882. dt4 = new DataTable();
  6883. }
  6884. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  6885. return;
  6886. }
  6887. if (type == "reBack")
  6888. {
  6889. //被打回
  6890. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6891. DataTable dt1 = null;
  6892. try
  6893. {
  6894. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6895. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6896. }
  6897. catch (Exception e)
  6898. {
  6899. dt1 = new DataTable();
  6900. }
  6901. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6902. return;
  6903. }
  6904. }
  6905. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6906. {
  6907. if (type == "puBack")
  6908. {
  6909. //退回
  6910. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6911. DataTable dt = null;
  6912. try
  6913. {
  6914. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6915. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6916. }
  6917. catch (Exception e)
  6918. {
  6919. dt = new DataTable();
  6920. }
  6921. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  6922. return;
  6923. }
  6924. if (type == "reBack")
  6925. {
  6926. //打回
  6927. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6928. DataTable dt1 = null;
  6929. try
  6930. {
  6931. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6932. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6933. }
  6934. catch (Exception e)
  6935. {
  6936. dt1 = new DataTable();
  6937. }
  6938. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6939. return;
  6940. }
  6941. if (type == "examEd")
  6942. {
  6943. //已审核
  6944. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6945. DataTable dt2 = null;
  6946. try
  6947. {
  6948. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6949. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  6950. }
  6951. catch (Exception e)
  6952. {
  6953. dt2 = new DataTable();
  6954. }
  6955. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  6956. return;
  6957. }
  6958. if (type == "waitExam")
  6959. {
  6960. //待审核
  6961. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6962. DataTable dt3 = null;
  6963. try
  6964. {
  6965. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6966. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  6967. }
  6968. catch (Exception e)
  6969. {
  6970. dt3 = new DataTable();
  6971. }
  6972. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  6973. return;
  6974. }
  6975. if (type == "Handling")
  6976. {
  6977. //处理中
  6978. 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) : ""));
  6979. DataTable dt4 = null;
  6980. try
  6981. {
  6982. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6983. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  6984. }
  6985. catch (Exception e)
  6986. {
  6987. dt4 = new DataTable();
  6988. }
  6989. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6990. return;
  6991. }
  6992. if (type == "Wait")
  6993. {
  6994. //待处理
  6995. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6996. DataTable dt5 = null;
  6997. try
  6998. {
  6999. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7000. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7001. }
  7002. catch (Exception e)
  7003. {
  7004. dt5 = new DataTable();
  7005. }
  7006. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7007. return;
  7008. }
  7009. if (type == "documentary")
  7010. {
  7011. //跟单中
  7012. 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) : ""));
  7013. DataTable dt6 = null;
  7014. try
  7015. {
  7016. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7017. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7018. }
  7019. catch (Exception e)
  7020. {
  7021. dt6 = new DataTable();
  7022. }
  7023. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7024. return;
  7025. }
  7026. }
  7027. returnSuccess(ro_json);
  7028. }
  7029. public void end_erp_aftersale()
  7030. {
  7031. if (UrlPostParmsCheck("ctid"))
  7032. {
  7033. string eid = GetPostString("ctid");
  7034. CeErpTradeCell entity = null;
  7035. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7036. if (entity != null)
  7037. {
  7038. string stype = GetPostString("stype");
  7039. string typeStr = stype;
  7040. entity.AfterSaleState = 4;
  7041. entity.FinishAfterSaleTime = DateTime.Now;
  7042. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7043. entity.Update();
  7044. ApiVo apiVo = new ApiVo();
  7045. apiVo.orderNumber = entity.ctid;
  7046. apiVo.actionName = "afterOver";
  7047. designHelper.API_WorkCore(apiVo); //afterOver
  7048. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7049. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7050. CeErpSukuraData.createInfo(entity.ctid, 8);
  7051. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7052. returnSuccessMsg("操作成功!");
  7053. return;
  7054. }
  7055. returnErrorMsg("找不到订单记录");
  7056. }
  7057. }
  7058. public void ins_erp_finishaftersale()
  7059. {
  7060. if (UrlPostParmsCheck("id"))
  7061. {
  7062. string eid = GetPostString("id");
  7063. CeErpTradeResponsible entity = null;
  7064. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7065. if (entity != null)
  7066. {
  7067. entity.VerifyState = 1;
  7068. entity.VerifyTime = DateTime.Now;
  7069. entity.Update();
  7070. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7071. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7072. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7073. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7074. if (dt.Rows.Count <= 0)
  7075. {
  7076. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  7077. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7078. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7079. CeErpSukuraData.createInfo(entity.tid, 8);
  7080. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7081. {
  7082. CeErpDesignerBill.Del(entity.tid);
  7083. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7084. }
  7085. }
  7086. returnSuccessMsg("操作成功!");
  7087. return;
  7088. }
  7089. returnErrorMsg("找不到订单记录");
  7090. }
  7091. }
  7092. public void upd_erp_arbitrateaftersale()
  7093. {
  7094. if (UrlPostParmsCheck("id"))
  7095. {
  7096. string eid = GetPostString("id");
  7097. CeErpTradeResponsible entity = null;
  7098. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7099. if (entity != null)
  7100. {
  7101. entity.IsArbitrate = 1;
  7102. entity.ArbitradeMemo = GetPostString("reason");
  7103. entity.VerifyState = 2;
  7104. entity.Update();
  7105. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7106. if (tradecell != null)
  7107. {
  7108. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7109. tradecell.IsArbitrate = 1;
  7110. tradecell.Update();
  7111. }
  7112. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7113. returnSuccessMsg("操作成功!");
  7114. return;
  7115. }
  7116. returnErrorMsg("找不到订单记录");
  7117. }
  7118. }
  7119. public void upd_erp_backaftersale()
  7120. {
  7121. if (UrlPostParmsCheck("tid"))
  7122. {
  7123. string eid = GetPostString("tid");
  7124. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7125. int backNum = 0;
  7126. if (number != null)
  7127. {
  7128. backNum = number.BackNum;
  7129. }
  7130. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7131. CeErpTradeCell entity = null;
  7132. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7133. if (entity != null)
  7134. {
  7135. entity.AfterSaleBackReason = GetPostString("backreason");
  7136. entity.AfterSaleState = 1;
  7137. entity.AfterSaleSupplierState = 0;
  7138. entity.Update();
  7139. returnSuccessMsg("操作成功!");
  7140. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7141. return;
  7142. }
  7143. returnErrorMsg("找不到订单记录");
  7144. }
  7145. }
  7146. public void get_erp_supplieraftersalelist()
  7147. {
  7148. DataStruct dStruct = GetPostStruct();
  7149. List<string> lw = new List<string>();
  7150. string tid = GetPostString("ctid");
  7151. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7152. string shopname = GetPostString("shopname");
  7153. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7154. string buyernick = GetPostString("buyer_nick");
  7155. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7156. string sellermemo = GetPostString("seller_memo");
  7157. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7158. string orderState = GetPostString("orderState");
  7159. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7160. string afterState = GetPostString("afterstate");
  7161. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7162. string date1 = GetPostString("date1");
  7163. string date2 = GetPostString("date2");
  7164. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7165. if (dw.Length > 0) lw.Add(dw);
  7166. string price1 = GetPostString("price1");
  7167. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7168. string price2 = GetPostString("price2");
  7169. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7170. string reason = GetPostString("reason");
  7171. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7172. string method = GetPostString("method");
  7173. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7174. string handledate1 = GetPostString("handledate1");
  7175. string handledate2 = GetPostString("handledate2");
  7176. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7177. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7178. string handler = GetPostString("handler");
  7179. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7180. string afterdate1 = GetPostString("afterdate1");
  7181. string afterdate2 = GetPostString("afterdate2");
  7182. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7183. if (afterDate.Length > 0) lw.Add(afterDate);
  7184. string customer = GetPostString("customer");
  7185. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7186. string design = GetPostString("design");
  7187. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7188. string afterMemoType = GetPostString("aftermemotype");
  7189. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7190. string vstate = GetPostString("vstate");
  7191. if (vstate.Length > 0)
  7192. {
  7193. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7194. }
  7195. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7196. string supplier = GetPostString("supplier");
  7197. int supid = commonHelper.getSupplierIDByName(supplier);
  7198. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7199. string posCode = CurrentUser.UserPost.Post.Code;
  7200. if (posCode == "Supplier")
  7201. {
  7202. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7203. }
  7204. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7205. {
  7206. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7207. }
  7208. else
  7209. {
  7210. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7211. }
  7212. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7213. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7214. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7215. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7216. writeGridDataTableJson(dStruct.TotalCount, dt);
  7217. }
  7218. public void upd_erp_supverifyaftersale()
  7219. {
  7220. if (UrlPostParmsCheck("id"))
  7221. {
  7222. string id = GetPostString("id");
  7223. int st = GetPostInt("afterstate");
  7224. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7225. CeErpTradeCell entity = null;
  7226. if (ceErpTradeResponsible != null)
  7227. {
  7228. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7229. }
  7230. string afmemo = GetPostString("supmemo");
  7231. string image = GetPostString("image");
  7232. if (entity != null)
  7233. {
  7234. entity.AfterSaleSupplierState = st;
  7235. entity.AfterSaleSupplierMemo = afmemo;
  7236. if (st == 1)
  7237. {
  7238. ceErpTradeResponsible.VerifyState = 1;
  7239. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7240. ceErpTradeResponsible.Update();
  7241. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7242. if (isAll)
  7243. {
  7244. entity.AfterSaleState = 4;
  7245. entity.FinishAfterSaleTime = DateTime.Now;
  7246. }
  7247. }
  7248. else
  7249. {
  7250. CeErpTradeResponsible.dateByTid(entity.ctid);
  7251. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7252. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7253. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7254. if (num <= 1)
  7255. {
  7256. entity.AfterSaleState = 1;
  7257. }
  7258. else
  7259. {
  7260. entity.AfterSaleState = 5;
  7261. }
  7262. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7263. if (ceErpTradeAfterSaleExtend != null)
  7264. {
  7265. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7266. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7267. ceErpTradeAfterSaleExtend.Update();
  7268. }
  7269. else
  7270. {
  7271. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7272. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7273. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7274. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7275. ceErpTradeAfterSaleExtend.Create();
  7276. }
  7277. }
  7278. if (entity.AfterSaleState == 4)
  7279. {
  7280. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7281. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7282. {
  7283. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7284. }
  7285. ApiVo apiVo = new ApiVo();
  7286. apiVo.orderNumber = entity.ctid;
  7287. apiVo.actionName = "afterOver";
  7288. designHelper.API_WorkCore(apiVo); //afterOver
  7289. }
  7290. entity.Update();
  7291. returnSuccessMsg("操作成功!");
  7292. CeErpSukuraData.createInfo(entity.ctid, 8);
  7293. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7294. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7295. return;
  7296. }
  7297. returnErrorMsg("找不到订单记录");
  7298. }
  7299. }
  7300. public void upd_erp_masteraftersale()
  7301. {
  7302. if (UrlPostParmsCheck("id"))
  7303. {
  7304. string id = GetPostString("id");
  7305. int st = GetPostInt("afterstate");
  7306. string afmemo = GetPostString("supmemo");
  7307. string image = GetPostString("image");
  7308. string textResult = GetPostString("textResult");
  7309. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7310. if (ceErpTradeResponsible != null)
  7311. {
  7312. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7313. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7314. ceErpTradeResponsible.Update();
  7315. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7316. if (entity != null)
  7317. {
  7318. entity.AfterSaleSupplierState = st;
  7319. entity.AfterSaleSupplierMemo = afmemo;
  7320. if (st == 1)
  7321. {
  7322. }
  7323. else
  7324. {
  7325. CeErpTradeResponsible.dateByTid(entity.ctid);
  7326. //退回到售后
  7327. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7328. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7329. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7330. if (num <= 1)
  7331. {
  7332. entity.AfterSaleState = 1;
  7333. }
  7334. else
  7335. {
  7336. entity.AfterSaleState = 5;
  7337. }
  7338. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7339. if (ceErpTradeAfterSaleExtend != null)
  7340. {
  7341. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7342. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7343. ceErpTradeAfterSaleExtend.Update();
  7344. }
  7345. else
  7346. {
  7347. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7348. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7349. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7350. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7351. ceErpTradeAfterSaleExtend.Create();
  7352. }
  7353. }
  7354. entity.Update();
  7355. returnSuccessMsg("操作成功!");
  7356. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7357. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7358. return;
  7359. }
  7360. }
  7361. returnErrorMsg("找不到订单记录");
  7362. }
  7363. }
  7364. public void upd_erp_personaftersale()
  7365. {
  7366. if (UrlPostParmsCheck("id"))
  7367. {
  7368. string id = GetPostString("id");
  7369. int st = GetPostInt("afterstate");
  7370. string afmemo = GetPostString("supmemo");
  7371. string image = GetPostString("image");
  7372. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7373. if (ceErpTradeResponsible != null)
  7374. {
  7375. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7376. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7377. ceErpTradeResponsible.Update();
  7378. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7379. if (entity != null)
  7380. {
  7381. entity.AfterSaleSupplierMemo = afmemo;
  7382. entity.AfterSaleSupplierState = st;
  7383. if (st == 1)
  7384. {
  7385. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7386. if (isAll)
  7387. {
  7388. entity.AfterSaleState = 4;
  7389. entity.FinishAfterSaleTime = DateTime.Now;
  7390. }
  7391. }
  7392. else
  7393. {
  7394. CeErpTradeResponsible.dateByTid(entity.ctid);
  7395. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7396. if (ceErpTradeAfterSaleExtend != null)
  7397. {
  7398. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7399. ceErpTradeAfterSaleExtend.Update();
  7400. }
  7401. else
  7402. {
  7403. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7404. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7405. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7406. ceErpTradeAfterSaleExtend.Create();
  7407. }
  7408. //退回到主管
  7409. //entity.AfterSaleState = 2;
  7410. }
  7411. if (entity.AfterSaleState == 4)
  7412. {
  7413. ApiVo apiVo = new ApiVo();
  7414. apiVo.orderNumber = entity.ctid;
  7415. apiVo.actionName = "afterOver";
  7416. designHelper.API_WorkCore(apiVo); //afterOver
  7417. }
  7418. entity.Update();
  7419. returnSuccessMsg("操作成功!");
  7420. CeErpSukuraData.createInfo(entity.ctid, 8);
  7421. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7422. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7423. return;
  7424. }
  7425. }
  7426. returnErrorMsg("找不到订单记录");
  7427. }
  7428. }
  7429. public void set_erp_supplierrefundtag()
  7430. {
  7431. if (UrlPostParmsCheck("ctid"))
  7432. {
  7433. string eid = GetPostString("ctid");
  7434. CeErpTradeCell entity = null;
  7435. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7436. if (entity != null)
  7437. {
  7438. entity.IsSupplierRefund = GetPostInt("tag");
  7439. entity.Update();
  7440. returnSuccessMsg("操作成功!");
  7441. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7442. return;
  7443. }
  7444. returnErrorMsg("找不到订单记录");
  7445. }
  7446. }
  7447. public void get_erp_refundlist()
  7448. {
  7449. DataStruct dStruct = GetPostStruct();
  7450. List<string> lw = new List<string>();
  7451. string tid = GetPostString("tid");
  7452. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7453. //string rid = GetPostString("refund_id");
  7454. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7455. string shopname = GetPostString("shopname");
  7456. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7457. string buyernick = GetPostString("buyer_nick");
  7458. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7459. string customer = GetPostString("customer");
  7460. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7461. string design = GetPostString("design");
  7462. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7463. string sellermemo = GetPostString("seller_memo");
  7464. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7465. //string date1 = GetPostString("date1");
  7466. //string date2 = GetPostString("date2");
  7467. //string dateType = GetPostString("dateType");
  7468. //if (dateType.Length > 0)
  7469. //{
  7470. // if (dateType == "1001") dateType = "0";
  7471. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7472. // if (searchDT.Count == 2)
  7473. // {
  7474. // date1 = searchDT[0].ToString();
  7475. // date2 = searchDT[1].ToString();
  7476. // }
  7477. //}
  7478. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7479. //if (dw.Length > 0) lw.Add(dw);
  7480. string redate1 = GetPostString("refunddate1");
  7481. string redate2 = GetPostString("refunddate2");
  7482. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7483. if (dwdate.Length > 0) lw.Add(dwdate);
  7484. string price1 = GetPostString("price1");
  7485. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7486. string price2 = GetPostString("price2");
  7487. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7488. string ispartrefund = GetPostString("ispartrefund");
  7489. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7490. string refundState = GetPostString("refundvstate");
  7491. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7492. int st = GetInt("st");
  7493. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7494. {
  7495. string responsible = GetPostString("responsibleman");
  7496. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7497. lw.Add(string.Format("RefundState>={0}", st));
  7498. string code = CurrentUser.UserPost.Post.Code;
  7499. if (code == "CustomerService")
  7500. {
  7501. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7502. }
  7503. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7504. {
  7505. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7506. }
  7507. else if (code == "Place" || code == "PlaceMr")
  7508. {
  7509. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7510. }
  7511. dStruct.Order = "RefundState asc,created desc";
  7512. }
  7513. else if (st == 10)
  7514. {
  7515. string responsible = GetPostString("responsibleman");
  7516. if (responsible == "空白")
  7517. {
  7518. lw.Add(string.Format("ResponsibleUserName = ''"));
  7519. }
  7520. else if (responsible.Length > 0)
  7521. {
  7522. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7523. }
  7524. lw.Add(string.Format("RefundState>=0"));
  7525. dStruct.Order = "created desc";
  7526. }
  7527. else
  7528. {
  7529. string responsible = GetPostString("responsibleman");
  7530. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7531. lw.Add(string.Format("RefundState={0}", st));
  7532. dStruct.Order = "created desc";
  7533. }
  7534. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7535. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7536. dt.Columns.Add("refund_fees");
  7537. foreach (DataRow dr in dt.Rows)
  7538. {
  7539. String status = dr["status"].ToString();
  7540. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7541. {
  7542. dr["refund_fees"] = dr["refund_fee"];
  7543. }
  7544. else
  7545. {
  7546. dr["refund_fees"] = "0.0";
  7547. }
  7548. }
  7549. writeGridDataTableJson(dStruct.TotalCount, dt);
  7550. }
  7551. public void get_erp_refunddesignlist()
  7552. {
  7553. DataStruct dStruct = GetPostStruct();
  7554. List<string> lw = new List<string>();
  7555. string tid = GetPostString("tid");
  7556. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7557. string shopname = GetPostString("shopname");
  7558. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7559. string buyernick = GetPostString("buyer_nick");
  7560. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7561. string customer = GetPostString("customer");
  7562. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7563. string design = GetPostString("design");
  7564. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7565. string sellermemo = GetPostString("seller_memo");
  7566. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7567. string redate1 = GetPostString("refunddate1");
  7568. string redate2 = GetPostString("refunddate2");
  7569. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7570. if (dwdate.Length > 0) lw.Add(dwdate);
  7571. string price1 = GetPostString("price1");
  7572. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7573. string price2 = GetPostString("price2");
  7574. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7575. string ispartrefund = GetPostString("ispartrefund");
  7576. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7577. string designerorg = GetPostString("designerorg");
  7578. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7579. string refundState = GetPostString("refundState");
  7580. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7581. int myOrgid = CurrentUser.UserPost.OrgID;
  7582. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7583. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7584. {
  7585. if (CurrentUser.User.TeamIds.Length > 0)
  7586. {
  7587. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7588. }
  7589. else
  7590. {
  7591. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7592. }
  7593. }
  7594. else if ("SysAdmin".Equals(myOrgCode))
  7595. {
  7596. }
  7597. else
  7598. {
  7599. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7600. {
  7601. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7602. }
  7603. else
  7604. {
  7605. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7606. }
  7607. }
  7608. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7609. dStruct.Order = "created desc";
  7610. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7611. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7612. dt.Columns.Add("refund_fees");
  7613. foreach (DataRow dr in dt.Rows)
  7614. {
  7615. String status = dr["status"].ToString();
  7616. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7617. {
  7618. dr["refund_fees"] = dr["refund_fee"];
  7619. }
  7620. else
  7621. {
  7622. dr["refund_fees"] = "0.0";
  7623. }
  7624. }
  7625. writeGridDataTableJson(dStruct.TotalCount, dt);
  7626. }
  7627. public void handle_erp_refundtag()
  7628. {
  7629. if (UrlPostParmsCheck("refund_id"))
  7630. {
  7631. string eid = GetPostString("refund_id");
  7632. string respMan = GetPostString("ResponsibleName");
  7633. if (respMan.Length <= 0)
  7634. {
  7635. returnErrorMsg("责任人不能为空");
  7636. return;
  7637. }
  7638. CeErpTradeRefund entity = null;
  7639. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7640. if (entity != null)
  7641. {
  7642. entity.ResponsibleUserName = respMan;
  7643. string userid = GetPostString("ResponsibleUserId");
  7644. if (userid.Length > 0)
  7645. {
  7646. entity.ResponsibleUserId = userid;
  7647. }
  7648. entity.Memo = GetPostString("Memo");
  7649. if (respMan.IndexOf("客服") != -1 ||
  7650. respMan.IndexOf("设计师") != -1 ||
  7651. respMan.IndexOf("下单员") != -1)
  7652. {
  7653. entity.RefundState = 2;
  7654. }
  7655. else
  7656. {
  7657. entity.RefundState = 3;
  7658. }
  7659. entity.modified = DateTime.Now;
  7660. entity.Update();
  7661. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7662. returnSuccessMsg("操作成功!");
  7663. return;
  7664. }
  7665. returnErrorMsg("找不到订单记录");
  7666. }
  7667. }
  7668. public void handle_erp_designrefundtag()
  7669. {
  7670. if (UrlPostParmsCheck("refund_id"))
  7671. {
  7672. string eid = GetPostString("refund_id");
  7673. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7674. if (ceErpTradeCellExtend == null)
  7675. {
  7676. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7677. ceErpTradeCellExtend.ctid = eid;
  7678. }
  7679. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7680. if (ceErpTradeCellExtend.ID > 0)
  7681. {
  7682. ceErpTradeCellExtend.Update();
  7683. }
  7684. else
  7685. {
  7686. ceErpTradeCellExtend.Create();
  7687. }
  7688. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7689. returnSuccessMsg("操作成功!");
  7690. return;
  7691. }
  7692. returnErrorMsg("找不到订单记录");
  7693. }
  7694. public void upd_erp_refundverify()
  7695. {
  7696. if (UrlPostParmsCheck("refund_id"))
  7697. {
  7698. string eid = GetPostString("refund_id");
  7699. CeErpTradeRefund entity = null;
  7700. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7701. if (entity != null)
  7702. {
  7703. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7704. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7705. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7706. {
  7707. entity.RefundState = 2;
  7708. }
  7709. else
  7710. {
  7711. entity.RefundState = 3;
  7712. }
  7713. entity.Update();
  7714. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7715. returnSuccessMsg("操作成功!");
  7716. return;
  7717. }
  7718. returnErrorMsg("找不到订单记录");
  7719. }
  7720. }
  7721. public void upd_erp_refundapprove()
  7722. {
  7723. if (UrlPostParmsCheck("refund_id"))
  7724. {
  7725. string eid = GetPostString("refund_id");
  7726. CeErpTradeRefund entity = null;
  7727. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7728. if (entity != null)
  7729. {
  7730. int apr = GetPostInt("approve");
  7731. if (apr == 0)
  7732. {
  7733. entity.RefundState = 1;
  7734. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7735. }
  7736. else if (apr == 1)
  7737. {
  7738. entity.RefundState = 3;
  7739. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7740. }
  7741. entity.modified = DateTime.Now;
  7742. entity.Update();
  7743. returnSuccessMsg("操作成功!");
  7744. return;
  7745. }
  7746. returnErrorMsg("找不到订单记录");
  7747. }
  7748. }
  7749. public void get_erp_billlist()
  7750. {
  7751. DataStruct dStruct = GetPostStruct();
  7752. List<string> lw = new List<string>();
  7753. string title = GetPostString("title");
  7754. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7755. string tid = GetPostString("tid");
  7756. string tids = GetPostString("tids");
  7757. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7758. if (tids.Length > 0)
  7759. {
  7760. tids = "'" + tids + "'";
  7761. tids = tids.Replace(",", "','");
  7762. lw.Add(string.Format("tid in ({0})", tids));
  7763. }
  7764. string shopname = GetPostString("shopname");
  7765. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7766. string buyernick = GetPostString("buyer_nick");
  7767. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7768. string customer = GetPostString("customer");
  7769. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7770. string date1 = GetPostString("date1");
  7771. string date2 = GetPostString("date2");
  7772. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7773. if (dw.Length > 0) lw.Add(dw);
  7774. string price1 = GetPostString("price1");
  7775. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7776. string price2 = GetPostString("price2");
  7777. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7778. string returndate1 = GetPostString("returndate1");
  7779. string returndate2 = GetPostString("returndate2");
  7780. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7781. if (dw1.Length > 0) lw.Add(dw1);
  7782. string billtype = GetPostString("billtype");
  7783. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7784. string billstate = GetPostString("billstate");
  7785. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7786. string usershop = CurrentUser.User.pemShop;
  7787. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7788. dStruct.Order = "createTime desc";
  7789. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7790. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7791. //foreach (DataRow dr in dt.Rows)
  7792. //{
  7793. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7794. //}
  7795. writeGridDataTableJson(dStruct.TotalCount, dt);
  7796. }
  7797. public void modify_erp_billinfo()
  7798. {
  7799. if (UrlPostParmsCheck("ID"))
  7800. {
  7801. string eid = GetPostString("ID");
  7802. CeErpBill bill_entity = null;
  7803. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7804. if (bill_entity != null)
  7805. {
  7806. bill_entity.tid = GetPostString("tid");
  7807. bill_entity.title = GetPostString("title");
  7808. bill_entity.tax = GetPostString("tax");
  7809. bill_entity.bank = GetPostString("bank");
  7810. bill_entity.bankac = GetPostString("bankac");
  7811. bill_entity.address = GetPostString("address");
  7812. bill_entity.phone = GetPostString("phone");
  7813. bill_entity.price = GetPostString("price");
  7814. bill_entity.productId = GetPostInt("ProductName");
  7815. bill_entity.num = GetPostInt("num");
  7816. bill_entity.unit = GetPostString("unit");
  7817. bill_entity.type = GetPostString("type");
  7818. bill_entity.sendType = GetPostString("SendType");
  7819. bill_entity.email = GetPostString("email");
  7820. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7821. bill_entity.shopName = GetPostString("ShopName");
  7822. bill_entity.applymemo = GetPostString("applymemo");
  7823. bill_entity.modifyTime = DateTime.Now;
  7824. bill_entity.createTime = DateTime.Now;
  7825. bill_entity.state = 0;
  7826. bill_entity.Update();
  7827. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7828. returnSuccessMsg("发票修改成功!");
  7829. return;
  7830. }
  7831. returnErrorMsg("找不到对应记录");
  7832. }
  7833. }
  7834. public void set_erp_invoicing()
  7835. {
  7836. if (UrlPostParmsCheck("id"))
  7837. {
  7838. try
  7839. {
  7840. string eid = GetPostString("id");
  7841. CeErpBill bill_entity = null;
  7842. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7843. if (bill_entity != null)
  7844. {
  7845. int ComId = GetPostInt("ComId");
  7846. //string memo = GetPostString("Memo");
  7847. int allInfo = GetPostInt("allinfo");
  7848. string clert = CurrentUser.User.Name;
  7849. //string detailValue = GetPostString("detailvalue");
  7850. string billId = bill_entity.billOrderId;
  7851. string[] billIdList = billId.Split(',');
  7852. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7853. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7854. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7855. {
  7856. billCount += 1;
  7857. }
  7858. if (billId.Length <= 0 || billIdList.Length != billCount)
  7859. {
  7860. bill_entity.billOrderId = "";
  7861. string prebill = "ltb";
  7862. for (int idx = 1; idx <= billCount; idx++)
  7863. {
  7864. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7865. string billoid = prebill + idx + dtstr;
  7866. bill_entity.billOrderId += billoid;
  7867. if (idx < billCount)
  7868. {
  7869. bill_entity.billOrderId += ",";
  7870. }
  7871. }
  7872. }
  7873. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7874. if (bill_entity.state == 5)
  7875. {
  7876. string errMsg = bill_entity.failerror;
  7877. string[] errlist = errMsg.Split('|');
  7878. string[] errTags = new string[errlist.Length];
  7879. for (int itag = 0; itag < errlist.Length; itag++)
  7880. {
  7881. if (errlist[itag].Length <= 0) continue;
  7882. errTags[itag] = errlist[itag].Split('&')[0];
  7883. }
  7884. for (int iii = 0; iii < errTags.Length; iii++)
  7885. {
  7886. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7887. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7888. if (billOrderList.Length >= erroBillOrderTag)
  7889. {
  7890. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7891. if (needModifyBillId.Length <= 19)
  7892. {
  7893. needModifyBillId = needModifyBillId + "1";
  7894. }
  7895. else
  7896. {
  7897. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7898. last = last + 1;
  7899. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7900. }
  7901. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7902. }
  7903. }
  7904. }
  7905. bool isHaveBillSucces = false;
  7906. string totalRes = "";
  7907. bill_entity.failerror = "";
  7908. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7909. {
  7910. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7911. totalRes += res;
  7912. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7913. {
  7914. isHaveBillSucces = true;
  7915. bill_entity.comId = ComId;
  7916. bill_entity.state = 1;
  7917. bill_entity.executeTime = DateTime.Now;
  7918. bill_entity.executeUser = clert;
  7919. }
  7920. else
  7921. {
  7922. bill_entity.state = 5;
  7923. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7924. }
  7925. }
  7926. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7927. bill_entity.Update();
  7928. if (isHaveBillSucces)
  7929. {
  7930. StringBuilder sql = new StringBuilder();
  7931. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7932. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7933. }
  7934. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7935. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7936. {
  7937. returnErrorMsg("开票失败");
  7938. }
  7939. else
  7940. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7941. return;
  7942. }
  7943. returnErrorMsg("找不到对应记录");
  7944. }
  7945. catch (Exception ex)
  7946. {
  7947. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7948. returnErrorMsg("操作失败");
  7949. }
  7950. }
  7951. }
  7952. public void get_erp_invoicing_back()
  7953. {
  7954. if (UrlPostParmsCheck("id"))
  7955. {
  7956. try
  7957. {
  7958. string id = GetPostString("id");
  7959. CeErpBill entiy = CeErpBill.Get(id);
  7960. if (entiy != null)
  7961. {
  7962. if (entiy.state == 0)
  7963. {
  7964. returnErrorMsg("发票还未开具");
  7965. return;
  7966. }
  7967. string[] billOrderList = entiy.billOrderId.Split(',');
  7968. int iTag = 0;
  7969. entiy.fplsh = "";
  7970. entiy.fpdm = "";
  7971. entiy.fphm = "";
  7972. foreach (string billOrderId in billOrderList)
  7973. {
  7974. iTag++;
  7975. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7976. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7977. {
  7978. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7979. try
  7980. {
  7981. Invoicing_get_response_Obj iObj = null;
  7982. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7983. if (iObj != null)
  7984. {
  7985. entiy.state = 2;
  7986. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7987. entiy.fpdm += iObj.list[0].c_fpdm;
  7988. entiy.fphm += iObj.list[0].c_fphm;
  7989. if (iTag < billOrderList.Length)
  7990. {
  7991. entiy.fplsh += ",";
  7992. entiy.fpdm += ",";
  7993. entiy.fphm += ",";
  7994. }
  7995. entiy.Update();
  7996. }
  7997. StringBuilder sql = new StringBuilder();
  7998. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7999. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8000. returnSuccessMsg("开票成功");
  8001. }
  8002. catch (Exception ex)
  8003. {
  8004. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8005. }
  8006. return;
  8007. }
  8008. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8009. {
  8010. var res_obj = new
  8011. {
  8012. data = "开票中"
  8013. };
  8014. string ro_json = JsonConvert.SerializeObject(res_obj);
  8015. returnSuccess(ro_json);
  8016. return;
  8017. }
  8018. else
  8019. {
  8020. int eidx = res.IndexOf("c_resultmsg");
  8021. int lidx = res.IndexOf("c_status");
  8022. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8023. entiy.state = 5;
  8024. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8025. entiy.Update();
  8026. returnErrorMsg("开票失败");
  8027. return;
  8028. }
  8029. }
  8030. }
  8031. }
  8032. catch (Exception ex)
  8033. {
  8034. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8035. }
  8036. return;
  8037. }
  8038. }
  8039. public void get_erp_invoicing()
  8040. {
  8041. if (UrlPostParmsCheck("id"))
  8042. {
  8043. try
  8044. {
  8045. string id = GetPostString("id");
  8046. CeErpBill entiy = CeErpBill.Get(id);
  8047. if (entiy != null)
  8048. {
  8049. if (entiy.state == 0)
  8050. {
  8051. returnErrorMsg("发票还未开具");
  8052. return;
  8053. }
  8054. if (entiy.sendType == "纸质发票")
  8055. {
  8056. if (entiy.img.Length <= 0)
  8057. {
  8058. returnErrorMsg("查无纸质发票");
  8059. return;
  8060. }
  8061. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8062. returnSuccess(returnres);
  8063. return;
  8064. }
  8065. string[] billOrderList = entiy.billOrderId.Split(',');
  8066. int iTag = 0;
  8067. string fpUrl = "";
  8068. entiy.fplsh = "";
  8069. entiy.fpdm = "";
  8070. entiy.fphm = "";
  8071. foreach (string billOrderId in billOrderList)
  8072. {
  8073. iTag++;
  8074. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8075. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8076. {
  8077. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8078. Invoicing_get_response_Obj iObj = null;
  8079. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8080. if (iObj != null)
  8081. {
  8082. //entiy.state = 2;
  8083. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8084. entiy.fpdm += iObj.list[0].c_fpdm;
  8085. entiy.fphm += iObj.list[0].c_fphm;
  8086. if (iTag < billOrderList.Length)
  8087. {
  8088. entiy.fplsh += ",";
  8089. entiy.fpdm += ",";
  8090. entiy.fphm += ",";
  8091. }
  8092. entiy.Update();
  8093. fpUrl += iObj.list[0].c_url + ",";
  8094. }
  8095. //returnSuccess(res);
  8096. StringBuilder sql = new StringBuilder();
  8097. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8098. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8099. }
  8100. else
  8101. {
  8102. int eidx = res.IndexOf("c_resultmsg");
  8103. //int lidx = res.IndexOf("c_status");
  8104. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8105. //开票失败
  8106. entiy.state = 5;
  8107. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8108. entiy.Update();
  8109. returnErrorMsg("开票失败");
  8110. return;
  8111. }
  8112. }
  8113. var returnObj = new
  8114. {
  8115. data = fpUrl
  8116. };
  8117. string ro_json = JsonConvert.SerializeObject(returnObj);
  8118. returnSuccess(ro_json);
  8119. }
  8120. }
  8121. catch (Exception ex)
  8122. {
  8123. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8124. }
  8125. return;
  8126. }
  8127. }
  8128. public void save_erp_billimg()
  8129. {
  8130. if (UrlPostParmsCheck("id"))
  8131. {
  8132. string eid = GetPostString("id");
  8133. CeErpBill bill_entity = null;
  8134. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8135. if (bill_entity != null)
  8136. {
  8137. bill_entity.img = GetPostString("img");
  8138. bill_entity.executeTime = DateTime.Now;
  8139. bill_entity.state = 2;
  8140. bill_entity.Update();
  8141. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8142. returnSuccessMsg("保存成功");
  8143. }
  8144. return;
  8145. }
  8146. }
  8147. public void upd_erp_billreturnback()
  8148. {
  8149. if (UrlPostParmsCheck("id"))
  8150. {
  8151. int eid = GetPostInt("id");
  8152. CeErpBill bill_entity = null;
  8153. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8154. if (bill_entity != null)
  8155. {
  8156. bill_entity.state = 3;
  8157. bill_entity.returnReason = GetPostString("reason");
  8158. bill_entity.Update();
  8159. returnSuccessMsg("驳回成功!");
  8160. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8161. }
  8162. return;
  8163. }
  8164. }
  8165. public void cancel_erp_bill()
  8166. {
  8167. if (UrlPostParmsCheck("id"))
  8168. {
  8169. int eid = GetPostInt("id");
  8170. int detailValue = GetPostInt("detailvalue");
  8171. CeErpBill bill_entity = null;
  8172. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8173. string cres = "";
  8174. string gres = "";
  8175. if (bill_entity != null)
  8176. {
  8177. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8178. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8179. {
  8180. int iTag = 0;
  8181. bill_entity.fplsh = "";
  8182. bill_entity.fpdm = "";
  8183. bill_entity.fphm = "";
  8184. foreach (string billOrderId in billOrderList)
  8185. {
  8186. iTag++;
  8187. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8188. if (gres.IndexOf("success") != -1)
  8189. {
  8190. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8191. Invoicing_get_response_Obj iObj = null;
  8192. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8193. if (iObj != null)
  8194. {
  8195. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8196. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8197. bill_entity.fphm += iObj.list[0].c_fphm;
  8198. if (iTag < billOrderList.Length)
  8199. {
  8200. bill_entity.fplsh += ",";
  8201. bill_entity.fpdm += ",";
  8202. bill_entity.fphm += ",";
  8203. }
  8204. bill_entity.Update();
  8205. }
  8206. }
  8207. else
  8208. {
  8209. returnErrorMsg(gres);
  8210. return;
  8211. }
  8212. }
  8213. }
  8214. if (bill_entity.sendType == "纸质发票")
  8215. {
  8216. //作废
  8217. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8218. //if (DateTime.Now.Month == extime.Month)
  8219. //{
  8220. //cres = taobaoHelper.cancel_invoicing(eid);
  8221. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8222. //{
  8223. bill_entity.state = 4;//已作废
  8224. bill_entity.Update();
  8225. returnSuccessMsg("发票已作废");
  8226. return;
  8227. //}
  8228. //else
  8229. //{
  8230. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8231. // bill_entity.Update();
  8232. // returnErrorMsg(cres);
  8233. // return;
  8234. //}
  8235. //}
  8236. //else
  8237. //{
  8238. // returnErrorMsg("纸质发票只能作废本月的发票");
  8239. // return;
  8240. //}
  8241. }
  8242. //红冲
  8243. int redTag = 0;
  8244. string[] fpdmList = bill_entity.fpdm.Split(',');
  8245. string[] fphmList = bill_entity.fphm.Split(',');
  8246. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8247. {
  8248. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8249. return;
  8250. }
  8251. foreach (string billOrderId in billOrderList)
  8252. {
  8253. redTag++;
  8254. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8255. cres += onecres;
  8256. cres += ",";
  8257. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8258. {
  8259. bill_entity.state = 4;//已作废
  8260. //bill_entity.Update();
  8261. //returnSuccessMsg("发票已红冲");
  8262. }
  8263. else if (onecres.IndexOf("重复冲红") != -1)
  8264. {
  8265. bill_entity.state = 4;//已作废
  8266. //bill_entity.Update();
  8267. //returnSuccessMsg("发票已红冲");
  8268. }
  8269. else
  8270. {
  8271. string errmsg = commonHelper.KeepChinese(onecres);
  8272. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8273. }
  8274. }
  8275. bill_entity.Update();
  8276. if (cres.IndexOf("失败") != -1)
  8277. returnErrorMsg("红冲失败");
  8278. else
  8279. returnSuccessMsg("发票已红冲");
  8280. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8281. return;
  8282. }
  8283. return;
  8284. }
  8285. }
  8286. public void del_erp_billorder()
  8287. {
  8288. if (UrlPostParmsCheck("id"))
  8289. {
  8290. string eid = GetPostString("id");
  8291. CeErpBill.Del(eid);
  8292. CeErpBill bill = CeErpBill.Get(eid);
  8293. if (bill != null)
  8294. {
  8295. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8296. }
  8297. returnSuccessMsg("删除成功");
  8298. }
  8299. }
  8300. public void finish_erp_bill()
  8301. {
  8302. if (UrlPostParmsCheck("ids"))
  8303. {
  8304. string eids = GetPostString("ids");
  8305. string[] list = eids.Split(',');
  8306. foreach (string eid in list)
  8307. {
  8308. CeErpBill bill = CeErpBill.Get(eid);
  8309. if (bill != null)
  8310. {
  8311. bill.state = 2;
  8312. bill.Update();
  8313. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8314. }
  8315. }
  8316. returnSuccessMsg("操作成功");
  8317. }
  8318. }
  8319. public void get_erp_returncash()
  8320. {
  8321. DataStruct dStruct = GetPostStruct();
  8322. List<string> lw = new List<string>();
  8323. string tid = GetPostString("tid");
  8324. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8325. string shopname = GetPostString("shopname");
  8326. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8327. string buyernick = GetPostString("buyer_nick");
  8328. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8329. string customer = GetPostString("customer");
  8330. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8331. string returndate1 = GetPostString("returndate1");
  8332. string returndate2 = GetPostString("returndate2");
  8333. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8334. if (dw.Length > 0) lw.Add(dw);
  8335. string finishDate1 = GetPostString("finishdate1");
  8336. string finishDate2 = GetPostString("finishdate2");
  8337. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8338. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8339. string returntype = GetPostString("returntype");
  8340. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8341. string returnvstate = GetPostString("returnvstate");
  8342. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8343. dStruct.Order = "created desc";
  8344. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8345. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8346. writeGridDataTableJson(dStruct.TotalCount, dt);
  8347. }
  8348. public void get_erp_staygoods()
  8349. {
  8350. DataStruct dStruct = GetPostStruct();
  8351. List<string> lw = new List<string>();
  8352. string tid = GetPostString("tid");
  8353. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8354. string shopname = GetPostString("shopname");
  8355. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8356. string wangwang = GetPostString("wangwang");
  8357. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8358. string customer = GetPostString("customer");
  8359. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8360. string returndate1 = GetPostString("returndate1");
  8361. string returndate2 = GetPostString("returndate2");
  8362. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8363. if (dw.Length > 0) lw.Add(dw);
  8364. string finishDate1 = GetPostString("finishdate1");
  8365. string finishDate2 = GetPostString("finishdate2");
  8366. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8367. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8368. string returnvstate = GetPostString("returnvstate");
  8369. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8370. string persuadetype = GetPostString("persuadetype");
  8371. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8372. string customerOrg = GetPostString("customerOrg");
  8373. if (customerOrg.Length > 0)
  8374. {
  8375. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8376. }
  8377. dStruct.Order = "creata_time desc";
  8378. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8379. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8380. writeGridDataTableJson(dStruct.TotalCount, dt);
  8381. }
  8382. public void upd_erp_staygoods()
  8383. {
  8384. if (UrlPostParmsCheck("id"))
  8385. {
  8386. int eid = GetPostInt("id");
  8387. CeErpStayGoods entity = null;
  8388. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8389. if (entity != null)
  8390. {
  8391. entity.audit_type = 1;
  8392. entity.audit_time = DateTime.Now;
  8393. entity.audit_u_id = CurrentUser.UserID;
  8394. entity.audit_u_name = CurrentUser.UserName;
  8395. entity.Update();
  8396. returnSuccessMsg("审核成功!");
  8397. return;
  8398. }
  8399. returnErrorMsg("找不到订单记录");
  8400. }
  8401. }
  8402. public void upd_erp_stayGoodsback()
  8403. {
  8404. if (UrlPostParmsCheck("id"))
  8405. {
  8406. int eid = GetPostInt("id");
  8407. CeErpStayGoods entity = null;
  8408. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8409. if (entity != null)
  8410. {
  8411. entity.audit_text = GetPostString("reason");
  8412. entity.audit_type = 2;
  8413. entity.audit_time = DateTime.Now;
  8414. entity.audit_u_id = CurrentUser.UserID;
  8415. entity.audit_u_name = CurrentUser.UserName;
  8416. entity.Update();
  8417. returnSuccessMsg("退回成功!");
  8418. return;
  8419. }
  8420. returnErrorMsg("找不到订单记录");
  8421. }
  8422. }
  8423. public void upd_erp_returncashverify()
  8424. {
  8425. if (UrlPostParmsCheck("ID"))
  8426. {
  8427. int eid = GetPostInt("ID");
  8428. CeErpReturnCash entity = null;
  8429. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8430. if (entity != null)
  8431. {
  8432. entity.cashstate = 1;
  8433. entity.verifytime = DateTime.Now;
  8434. entity.verifyuserid = CurrentUser.UserID;
  8435. entity.Update();
  8436. returnSuccessMsg("审核成功!");
  8437. return;
  8438. }
  8439. returnErrorMsg("找不到订单记录");
  8440. }
  8441. }
  8442. public void upd_all_erp_returncashverify()
  8443. {
  8444. if (UrlPostParmsCheck("ID"))
  8445. {
  8446. String[] list = GetPostString("ID").Split(',');
  8447. CeErpReturnCash entity = null;
  8448. for (int i = 0; i < list.Length; i++)
  8449. {
  8450. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8451. if (entity != null)
  8452. {
  8453. if (entity.cashstate == 1)
  8454. {
  8455. returnErrorMsg("已审核过的订单不需要在审核!");
  8456. return;
  8457. }
  8458. entity.cashstate = 1;
  8459. entity.verifytime = DateTime.Now;
  8460. entity.verifyuserid = CurrentUser.UserID;
  8461. entity.Update();
  8462. }
  8463. }
  8464. returnSuccessMsg("审核成功!");
  8465. return;
  8466. }
  8467. }
  8468. public void upd_erp_returncashback()
  8469. {
  8470. if (UrlPostParmsCheck("ID"))
  8471. {
  8472. int eid = GetPostInt("ID");
  8473. CeErpReturnCash entity = null;
  8474. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8475. if (entity != null)
  8476. {
  8477. entity.backreason = GetPostString("reason");
  8478. entity.cashstate = 2;
  8479. entity.verifytime = DateTime.Now;
  8480. entity.verifyuserid = CurrentUser.UserID;
  8481. entity.Update();
  8482. returnSuccessMsg("退回成功!");
  8483. return;
  8484. }
  8485. returnErrorMsg("找不到订单记录");
  8486. }
  8487. }
  8488. public void upd_erp_returnprice()
  8489. {
  8490. if (UrlPostParmsCheck("ID"))
  8491. {
  8492. int eid = GetPostInt("ID");
  8493. CeErpReturnCash entity = null;
  8494. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8495. if (entity != null)
  8496. {
  8497. if (entity.cashstate == 1)
  8498. {
  8499. returnErrorMsg("审核通过了不能改");
  8500. return;
  8501. }
  8502. entity.returnprice = GetPostDouble("returnprice");
  8503. entity.Update();
  8504. returnSuccessMsg("修改成功!");
  8505. return;
  8506. }
  8507. returnErrorMsg("找不到订单记录");
  8508. }
  8509. }
  8510. public void del_erp_returncash()
  8511. {
  8512. if (UrlPostParmsCheck("ID"))
  8513. {
  8514. int eid = GetPostInt("ID");
  8515. CeErpReturnCash.Del(eid);
  8516. returnSuccessMsg("操作成功");
  8517. return;
  8518. }
  8519. }
  8520. public void test_for_do_sql()
  8521. {
  8522. string sql = GetPostString("sqlstr");
  8523. if (sql.Length > 0)
  8524. {
  8525. try
  8526. {
  8527. DbHelper.DbConn.ExecuteNonQuery(sql);
  8528. var res_obj = new
  8529. {
  8530. data = "成功",
  8531. };
  8532. string ro_json = JsonConvert.SerializeObject(res_obj);
  8533. returnSuccess(ro_json);
  8534. }
  8535. catch (Exception ex)
  8536. {
  8537. var res_obj = new
  8538. {
  8539. data = ex.Message,
  8540. };
  8541. string ro_json = JsonConvert.SerializeObject(res_obj);
  8542. returnSuccess(ro_json);
  8543. }
  8544. }
  8545. }
  8546. public void get_user_info()
  8547. {
  8548. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8549. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8550. }
  8551. public void get_total_data()
  8552. {
  8553. int userId = CurrentUser.UserID;
  8554. string sql = "";
  8555. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8556. {
  8557. 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);
  8558. }
  8559. else
  8560. {
  8561. 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 " +
  8562. "(select ID from CE_ErpUser where ID = {0}) d " +
  8563. "left join " +
  8564. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8565. ") a on d.ID = a.id left join " +
  8566. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8567. ") b on a.id = b.id1 left join" +
  8568. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8569. ") c on a.id = c.id2;", userId);
  8570. }
  8571. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8572. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8573. }
  8574. public void get_date_area_total_data2()
  8575. {
  8576. int userId = CurrentUser.UserID;
  8577. string date_type = GetPostString("timetype");
  8578. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8579. string sql = "";
  8580. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8581. {
  8582. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8583. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8584. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8585. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8586. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8587. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8588. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8589. ") a on e.ID = a.id left join " +
  8590. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8591. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8592. ") b on a.id = b.id1 " +
  8593. "left join " +
  8594. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8595. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8596. ") c on a.id = c.id2 " +
  8597. "left join " +
  8598. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8599. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8600. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8601. }
  8602. else
  8603. {
  8604. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8605. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8606. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8607. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8608. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8609. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8610. ") a on e.ID = a.id left join " +
  8611. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8612. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8613. ") c on a.id = c.id2 " +
  8614. "left join " +
  8615. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8616. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8617. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8618. }
  8619. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8620. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8621. }
  8622. public void get_date_area_total_data()
  8623. {
  8624. int userId = CurrentUser.UserID;
  8625. string date_type = GetPostString("timetype");
  8626. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8627. string date1 = searchDT[0].ToString();
  8628. string date2 = searchDT[1].ToString();
  8629. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8630. {
  8631. SqlParameter[] sqlParameter ={
  8632. new SqlParameter("@userId", SqlDbType.Int,4),
  8633. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8634. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8635. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8636. };
  8637. sqlParameter[0].Value = userId;
  8638. sqlParameter[1].Value = date1;
  8639. sqlParameter[2].Value = date2;
  8640. sqlParameter[3].Direction = ParameterDirection.Output;
  8641. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8642. string res = sqlParameter[3].Value.ToString();
  8643. var res_obj = new
  8644. {
  8645. data = res
  8646. };
  8647. string ro_json = JsonConvert.SerializeObject(res_obj);
  8648. returnSuccess(ro_json);
  8649. }
  8650. else
  8651. {
  8652. SqlParameter[] sqlParameter ={
  8653. new SqlParameter("@userId", SqlDbType.Int,4),
  8654. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8655. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8656. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8657. };
  8658. sqlParameter[0].Value = userId;
  8659. sqlParameter[1].Value = date1;
  8660. sqlParameter[2].Value = date2;
  8661. sqlParameter[3].Direction = ParameterDirection.Output;
  8662. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8663. string res = sqlParameter[3].Value.ToString();
  8664. var res_obj = new
  8665. {
  8666. data = res
  8667. };
  8668. string ro_json = JsonConvert.SerializeObject(res_obj);
  8669. returnSuccess(ro_json);
  8670. }
  8671. //writeGridDataViewJson(dt.Rows.Count, dv);
  8672. }
  8673. public void get_order_list()
  8674. {
  8675. string strFields = GetPostString("paraFields");
  8676. string strOrder = GetPostString("paraOrder");
  8677. string strWhere = GetPostString("paraWhere");
  8678. string strPageSize = GetPostString("paraPageSize");
  8679. DataStruct dStruct = GetPostStruct();
  8680. dStruct.PageSize = int.Parse(strPageSize);
  8681. dStruct.Fileds = strFields;
  8682. dStruct.Order = strOrder;
  8683. dStruct.MainWhere = strWhere;
  8684. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8685. writeGridDataTableJson(dStruct.TotalCount, dt);
  8686. }
  8687. ////获取待开始订单列表
  8688. //public void get_wait_design_order_list()
  8689. //{
  8690. // string date_type = GetPostString("date_type");
  8691. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8692. // DataStruct dStruct = GetPostStruct();
  8693. // dStruct.PageSize = 1000;
  8694. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8695. // List<string> lw = new List<string>();
  8696. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8697. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8698. // dStruct.Order = "WaitDesignTime asc";
  8699. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8700. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8701. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8702. //}
  8703. //获取完成单量排名
  8704. public void get_finish_order_count_ranking()
  8705. {
  8706. /* string date_type = GetPostString("date_type");
  8707. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8708. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8709. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8710. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8711. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8712. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8713. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8714. writeGridDataTableJson(0, new DataTable());
  8715. }
  8716. public void get_finish_order_amount_ranking()
  8717. {
  8718. /*string date_type = GetPostString("date_type");
  8719. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8720. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8721. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8722. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8723. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8724. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8725. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8726. writeGridDataTableJson(0, new DataTable());
  8727. }
  8728. public void get_finish_refund_count_ranking()
  8729. {
  8730. string date_type = GetPostString("date_type");
  8731. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8732. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8733. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8734. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8735. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8736. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8737. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8738. writeGridDataTableJson(dt.Rows.Count, dt);
  8739. }
  8740. public void get_finish_refund_amount_ranking()
  8741. {
  8742. string date_type = GetPostString("date_type");
  8743. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8744. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8745. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8746. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8747. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8748. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8749. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8750. writeGridDataTableJson(dt.Rows.Count, dt);
  8751. }
  8752. public void set_erp_finishorder_director()
  8753. {
  8754. if (UrlPostParmsCheck("ctid"))
  8755. {
  8756. string eid = GetPostString("ctid");
  8757. CeErpTradeCell entity = null;
  8758. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8759. if (entity != null)
  8760. {
  8761. entity.OrderState = 8;
  8762. entity.Update();
  8763. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8764. returnSuccessMsg("操作成功!");
  8765. return;
  8766. }
  8767. returnErrorMsg("找不到记录");
  8768. }
  8769. }
  8770. public void get_erp_placeregistlist()
  8771. {
  8772. DataStruct dStruct = GetPostStruct();
  8773. List<string> lw = new List<string>();
  8774. string outsid = GetPostString("outsid");
  8775. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8776. string memo = GetPostString("memo");
  8777. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8778. string filename = GetPostString("filename");
  8779. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8780. string islate = GetPostString("islate");
  8781. if (islate.Length > 0)
  8782. {
  8783. if (islate == "1")
  8784. lw.Add(string.Format("OutLate>0"));
  8785. else
  8786. lw.Add(string.Format("OutLate=0"));
  8787. }
  8788. string placedate1 = GetPostString("placedate1");
  8789. string placedate2 = GetPostString("placedate2");
  8790. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8791. if (dw.Length > 0) lw.Add(dw);
  8792. string deliveryDate1 = GetPostString("deliverydate1");
  8793. string deliveryDate2 = GetPostString("deliverydate2");
  8794. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8795. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8796. dStruct.Order = "ID desc";
  8797. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8798. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8799. writeGridDataTableJson(dStruct.TotalCount, dt);
  8800. }
  8801. public void ins_erp_placeregist()
  8802. {
  8803. if (UrlPostParmsCheck("id"))
  8804. {
  8805. string eid = GetPostString("id");
  8806. CeErpPlaceRegister entity = null;
  8807. if (eid == "0")//新增
  8808. {
  8809. entity = new CeErpPlaceRegister();
  8810. string xdTime = GetPostString("placeTime");
  8811. if (xdTime.Length > 0)
  8812. {
  8813. entity.PlactTime = Convert.ToDateTime(xdTime);
  8814. }
  8815. string fhTime = GetPostString("deliveryTime");
  8816. if (fhTime.Length > 0)
  8817. {
  8818. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8819. }
  8820. string preTime = GetPostString("preOutTime");
  8821. if (preTime.Length > 0)
  8822. {
  8823. entity.PreOutTime = Convert.ToDateTime(preTime);
  8824. }
  8825. entity.DeliveryCount = GetPostInt("deliveryCount");
  8826. entity.ReceiveCount = GetPostInt("receiveCount");
  8827. entity.OutSid = GetPostString("outSid");
  8828. entity.FileName = GetPostString("fileName");
  8829. entity.Memo = GetPostString("memo");
  8830. entity.AddUserId = CurrentUser.UserID;
  8831. entity.CreateTime = DateTime.Now;
  8832. entity.Img = GetPostString("img");
  8833. entity.Supplier = GetPostInt("supplier");
  8834. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8835. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8836. {
  8837. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8838. DateTime dt2 = (DateTime)entity.PreOutTime;
  8839. TimeSpan span = dt1.Subtract(dt2);
  8840. if (span.Days > 0)
  8841. {
  8842. entity.OutLate = span.Days;
  8843. }
  8844. }
  8845. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8846. entity.Create();
  8847. returnSuccessMsg("添加成功!");
  8848. return;
  8849. }
  8850. else //修改
  8851. {
  8852. entity = CeErpPlaceRegister.Get(eid);
  8853. if (entity != null)
  8854. {
  8855. string xdTime = GetPostString("placeTime");
  8856. if (xdTime.Length > 0)
  8857. {
  8858. entity.PlactTime = Convert.ToDateTime(xdTime);
  8859. }
  8860. string fhTime = GetPostString("deliveryTime");
  8861. if (fhTime.Length > 0)
  8862. {
  8863. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8864. }
  8865. string preTime = GetPostString("preOutTime");
  8866. if (preTime.Length > 0)
  8867. {
  8868. entity.PreOutTime = Convert.ToDateTime(preTime);
  8869. }
  8870. entity.DeliveryCount = GetPostInt("deliveryCount");
  8871. entity.ReceiveCount = GetPostInt("receiveCount");
  8872. if (entity.DeliveryCount == entity.ReceiveCount)
  8873. {
  8874. entity.CurState = "已完成";
  8875. }
  8876. else
  8877. {
  8878. entity.CurState = "未完成";
  8879. }
  8880. entity.OutSid = GetPostString("outSid");
  8881. entity.FileName = GetPostString("fileName");
  8882. entity.Memo = GetPostString("memo");
  8883. entity.Img = GetPostString("img");
  8884. entity.Supplier = GetPostInt("supplier");
  8885. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8886. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8887. {
  8888. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8889. DateTime dt2 = (DateTime)entity.PreOutTime;
  8890. TimeSpan span = dt1.Subtract(dt2);
  8891. if (span.Days > 0)
  8892. {
  8893. entity.OutLate = span.Days;
  8894. }
  8895. }
  8896. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8897. entity.Update();
  8898. returnSuccessMsg("修改成功");
  8899. return;
  8900. }
  8901. returnErrorMsg("找不到对应的记录");
  8902. return;
  8903. }
  8904. }
  8905. returnErrorMsg("缺少必要参数");
  8906. }
  8907. public void del_erp_placeregist()
  8908. {
  8909. string eid = GetPostString("id");
  8910. CeErpPlaceRegister.Del(eid);
  8911. returnSuccessMsg("删除成功!");
  8912. return;
  8913. }
  8914. public void ins_erp_placeregistbyorder()
  8915. {
  8916. string ctid = GetPostString("ctid");
  8917. if (ctid.Length > 0)
  8918. {
  8919. StringBuilder sql = new StringBuilder();
  8920. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8921. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8922. if (dt.Rows.Count > 0)
  8923. {
  8924. foreach (DataRow dr in dt.Rows)
  8925. {
  8926. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8927. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8928. entity.AddUserId = CurrentUser.UserID;
  8929. entity.tid = dr["tid"].ToString();
  8930. entity.Did = Convert.ToString(dr["ctid"]);
  8931. entity.splitTag = dr["SplitTag"].ToString();
  8932. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8933. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8934. if (pre_ctid.Length > 0)
  8935. {
  8936. sellmemo = sellmemo.Replace(pre_ctid, "");
  8937. }
  8938. sellmemo = sellmemo.Replace("[", "");
  8939. sellmemo = sellmemo.Replace("]", "");
  8940. entity.FileName = sellmemo;
  8941. string count = dr["ProductCount"].ToString();
  8942. int usecount = commonHelper.getIntCountFromString(count);
  8943. entity.DeliveryCount = usecount;
  8944. entity.CurState = "未完成";
  8945. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8946. {
  8947. entity.Supplier = 24;//dl手提袋定制
  8948. }
  8949. else
  8950. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8951. entity.CreateTime = DateTime.Now;
  8952. entity.Create();
  8953. }
  8954. returnSuccessMsg("操作成功");
  8955. return;
  8956. }
  8957. returnErrorMsg("没有找到对应订单");
  8958. return;
  8959. }
  8960. returnErrorMsg("缺少订单编号");
  8961. return;
  8962. }
  8963. public void get_erp_persuadelist()
  8964. {
  8965. DataStruct dStruct = GetPostStruct();
  8966. List<string> lw = new List<string>();
  8967. string ctid = GetPostString("ctid");
  8968. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8969. string shopname = GetPostString("shopname");
  8970. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8971. string buyernick = GetPostString("buyer_nick");
  8972. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8973. string customer = GetPostString("customer");
  8974. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8975. string returndate1 = GetPostString("returndate1");
  8976. string returndate2 = GetPostString("returndate2");
  8977. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8978. if (dw.Length > 0) lw.Add(dw);
  8979. string finishDate1 = GetPostString("finishdate1");
  8980. string finishDate2 = GetPostString("finishdate2");
  8981. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8982. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8983. string persuadetype = GetPostString("persuadetype");
  8984. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8985. string returnvstate = GetPostString("returnvstate");
  8986. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8987. dStruct.Order = "created desc";
  8988. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8989. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8990. writeGridDataTableJson(dStruct.TotalCount, dt);
  8991. }
  8992. public void upd_erp_returnpersuadeback()
  8993. {
  8994. if (UrlPostParmsCheck("ID"))
  8995. {
  8996. int eid = GetPostInt("ID");
  8997. CeErpPersuade entity = null;
  8998. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8999. if (entity != null)
  9000. {
  9001. entity.backreason = GetPostString("reason");
  9002. entity.pstate = 2;
  9003. entity.verifytime = DateTime.Now;
  9004. entity.verifyuserid = CurrentUser.UserID;
  9005. entity.Update();
  9006. returnSuccessMsg("退回成功!");
  9007. return;
  9008. }
  9009. returnErrorMsg("找不到订单记录");
  9010. }
  9011. }
  9012. public void upd_erp_returnpersuadeverify()
  9013. {
  9014. if (UrlPostParmsCheck("ID"))
  9015. {
  9016. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9017. {
  9018. returnErrorMsg("暂无权限审核");
  9019. return;
  9020. }
  9021. int eid = GetPostInt("ID");
  9022. CeErpPersuade entity = null;
  9023. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9024. if (entity != null)
  9025. {
  9026. entity.pstate = 1;
  9027. entity.verifytime = DateTime.Now;
  9028. entity.verifyuserid = CurrentUser.UserID;
  9029. entity.Update();
  9030. returnSuccessMsg("审核成功!");
  9031. return;
  9032. }
  9033. returnErrorMsg("找不到订单记录");
  9034. }
  9035. }
  9036. public void del_erp_persuade()
  9037. {
  9038. if (UrlPostParmsCheck("ID"))
  9039. {
  9040. int eid = GetPostInt("ID");
  9041. CeErpPersuade.Del(eid);
  9042. returnSuccessMsg("操作成功");
  9043. return;
  9044. }
  9045. }
  9046. public void get_erp_oldcustoupload()
  9047. {
  9048. DataStruct dStruct = GetPostStruct();
  9049. List<string> lw = new List<string>();
  9050. string buyernick = GetPostString("buyer_nick");
  9051. if (buyernick.Length > 0)
  9052. {
  9053. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9054. }
  9055. else
  9056. return;
  9057. dStruct.Order = "pay_time desc";
  9058. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9059. DataTable dt = null;
  9060. dt = WebCache.GetData("view_erptradecell", dStruct);
  9061. writeGridDataTableJson(dStruct.TotalCount, dt);
  9062. }
  9063. public void get_erp_checkorderlist()
  9064. {
  9065. DataStruct dStruct = GetPostStruct();
  9066. List<string> lw = new List<string>();
  9067. string tid = GetPostString("ctid");
  9068. if (tid.Length > 0)
  9069. {
  9070. string select_tid = getTidByCtid(tid);
  9071. lw.Add(string.Format("tid='{0}'", select_tid));
  9072. }
  9073. string shopname = GetPostString("shopname");
  9074. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9075. string buyernick = GetPostString("buyer_nick");
  9076. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9077. string customer = GetPostString("customer");
  9078. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9079. string design = GetPostString("design");
  9080. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9081. string orderState = GetPostString("orderState");
  9082. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9083. string address = GetPostString("address");
  9084. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9085. string sellermemo = GetPostString("seller_memo");
  9086. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9087. string supplier = GetPostString("supplier");
  9088. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9089. {
  9090. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9091. }
  9092. else
  9093. {
  9094. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9095. }
  9096. string date1 = GetPostString("date1");
  9097. string date2 = GetPostString("date2");
  9098. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9099. if (dw.Length > 0) lw.Add(dw);
  9100. string placedate1 = GetPostString("placedate1");
  9101. string placedate2 = GetPostString("placedate2");
  9102. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9103. if (fdw.Length > 0) lw.Add(fdw);
  9104. string price1 = GetPostString("price1");
  9105. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9106. string price2 = GetPostString("price2");
  9107. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9108. string checkst = GetPostString("checkstate");
  9109. if (checkst.Length > 0 && "10".Equals(checkst))
  9110. {
  9111. lw.Add(string.Format("CheckOut>0"));
  9112. }
  9113. else
  9114. {
  9115. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9116. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9117. }
  9118. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9119. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9120. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9121. writeGridDataTableJson(dStruct.TotalCount, dt);
  9122. }
  9123. public void ins_erp_startCheck()
  9124. {
  9125. if (UrlPostParmsCheck("ctid"))
  9126. {
  9127. string eid = GetPostString("ctid");
  9128. CeErpTradeCell entity = null;
  9129. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9130. if (entity != null)
  9131. {
  9132. entity.MemoOpt = 4;
  9133. entity.Update();
  9134. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9135. CeErpSukuraData.createInfo(entity.ctid, 6);
  9136. returnSuccessMsg("操作成功!");
  9137. return;
  9138. }
  9139. returnErrorMsg("找不到记录");
  9140. }
  9141. }
  9142. public void upd_erp_sendXlw()
  9143. {
  9144. if (UrlPostParmsCheck("ctid"))
  9145. {
  9146. string eid = GetPostString("ctid");
  9147. CeErpTradeCell entity = null;
  9148. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9149. if (entity != null)
  9150. {
  9151. if (entity.IsSendGift == 1)
  9152. {
  9153. returnErrorMsg("请勿重复标记");
  9154. return;
  9155. }
  9156. entity.IsSendGift = 1;
  9157. entity.Update();
  9158. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9159. returnSuccessMsg("操作成功!");
  9160. return;
  9161. }
  9162. returnErrorMsg("找不到记录");
  9163. }
  9164. }
  9165. public void cancel_sendXlw()
  9166. {
  9167. if (UrlPostParmsCheck("ctid"))
  9168. {
  9169. string eid = GetPostString("ctid");
  9170. CeErpTradeCell entity = null;
  9171. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9172. if (entity != null)
  9173. {
  9174. if (entity.IsSendGift == 0)
  9175. {
  9176. returnErrorMsg("未标记小礼物");
  9177. return;
  9178. }
  9179. entity.IsSendGift = 0;
  9180. entity.Update();
  9181. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9182. returnSuccessMsg("操作成功!");
  9183. return;
  9184. }
  9185. returnErrorMsg("找不到记录");
  9186. }
  9187. }
  9188. public void get_erp_designbill()
  9189. {
  9190. DataStruct dStruct = GetPostStruct();
  9191. List<string> lw = new List<string>();
  9192. int isMy = GetInt("my");
  9193. if (isMy == 1)
  9194. {
  9195. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9196. }
  9197. string tid = GetPostString("tid");
  9198. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9199. string userName = GetPostString("design");
  9200. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9201. string price1 = GetPostString("price1");
  9202. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9203. string price2 = GetPostString("price2");
  9204. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9205. string rePrice1 = GetPostString("rePrice1");
  9206. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9207. string rePrice2 = GetPostString("rePrice2");
  9208. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9209. string designerType = GetPostString("designerType");
  9210. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9211. string orderState = GetPostString("orderState");
  9212. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9213. string endTime1 = GetPostString("endTime1");
  9214. string endTime2 = GetPostString("endTime2");
  9215. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9216. if (dw.Length > 0) lw.Add(dw);
  9217. string isDk = GetPostString("isDk");
  9218. if (isDk == "1")
  9219. {
  9220. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9221. }
  9222. else if (isDk == "0")
  9223. {
  9224. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9225. }
  9226. dStruct.Order = "oid, create_time desc";
  9227. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9228. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9229. writeGridDataTableJson(dStruct.TotalCount, dt);
  9230. }
  9231. public void upd_erp_designerbill()
  9232. {
  9233. if (UrlPostParmsCheck("ID"))
  9234. {
  9235. string eid = GetPostString("ID");
  9236. CeErpDesignerBill entity = null;
  9237. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9238. if (entity != null)
  9239. {
  9240. if (GetPostDouble("designerpirce") > 0)
  9241. {
  9242. entity.realPrice = GetPostDouble("designerpirce");
  9243. entity.update_time = DateTime.Now;
  9244. entity.update_u_id = CurrentUser.UserID;
  9245. entity.update_u_name = CurrentUser.UserName;
  9246. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9247. entity.Update();
  9248. returnSuccessMsg("操作成功!");
  9249. return;
  9250. }
  9251. else
  9252. {
  9253. entity.price = GetPostDouble("price");
  9254. entity.update_time = DateTime.Now;
  9255. entity.update_u_id = CurrentUser.UserID;
  9256. entity.update_u_name = CurrentUser.UserName;
  9257. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9258. entity.Update();
  9259. returnSuccessMsg("操作成功!");
  9260. return;
  9261. }
  9262. }
  9263. returnErrorMsg("找不到记录");
  9264. }
  9265. }
  9266. public void audit_erp_designerbill()
  9267. {
  9268. if (UrlPostParmsCheck("ID"))
  9269. {
  9270. string eid = GetPostString("ID");
  9271. CeErpDesignerBill entity = null;
  9272. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9273. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9274. if (entity != null)
  9275. {
  9276. entity.realPrice = GetPostDouble("designerpirce");
  9277. entity.update_time = DateTime.Now;
  9278. entity.update_u_id = CurrentUser.UserID;
  9279. entity.update_u_name = CurrentUser.UserName;
  9280. entity.isAudit = 1;
  9281. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9282. entity.Update();
  9283. if (orderEntity != null)
  9284. {
  9285. orderEntity.IsReadTag = 3;
  9286. orderEntity.Update();
  9287. }
  9288. returnSuccessMsg("操作成功!");
  9289. return;
  9290. }
  9291. returnErrorMsg("找不到记录");
  9292. }
  9293. }
  9294. public void all_audit_erp_designerbill()
  9295. {
  9296. if (UrlPostParmsCheck("idList"))
  9297. {
  9298. string[] list = GetPostString("idList").Split(',');
  9299. CeErpDesignerBill entity = null;
  9300. for (int i = 0; i < list.Length; i++)
  9301. {
  9302. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9303. if (entity == null) return;
  9304. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9305. if (orderEntity == null) return;
  9306. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9307. entity.update_time = DateTime.Now;
  9308. entity.update_u_id = CurrentUser.UserID;
  9309. entity.update_u_name = CurrentUser.UserName;
  9310. entity.isAudit = 1;
  9311. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9312. entity.Update();
  9313. orderEntity.IsReadTag = 3;
  9314. orderEntity.Update();
  9315. }
  9316. returnSuccessMsg("操作成功!");
  9317. return;
  9318. }
  9319. }
  9320. public void get_erp_sameorders()
  9321. {
  9322. if (UrlPostParmsCheck("ctid"))
  9323. {
  9324. string eid = GetPostString("ctid");
  9325. CeErpTradeCell entity = null;
  9326. entity = CeErpTradeCell.GetByCtid(eid);
  9327. if (entity != null)
  9328. {
  9329. StringBuilder sql = new StringBuilder();
  9330. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9331. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9332. var res = new
  9333. {
  9334. data = dt.Rows.Count
  9335. };
  9336. string ro_jsond = JsonConvert.SerializeObject(res);
  9337. returnSuccess(ro_jsond);
  9338. return;
  9339. }
  9340. returnErrorMsg("未找到订单");
  9341. return;
  9342. }
  9343. returnErrorMsg("缺少必要的参数");
  9344. }
  9345. public void get_erp_islasthavesameorder()
  9346. {
  9347. if (UrlPostParmsCheck("ctid"))
  9348. {
  9349. string eid = GetPostString("ctid");
  9350. string[] ctidList = eid.Split(',');
  9351. StringBuilder sql = new StringBuilder();
  9352. string tisCtid = "";
  9353. foreach (string ctid in ctidList)
  9354. {
  9355. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9356. if (entity != null)
  9357. {
  9358. sql = new StringBuilder();
  9359. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9360. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9361. if (dth.Rows.Count > 0)
  9362. {
  9363. tisCtid += entity.ctid;
  9364. tisCtid += ",";
  9365. }
  9366. }
  9367. }
  9368. if (tisCtid.Length > 0)
  9369. {
  9370. var res = new
  9371. {
  9372. data = tisCtid
  9373. };
  9374. string ro_jsond = JsonConvert.SerializeObject(res);
  9375. returnSuccess(ro_jsond);
  9376. }
  9377. else
  9378. {
  9379. var res = new
  9380. {
  9381. data = ""
  9382. };
  9383. string ro_jsond = JsonConvert.SerializeObject(res);
  9384. returnSuccess(ro_jsond);
  9385. }
  9386. return;
  9387. }
  9388. returnErrorMsg("缺少必要的参数");
  9389. }
  9390. public void file_client_down_url()
  9391. {
  9392. if (!UrlPostParmsCheck("userId"))
  9393. {
  9394. returnErrorMsg("缺少必要的参数");
  9395. }
  9396. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9397. }
  9398. public void checkout_form_data()
  9399. {
  9400. if (!UrlPostParmsCheck("tid"))
  9401. {
  9402. returnErrorMsg("缺少必要的参数");
  9403. }
  9404. string tid = GetPostString("tid");
  9405. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9406. if (ceErpOrderFormData != null)
  9407. {
  9408. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9409. returnSuccess(ro_jsond);
  9410. return;
  9411. }
  9412. returnErrorMsg("尚未有文件!");
  9413. }
  9414. public void back_supplier_audit()
  9415. {
  9416. int userId = CurrentUser.UserID;
  9417. StringBuilder sql = new StringBuilder();
  9418. 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);
  9419. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9420. if (dt.Rows.Count > 0)
  9421. {
  9422. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9423. }
  9424. else
  9425. {
  9426. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9427. }
  9428. }
  9429. public void back_supplier_query()
  9430. {
  9431. string eid = GetPostString("ctid");
  9432. if (eid != "")
  9433. {
  9434. StringBuilder sql = new StringBuilder();
  9435. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9436. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9437. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9438. }
  9439. else
  9440. {
  9441. returnErrorMsg("找不到订单记录");
  9442. return;
  9443. }
  9444. }
  9445. public void verified_to_order()
  9446. {
  9447. int userId = CurrentUser.UserID;
  9448. StringBuilder sql = new StringBuilder();
  9449. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9450. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9451. if (dt.Rows.Count > 0)
  9452. {
  9453. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9454. }
  9455. else
  9456. {
  9457. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9458. }
  9459. }
  9460. public void upd_supplier_audit()
  9461. {
  9462. if (UrlPostParmsCheck("ctid"))
  9463. {
  9464. string eid = GetPostString("ctid");
  9465. string reason = GetPostString("returnreason");
  9466. CeErpTradeCell entity = null;
  9467. CeWithdraw withdraw = null;
  9468. withdraw = CeWithdraw.GetByTid(eid);
  9469. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9470. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9471. {
  9472. if (withdraw != null)
  9473. {
  9474. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9475. {
  9476. returnSuccessMsg("您没有权限操作!");
  9477. return;
  9478. }
  9479. else
  9480. {
  9481. if (reason.Equals("1"))
  9482. {
  9483. if (entity.OrderState == -1)
  9484. {
  9485. if (entity.FinishPlaceTime == null)
  9486. {
  9487. entity.OrderState = 2;
  9488. }
  9489. else
  9490. {
  9491. entity.OrderState = 6;
  9492. }
  9493. }
  9494. entity.Update();
  9495. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9496. if (withdraw != null)
  9497. {
  9498. withdraw.status = int.Parse(reason);
  9499. withdraw.Update();
  9500. }
  9501. returnSuccessMsg("操作成功!");
  9502. return;
  9503. }
  9504. else
  9505. {
  9506. withdraw.status = int.Parse(reason);
  9507. withdraw.acknowledgingtime = DateTime.Now;
  9508. withdraw.Update();
  9509. returnSuccessMsg("查看详细请点击线下订单查询");
  9510. return;
  9511. }
  9512. }
  9513. }
  9514. // 第一个字符是 'N'
  9515. }
  9516. if (eid[0] != 'N')
  9517. {
  9518. }
  9519. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9520. {
  9521. entity.IsVerifyToSupplier = false;
  9522. entity.IsReturn = 1;
  9523. entity.ReturnTime = DateTime.Now;
  9524. entity.ReturnReason = reason;
  9525. if (entity.OrderState == 6)
  9526. {
  9527. entity.OrderState = 5;
  9528. }
  9529. entity.Update();
  9530. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9531. if (withdraw != null)
  9532. {
  9533. withdraw.status = int.Parse(reason);
  9534. withdraw.Update();
  9535. }
  9536. returnSuccessMsg("操作成功!");
  9537. return;
  9538. }
  9539. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9540. {
  9541. ;
  9542. if (withdraw != null)
  9543. {
  9544. withdraw.status = int.Parse(reason);
  9545. withdraw.acknowledgingtime = DateTime.Now;
  9546. withdraw.Update();
  9547. returnSuccessMsg("供应商取消撤回!");
  9548. return;
  9549. }
  9550. }
  9551. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9552. {
  9553. if (entity.OrderState == -1)
  9554. {
  9555. if (entity.FinishPlaceTime == null)
  9556. {
  9557. entity.OrderState = 2;
  9558. }
  9559. else
  9560. {
  9561. entity.OrderState = 3;
  9562. }
  9563. commonHelper.getCytPrice(entity);
  9564. }
  9565. entity.Update();
  9566. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9567. if (withdraw != null)
  9568. {
  9569. withdraw.status = int.Parse(reason);
  9570. withdraw.Update();
  9571. }
  9572. returnSuccessMsg("操作成功!");
  9573. return;
  9574. }
  9575. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9576. {
  9577. if (withdraw == null)
  9578. {
  9579. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9580. return;
  9581. }
  9582. }
  9583. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9584. {
  9585. if (withdraw != null)
  9586. {
  9587. withdraw.status = int.Parse(reason);
  9588. withdraw.acknowledgingtime = DateTime.Now;
  9589. withdraw.Update();
  9590. returnSuccessMsg("查看详细请点击线下订单查询");
  9591. return;
  9592. }
  9593. }
  9594. return;
  9595. }
  9596. }
  9597. //校验报价
  9598. public void refund_order_tip()
  9599. {
  9600. int userid = CurrentUser.UserID;
  9601. int sectionId = CurrentUser.UserPost.OrgID;
  9602. StringBuilder sql = new StringBuilder();
  9603. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9604. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9605. List<string> ids = new List<string>();
  9606. if (dth.Rows.Count > 0)
  9607. {
  9608. foreach (DataRow dr in dth.Rows)
  9609. {
  9610. ids.Add(dr["ID"].ToString());
  9611. }
  9612. try
  9613. {
  9614. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9615. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9616. }
  9617. catch (Exception ex)
  9618. {
  9619. }
  9620. }
  9621. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9622. }
  9623. public void refund_order_Design()
  9624. {
  9625. int userid = CurrentUser.UserID;
  9626. int sectionId = CurrentUser.UserPost.OrgID;
  9627. StringBuilder sql = new StringBuilder();
  9628. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9629. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9630. List<string> ids = new List<string>();
  9631. if (dth.Rows.Count > 0)
  9632. {
  9633. foreach (DataRow dr in dth.Rows)
  9634. {
  9635. ids.Add(dr["ID"].ToString());
  9636. }
  9637. try
  9638. {
  9639. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9640. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9641. }
  9642. catch (Exception ex)
  9643. {
  9644. }
  9645. }
  9646. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9647. }
  9648. public void change_order_info()
  9649. {
  9650. int userid = CurrentUser.UserID;
  9651. StringBuilder sql = new StringBuilder();
  9652. 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);
  9653. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9654. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9655. }
  9656. public void change_win_mome()
  9657. {
  9658. if (UrlPostParmsCheck("id,ctid"))
  9659. {
  9660. string id = GetPostString("id");
  9661. string ctid = GetPostString("ctid");
  9662. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9663. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9664. if (ce == null || ceErpMessageTip == null)
  9665. {
  9666. returnSuccessMsg("未找到对应的订单!");
  9667. return;
  9668. }
  9669. int type = GetPostInt("type");
  9670. string content = GetPostString("content");
  9671. if (type == 0)
  9672. {
  9673. content = content.Replace("(", "(");
  9674. content = content.Replace(")", ")");
  9675. string check = MidStrEx(content, "(", ")").Trim();
  9676. if (string.IsNullOrEmpty(check))
  9677. {
  9678. returnSuccessMsg("文件名格式不正确");
  9679. return;
  9680. }
  9681. }
  9682. ce.seller_memo = content;
  9683. ce.Update();
  9684. ceErpMessageTip.isVisit = true;
  9685. ceErpMessageTip.Update();
  9686. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9687. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9688. ApiVo apiVo = new ApiVo();
  9689. apiVo.orderNumber = ce.ctid;
  9690. apiVo.actionName = "demandDesign";
  9691. apiVo.orderRemarks = content;
  9692. apiVo.demandExamine = type + 1;
  9693. designHelper.API_WorkCore(apiVo);//demandDesign
  9694. returnSuccessMsg("修改成功!");
  9695. }
  9696. }
  9697. public static string MidStrEx(string sourse, string startstr, string endstr)
  9698. {
  9699. string result = string.Empty;
  9700. int startindex, endindex;
  9701. try
  9702. {
  9703. startindex = sourse.IndexOf(startstr);
  9704. if (startindex == -1)
  9705. return result;
  9706. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9707. endindex = tmpstr.IndexOf(endstr);
  9708. if (endindex == -1)
  9709. return result;
  9710. result = tmpstr.Remove(endindex);
  9711. }
  9712. catch (Exception ex)
  9713. {
  9714. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9715. }
  9716. return result;
  9717. }
  9718. public void refund_order_list()
  9719. {
  9720. int userid = CurrentUser.UserID;
  9721. int sectionId = CurrentUser.UserPost.OrgID;
  9722. StringBuilder sql = new StringBuilder();
  9723. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9724. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9725. DataStruct dStruct = GetPostStruct();
  9726. DataTable dt = null;
  9727. List<string> ids = new List<string>();
  9728. List<string> tids = new List<string>();
  9729. if (dth.Rows.Count > 0)
  9730. {
  9731. foreach (DataRow dr in dth.Rows)
  9732. {
  9733. tids.Add("'" + dr["tid"].ToString() + "'");
  9734. ids.Add(dr["id"].ToString());
  9735. }
  9736. try
  9737. {
  9738. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9739. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9740. List<string> lw = new List<string>();
  9741. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9742. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9743. dt = WebCache.GetData("view_orderlist", dStruct);
  9744. }
  9745. catch (Exception ex)
  9746. {
  9747. }
  9748. }
  9749. writeGridDataTableJson(dStruct.TotalCount, dt);
  9750. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9751. }
  9752. //新增
  9753. public void order_batch_downloads()
  9754. {
  9755. string ceid = GetPostString("tid");
  9756. String[] tid = ceid.Split(',');
  9757. order_batch_caiyingtong(tid);
  9758. /* (string success, string errors) = UploadFiles(tid);
  9759. returnSuccessMsg(success + errors);*/
  9760. return;
  9761. }
  9762. //报价接口
  9763. public void Get_To_Quote()
  9764. {
  9765. string ceid = GetPostString("ctid");
  9766. if (ceid != null)
  9767. {
  9768. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9769. if (entity != null)
  9770. {
  9771. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9772. {
  9773. return;
  9774. }
  9775. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9776. double price = 0;
  9777. if (cp == null)
  9778. {
  9779. JObject jsonObject12 = new JObject
  9780. {
  9781. { "UserId", "77886" },
  9782. { "Pwd", "lt666888" },
  9783. { "Filename", entity.seller_memo }
  9784. };
  9785. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9786. JObject jsonObjects1 = JObject.Parse(response1);
  9787. string ms1g = (string)jsonObjects1["msg"];
  9788. if (ms1g == "报价成功")
  9789. {
  9790. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9791. string data = (string)jsonObject1["price"];
  9792. 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 + "');";
  9793. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9794. returnSuccessMsg("获取报价成功:" + data);
  9795. price = Convert.ToDouble(data);
  9796. }
  9797. else
  9798. {
  9799. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9800. return;
  9801. }
  9802. }
  9803. String[] beizhu = entity.seller_memo.Split('-');
  9804. String chanp = "";
  9805. if (beizhu.Length > 0)
  9806. {
  9807. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9808. }
  9809. else
  9810. {
  9811. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9812. }
  9813. JObject jsonObject = new JObject
  9814. {
  9815. { "UserId", "77886" },
  9816. { "Pwd", "lt666888" },
  9817. { "Filename", chanp }
  9818. };
  9819. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9820. JObject jsonObjects = JObject.Parse(response);
  9821. string msg = (string)jsonObjects["msg"];
  9822. if (msg == "报价成功")
  9823. {
  9824. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9825. string data = (string)jsonObject1["price"];
  9826. 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 + "');";
  9827. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9828. returnSuccessMsg("获取报价成功:" + data);
  9829. price = Convert.ToDouble(data);
  9830. }
  9831. else
  9832. {
  9833. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9834. return;
  9835. }
  9836. if (price > 0)
  9837. {
  9838. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9839. if (ceErpTradeCellExtend == null)
  9840. {
  9841. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9842. ceErpTradeCellExtend.ctid = entity.ctid;
  9843. ceErpTradeCellExtend.payment_cyt = price;
  9844. ceErpTradeCellExtend.Create();
  9845. }
  9846. else
  9847. {
  9848. ceErpTradeCellExtend.payment_cyt = price;
  9849. ceErpTradeCellExtend.Update();
  9850. }
  9851. }
  9852. return;
  9853. }
  9854. }
  9855. else
  9856. {
  9857. returnErrorMsg("请至少选择一条数据");
  9858. return;
  9859. }
  9860. }
  9861. //新增
  9862. public void order_To_Supplier()
  9863. {
  9864. string ceid = GetPostString("tid");
  9865. String[] tid = ceid.Split(',');
  9866. if (tid.Length > 0)
  9867. {
  9868. try
  9869. {
  9870. for (int i = 0; i < tid.Length; i++)
  9871. {
  9872. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9873. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9874. entity.SupplierId = suid;
  9875. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9876. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9877. entity.Update();
  9878. }
  9879. }
  9880. catch (Exception ex)
  9881. {
  9882. returnErrorMsg("自动匹配供应商失败");
  9883. return;
  9884. }
  9885. }
  9886. else
  9887. {
  9888. returnErrorMsg("请至少选择一条数据");
  9889. return;
  9890. }
  9891. returnSuccessMsg("自动匹配供应商成功");
  9892. return;
  9893. }
  9894. public (string, string) UploadFiles(string[] urls)
  9895. {
  9896. string success = "";
  9897. string errors = "";
  9898. int userid = CurrentUser.UserID;
  9899. foreach (string url in urls)
  9900. {
  9901. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9902. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9903. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9904. {
  9905. JObject jsonObject = new JObject
  9906. {
  9907. { "Userid", "77886" },
  9908. { "pwd", "cyt86435015" },
  9909. { "content", base64FileContent },
  9910. { "ext", Path.GetExtension(fileName) }
  9911. };
  9912. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9913. JObject jsonObjects = JObject.Parse(response);
  9914. string msg = (string)jsonObjects["msg"];
  9915. if (msg.Equals("上传成功"))
  9916. {
  9917. success += url + " 上传成功";
  9918. }
  9919. else
  9920. {
  9921. errors += url + " 上传失败";
  9922. }
  9923. }
  9924. else
  9925. {
  9926. errors += url + " 格式出现问题";
  9927. }
  9928. }
  9929. if (urls.Length == 0)
  9930. {
  9931. return (success, errors);
  9932. }
  9933. return (success, errors);
  9934. }
  9935. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9936. {
  9937. return true; //总是接受
  9938. }
  9939. public static string HttpPost(string url, string param = null)
  9940. {
  9941. HttpWebRequest request;
  9942. //如果是发送HTTPS请求
  9943. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9944. {
  9945. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9946. request = WebRequest.Create(url) as HttpWebRequest;
  9947. request.ProtocolVersion = HttpVersion.Version10;
  9948. }
  9949. else
  9950. {
  9951. request = WebRequest.Create(url) as HttpWebRequest;
  9952. }
  9953. request.Method = "POST";
  9954. request.ContentType = "application/json";
  9955. request.Accept = "*/*";
  9956. request.Timeout = 120000;
  9957. request.AllowAutoRedirect = false;
  9958. StreamWriter requestStream = null;
  9959. WebResponse response = null;
  9960. string responseStr = null;
  9961. try
  9962. {
  9963. requestStream = new StreamWriter(request.GetRequestStream());
  9964. requestStream.Write(param);
  9965. requestStream.Close();
  9966. response = request.GetResponse();
  9967. if (response != null)
  9968. {
  9969. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9970. responseStr = reader.ReadToEnd();
  9971. reader.Close();
  9972. }
  9973. }
  9974. catch (Exception ex)
  9975. {
  9976. return ex.Message;
  9977. }
  9978. finally
  9979. {
  9980. request = null;
  9981. requestStream = null;
  9982. response = null;
  9983. }
  9984. return responseStr;
  9985. }
  9986. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9987. {
  9988. string base64FileContent;
  9989. string fileName;
  9990. using (WebClient webClient = new WebClient())
  9991. {
  9992. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9993. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9994. {
  9995. using (Stream stream = response.GetResponseStream())
  9996. {
  9997. using (MemoryStream memoryStream = new MemoryStream())
  9998. {
  9999. stream.CopyTo(memoryStream);
  10000. byte[] fileBytes = memoryStream.ToArray();
  10001. base64FileContent = Convert.ToBase64String(fileBytes);
  10002. fileName = response.Headers["Content-Disposition"];
  10003. if (!string.IsNullOrEmpty(fileName))
  10004. {
  10005. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10006. if (index >= 0)
  10007. {
  10008. fileName = fileName.Substring(index + 9).Trim('\"');
  10009. }
  10010. }
  10011. else
  10012. {
  10013. fileName = Path.GetFileName(downloadUrl);
  10014. }
  10015. }
  10016. }
  10017. }
  10018. }
  10019. return (fileName, base64FileContent);
  10020. }
  10021. //新增
  10022. public void order_batch_caiyingtong(string[] downloadUrls)
  10023. {
  10024. try
  10025. {
  10026. //遍历文件
  10027. DataStruct dStruct = GetPostStruct();
  10028. DataTable dt = null;
  10029. int userid = CurrentUser.UserID;
  10030. List<string> ids = new List<string>();//失败组
  10031. List<string> tids = new List<string>();
  10032. using (WebClient webClient = new WebClient())
  10033. {
  10034. foreach (var url in downloadUrls)
  10035. {
  10036. try
  10037. {
  10038. tids.Add("'" + url + "'");
  10039. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10040. if (entity != null)
  10041. {
  10042. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10043. if (cp == null)
  10044. {
  10045. JObject jsonObject = new JObject
  10046. {
  10047. { "Userid", "77886" },
  10048. { "pwd", "lt666888" },
  10049. { "Filename",entity.seller_memo }
  10050. };
  10051. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10052. JObject jsonObjects = JObject.Parse(response);
  10053. string msg = (string)jsonObjects["msg"];
  10054. if (msg == "报价成功")
  10055. {
  10056. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10057. DownloadAndConvertToBase64(url1);
  10058. }
  10059. else
  10060. {
  10061. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10062. }
  10063. }
  10064. else
  10065. {
  10066. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10067. JObject jsonObject = new JObject
  10068. {
  10069. { "Userid", "77886" },
  10070. { "pwd", "lt666888" },
  10071. { "Filename",chanp }
  10072. };
  10073. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10074. JObject jsonObjects = JObject.Parse(response);
  10075. string msg = (string)jsonObjects["msg"];
  10076. if (msg == "报价成功")
  10077. {
  10078. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10079. DownloadAndConvertToBase64(url1);
  10080. }
  10081. else
  10082. {
  10083. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10084. }
  10085. }
  10086. }
  10087. // 上传文件到FTP
  10088. }
  10089. catch (Exception ex)
  10090. {
  10091. Console.WriteLine($"An error occurred: {ex.Message}");
  10092. }
  10093. }
  10094. List<string> lw = new List<string>();
  10095. lw.Add(string.Format("( OrderState < 6 )"));
  10096. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10097. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10098. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10099. if (dt.Rows.Count > 0)
  10100. {
  10101. foreach (DataRow dr in dt.Rows)
  10102. {
  10103. ids.Add(dr["ctid"].ToString());
  10104. }
  10105. }
  10106. String ErrorMsgs = "";
  10107. foreach (String id in ids)
  10108. {
  10109. ErrorMsgs += id + ",";
  10110. }
  10111. if (ErrorMsgs.Length > 1)
  10112. {
  10113. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10114. }
  10115. if (ErrorMsgs.Length < 1)
  10116. {
  10117. ErrorMsgs = "上传成功";
  10118. returnSuccessMsg(ErrorMsgs);
  10119. }
  10120. else
  10121. {
  10122. returnErrorMsg("以下订单" + ErrorMsgs);
  10123. }
  10124. }
  10125. // 删除文件夹及其内容
  10126. /* Directory.Delete(localDirectory, true);*/
  10127. }
  10128. catch { }
  10129. }
  10130. public void get_center_data()
  10131. {
  10132. int userId = CurrentUser.UserID;
  10133. string postCode = CurrentUser.UserPost.Post.Code;
  10134. List<string> lw = new List<string>();
  10135. List<string> ww = new List<string>();
  10136. DateTime currentTime = DateTime.Now;
  10137. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10138. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10139. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10140. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10141. string sql = " SELECT ";
  10142. string startTime = "2023-10-01 11:22:31";
  10143. //设计
  10144. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10145. {
  10146. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10147. 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));
  10148. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10149. 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));
  10150. }
  10151. //客服
  10152. else if (postCode == "CustomerService" || postCode == "Director")
  10153. {
  10154. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10155. 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));
  10156. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10157. 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));
  10158. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10159. 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));
  10160. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10161. 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));
  10162. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10163. 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));
  10164. }
  10165. //售后
  10166. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10167. {
  10168. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10169. 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));
  10170. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10171. 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));
  10172. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10173. 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));
  10174. }
  10175. //下单部
  10176. else if (postCode == "Place" || postCode == "PlaceMr")
  10177. {
  10178. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10179. 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));
  10180. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10181. 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));
  10182. }
  10183. //车间
  10184. else if (postCode == "Supplier")
  10185. {
  10186. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10187. 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));
  10188. }
  10189. DataTable dt = new DataTable();
  10190. if (lw.Count > 0)
  10191. {
  10192. sql += string.Join(" , ", lw);
  10193. sql += " FROM ";
  10194. sql += string.Join(" , ", ww);
  10195. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10196. }
  10197. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10198. }
  10199. public void get_center_data_list()
  10200. {
  10201. int userId = CurrentUser.UserID;
  10202. string postCode = CurrentUser.UserPost.Post.Code;
  10203. string shopIds = CurrentUser.User.pemShop;
  10204. DataStruct dStruct = GetPostStruct();
  10205. List<string> lw = new List<string>();
  10206. DateTime currentTime = DateTime.Now;
  10207. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10208. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10209. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10210. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10211. string startTime = "2023-10-01 11:22:31";
  10212. int order_type = GetPostInt("order_type");
  10213. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10214. {
  10215. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10216. if (order_type == 0)
  10217. {
  10218. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10219. }
  10220. else if (order_type == 3)
  10221. {
  10222. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10223. }
  10224. else
  10225. {
  10226. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10227. }
  10228. }
  10229. //客服
  10230. if (postCode == "CustomerService" || postCode == "Director")
  10231. {
  10232. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10233. if (order_type == 0)
  10234. {
  10235. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10236. }
  10237. else if (order_type == 1)
  10238. {
  10239. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10240. }
  10241. else if (order_type == 2)
  10242. {
  10243. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10244. }
  10245. else if (order_type == 3)
  10246. {
  10247. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10248. }
  10249. else if (order_type == 4)
  10250. {
  10251. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10252. }
  10253. else
  10254. {
  10255. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10256. }
  10257. }
  10258. //售后
  10259. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10260. {
  10261. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10262. if (shopIds != "")
  10263. {
  10264. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10265. }
  10266. if (order_type == 2)
  10267. {
  10268. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10269. }
  10270. else if (order_type == 4)
  10271. {
  10272. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10273. }
  10274. else if (order_type == 5)
  10275. {
  10276. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10277. }
  10278. else
  10279. {
  10280. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10281. }
  10282. }
  10283. //下单部
  10284. if (postCode == "Place" || postCode == "PlaceMr")
  10285. {
  10286. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10287. if (shopIds != "")
  10288. {
  10289. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10290. }
  10291. else if (order_type == 1)
  10292. {
  10293. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10294. }
  10295. else if (order_type == 2)
  10296. {
  10297. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10298. }
  10299. else
  10300. {
  10301. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10302. }
  10303. }
  10304. //车间
  10305. if (postCode == "Supplier")
  10306. {
  10307. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10308. if (order_type == 5)
  10309. {
  10310. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10311. }
  10312. else
  10313. {
  10314. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10315. }
  10316. }
  10317. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10318. dStruct.Fileds = "tid,ctid";
  10319. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10320. writeGridDataTableJson(dStruct.TotalCount, dt);
  10321. }
  10322. public void aftersale_audit_master()
  10323. {
  10324. if (UrlPostParmsCheck("ctid"))
  10325. {
  10326. string ctid = GetPostString("ctid");
  10327. if (ctid.Length > 0)
  10328. {
  10329. bool result = aftersale_data_change(ctid);
  10330. if (result)
  10331. {
  10332. returnSuccessMsg("修改成功!");
  10333. return;
  10334. }
  10335. }
  10336. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10337. }
  10338. }
  10339. public void aftersale_batch_audit_master()
  10340. {
  10341. if (UrlPostParmsCheck("ctids"))
  10342. {
  10343. string ctids = GetPostString("ctids");
  10344. if (ctids.Length > 0)
  10345. {
  10346. List<string> list = new List<string>();
  10347. string[] ctid_list = ctids.Split(',');
  10348. foreach (var item in ctid_list)
  10349. {
  10350. bool result = aftersale_data_change(item);
  10351. if (!result)
  10352. {
  10353. list.Add(item);
  10354. }
  10355. }
  10356. if (list.Count > 0)
  10357. {
  10358. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10359. return;
  10360. }
  10361. returnSuccessMsg("修改成功!");
  10362. return;
  10363. }
  10364. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10365. }
  10366. }
  10367. public bool aftersale_data_change(string ctid)
  10368. {
  10369. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10370. if (ceErpTradeCell != null)
  10371. {
  10372. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10373. ceErpTradeCell.AfterSaleSupplierState = 0;
  10374. StringBuilder sql = new StringBuilder();
  10375. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10376. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10377. CeErpTradeResponsible.DelByTid(ctid, 0);
  10378. 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 == "不理赔")
  10379. {
  10380. CeErpTradeResponsible.DelByTid(ctid, 1);
  10381. ceErpTradeCell.AfterSaleSupplierState = 1;
  10382. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10383. ceErpTradeCell.AfterSaleState = 4;
  10384. }
  10385. else
  10386. {
  10387. ceErpTradeCell.AfterSaleState = 3;
  10388. }
  10389. bool needCyt = false;
  10390. if (dt != null)
  10391. {
  10392. if (dt.Rows.Count == 1)
  10393. {
  10394. bool isEnd = false;
  10395. foreach (DataRow dr in dt.Rows)
  10396. {
  10397. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10398. {
  10399. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10400. isEnd = true;
  10401. }
  10402. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10403. {
  10404. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10405. isEnd = true;
  10406. }
  10407. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10408. {
  10409. needCyt = true;
  10410. }
  10411. }
  10412. if (isEnd)
  10413. {
  10414. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10415. ceErpTradeCell.AfterSaleState = 4;
  10416. ceErpTradeCell.AfterSaleSupplierState = 1;
  10417. }
  10418. }
  10419. else
  10420. {
  10421. bool isAll = true;
  10422. foreach (DataRow dr in dt.Rows)
  10423. {
  10424. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10425. {
  10426. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10427. continue;
  10428. }
  10429. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10430. {
  10431. string path = "";
  10432. int OrgID = 0;
  10433. if (!Convert.IsDBNull(dr["OrgPath"]))
  10434. {
  10435. path = dr["OrgPath"].ToString();
  10436. }
  10437. if (!Convert.IsDBNull(dr["OrgID"]))
  10438. {
  10439. OrgID = Convert.ToInt32(dr["OrgID"]);
  10440. }
  10441. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10442. {
  10443. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10444. continue;
  10445. }
  10446. }
  10447. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10448. {
  10449. needCyt = true;
  10450. }
  10451. isAll = false;
  10452. }
  10453. if (isAll)
  10454. {
  10455. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10456. ceErpTradeCell.AfterSaleState = 4;
  10457. ceErpTradeCell.AfterSaleSupplierState = 1;
  10458. }
  10459. }
  10460. }
  10461. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10462. {
  10463. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10464. }
  10465. if (ceErpTradeCell.AfterSaleState == 4)
  10466. {
  10467. ApiVo apiVo = new ApiVo();
  10468. apiVo.orderNumber = ceErpTradeCell.ctid;
  10469. apiVo.actionName = "afterOver";
  10470. designHelper.API_WorkCore(apiVo); //afterOver
  10471. }
  10472. ceErpTradeCell.Update();
  10473. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10474. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10475. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10476. return true;
  10477. }
  10478. return false;
  10479. }
  10480. public void get_erp_wechatorder()
  10481. {
  10482. DataStruct dStruct = GetPostStruct();
  10483. List<string> lw = new List<string>();
  10484. string tid = GetPostString("tid");
  10485. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10486. string shopname = GetPostString("shopname");
  10487. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10488. string buyernick = GetPostString("buyer_nick");
  10489. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10490. string customer = GetPostString("customer");
  10491. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10492. string returndate1 = GetPostString("returndate1");
  10493. string returndate2 = GetPostString("returndate2");
  10494. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10495. if (dw.Length > 0) lw.Add(dw);
  10496. string finishDate1 = GetPostString("finishdate1");
  10497. string finishDate2 = GetPostString("finishdate2");
  10498. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10499. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10500. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10501. dStruct.Order = "created desc";
  10502. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10503. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10504. writeGridDataTableJson(dStruct.TotalCount, dt);
  10505. }
  10506. public void get_erp_wechatlist_sumprice()
  10507. {
  10508. DataStruct dStruct = GetPostStruct();
  10509. List<string> lw = new List<string>();
  10510. string tid = GetPostString("tid");
  10511. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10512. string shopname = GetPostString("shopname");
  10513. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10514. string buyernick = GetPostString("buyer_nick");
  10515. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10516. string customer = GetPostString("customer");
  10517. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10518. string returndate1 = GetPostString("returndate1");
  10519. string returndate2 = GetPostString("returndate2");
  10520. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10521. if (dw.Length > 0) lw.Add(dw);
  10522. string finishDate1 = GetPostString("finishdate1");
  10523. string finishDate2 = GetPostString("finishdate2");
  10524. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10525. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10526. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10527. string mainWhere = string.Join(" and ", lw.ToArray());
  10528. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10529. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10530. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10531. decimal total = 0;
  10532. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10533. {
  10534. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10535. }
  10536. var res = new
  10537. {
  10538. data = total
  10539. };
  10540. string ro_jsond = JsonConvert.SerializeObject(res);
  10541. returnSuccess(ro_jsond);
  10542. return;
  10543. }
  10544. public void get_erp_qr_waitdeliverylist()
  10545. {
  10546. DataStruct dStruct = GetPostStruct();
  10547. List<string> lw = new List<string>();
  10548. string tid = GetPostString("ctid");
  10549. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10550. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10551. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10552. var res_objz = new
  10553. {
  10554. restype = 1,
  10555. data = dt
  10556. };
  10557. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10558. returnSuccess(ro_jsonz);
  10559. }
  10560. public void get_erp_yield_list()
  10561. {
  10562. DataStruct dStruct = GetPostStruct();
  10563. List<string> lw = new List<string>();
  10564. string tid = GetPostString("ctid");
  10565. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10566. string shopname = GetPostString("shopname");
  10567. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10568. string buyernick = GetPostString("buyer_nick");
  10569. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10570. //if (tid.Length == 0 && buyernick.Length == 0)
  10571. //{
  10572. // lw.Add(string.Format("IsRefund<={0}", 1));
  10573. //}
  10574. string customer = GetPostString("customer");
  10575. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10576. string design = GetPostString("design");
  10577. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10578. string orderState = GetPostString("orderState");
  10579. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10580. string address = GetPostString("address");
  10581. 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));
  10582. string sellermemo = GetPostString("seller_memo");
  10583. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10584. string supplier = GetPostString("supplier");
  10585. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10586. string OrderArea = GetPostString("order_area");
  10587. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10588. string placedate1 = GetPostString("placedate1");
  10589. string placedate2 = GetPostString("placedate2");
  10590. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10591. if (fdw.Length > 0) lw.Add(fdw);
  10592. string price1 = GetPostString("price1");
  10593. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10594. string price2 = GetPostString("price2");
  10595. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10596. string unusualCon = GetPostString("unusualcon");
  10597. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10598. string posTag = CurrentUser.UserPost.Post.Code;
  10599. if (posTag == "Supplier")
  10600. {
  10601. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10602. }
  10603. lw.Add(string.Format("OrderState = 6 "));
  10604. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10605. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10606. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10607. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10608. writeGridDataTableJson(dStruct.TotalCount, dt);
  10609. }
  10610. public void change_erp_sup_state()
  10611. {
  10612. if (UrlPostParmsCheck("ctid"))
  10613. {
  10614. string ctid = GetPostString("ctid");
  10615. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10616. if (ceErpTradeCell != null)
  10617. {
  10618. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10619. if (ceErpTradeCellExtend == null)
  10620. {
  10621. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10622. ceErpTradeCellExtend.ctid = ctid;
  10623. ceErpTradeCellExtend.SupState = 1;
  10624. ceErpTradeCellExtend.Create();
  10625. }
  10626. else
  10627. {
  10628. ceErpTradeCellExtend.SupState = 1;
  10629. ceErpTradeCellExtend.Update();
  10630. }
  10631. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10632. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10633. return;
  10634. }
  10635. returnErrorMsg("找不到订单");
  10636. }
  10637. }
  10638. public void supplier_all_downs()
  10639. {
  10640. if (UrlPostParmsCheck("tids"))
  10641. {
  10642. string tids = GetPostString("tids");
  10643. if (tids != null && tids.Length > 0)
  10644. {
  10645. StringBuilder sql = new StringBuilder();
  10646. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10647. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10648. sql = new StringBuilder();
  10649. 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, "下载设计文件");
  10650. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10651. string[] list = tids.Split(',');
  10652. foreach (string ctid in list)
  10653. {
  10654. CeErpSukuraData.createInfo(ctid, 3);
  10655. }
  10656. designHelper.api_approveDesign(tids); //approveDesign
  10657. returnSuccessMsg("下载成功!");
  10658. return;
  10659. }
  10660. returnErrorMsg("下载订单更新失败");
  10661. }
  10662. }
  10663. public void uploaderFileSuccess()
  10664. {
  10665. if (UrlPostParmsCheck("fileName"))
  10666. {
  10667. string fileName = GetPostString("fileName");
  10668. ApiVo apiVo = new ApiVo();
  10669. apiVo.orderNumber = fileName;
  10670. apiVo.actionName = "finishDesign";
  10671. designHelper.API_WorkCore(apiVo);//finishDesign
  10672. returnSuccessMsg("");
  10673. }
  10674. }
  10675. public void get_sample2_order()
  10676. {
  10677. if (UrlPostParmsCheck("ctid"))
  10678. {
  10679. string ctid = GetPostString("ctid");
  10680. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10681. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10682. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10683. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10684. double total = 0.0;
  10685. double order_price = 0.0;
  10686. if (dt_bu.Rows.Count > 0)
  10687. {
  10688. foreach (DataRow dr in dt_bu.Rows)
  10689. {
  10690. total += Convert.ToDouble(dr["payment"]);
  10691. }
  10692. }
  10693. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10694. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10695. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10696. string tid = ctid.Replace("S_", "");
  10697. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10698. double paymant = 0.0;
  10699. if (entity != null)
  10700. {
  10701. paymant = entity.payment;
  10702. }
  10703. string return_reason = "";
  10704. if (dt_after != null && dt_after.Rows.Count > 0)
  10705. {
  10706. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10707. }
  10708. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10709. }
  10710. }
  10711. public void get_erp_design_status()
  10712. {
  10713. string designName = GetPostString("designName");
  10714. DataStruct dStruct = GetPostStruct();
  10715. if (designName.Length > 0)
  10716. {
  10717. 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";
  10718. sql_user += " and Name like '%" + designName + "%'";
  10719. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10720. List<string> ids_list = new List<string>();
  10721. if (user_table.Rows.Count > 0)
  10722. {
  10723. foreach (DataRow item in user_table.Rows)
  10724. {
  10725. ids_list.Add(item["id"].ToString());
  10726. string ids_s = item["TeamIds"].ToString();
  10727. if (ids_s.Length > 0)
  10728. {
  10729. ids_list.AddRange(ids_s.Split(','));
  10730. }
  10731. }
  10732. }
  10733. HashSet<string> set = new HashSet<string>(ids_list);
  10734. ids_list = set.ToList();
  10735. if (ids_list.Count > 0)
  10736. {
  10737. 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));
  10738. dStruct.MainWhere = sql;
  10739. DataTable dt = null;
  10740. dt = WebCache.GetData("view_ErpUser", dStruct);
  10741. writeGridDataTableJson(dStruct.TotalCount, dt);
  10742. }
  10743. }
  10744. }
  10745. public void change_erp_order_price()
  10746. {
  10747. string ctid = GetPostString("ctid");
  10748. double price = GetPostDouble("price");
  10749. if (ctid.Length > 0)
  10750. {
  10751. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10752. if (ceErpTradeCellExtend == null)
  10753. {
  10754. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10755. ceErpTradeCellExtend.ctid = ctid;
  10756. ceErpTradeCellExtend.payment_cyt = price;
  10757. ceErpTradeCellExtend.Create();
  10758. }
  10759. else
  10760. {
  10761. ceErpTradeCellExtend.payment_cyt = price;
  10762. ceErpTradeCellExtend.Update();
  10763. }
  10764. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10765. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10766. {
  10767. ceErpDataSendOrderInfo.isSync = false;
  10768. ceErpDataSendOrderInfo.Update();
  10769. }
  10770. if (ceErpDataSendOrderInfo == null)
  10771. {
  10772. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10773. ceErpDataSendOrderInfo.isSync = false;
  10774. ceErpDataSendOrderInfo.ctid = ctid;
  10775. ceErpDataSendOrderInfo.Create();
  10776. }
  10777. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10778. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10779. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10780. if (dth != null && dth.Rows.Count > 0)
  10781. {
  10782. dataSendOrderBean dataSendOrderBean = null;
  10783. foreach (DataRow item in dth.Rows)
  10784. {
  10785. try
  10786. {
  10787. dataSendOrderBean = new dataSendOrderBean();
  10788. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10789. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10790. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10791. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10792. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10793. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10794. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10795. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10796. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10797. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10798. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10799. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10800. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10801. if (result != null)
  10802. {
  10803. if ("0".Equals(result.errcode))
  10804. {
  10805. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10806. }
  10807. else
  10808. {
  10809. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10810. }
  10811. }
  10812. }
  10813. catch (Exception ex)
  10814. {
  10815. }
  10816. }
  10817. }
  10818. returnSuccessMsg("修改成功!");
  10819. return;
  10820. }
  10821. returnErrorMsg("找不到订单");
  10822. }
  10823. public void find_he_together()
  10824. {
  10825. string ctid = GetPostString("ctid");
  10826. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10827. List<string> list = new List<string>();
  10828. if (ceErpTradeCell != null)
  10829. {
  10830. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10831. {
  10832. 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);
  10833. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10834. if (table != null && table.Rows.Count > 0)
  10835. {
  10836. foreach (TableRow row in table.Rows)
  10837. {
  10838. }
  10839. }
  10840. }
  10841. }
  10842. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10843. }
  10844. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10845. {
  10846. //chy----19
  10847. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10848. //GD-CYT-----64
  10849. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10850. //ZHX----3
  10851. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10852. //JK----97
  10853. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10854. //ZT----70
  10855. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10856. //LHCY-----98
  10857. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10858. //XD-----90
  10859. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10860. //CYCY-----14
  10861. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10862. };
  10863. //其他改名
  10864. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10865. {
  10866. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10867. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10868. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10869. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10870. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10871. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10872. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10873. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10874. };
  10875. //不统计
  10876. List<int> no_suppliers = new List<int>()
  10877. {
  10878. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10879. };
  10880. //配件单
  10881. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10882. {
  10883. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10884. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10885. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10886. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10887. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10888. {"旗杆",new List<string>(){ "班旗" } },
  10889. {"牙签",new List<string>(){ "不干胶" } }
  10890. };
  10891. public void get_place_order_data()
  10892. {
  10893. string date1 = GetPostString("date1");
  10894. string date2 = GetPostString("date2");
  10895. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10896. DateTime start = DateTime.Parse(starttime);
  10897. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10898. DateTime end = DateTime.Parse(endtime);
  10899. if (date1 != null && date1.Length > 0)
  10900. {
  10901. DateTime dateTime = DateTime.Parse(date1);
  10902. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10903. start = DateTime.Parse(starttime);
  10904. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10905. end = DateTime.Parse(endtime);
  10906. }
  10907. if (date2 != null && date2.Length > 0)
  10908. {
  10909. DateTime dateTime = DateTime.Parse(date2);
  10910. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10911. end = DateTime.Parse(endtime);
  10912. }
  10913. 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);
  10914. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10915. //不干胶-----1,卡片-----29
  10916. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10917. foreach (DataRow row in data.Rows)
  10918. {
  10919. int productId = Convert.ToInt32(row["ProductId"]);
  10920. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10921. if (no_suppliers.Contains(supplierId))
  10922. {
  10923. continue;
  10924. }
  10925. string seller_memo = row["seller_memo"].ToString();
  10926. bool ispj = false;//是否配件单
  10927. bool isfirst = true;//第一个配
  10928. maps.Keys.ForEach(key =>
  10929. {
  10930. //备注包含配件
  10931. if (seller_memo.Contains(key) && isfirst)
  10932. {
  10933. List<string> list = maps[key];
  10934. ispj = true;
  10935. isfirst = false;
  10936. for (int i = 0; i < list.Count; i++)
  10937. {
  10938. if (seller_memo.Contains(list[i]))
  10939. {
  10940. ispj = false;
  10941. break;
  10942. }
  10943. }
  10944. }
  10945. });
  10946. if (ispj)
  10947. {
  10948. continue;
  10949. }
  10950. seller_memo = seller_memo.Replace("UV", "uv");
  10951. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10952. //吊牌归到卡片
  10953. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10954. seller_memo = seller_memo.Replace("卡套", "卡片");
  10955. seller_memo = seller_memo.Replace("封套", "卡片");
  10956. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10957. seller_memo = seller_memo.Replace("腰封", "卡片");
  10958. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10959. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10960. seller_memo = seller_memo.Replace("横幅", "条幅");
  10961. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10962. string map_key = "";
  10963. string type = "";
  10964. if (supplierMap.ContainsKey(supplierId))
  10965. {
  10966. foreach (var kvp in supplierMap[supplierId])
  10967. {
  10968. if (seller_memo.Contains(kvp.Key))
  10969. {
  10970. map_key = kvp.Value;
  10971. type = kvp.Value;
  10972. break;
  10973. }
  10974. }
  10975. }
  10976. if (map_key == "")
  10977. {
  10978. type = "其他";
  10979. map_key = "其他";
  10980. }
  10981. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10982. {
  10983. map_key = suppliers[supplierId];
  10984. }
  10985. if (supplierId == 70)
  10986. {
  10987. supplierId = 70;
  10988. }
  10989. map_key += "_" + row["SupplierName"].ToString();
  10990. Dictionary<string, int> map = null;
  10991. if (other_map.ContainsKey(map_key))
  10992. {
  10993. other_map.TryGetValue(map_key, out map);
  10994. }
  10995. else
  10996. {
  10997. map = new Dictionary<string, int>();
  10998. map.Add("dayDev", 0);//当天出货
  10999. map.Add("dayTotal", 0);//下单总数
  11000. map.Add("payTotal", 0);//500以上
  11001. map.Add("today", 0);//当天出货数量
  11002. map.Add("unusua", 0);//异常数
  11003. other_map.Add(map_key, map);
  11004. other_map.TryGetValue(map_key, out map);
  11005. }
  11006. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11007. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11008. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11009. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11010. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11011. {
  11012. map["dayTotal"]++;
  11013. if (supplierId == 97)
  11014. {
  11015. supplierId = 97;
  11016. }
  11017. }
  11018. if (Convert.ToDecimal(row["payment"]) >= 500)
  11019. {
  11020. map["payTotal"]++;
  11021. }
  11022. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11023. {
  11024. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11025. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11026. {
  11027. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11028. {
  11029. map["today"]++;
  11030. }
  11031. }
  11032. else
  11033. {
  11034. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11035. {
  11036. map["today"]++;
  11037. }
  11038. else
  11039. {
  11040. if (supplierId == 119)
  11041. {
  11042. Debug.WriteLine(row["seller_memo"].ToString());
  11043. }
  11044. }
  11045. }
  11046. }
  11047. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11048. {
  11049. map["unusua"]++;
  11050. }
  11051. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11052. //GD-CYT-----64
  11053. DateTime two = palceTimeStart.AddHours(14);
  11054. DateTime three = palceTimeStart.AddHours(15);
  11055. DateTime four = palceTimeStart.AddHours(16);
  11056. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11057. {
  11058. //下午四点前 500-1000
  11059. string count = row["ProductCount"].ToString();
  11060. if (count != null && count.Length > 0)
  11061. {
  11062. int productCount = commonHelper.getPlaceProductCount(count);
  11063. if (productCount >= 500 && productCount <= 1000)
  11064. {
  11065. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11066. {
  11067. map["dayDev"]++;
  11068. }
  11069. }
  11070. }
  11071. }
  11072. //UV
  11073. else if ("uv".Equals(type))
  11074. {
  11075. //ZT----70
  11076. //ZHX----3
  11077. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11078. {
  11079. map["dayDev"]++;
  11080. }
  11081. //JK----97
  11082. //HZX----105
  11083. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11084. {
  11085. map["dayDev"]++;
  11086. if (supplierId == 97)
  11087. {
  11088. supplierId = 97;
  11089. }
  11090. }
  11091. }
  11092. //帆布---52|条幅---27
  11093. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11094. {
  11095. //LHCY-----98
  11096. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11097. {
  11098. map["dayDev"]++;
  11099. }
  11100. }
  11101. //条幅
  11102. else if ("条幅".Equals(type))
  11103. {
  11104. //XD-----90
  11105. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11106. {
  11107. map["dayDev"]++;
  11108. }
  11109. }
  11110. //桌布
  11111. else if ("桌布".Equals(type))
  11112. {
  11113. //XD-----90
  11114. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11115. {
  11116. map["dayDev"]++;
  11117. }
  11118. }
  11119. //DL---10
  11120. //AYTW---119
  11121. //FS-CYT-DY ----80
  11122. //JK----97
  11123. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11124. {
  11125. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11126. {
  11127. map["dayDev"]++;
  11128. }
  11129. }
  11130. }
  11131. DataTable dt = new DataTable();
  11132. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11133. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11134. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11135. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11136. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11137. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11138. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11139. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11140. other_map.Keys.ForEach(key =>
  11141. {
  11142. DataRow dr = dt.NewRow();
  11143. Dictionary<string, int> map = other_map[key];
  11144. string[] key_list = key.Split('_');
  11145. dr[0] = key_list[0];
  11146. dr[1] = key_list[1];
  11147. if (key_list.Length > 2)
  11148. {
  11149. dr[1] += "(" + key_list[2] + ")";
  11150. }
  11151. dr[2] = map["dayTotal"];
  11152. dr[3] = map["payTotal"];
  11153. dr[4] = map["today"];
  11154. dr[5] = map["unusua"];
  11155. dr[6] = map["dayDev"];
  11156. double rate = 0.00;
  11157. if (map["dayDev"] > 0)
  11158. {
  11159. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11160. }
  11161. dr[7] = rate.ToString();
  11162. dt.Rows.Add(dr);
  11163. });
  11164. DataView dv = new DataView(dt);
  11165. dv.Sort = "SupplierName";
  11166. //dv.Sort = "AllOrder desc";
  11167. DataTable dtNew = dv.ToTable();
  11168. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11169. }
  11170. public void check_order_desing_info()
  11171. {
  11172. string ctid = GetPostString("ctid");
  11173. if (!string.IsNullOrEmpty(ctid))
  11174. {
  11175. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11176. if (ceErpTradeCell != null)
  11177. {
  11178. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11179. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11180. return;
  11181. }
  11182. returnErrorMsg("找不到订单");
  11183. return;
  11184. }
  11185. returnErrorMsg("找不到订单");
  11186. }
  11187. public void get_timeout_detail()
  11188. {
  11189. string poscode = CurrentUser.UserPost.Post.Code;
  11190. DataStruct dStruct = GetPostStruct();
  11191. List<string> lw = new List<string>();
  11192. string id = GetPostString("id");
  11193. string pay_date1 = GetPostString("pay_date1");
  11194. string pay_date2 = GetPostString("pay_date2");
  11195. int type = GetPostInt("type");
  11196. if (type == 0)
  11197. {
  11198. if (pay_date1.Length > 0)
  11199. {
  11200. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11201. }
  11202. if (pay_date2.Length > 0)
  11203. {
  11204. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11205. }
  11206. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11207. }
  11208. if (type == 1)
  11209. {
  11210. if (pay_date1.Length > 0)
  11211. {
  11212. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11213. }
  11214. if (pay_date2.Length > 0)
  11215. {
  11216. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11217. }
  11218. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11219. }
  11220. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11221. DataTable dt = null;
  11222. dt = WebCache.GetData("view_orderlist", dStruct);
  11223. writeGridDataTableJson(dStruct.TotalCount, dt);
  11224. }
  11225. public void saveUrgentChargePrice()
  11226. {
  11227. string ctid = GetPostString("ctid");
  11228. if (!string.IsNullOrEmpty(ctid))
  11229. {
  11230. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11231. if (ceErpTradeCell != null)
  11232. {
  11233. double price = GetPostDouble("price");
  11234. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11235. if (ceErpTradeCellExtend == null)
  11236. {
  11237. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11238. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11239. }
  11240. ceErpTradeCellExtend.urgentCharge = price;
  11241. if (ceErpTradeCellExtend.ID > 0)
  11242. {
  11243. ceErpTradeCellExtend.Update();
  11244. }
  11245. else
  11246. {
  11247. ceErpTradeCellExtend.Save();
  11248. }
  11249. returnSuccessMsg("修改成功!");
  11250. return;
  11251. }
  11252. returnErrorMsg("找不到订单");
  11253. return;
  11254. }
  11255. returnErrorMsg("找不到订单");
  11256. }
  11257. public void finish_erp_order()
  11258. {
  11259. string ctid = GetPostString("ctid");
  11260. if (!string.IsNullOrEmpty(ctid))
  11261. {
  11262. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11263. {
  11264. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11265. if (ceErpTradeCell != null)
  11266. {
  11267. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11268. ceErpTradeCell.Update();
  11269. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11270. returnSuccessMsg("修改成功!");
  11271. return;
  11272. }
  11273. }
  11274. }
  11275. returnErrorMsg("找不到订单");
  11276. }
  11277. public void get_trade_order_list()
  11278. {
  11279. string tid = GetPostString("tid");
  11280. if (!string.IsNullOrEmpty(tid))
  11281. {
  11282. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11283. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11284. writeGridDataTableJson(data.Rows.Count, data);
  11285. return;
  11286. }
  11287. returnErrorMsg("找不到订单");
  11288. }
  11289. public void save_cell_spu()
  11290. {
  11291. string ctid = GetPostString("ctid");
  11292. string spu_id = GetPostString("spu_id");
  11293. if (!string.IsNullOrEmpty(ctid))
  11294. {
  11295. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11296. if (ceErpTradeCellExtend == null)
  11297. {
  11298. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11299. ceErpTradeCellExtend.ctid = ctid;
  11300. }
  11301. ceErpTradeCellExtend.spu_id = spu_id;
  11302. if (ceErpTradeCellExtend.ID == 0)
  11303. {
  11304. ceErpTradeCellExtend.Create();
  11305. }
  11306. else
  11307. {
  11308. ceErpTradeCellExtend.Update();
  11309. }
  11310. returnSuccessMsg("修改成功!");
  11311. return;
  11312. }
  11313. returnErrorMsg("找不到订单");
  11314. }
  11315. public void change_express_info()
  11316. {
  11317. string ctid = GetPostString("ctid");
  11318. string transNo = GetPostString("transNo");
  11319. string transCom = GetPostString("transCom");
  11320. if (!string.IsNullOrEmpty(ctid))
  11321. {
  11322. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11323. if (ceErpTradeCellExtend == null)
  11324. {
  11325. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11326. ceErpTradeCellExtend.ctid = ctid;
  11327. }
  11328. ceErpTradeCellExtend.modExpressNo = transNo;
  11329. ceErpTradeCellExtend.modExpressCom = transCom;
  11330. ceErpTradeCellExtend.readMod = 2;
  11331. if (ceErpTradeCellExtend.ID == 0)
  11332. {
  11333. ceErpTradeCellExtend.Create();
  11334. }
  11335. else
  11336. {
  11337. ceErpTradeCellExtend.Update();
  11338. }
  11339. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11340. returnSuccessMsg("修改成功!");
  11341. return;
  11342. }
  11343. returnErrorMsg("找不到订单");
  11344. }
  11345. public void get_change_express_list()
  11346. {
  11347. DataStruct dStruct = GetPostStruct();
  11348. List<string> lw = new List<string>();
  11349. int st = 2;
  11350. string tid = GetPostString("ctid");
  11351. if (tid.Length > 0)
  11352. {
  11353. string select_tid = getTidByCtid(tid);
  11354. lw.Add(string.Format("tid='{0}'", select_tid));
  11355. }
  11356. string shopname = GetPostString("shopname");
  11357. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11358. string buyernick = GetPostString("buyer_nick");
  11359. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11360. string sellermemo = GetPostString("seller_memo");
  11361. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11362. string supplier = GetPostString("supplier");
  11363. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11364. string customer = GetPostString("customer");
  11365. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11366. string design = GetPostString("design");
  11367. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11368. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11369. string poscode = CurrentUser.UserPost.Post.Code;
  11370. if (poscode != "SysAdmin")
  11371. {
  11372. string shopid = CurrentUser.User.pemShop;
  11373. lw.Add(string.Format("shopId in ({0})", shopid));
  11374. }
  11375. lw.Add("readMod = 2");
  11376. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11377. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11378. writeGridDataTableJson(dStruct.TotalCount, dt);
  11379. }
  11380. public void deal_express_complete()
  11381. {
  11382. string ctid = GetPostString("ctid");
  11383. if (!string.IsNullOrEmpty(ctid))
  11384. {
  11385. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11386. if (ceErpTradeCellExtend == null)
  11387. {
  11388. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11389. ceErpTradeCellExtend.ctid = ctid;
  11390. }
  11391. ceErpTradeCellExtend.readMod = 1;
  11392. if (ceErpTradeCellExtend.ID == 0)
  11393. {
  11394. ceErpTradeCellExtend.Create();
  11395. }
  11396. else
  11397. {
  11398. ceErpTradeCellExtend.Update();
  11399. }
  11400. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11401. returnSuccessMsg("修改成功!");
  11402. return;
  11403. }
  11404. returnErrorMsg("找不到订单");
  11405. }
  11406. public void aftersale_return_visit()
  11407. {
  11408. string ctid = GetPostString("ctid");
  11409. if (!string.IsNullOrEmpty(ctid))
  11410. {
  11411. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11412. if (ceErpTradeCellExtend == null)
  11413. {
  11414. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11415. ceErpTradeCellExtend.ctid = ctid;
  11416. }
  11417. ceErpTradeCellExtend.returnVisit = 1;
  11418. if (ceErpTradeCellExtend.ID == 0)
  11419. {
  11420. ceErpTradeCellExtend.Create();
  11421. }
  11422. else
  11423. {
  11424. ceErpTradeCellExtend.Update();
  11425. }
  11426. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11427. if (ceErpTradeAfterSaleExtend != null)
  11428. {
  11429. ceErpTradeAfterSaleExtend.TextResult = "";
  11430. ceErpTradeAfterSaleExtend.Update();
  11431. }
  11432. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11433. returnSuccessMsg("修改成功!");
  11434. return;
  11435. }
  11436. returnErrorMsg("找不到订单");
  11437. }
  11438. public void orderPlaceInfo()
  11439. {
  11440. string ctids = GetPostString("ctids");
  11441. string[] list = ctids.Split(',');
  11442. foreach (string ctid in list)
  11443. {
  11444. CeErpSukuraData.createInfo(ctid, 3);
  11445. }
  11446. designHelper.api_approveDesign(ctids); //approveDesign
  11447. returnSuccessMsg("");
  11448. }
  11449. public void get_issue_list()
  11450. {
  11451. DataStruct dStruct = GetPostStruct();
  11452. List<string> lw = new List<string>();
  11453. int st = 2;
  11454. string tid = GetPostString("ctid");
  11455. if (tid.Length > 0)
  11456. {
  11457. string select_tid = getTidByCtid(tid);
  11458. lw.Add(string.Format("tid='{0}'", select_tid));
  11459. }
  11460. string shopname = GetPostString("shopname");
  11461. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11462. string buyernick = GetPostString("buyer_nick");
  11463. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11464. string sellermemo = GetPostString("seller_memo");
  11465. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11466. string supplier = GetPostString("supplier");
  11467. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11468. string customer = GetPostString("customer");
  11469. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11470. string design = GetPostString("design");
  11471. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11472. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11473. string poscode = CurrentUser.UserPost.Post.Code;
  11474. if (poscode != "SysAdmin")
  11475. {
  11476. string shopid = CurrentUser.User.pemShop;
  11477. lw.Add(string.Format("shopId in ({0})", shopid));
  11478. }
  11479. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11480. {
  11481. lw.Add("IssueState = 1");
  11482. }
  11483. lw.Add("IssueState > 0");
  11484. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11485. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11486. writeGridDataTableJson(dStruct.TotalCount, dt);
  11487. }
  11488. public void saveIssueContent()
  11489. {
  11490. string ctid = GetPostString("ctid");
  11491. if (!string.IsNullOrEmpty(ctid))
  11492. {
  11493. string content = GetPostString("content");
  11494. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11495. if (ceErpTradeAfterSaleExtend == null)
  11496. {
  11497. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11498. ceErpTradeAfterSaleExtend.tid = ctid;
  11499. }
  11500. ceErpTradeAfterSaleExtend.IssueContent = content;
  11501. ceErpTradeAfterSaleExtend.IssueState = 1;
  11502. if (ceErpTradeAfterSaleExtend.ID > 0)
  11503. {
  11504. ceErpTradeAfterSaleExtend.Update();
  11505. }
  11506. else
  11507. {
  11508. ceErpTradeAfterSaleExtend.Create();
  11509. }
  11510. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11511. returnSuccessMsg("添加成功!");
  11512. return;
  11513. }
  11514. returnErrorMsg("找不到订单");
  11515. }
  11516. public void dealIssueContent()
  11517. {
  11518. string ctid = GetPostString("ctid");
  11519. if (!string.IsNullOrEmpty(ctid))
  11520. {
  11521. string content = GetPostString("content");
  11522. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11523. if (ceErpTradeAfterSaleExtend != null)
  11524. {
  11525. ceErpTradeAfterSaleExtend.IssueState = 2;
  11526. ceErpTradeAfterSaleExtend.Update();
  11527. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11528. returnSuccessMsg("修改完成!");
  11529. return;
  11530. }
  11531. }
  11532. returnErrorMsg("找不到订单");
  11533. }
  11534. public void set_tid_attachments()
  11535. {
  11536. string tid = GetPostString("tid");
  11537. string atta = GetPostString("atta");
  11538. if (!string.IsNullOrEmpty(tid))
  11539. {
  11540. if (string.IsNullOrEmpty(atta))
  11541. {
  11542. returnErrorMsg("文件地址为空");
  11543. return;
  11544. }
  11545. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11546. if (ceErpTradeCell != null)
  11547. {
  11548. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11549. if (ceErpTrade == null)
  11550. {
  11551. returnErrorMsg("找不到订单");
  11552. return;
  11553. }
  11554. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11555. bool isSend = false;
  11556. if (dt != null && dt.Rows.Count > 0)
  11557. {
  11558. foreach (DataRow row in dt.Rows)
  11559. {
  11560. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11561. {
  11562. isSend = true;
  11563. }
  11564. }
  11565. if (isSend)
  11566. {
  11567. returnErrorMsg("已发货无法修改");
  11568. return;
  11569. }
  11570. ceErpTrade.Attachments = atta;
  11571. ceErpTrade.Update();
  11572. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11573. returnSuccessMsg("上传成功!");
  11574. return;
  11575. }
  11576. }
  11577. }
  11578. returnErrorMsg("找不到订单");
  11579. }
  11580. public void get_tid_attachments()
  11581. {
  11582. string tid = GetPostString("tid");
  11583. if (!string.IsNullOrEmpty(tid))
  11584. {
  11585. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11586. if (ceErpTradeCell != null)
  11587. {
  11588. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11589. if (ceErpTrade == null)
  11590. {
  11591. returnErrorMsg("找不到订单");
  11592. return;
  11593. }
  11594. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11595. return;
  11596. }
  11597. }
  11598. returnErrorMsg("找不到订单");
  11599. }
  11600. public void check_erp_sameorders()
  11601. {
  11602. if (UrlPostParmsCheck("ctid"))
  11603. {
  11604. string eid = GetPostString("ctid");
  11605. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11606. if (entity != null)
  11607. {
  11608. StringBuilder sql = new StringBuilder();
  11609. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  11610. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11611. List<string> ids = new List<string>();
  11612. if (dt != null && dt.Rows.Count > 1)
  11613. {
  11614. foreach (DataRow dr in dt.Rows)
  11615. {
  11616. ids.Add("'" + dr["ctid"] + "'");
  11617. }
  11618. sql = new StringBuilder();
  11619. sql.AppendFormat("select * from CE_ErpDeliverMark where ctid in ({0});", string.Join(",", ids));
  11620. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  11621. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11622. foreach (DataRow dr in dt.Rows)
  11623. {
  11624. dr["dstate"] = 0;
  11625. foreach (DataRow row in dt1.Rows)
  11626. {
  11627. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  11628. {
  11629. dr["dstate"] = 2;
  11630. }
  11631. }
  11632. if (eid.Equals(dr["ctid"].ToString()))
  11633. {
  11634. dr["dstate"] = 1;
  11635. }
  11636. }
  11637. }
  11638. string ro_jsond = JsonConvert.SerializeObject(dt.Rows);
  11639. returnSuccess(ro_jsond);
  11640. return;
  11641. }
  11642. returnErrorMsg("未找到订单");
  11643. return;
  11644. }
  11645. returnErrorMsg("缺少必要的参数");
  11646. }
  11647. }
  11648. }