sync.order.cs 571 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313
  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.WebControls;
  37. using Utils;
  38. using Utils.Serialization;
  39. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  40. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  41. using static SiteCore.taoObj.work_core_vo;
  42. using static System.Net.Mime.MediaTypeNames;
  43. namespace SiteCore.Handler
  44. {
  45. public partial class sync
  46. {
  47. public void get_erp_orderlist()
  48. {
  49. string poscode = CurrentUser.UserPost.Post.Code;
  50. DataStruct dStruct = GetPostStruct();
  51. //apiHelper.Api_SyncOrderByTime("598825");
  52. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  53. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  54. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  55. //banniuApiHelper.sendLogisticsInfo(null);
  56. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  57. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  58. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  59. //int sid = commonHelper.autoDistributeToSupplier(entity);
  60. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  61. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1740972223000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1741145016000,\"lines\":[{\"mark2\":[],\"num\":1,\"outerId\":\"\",\"payment\":10.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2208932202028/O1CN01SQkhPk1QqsBIMPegn_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":10.0,\"refOlId\":\"2484480075794418199\",\"refSkuId\":\"0\",\"refSpuId\":\"787248116865\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":10.0,\"singleFee\":10.0,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"饰品售后卡片定制珠宝项链购后感谢卡硬卡设计金银保养留言卡纸制作电商包裹贺卡高级明信片首饰好平小卡印刷\",\"totalFee\":10.0,\"totalPrice\":10.0,\"totalSellPrice\":10.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1740995566000,\"openBuyerId\":\"AAFoRHraABkUZRPgSx0XdWH-\",\"openBuyerNick\":\"t**\",\"openSellerNick\":\"麦郁旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1740972209000,\"payTime\":1740972216000,\"payment\":10.0,\"platServiceFee\":0.0,\"posCode\":\"maiyu\",\"posId\":598808,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"湖州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吴兴区\",\"receiverId\":\"82b7afe37a7abf32c5a68285642bc6c7$\",\"receiverState\":\"浙江省\",\"receiverTown\":\"织里镇\",\"refOid\":\"2484480075794418199\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"寄样-卡片-300克铜版纸-tb90589912-小元-2,寄样-卡片-300克雅柔纸-tb90589912-小元-2,寄样-卡片-300克蛋壳纸-tb90589912-小元-2,寄样-卡片-300克刚古水纹纸-tb90589912-小元-2,寄样-卡片-300克荷兰白卡纸-tb90589912-小元-2\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":10.0,\"totalPrice\":10.0,\"totalSellPrice\":10.0,\"type\":\"SALE\"}}");
  62. //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}}");
  63. List<string> lw = new List<string>();
  64. string tid = GetPostString("ctid");
  65. string date1 = GetPostString("date1");
  66. //12-1 修改
  67. string urgent = GetPostString("urgent");
  68. string back = GetPostString("back");
  69. string offlineSearch = GetPostString("offlineSearch");
  70. int paramsCount = 0;
  71. if (!string.IsNullOrWhiteSpace(urgent))
  72. {
  73. if (urgent.Equals("true"))
  74. {
  75. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  76. }
  77. }
  78. if (!string.IsNullOrWhiteSpace(back))
  79. {
  80. if (back.Equals("true"))
  81. {
  82. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  83. }
  84. }
  85. if (!string.IsNullOrWhiteSpace(offlineSearch))
  86. {
  87. if (offlineSearch.Equals("true"))
  88. {
  89. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  90. }
  91. }
  92. //end
  93. string date2 = GetPostString("date2");
  94. string buyernick = GetPostString("buyer_nick");
  95. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  96. {
  97. if (tid.Length <= 0 && buyernick.Length <= 0)
  98. {
  99. return;
  100. }
  101. }
  102. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  103. {
  104. if (tid.Length > 0)
  105. {
  106. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
  107. }
  108. if (buyernick.Length > 0)
  109. {
  110. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  111. }
  112. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  113. if (dw.Length > 0)
  114. {
  115. lw.Add(dw);
  116. }
  117. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  118. {
  119. string usershop = CurrentUser.User.pemShop;
  120. lw.Add(string.Format("ShopId in ({0})", usershop));
  121. }
  122. }
  123. else
  124. {
  125. if (ex_psize == 0)
  126. {
  127. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  128. }
  129. if (PKey != "admin")
  130. {
  131. string usershop = CurrentUser.User.pemShop;
  132. lw.Add(string.Format("ShopId in ({0})", usershop));
  133. paramsCount++;
  134. }
  135. }
  136. string uploaddate1 = GetPostString("uploaddate1");
  137. string uploaddate2 = GetPostString("uploaddate2");
  138. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  139. if (update.Length > 0) lw.Add(update);
  140. string deliverydate1 = GetPostString("deliverydate1");
  141. string deliverydate2 = GetPostString("deliverydate2");
  142. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  143. if (deliverydate.Length > 0)
  144. {
  145. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  146. };
  147. string shopname = GetPostString("shopname");
  148. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  149. string addwechat = GetPostString("addwechat");
  150. if (addwechat.Length > 0)
  151. {
  152. int addWt = Convert.ToInt32(addwechat);
  153. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  154. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  155. }
  156. string customer = GetPostString("customer");
  157. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  158. string design = GetPostString("design");
  159. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  160. string orderState = GetPostString("orderState");
  161. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  162. string address = GetPostString("address");
  163. 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));
  164. string sellermemo = GetPostString("seller_memo");
  165. if (sellermemo.Length > 0)
  166. {
  167. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  168. }
  169. string backReason = GetPostString("backReason");
  170. if (backReason.Length > 0)
  171. {
  172. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  173. }
  174. string apdate1 = GetPostString("apdate1");
  175. string apdate2 = GetPostString("apdate2");
  176. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  177. if (dwap.Length > 0) lw.Add(dwap);
  178. string price1 = GetPostString("price1");
  179. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  180. string price2 = GetPostString("price2");
  181. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  182. string isoldcustomer = GetPostString("isoldcus");
  183. string finishdate1 = GetPostString("finishdate1");
  184. string finishdate2 = GetPostString("finishdate2");
  185. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  186. bool isFinish = false;
  187. if (finishdate.Length > 0)
  188. {
  189. lw.Add(finishdate);
  190. isFinish = true;
  191. paramsCount++;
  192. }
  193. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  194. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  195. if (ex_psize > 0)
  196. {
  197. int UserID = CurrentUser.UserID;
  198. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  199. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  200. {
  201. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  202. }
  203. dStruct.Order = "pay_time desc";
  204. }
  205. string isNew = GetPostString("isNew");
  206. if (isNew == "true")
  207. {
  208. lw.Add(string.Format("IsNew = {0}", 1));
  209. }
  210. string overtime = GetPostString("overtime");
  211. if (overtime == "1")
  212. {
  213. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  214. }
  215. String usePost = CurrentUser.UserPost.Post.Code;
  216. if (usePost.Equals("Operation") == true)
  217. {
  218. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  219. }
  220. else
  221. {
  222. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  223. }
  224. //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";
  225. if (dStruct.PageSize == 100000)
  226. {
  227. dStruct.Order = "";
  228. }
  229. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  230. DataTable dt = null;
  231. string tablename = "view_orderlist";
  232. if (isFinish)
  233. {
  234. tablename = "view_orderlist_end";
  235. }
  236. dt = WebCache.GetData(tablename, dStruct);
  237. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  238. if (dt != null && dt.Rows.Count > 0)
  239. {
  240. foreach (DataRow dr in dt.Rows)
  241. {
  242. try
  243. {
  244. if (dr["refund_fees"] != null)
  245. {
  246. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  247. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  248. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  249. if (payment == refund_fees)
  250. {
  251. dr["refund_fees"] = Math.Round(refund_fees, 2);
  252. }
  253. else if (refund_fees == total_fee)
  254. {
  255. dr["refund_fees"] = payment;
  256. }
  257. else
  258. {
  259. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  260. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  261. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  262. }
  263. }
  264. // 对象操作
  265. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  266. ceErpTradeCell.ctid = dr["ctid"].ToString();
  267. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  268. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  269. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  270. if (dStruct.PageSize != 100000)
  271. {
  272. if (dr["DispatchSort"].ToString() == "2")
  273. {
  274. dr["gongchuang"] = 200;
  275. }
  276. else
  277. {
  278. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  279. dr["gongchuang"] = response.code;
  280. }
  281. }
  282. }
  283. catch (NullReferenceException ex)
  284. {
  285. // 处理空引用异常
  286. dr["refund_fees"] = "0.00";
  287. }
  288. }
  289. }
  290. writeGridDataTableJson(dStruct.TotalCount, dt);
  291. }
  292. public void get_erp_orderlist_sumprice()
  293. {
  294. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  295. return;
  296. List<string> lw = new List<string>();
  297. string tid = GetPostString("ctid");
  298. string date1 = GetPostString("date1");
  299. string date2 = GetPostString("date2");
  300. if (tid.Length > 0 || date1.Length > 0)
  301. {
  302. lw.Add(string.Format("ctid like '%{0}%'", tid));
  303. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  304. if (dw.Length > 0) lw.Add(dw);
  305. }
  306. else
  307. {
  308. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  309. }
  310. string shopname = GetPostString("shopname");
  311. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  312. string buyernick = GetPostString("buyer_nick");
  313. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  314. string customer = GetPostString("customer");
  315. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  316. string design = GetPostString("design");
  317. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  318. string orderState = GetPostString("orderState");
  319. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  320. string address = GetPostString("address");
  321. 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));
  322. string sellermemo = GetPostString("seller_memo");
  323. if (sellermemo.Length > 0)
  324. {
  325. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  326. }
  327. string apdate1 = GetPostString("apdate1");
  328. string apdate2 = GetPostString("apdate2");
  329. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  330. if (dwap.Length > 0) lw.Add(dwap);
  331. string price1 = GetPostString("price1");
  332. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  333. string price2 = GetPostString("price2");
  334. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  335. string isoldcustomer = GetPostString("isoldcus");
  336. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  337. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  338. if (PKey != "admin")
  339. {
  340. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  341. lw.Add(string.Format("shopId in ({0})", usershop));
  342. }
  343. //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";
  344. string mainWhere = string.Join(" and ", lw.ToArray());
  345. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  346. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  347. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  348. decimal total = 0;
  349. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  350. {
  351. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  352. }
  353. var res = new
  354. {
  355. data = total
  356. };
  357. string ro_jsond = JsonConvert.SerializeObject(res);
  358. returnSuccess(ro_jsond);
  359. return;
  360. }
  361. public void get_erp_CustomerServiceGather()
  362. {
  363. string userWhere = "", orderWhere = "";
  364. List<string> lw = new List<string>();
  365. string customer = GetPostString("customer");
  366. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  367. string shopname = GetPostString("shopname");
  368. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  369. string date1 = GetPostString("date1");
  370. string date2 = GetPostString("date2");
  371. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  372. if (dw.Length > 0) lw.Add(dw);
  373. orderWhere = string.Join(" and ", lw.ToArray());
  374. 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 " +
  375. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  376. "left join " +
  377. "( " +
  378. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  379. ") as b on a.ID = b.CustomerUserId " +
  380. "left join " +
  381. "( " +
  382. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  383. ") as d on a.ID = d.CustomerUserId " +
  384. "left join " +
  385. "( " +
  386. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  387. ") as e on a.ID = e.CustomerUserId " +
  388. "left join " +
  389. "( " +
  390. " select CustomerUserId, RefundCount, RefundSum from " +
  391. " ( " +
  392. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  393. " from CE_ErpTradeRefund a " +
  394. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  395. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  396. " group by CustomerUserId " +
  397. " ) as a " +
  398. ") as f on a.ID = f.CustomerUserId " +
  399. "where a.PostCode = 'CustomerService'",
  400. userWhere, orderWhere);
  401. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  402. writeGridDataTableJson(dt.Rows.Count, dt);
  403. //writeGridDataTableJson(dt.Rows.Count, dt);
  404. }
  405. //设计汇总
  406. public void get_erp_DesignerGather()
  407. {
  408. string userWhere = "", orderWhere = "";
  409. List<string> lw = new List<string>();
  410. string Designer = GetPostString("designer");
  411. int org = GetPostInt("org");
  412. if (Designer.Length > 0)
  413. {
  414. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  415. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  416. }
  417. else if (org > 0)
  418. {
  419. userWhere = string.Format(" where OrgID ={0}", org);
  420. }
  421. string shopname = GetPostString("shopname");
  422. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  423. string state = GetPostString("state");
  424. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  425. string OrderArea = GetPostString("order_area");
  426. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  427. string date1 = GetPostString("date1");
  428. string date2 = GetPostString("date2");
  429. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  430. if (dw.Length > 0) lw.Add(dw);
  431. string UpDate1 = GetPostString("UpDate1");
  432. string UpDate2 = GetPostString("UpDate2");
  433. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  434. if (dw.Length > 0) lw.Add(dw);
  435. orderWhere = string.Join(" and ", lw.ToArray());
  436. 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 (" +
  437. "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 " +
  438. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  439. "left join " +
  440. "( " +
  441. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  442. ") as b on a.ID = b.DesignUserId " +
  443. "left join " +
  444. "( " +
  445. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  446. ") as d on a.ID = d.DesignUserId " +
  447. "left join " +
  448. "( " +
  449. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  450. ") as e on a.ID = e.DesignUserId " +
  451. "left join " +
  452. "( " +
  453. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  454. ") as g on a.ID = g.DesignUserId " +
  455. "left join " +
  456. "( " +
  457. " select CustomerUserId, RefundCount, RefundSum from " +
  458. " ( " +
  459. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  460. " from CE_ErpTradeRefund a " +
  461. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  462. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  463. " group by CustomerUserId " +
  464. " ) as a " +
  465. ") as f on a.ID = f.CustomerUserId " +
  466. "where a.PostCode = 'Designer') as z",
  467. userWhere, orderWhere);
  468. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  469. writeGridDataTableJson(dt.Rows.Count, dt);
  470. }
  471. //删除tradecell的订单
  472. public void del_erp_cellorder()
  473. {
  474. if (UrlPostParmsCheck("ctid"))
  475. {
  476. string eid = GetPostString("ctid");
  477. CeErpTradeCell.DelByCtid(eid);
  478. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  479. returnSuccessMsg("删除成功");
  480. }
  481. }
  482. public void clear_erp_refundstate()
  483. {
  484. if (UrlPostParmsCheck("ids"))
  485. {
  486. string eids = GetPostString("ids");
  487. string[] ctidList = eids.Split(',');
  488. foreach (string ctid in ctidList)
  489. {
  490. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  491. if (entity != null)
  492. {
  493. entity.IsRefund = 0;
  494. entity.Update();
  495. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  496. }
  497. else
  498. continue;
  499. }
  500. returnSuccessMsg("操作成功");
  501. return;
  502. }
  503. returnErrorMsg("缺少必要参数");
  504. }
  505. public void set_erp_urgency()
  506. {
  507. if (UrlPostParmsCheck("ctid"))
  508. {
  509. string eid = GetPostString("ctid");
  510. CeErpTradeCell entity = null;
  511. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  512. if (entity != null)
  513. {
  514. string utime = GetPostString("urgencytime");
  515. if (utime.Length > 0)
  516. {
  517. entity.UrgencyTime = Convert.ToDateTime(utime);
  518. }
  519. else
  520. {
  521. returnErrorMsg("请选择加急时间");
  522. return;
  523. }
  524. if (entity.OrderState <= 4)
  525. {
  526. //entity.seller_memo = entity.seller_memo + "-加急";
  527. string smemo = entity.seller_memo;
  528. int kindex = smemo.IndexOf(")");
  529. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  530. if (lastoneStr != "-")
  531. {
  532. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  533. }
  534. string prememo = smemo.Substring(0, kindex + 2);
  535. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  536. int lastkindex = lastmemo.IndexOf("(");
  537. DateTime urgtime = Convert.ToDateTime(utime);
  538. string newlastmemo = "";
  539. if (lastkindex == 0)
  540. {
  541. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  542. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  543. }
  544. else
  545. {
  546. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  547. }
  548. entity.seller_memo = prememo + newlastmemo;
  549. }
  550. entity.IsUrgency = true;
  551. entity.Update();
  552. ApiVo apiVo = new ApiVo();
  553. apiVo.orderNumber = entity.ctid;
  554. apiVo.actionName = "changeDesign";
  555. apiVo.orderRemarks = entity.seller_memo;
  556. apiVo.remarkSign = 3;
  557. designHelper.API_WorkCore(apiVo); //changeDesign
  558. CeErpSukuraData.createInfo(entity.ctid, 7);
  559. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  560. returnSuccessMsg("设置成功!");
  561. return;
  562. }
  563. returnErrorMsg("找不到记录");
  564. }
  565. }
  566. public void set_erp_reset()
  567. {
  568. if (UrlPostParmsCheck("ctid"))
  569. {
  570. string eid = GetPostString("ctid");
  571. CeErpTradeCell entity = null;
  572. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  573. if (entity != null)
  574. {
  575. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  576. {
  577. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  578. {
  579. returnErrorMsg("财务要求已下单已发货无法重置");
  580. return;
  581. }
  582. }
  583. entity.IsUrgency = false;
  584. entity.seller_memo = "";
  585. entity.OtherMemo = "";
  586. entity.OrderState = 0;
  587. entity.IsReturn = 0;
  588. //entity.IsRefund = 0;
  589. entity.MemoOpt = 0;
  590. entity.AfterSaleState = 0;
  591. entity.AfterSaleResponsible = "";
  592. entity.AfterSaleUserId = 0;
  593. entity.IsNeedBill = 0;
  594. entity.CustomerUserId = 0;
  595. entity.DesignUserId = 0;
  596. entity.SupplierId = 0;
  597. entity.PlaceUserId = 0;
  598. entity.ptid = "";
  599. entity.IsSample = 0;
  600. entity.IsXianHuo = 0;
  601. entity.isDianziOrder = 0;
  602. entity.DispatchSort = 0;
  603. entity.FinishPlaceTime = null;
  604. entity.Update();
  605. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  606. if (trade != null)
  607. {
  608. trade.seller_memo = "";
  609. trade.Update();
  610. }
  611. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  612. returnSuccessMsg("重置成功!");
  613. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  614. if (desginBill != null)
  615. {
  616. desginBill.isDel = 1;
  617. desginBill.Update();
  618. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  619. }
  620. ApiVo apiVo = new ApiVo();
  621. apiVo.orderNumber = entity.ctid;
  622. apiVo.actionName = "resetDesign";
  623. designHelper.API_WorkCore(apiVo);//resetDesign
  624. return;
  625. }
  626. returnErrorMsg("找不到记录");
  627. }
  628. }
  629. public void save_erp_sellermemo()
  630. {
  631. if (UrlPostParmsCheck("ctid"))
  632. {
  633. string ctid = GetPostString("ctid");
  634. CeErpTradeCell entity = null;
  635. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  636. if (entity != null)
  637. {
  638. string memo = GetPostString("seller_memo");
  639. memo = memo.Replace(" ", "");
  640. if (memo.Contains("补差"))
  641. {
  642. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  643. return;
  644. }
  645. if (entity.seller_memo != memo)
  646. {
  647. if (entity.IsSample == 2)
  648. {
  649. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  650. return;
  651. }
  652. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  653. {
  654. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  655. {
  656. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  657. return;
  658. }
  659. }
  660. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  661. }
  662. commonHelper.getCytPrice(entity);
  663. int memoopt = GetPostInt("MemoOpt");
  664. Boolean ismemoopt = false;
  665. if (memoopt > 0)
  666. {
  667. string stropt = "";
  668. if (memoopt == 1)
  669. {
  670. stropt = "“改稿”";
  671. ismemoopt = true;
  672. }
  673. else if (memoopt == 2)
  674. {
  675. stropt = "“定稿”";
  676. }
  677. else if (memoopt == 3)
  678. {
  679. stropt = "“查货”";
  680. CeErpSukuraData.createInfo(entity.ctid, 6);
  681. }
  682. entity.MemoOpt = Convert.ToInt32(memoopt);
  683. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  684. }
  685. if (entity.OrderState < 5)
  686. {
  687. memo = memo.Replace("(", "(");
  688. memo = memo.Replace(")", ")");
  689. }
  690. entity.seller_memo = memo;
  691. entity.Update();
  692. ApiVo apiVo = new ApiVo();
  693. apiVo.orderNumber = entity.ctid;
  694. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  695. apiVo.orderRemarks = memo;
  696. apiVo.remarkSign = memoopt;
  697. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  698. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  699. returnSuccessMsg("保存成功!");
  700. return;
  701. }
  702. returnErrorMsg("找不到记录");
  703. }
  704. }
  705. public void ins_erp_checkorder()
  706. {
  707. if (UrlPostParmsCheck("ctid"))
  708. {
  709. string ctid = GetPostString("ctid");
  710. CeErpTradeCell entity = null;
  711. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  712. if (entity != null)
  713. {
  714. if (entity.OrderState < 6)
  715. {
  716. returnErrorMsg("下单完成后才可查货");
  717. return;
  718. }
  719. /*if (entity.OrderState > 6)
  720. {
  721. returnErrorMsg("订单已发货");
  722. return;
  723. }*/
  724. if (entity.FinishPlaceTime != null)
  725. {
  726. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  727. {
  728. returnErrorMsg("下单时间不足,无法查货");
  729. return;
  730. }
  731. }
  732. entity.MemoOpt = 3;
  733. entity.CheckOrderTime = DateTime.Now;
  734. entity.Update();
  735. CeErpSukuraData.createInfo(entity.ctid, 6);
  736. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  737. returnSuccessMsg("操作成功!");
  738. return;
  739. }
  740. returnErrorMsg("找不到记录");
  741. }
  742. }
  743. public void save_erp_othermemo()
  744. {
  745. if (UrlPostParmsCheck("ctid"))
  746. {
  747. string ctid = GetPostString("ctid");
  748. CeErpTradeCell entity = null;
  749. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  750. if (entity != null)
  751. {
  752. entity.OtherMemo = GetPostString("otherMemo");
  753. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  754. {
  755. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  756. StringBuilder sql = new StringBuilder();
  757. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  758. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  759. if (dt != null && dt.Rows.Count > 0)
  760. {
  761. foreach (DataRow dr in dt.Rows)
  762. {
  763. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  764. {
  765. //品类一直
  766. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  767. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  768. if (ceErpSampleCustomer == null)
  769. {
  770. ceErpSampleCustomer = new CeErpSampleCustomer();
  771. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  772. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  773. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  774. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  775. ceErpSampleCustomer.shopId = entity.ShopId;
  776. }
  777. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  778. ceErpSampleCustomer.lastTid = entity.tid;
  779. if (ceErpSampleCustomer.ID > 0)
  780. {
  781. ceErpSampleCustomer.Update();
  782. }
  783. else
  784. {
  785. ceErpSampleCustomer.Create();
  786. }
  787. }
  788. }
  789. }
  790. }
  791. //if (entity.IsOldCustomer == 1)
  792. //{
  793. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  794. //{
  795. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  796. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  797. //}
  798. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  799. //{
  800. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  801. // {
  802. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  803. // {
  804. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  805. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  806. // }
  807. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  808. // {
  809. // entity.OrderState = 2;
  810. // entity.DesignUserId = 0;
  811. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  812. // }
  813. // else
  814. // {
  815. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  816. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  817. // }
  818. // }
  819. //}
  820. //}
  821. entity.Update();
  822. returnSuccessMsg("保存成功!");
  823. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  824. return;
  825. }
  826. returnErrorMsg("找不到记录");
  827. }
  828. }
  829. public void save_erp_customermemo()
  830. {
  831. if (UrlPostParmsCheck("ctid"))
  832. {
  833. string ctid = GetPostString("ctid");
  834. CeErpTradeCell entity = null;
  835. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  836. if (entity != null)
  837. {
  838. entity.CustomerMemo = GetPostString("CustomerMemo");
  839. entity.Update();
  840. ApiVo apiVo = new ApiVo();
  841. apiVo.orderNumber = entity.ctid;
  842. apiVo.actionName = "followRemarks";
  843. apiVo.orderRemarks = entity.CustomerMemo;
  844. designHelper.API_WorkCore(apiVo);//followRemarks
  845. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  846. returnSuccessMsg("保存成功!");
  847. return;
  848. }
  849. returnErrorMsg("找不到记录");
  850. }
  851. }
  852. public void upd_erp_addmemotag()
  853. {
  854. if (UrlPostParmsCheck("ctid"))
  855. {
  856. ;
  857. string eid = GetPostString("ctid");
  858. string sfTagstr = GetPostString("memotag");
  859. CeErpTradeCell entity = null;
  860. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  861. if (entity != null)
  862. {
  863. if (entity.OrderState == 0)
  864. {
  865. returnErrorMsg("请先领单");
  866. return;
  867. }
  868. //撤销顺丰
  869. if (sfTagstr == "撤销顺丰")
  870. {
  871. entity.IsSF = 0;
  872. string reMsg = "";
  873. string oldmemo = entity.seller_memo;
  874. if (entity.OrderState < 5)
  875. {
  876. oldmemo = oldmemo.Replace("顺丰到付", "");
  877. oldmemo = oldmemo.Replace("顺丰寄付", "");
  878. entity.seller_memo = oldmemo;
  879. }
  880. else
  881. {
  882. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  883. {
  884. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  885. }
  886. }
  887. entity.Update();
  888. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  889. api.orderNumber = entity.ctid;
  890. api.actionName = "followRemarks";
  891. api.orderRemarks = entity.seller_memo;
  892. api.isSf = entity.IsSF.ToString();
  893. designHelper.API_WorkCore(api);//followRemarks
  894. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  895. returnSuccessMsg("撤销成功!" + reMsg);
  896. return;
  897. }
  898. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  899. {
  900. //string oldmemo = entity.seller_memo;
  901. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  902. string sfStr = GetPostString("memotag");
  903. string smemo = entity.seller_memo;
  904. int kindex = smemo.IndexOf(")");
  905. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  906. if (lastoneStr != "-")
  907. {
  908. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  909. }
  910. string prememo = smemo.Substring(0, kindex + 2);
  911. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  912. int lastkindex = lastmemo.IndexOf("(");
  913. string newlastmemo = "";
  914. if (lastkindex == 0)
  915. {
  916. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  917. newlastmemo = "(" + sfStr + "." + useLastmemo;
  918. }
  919. else
  920. {
  921. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  922. }
  923. entity.seller_memo = prememo + newlastmemo;
  924. }
  925. string sfTagMSg = "";
  926. if (sfTagstr == "顺丰寄付")
  927. {
  928. entity.IsSF = 1;
  929. sfTagMSg = "顺丰寄付";
  930. }
  931. else if (sfTagstr == "顺丰到付")
  932. {
  933. entity.IsSF = 2;
  934. sfTagMSg = "顺丰到付";
  935. }
  936. entity.Update();
  937. ApiVo apiVo = new ApiVo();
  938. apiVo.orderNumber = entity.ctid;
  939. apiVo.actionName = "orderRemarks";
  940. apiVo.orderRemarks = entity.seller_memo;
  941. apiVo.isSf = entity.IsSF.ToString();
  942. designHelper.API_WorkCore(apiVo);//orderRemarks
  943. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  944. returnSuccessMsg("标记成功!");
  945. return;
  946. }
  947. returnErrorMsg("找不到记录");
  948. }
  949. }
  950. public void upd_erp_ordertag()
  951. {
  952. if (UrlPostParmsCheck("ctid"))
  953. {
  954. string eid = GetPostString("ctid");
  955. CeErpTradeCell entity = null;
  956. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  957. if (entity != null)
  958. {
  959. int tag = GetPostInt("wechattag");
  960. //if(tag==4 && entity.IsSample == 2)
  961. //{
  962. // returnErrorMsg("补差价单不能标记微信单");
  963. // return;
  964. //}
  965. entity.wechatTag = tag;
  966. entity.Update();
  967. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  968. if (tag == 1)
  969. {
  970. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  971. if (cash == null)
  972. {
  973. CeErpTrade main = CeErpTrade.Get(entity.tid);
  974. cash = new CeErpReturnCash();
  975. cash.tid = entity.tid;
  976. cash.seller_nick = main.seller_nick;
  977. cash.payment = trade.payment;
  978. cash.buyer_nick = main.buyer_nick;
  979. cash.cashstate = 0;
  980. cash.rtype = "微信返现";
  981. cash.returnprice = 0;
  982. cash.created = DateTime.Now;
  983. cash.con = "订单标记微信单";
  984. cash.img = "";
  985. cash.applyuserid = CurrentUser.UserID;
  986. cash.Create();
  987. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  988. }
  989. else
  990. {
  991. cash.cashstate = 0;
  992. cash.Update();
  993. }
  994. CeErpSukuraData.createInfo(entity.ctid, 9);
  995. }
  996. else if (tag == 2)
  997. {
  998. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  999. if (cash == null)
  1000. {
  1001. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1002. cash = new CeErpReturnCash();
  1003. cash.tid = entity.tid;
  1004. cash.seller_nick = main.seller_nick;
  1005. cash.payment = trade.payment;
  1006. cash.buyer_nick = main.buyer_nick;
  1007. cash.cashstate = 0;
  1008. cash.rtype = "推购返现";
  1009. cash.returnprice = 5;
  1010. cash.created = DateTime.Now;
  1011. cash.con = "订单标记推购单";
  1012. cash.img = "";
  1013. cash.applyuserid = CurrentUser.UserID;
  1014. cash.Create();
  1015. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1016. }
  1017. else
  1018. {
  1019. cash.cashstate = 0;
  1020. cash.Update();
  1021. }
  1022. CeErpSukuraData.createInfo(entity.ctid, 9);
  1023. }
  1024. else if (tag == 3)
  1025. {
  1026. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1027. if (pers == null)
  1028. {
  1029. pers = new CeErpPersuade();
  1030. pers.ctid = entity.ctid;
  1031. pers.pstate = 0;
  1032. pers.created = DateTime.Now;
  1033. pers.applyuserid = CurrentUser.UserID;
  1034. pers.Create();
  1035. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1036. }
  1037. else
  1038. {
  1039. pers.pstate = 0;
  1040. pers.Update();
  1041. }
  1042. }
  1043. else if (tag == 4 || tag == 5)
  1044. {
  1045. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1046. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1047. if (pers == null)
  1048. {
  1049. pers = new CeErpStayGoods();
  1050. pers.t_id = entity.tid;
  1051. pers.status = "待审核";
  1052. pers.audit_type = 0;
  1053. if (tag == 4)
  1054. {
  1055. pers.stay_type = "微信推购";
  1056. }
  1057. else
  1058. {
  1059. pers.stay_type = "旺旺推购";
  1060. }
  1061. if (entity.IsXianHuo == 0)
  1062. {
  1063. pers.product_id = entity.ProductId;
  1064. }
  1065. pers.wangwang = main.buyer_nick;
  1066. pers.shop_name = main.seller_nick;
  1067. pers.creata_time = DateTime.Now;
  1068. pers.create_u_id = CurrentUser.UserID;
  1069. pers.create_u_name = CurrentUser.UserName;
  1070. pers.Create();
  1071. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1072. }
  1073. else
  1074. {
  1075. pers.audit_type = 0;
  1076. pers.Update();
  1077. }
  1078. CeErpSukuraData.createInfo(entity.ctid, 10);
  1079. }
  1080. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1081. returnSuccessMsg("标记成功!");
  1082. return;
  1083. }
  1084. returnErrorMsg("找不到记录");
  1085. }
  1086. }
  1087. public void upd_erp_ordertag_cancel()
  1088. {
  1089. if (UrlPostParmsCheck("ctid"))
  1090. {
  1091. string eid = GetPostString("ctid");
  1092. CeErpTradeCell entity = null;
  1093. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1094. if (entity != null)
  1095. {
  1096. entity.wechatTag = 0;
  1097. entity.Update();
  1098. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1099. if (pers != null)
  1100. {
  1101. pers.status = "取消推购";
  1102. pers.audit_type = 3;
  1103. pers.Update();
  1104. }
  1105. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1106. returnSuccessMsg("标记成功!");
  1107. return;
  1108. }
  1109. returnErrorMsg("找不到记录");
  1110. }
  1111. }
  1112. public void upd_erp_addweichattag()
  1113. {
  1114. if (UrlPostParmsCheck("ctid"))
  1115. {
  1116. ;
  1117. string eid = GetPostString("ctid");
  1118. CeErpTradeCell entity = null;
  1119. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1120. if (entity != null)
  1121. {
  1122. if (entity.IsAddWechat > 0)
  1123. {
  1124. returnErrorMsg("此单已经标记过了");
  1125. return;
  1126. }
  1127. 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);
  1128. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1129. if (dt.Rows.Count > 0)
  1130. {
  1131. entity.IsAddWechat = 2;
  1132. }
  1133. else
  1134. {
  1135. entity.IsAddWechat = 1;
  1136. }
  1137. entity.Update();
  1138. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1139. returnSuccessMsg("标记成功!");
  1140. return;
  1141. }
  1142. returnErrorMsg("找不到记录");
  1143. }
  1144. }
  1145. public void upd_erp_getmyorder()
  1146. {
  1147. if (UrlPostParmsCheck("ctid"))
  1148. {
  1149. ;
  1150. string eid = GetPostString("ctid");
  1151. CeErpTradeCell entity = null;
  1152. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1153. if (entity != null)
  1154. {
  1155. if (entity.ctid.IndexOf("C") != -1)
  1156. {
  1157. StringBuilder sql = new StringBuilder();
  1158. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1159. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1160. if (dt.Rows.Count > 0)
  1161. {
  1162. decimal total = 0;
  1163. foreach (DataRow dr in dt.Rows)
  1164. {
  1165. total += Convert.ToDecimal(dr["payment"]);
  1166. }
  1167. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1168. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1169. {
  1170. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1171. return;
  1172. }
  1173. }
  1174. }
  1175. entity.CustomerUserId = CurrentUser.UserID;
  1176. if (entity.OrderState < 2)
  1177. {
  1178. entity.OrderState = 2;
  1179. if (entity.ShopId != 0)
  1180. {
  1181. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1182. }
  1183. }
  1184. entity.Update();
  1185. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1186. returnSuccessMsg("领单成功!");
  1187. return;
  1188. }
  1189. returnErrorMsg("找不到记录");
  1190. }
  1191. }
  1192. public void getmyorder_from_init()
  1193. {
  1194. if (UrlPostParmsCheck("ctid"))
  1195. {
  1196. string eid = GetPostString("ctid");
  1197. CeErpTradeCell entity = null;
  1198. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1199. if (entity != null)
  1200. {
  1201. string sellerMemo = GetPostString("sellerMemo");
  1202. if (sellerMemo.Length > 0)
  1203. {
  1204. entity.seller_memo = sellerMemo;
  1205. }
  1206. string oterhMemo = GetPostString("otherMemo");
  1207. if (oterhMemo.Length > 0)
  1208. {
  1209. entity.OtherMemo = oterhMemo;
  1210. }
  1211. int urg = GetPostInt("urgency");
  1212. entity.IsUrgency = (urg == 1 ? true : false);
  1213. int wechat = GetPostInt("wechat");
  1214. int command = GetPostInt("command");
  1215. if (wechat == 1)
  1216. {
  1217. entity.wechatTag = 1;
  1218. }
  1219. if (command == 1)
  1220. {
  1221. entity.wechatTag = 2;
  1222. }
  1223. string pPro = GetPostString("pprofession");
  1224. if (pPro.Length > 0)
  1225. {
  1226. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1227. string spro = GetPostString("profession");
  1228. if (spro.Length > 0)
  1229. {
  1230. entity.ProfessionId = Convert.ToInt32(spro);
  1231. }
  1232. }
  1233. string proId = GetPostString("productId");
  1234. if (proId.Length > 0)
  1235. {
  1236. entity.ProductId = Convert.ToInt32(proId);
  1237. }
  1238. entity.Material = GetPostString("material");
  1239. entity.Craft = GetPostString("craft");
  1240. entity.CustomerUserId = CurrentUser.UserID;
  1241. if (entity.OrderState < 2)
  1242. {
  1243. entity.OrderState = 2;
  1244. if (entity.ShopId != 0)
  1245. {
  1246. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1247. }
  1248. }
  1249. entity.Update();
  1250. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1251. returnSuccessMsg("领单成功!");
  1252. return;
  1253. }
  1254. returnErrorMsg("找不到记录");
  1255. }
  1256. }
  1257. public void upd_erp_setrelationorder()
  1258. {
  1259. if (UrlPostParmsCheck("ctid"))
  1260. {
  1261. ;
  1262. string eid = GetPostString("ctid");
  1263. string ftid = GetPostString("ftid");
  1264. CeErpTradeCell entity = null;
  1265. CeErpTradeCell fentity = null;
  1266. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1267. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1268. if (fentity == null)
  1269. {
  1270. returnErrorMsg("找不到关联的主订单");
  1271. return;
  1272. }
  1273. if (entity != null)
  1274. {
  1275. if (entity.OrderState >= 5)
  1276. {
  1277. returnErrorMsg("本单已经设计完成无法关联");
  1278. return;
  1279. }
  1280. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1281. {
  1282. returnErrorMsg("线下单续审核后才能关联!");
  1283. return;
  1284. }
  1285. entity.ptid = ftid;
  1286. entity.OrderState = fentity.OrderState;
  1287. //entity.status = fentity.status;
  1288. entity.CustomerUserId = fentity.CustomerUserId;
  1289. entity.DesignUserId = fentity.DesignUserId;
  1290. entity.seller_memo = "补差价单:" + ftid;
  1291. entity.IsSample = 2;
  1292. entity.Update();
  1293. ApiVo apiVo = new ApiVo();
  1294. apiVo.orderNumber = ftid;
  1295. apiVo.payment = entity.payment;
  1296. apiVo.actionName = "repairDesign";
  1297. designHelper.API_WorkCore(apiVo);//repairDesign
  1298. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1299. returnSuccessMsg("关联成功!");
  1300. return;
  1301. }
  1302. else
  1303. returnErrorMsg("找不到记录");
  1304. }
  1305. }
  1306. public void download_erp_neworder()
  1307. {
  1308. string seller = GetPostString("seller_nick");
  1309. string tid = GetPostString("tid");
  1310. if (seller.Length <= 0 || tid.Length <= 0)
  1311. {
  1312. returnErrorMsg("数据错误");
  1313. }
  1314. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1315. //{
  1316. // returnErrorMsg("找不到店铺Sessionkey");
  1317. //}
  1318. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1319. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1320. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1321. if (res.IndexOf("refOid") == -1)
  1322. {
  1323. returnErrorMsg("下载订单数据失败");
  1324. return;
  1325. }
  1326. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1327. returnSuccessMsg("下载完成");
  1328. //tmcHelper.createNewOrder(res);
  1329. //CeErpTrade entr = null;
  1330. //entr = CeErpTrade.Get(tid);
  1331. //if (entr != null)
  1332. //{
  1333. // returnSuccess("下载成功");
  1334. // //下载成功之后,Cell表生成对应的订单;
  1335. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1336. //}
  1337. //else
  1338. //{
  1339. // returnErrorMsg("下载失败或者创建订单失败");
  1340. //}
  1341. }
  1342. public void set_erp_atersale()
  1343. {
  1344. if (UrlPostParmsCheck("ctid"))
  1345. {
  1346. string eid = GetPostString("ctid");
  1347. string reason = GetPostString("AfterSaleReason");
  1348. CeErpTradeCell entity = null;
  1349. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1350. if (entity != null)
  1351. {
  1352. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1353. {
  1354. returnErrorMsg("此订单已经在售后");
  1355. return;
  1356. }
  1357. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1358. //entity.AfterSaleReason = reason;
  1359. entity.AfterSaleTime = DateTime.Now;
  1360. entity.Update();
  1361. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1362. returnSuccessMsg("转售后成功!");
  1363. return;
  1364. }
  1365. returnErrorMsg("找不到记录");
  1366. }
  1367. }
  1368. public void set_erp_withdraw()
  1369. {
  1370. if (UrlPostParmsCheck("ctid"))
  1371. {
  1372. try
  1373. {
  1374. string eid = GetPostString("ctid");//商品id
  1375. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1376. CeWithdraw ceWithdrawSelect = null;
  1377. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1378. if (ceWithdrawSelect != null)
  1379. {
  1380. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1381. {
  1382. ceWithdrawSelect.status = -1;
  1383. ceWithdrawSelect.Update();
  1384. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1385. returnSuccessMsg("重新发起审核成功");
  1386. return;
  1387. }
  1388. else
  1389. {
  1390. returnSuccessMsg("请勿重复申请!");
  1391. return;
  1392. }
  1393. }
  1394. else
  1395. {
  1396. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1397. if (string.IsNullOrEmpty(CustomerUserId))
  1398. {
  1399. CustomerUserId = "-1";
  1400. }
  1401. int Userid = CurrentUser.UserID;//用户id
  1402. CeWithdraw ceWithdraw = new CeWithdraw();
  1403. ceWithdraw.tid = eid;
  1404. ceWithdraw.userid = Userid;
  1405. ceWithdraw.providerid = CustomerUserId;
  1406. ceWithdraw.status = 3;
  1407. ceWithdraw.creationtime = DateTime.Now;
  1408. ceWithdraw.Create();
  1409. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1410. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1411. return;
  1412. }
  1413. }
  1414. catch
  1415. {
  1416. returnErrorMsg("申请撤回订单失败");
  1417. return;
  1418. }
  1419. }
  1420. }
  1421. public void ins_erp_billinfo()
  1422. {
  1423. if (UrlPostParmsCheck("ctid"))
  1424. {
  1425. string eid = GetPostString("ctid");
  1426. CeErpTradeCell entity = null;
  1427. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1428. if (entity != null)
  1429. {
  1430. CeErpBill bill = CeErpBill.GetByTid(eid);
  1431. bool isHave = false;
  1432. if (bill != null)
  1433. {
  1434. isHave = true;
  1435. if (bill.state != 4)
  1436. {
  1437. returnErrorMsg("此单已经申请过发票了");
  1438. return;
  1439. }
  1440. }
  1441. if (entity.IsNeedBill == 0)
  1442. {
  1443. entity.IsNeedBill = 1;
  1444. }
  1445. entity.Update();
  1446. string errjson = "";
  1447. try
  1448. {
  1449. CeErpBill bill_entity = new CeErpBill();
  1450. bill_entity.tid = entity.tid;
  1451. bill_entity.title = GetPostString("title");
  1452. string taxstr = GetPostString("tax");
  1453. taxstr = taxstr.Replace(" ", "");
  1454. bill_entity.tax = taxstr;
  1455. bill_entity.bank = GetPostString("bank");
  1456. string bankacstr = GetPostString("bankac");
  1457. bankacstr = bankacstr.Replace(" ", "");
  1458. bill_entity.bankac = bankacstr;
  1459. bill_entity.address = GetPostString("address");
  1460. bill_entity.phone = GetPostString("phone");
  1461. bill_entity.price = GetPostString("price");
  1462. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1463. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1464. {
  1465. billCount += 1;
  1466. }
  1467. string prebill = "ltb";
  1468. for (int idx = 1; idx <= billCount; idx++)
  1469. {
  1470. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1471. string billoid = prebill + idx + dtstr;
  1472. bill_entity.billOrderId += billoid;
  1473. if (idx < billCount)
  1474. {
  1475. bill_entity.billOrderId += ",";
  1476. }
  1477. }
  1478. bill_entity.productId = GetPostInt("ProductName");
  1479. bill_entity.num = GetPostInt("num");
  1480. bill_entity.unit = GetPostString("unit");
  1481. bill_entity.type = GetPostString("type");
  1482. bill_entity.sendType = GetPostString("SendType");
  1483. bill_entity.email = GetPostString("email");
  1484. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1485. bill_entity.shopName = GetPostString("ShopName");
  1486. bill_entity.applymemo = GetPostString("applyMemo");
  1487. bill_entity.createTime = DateTime.Now;
  1488. bill_entity.state = 0;
  1489. bill_entity.userId = CurrentUser.UserID;
  1490. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1491. bill_entity.Create();
  1492. }
  1493. catch (Exception ex)
  1494. {
  1495. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1496. returnErrorMsg("创建发票出错!");
  1497. return;
  1498. }
  1499. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1500. returnSuccessMsg("发票申请成功!");
  1501. return;
  1502. }
  1503. returnErrorMsg("找不到记录");
  1504. }
  1505. }
  1506. public void ins_erp_neworder()
  1507. {
  1508. if (UrlPostParmsCheck("receiver_name"))
  1509. {
  1510. CeErpTrade entity = new CeErpTrade();
  1511. string plat_form = GetPostString("platform");
  1512. string preStr = "N_";
  1513. if (plat_form == "拼多多")
  1514. {
  1515. preStr = "P_";
  1516. }
  1517. else if (plat_form == "阿里巴巴")
  1518. {
  1519. preStr = "A_";
  1520. }
  1521. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1522. entity.seller_nick = GetPostString("seller_nick");
  1523. entity.buyer_nick = GetPostString("buyer_nick");
  1524. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1525. entity.total_fee = entity.payment;
  1526. entity.pay_time = DateTime.Now;
  1527. entity.status = "NOT_SHIPPED";
  1528. entity.receiver_name = GetPostString("receiver_name");
  1529. entity.receiver_mobile = GetPostString("receiver_mobile");
  1530. entity.receiver_state = GetPostString("receiver_state");
  1531. entity.receiver_city = GetPostString("receiver_city");
  1532. entity.receiver_district = GetPostString("receiver_district");
  1533. entity.receiver_address = GetPostString("receiver_address");
  1534. if (entity.receiver_state == "" || entity.receiver_city == "")
  1535. {
  1536. returnErrorMsg("收件地址不能为空");
  1537. return;
  1538. }
  1539. int shopId = 0;
  1540. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1541. if (nShop != null)
  1542. {
  1543. shopId = nShop.ID;
  1544. }
  1545. if (shopId != 34 && entity.payment == 0)
  1546. {
  1547. returnErrorMsg("公司自用的单金额才能为0");
  1548. return;
  1549. }
  1550. entity.Create();
  1551. CeErpTradeCell entitycell = new CeErpTradeCell();
  1552. entitycell.ctid = entity.tid;
  1553. entitycell.tid = entity.tid;
  1554. entitycell.ShopId = shopId;
  1555. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1556. entitycell.OrderState = 0;
  1557. entitycell.pay_time = entity.pay_time;
  1558. entitycell.IsOffLineOrder = 1;
  1559. entitycell.Create();
  1560. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1561. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1562. return;
  1563. }
  1564. }
  1565. public void ins_erp_neworder2()
  1566. {
  1567. if (UrlPostParmsCheck("receiver_name"))
  1568. {
  1569. //string plat_form = GetPostString("platform");
  1570. string preStr = "X_";
  1571. string memo = GetPostString("memo");
  1572. string productId = GetPostString("productId");
  1573. string primg = GetPostString("proofimg");
  1574. string sellerNick = GetPostString("seller_nick");
  1575. string addFrom = GetPostString("addfrom");
  1576. if (addFrom == "1")
  1577. {
  1578. preStr = "N_";
  1579. }
  1580. int shopId = 0;
  1581. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1582. if (nShop != null)
  1583. {
  1584. shopId = nShop.ID;
  1585. }
  1586. else
  1587. {
  1588. returnErrorMsg("找不到对应店铺");
  1589. return;
  1590. }
  1591. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1592. {
  1593. returnErrorMsg("必须上传付款凭证");
  1594. return;
  1595. }
  1596. CeErpTrade entity = new CeErpTrade();
  1597. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1598. entity.seller_nick = sellerNick;
  1599. entity.buyer_nick = GetPostString("buyer_nick");
  1600. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1601. entity.total_fee = entity.payment;
  1602. entity.pay_time = DateTime.Now;
  1603. entity.status = "NOT_SHIPPED";
  1604. entity.receiver_name = GetPostString("receiver_name");
  1605. entity.receiver_mobile = GetPostString("receiver_mobile");
  1606. entity.receiver_state = GetPostString("receiver_state");
  1607. entity.receiver_city = GetPostString("receiver_city");
  1608. entity.receiver_district = GetPostString("receiver_district");
  1609. entity.receiver_address = GetPostString("receiver_address");
  1610. entity.seller_memo = memo;
  1611. entity.orderFrom = 20;
  1612. entity.orderType = 15;
  1613. if (entity.receiver_state == "" || entity.receiver_city == "")
  1614. {
  1615. returnErrorMsg("收件地址不能为空");
  1616. return;
  1617. }
  1618. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1619. {
  1620. returnErrorMsg("公司自用的单金额才能为0");
  1621. return;
  1622. }
  1623. entity.Create();
  1624. string toWhere = GetPostString("towhere");
  1625. CeErpTradeCell entitycell = new CeErpTradeCell();
  1626. entitycell.ctid = entity.tid;
  1627. //唯一标识
  1628. entitycell.OrderSn = entity.tid;
  1629. //string orderSn = dataHelper.getSaleOrderSn();
  1630. //if (orderSn != "")
  1631. // {
  1632. // entitycell.OrderSn = orderSn;
  1633. // }
  1634. entitycell.tid = entity.tid;
  1635. //if (preStr == "X_")
  1636. //{
  1637. entitycell.IsOffLineOrder = 1;
  1638. //}
  1639. entitycell.CustomerUserId = CurrentUser.UserID;
  1640. entitycell.PayProofImg = primg;
  1641. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1642. entitycell.ProductId = Convert.ToInt32(productId);
  1643. entitycell.ShopId = shopId;
  1644. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1645. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1646. {
  1647. entitycell.IsXianHuo = 1;
  1648. }
  1649. entitycell.pay_time = entity.pay_time;
  1650. if (toWhere == "1")
  1651. {
  1652. entitycell.OrderState = 2;
  1653. }
  1654. else
  1655. {
  1656. entitycell.OrderState = 6;
  1657. entitycell.FinishPlaceTime = entitycell.pay_time;
  1658. }
  1659. if (shopId == 94)
  1660. {
  1661. entitycell.OrderState = 4;
  1662. entitycell.WaitDesignTime = entitycell.pay_time;
  1663. entitycell.StartDesignTime = entitycell.pay_time;
  1664. entitycell.DesignUserId = 218;
  1665. }
  1666. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1667. {
  1668. entitycell.OrderState = -1;//修改12-5
  1669. CeWithdraw ceWithdraw = new CeWithdraw();
  1670. ceWithdraw.tid = entity.tid;
  1671. ceWithdraw.providerid = "-1";
  1672. ceWithdraw.status = -1;
  1673. ceWithdraw.creationtime = DateTime.Now;
  1674. ceWithdraw.userid = 1337;
  1675. ceWithdraw.Create();
  1676. }
  1677. entitycell.Create();
  1678. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1679. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1680. {
  1681. addPlaceRegist(entitycell, CurrentUser.UserID);
  1682. }
  1683. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1684. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1685. return;
  1686. }
  1687. }
  1688. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1689. {
  1690. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1691. entity.PlactTime = tradecell.pay_time;
  1692. entity.AddUserId = userid;
  1693. entity.FileName = tradecell.seller_memo;
  1694. entity.Supplier = 24;
  1695. entity.CreateTime = DateTime.Now;
  1696. entity.Did = tradecell.ctid;
  1697. entity.tid = tradecell.tid;
  1698. entity.splitTag = tradecell.SplitTag;
  1699. entity.CurState = "未完成";
  1700. entity.Create();
  1701. }
  1702. public void get_erp_offlinelist()
  1703. {
  1704. DataStruct dStruct = GetPostStruct();
  1705. List<string> lw = new List<string>();
  1706. string tid = GetPostString("ctid");
  1707. string date1 = GetPostString("date1");
  1708. string date2 = GetPostString("date2");
  1709. if (tid.Length > 0 || date1.Length > 0)
  1710. {
  1711. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1712. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1713. if (dw.Length > 0) lw.Add(dw);
  1714. }
  1715. else
  1716. {
  1717. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1718. }
  1719. string shopname = GetPostString("shopname");
  1720. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1721. string buyernick = GetPostString("buyer_nick");
  1722. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1723. string customer = GetPostString("customer");
  1724. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1725. string design = GetPostString("design");
  1726. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1727. string orderState = GetPostString("orderState");
  1728. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1729. string address = GetPostString("address");
  1730. 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));
  1731. string sellermemo = GetPostString("seller_memo");
  1732. if (sellermemo.Length > 0)
  1733. {
  1734. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1735. }
  1736. string price1 = GetPostString("price1");
  1737. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1738. string price2 = GetPostString("price2");
  1739. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1740. //if (PKey != "admin")
  1741. //{
  1742. // string usershop = CurrentUser.User.pemShop;
  1743. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1744. //}
  1745. //if (ex_psize > 0)
  1746. //{
  1747. dStruct.Order = "pay_time desc";
  1748. //}
  1749. //else
  1750. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1751. lw.Add(string.Format("IsOffLineOrder=1"));
  1752. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1753. DataTable dt = null;
  1754. dt = WebCache.GetData("view_erptradecell", dStruct);
  1755. writeGridDataTableJson(dStruct.TotalCount, dt);
  1756. }
  1757. public void get_erp_returncashrecord()
  1758. {
  1759. DataStruct dStruct = GetPostStruct();
  1760. List<string> lw = new List<string>();
  1761. string tid = GetPostString("ctid");
  1762. if (tid.Length > 0)
  1763. {
  1764. lw.Add(string.Format("tid like '%{0}%'", tid));
  1765. dStruct.Order = "id desc";
  1766. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1767. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1768. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1769. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1770. return;
  1771. }
  1772. returnErrorMsg("id数据错误!");
  1773. }
  1774. public void ins_erp_returncashrecord()
  1775. {
  1776. if (UrlPostParmsCheck("tid"))
  1777. {
  1778. string tid = GetPostString("tid");
  1779. string retype = GetPostString("type");
  1780. StringBuilder sql = new StringBuilder();
  1781. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1782. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1783. if (dt.Rows.Count > 0)
  1784. {
  1785. returnErrorMsg("相同返现类型记录已存在");
  1786. return;
  1787. }
  1788. CeErpReturnCash entity = new CeErpReturnCash();
  1789. entity.tid = tid;
  1790. entity.seller_nick = GetPostString("seller_nick");
  1791. string pment = GetPostString("payment");
  1792. if (pment.Length > 0)
  1793. {
  1794. entity.payment = Convert.ToDouble(pment);
  1795. }
  1796. entity.buyer_nick = GetPostString("buyer_nick");
  1797. entity.cashstate = 0;
  1798. entity.rtype = retype;
  1799. string rPrice = GetPostString("returnprice");
  1800. if (rPrice.Length > 0)
  1801. {
  1802. entity.returnprice = Convert.ToDouble(rPrice);
  1803. }
  1804. entity.created = DateTime.Now;
  1805. entity.con = GetPostString("con");
  1806. entity.img = GetPostString("img");
  1807. entity.applyuserid = CurrentUser.UserID;
  1808. entity.Create();
  1809. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1810. returnSuccessMsg("操作成功!");
  1811. return;
  1812. }
  1813. }
  1814. public void set_erp_predelivery()
  1815. {
  1816. if (UrlPostParmsCheck("ctid"))
  1817. {
  1818. string eid = GetPostString("ctid");
  1819. CeErpTradeCell entity = null;
  1820. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1821. if (entity != null)
  1822. {
  1823. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1824. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1825. //{
  1826. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1827. // return;
  1828. //}
  1829. entity.IsPreDelivery = 1;
  1830. entity.Update();
  1831. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1832. returnSuccessMsg("预发货成功!");
  1833. return;
  1834. //string shop = GetPostString("seller_nick");
  1835. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1836. //string comName = GetPostString("comName");
  1837. //string comCode = GetPostString("comCode");
  1838. //string outSid = GetPostString("outSid");//运单号
  1839. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1840. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1841. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1842. //string apires = "";
  1843. //if (deliveryType == "虚拟发货")
  1844. //{
  1845. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1846. //}
  1847. //else
  1848. //{
  1849. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1850. //}
  1851. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1852. ////{
  1853. //if (apires.IndexOf("发货成功") != -1)
  1854. //{
  1855. // if (deliveryType != "虚拟发货")
  1856. // {
  1857. // //还要插入快递信息到 快递信息表
  1858. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1859. // exinfo.tid = eid;
  1860. // exinfo.out_sid = outSid;
  1861. // exinfo.company_code = comCode;
  1862. // exinfo.company_name = comName;
  1863. // exinfo.delivery_memo = deliveryMemo;
  1864. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1865. // exinfo.deliveryType = deliveryType;
  1866. // exinfo.Create();
  1867. // }
  1868. // returnSuccessMsg("发货成功!");
  1869. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1870. //}
  1871. //else
  1872. //{
  1873. // returnErrorMsg("淘宝发货失败!!");
  1874. //}
  1875. //return;
  1876. }
  1877. returnErrorMsg("找不到订单记录");
  1878. }
  1879. }
  1880. public void get_erp_unusuallist()
  1881. {
  1882. DataStruct dStruct = GetPostStruct();
  1883. List<string> lw = new List<string>();
  1884. string tid = GetPostString("ctid");
  1885. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1886. string shopname = GetPostString("shopname");
  1887. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1888. string buyernick = GetPostString("buyer_nick");
  1889. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1890. string ResponsibleMan = GetPostString("responsible");
  1891. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1892. string date1 = GetPostString("date1");
  1893. string date2 = GetPostString("date2");
  1894. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1895. if (dw.Length > 0) lw.Add(dw);
  1896. string price1 = GetPostString("price1");
  1897. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1898. string price2 = GetPostString("price2");
  1899. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1900. string orderState = GetPostString("orderState");
  1901. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1902. string sellermemo = GetPostString("seller_memo");
  1903. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1904. lw.Add(string.Format("UnusualTag > 0"));
  1905. lw.Add(string.Format("IsRefund<={0}", 1));
  1906. dStruct.Order = "pay_time desc";
  1907. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1908. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1909. writeGridDataTableJson(dStruct.TotalCount, dt);
  1910. }
  1911. public void set_erp_unusualtonomal()
  1912. {
  1913. if (UrlPostParmsCheck("ctid"))
  1914. {
  1915. string eid = GetPostString("ctid");
  1916. CeErpTradeCell entity = null;
  1917. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1918. if (entity != null)
  1919. {
  1920. entity.UnusualTag = -1;
  1921. entity.Update();
  1922. returnSuccessMsg("忽略成功!");
  1923. return;
  1924. }
  1925. returnErrorMsg("找不到记录");
  1926. }
  1927. }
  1928. public void ins_erp_unusualreason()
  1929. {
  1930. if (UrlPostParmsCheck("ctid"))
  1931. {
  1932. string eid = GetPostString("ctid");
  1933. CeErpTradeCell entity = null;
  1934. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1935. if (entity != null)
  1936. {
  1937. entity.MemoOpt = 4;
  1938. entity.UnusualCon = GetPostString("con");
  1939. entity.Update();
  1940. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1941. if (trade != null)
  1942. {
  1943. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1944. }
  1945. //查货是否超时
  1946. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1947. if (ceErpTradeCellExtend == null)
  1948. {
  1949. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1950. ceErpTradeCellExtend.ctid = entity.ctid;
  1951. }
  1952. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1953. {
  1954. ceErpTradeCellExtend.CheckOut += 1;
  1955. }
  1956. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1957. if (ceErpTradeCellExtend.ID > 0)
  1958. {
  1959. ceErpTradeCellExtend.Update();
  1960. }
  1961. else
  1962. {
  1963. ceErpTradeCellExtend.Create();
  1964. }
  1965. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1966. returnSuccessMsg("操作成功!");
  1967. return;
  1968. }
  1969. returnErrorMsg("找不到记录");
  1970. }
  1971. }
  1972. public void upd_erp_sampleorder()
  1973. {
  1974. if (UrlPostParmsCheck("ctid"))
  1975. {
  1976. string eid = GetPostString("ctid");
  1977. string[] eArr = eid.Split(',');
  1978. if (eArr.Length > 1)
  1979. {
  1980. List<string> eLst = new List<string>();
  1981. for (int i = 0; i < eArr.Length; i++)
  1982. {
  1983. eLst.Add("'" + eArr[i] + "'");
  1984. }
  1985. eid = string.Join(",", eLst.ToArray());
  1986. }
  1987. else
  1988. {
  1989. eid = "'" + eid + "'";
  1990. }
  1991. StringBuilder sql = new StringBuilder();
  1992. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1993. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1994. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1995. if (dt.Rows.Count > 0)
  1996. {
  1997. string errmsg = "";
  1998. foreach (DataRow dr in dt.Rows)
  1999. {
  2000. StringBuilder sqlsb = new StringBuilder();
  2001. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2002. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2003. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2004. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2005. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2006. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2007. {
  2008. continue;
  2009. }
  2010. else
  2011. {
  2012. string emsg = commonHelper.KeepChinese(apires);
  2013. errmsg += emsg;
  2014. }
  2015. }
  2016. if (errmsg.Length > 0)
  2017. {
  2018. returnErrorMsg(errmsg);
  2019. return;
  2020. }
  2021. returnSuccessMsg("操作成功");
  2022. return;
  2023. }
  2024. returnErrorMsg("找不到记录");
  2025. }
  2026. }
  2027. public void upd_erp_transcustomer()
  2028. {
  2029. if (UrlPostParmsCheck("ctid"))
  2030. {
  2031. string eid = GetPostString("ctid");
  2032. int userid = GetPostInt("CustomerUserId");
  2033. CeErpTradeCell entity = null;
  2034. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2035. if (entity != null)
  2036. {
  2037. //string[] mlist = entity.seller_memo.Split('-');
  2038. //string sql = "select * from view_erpuser where id=" + userid;
  2039. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2040. //if (dt != null && dt.Rows.Count > 0)
  2041. //{
  2042. // string nmemo = "";
  2043. // for(int i = 0; i < mlist.Length - 1; i++)
  2044. // {
  2045. // nmemo += mlist[i];
  2046. // nmemo += "-";
  2047. // }
  2048. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2049. // entity.seller_memo = nmemo;
  2050. //}
  2051. entity.CustomerUserId = userid;
  2052. entity.Update();
  2053. returnSuccessMsg("操作成功!");
  2054. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2055. return;
  2056. }
  2057. returnErrorMsg("找不到记录");
  2058. }
  2059. }
  2060. public void upd_erp_transdesigner()
  2061. {
  2062. if (UrlPostParmsCheck("ctid"))
  2063. {
  2064. string eids = GetPostString("ctid");
  2065. string[] ctidList = eids.Split(',');
  2066. int userid = GetPostInt("DesignUserId");
  2067. foreach (string ctid in ctidList)
  2068. {
  2069. CeErpTradeCell entity = null;
  2070. CeErpDesignerBill entitys = null;
  2071. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2072. entitys = CeErpDesignerBill.GetByTid(ctid);
  2073. if (entity != null)
  2074. {
  2075. if (entity.OrderState > 4)
  2076. {
  2077. continue;
  2078. }
  2079. //存在退款不能流转
  2080. if (entity.IsRefund > 0)
  2081. {
  2082. continue;
  2083. }
  2084. entity.DesignUserId = userid;
  2085. entity.WaitDesignTime = DateTime.Now;
  2086. entity.Update();
  2087. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2088. }
  2089. }
  2090. returnSuccessMsg("操作成功!");
  2091. }
  2092. }
  2093. public void upd_erp_distributedesigner()
  2094. {
  2095. if (UrlPostParmsCheck("ctid"))
  2096. {
  2097. string eid = GetPostString("ctid");
  2098. int userid = GetPostInt("DesignUserId");
  2099. string[] idlist = eid.Split(',');
  2100. if (idlist.Length <= 0)
  2101. {
  2102. returnErrorMsg("订单不能为空");
  2103. return;
  2104. }
  2105. foreach (string ctid in idlist)
  2106. {
  2107. CeErpTradeCell entity = null;
  2108. CeErpDesignerBill entitys = null;
  2109. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2110. else continue;
  2111. if (entity != null)
  2112. {
  2113. if (userid == 2125 || userid == 3542)
  2114. { }
  2115. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2116. {
  2117. returnErrorMsg("金额错误的订单无法指派");
  2118. return;
  2119. }
  2120. if (entity.OrderState >= 5)
  2121. {
  2122. returnErrorMsg("已经设计完成无法指派");
  2123. return;
  2124. }
  2125. if (entity.OrderState == -1)
  2126. {
  2127. returnErrorMsg("审核中的订单无法指派");
  2128. return;
  2129. }
  2130. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2131. {
  2132. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2133. return;
  2134. }
  2135. if (entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize")
  2136. {
  2137. returnErrorMsg("指派设计共创无法再次指派!");
  2138. return;
  2139. }
  2140. entity.OrderState = 3;
  2141. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2142. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2143. {
  2144. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2145. entity.SupplierId = suid;
  2146. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2147. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2148. }
  2149. if (userid == 2125 && entity.seller_memo != "")
  2150. {
  2151. apiDesign.API_GetPrintData_CreateOrder(entity);
  2152. }
  2153. if (userid == 3542 && entity.seller_memo != "")
  2154. {
  2155. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2156. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2157. if (response.msg != "设计共创:成功")
  2158. {
  2159. returnErrorMsg(response.msg);
  2160. return;
  2161. }
  2162. entity.DispatchSort = 2;
  2163. entity.OrderState = 3;
  2164. }
  2165. entity.DesignUserId = userid;
  2166. entity.WaitDesignTime = DateTime.Now;
  2167. entity.Update();
  2168. string name = commonHelper.getUserNameById(userid);
  2169. commonHelper.UpdateRelationOrder(entity.ctid);
  2170. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2171. }
  2172. }
  2173. returnSuccessMsg("操作成功!");
  2174. return;
  2175. }
  2176. }
  2177. public void get_erp_myorderlist()
  2178. {
  2179. DataStruct dStruct = GetPostStruct();
  2180. List<string> lw = new List<string>();
  2181. string tid = GetPostString("ctid");
  2182. if (tid.Length > 0)
  2183. {
  2184. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2185. }
  2186. else
  2187. {
  2188. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2189. }
  2190. //12-1 修改
  2191. string urgent = GetPostString("urgent");
  2192. string back = GetPostString("back");
  2193. string offlineSearch = GetPostString("offlineSearch");
  2194. if (!string.IsNullOrWhiteSpace(urgent))
  2195. {
  2196. if (urgent.Equals("true"))
  2197. {
  2198. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2199. }
  2200. }
  2201. if (!string.IsNullOrWhiteSpace(back))
  2202. {
  2203. if (back.Equals("true"))
  2204. {
  2205. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2206. }
  2207. }
  2208. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2209. {
  2210. if (offlineSearch.Equals("true"))
  2211. {
  2212. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2213. }
  2214. }
  2215. //end
  2216. string shopname = GetPostString("shopname");
  2217. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2218. string buyernick = GetPostString("buyer_nick");
  2219. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2220. string design = GetPostString("design");
  2221. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2222. string orderState = GetPostString("orderState");
  2223. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2224. string sellermemo = GetPostString("seller_memo");
  2225. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2226. string date1 = GetPostString("date1");
  2227. string date2 = GetPostString("date2");
  2228. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2229. if (dw.Length > 0) lw.Add(dw);
  2230. string price1 = GetPostString("price1");
  2231. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2232. string price2 = GetPostString("price2");
  2233. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2234. string urgency = GetPostString("urgency");
  2235. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2236. string after = GetPostString("after");
  2237. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2238. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2239. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2240. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2241. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2242. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2243. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2244. if (dt != null && dt.Rows.Count > 0)
  2245. {
  2246. foreach (DataRow dr in dt.Rows)
  2247. {
  2248. try
  2249. {
  2250. // 对象操作
  2251. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2252. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2253. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2254. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2255. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2256. if (dStruct.PageSize != 100000)
  2257. {
  2258. if (dr["DispatchSort"].ToString() == "2")
  2259. {
  2260. dr["gongchuang"] = 200;
  2261. }
  2262. else
  2263. {
  2264. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2265. dr["gongchuang"] = response.code;
  2266. }
  2267. }
  2268. }
  2269. catch (NullReferenceException ex)
  2270. {
  2271. }
  2272. }
  2273. }
  2274. writeGridDataTableJson(dStruct.TotalCount, dt);
  2275. }
  2276. public void get_erp_myreturnorderlist()
  2277. {
  2278. DataStruct dStruct = GetPostStruct();
  2279. List<string> lw = new List<string>();
  2280. string tid = GetPostString("ctid");
  2281. if (tid.Length > 0)
  2282. {
  2283. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  2284. }
  2285. else
  2286. {
  2287. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2288. }
  2289. string shopname = GetPostString("shopname");
  2290. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2291. string buyernick = GetPostString("buyer_nick");
  2292. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2293. string design = GetPostString("design");
  2294. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2295. string orderState = GetPostString("orderState");
  2296. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2297. string sellermemo = GetPostString("seller_memo");
  2298. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2299. string date1 = GetPostString("date1");
  2300. string date2 = GetPostString("date2");
  2301. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2302. if (dw.Length > 0) lw.Add(dw);
  2303. string price1 = GetPostString("price1");
  2304. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2305. string price2 = GetPostString("price2");
  2306. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2307. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2308. {
  2309. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2310. }
  2311. else
  2312. {
  2313. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2314. }
  2315. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2316. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2317. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2318. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2319. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2320. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2321. if (dt != null && dt.Rows.Count > 0)
  2322. {
  2323. foreach (DataRow dr in dt.Rows)
  2324. {
  2325. try
  2326. {
  2327. // 对象操作
  2328. if (dStruct.PageSize != 100000)
  2329. {
  2330. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2331. dr["gongchuang"] = response.code;
  2332. }
  2333. }
  2334. catch (NullReferenceException ex)
  2335. {
  2336. // 处理空引用异常
  2337. }
  2338. }
  2339. }
  2340. writeGridDataTableJson(dStruct.TotalCount, dt);
  2341. }
  2342. public void get_erp_myorderlist_pregather()
  2343. {
  2344. string date1 = GetPostString("date1");
  2345. string date2 = GetPostString("date2");
  2346. int userId = CurrentUser.UserID; //客服id
  2347. string orderWhere = "";
  2348. List<string> lw = new List<string>();
  2349. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2350. if (dw.Length > 0) lw.Add(dw);
  2351. lw.Add(string.Format("CustomerUserId={0}", userId));
  2352. lw.Add(string.Format("OrderState<9"));
  2353. orderWhere = string.Join(" and ", lw.ToArray());
  2354. string orderWhere2 = "";
  2355. List<string> lw2 = new List<string>();
  2356. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2357. if (dw2.Length > 0) lw2.Add(dw2);
  2358. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2359. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2360. string sql = string.Format("select *" +
  2361. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2362. "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 " +
  2363. "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 " +
  2364. "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");
  2365. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2366. //writeGridDataTableJson(dt.Rows.Count, dt);
  2367. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2368. }
  2369. public void upd_erp_publishorder()
  2370. {
  2371. if (UrlPostParmsCheck("ctid"))
  2372. {
  2373. string eid = GetPostString("ctid");
  2374. CeErpTradeCell entity = null;
  2375. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2376. if (entity != null)
  2377. {
  2378. entity.OrderState = 0; //发布后,变为待抢单
  2379. entity.Update();
  2380. commonHelper.UpdateRelationOrder(entity.ctid);
  2381. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2382. returnSuccessMsg("发布成功!");
  2383. return;
  2384. }
  2385. returnErrorMsg("找不到记录");
  2386. }
  2387. }
  2388. public void get_erp_my_tiporder()
  2389. {
  2390. StringBuilder sql = new StringBuilder();
  2391. int userId = 0;
  2392. if (CurrentUser != null) userId = CurrentUser.UserID;
  2393. string posCode = CurrentUser.UserPost.Post.Code;
  2394. string isTipedAfterSaleVerify = GetPostString("af");
  2395. DataTable dt = new DataTable();
  2396. if (posCode != "Supplier")
  2397. {
  2398. if (posCode == "CustomerService" || posCode == "Director")
  2399. {
  2400. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2401. }
  2402. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2403. {
  2404. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2405. }
  2406. else
  2407. {
  2408. string teamIds = CurrentUser.User.TeamIds;
  2409. if (teamIds == "")
  2410. {
  2411. teamIds = "0";
  2412. }
  2413. 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);
  2414. }
  2415. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2416. }
  2417. if (dt.Rows.Count <= 0)
  2418. {
  2419. string key = "aftersale_order_" + userId;
  2420. if (RedisHelper.HasKey(key))
  2421. {
  2422. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2423. dt.Columns.Add("ctid", typeof(string));
  2424. dt.Columns.Add("IsReadTag", typeof(int));
  2425. foreach (var i in list)
  2426. {
  2427. DataRow data = dt.NewRow();
  2428. data["ctid"] = i;
  2429. data["IsReadTag"] = 4;
  2430. dt.Rows.Add(data);
  2431. }
  2432. RedisHelper.StringDelete(key);
  2433. }
  2434. }
  2435. if (dt.Rows.Count <= 0)
  2436. {
  2437. sql = new StringBuilder();
  2438. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2439. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2440. }
  2441. if (posCode == "Supplier")
  2442. {
  2443. string ids = CurrentUser.User.pemVend;
  2444. if (ids != null && ids.Length > 0)
  2445. {
  2446. string[] ids_list = ids.Split(',');
  2447. foreach (var item in ids_list)
  2448. {
  2449. string key = "return_order_" + item;
  2450. if (RedisHelper.HasKey(key))
  2451. {
  2452. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2453. dt.Columns.Add("ctid", typeof(string));
  2454. dt.Columns.Add("IsReadTag", typeof(int));
  2455. foreach (var i in list)
  2456. {
  2457. DataRow data = dt.NewRow();
  2458. data["ctid"] = i;
  2459. data["IsReadTag"] = 1;
  2460. dt.Rows.Add(data);
  2461. }
  2462. RedisHelper.StringDelete(key);
  2463. }
  2464. }
  2465. }
  2466. if (dt.Rows.Count <= 0)
  2467. {
  2468. sql = new StringBuilder();
  2469. 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);
  2470. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2471. }
  2472. }
  2473. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2474. }
  2475. public void reset_erp_tiporder()
  2476. {
  2477. string ids = GetPostString("ids");
  2478. string[] ctidList = ids.Split(',');
  2479. foreach (string ctid in ctidList)
  2480. {
  2481. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2482. if (enty != null)
  2483. {
  2484. enty.IsReadTag = 0;
  2485. enty.Update();
  2486. }
  2487. }
  2488. returnSuccessMsg("成功!");
  2489. return;
  2490. }
  2491. public void get_erp_designlist()
  2492. {
  2493. DataStruct dStruct = GetPostStruct();
  2494. List<string> lw = new List<string>();
  2495. string tid = GetPostString("ctid");
  2496. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  2497. string shopname = GetPostString("shopname");
  2498. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2499. string buyernick = GetPostString("buyer_nick");
  2500. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2501. string customer = GetPostString("customer");
  2502. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2503. string design = GetPostString("design");
  2504. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2505. string orderState = GetPostString("orderState");
  2506. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2507. lw.Add(string.Format("OrderState<6"));
  2508. string address = GetPostString("address");
  2509. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2510. string sellermemo = GetPostString("seller_memo");
  2511. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2512. string date1 = GetPostString("date1");
  2513. string date2 = GetPostString("date2");
  2514. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2515. if (dw.Length > 0) lw.Add(dw);
  2516. string apdate1 = GetPostString("apdate1");
  2517. string apdate2 = GetPostString("apdate2");
  2518. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2519. if (dwap.Length > 0) lw.Add(dwap);
  2520. string price1 = GetPostString("price1");
  2521. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2522. string price2 = GetPostString("price2");
  2523. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2524. string designTime = GetPostString("designtime");
  2525. if (designTime.Length > 0)
  2526. {
  2527. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2528. }
  2529. string usershop = CurrentUser.User.pemShop;
  2530. if (usershop.Length > 0)
  2531. {
  2532. lw.Add(string.Format("shopId in ({0})", usershop));
  2533. }
  2534. int myOrgid = CurrentUser.UserPost.OrgID;
  2535. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2536. if (myOrgCode.IndexOf("Designer") != -1)
  2537. {
  2538. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2539. {
  2540. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2541. }
  2542. else
  2543. {
  2544. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2545. }
  2546. }
  2547. else
  2548. {
  2549. string orgId = GetPostString("designerhd");
  2550. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2551. }
  2552. if (tid.Length > 0 || buyernick.Length > 0)
  2553. {
  2554. lw.Add(string.Format("OrderState >= 3"));
  2555. }
  2556. else
  2557. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2558. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2559. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2560. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2561. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2562. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2563. if (dt != null && dt.Rows.Count > 0)
  2564. {
  2565. foreach (DataRow dr in dt.Rows)
  2566. {
  2567. try
  2568. {
  2569. // 对象操作
  2570. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2571. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2572. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2573. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2574. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2575. if (dStruct.PageSize != 100000)
  2576. {
  2577. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2578. dr["gongchuang"] = response.code;
  2579. }
  2580. }
  2581. catch (NullReferenceException ex)
  2582. {
  2583. }
  2584. }
  2585. }
  2586. writeGridDataTableJson(dStruct.TotalCount, dt);
  2587. }
  2588. public void get_erp_mydesignlist()
  2589. {
  2590. DataStruct dStruct = GetPostStruct();
  2591. List<string> lw = new List<string>();
  2592. string tid = GetPostString("ctid");
  2593. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2594. string shopname = GetPostString("shopname");
  2595. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2596. string buyernick = GetPostString("buyer_nick");
  2597. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2598. string customer = GetPostString("customer");
  2599. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2600. string orderState = GetPostString("orderState");
  2601. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2602. //lw.Add(string.Format("OrderState<6"));
  2603. string date1 = GetPostString("date1");
  2604. string date2 = GetPostString("date2");
  2605. string dw = GetDateWhere("pay_time", date1, date2);
  2606. if (dw.Length > 0) lw.Add(dw);
  2607. string apdate1 = GetPostString("apdate1");
  2608. string apdate2 = GetPostString("apdate2");
  2609. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2610. if (dwap.Length > 0) lw.Add(dwap);
  2611. string price1 = GetPostString("price1");
  2612. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2613. string price2 = GetPostString("price2");
  2614. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2615. string olddownload = GetPostString("olddown");
  2616. if (olddownload == "1")
  2617. {
  2618. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2619. }
  2620. else if (olddownload == "2")
  2621. {
  2622. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2623. }
  2624. string sellermemo = GetPostString("seller_memo");
  2625. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2626. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2627. if (CurrentUser.User.TeamIds.Length > 0)
  2628. {
  2629. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2630. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2631. else
  2632. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2633. }
  2634. else
  2635. {
  2636. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2637. }
  2638. if (tid.Length <= 0)
  2639. {
  2640. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2641. }
  2642. lw.Add(string.Format("IsReturn!=3"));
  2643. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2644. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2645. string teamids = CurrentUser.User.TeamIds.ToString();
  2646. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2647. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2648. if (dt != null && dt.Rows.Count > 0)
  2649. {
  2650. foreach (DataRow dr in dt.Rows)
  2651. {
  2652. try
  2653. {
  2654. // 对象操作
  2655. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2656. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2657. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2658. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2659. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2660. if (dStruct.PageSize != 100000)
  2661. {
  2662. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2663. dr["gongchuang"] = response.code;
  2664. }
  2665. }
  2666. catch (NullReferenceException ex)
  2667. {
  2668. }
  2669. }
  2670. }
  2671. writeGridDataTableJson(dStruct.TotalCount, dt);
  2672. }
  2673. public void set_erp_startdesign()
  2674. {
  2675. if (UrlPostParmsCheck("ctid"))
  2676. {
  2677. string eid = GetPostString("ctid");
  2678. CeErpTradeCell entity = null;
  2679. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2680. if (entity != null)
  2681. {
  2682. if (entity.OrderState != 3)
  2683. {
  2684. returnErrorMsg("请刷新,订单已经设计了");
  2685. return;
  2686. }
  2687. entity.StartDesignTime = DateTime.Now;
  2688. entity.OrderState = 4;
  2689. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2690. {
  2691. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2692. entity.SupplierId = suid;
  2693. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2694. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2695. }
  2696. //entity.MakeSupplier = suname;
  2697. entity.Update();
  2698. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2699. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2700. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2701. commonHelper.getCytPrice(entity);
  2702. returnSuccessMsg("操作成功!");
  2703. return;
  2704. }
  2705. returnErrorMsg("找不到记录");
  2706. }
  2707. }
  2708. public void ins_erp_designselfmemo()
  2709. {
  2710. if (UrlPostParmsCheck("ctid"))
  2711. {
  2712. string eid = GetPostString("ctid");
  2713. string con = GetPostString("con");
  2714. CeErpTradeCell entity = null;
  2715. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2716. if (entity != null)
  2717. {
  2718. entity.DesignSelfMemo = con;
  2719. entity.Update();
  2720. returnSuccessMsg("操作成功!");
  2721. return;
  2722. }
  2723. returnErrorMsg("找不到记录");
  2724. }
  2725. }
  2726. public void ins_erp_designprice()
  2727. {
  2728. if (UrlPostParmsCheck("ctid"))
  2729. {
  2730. string eid = GetPostString("ctid");
  2731. int uid = CurrentUser.UserID;
  2732. string userName = CurrentUser.UserName;
  2733. CeErpTradeCell entity = null;
  2734. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2735. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2736. if (entitys == null)
  2737. {
  2738. entitys = new CeErpDesignerBill();
  2739. }
  2740. if (entity != null)
  2741. {
  2742. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2743. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2744. entity.StartDesignTime = DateTime.Now;
  2745. entity.OrderState = 4;
  2746. string suname = "";
  2747. if (entity.SupplierId == 0)
  2748. {
  2749. int sid = commonHelper.autoDistributeToSupplier(entity);
  2750. entity.SupplierId = sid;
  2751. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2752. }
  2753. entity.Update();
  2754. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2755. if (ceErpUserPost != null)
  2756. {
  2757. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2758. if (ceErpPost != null)
  2759. {
  2760. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2761. {
  2762. entitys.tid = entity.ctid;
  2763. entitys.oid = entity.tid;
  2764. entitys.uid = uid;
  2765. entitys.userName = userName;
  2766. entitys.designerType = 1;
  2767. entitys.designerTypeText = "内部设计师";
  2768. entitys.price = Convert.ToDouble(GetPostString("price"));
  2769. entitys.designNum = GetPostInt("designNum");
  2770. entitys.modifyNum = GetPostInt("modifyNum");
  2771. entitys.designSize = GetPostString("designSize");
  2772. entitys.modifySize = GetPostString("modifySize");
  2773. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2774. {
  2775. entitys.create_time = DateTime.Now;
  2776. entitys.create_u_id = uid;
  2777. entitys.create_u_name = userName;
  2778. entitys.Save();
  2779. }
  2780. else
  2781. {
  2782. entitys.update_time = DateTime.Now;
  2783. entitys.update_u_id = uid;
  2784. entitys.update_u_name = userName;
  2785. entitys.Update();
  2786. }
  2787. }
  2788. }
  2789. }
  2790. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2791. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2792. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2793. if (suname != "")
  2794. {
  2795. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2796. }
  2797. commonHelper.getCytPrice(entity);
  2798. returnSuccessMsg("操作成功!");
  2799. return;
  2800. }
  2801. returnErrorMsg("找不到记录");
  2802. }
  2803. }
  2804. public void upload_erp_filecomplete()
  2805. {
  2806. if (UrlPostParmsCheck("ctid"))
  2807. {
  2808. string eid = GetPostString("ctid");
  2809. CeErpTradeCell entity = null;
  2810. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2811. if (entity != null)
  2812. {
  2813. entity.OrderState = 5; //设计完成
  2814. entity.Update();
  2815. returnSuccessMsg(eid + "上传成功,设计完成!");
  2816. return;
  2817. }
  2818. returnErrorMsg("找不到订单记录");
  2819. }
  2820. }
  2821. public void get_erp_designovertimelist()
  2822. {
  2823. DataStruct dStruct = GetPostStruct();
  2824. List<string> lw = new List<string>();
  2825. string tid = GetPostString("ctid");
  2826. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2827. string shopname = GetPostString("shopname");
  2828. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2829. string buyernick = GetPostString("buyer_nick");
  2830. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2831. string ResponsibleMan = GetPostString("responsible");
  2832. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2833. string date1 = GetPostString("date1");
  2834. string date2 = GetPostString("date2");
  2835. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2836. if (dw.Length > 0) lw.Add(dw);
  2837. string price1 = GetPostString("price1");
  2838. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2839. string price2 = GetPostString("price2");
  2840. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2841. string orderState = GetPostString("orderState");
  2842. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2843. string sellermemo = GetPostString("seller_memo");
  2844. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2845. lw.Add(string.Format("UnusualTag=3"));
  2846. lw.Add(string.Format("IsRefund<={0}", 1));
  2847. dStruct.Order = "WaitDesignTime desc";
  2848. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2849. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2850. writeGridDataTableJson(dStruct.TotalCount, dt);
  2851. }
  2852. //设计管理 获取抢单大厅列表
  2853. public void get_erp_grabinglist()
  2854. {
  2855. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2856. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2857. bool oldOrder = false;
  2858. if (org != null)
  2859. {
  2860. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2861. }
  2862. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2863. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2864. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2865. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2866. //先处理订单数据
  2867. if (dt.Rows.Count > 0)
  2868. {
  2869. Dictionary<string, int> design = null;
  2870. int count = 0;
  2871. foreach (DataRow row in dt.Rows)
  2872. {
  2873. if (map.ContainsKey(row["ShopId"].ToString()))
  2874. {
  2875. map.TryGetValue(row["ShopId"].ToString(), out design);
  2876. }
  2877. else
  2878. {
  2879. design = new Dictionary<string, int>();
  2880. }
  2881. if (design.ContainsKey(row["ProductId"].ToString()))
  2882. {
  2883. design.TryGetValue(row["ProductId"].ToString(), out count);
  2884. }
  2885. count++;
  2886. design[row["ProductId"].ToString()] = count;
  2887. map[row["ShopId"].ToString()] = design;
  2888. }
  2889. }
  2890. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2891. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2892. //把店铺排序和技能排序分类
  2893. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2894. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2895. if (design_dt.Rows.Count > 0)
  2896. {
  2897. Dictionary<string, string> design = null;
  2898. List<string> shopIds = null;
  2899. foreach (DataRow row in design_dt.Rows)
  2900. {
  2901. if ("0".Equals(row["designId"].ToString()))
  2902. {
  2903. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2904. {
  2905. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2906. }
  2907. else
  2908. {
  2909. shopIds = new List<string>();
  2910. }
  2911. shopIds.Add(row["shopId"].ToString());
  2912. shop_orders[row["orders"].ToString()] = shopIds;
  2913. }
  2914. else
  2915. {
  2916. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2917. {
  2918. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2919. }
  2920. else
  2921. {
  2922. design = new Dictionary<string, string>();
  2923. }
  2924. design[row["orders"].ToString()] = row["designId"].ToString();
  2925. design_orders[row["shopId"].ToString()] = design;
  2926. }
  2927. }
  2928. //处理成key value后根据key排序
  2929. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2930. foreach (List<string> val in shop_orders.Values)
  2931. {
  2932. if (val != null)
  2933. {
  2934. foreach (string key in val)
  2935. {
  2936. if (design_orders.ContainsKey(key.ToString()))
  2937. {
  2938. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2939. }
  2940. }
  2941. }
  2942. }
  2943. }
  2944. //校验哪个优先级有订单
  2945. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2946. foreach (string key in shop_orders.Keys)
  2947. {
  2948. List<string> ids = null;
  2949. shop_orders.TryGetValue(key, out ids);
  2950. //id为shopid
  2951. foreach (string id in ids)
  2952. {
  2953. Dictionary<string, int> list = null;
  2954. Dictionary<string, string> desing = null;
  2955. map.TryGetValue(id, out list);
  2956. design_orders.TryGetValue(id, out desing);
  2957. if (list != null && desing != null)
  2958. {
  2959. foreach (var item in desing)
  2960. {
  2961. int count = 0;
  2962. if (list.ContainsKey(item.Value))
  2963. {
  2964. list.TryGetValue(item.Value, out count);
  2965. if (count > 0)
  2966. {
  2967. designIds[id] = item.Value;
  2968. break;
  2969. }
  2970. }
  2971. }
  2972. }
  2973. }
  2974. if (designIds.Count > 0)
  2975. {
  2976. break;
  2977. }
  2978. }
  2979. DataTable table = new DataTable();
  2980. table.Columns.Add("tid", typeof(string));
  2981. table.Columns.Add("ctid", typeof(string));
  2982. table.Columns.Add("seller_nick", typeof(string));
  2983. table.Columns.Add("productName", typeof(string));
  2984. table.Columns.Add("pay_time", typeof(string));
  2985. table.Columns.Add("seller_memo", typeof(string));
  2986. if (designIds.Count > 0)
  2987. {
  2988. string shopId = "";
  2989. string productId = "";
  2990. foreach (var designInfo in designIds)
  2991. {
  2992. shopId = designInfo.Key;
  2993. productId = designInfo.Value;
  2994. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  2995. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  2996. if (dt.Rows.Count > 0)
  2997. {
  2998. foreach (DataRow row in dt.Rows)
  2999. {
  3000. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3001. {
  3002. DataRow data = table.NewRow();
  3003. data["ctid"] = row["ctid"].ToString();
  3004. data["tid"] = row["tid"].ToString();
  3005. data["seller_nick"] = ceErpShop.ShopName;
  3006. data["pay_time"] = row["pay_time"].ToString();
  3007. data["seller_memo"] = row["seller_memo"].ToString();
  3008. data["productName"] = ceErpProduct.PType;
  3009. table.Rows.Add(data);
  3010. }
  3011. }
  3012. }
  3013. }
  3014. }
  3015. writeGridDataTableJson(table.Rows.Count, table);
  3016. }
  3017. private object rushLockObject = new object();
  3018. public void set_erp_grabingorder()
  3019. {
  3020. if (UrlPostParmsCheck("ctid"))
  3021. {
  3022. int total = CurrentUser.User.Person.Total;
  3023. int userId = CurrentUser.User.ID;
  3024. int noFinish = CurrentUser.User.Person.NoFinish;
  3025. int finalization = CurrentUser.User.Person.Finalization;
  3026. string eids = GetPostString("ctid");
  3027. string key = "RushKey_" + userId;
  3028. int count = 0;
  3029. if (erpRedis.RedisHelper.KeyExists(key))
  3030. {
  3031. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3032. if (redisCount != null)
  3033. {
  3034. count = Convert.ToInt32(redisCount);
  3035. }
  3036. }
  3037. if (count >= total)
  3038. {
  3039. returnErrorMsg("半小时内已经抢" + total + "单");
  3040. return;
  3041. }
  3042. string[] ctidlist = eids.Split(',');
  3043. if (count + ctidlist.Length > total)
  3044. {
  3045. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3046. return;
  3047. }
  3048. int itag = 0;
  3049. lock (rushLockObject)
  3050. {
  3051. if (ctidlist.Length > 0)
  3052. {
  3053. string[] dtList = new string[ctidlist.Length];
  3054. for (int i = 0; i < ctidlist.Length; i++)
  3055. {
  3056. dtList[i] = "'" + ctidlist[i] + "'";
  3057. }
  3058. 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"));
  3059. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3060. if (dt_user.Rows.Count > 0)
  3061. {
  3062. int doing = 0;//未定稿
  3063. int finish = 0;//已完成
  3064. foreach (DataRow dr in dt_user.Rows)
  3065. {
  3066. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3067. {
  3068. doing++;
  3069. }
  3070. else
  3071. {
  3072. finish++;
  3073. }
  3074. }
  3075. if (doing >= noFinish)
  3076. {
  3077. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3078. return;
  3079. }
  3080. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3081. {
  3082. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3083. return;
  3084. }
  3085. }
  3086. //校验选择单子状态
  3087. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3088. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3089. if (dt.Rows.Count > 0)
  3090. {
  3091. List<string> list = new List<string>();
  3092. foreach (DataRow dr in dt.Rows)
  3093. {
  3094. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3095. {
  3096. list.Add(dr["ctid"].ToString());
  3097. }
  3098. }
  3099. if (list.Count > 0)
  3100. {
  3101. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3102. return;
  3103. }
  3104. }
  3105. foreach (string ctid in ctidlist)
  3106. {
  3107. CeErpTradeCell entity = null;
  3108. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3109. if (entity != null)
  3110. {
  3111. entity.OrderState = 3;
  3112. entity.DesignUserId = CurrentUser.UserID;
  3113. entity.WaitDesignTime = DateTime.Now;
  3114. entity.StartDesignTime = DateTime.Now;
  3115. entity.Update();
  3116. commonHelper.UpdateRelationOrder(entity.ctid);
  3117. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3118. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3119. itag++;
  3120. }
  3121. }
  3122. }
  3123. }
  3124. count += ctidlist.Length;
  3125. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3126. if (itag == 0)
  3127. returnErrorMsg("没有找到相关订单");
  3128. else
  3129. returnSuccessMsg("抢单成功!");
  3130. return;
  3131. }
  3132. }
  3133. public void get_erp_waitorderlist()
  3134. {
  3135. DataStruct dStruct = GetPostStruct();
  3136. List<string> lw = new List<string>();
  3137. string tid = GetPostString("ctid");
  3138. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3139. string shopname = GetPostString("shopname");
  3140. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3141. string buyernick = GetPostString("buyer_nick");
  3142. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3143. string customer = GetPostString("customer");
  3144. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3145. string design = GetPostString("design");
  3146. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3147. string orderState = GetPostString("orderState");
  3148. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3149. string supplier = GetPostString("supplier");
  3150. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3151. string sellermemo = GetPostString("seller_memo");
  3152. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3153. string otherMemo = GetPostString("otherMemo");
  3154. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3155. string address = GetPostString("address");
  3156. 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));
  3157. string date1 = GetPostString("date1");
  3158. string date2 = GetPostString("date2");
  3159. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3160. if (dw.Length > 0) lw.Add(dw);
  3161. string price1 = GetPostString("price1");
  3162. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3163. string price2 = GetPostString("price2");
  3164. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3165. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3166. lw.Add(string.Format("IsSample != 2 "));
  3167. lw.Add(string.Format("OrderState = 5 "));
  3168. lw.Add(string.Format("IsRefund<={0}", 1));
  3169. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3170. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3171. string pagesize = GetPostString("pagesize");
  3172. if (pagesize != null)
  3173. {
  3174. dStruct.PageSize = 200;
  3175. }
  3176. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3177. foreach (DataRow dr in dt.Rows)
  3178. {
  3179. 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();
  3180. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3181. {
  3182. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3183. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3184. entity.SupplierId = suid;
  3185. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3186. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3187. entity.Update();
  3188. }
  3189. }
  3190. writeGridDataTableJson(dStruct.TotalCount, dt);
  3191. }
  3192. public void get_erp_supplierwaitorderlist()
  3193. {
  3194. DataStruct dStruct = GetPostStruct();
  3195. List<string> lw = new List<string>();
  3196. string tid = GetPostString("ctid");
  3197. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3198. string shopname = GetPostString("shopname");
  3199. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3200. string sellermemo = GetPostString("seller_memo");
  3201. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3202. string date1 = GetPostString("date1");
  3203. string date2 = GetPostString("date2");
  3204. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3205. if (dw.Length > 0) lw.Add(dw);
  3206. lw.Add(string.Format("OrderState = 5 "));
  3207. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3208. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3209. {
  3210. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3211. }
  3212. string supplier = GetPostString("supplier");
  3213. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3214. {
  3215. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3216. }
  3217. lw.Add(string.Format("IsRefund<={0}", 1));
  3218. dStruct.Order = "FinishDesignTime desc";
  3219. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3220. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3221. if (dt != null)
  3222. {
  3223. foreach (DataRow dr in dt.Rows)
  3224. {
  3225. 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();
  3226. }
  3227. }
  3228. writeGridDataTableJson(dStruct.TotalCount, dt);
  3229. }
  3230. public void upd_erp_verifytosupplier()
  3231. {
  3232. if (UrlPostParmsCheck("ctid"))
  3233. {
  3234. string eids = GetPostString("ctid");
  3235. CeErpTradeCell entity = null;
  3236. string[] eidsList = eids.Split(',');
  3237. if (eidsList.Length <= 0)
  3238. {
  3239. returnErrorMsg("订单号不能空");
  3240. return;
  3241. }
  3242. List<string> tLst = new List<string>();
  3243. foreach (string ctidstr in eidsList)
  3244. {
  3245. tLst.Add("'" + ctidstr + "'");
  3246. CeErpDataSendOrderInfo.createObject(ctidstr);
  3247. }
  3248. string needtids = string.Join(",", tLst.ToArray());
  3249. StringBuilder sql = new StringBuilder();
  3250. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3251. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3252. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3253. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3254. returnSuccessMsg("操作成功!");
  3255. return;
  3256. /**foreach (string ctidstr in eidsList)
  3257. {
  3258. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3259. if (entity != null)
  3260. {
  3261. if (entity.SupplierId == 0)
  3262. {
  3263. continue;
  3264. }
  3265. entity.IsVerifyToSupplier = true;
  3266. if (entity.IsReturn == 1) //1是供应商打回
  3267. {
  3268. entity.IsReturn = 0;
  3269. }
  3270. entity.FinishPlaceTime = DateTime.Now;
  3271. entity.PlaceUserId = CurrentUser.UserID;
  3272. entity.Update();
  3273. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3274. }
  3275. }
  3276. returnSuccessMsg("操作成功!");
  3277. return;**/
  3278. }
  3279. }
  3280. public void upd_erp_supplierback()
  3281. {
  3282. if (UrlPostParmsCheck("ctid"))
  3283. {
  3284. string eid = GetPostString("ctid");
  3285. string reason = GetPostString("returnreason");
  3286. CeErpTradeCell entity = null;
  3287. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3288. if (entity != null)
  3289. {
  3290. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3291. {
  3292. string key = "return_order_" + entity.SupplierId;
  3293. List<string> list = new List<string>();
  3294. if (RedisHelper.HasKey(key))
  3295. {
  3296. object data = RedisHelper.StringGet(key);
  3297. list = Convert.ToString(data).Split(',').ToList();
  3298. }
  3299. list.Add(eid);
  3300. RedisHelper.StringSet(key, string.Join(",", list));
  3301. }
  3302. entity.IsVerifyToSupplier = false;
  3303. entity.IsReturn = 1;
  3304. entity.ReturnTime = DateTime.Now;
  3305. entity.ReturnReason = reason;
  3306. if (entity.OrderState == 6)
  3307. {
  3308. entity.OrderState = 5;
  3309. }
  3310. entity.Update();
  3311. CeErpSukuraData.createInfo(entity.ctid, 5);
  3312. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3313. returnSuccessMsg("操作成功!");
  3314. return;
  3315. }
  3316. returnErrorMsg("找不到订单记录");
  3317. }
  3318. }
  3319. public void upd_erp_toaftersaleorder()
  3320. {
  3321. if (UrlPostParmsCheck("ctid"))
  3322. {
  3323. string eid = GetPostString("ctid");
  3324. string reason = GetPostString("returnreason");
  3325. CeErpTradeCell entity = null;
  3326. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3327. if (entity != null)
  3328. {
  3329. if (entity.isAfterSaleOrder != 1)
  3330. {
  3331. returnErrorMsg("带S的售后单才能打回给售后");
  3332. return;
  3333. }
  3334. if (entity.OrderState >= 5)
  3335. {
  3336. returnErrorMsg("已经设计完成了不能打回给售后");
  3337. return;
  3338. }
  3339. entity.OrderState = 0;
  3340. entity.IsReturn = 3;
  3341. entity.ReturnTime = DateTime.Now;
  3342. entity.ReturnReason = reason;
  3343. entity.Update();
  3344. CeErpSukuraData.createInfo(entity.ctid, 5);
  3345. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3346. returnSuccessMsg("操作成功!");
  3347. return;
  3348. }
  3349. returnErrorMsg("找不到订单记录");
  3350. }
  3351. }
  3352. public void upd_erp_aftersaletodesign()
  3353. {
  3354. if (UrlPostParmsCheck("ctid"))
  3355. {
  3356. string eid = GetPostString("ctid");
  3357. CeErpTradeCell entity = null;
  3358. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3359. if (entity != null)
  3360. {
  3361. entity.OrderState = 3;
  3362. entity.IsReturn = 0;
  3363. entity.Update();
  3364. CeErpSukuraData.createInfo(entity.ctid, 5);
  3365. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3366. returnSuccessMsg("操作成功!");
  3367. return;
  3368. }
  3369. returnErrorMsg("找不到订单记录");
  3370. }
  3371. }
  3372. public void assign_erp_supplier()
  3373. {
  3374. if (UrlPostParmsCheck("ctid"))
  3375. {
  3376. string eids = GetPostString("ctid");
  3377. int sid = GetPostInt("SupplierName");
  3378. string fromTag = GetPostString("tag");
  3379. string[] eidList = eids.Split(',');
  3380. if (eidList.Length <= 0)
  3381. {
  3382. returnErrorMsg("指派不能为空");
  3383. return;
  3384. }
  3385. string errMsg = "";
  3386. string suname = commonHelper.getSupplierNameById(sid);
  3387. foreach (string ctid in eidList)
  3388. {
  3389. CeErpTradeCell entity = null;
  3390. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3391. if (entity != null)
  3392. {
  3393. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3394. {
  3395. errMsg += (ctid + "指派失败!!!");
  3396. continue;
  3397. }
  3398. entity.SupplierId = sid;
  3399. entity.Update();
  3400. commonHelper.UpdateRelationOrder(entity.ctid);
  3401. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3402. if (entity.OrderState >= 6)
  3403. {
  3404. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3405. //{
  3406. // string msl = entity.MakeSupplier;
  3407. // string[] mslist = msl.Split(',');
  3408. // 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);
  3409. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3410. //}
  3411. //else
  3412. //{
  3413. StringBuilder sql = new StringBuilder();
  3414. 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);
  3415. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3416. //}
  3417. }
  3418. }
  3419. else
  3420. {
  3421. continue;
  3422. }
  3423. }
  3424. if (errMsg.Length > 0)
  3425. {
  3426. returnErrorMsg(errMsg);
  3427. return;
  3428. }
  3429. returnSuccessMsg("操作成功!");
  3430. return;
  3431. }
  3432. }
  3433. public void assign_erp_makesupplier()
  3434. {
  3435. if (UrlPostParmsCheck("ctid"))
  3436. {
  3437. string eids = GetPostString("ctid");
  3438. string sname = GetPostString("SupplierName");
  3439. string[] eidList = eids.Split(',');
  3440. if (eidList.Length <= 0)
  3441. {
  3442. returnErrorMsg("指派不能为空");
  3443. return;
  3444. }
  3445. List<string> tLst = new List<string>();
  3446. foreach (string ctid in eidList)
  3447. {
  3448. CeErpTradeCell entity = null;
  3449. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3450. if (entity != null)
  3451. {
  3452. entity.MakeSupplier = sname;
  3453. entity.Update();
  3454. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3455. tLst.Add("'" + ctid + "'");
  3456. }
  3457. else
  3458. {
  3459. continue;
  3460. }
  3461. }
  3462. string ctids = string.Join(",", tLst.ToArray());
  3463. StringBuilder sql2 = new StringBuilder();
  3464. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3465. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3466. returnSuccessMsg("操作成功!");
  3467. return;
  3468. }
  3469. }
  3470. public void ins_erp_returnreason()
  3471. {
  3472. if (UrlPostParmsCheck("ctid"))
  3473. {
  3474. string eid = GetPostString("ctid");
  3475. CeErpTradeCell entity = null;
  3476. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3477. string userpost = CurrentUser.UserPost.Post.Code;
  3478. if (entity != null)
  3479. {
  3480. bool isPlace = false;
  3481. if (entity.OrderState > 6)
  3482. {
  3483. returnErrorMsg("已发货无法打回!");
  3484. return;
  3485. }
  3486. if (entity.OrderState == 6)
  3487. {
  3488. isPlace = true;
  3489. }
  3490. bool isNeedUpdateCell2 = false;
  3491. if (entity.OrderState >= 6)
  3492. {
  3493. isNeedUpdateCell2 = true;
  3494. }
  3495. int returnTag = 2;
  3496. if (userpost == "Supplier")
  3497. {
  3498. returnTag = 1;
  3499. }
  3500. int toType = GetPostInt("totype");
  3501. string fromType = "3";
  3502. if (entity.OrderState < 5)
  3503. {
  3504. fromType = "3";
  3505. }
  3506. else
  3507. {
  3508. fromType = "4";
  3509. }
  3510. if (entity.IsXianHuo == 0)
  3511. {
  3512. if (returnTag == 2)
  3513. {
  3514. if (toType == 1)
  3515. {
  3516. entity.OrderState = 0;
  3517. entity.ReturnUserType = 1;
  3518. string clearman = GetPostString("clearman");
  3519. if (!string.IsNullOrEmpty(clearman))
  3520. {
  3521. entity.DesignUserId = 0;
  3522. }
  3523. }
  3524. else
  3525. {
  3526. entity.OrderState = 3;
  3527. entity.ReturnUserType = 2;
  3528. }
  3529. entity.IsReadTag = 1;
  3530. }
  3531. else if (returnTag == 1)
  3532. {
  3533. entity.OrderState = 5;
  3534. }
  3535. entity.IsVerifyToSupplier = false;
  3536. }
  3537. if (entity.IsXianHuo == 1)
  3538. {
  3539. entity.OrderState = 5;
  3540. }
  3541. entity.UnusualTag = 0;
  3542. entity.UnusualTime = null;
  3543. entity.UnusualCon = "";
  3544. entity.IsReturn = returnTag;
  3545. entity.ReturnTime = DateTime.Now;
  3546. entity.ReturnReason = GetPostString("returnreason");
  3547. entity.Update();
  3548. if (entity.OrderState == 3)
  3549. {
  3550. ApiVo apiVo = new ApiVo();
  3551. apiVo.orderNumber = entity.ctid;
  3552. apiVo.actionName = "rebutDesign";
  3553. apiVo.orderRemarks = entity.ReturnReason;
  3554. designHelper.API_WorkCore(apiVo);//rebutDesign
  3555. }
  3556. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3557. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3558. {
  3559. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3560. }
  3561. CeErpSukuraData.createInfo(entity.ctid, 5);
  3562. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3563. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3564. if (isPlace)
  3565. {
  3566. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3567. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3568. if (dth != null && dth.Rows.Count > 0)
  3569. {
  3570. dataSendOrderBean dataSendOrderBean = null;
  3571. foreach (DataRow item in dth.Rows)
  3572. {
  3573. try
  3574. {
  3575. dataSendOrderBean = new dataSendOrderBean();
  3576. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3577. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3578. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3579. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3580. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3581. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3582. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3583. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3584. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3585. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3586. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3587. dataSendOrderBean.Radio1723534706288 = "打回";
  3588. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3589. if (result != null)
  3590. {
  3591. if ("0".Equals(result.errcode))
  3592. {
  3593. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3594. }
  3595. else
  3596. {
  3597. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3598. }
  3599. }
  3600. }
  3601. catch (Exception ex)
  3602. {
  3603. }
  3604. }
  3605. }
  3606. }
  3607. if (isNeedUpdateCell2)
  3608. {
  3609. if (entity.MakeSupplier.IndexOf(",") != -1)
  3610. {
  3611. StringBuilder sql2 = new StringBuilder();
  3612. 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);
  3613. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3614. }
  3615. else
  3616. {
  3617. StringBuilder sql2 = new StringBuilder();
  3618. 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);
  3619. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3620. }
  3621. }
  3622. returnSuccessMsg("操作成功!");
  3623. return;
  3624. }
  3625. returnErrorMsg("找不到订单记录");
  3626. }
  3627. }
  3628. public void cyt_erp_returnreason()
  3629. {
  3630. if (UrlPostParmsCheck("ctid"))
  3631. {
  3632. string eid = GetPostString("ctid");
  3633. CeErpTradeCell entity = null;
  3634. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3635. string userpost = CurrentUser.UserPost.Post.Code;
  3636. if (entity != null)
  3637. {
  3638. if (entity.OrderState > 6)
  3639. {
  3640. returnErrorMsg("已发货无法打回!");
  3641. return;
  3642. }
  3643. JObject jsonObject = new JObject
  3644. {
  3645. { "Userid", "77886" },
  3646. { "Pwd", "lt666888" },
  3647. { "LTOrderId",eid }
  3648. };
  3649. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3650. JObject jsonObjects = JObject.Parse(response);
  3651. string msg = (string)jsonObjects["msg"];
  3652. if (msg != "取消成功")
  3653. {
  3654. returnErrorMsg(msg);
  3655. return;
  3656. }
  3657. bool isNeedUpdateCell2 = false;
  3658. if (entity.OrderState >= 6)
  3659. {
  3660. isNeedUpdateCell2 = true;
  3661. }
  3662. int returnTag = 2;
  3663. if (userpost == "Supplier")
  3664. {
  3665. returnTag = 1;
  3666. }
  3667. if (entity.IsXianHuo == 0)
  3668. {
  3669. if (returnTag == 2)
  3670. {
  3671. int toType = GetPostInt("totype");
  3672. if (toType == 1)
  3673. {
  3674. entity.OrderState = 0;
  3675. entity.ReturnUserType = 1;
  3676. }
  3677. else
  3678. {
  3679. entity.OrderState = 4;
  3680. entity.ReturnUserType = 2;
  3681. }
  3682. entity.IsReadTag = 1;
  3683. }
  3684. else if (returnTag == 1)
  3685. {
  3686. entity.OrderState = 5;
  3687. }
  3688. entity.IsVerifyToSupplier = false;
  3689. }
  3690. entity.UnusualTag = 0;
  3691. entity.UnusualTime = null;
  3692. entity.UnusualCon = "";
  3693. entity.IsReturn = returnTag;
  3694. entity.ReturnTime = DateTime.Now;
  3695. entity.ReturnReason = GetPostString("returnreason");
  3696. entity.Update();
  3697. if (entity.OrderState == 4)
  3698. {
  3699. ApiVo apiVo = new ApiVo();
  3700. apiVo.orderNumber = entity.ctid;
  3701. apiVo.actionName = "rebutDesign";
  3702. apiVo.orderRemarks = entity.ReturnReason;
  3703. designHelper.API_WorkCore(apiVo);//rebutDesign
  3704. }
  3705. CeErpSukuraData.createInfo(entity.ctid, 5);
  3706. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3707. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3708. if (isNeedUpdateCell2)
  3709. {
  3710. if (entity.MakeSupplier.IndexOf(",") != -1)
  3711. {
  3712. StringBuilder sql2 = new StringBuilder();
  3713. 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);
  3714. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3715. }
  3716. else
  3717. {
  3718. StringBuilder sql2 = new StringBuilder();
  3719. 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);
  3720. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3721. }
  3722. }
  3723. returnSuccessMsg("操作成功!");
  3724. return;
  3725. }
  3726. returnErrorMsg("找不到订单记录");
  3727. }
  3728. }
  3729. public void upd_erp_xianhuoreturntag()
  3730. {
  3731. if (UrlPostParmsCheck("ctid"))
  3732. {
  3733. string eids = GetPostString("ctid");
  3734. string[] ctids = eids.Split(',');
  3735. foreach (string ctid in ctids)
  3736. {
  3737. CeErpTradeCell entity = null;
  3738. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3739. if (entity != null)
  3740. {
  3741. entity.IsReturn = 0;
  3742. entity.Update();
  3743. CeErpSukuraData.createInfo(entity.ctid, 5);
  3744. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3745. }
  3746. }
  3747. returnSuccessMsg("操作成功!");
  3748. return;
  3749. }
  3750. }
  3751. public void get_erp_waitdeliverylist()
  3752. {
  3753. DataStruct dStruct = GetPostStruct();
  3754. List<string> lw = new List<string>();
  3755. string tid = GetPostString("ctid");
  3756. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3757. string shopname = GetPostString("shopname");
  3758. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3759. string buyernick = GetPostString("buyer_nick");
  3760. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3761. //if (tid.Length == 0 && buyernick.Length == 0)
  3762. //{
  3763. // lw.Add(string.Format("IsRefund<={0}", 1));
  3764. //}
  3765. string customer = GetPostString("customer");
  3766. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3767. string design = GetPostString("design");
  3768. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3769. string orderState = GetPostString("orderState");
  3770. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3771. string address = GetPostString("address");
  3772. 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));
  3773. string sellermemo = GetPostString("seller_memo");
  3774. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3775. string supplier = GetPostString("supplier");
  3776. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3777. string OrderArea = GetPostString("order_area");
  3778. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3779. string placedate1 = GetPostString("placedate1");
  3780. string placedate2 = GetPostString("placedate2");
  3781. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3782. if (fdw.Length > 0) lw.Add(fdw);
  3783. string price1 = GetPostString("price1");
  3784. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3785. string price2 = GetPostString("price2");
  3786. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3787. string unusualCon = GetPostString("unusualcon");
  3788. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3789. string otherMemo = GetPostString("otherMemo");
  3790. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3791. string posTag = CurrentUser.UserPost.Post.Code;
  3792. if (posTag == "Supplier")
  3793. {
  3794. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3795. }
  3796. lw.Add(string.Format("OrderState = 6 "));
  3797. lw.Add(string.Format("type != 'PDD' "));
  3798. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3799. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3800. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3801. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3802. writeGridDataTableJson(dStruct.TotalCount, dt);
  3803. }
  3804. public void get_erp_pddderiving()
  3805. {
  3806. DataStruct dStruct = GetPostStruct();
  3807. List<string> lw = new List<string>();
  3808. string tid = GetPostString("ctid");
  3809. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3810. string shopname = GetPostString("shopname");
  3811. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3812. string buyernick = GetPostString("buyer_nick");
  3813. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3814. //if (tid.Length == 0 && buyernick.Length == 0)
  3815. //{
  3816. // lw.Add(string.Format("IsRefund<={0}", 1));
  3817. //}
  3818. string customer = GetPostString("customer");
  3819. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3820. string design = GetPostString("design");
  3821. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3822. string orderState = GetPostString("orderState");
  3823. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3824. string address = GetPostString("address");
  3825. 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));
  3826. string sellermemo = GetPostString("seller_memo");
  3827. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3828. string supplier = GetPostString("supplier");
  3829. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3830. string OrderArea = GetPostString("order_area");
  3831. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3832. string placedate1 = GetPostString("placedate1");
  3833. string placedate2 = GetPostString("placedate2");
  3834. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3835. if (fdw.Length > 0) lw.Add(fdw);
  3836. string price1 = GetPostString("price1");
  3837. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3838. string price2 = GetPostString("price2");
  3839. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3840. string unusualCon = GetPostString("unusualcon");
  3841. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3842. string posTag = CurrentUser.UserPost.Post.Code;
  3843. if (posTag == "Supplier")
  3844. {
  3845. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3846. }
  3847. lw.Add(string.Format("OrderState = 6 "));
  3848. lw.Add(string.Format("type = 'PDD' "));
  3849. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3850. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3851. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3852. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3853. writeGridDataTableJson(dStruct.TotalCount, dt);
  3854. }
  3855. public void get_erp_jdderiving()
  3856. {
  3857. DataStruct dStruct = GetPostStruct();
  3858. List<string> lw = new List<string>();
  3859. string tid = GetPostString("ctid");
  3860. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3861. string shopname = GetPostString("shopname");
  3862. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3863. string buyernick = GetPostString("buyer_nick");
  3864. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3865. //if (tid.Length == 0 && buyernick.Length == 0)
  3866. //{
  3867. // lw.Add(string.Format("IsRefund<={0}", 1));
  3868. //}
  3869. string customer = GetPostString("customer");
  3870. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3871. string design = GetPostString("design");
  3872. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3873. string orderState = GetPostString("orderState");
  3874. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3875. string address = GetPostString("address");
  3876. 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));
  3877. string sellermemo = GetPostString("seller_memo");
  3878. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3879. string supplier = GetPostString("supplier");
  3880. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3881. string OrderArea = GetPostString("order_area");
  3882. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3883. string placedate1 = GetPostString("placedate1");
  3884. string placedate2 = GetPostString("placedate2");
  3885. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3886. if (fdw.Length > 0) lw.Add(fdw);
  3887. string price1 = GetPostString("price1");
  3888. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3889. string price2 = GetPostString("price2");
  3890. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3891. string unusualCon = GetPostString("unusualcon");
  3892. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3893. string posTag = CurrentUser.UserPost.Post.Code;
  3894. if (posTag == "Supplier")
  3895. {
  3896. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3897. }
  3898. lw.Add(string.Format("OrderState = 6 "));
  3899. lw.Add(string.Format("type = 'JD' "));
  3900. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3901. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3902. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3903. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3904. writeGridDataTableJson(dStruct.TotalCount, dt);
  3905. }
  3906. public void get_erp_demoorderlist()
  3907. {
  3908. DataStruct dStruct = GetPostStruct();
  3909. List<string> lw = new List<string>();
  3910. string tid = GetPostString("ctid");
  3911. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3912. string shopname = GetPostString("shopname");
  3913. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3914. string buyernick = GetPostString("buyer_nick");
  3915. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3916. string customer = GetPostString("customer");
  3917. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3918. string design = GetPostString("design");
  3919. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3920. string orderState = GetPostString("orderState");
  3921. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3922. string address = GetPostString("address");
  3923. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3924. string sellermemo = GetPostString("seller_memo");
  3925. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3926. string supplier = GetPostString("supplier");
  3927. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3928. string OrderArea = GetPostString("order_area");
  3929. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3930. string date1 = GetPostString("date1");
  3931. string date2 = GetPostString("date2");
  3932. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3933. if (dw.Length > 0) lw.Add(dw);
  3934. string price1 = GetPostString("price1");
  3935. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3936. string price2 = GetPostString("price2");
  3937. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3938. string posTag = CurrentUser.UserPost.Post.Code;
  3939. if (posTag == "Supplier")
  3940. {
  3941. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3942. }
  3943. //lw.Add(string.Format("OrderState = 6 "));
  3944. lw.Add(string.Format("IsSample={0}", 3));
  3945. lw.Add(string.Format("IsRefund<={0}", 1));
  3946. dStruct.Order = "pay_time desc";
  3947. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3948. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3949. writeGridDataTableJson(dStruct.TotalCount, dt);
  3950. }
  3951. public void save_erp_checkmemo()
  3952. {
  3953. if (UrlPostParmsCheck("ctid"))
  3954. {
  3955. string ctid = GetPostString("ctid");
  3956. CeErpTradeCell entity = null;
  3957. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3958. if (entity != null)
  3959. {
  3960. entity.CheckMemo = GetPostString("CheckMemo");
  3961. entity.Update();
  3962. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  3963. if (trade != null)
  3964. {
  3965. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  3966. }
  3967. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  3968. returnSuccessMsg("保存成功!");
  3969. return;
  3970. }
  3971. returnErrorMsg("找不到记录");
  3972. }
  3973. }
  3974. public void get_erp_returnlist()
  3975. {
  3976. DataStruct dStruct = GetPostStruct();
  3977. List<string> lw = new List<string>();
  3978. string tid = GetPostString("ctid");
  3979. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3980. string shopname = GetPostString("shopname");
  3981. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3982. string buyernick = GetPostString("buyer_nick");
  3983. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3984. string customer = GetPostString("customer");
  3985. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3986. string design = GetPostString("design");
  3987. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3988. string orderState = GetPostString("orderState");
  3989. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3990. string address = GetPostString("address");
  3991. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3992. string sellermemo = GetPostString("seller_memo");
  3993. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3994. string supplier = GetPostString("supplier");
  3995. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3996. string date1 = GetPostString("date1");
  3997. string date2 = GetPostString("date2");
  3998. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3999. if (dw.Length > 0) lw.Add(dw);
  4000. string bdate1 = GetPostString("backdate1");
  4001. string bdate2 = GetPostString("backdate2");
  4002. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4003. if (dw_back.Length > 0) lw.Add(dw_back);
  4004. string price1 = GetPostString("price1");
  4005. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4006. string price2 = GetPostString("price2");
  4007. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4008. lw.Add(string.Format("IsReturn>0"));
  4009. lw.Add(string.Format("IsXianHuo=0"));
  4010. lw.Add(string.Format("IsReturn!=3"));
  4011. string backtype = GetPostString("backtype");
  4012. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4013. dStruct.Order = "FinishDesignTime desc";
  4014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4015. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4016. writeGridDataTableJson(dStruct.TotalCount, dt);
  4017. }
  4018. public void get_erp_today_sumreturn()
  4019. {
  4020. DataStruct dStruct = GetPostStruct();
  4021. List<string> lw = new List<string>();
  4022. string bdate1 = GetPostString("returnTimeS");
  4023. string bdate2 = GetPostString("returnTimeE");
  4024. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4025. if (dw_back.Length > 0) lw.Add(dw_back);
  4026. lw.Add(string.Format("IsReturn=0"));
  4027. lw.Add(string.Format("IsXianHuo=0"));
  4028. string mainWhere = string.Join(" and ", lw.ToArray());
  4029. string sql = "";
  4030. if (dw_back.Length > 0)
  4031. {
  4032. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4033. }
  4034. else
  4035. {
  4036. 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 + "'";
  4037. }
  4038. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4039. decimal total = 0, today_finish = 0;
  4040. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4041. {
  4042. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4043. }
  4044. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4045. {
  4046. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4047. }
  4048. var res = new
  4049. {
  4050. data = total,
  4051. data1 = today_finish,
  4052. };
  4053. string ro_jsond = JsonConvert.SerializeObject(res);
  4054. returnSuccess(ro_jsond);
  4055. return;
  4056. }
  4057. public void get_erp_allreturnlist()
  4058. {
  4059. DataStruct dStruct = GetPostStruct();
  4060. List<string> lw = new List<string>();
  4061. string tid = GetPostString("ctid");
  4062. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4063. string shopname = GetPostString("shopname");
  4064. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4065. string buyernick = GetPostString("buyer_nick");
  4066. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4067. string customer = GetPostString("customer");
  4068. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4069. string design = GetPostString("design");
  4070. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4071. string orderState = GetPostString("orderState");
  4072. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4073. string address = GetPostString("address");
  4074. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4075. string sellermemo = GetPostString("seller_memo");
  4076. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4077. string supplier = GetPostString("supplier");
  4078. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4079. string date1 = GetPostString("date1");
  4080. string date2 = GetPostString("date2");
  4081. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4082. if (dw.Length > 0) lw.Add(dw);
  4083. string bdate1 = GetPostString("backdate1");
  4084. string bdate2 = GetPostString("backdate2");
  4085. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4086. if (dw_back.Length > 0) lw.Add(dw_back);
  4087. string price1 = GetPostString("price1");
  4088. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4089. string price2 = GetPostString("price2");
  4090. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4091. string backreason = GetPostString("backreason");
  4092. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4093. lw.Add(string.Format("IsXianHuo=0"));
  4094. lw.Add(string.Format("ReturnTime != ''"));
  4095. string backtype = GetPostString("backtype");
  4096. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4097. dStruct.Order = "FinishDesignTime desc";
  4098. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4099. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4100. writeGridDataTableJson(dStruct.TotalCount, dt);
  4101. }
  4102. public void get_erp_aftersalereturnlist()
  4103. {
  4104. DataStruct dStruct = GetPostStruct();
  4105. List<string> lw = new List<string>();
  4106. string tid = GetPostString("ctid");
  4107. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4108. string shopname = GetPostString("shopname");
  4109. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4110. string buyernick = GetPostString("buyer_nick");
  4111. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4112. string customer = GetPostString("customer");
  4113. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4114. string design = GetPostString("design");
  4115. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4116. string orderState = GetPostString("orderState");
  4117. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4118. string address = GetPostString("address");
  4119. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4120. string sellermemo = GetPostString("seller_memo");
  4121. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4122. string supplier = GetPostString("supplier");
  4123. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4124. string date1 = GetPostString("date1");
  4125. string date2 = GetPostString("date2");
  4126. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4127. if (dw.Length > 0) lw.Add(dw);
  4128. string bdate1 = GetPostString("backdate1");
  4129. string bdate2 = GetPostString("backdate2");
  4130. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4131. if (dw_back.Length > 0) lw.Add(dw_back);
  4132. string price1 = GetPostString("price1");
  4133. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4134. string price2 = GetPostString("price2");
  4135. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4136. lw.Add(string.Format("IsReturn=3"));
  4137. string backtype = GetPostString("backtype");
  4138. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4139. string backreason = GetPostString("backreason");
  4140. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4141. dStruct.Order = "ReturnTime desc";
  4142. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4143. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4144. writeGridDataTableJson(dStruct.TotalCount, dt);
  4145. }
  4146. public void get_erp_xianhuoreturnlist()
  4147. {
  4148. DataStruct dStruct = GetPostStruct();
  4149. List<string> lw = new List<string>();
  4150. string tid = GetPostString("ctid");
  4151. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4152. string shopname = GetPostString("shopname");
  4153. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4154. string buyernick = GetPostString("buyer_nick");
  4155. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4156. string customer = GetPostString("customer");
  4157. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4158. string design = GetPostString("design");
  4159. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4160. string orderState = GetPostString("orderState");
  4161. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4162. string address = GetPostString("address");
  4163. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4164. string sellermemo = GetPostString("seller_memo");
  4165. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4166. string supplier = GetPostString("supplier");
  4167. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4168. string OrderArea = GetPostString("order_area");
  4169. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4170. string date1 = GetPostString("date1");
  4171. string date2 = GetPostString("date2");
  4172. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4173. if (dw.Length > 0) lw.Add(dw);
  4174. string price1 = GetPostString("price1");
  4175. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4176. string price2 = GetPostString("price2");
  4177. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4178. string posTag = CurrentUser.UserPost.Post.Code;
  4179. if (posTag == "Supplier")
  4180. {
  4181. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4182. }
  4183. lw.Add(string.Format("OrderState=6 "));
  4184. lw.Add(string.Format("IsXianHuo=1 "));
  4185. lw.Add(string.Format("IsReturn>0 "));
  4186. lw.Add(string.Format("IsReturn!=3"));
  4187. lw.Add(string.Format("IsRefund<={0}", 1));
  4188. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4189. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4190. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4191. writeGridDataTableJson(dStruct.TotalCount, dt);
  4192. }
  4193. public void set_erp_orderdelivery()
  4194. {
  4195. if (UrlPostParmsCheck("ctid"))
  4196. {
  4197. string eid = GetPostString("ctid");
  4198. CeErpTradeCell entity = null;
  4199. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4200. if (entity != null)
  4201. {
  4202. if (entity.OrderState >= 7)
  4203. {
  4204. returnErrorMsg("此单已发货,无需重复发货");
  4205. return;
  4206. }
  4207. if (entity.OrderState != 6)
  4208. {
  4209. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4210. return;
  4211. }
  4212. string shop = GetPostString("seller_nick");
  4213. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4214. string comName = GetPostString("comName");
  4215. string comCode = GetPostString("comCode");
  4216. string outSid = GetPostString("outSid");
  4217. string deliveryType = GetPostString("deliveryType");
  4218. string deliveryMemo = GetPostString("deliveryMemo");
  4219. outSid = outSid.Trim();
  4220. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4221. if (mainEn == null)
  4222. {
  4223. returnErrorMsg("找不到原始订单记录");
  4224. return;
  4225. }
  4226. bool isInitOrderDeliv = false;
  4227. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4228. {
  4229. isInitOrderDeliv = true;
  4230. }
  4231. string apires = "";
  4232. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4233. 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)
  4234. {
  4235. apires = "发货成功true";
  4236. }
  4237. else
  4238. {
  4239. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4240. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4241. }
  4242. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4243. {
  4244. entity.OrderState = 7;//发货后订单已发货
  4245. entity.OutSid = outSid;
  4246. entity.MemoOpt = 0;
  4247. entity.FinishDeliveryTime = DateTime.Now;
  4248. entity.Update();
  4249. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4250. commonHelper.UpdateRelationOrder(entity.ctid);
  4251. //还要插入快递信息到 快递信息表
  4252. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4253. exinfo.tid = eid;
  4254. exinfo.out_sid = outSid;
  4255. exinfo.company_code = comCode;
  4256. exinfo.company_name = comName;
  4257. exinfo.delivery_memo = deliveryMemo;
  4258. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4259. exinfo.deliveryType = deliveryType;
  4260. exinfo.Create();
  4261. returnSuccessMsg("发货操作成功!");
  4262. commonHelper.UpdateRelationOrder(entity.ctid);
  4263. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4264. CeErpSukuraData.createInfo(entity.ctid, 4);
  4265. if (entity.SupplierId == 64)
  4266. {
  4267. commonHelper.sendCytExpress(exinfo);
  4268. }
  4269. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4270. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4271. }
  4272. else
  4273. {
  4274. string errmsg = commonHelper.KeepChinese(apires);
  4275. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4276. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4277. }
  4278. return;
  4279. }
  4280. returnErrorMsg("找不到订单记录");
  4281. }
  4282. }
  4283. public void set_erp_multidelivery()
  4284. {
  4285. string eids = GetPostString("tids");
  4286. string[] eidList = eids.Split(',');
  4287. if (eidList.Length <= 0)
  4288. {
  4289. returnErrorMsg("发货不能为空");
  4290. return;
  4291. }
  4292. foreach (string ctid in eidList)
  4293. {
  4294. if (ctid.Length <= 0) continue;
  4295. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4296. if (expInfo != null)
  4297. {
  4298. StringBuilder sql = new StringBuilder();
  4299. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4300. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4301. if (dt.Rows.Count > 0)
  4302. {
  4303. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4304. {
  4305. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4306. expInfo.state = "异常";
  4307. expInfo.isMultiDelivery = 1;
  4308. expInfo.Update();
  4309. continue;
  4310. }
  4311. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4312. {
  4313. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4314. expInfo.state = "异常";
  4315. expInfo.Update();
  4316. continue;
  4317. }
  4318. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4319. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4320. bool isInitOrderDeliv = false;
  4321. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4322. {
  4323. isInitOrderDeliv = true;
  4324. expInfo.isMultiDelivery = 1;
  4325. }
  4326. if (ctid.IndexOf("N") != -1)
  4327. {
  4328. StringBuilder sqlbucha = new StringBuilder();
  4329. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4330. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4331. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4332. commonHelper.UpdateRelationOrder(ctid);
  4333. expInfo.delivery_memo = "发货成功";
  4334. expInfo.state = "发货成功";
  4335. expInfo.isMultiDelivery = 1;
  4336. expInfo.Update();
  4337. }
  4338. else
  4339. {
  4340. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4341. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4342. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4343. {
  4344. expInfo.delivery_memo = "发货成功";
  4345. expInfo.state = "发货成功";
  4346. expInfo.isMultiDelivery = 1;
  4347. expInfo.Update();
  4348. commonHelper.UpdateRelationOrder(ctid);
  4349. CeErpSukuraData.createInfo(ctid, 4);
  4350. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4351. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4352. }
  4353. else
  4354. {
  4355. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4356. expInfo.state = "异常";
  4357. expInfo.Update();
  4358. }
  4359. }
  4360. }
  4361. }
  4362. }
  4363. returnSuccessMsg("操作完成");
  4364. }
  4365. public void reset_erp_memoopt()
  4366. {
  4367. if (UrlPostParmsCheck("ctid"))
  4368. {
  4369. string eid = GetPostString("ctid");
  4370. CeErpTradeCell entity = null;
  4371. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4372. if (entity != null)
  4373. {
  4374. string stropt = "";
  4375. if (entity.MemoOpt == 1)
  4376. {
  4377. stropt = "“改稿”";
  4378. }
  4379. else if (entity.MemoOpt == 2)
  4380. {
  4381. stropt = "“定稿”";
  4382. }
  4383. else if (entity.MemoOpt == 3)
  4384. {
  4385. stropt = "“完成查货”";
  4386. CeErpSukuraData.createInfo(entity.ctid, 6);
  4387. }
  4388. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4389. entity.MemoOpt = 0;
  4390. entity.Update();
  4391. returnSuccessMsg("操作成功!");
  4392. return;
  4393. }
  4394. returnErrorMsg("找不到记录");
  4395. }
  4396. }
  4397. public void get_erp_deliveryunusual()
  4398. {
  4399. DataStruct dStruct = GetPostStruct();
  4400. List<string> lw = new List<string>();
  4401. string tid = GetPostString("ctid");
  4402. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4403. string shopname = GetPostString("shopname");
  4404. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4405. string buyernick = GetPostString("buyer_nick");
  4406. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4407. string customer = GetPostString("customer");
  4408. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4409. string design = GetPostString("design");
  4410. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4411. string sellermemo = GetPostString("seller_memo");
  4412. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4413. string supplier = GetPostString("supplier");
  4414. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4415. string date1 = GetPostString("date1");
  4416. string date2 = GetPostString("date2");
  4417. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4418. if (dw.Length > 0) lw.Add(dw);
  4419. string placedate1 = GetPostString("placedate1");
  4420. string placedate2 = GetPostString("placedate2");
  4421. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4422. if (dw_place.Length > 0) lw.Add(dw_place);
  4423. string price1 = GetPostString("price1");
  4424. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4425. string price2 = GetPostString("price2");
  4426. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4427. string unusualCon = GetPostString("unusualcon");
  4428. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4429. string posTag = CurrentUser.UserPost.Post.Code;
  4430. if (posTag == "Supplier")
  4431. {
  4432. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4433. }
  4434. lw.Add(string.Format("OrderState = 6"));
  4435. lw.Add(string.Format("UnusualTag = 5"));
  4436. lw.Add(string.Format("IsRefund<={0}", 1));
  4437. dStruct.Order = "FinishPlaceTime desc";
  4438. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4439. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4440. writeGridDataTableJson(dStruct.TotalCount, dt);
  4441. }
  4442. public void get_erp_deliveryedlist()
  4443. {
  4444. DataStruct dStruct = GetPostStruct();
  4445. List<string> lw = new List<string>();
  4446. string tid = GetPostString("ctid");
  4447. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4448. string shopname = GetPostString("shopname");
  4449. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4450. string buyernick = GetPostString("buyer_nick");
  4451. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4452. string customer = GetPostString("customer");
  4453. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4454. string design = GetPostString("design");
  4455. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4456. string sellermemo = GetPostString("seller_memo");
  4457. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4458. string logistics = GetPostString("logistics");
  4459. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4460. string date1 = GetPostString("date1");
  4461. string date2 = GetPostString("date2");
  4462. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4463. //if (dw.Length > 0) lw.Add(dw);
  4464. string placedate1 = GetPostString("placedate1");
  4465. string placedate2 = GetPostString("placedate2");
  4466. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4467. if (fdw.Length > 0) lw.Add(fdw);
  4468. string devdate1 = GetPostString("deliverydate1");
  4469. string devdate2 = GetPostString("deliverydate2");
  4470. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4471. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4472. string price1 = GetPostString("price1");
  4473. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4474. string price2 = GetPostString("price2");
  4475. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4476. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4477. {
  4478. if (tid.Length > 0)
  4479. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4480. if (buyernick.Length > 0)
  4481. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4482. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4483. if (dw.Length > 0) lw.Add(dw);
  4484. }
  4485. else
  4486. {
  4487. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4488. }
  4489. string posTag = CurrentUser.UserPost.Post.Code;
  4490. if (posTag == "Supplier")
  4491. {
  4492. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4493. }
  4494. else
  4495. {
  4496. string supplier = GetPostString("supplier");
  4497. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4498. }
  4499. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4500. lw.Add(string.Format("IsRefund!={0}", 2));
  4501. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4502. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4503. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4504. if (dt != null)
  4505. {
  4506. foreach (DataRow dr in dt.Rows)
  4507. {
  4508. 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();
  4509. }
  4510. }
  4511. writeGridDataTableJson(dStruct.TotalCount, dt);
  4512. }
  4513. public void get_erp_pdddeliveryed()
  4514. {
  4515. DataStruct dStruct = GetPostStruct();
  4516. List<string> lw = new List<string>();
  4517. string tid = GetPostString("ctid");
  4518. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4519. string shopname = GetPostString("shopname");
  4520. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4521. string buyernick = GetPostString("buyer_nick");
  4522. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4523. string customer = GetPostString("customer");
  4524. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4525. string design = GetPostString("design");
  4526. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4527. string sellermemo = GetPostString("seller_memo");
  4528. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4529. string logistics = GetPostString("logistics");
  4530. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4531. string date1 = GetPostString("date1");
  4532. string date2 = GetPostString("date2");
  4533. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4534. //if (dw.Length > 0) lw.Add(dw);
  4535. string placedate1 = GetPostString("placedate1");
  4536. string placedate2 = GetPostString("placedate2");
  4537. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4538. if (fdw.Length > 0) lw.Add(fdw);
  4539. string devdate1 = GetPostString("deliverydate1");
  4540. string devdate2 = GetPostString("deliverydate2");
  4541. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4542. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4543. string price1 = GetPostString("price1");
  4544. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4545. string price2 = GetPostString("price2");
  4546. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4547. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4548. {
  4549. if (tid.Length > 0)
  4550. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4551. if (buyernick.Length > 0)
  4552. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4553. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4554. if (dw.Length > 0) lw.Add(dw);
  4555. }
  4556. else
  4557. {
  4558. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4559. }
  4560. string posTag = CurrentUser.UserPost.Post.Code;
  4561. if (posTag == "Supplier")
  4562. {
  4563. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4564. }
  4565. else
  4566. {
  4567. string supplier = GetPostString("supplier");
  4568. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4569. }
  4570. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4571. lw.Add(string.Format("type = 'PDD' "));
  4572. lw.Add(string.Format("IsRefund!={0}", 2));
  4573. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4574. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4575. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4576. foreach (DataRow dr in dt.Rows)
  4577. {
  4578. 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();
  4579. }
  4580. writeGridDataTableJson(dStruct.TotalCount, dt);
  4581. }
  4582. public void get_erp_jddeliveryed()
  4583. {
  4584. DataStruct dStruct = GetPostStruct();
  4585. List<string> lw = new List<string>();
  4586. string tid = GetPostString("ctid");
  4587. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4588. string shopname = GetPostString("shopname");
  4589. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4590. string buyernick = GetPostString("buyer_nick");
  4591. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4592. string customer = GetPostString("customer");
  4593. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4594. string design = GetPostString("design");
  4595. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4596. string sellermemo = GetPostString("seller_memo");
  4597. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4598. string date1 = GetPostString("date1");
  4599. string date2 = GetPostString("date2");
  4600. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4601. //if (dw.Length > 0) lw.Add(dw);
  4602. string placedate1 = GetPostString("placedate1");
  4603. string placedate2 = GetPostString("placedate2");
  4604. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4605. if (fdw.Length > 0) lw.Add(fdw);
  4606. string devdate1 = GetPostString("deliverydate1");
  4607. string devdate2 = GetPostString("deliverydate2");
  4608. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4609. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4610. string price1 = GetPostString("price1");
  4611. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4612. string price2 = GetPostString("price2");
  4613. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4614. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4615. {
  4616. if (tid.Length > 0)
  4617. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4618. if (buyernick.Length > 0)
  4619. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4620. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4621. if (dw.Length > 0) lw.Add(dw);
  4622. }
  4623. else
  4624. {
  4625. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4626. }
  4627. string posTag = CurrentUser.UserPost.Post.Code;
  4628. if (posTag == "Supplier")
  4629. {
  4630. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4631. }
  4632. else
  4633. {
  4634. string supplier = GetPostString("supplier");
  4635. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4636. }
  4637. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4638. lw.Add(string.Format("type = 'JD' "));
  4639. lw.Add(string.Format("IsRefund!={0}", 2));
  4640. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4641. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4642. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4643. foreach (DataRow dr in dt.Rows)
  4644. {
  4645. 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();
  4646. }
  4647. writeGridDataTableJson(dStruct.TotalCount, dt);
  4648. }
  4649. public void get_erp_allplacelist()
  4650. {
  4651. DataStruct dStruct = GetPostStruct();
  4652. List<string> lw = new List<string>();
  4653. string tid = GetPostString("ctid");
  4654. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4655. string shopname = GetPostString("shopname");
  4656. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4657. string buyernick = GetPostString("buyer_nick");
  4658. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4659. string customer = GetPostString("customer");
  4660. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4661. string design = GetPostString("design");
  4662. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4663. string sellermemo = GetPostString("seller_memo");
  4664. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4665. string supplier = GetPostString("supplier");
  4666. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4667. string date1 = GetPostString("date1");
  4668. string date2 = GetPostString("date2");
  4669. string pldate1 = GetPostString("placedate1");
  4670. string pldate2 = GetPostString("placedate2");
  4671. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4672. //if (dw.Length > 0) lw.Add(dw);
  4673. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4674. {
  4675. if (tid.Length > 0)
  4676. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4677. if (buyernick.Length > 0)
  4678. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4679. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4680. if (dw.Length > 0) lw.Add(dw);
  4681. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4682. if (dw_place.Length > 0) lw.Add(dw_place);
  4683. }
  4684. else
  4685. {
  4686. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4687. {
  4688. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4689. }
  4690. }
  4691. string price1 = GetPostString("price1");
  4692. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4693. string price2 = GetPostString("price2");
  4694. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4695. string posTag = CurrentUser.UserPost.Post.Code;
  4696. if (posTag == "Supplier")
  4697. {
  4698. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4699. }
  4700. lw.Add(string.Format("OrderState >= 6"));
  4701. lw.Add(string.Format("IsSample != 2 "));
  4702. lw.Add(string.Format("isDianziOrder = 0 "));
  4703. //lw.Add(string.Format("IsRefund<={0}", 1));
  4704. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4705. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4706. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4707. foreach (DataRow dr in dt.Rows)
  4708. {
  4709. 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();
  4710. }
  4711. writeGridDataTableJson(dStruct.TotalCount, dt);
  4712. }
  4713. public void get_erp_financeallplacelist()
  4714. {
  4715. DataStruct dStruct = GetPostStruct();
  4716. List<string> lw = new List<string>();
  4717. string tid = GetPostString("ctid");
  4718. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4719. string shopname = GetPostString("shopname");
  4720. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4721. string buyernick = GetPostString("buyer_nick");
  4722. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4723. string customer = GetPostString("customer");
  4724. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4725. string design = GetPostString("design");
  4726. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4727. string sellermemo = GetPostString("seller_memo");
  4728. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4729. string supplier = GetPostString("supplier");
  4730. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4731. string date1 = GetPostString("date1");
  4732. string date2 = GetPostString("date2");
  4733. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4734. if (dw.Length > 0) lw.Add(dw);
  4735. string pldate1 = GetPostString("placedate1");
  4736. string pldate2 = GetPostString("placedate2");
  4737. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4738. if (dw_place.Length > 0) lw.Add(dw_place);
  4739. string price1 = GetPostString("price1");
  4740. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4741. string price2 = GetPostString("price2");
  4742. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4743. string posTag = CurrentUser.UserPost.Post.Code;
  4744. if (posTag == "Supplier")
  4745. {
  4746. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4747. }
  4748. //lw.Add(string.Format("OrderState >= 6"));
  4749. lw.Add(string.Format("IsSample != 2 "));
  4750. lw.Add(string.Format("isDianziOrder = 0 "));
  4751. //lw.Add(string.Format("IsRefund<={0}", 1));
  4752. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4753. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4754. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4755. foreach (DataRow dr in dt.Rows)
  4756. {
  4757. 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();
  4758. }
  4759. writeGridDataTableJson(dStruct.TotalCount, dt);
  4760. }
  4761. public void get_erp_expresslist()
  4762. {
  4763. int listtype = GetInt("ltype");
  4764. DataStruct dStruct = GetPostStruct();
  4765. List<string> lw = new List<string>();
  4766. string tid = GetPostString("tid");
  4767. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4768. string outsid = GetPostString("out_sid");
  4769. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4770. string importer = GetPostString("ImportUserName");
  4771. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4772. string file = GetPostString("import_file");
  4773. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4774. string printman = GetPostString("printman");
  4775. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4776. string date1 = GetPostString("date1");
  4777. string date2 = GetPostString("date2");
  4778. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4779. if (dw.Length > 0) lw.Add(dw);
  4780. string fdate1 = GetPostString("finishdate1");
  4781. string fdate2 = GetPostString("finishdate2");
  4782. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4783. if (fdw.Length > 0) lw.Add(fdw);
  4784. string supplierId = GetPostString("supplierId");
  4785. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  4786. if (listtype == 1)
  4787. {
  4788. lw.Add(string.Format("importUserId !=0"));
  4789. }
  4790. string posTag = CurrentUser.UserPost.Post.Code;
  4791. if (posTag == "Supplier")
  4792. {
  4793. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4794. }
  4795. if (dStruct.PageSize != 100000)
  4796. {
  4797. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4798. }
  4799. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4800. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4801. writeGridDataTableJson(dStruct.TotalCount, dt);
  4802. }
  4803. public void set_erp_buchaorderdelivery()
  4804. {
  4805. if (UrlPostParmsCheck("ctid"))
  4806. {
  4807. string eid = GetPostString("ctid");
  4808. CeErpTradeCell entity = null;
  4809. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4810. if (entity != null)
  4811. {
  4812. if (entity.IsSample != 2)
  4813. {
  4814. returnErrorMsg("补差价单才能标记为已发货");
  4815. return;
  4816. }
  4817. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4818. entity.OrderState = 7;
  4819. entity.Update();
  4820. returnSuccessMsg("操作成功!");
  4821. return;
  4822. }
  4823. returnErrorMsg("找不到记录");
  4824. }
  4825. }
  4826. public void get_stdtemplates()
  4827. {
  4828. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4829. //string res = taobaoHelper.test();
  4830. string res = apiHelper.API_PrintTemplate();
  4831. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4832. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4833. {
  4834. int sidx = res.IndexOf("error_code");
  4835. int eidx = res.IndexOf("success");
  4836. string msg = res.Substring(sidx, eidx - sidx);
  4837. returnErrorMsg(msg);
  4838. return;
  4839. }
  4840. if (res.Length <= 0)
  4841. {
  4842. returnErrorMsg("模板数据为空!");
  4843. return;
  4844. }
  4845. ReturnSuccess(res);
  4846. }
  4847. public void cancel_print_order()
  4848. {
  4849. if (UrlPostParmsCheck("ctid"))
  4850. {
  4851. string ctid = GetPostString("ctid");
  4852. CeErpTradeCell entity = null;
  4853. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4854. if (entity != null)
  4855. {
  4856. string res = "";
  4857. string code = entity.LastBillWaybillCode;
  4858. if (code == "")
  4859. {
  4860. code = entity.OutSid;
  4861. }
  4862. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  4863. XLog.SaveLog(0, "取消面单" + res);
  4864. }
  4865. }
  4866. }
  4867. public void set_erp_printwaybill()
  4868. {
  4869. if (UrlPostParmsCheck("ctid"))
  4870. {
  4871. string ctid = GetPostString("ctid");
  4872. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  4873. string cpName = GetPostString("cpname");
  4874. string isTogether = GetPostString("together");
  4875. //var res_obj = new
  4876. //{
  4877. // restype = 1,
  4878. // 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\"}"
  4879. //};
  4880. //string ro_json = JsonConvert.SerializeObject(res_obj);
  4881. //ReturnSuccess(ro_json);
  4882. //return;
  4883. bool isUseLastWayBillCode = false;
  4884. CeErpTradeCell entity = null;
  4885. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4886. if (entity != null)
  4887. {
  4888. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  4889. {
  4890. isUseLastWayBillCode = true;
  4891. }
  4892. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  4893. {
  4894. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  4895. return;
  4896. }
  4897. }
  4898. string res = "";
  4899. Api_waybill_code_response_Obj fullObj = null;
  4900. string pData_str = "";
  4901. string curUseWayBillCode = "";
  4902. if (isUseLastWayBillCode == false)
  4903. {
  4904. res = apiHelper.API_GetWaybill(cpCode, ctid);
  4905. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  4906. if (res.IndexOf("failure") != -1)
  4907. {
  4908. //int idx = res.IndexOf("sub_message");
  4909. //int idx2 = res.IndexOf("flag");
  4910. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  4911. string errMsgNeed = commonHelper.KeepChinese(res);
  4912. var res_objd = new
  4913. {
  4914. restype = 0,
  4915. data = "获取面单失败" + errMsgNeed
  4916. };
  4917. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  4918. returnSuccess(ro_jsond);
  4919. if (res.IndexOf("停发") != -1)
  4920. {
  4921. entity.UnusualCon = "物流停发";
  4922. entity.Update();
  4923. }
  4924. //returnErrorMsg("获取面单失败,"+emsg);
  4925. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  4926. return;
  4927. }
  4928. else if (res.IndexOf("errorMsg") != -1)
  4929. {
  4930. //int idx = res.IndexOf("errorMsg");
  4931. //int idx2 = res.IndexOf("}]}");
  4932. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  4933. string errMsgNeed = commonHelper.KeepChinese(res);
  4934. var res_objf = new
  4935. {
  4936. restype = 0,
  4937. data = "获取面单失败2" + errMsgNeed
  4938. };
  4939. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4940. if (res.IndexOf("停发") != -1)
  4941. {
  4942. entity.UnusualCon = "物流停发";
  4943. entity.Update();
  4944. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4945. if (trade != null)
  4946. {
  4947. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  4948. }
  4949. }
  4950. returnSuccess(ro_jsonf);
  4951. //returnErrorMsg("获取面单失败," + emsg);
  4952. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  4953. return;
  4954. }
  4955. try
  4956. {
  4957. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4958. //res = res.Replace(" ", "");
  4959. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  4960. }
  4961. catch (Exception ex)
  4962. {
  4963. XLog.SaveLog(0, "生成fullObj" + res);
  4964. var res_objf = new
  4965. {
  4966. restype = 0,
  4967. data = "生成fullObj发生错误" + ex.Message
  4968. };
  4969. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4970. returnSuccess(ro_jsonf);
  4971. return;
  4972. }
  4973. if (fullObj.response.data.content.Count > 0)
  4974. {
  4975. ContentItem codeObj = fullObj.response.data.content[0];
  4976. if (cpCode.IndexOf("SFFQ-") != -1)
  4977. {
  4978. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  4979. }
  4980. else
  4981. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  4982. curUseWayBillCode = codeObj.waybillCode;
  4983. }
  4984. else
  4985. {
  4986. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  4987. var res_objf = new
  4988. {
  4989. restype = 0,
  4990. data = "生成fullObj找不到快递单号waybillCode"
  4991. };
  4992. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4993. returnSuccess(ro_jsonf);
  4994. return;
  4995. }
  4996. }
  4997. else
  4998. {
  4999. //使用上次打印的快递单号
  5000. if (cpCode == "SFFQ-LY")
  5001. {
  5002. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5003. }
  5004. else
  5005. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5006. curUseWayBillCode = entity.LastBillWaybillCode;
  5007. }
  5008. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5009. {
  5010. var res_obje = new
  5011. {
  5012. restype = 0,
  5013. data = "获取加密打印数据失败"
  5014. };
  5015. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5016. returnSuccess(ro_jsone);
  5017. entity.LastBillCpCode = cpCode;
  5018. entity.LastBillWaybillCode = curUseWayBillCode;
  5019. entity.Update();
  5020. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5021. //returnErrorMsg("获取加密打印数据失败");
  5022. return;
  5023. }
  5024. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5025. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5026. string btnType = "";
  5027. if (entity != null)
  5028. {
  5029. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5030. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5031. //cpcode是 YTO-CAINIAO
  5032. //string comCode = cpCode.Split('-')[0].ToString();
  5033. string apires = "";
  5034. if (ctid.IndexOf("N") != -1)
  5035. {
  5036. apires = "发货成功";
  5037. }
  5038. else
  5039. {
  5040. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5041. }
  5042. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5043. //打单后发货
  5044. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5045. {
  5046. try
  5047. {
  5048. btnType = "待发货";
  5049. entity.OutSid = curUseWayBillCode;
  5050. entity.OrderState = 7;
  5051. entity.IsUrgency = false;
  5052. entity.LastBillCpCode = "";
  5053. entity.LastBillWaybillCode = "";
  5054. entity.FinishDeliveryTime = DateTime.Now;
  5055. entity.IsReturn = 0;
  5056. entity.MemoOpt = 0;
  5057. entity.Update();
  5058. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5059. //还要插入快递信息到 快递信息表
  5060. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5061. exinfo.tid = entity.ctid;
  5062. exinfo.out_sid = entity.OutSid;
  5063. exinfo.company_code = cpCode;
  5064. exinfo.company_name = cpName;
  5065. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5066. exinfo.deliveryType = "发货成功";
  5067. exinfo.print_time = DateTime.Now;
  5068. exinfo.printUser = CurrentUser.UserName;
  5069. exinfo.Create();
  5070. commonHelper.UpdateRelationOrder(entity.ctid);
  5071. CeErpSukuraData.createInfo(ctid, 4);
  5072. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5073. if (entity.SupplierId == 64)
  5074. {
  5075. commonHelper.sendCytExpress(exinfo);
  5076. }
  5077. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5078. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5079. if (isTogether == "1")
  5080. {
  5081. StringBuilder sqlsb = new StringBuilder();
  5082. 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);
  5083. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5084. }
  5085. }
  5086. catch (Exception ex)
  5087. {
  5088. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5089. }
  5090. }
  5091. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5092. {
  5093. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5094. if (entity.OrderState == 6)
  5095. {
  5096. entity.OrderState = 7;
  5097. }
  5098. entity.FinishDeliveryTime = DateTime.Now;
  5099. btnType = "已发货";
  5100. entity.Update();
  5101. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5102. exinfo.tid = entity.ctid;
  5103. exinfo.out_sid = entity.OutSid;
  5104. exinfo.company_code = cpCode;
  5105. exinfo.company_name = cpName;
  5106. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5107. exinfo.deliveryType = "发货成功";
  5108. exinfo.print_time = DateTime.Now;
  5109. exinfo.printUser = CurrentUser.UserName;
  5110. exinfo.Create();
  5111. commonHelper.UpdateRelationOrder(entity.ctid);
  5112. CeErpSukuraData.createInfo(entity.ctid, 4);
  5113. if (entity.SupplierId == 64)
  5114. {
  5115. commonHelper.sendCytExpress(exinfo);
  5116. }
  5117. if (isTogether == "1")
  5118. {
  5119. StringBuilder sqlsb = new StringBuilder();
  5120. 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);
  5121. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5122. }
  5123. //不处理
  5124. }
  5125. else
  5126. {
  5127. entity.LastBillCpCode = cpCode;
  5128. entity.LastBillWaybillCode = curUseWayBillCode;
  5129. entity.Update();
  5130. string errmsg = commonHelper.KeepChinese(apires);
  5131. var res_objz = new
  5132. {
  5133. restype = 0,
  5134. data = "打单后发货失败"
  5135. };
  5136. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5137. returnSuccess(ro_jsonz);
  5138. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5139. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5140. return;
  5141. }
  5142. }
  5143. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5144. var res_obj = new
  5145. {
  5146. restype = 1,
  5147. data = pData_str
  5148. };
  5149. string ro_json = JsonConvert.SerializeObject(res_obj);
  5150. ReturnSuccess(ro_json);
  5151. return;
  5152. }
  5153. }
  5154. private string GetUTF8String(byte[] vs)
  5155. {
  5156. throw new NotImplementedException();
  5157. }
  5158. public void set_erp_printwaybill_cn()
  5159. {
  5160. if (UrlPostParmsCheck("ctid"))
  5161. {
  5162. string ctid = GetPostString("ctid");
  5163. string cpCode = GetPostString("cpcode");
  5164. string cpName = GetPostString("cpname");
  5165. string tempUrl = GetPostString("tempurl");
  5166. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5167. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5168. //string res = taobaoHelper.test();
  5169. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5170. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5171. {
  5172. int sidx = res.IndexOf("errorMsg");
  5173. int eidx = res.IndexOf("}");
  5174. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5175. var res_objzxx = new
  5176. {
  5177. restype = 0,
  5178. data = msg
  5179. };
  5180. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5181. returnSuccess(ro_jsonzxx);
  5182. //returnErrorMsg(msg);
  5183. return;
  5184. }
  5185. int idx = res.IndexOf("waybillCode");
  5186. int idx2 = res.IndexOf("printData");
  5187. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5188. string eid = GetPostString("ctid");
  5189. CeErpTradeCell entity = null;
  5190. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5191. if (entity != null)
  5192. {
  5193. string osid = entity.OutSid;
  5194. entity.OutSid = osid + "," + outsid;
  5195. entity.FinishDeliveryTime = DateTime.Now;
  5196. entity.OrderState = 7;
  5197. entity.IsReturn = 0;
  5198. entity.Update();
  5199. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5200. exinfo.tid = entity.ctid;
  5201. exinfo.out_sid = outsid;
  5202. exinfo.company_code = cpCode;
  5203. exinfo.company_name = cpName;
  5204. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5205. exinfo.deliveryType = "发货成功";
  5206. exinfo.print_time = DateTime.Now;
  5207. exinfo.printUser = CurrentUser.UserName;
  5208. exinfo.Create();
  5209. if (entity.SupplierId == 64)
  5210. {
  5211. commonHelper.sendCytExpress(exinfo);
  5212. }
  5213. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5214. }
  5215. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5216. var res_objz = new
  5217. {
  5218. restype = 1,
  5219. data = res
  5220. };
  5221. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5222. returnSuccess(ro_jsonz);
  5223. //ReturnSuccess(res);
  5224. }
  5225. }
  5226. ////打单,打印面单 获取面单号
  5227. //public void set_erp_printwaybill()
  5228. //{
  5229. // if (UrlPostParmsCheck("ctid"))
  5230. // {
  5231. // string ctid = GetPostString("ctid");
  5232. // string cpCode = GetPostString("cpcode");
  5233. // string tempUrl = GetPostString("tempurl");
  5234. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5235. // //string res = taobaoHelper.test();
  5236. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5237. // if (res.IndexOf("error_response") != -1)
  5238. // {
  5239. // int sidx = res.IndexOf("sub_msg");
  5240. // int eidx = res.IndexOf("request_id");
  5241. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5242. // returnErrorMsg(msg);
  5243. // return;
  5244. // }
  5245. // int idx = res.IndexOf("waybill_code");
  5246. // int idx2 = res.IndexOf("}]}");
  5247. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5248. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5249. // ReturnSuccess(res);
  5250. // }
  5251. //}
  5252. public void cancel_erp_aftersale()
  5253. {
  5254. if (UrlPostParmsCheck("ctid"))
  5255. {
  5256. string eid = GetPostString("ctid");
  5257. CeErpTradeCell entity = null;
  5258. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5259. if (entity != null)
  5260. {
  5261. //有过处理的售后,取消也不能删除 售 字,保留
  5262. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5263. {
  5264. entity.AfterSaleState = 4;
  5265. }
  5266. else
  5267. entity.AfterSaleState = 0;
  5268. entity.Update();
  5269. returnSuccessMsg("操作成功!");
  5270. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5271. return;
  5272. }
  5273. returnErrorMsg("找不到订单记录");
  5274. }
  5275. }
  5276. public void get_erp_aftersalelist()
  5277. {
  5278. DataStruct dStruct = GetPostStruct();
  5279. List<string> lw = new List<string>();
  5280. int st = GetInt("st");
  5281. string tid = GetPostString("ctid");
  5282. if (st == 3)
  5283. {
  5284. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5285. }
  5286. else
  5287. {
  5288. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5289. }
  5290. string shopname = GetPostString("shopname");
  5291. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5292. string buyernick = GetPostString("buyer_nick");
  5293. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5294. string sellermemo = GetPostString("seller_memo");
  5295. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5296. string orderState = GetPostString("orderState");
  5297. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5298. string afterState = GetPostString("afterstate");
  5299. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5300. string date1 = GetPostString("date1");
  5301. string date2 = GetPostString("date2");
  5302. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5303. if (dw.Length > 0) lw.Add(dw);
  5304. string price1 = GetPostString("price1");
  5305. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5306. string price2 = GetPostString("price2");
  5307. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5308. //lw.Add(string.Format("IsRefund!={0}", 1));
  5309. string reason = GetPostString("reason");
  5310. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5311. string method = GetPostString("method");
  5312. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5313. string handler = GetPostString("handler");
  5314. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5315. string handledate1 = GetPostString("handledate1");
  5316. string handledate2 = GetPostString("handledate2");
  5317. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5318. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5319. string finish1 = GetPostString("finishdate1");
  5320. string finish2 = GetPostString("finishdate2");
  5321. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5322. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5323. string afterdate1 = GetPostString("afterdate1");
  5324. string afterdate2 = GetPostString("afterdate2");
  5325. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5326. if (afterDate.Length > 0) lw.Add(afterDate);
  5327. string supplier = GetPostString("supplier");
  5328. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5329. string responsible = GetPostString("responsibleman");
  5330. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5331. string customer = GetPostString("customer");
  5332. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5333. string design = GetPostString("design");
  5334. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5335. string afterMemoType = GetPostString("aftermemotype");
  5336. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5337. string posCode = CurrentUser.UserPost.Post.Code;
  5338. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5339. //{
  5340. // string vstate = GetPostString("vstate");
  5341. // if (vstate.Length > 0)
  5342. // {
  5343. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5344. // }
  5345. // if (posCode == "Supplier")
  5346. // {
  5347. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5348. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5349. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5350. // }
  5351. // else
  5352. // {
  5353. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5354. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5355. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5356. // {
  5357. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5358. // }
  5359. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5360. // {
  5361. // int orgid = CurrentUser.UserPost.OrgID;
  5362. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5363. // }
  5364. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5365. // {
  5366. // string shopid = CurrentUser.User.pemShop;
  5367. // lw.Add(string.Format("shopId in ({0})", shopid));
  5368. // }
  5369. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5370. // //{
  5371. // // int org_id = CurrentUser.UserPost.OrgID;
  5372. // // lw.Add(string.Format("OrgID={0}", org_id));
  5373. // //}
  5374. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5375. // }
  5376. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5377. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5378. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5379. //}
  5380. if (st == 5)
  5381. {
  5382. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5383. {
  5384. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5385. {
  5386. string shopid = CurrentUser.User.pemShop;
  5387. lw.Add(string.Format("shopId in ({0})", shopid));
  5388. }
  5389. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5390. {
  5391. int mrOrgid = CurrentUser.UserPost.OrgID;
  5392. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5393. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5394. }
  5395. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5396. //{
  5397. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5398. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5399. //}
  5400. else
  5401. {
  5402. string userIdStr = "";
  5403. if (posCode == "CustomerService")
  5404. {
  5405. userIdStr = CurrentUser.UserID + "_k";
  5406. }
  5407. else if (posCode == "Designer" || posCode == "wxDesigner")
  5408. {
  5409. userIdStr = CurrentUser.UserID + "_s";
  5410. }
  5411. else if (posCode == "Place")
  5412. {
  5413. userIdStr = CurrentUser.UserID + "_x";
  5414. }
  5415. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5416. }
  5417. }
  5418. string placedate1 = GetPostString("placedate1");
  5419. string placedate2 = GetPostString("placedate2");
  5420. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5421. if (dwplace.Length > 0) lw.Add(dwplace);
  5422. string supState = GetPostString("supState");
  5423. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5424. string searchType = GetPostString("searchType");
  5425. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5426. {
  5427. lw.Add(string.Format("BackNum>1"));
  5428. }
  5429. lw.Add(string.Format("AfterSaleState>0"));
  5430. if (ex_psize > 0)
  5431. {
  5432. if (CurrentUser.UserPost.Post.Code == "Finance")
  5433. dStruct.Order = "pay_time desc";
  5434. else
  5435. dStruct.Order = "HandleTime desc";
  5436. }
  5437. else
  5438. dStruct.Order = "HandleTime desc";
  5439. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5440. DataTable dt = WebCache.GetData("view_test", dStruct);
  5441. writeGridDataTableJson(dStruct.TotalCount, dt);
  5442. }
  5443. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5444. //{
  5445. // lw.Add(string.Format("AfterSaleState=4"));
  5446. // string code = CurrentUser.UserPost.Post.Code;
  5447. // if (code == "CustomerService")
  5448. // {
  5449. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5450. // }
  5451. // else if (code == "Designer" || code == "DesignerMr")
  5452. // {
  5453. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5454. // }
  5455. // else if (code == "Place" || code == "PlaceMr")
  5456. // {
  5457. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5458. // }
  5459. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5460. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5461. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5462. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5463. //}
  5464. //else //处理中的售后,待处理和处理中合并
  5465. //{
  5466. // if (afterState.Length <= 0)
  5467. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5468. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5469. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5470. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5471. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5472. //}
  5473. }
  5474. public void get_erp_disagreeftersalelist()
  5475. {
  5476. DataStruct dStruct = GetPostStruct();
  5477. List<string> lw = new List<string>();
  5478. int st = 2;
  5479. string tid = GetPostString("ctid");
  5480. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5481. string shopname = GetPostString("shopname");
  5482. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5483. string buyernick = GetPostString("buyer_nick");
  5484. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5485. string sellermemo = GetPostString("seller_memo");
  5486. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5487. string orderState = GetPostString("orderState");
  5488. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5489. string afterState = GetPostString("afterstate");
  5490. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5491. string date1 = GetPostString("date1");
  5492. string date2 = GetPostString("date2");
  5493. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5494. if (dw.Length > 0) lw.Add(dw);
  5495. string price1 = GetPostString("price1");
  5496. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5497. string price2 = GetPostString("price2");
  5498. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5499. //lw.Add(string.Format("IsRefund!={0}", 1));
  5500. string reason = GetPostString("reason");
  5501. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5502. string method = GetPostString("method");
  5503. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5504. string handler = GetPostString("handler");
  5505. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5506. string handledate1 = GetPostString("handledate1");
  5507. string handledate2 = GetPostString("handledate2");
  5508. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5509. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5510. string afterdate1 = GetPostString("afterdate1");
  5511. string afterdate2 = GetPostString("afterdate2");
  5512. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5513. if (afterDate.Length > 0) lw.Add(afterDate);
  5514. string backdate1 = GetPostString("backdate1");
  5515. string backdate2 = GetPostString("backdate2");
  5516. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5517. if (backDate.Length > 0) lw.Add(backDate);
  5518. string supplier = GetPostString("supplier");
  5519. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5520. string responsible = GetPostString("responsibleman");
  5521. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5522. string customer = GetPostString("customer");
  5523. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5524. string design = GetPostString("design");
  5525. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5526. string afterSaleMemo = GetPostString("afterSaleMemo");
  5527. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5528. string afterMemoType = GetPostString("aftermemotype");
  5529. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5530. string aftersakereason = GetPostString("aftersakereason");
  5531. if (aftersakereason.Length > 0)
  5532. {
  5533. if (aftersakereason == "1")
  5534. {
  5535. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5536. }
  5537. if (aftersakereason == "2")
  5538. {
  5539. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5540. }
  5541. }
  5542. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5543. string poscode = CurrentUser.UserPost.Post.Code;
  5544. if (poscode != "SysAdmin")
  5545. {
  5546. string shopid = CurrentUser.User.pemShop;
  5547. lw.Add(string.Format("shopId in ({0})", shopid));
  5548. }
  5549. string searchType = GetPostString("searchType");
  5550. if (searchType == "wait")
  5551. {
  5552. lw.Add(string.Format("HandleTime is null"));
  5553. }
  5554. if (searchType == "handling")
  5555. {
  5556. lw.Add(string.Format("HandleTime is not null "));
  5557. }
  5558. if (searchType == "back" || searchType == "puBack")
  5559. {
  5560. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5561. }
  5562. if (searchType == "reBack")
  5563. {
  5564. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5565. }
  5566. if (searchType == "moreBack")
  5567. {
  5568. lw.Add(string.Format("backNum > 1"));
  5569. }
  5570. lw.Add(string.Format("(AfterSaleState=5)"));
  5571. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5572. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5573. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5574. writeGridDataTableJson(dStruct.TotalCount, dt);
  5575. }
  5576. public void get_erp_handlingaftersalelist()
  5577. {
  5578. DataStruct dStruct = GetPostStruct();
  5579. List<string> lw = new List<string>();
  5580. int st = 2;
  5581. string tid = GetPostString("ctid");
  5582. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5583. string shopname = GetPostString("shopname");
  5584. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5585. string buyernick = GetPostString("buyer_nick");
  5586. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5587. string sellermemo = GetPostString("seller_memo");
  5588. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5589. string orderState = GetPostString("orderState");
  5590. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5591. string afterState = GetPostString("afterstate");
  5592. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5593. string date1 = GetPostString("date1");
  5594. string date2 = GetPostString("date2");
  5595. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5596. if (dw.Length > 0) lw.Add(dw);
  5597. string price1 = GetPostString("price1");
  5598. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5599. string price2 = GetPostString("price2");
  5600. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5601. //lw.Add(string.Format("IsRefund!={0}", 1));
  5602. string reason = GetPostString("reason");
  5603. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5604. string method = GetPostString("method");
  5605. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5606. string handler = GetPostString("handler");
  5607. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5608. string handledate1 = GetPostString("handledate1");
  5609. string handledate2 = GetPostString("handledate2");
  5610. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5611. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5612. string afterdate1 = GetPostString("afterdate1");
  5613. string afterdate2 = GetPostString("afterdate2");
  5614. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5615. if (afterDate.Length > 0) lw.Add(afterDate);
  5616. string supplier = GetPostString("supplier");
  5617. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5618. string responsible = GetPostString("responsibleman");
  5619. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5620. string customer = GetPostString("customer");
  5621. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5622. string design = GetPostString("design");
  5623. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5624. string afterSaleMemo = GetPostString("afterSaleMemo");
  5625. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5626. string afterMemoType = GetPostString("aftermemotype");
  5627. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5628. string afterresult = GetPostString("afterresult");
  5629. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5630. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5631. string poscode = CurrentUser.UserPost.Post.Code;
  5632. if (poscode != "SysAdmin")
  5633. {
  5634. string shopid = CurrentUser.User.pemShop;
  5635. lw.Add(string.Format("shopId in ({0})", shopid));
  5636. }
  5637. string searchType = GetPostString("searchType");
  5638. if (searchType == "wait")
  5639. {
  5640. lw.Add(string.Format("HandleTime is null"));
  5641. }
  5642. if (searchType == "documentary")
  5643. {
  5644. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5645. }
  5646. if (searchType == "handling")
  5647. {
  5648. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5649. }
  5650. if (searchType == "back" || searchType == "puBack")
  5651. {
  5652. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5653. }
  5654. if (searchType == "reBack")
  5655. {
  5656. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5657. }
  5658. if (afterState.Length <= 0)
  5659. {
  5660. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5661. }
  5662. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5663. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5664. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5665. writeGridDataTableJson(dStruct.TotalCount, dt);
  5666. }
  5667. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5668. //public void get_erp_back_handlingaftersalelist()
  5669. //{
  5670. // DataStruct dStruct = GetPostStruct();
  5671. // List<string> lw = new List<string>();
  5672. // string tid = GetPostString("ctid");
  5673. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5674. // string shopname = GetPostString("shopname");
  5675. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5676. // string buyernick = GetPostString("buyer_nick");
  5677. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5678. // string sellermemo = GetPostString("seller_memo");
  5679. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5680. // string orderState = GetPostString("orderState");
  5681. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5682. // string afterState = GetPostString("afterstate");
  5683. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5684. // string date1 = GetPostString("date1");
  5685. // string date2 = GetPostString("date2");
  5686. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5687. // if (dw.Length > 0) lw.Add(dw);
  5688. // string price1 = GetPostString("price1");
  5689. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5690. // string price2 = GetPostString("price2");
  5691. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5692. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5693. // string reason = GetPostString("reason");
  5694. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5695. // string method = GetPostString("method");
  5696. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5697. // string handler = GetPostString("handler");
  5698. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5699. // string handledate1 = GetPostString("handledate1");
  5700. // string handledate2 = GetPostString("handledate2");
  5701. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5702. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5703. // string afterdate1 = GetPostString("afterdate1");
  5704. // string afterdate2 = GetPostString("afterdate2");
  5705. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5706. // if (afterDate.Length > 0) lw.Add(afterDate);
  5707. // string supplier = GetPostString("supplier");
  5708. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5709. // string responsible = GetPostString("responsibleman");
  5710. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5711. // string customer = GetPostString("customer");
  5712. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5713. // string design = GetPostString("design");
  5714. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5715. // string afterMemoType = GetPostString("aftermemotype");
  5716. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5717. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5718. // if (afterState.Length <= 0)
  5719. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5720. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5721. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5722. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5723. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5724. //}
  5725. public void get_erp_aftersaleverifylist()
  5726. {
  5727. DataStruct dStruct = GetPostStruct();
  5728. List<string> lw = new List<string>();
  5729. string tid = GetPostString("ctid");
  5730. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5731. string shopname = GetPostString("shopname");
  5732. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5733. string buyernick = GetPostString("buyer_nick");
  5734. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5735. string sellermemo = GetPostString("seller_memo");
  5736. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5737. string orderState = GetPostString("orderState");
  5738. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5739. //lw.Add(string.Format("IsRefund!={0}", 1));
  5740. string reason = GetPostString("reason");
  5741. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5742. string method = GetPostString("method");
  5743. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5744. string handler = GetPostString("handler");
  5745. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5746. string handledate1 = GetPostString("handledate1");
  5747. string handledate2 = GetPostString("handledate2");
  5748. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5749. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5750. string finish1 = GetPostString("finishdate1");
  5751. string finish2 = GetPostString("finishdate2");
  5752. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5753. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5754. string supplier = GetPostString("supplier");
  5755. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5756. string responsible = GetPostString("responsibleman");
  5757. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5758. string posCode = CurrentUser.UserPost.Post.Code;
  5759. string vstate = GetPostString("vstate");
  5760. if (vstate.Length > 0)
  5761. {
  5762. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5763. }
  5764. if (posCode == "Supplier")
  5765. {
  5766. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5767. lw.Add(string.Format("VerifyState = 0"));
  5768. lw.Add("type = 1");
  5769. lw.Add(string.Format("AfterSaleState={0}", 3));
  5770. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5771. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5772. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5773. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5774. writeGridDataTableJson(dStruct.TotalCount, dt);
  5775. }
  5776. else if (posCode == "logistics")
  5777. {
  5778. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5779. lw.Add(string.Format("VerifyState = 0"));
  5780. lw.Add("type = 2");
  5781. lw.Add(string.Format("AfterSaleState={0}", 3));
  5782. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5783. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5784. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5785. writeGridDataTableJson(dStruct.TotalCount, dt);
  5786. }
  5787. else
  5788. {
  5789. lw.Add(string.Format("(AfterSaleState = 3)"));
  5790. string reasonState = GetPostString("reasonState");
  5791. lw.Add("type = 0");
  5792. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5793. || posCode == "Summarize" || posCode == "Finance")
  5794. {
  5795. if (reasonState == "2")
  5796. {
  5797. lw.Add("VerifyState = 3");
  5798. }
  5799. else if (reasonState == "1")
  5800. {
  5801. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5802. }
  5803. else
  5804. {
  5805. lw.Add("VerifyState in (0,3)");
  5806. }
  5807. //不加条件,可以看全部
  5808. }
  5809. 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")
  5810. {
  5811. int orgid = CurrentUser.UserPost.OrgID;
  5812. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5813. if (string.IsNullOrEmpty(manageOrgId))
  5814. {
  5815. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5816. }
  5817. else
  5818. {
  5819. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5820. }
  5821. if (reasonState == "1")
  5822. {
  5823. lw.Add("VerifyState = 3");
  5824. }
  5825. else if (reasonState == "2")
  5826. {
  5827. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5828. }
  5829. else
  5830. {
  5831. }
  5832. }
  5833. else
  5834. {
  5835. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5836. }
  5837. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5838. //{
  5839. // int org_id = CurrentUser.UserPost.OrgID;
  5840. // lw.Add(string.Format("OrgID={0}", org_id));
  5841. //}
  5842. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  5843. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5844. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5845. writeGridDataTableJson(dStruct.TotalCount, dt);
  5846. }
  5847. }
  5848. public void get_erp_finishaftersalelist()
  5849. {
  5850. DataStruct dStruct = GetPostStruct();
  5851. List<string> lw = new List<string>();
  5852. int st = 4;
  5853. string tid = GetPostString("ctid");
  5854. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  5855. string shopname = GetPostString("shopname");
  5856. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5857. //lw.Add(string.Format("IsRefund!={0}", 1));
  5858. string reason = GetPostString("reason");
  5859. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5860. string method = GetPostString("method");
  5861. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5862. string buyernick = GetPostString("buyer_nick");
  5863. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5864. string handler = GetPostString("handler");
  5865. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5866. string handledate1 = GetPostString("handledate1");
  5867. string handledate2 = GetPostString("handledate2");
  5868. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5869. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5870. string finish1 = GetPostString("finishdate1");
  5871. string finish2 = GetPostString("finishdate2");
  5872. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5873. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5874. string supplier = GetPostString("supplier");
  5875. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5876. string responsible = GetPostString("responsibleman");
  5877. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5878. string vstate = GetPostString("vstate");
  5879. if (vstate.Length > 0)
  5880. {
  5881. if ("3".Equals(vstate))
  5882. {
  5883. lw.Add(string.Format("IsTem=1"));
  5884. }
  5885. else
  5886. {
  5887. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5888. }
  5889. }
  5890. lw.Add(string.Format("AfterSaleState=4"));
  5891. string code = CurrentUser.UserPost.Post.Code;
  5892. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  5893. {
  5894. //不加条件,可以看全部
  5895. }
  5896. else if (code == "Supplier")
  5897. {
  5898. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5899. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5900. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5901. }
  5902. else if (code == "logistics")
  5903. {
  5904. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  5905. lw.Add("type = 2");
  5906. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5907. }
  5908. 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")
  5909. {
  5910. int orgid = CurrentUser.UserPost.OrgID;
  5911. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  5912. if (string.IsNullOrEmpty(manageOrgIds))
  5913. {
  5914. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  5915. }
  5916. else
  5917. {
  5918. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  5919. }
  5920. }
  5921. else
  5922. {
  5923. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  5924. }
  5925. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5926. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5927. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5928. writeGridDataTableJson(dStruct.TotalCount, dt);
  5929. }
  5930. public void handle_erp_aftersale()
  5931. {
  5932. if (UrlPostParmsCheck("ctid"))
  5933. {
  5934. string eid = GetPostString("ctid");
  5935. string responStr = GetPostString("AfterSaleResponsible");
  5936. if (responStr.Length <= 0)
  5937. {
  5938. returnErrorMsg("售后责任人不能为空");
  5939. return;
  5940. }
  5941. bool isDesign = false;
  5942. double designFree = 0.00;
  5943. int responsibleId = 0;
  5944. CeErpTradeCell entity = null;
  5945. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5946. if (entity != null)
  5947. {
  5948. int isNeedNewOrder = GetPostInt("IsNewOrder");
  5949. string afterMethod = GetPostString("AfterSaleMethod");
  5950. if (isNeedNewOrder == 1)
  5951. {
  5952. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  5953. bool ishav = true;
  5954. if (newentity == null)
  5955. {
  5956. newentity = entity.Clone() as CeErpTradeCell;
  5957. ishav = false;
  5958. newentity.ctid = "S_" + entity.ctid;
  5959. newentity.OrderState = 0;
  5960. }
  5961. //唯一标识
  5962. newentity.OrderSn = newentity.ctid;
  5963. /* string orderSn = dataHelper.getSaleOrderSn();
  5964. if (orderSn != "")
  5965. {
  5966. newentity.OrderSn = orderSn;
  5967. }*/
  5968. newentity.AfterSaleState = 0;
  5969. newentity.AfterSaleMethod = afterMethod;
  5970. if (!ishav)
  5971. {
  5972. string memo_str = newentity.seller_memo;
  5973. memo_str = memo_str.Replace("(", "(");
  5974. memo_str = memo_str.Replace(")", ")");
  5975. int sIndex = memo_str.IndexOf("(");
  5976. int eIndex = memo_str.IndexOf(")");
  5977. if (sIndex == -1 || eIndex == -1)
  5978. {
  5979. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  5980. return;
  5981. }
  5982. string first = memo_str.Substring(0, sIndex + 1);
  5983. string memoCtid = newentity.OrderSn;
  5984. //if (memoCtid.IndexOf("C") != -1)
  5985. //{
  5986. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  5987. //if (CIdx.IndexOf("+") != -1)
  5988. //{
  5989. //CIdx = "C" + CIdx.Split('+')[1];
  5990. //}
  5991. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  5992. //}
  5993. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  5994. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  5995. string newMemo = first + memoCtid + last;
  5996. newentity.seller_memo = newMemo;
  5997. newentity.FinishPlaceTime = null;
  5998. newentity.UnusualTag = 0;
  5999. newentity.UnusualCon = "";
  6000. newentity.UnusualTime = null;
  6001. newentity.AfterSaleMemo = "";
  6002. newentity.AfterSaleMethod = afterMethod;
  6003. newentity.AfterSalePreTime = null;
  6004. newentity.AfterSaleReason = "";
  6005. newentity.AfterSaleResponsible = "";
  6006. newentity.AfterSaleState = 0;
  6007. newentity.AfterSaleTime = null;
  6008. newentity.AfterSaleUserId = 0;
  6009. newentity.AfterSaleSupplierState = 0;
  6010. newentity.LastBillWaybillCode = "";
  6011. newentity.LastBillCpCode = "";
  6012. newentity.FinishAfterSaleTime = null;
  6013. newentity.HandleTime = null;
  6014. newentity.IsSF = 0;
  6015. newentity.IsOldCustomer = 0;
  6016. newentity.UrgencyTime = null;
  6017. newentity.ResponsibleUserId = "";
  6018. newentity.IsVerifyToSupplier = false;
  6019. newentity.payment = 0;
  6020. newentity.CheckMemo = "";
  6021. newentity.OutSid = "";
  6022. newentity.CheckOrderTime = null;
  6023. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6024. }
  6025. newentity.isAfterSaleOrder = 1;
  6026. newentity.IsRefund = 0;
  6027. string receiveMobile = GetPostString("receiver_mobile");
  6028. if (receiveMobile.Length > 0)
  6029. {
  6030. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6031. if (trade != null)
  6032. {
  6033. trade.receiver_name = GetPostString("receiver_name");
  6034. trade.receiver_mobile = receiveMobile;
  6035. trade.receiver_state = GetPostString("receiver_state");
  6036. trade.receiver_city = GetPostString("receiver_city");
  6037. trade.receiver_district = GetPostString("receiver_district");
  6038. trade.receiver_address = GetPostString("receiver_address");
  6039. newentity.IsOffLineOrder = 1;
  6040. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6041. }
  6042. }
  6043. string st = GetPostString("ToState");
  6044. if (st.Length > 0)
  6045. {
  6046. if (newentity.OrderState <= 3)
  6047. {
  6048. newentity.WaitDesignTime = DateTime.Now;
  6049. newentity.StartDesignTime = null;
  6050. newentity.FinishDesignTime = null;
  6051. newentity.OrderState = 3;
  6052. if (st == "下单员")
  6053. {
  6054. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6055. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6056. {
  6057. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6058. }
  6059. }
  6060. else
  6061. {
  6062. newentity.WaitDesignTime = DateTime.Now;
  6063. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6064. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6065. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6066. {
  6067. DataRow user = dt1.Rows[0];
  6068. //找主管
  6069. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6070. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6071. if (dt != null && dt.Rows.Count > 0)
  6072. {
  6073. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6074. newentity.DesignUserId = designMr;
  6075. string key = "aftersale_order_" + designMr;
  6076. if (RedisHelper.HasKey(key))
  6077. {
  6078. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6079. list.Add(newentity.ctid);
  6080. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6081. }
  6082. }
  6083. //账号正常
  6084. if (user["State"].ToString() == "0")
  6085. {
  6086. newentity.DesignUserId = entity.DesignUserId;
  6087. string key = "aftersale_order_" + entity.DesignUserId;
  6088. if (RedisHelper.HasKey(key))
  6089. {
  6090. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6091. list.Add(newentity.ctid);
  6092. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6093. }
  6094. }
  6095. }
  6096. }
  6097. }
  6098. if (entity.IsXianHuo == 1)
  6099. {
  6100. newentity.OrderState = 6;
  6101. entity.FinishPlaceTime = DateTime.Now;
  6102. }
  6103. }
  6104. if (ishav)
  6105. {
  6106. newentity.Update();
  6107. }
  6108. else
  6109. {
  6110. newentity.Create();
  6111. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6112. newCellExtend.ctid = newentity.ctid;
  6113. newCellExtend.orderFrom = 20;
  6114. newCellExtend.orderType = 30;
  6115. if (st == "下单员")
  6116. {
  6117. }
  6118. else
  6119. {
  6120. newCellExtend.ReprintTime = DateTime.Now;
  6121. }
  6122. newCellExtend.Create();
  6123. }
  6124. if (st != "下单员")
  6125. {
  6126. designHelper.API_GetPrintData_CreateOrder(newentity);
  6127. }
  6128. }
  6129. //处理售后扩展
  6130. string resIdStr = GetPostString("ResponsibleUserId");
  6131. string refundFees = GetPostString("refundFrees");
  6132. int IsComplain = GetPostInt("isComplain");
  6133. int IsBad = GetPostInt("isBad");
  6134. string IsOriginal = GetPostString("isOriginal");
  6135. double diffResultPrice = GetPostDouble("diffResultPrice");
  6136. string textResult = GetPostString("textResult");
  6137. string supplierResponsible = GetPostString("supplierResponsible");
  6138. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6139. if (ceErpTradeAfterSaleExtend == null)
  6140. {
  6141. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6142. ceErpTradeAfterSaleExtend.tid = eid;
  6143. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6144. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6145. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6146. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6147. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6148. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6149. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6150. ceErpTradeAfterSaleExtend.Create();
  6151. }
  6152. else
  6153. {
  6154. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6155. {
  6156. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6157. }
  6158. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6159. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6160. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6161. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6162. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6163. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6164. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6165. ceErpTradeAfterSaleExtend.Update();
  6166. }
  6167. int gysid = GetPostInt("ResponsibleSupId");
  6168. if (entity.AfterSaleUserId == 0)
  6169. {
  6170. entity.AfterSaleUserId = CurrentUser.UserID;
  6171. }
  6172. entity.ResponsibleUserId = resIdStr;
  6173. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6174. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6175. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6176. {
  6177. CeErpTradeResponsible.DelByTid(eid, -1);
  6178. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6179. int backNum = 0;
  6180. if (number != null)
  6181. {
  6182. backNum = number.BackNum;
  6183. }
  6184. char[] separator = { ',' };
  6185. string[] sArray = resIdStr.Split(separator);
  6186. string[] refundFreeList = { };
  6187. if (refundFees.Length > 0)
  6188. {
  6189. refundFreeList = refundFees.Split(separator);
  6190. }
  6191. int index = -1;
  6192. foreach (string i in sArray)
  6193. {
  6194. index++;
  6195. if (i.Length <= 0) continue;
  6196. char[] separator2 = { '_' };
  6197. string idstr = i.Split(separator2)[0];
  6198. string idtype = i.Split(separator2)[1];
  6199. double refudFree = 0;
  6200. if (refundFreeList.Length > 0)
  6201. {
  6202. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6203. }
  6204. if (idtype == "s")
  6205. {
  6206. isDesign = true;
  6207. designFree = refudFree;
  6208. }
  6209. int userId = Convert.ToInt32(idstr);
  6210. int type = 0;
  6211. if (idtype == "g")
  6212. {
  6213. type = 1;
  6214. }
  6215. if (idtype == "w")
  6216. {
  6217. type = 2;
  6218. }
  6219. if (idtype == "t")
  6220. {
  6221. type = 3;
  6222. }
  6223. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6224. if (ceErpTradeResponsible == null)
  6225. {
  6226. ceErpTradeResponsible = new CeErpTradeResponsible();
  6227. ceErpTradeResponsible.tid = eid;
  6228. ceErpTradeResponsible.UserId = userId;
  6229. ceErpTradeResponsible.createdTime = DateTime.Now;
  6230. ceErpTradeResponsible.type = type;
  6231. if (type == 1)
  6232. {
  6233. ceErpTradeResponsible.IsSup = 1;
  6234. }
  6235. if (type == 2)
  6236. {
  6237. ceErpTradeResponsible.IsFlow = 1;
  6238. }
  6239. }
  6240. ceErpTradeResponsible.RefundFee = refudFree;
  6241. ceErpTradeResponsible.VerifyState = 0;
  6242. if (userId == 2125 || idtype == "w")
  6243. {
  6244. ceErpTradeResponsible.VerifyState = 1;
  6245. }
  6246. if (idtype == "w" && userId == 101)
  6247. {
  6248. ceErpTradeResponsible.VerifyState = 0;
  6249. }
  6250. if (ceErpTradeResponsible.ID > 0)
  6251. {
  6252. ceErpTradeResponsible.Update();
  6253. }
  6254. else
  6255. {
  6256. ceErpTradeResponsible.Create();
  6257. }
  6258. if (isDesign)
  6259. {
  6260. responsibleId = ceErpTradeResponsible.ID;
  6261. }
  6262. }
  6263. CeErpTradeResponsible.NumByTid(backNum, eid);
  6264. }
  6265. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6266. if (ceErpTradeCellExtend != null)
  6267. {
  6268. ceErpTradeCellExtend.returnVisit = 0;
  6269. ceErpTradeCellExtend.Update();
  6270. }
  6271. if (entity.HandleTime != null)
  6272. {
  6273. if (entity.AfterSaleState == 1)
  6274. {
  6275. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6276. }
  6277. else
  6278. {
  6279. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6280. }
  6281. }
  6282. else
  6283. {
  6284. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6285. entity.HandleTime = DateTime.Now;
  6286. }
  6287. bool isCompale = false;
  6288. if (entity.AfterSaleState == 5)
  6289. {
  6290. isCompale = true;
  6291. entity.AfterSaleState = 3;
  6292. }
  6293. entity.AfterSaleSupplierState = 0;
  6294. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6295. {
  6296. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6297. }
  6298. string sImgs = GetPostString("img");
  6299. entity.AfterSaleSupplierImg = sImgs;
  6300. entity.supRefundType = GetPostString("supRefundType");
  6301. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6302. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6303. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6304. entity.AfterSaleMemoType = GetPostString("MemoType");
  6305. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6306. {
  6307. //entity.AfterSaleSupplierState = 2;
  6308. }
  6309. string df = GetPostString("DeductFee");
  6310. if (df == "")
  6311. {
  6312. df = "0";
  6313. }
  6314. string rf = GetPostString("RefundFee");
  6315. if (rf == "")
  6316. {
  6317. rf = "0";
  6318. }
  6319. string pm = GetPostString("AfterSalePayment");
  6320. if (pm == "")
  6321. {
  6322. pm = "0";
  6323. }
  6324. entity.AfterSalePayment = Convert.ToDouble(pm);
  6325. entity.DeductFee = Convert.ToDouble(df);
  6326. entity.RefundFee = Convert.ToDouble(rf);
  6327. entity.Update();
  6328. string toState = GetPostString("ToState");
  6329. string original = GetPostString("isOriginal");
  6330. ApiVo apiVo = new ApiVo();
  6331. apiVo.orderNumber = entity.ctid;
  6332. apiVo.actionName = "afterDesign";
  6333. apiVo.orderRemarks = entity.AfterSaleMethod;
  6334. apiVo.reasonRemarks = entity.AfterSaleReason;
  6335. apiVo.isDesign = isDesign;
  6336. apiVo.designFree = designFree;
  6337. apiVo.responsibleId = responsibleId;
  6338. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6339. if (toState == "设计师")
  6340. {
  6341. apiVo.isOriginal = Convert.ToBoolean(original);
  6342. }
  6343. designHelper.API_WorkCore(apiVo);//afterDesign
  6344. CeErpMethod methodSql = new CeErpMethod();
  6345. methodSql.con = entity.AfterSaleMethod;
  6346. methodSql.addTime = DateTime.Now;
  6347. methodSql.Create();
  6348. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6349. CeErpMethod.ExecuteNonQuery(delsql);
  6350. if (isCompale)
  6351. {
  6352. aftersale_data_change(entity.ctid);
  6353. }
  6354. returnSuccessMsg("操作成功!");
  6355. return;
  6356. }
  6357. returnErrorMsg("找不到订单记录");
  6358. }
  6359. }
  6360. public void ins_erp_toresponsible()
  6361. {
  6362. if (UrlPostParmsCheck("ctid"))
  6363. {
  6364. string eid = GetPostString("ctid");
  6365. CeErpTradeCell entity = null;
  6366. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6367. if (entity != null)
  6368. {
  6369. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6370. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6371. {
  6372. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6373. return;
  6374. }
  6375. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6376. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6377. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6378. if (entity.AfterSalePreTime == null)
  6379. {
  6380. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6381. {
  6382. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6383. }
  6384. }
  6385. entity.AfterSalePreTime = DateTime.Now;
  6386. //预完成给售后主管审核客户问题直接完成
  6387. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6388. {
  6389. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6390. {
  6391. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6392. }
  6393. }
  6394. ceErpTradeAfterSaleExtend.Update();
  6395. entity.AfterSaleState = 2;
  6396. entity.Update();
  6397. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6398. aftersale_data_change(entity.ctid);
  6399. returnSuccessMsg("操作成功!");
  6400. return;
  6401. }
  6402. returnErrorMsg("找不到订单记录");
  6403. }
  6404. }
  6405. public void cancel_erp_aftersaleanddelnew()
  6406. {
  6407. if (UrlPostParmsCheck("ctid"))
  6408. {
  6409. string eid = GetPostString("ctid");
  6410. CeErpTradeCell entity = null;
  6411. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6412. if (entity != null)
  6413. {
  6414. entity.AfterSaleState = 0;
  6415. entity.AfterSaleReason = "";
  6416. entity.AfterSaleMethod = "";
  6417. entity.AfterSaleMemo = "";
  6418. entity.AfterSaleResponsible = "";
  6419. entity.ResponsibleUserId = "";
  6420. entity.DeductFee = 0;
  6421. entity.RefundFee = 0;
  6422. entity.IsArbitrate = 0;
  6423. CeErpTradeResponsible.DelByTid(eid, -1);
  6424. entity.Update();
  6425. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6426. if (after != null)
  6427. {
  6428. if (after.OrderState < 5)
  6429. CeErpTradeCell.DelByCtid("S_" + eid);
  6430. }
  6431. returnSuccessMsg("操作成功!");
  6432. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6433. return;
  6434. }
  6435. returnErrorMsg("找不到订单记录");
  6436. }
  6437. }
  6438. public void get_erp_aftersale_pregather()
  6439. {
  6440. List<string> lw = new List<string>();
  6441. int st = GetInt("st");
  6442. string tid = GetPostString("ctid");
  6443. if (tid.Length > 0) lw.Add(string.Format("(tid = '{0}' or ctid = '{0}' or orderSn = '{0}')", tid));
  6444. string shopname = GetPostString("shopname");
  6445. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6446. string buyernick = GetPostString("buyer_nick");
  6447. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6448. string sellermemo = GetPostString("seller_memo");
  6449. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6450. string orderState = GetPostString("orderState");
  6451. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6452. string reason = GetPostString("reason");
  6453. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6454. string method = GetPostString("method");
  6455. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6456. string handler = GetPostString("handler");
  6457. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6458. string handledate1 = GetPostString("handledate1");
  6459. string handledate2 = GetPostString("handledate2");
  6460. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6461. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6462. string supplier = GetPostString("supplier");
  6463. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6464. string responsible = GetPostString("responsibleman");
  6465. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6466. string customer = GetPostString("customer");
  6467. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6468. string design = GetPostString("design");
  6469. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6470. string afterMemoType = GetPostString("aftermemotype");
  6471. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6472. string afterSaleMemo = GetPostString("afterSaleMemo");
  6473. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6474. string afterresult = GetPostString("afterresult");
  6475. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6476. string poscode = CurrentUser.UserPost.Post.Code;
  6477. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6478. {
  6479. string shopid = CurrentUser.User.pemShop;
  6480. lw.Add(string.Format("shopId in ({0})", shopid));
  6481. }
  6482. var mainwhere = string.Join(" and ", lw.ToArray());
  6483. string ro_json = "";
  6484. string type = GetPostString("gather_type");
  6485. if (poscode == "AfterSale")
  6486. {
  6487. //处理中
  6488. if (type == "Handling")
  6489. {
  6490. 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) : ""));
  6491. DataTable dt = null;
  6492. try
  6493. {
  6494. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6495. }
  6496. catch (Exception e)
  6497. {
  6498. dt = new DataTable();
  6499. }
  6500. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6501. return;
  6502. }
  6503. if (type == "Wait")
  6504. {
  6505. //待处理
  6506. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6507. DataTable dt1 = null;
  6508. try
  6509. {
  6510. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6511. }
  6512. catch (Exception e)
  6513. {
  6514. dt1 = new DataTable();
  6515. }
  6516. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6517. return;
  6518. }
  6519. if (type == "back")
  6520. {
  6521. //打回
  6522. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6523. DataTable dt2 = null;
  6524. try
  6525. {
  6526. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6527. }
  6528. catch (Exception e)
  6529. {
  6530. dt2 = new DataTable();
  6531. }
  6532. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6533. return;
  6534. }
  6535. if (type == "preCompletion")
  6536. {
  6537. //预完成
  6538. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6539. DataTable dt3 = null;
  6540. try
  6541. {
  6542. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6543. }
  6544. catch (Exception e)
  6545. {
  6546. dt3 = new DataTable();
  6547. }
  6548. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6549. return;
  6550. }
  6551. if (type == "documentary")
  6552. {
  6553. //跟单中
  6554. 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) : ""));
  6555. DataTable dt4 = null;
  6556. try
  6557. {
  6558. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6559. }
  6560. catch (Exception e)
  6561. {
  6562. dt4 = new DataTable();
  6563. }
  6564. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6565. return;
  6566. }
  6567. if (type == "reBack")
  6568. {
  6569. //被打回
  6570. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6571. DataTable dt1 = null;
  6572. try
  6573. {
  6574. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6575. }
  6576. catch (Exception e)
  6577. {
  6578. dt1 = new DataTable();
  6579. }
  6580. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6581. return;
  6582. }
  6583. }
  6584. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6585. {
  6586. if (type == "puBack")
  6587. {
  6588. //退回
  6589. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6590. DataTable dt = null;
  6591. try
  6592. {
  6593. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6594. }
  6595. catch (Exception e)
  6596. {
  6597. dt = new DataTable();
  6598. }
  6599. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6600. return;
  6601. }
  6602. if (type == "reBack")
  6603. {
  6604. //打回
  6605. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6606. DataTable dt1 = null;
  6607. try
  6608. {
  6609. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6610. }
  6611. catch (Exception e)
  6612. {
  6613. dt1 = new DataTable();
  6614. }
  6615. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6616. return;
  6617. }
  6618. if (type == "examEd")
  6619. {
  6620. //已审核
  6621. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6622. DataTable dt2 = null;
  6623. try
  6624. {
  6625. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6626. }
  6627. catch (Exception e)
  6628. {
  6629. dt2 = new DataTable();
  6630. }
  6631. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6632. return;
  6633. }
  6634. if (type == "waitExam")
  6635. {
  6636. //待审核
  6637. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6638. DataTable dt3 = null;
  6639. try
  6640. {
  6641. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6642. }
  6643. catch (Exception e)
  6644. {
  6645. dt3 = new DataTable();
  6646. }
  6647. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6648. return;
  6649. }
  6650. if (type == "Handling")
  6651. {
  6652. //处理中
  6653. 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) : ""));
  6654. DataTable dt4 = null;
  6655. try
  6656. {
  6657. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6658. }
  6659. catch (Exception e)
  6660. {
  6661. dt4 = new DataTable();
  6662. }
  6663. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6664. return;
  6665. }
  6666. if (type == "Wait")
  6667. {
  6668. //待处理
  6669. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6670. DataTable dt5 = null;
  6671. try
  6672. {
  6673. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6674. }
  6675. catch (Exception e)
  6676. {
  6677. dt5 = new DataTable();
  6678. }
  6679. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6680. return;
  6681. }
  6682. if (type == "documentary")
  6683. {
  6684. //跟单中
  6685. 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) : ""));
  6686. DataTable dt6 = null;
  6687. try
  6688. {
  6689. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6690. }
  6691. catch (Exception e)
  6692. {
  6693. dt6 = new DataTable();
  6694. }
  6695. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6696. return;
  6697. }
  6698. }
  6699. returnSuccess(ro_json);
  6700. }
  6701. public void end_erp_aftersale()
  6702. {
  6703. if (UrlPostParmsCheck("ctid"))
  6704. {
  6705. string eid = GetPostString("ctid");
  6706. CeErpTradeCell entity = null;
  6707. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6708. if (entity != null)
  6709. {
  6710. string stype = GetPostString("stype");
  6711. string typeStr = stype;
  6712. entity.AfterSaleState = 4;
  6713. entity.FinishAfterSaleTime = DateTime.Now;
  6714. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6715. entity.Update();
  6716. ApiVo apiVo = new ApiVo();
  6717. apiVo.orderNumber = entity.ctid;
  6718. apiVo.actionName = "afterOver";
  6719. designHelper.API_WorkCore(apiVo); //afterOver
  6720. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6721. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6722. CeErpSukuraData.createInfo(entity.ctid, 8);
  6723. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6724. returnSuccessMsg("操作成功!");
  6725. return;
  6726. }
  6727. returnErrorMsg("找不到订单记录");
  6728. }
  6729. }
  6730. public void ins_erp_finishaftersale()
  6731. {
  6732. if (UrlPostParmsCheck("id"))
  6733. {
  6734. string eid = GetPostString("id");
  6735. CeErpTradeResponsible entity = null;
  6736. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6737. if (entity != null)
  6738. {
  6739. entity.VerifyState = 1;
  6740. entity.VerifyTime = DateTime.Now;
  6741. entity.Update();
  6742. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6743. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6744. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6745. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6746. if (dt.Rows.Count <= 0)
  6747. {
  6748. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6749. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6750. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6751. CeErpSukuraData.createInfo(entity.tid, 8);
  6752. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6753. {
  6754. CeErpDesignerBill.Del(entity.tid);
  6755. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6756. }
  6757. }
  6758. returnSuccessMsg("操作成功!");
  6759. return;
  6760. }
  6761. returnErrorMsg("找不到订单记录");
  6762. }
  6763. }
  6764. public void upd_erp_arbitrateaftersale()
  6765. {
  6766. if (UrlPostParmsCheck("id"))
  6767. {
  6768. string eid = GetPostString("id");
  6769. CeErpTradeResponsible entity = null;
  6770. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6771. if (entity != null)
  6772. {
  6773. entity.IsArbitrate = 1;
  6774. entity.ArbitradeMemo = GetPostString("reason");
  6775. entity.VerifyState = 2;
  6776. entity.Update();
  6777. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6778. if (tradecell != null)
  6779. {
  6780. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6781. tradecell.IsArbitrate = 1;
  6782. tradecell.Update();
  6783. }
  6784. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6785. returnSuccessMsg("操作成功!");
  6786. return;
  6787. }
  6788. returnErrorMsg("找不到订单记录");
  6789. }
  6790. }
  6791. public void upd_erp_backaftersale()
  6792. {
  6793. if (UrlPostParmsCheck("tid"))
  6794. {
  6795. string eid = GetPostString("tid");
  6796. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6797. int backNum = 0;
  6798. if (number != null)
  6799. {
  6800. backNum = number.BackNum;
  6801. }
  6802. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6803. CeErpTradeCell entity = null;
  6804. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6805. if (entity != null)
  6806. {
  6807. entity.AfterSaleBackReason = GetPostString("backreason");
  6808. entity.AfterSaleState = 1;
  6809. entity.AfterSaleSupplierState = 0;
  6810. entity.Update();
  6811. returnSuccessMsg("操作成功!");
  6812. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6813. return;
  6814. }
  6815. returnErrorMsg("找不到订单记录");
  6816. }
  6817. }
  6818. public void get_erp_supplieraftersalelist()
  6819. {
  6820. DataStruct dStruct = GetPostStruct();
  6821. List<string> lw = new List<string>();
  6822. string tid = GetPostString("ctid");
  6823. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6824. string shopname = GetPostString("shopname");
  6825. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6826. string buyernick = GetPostString("buyer_nick");
  6827. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6828. string sellermemo = GetPostString("seller_memo");
  6829. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6830. string orderState = GetPostString("orderState");
  6831. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6832. string afterState = GetPostString("afterstate");
  6833. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6834. string date1 = GetPostString("date1");
  6835. string date2 = GetPostString("date2");
  6836. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6837. if (dw.Length > 0) lw.Add(dw);
  6838. string price1 = GetPostString("price1");
  6839. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6840. string price2 = GetPostString("price2");
  6841. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6842. string reason = GetPostString("reason");
  6843. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6844. string method = GetPostString("method");
  6845. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6846. string handledate1 = GetPostString("handledate1");
  6847. string handledate2 = GetPostString("handledate2");
  6848. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6849. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6850. string handler = GetPostString("handler");
  6851. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6852. string afterdate1 = GetPostString("afterdate1");
  6853. string afterdate2 = GetPostString("afterdate2");
  6854. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6855. if (afterDate.Length > 0) lw.Add(afterDate);
  6856. string customer = GetPostString("customer");
  6857. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6858. string design = GetPostString("design");
  6859. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6860. string afterMemoType = GetPostString("aftermemotype");
  6861. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6862. string vstate = GetPostString("vstate");
  6863. if (vstate.Length > 0)
  6864. {
  6865. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6866. }
  6867. lw.Add(string.Format("AfterSaleState>={0}", 2));
  6868. string supplier = GetPostString("supplier");
  6869. int supid = commonHelper.getSupplierIDByName(supplier);
  6870. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  6871. string posCode = CurrentUser.UserPost.Post.Code;
  6872. if (posCode == "Supplier")
  6873. {
  6874. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6875. }
  6876. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  6877. {
  6878. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  6879. }
  6880. else
  6881. {
  6882. lw.Add(string.Format("AfterSaleResSupId != 0"));
  6883. }
  6884. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6885. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6886. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6887. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6888. writeGridDataTableJson(dStruct.TotalCount, dt);
  6889. }
  6890. public void upd_erp_supverifyaftersale()
  6891. {
  6892. if (UrlPostParmsCheck("id"))
  6893. {
  6894. string id = GetPostString("id");
  6895. int st = GetPostInt("afterstate");
  6896. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6897. CeErpTradeCell entity = null;
  6898. if (ceErpTradeResponsible != null)
  6899. {
  6900. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6901. }
  6902. string afmemo = GetPostString("supmemo");
  6903. string image = GetPostString("image");
  6904. if (entity != null)
  6905. {
  6906. entity.AfterSaleSupplierState = st;
  6907. entity.AfterSaleSupplierMemo = afmemo;
  6908. if (st == 1)
  6909. {
  6910. ceErpTradeResponsible.VerifyState = 1;
  6911. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6912. ceErpTradeResponsible.Update();
  6913. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6914. if (isAll)
  6915. {
  6916. entity.AfterSaleState = 4;
  6917. entity.FinishAfterSaleTime = DateTime.Now;
  6918. }
  6919. }
  6920. else
  6921. {
  6922. CeErpTradeResponsible.dateByTid(entity.ctid);
  6923. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6924. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6925. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6926. if (num <= 1)
  6927. {
  6928. entity.AfterSaleState = 1;
  6929. }
  6930. else
  6931. {
  6932. entity.AfterSaleState = 5;
  6933. }
  6934. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6935. if (ceErpTradeAfterSaleExtend != null)
  6936. {
  6937. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6938. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6939. ceErpTradeAfterSaleExtend.Update();
  6940. }
  6941. else
  6942. {
  6943. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6944. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6945. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6946. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6947. ceErpTradeAfterSaleExtend.Create();
  6948. }
  6949. }
  6950. if (entity.AfterSaleState == 4)
  6951. {
  6952. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6953. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  6954. {
  6955. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6956. }
  6957. ApiVo apiVo = new ApiVo();
  6958. apiVo.orderNumber = entity.ctid;
  6959. apiVo.actionName = "afterOver";
  6960. designHelper.API_WorkCore(apiVo); //afterOver
  6961. }
  6962. entity.Update();
  6963. returnSuccessMsg("操作成功!");
  6964. CeErpSukuraData.createInfo(entity.ctid, 8);
  6965. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6966. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6967. return;
  6968. }
  6969. returnErrorMsg("找不到订单记录");
  6970. }
  6971. }
  6972. public void upd_erp_masteraftersale()
  6973. {
  6974. if (UrlPostParmsCheck("id"))
  6975. {
  6976. string id = GetPostString("id");
  6977. int st = GetPostInt("afterstate");
  6978. string afmemo = GetPostString("supmemo");
  6979. string image = GetPostString("image");
  6980. string textResult = GetPostString("textResult");
  6981. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6982. if (ceErpTradeResponsible != null)
  6983. {
  6984. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  6985. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6986. ceErpTradeResponsible.Update();
  6987. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6988. if (entity != null)
  6989. {
  6990. entity.AfterSaleSupplierState = st;
  6991. entity.AfterSaleSupplierMemo = afmemo;
  6992. if (st == 1)
  6993. {
  6994. }
  6995. else
  6996. {
  6997. CeErpTradeResponsible.dateByTid(entity.ctid);
  6998. //退回到售后
  6999. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7000. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7001. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7002. if (num <= 1)
  7003. {
  7004. entity.AfterSaleState = 1;
  7005. }
  7006. else
  7007. {
  7008. entity.AfterSaleState = 5;
  7009. }
  7010. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7011. if (ceErpTradeAfterSaleExtend != null)
  7012. {
  7013. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7014. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7015. ceErpTradeAfterSaleExtend.Update();
  7016. }
  7017. else
  7018. {
  7019. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7020. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7021. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7022. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7023. ceErpTradeAfterSaleExtend.Create();
  7024. }
  7025. }
  7026. entity.Update();
  7027. returnSuccessMsg("操作成功!");
  7028. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7029. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7030. return;
  7031. }
  7032. }
  7033. returnErrorMsg("找不到订单记录");
  7034. }
  7035. }
  7036. public void upd_erp_personaftersale()
  7037. {
  7038. if (UrlPostParmsCheck("id"))
  7039. {
  7040. string id = GetPostString("id");
  7041. int st = GetPostInt("afterstate");
  7042. string afmemo = GetPostString("supmemo");
  7043. string image = GetPostString("image");
  7044. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7045. if (ceErpTradeResponsible != null)
  7046. {
  7047. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7048. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7049. ceErpTradeResponsible.Update();
  7050. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7051. if (entity != null)
  7052. {
  7053. entity.AfterSaleSupplierMemo = afmemo;
  7054. entity.AfterSaleSupplierState = st;
  7055. if (st == 1)
  7056. {
  7057. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7058. if (isAll)
  7059. {
  7060. entity.AfterSaleState = 4;
  7061. entity.FinishAfterSaleTime = DateTime.Now;
  7062. }
  7063. }
  7064. else
  7065. {
  7066. CeErpTradeResponsible.dateByTid(entity.ctid);
  7067. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7068. if (ceErpTradeAfterSaleExtend != null)
  7069. {
  7070. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7071. ceErpTradeAfterSaleExtend.Update();
  7072. }
  7073. else
  7074. {
  7075. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7076. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7077. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7078. ceErpTradeAfterSaleExtend.Create();
  7079. }
  7080. //退回到主管
  7081. //entity.AfterSaleState = 2;
  7082. }
  7083. if (entity.AfterSaleState == 4)
  7084. {
  7085. ApiVo apiVo = new ApiVo();
  7086. apiVo.orderNumber = entity.ctid;
  7087. apiVo.actionName = "afterOver";
  7088. designHelper.API_WorkCore(apiVo); //afterOver
  7089. }
  7090. entity.Update();
  7091. returnSuccessMsg("操作成功!");
  7092. CeErpSukuraData.createInfo(entity.ctid, 8);
  7093. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7094. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7095. return;
  7096. }
  7097. }
  7098. returnErrorMsg("找不到订单记录");
  7099. }
  7100. }
  7101. public void set_erp_supplierrefundtag()
  7102. {
  7103. if (UrlPostParmsCheck("ctid"))
  7104. {
  7105. string eid = GetPostString("ctid");
  7106. CeErpTradeCell entity = null;
  7107. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7108. if (entity != null)
  7109. {
  7110. entity.IsSupplierRefund = GetPostInt("tag");
  7111. entity.Update();
  7112. returnSuccessMsg("操作成功!");
  7113. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7114. return;
  7115. }
  7116. returnErrorMsg("找不到订单记录");
  7117. }
  7118. }
  7119. public void get_erp_refundlist()
  7120. {
  7121. DataStruct dStruct = GetPostStruct();
  7122. List<string> lw = new List<string>();
  7123. string tid = GetPostString("tid");
  7124. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7125. //string rid = GetPostString("refund_id");
  7126. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7127. string shopname = GetPostString("shopname");
  7128. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7129. string buyernick = GetPostString("buyer_nick");
  7130. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7131. string customer = GetPostString("customer");
  7132. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7133. string design = GetPostString("design");
  7134. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7135. string sellermemo = GetPostString("seller_memo");
  7136. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7137. //string date1 = GetPostString("date1");
  7138. //string date2 = GetPostString("date2");
  7139. //string dateType = GetPostString("dateType");
  7140. //if (dateType.Length > 0)
  7141. //{
  7142. // if (dateType == "1001") dateType = "0";
  7143. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7144. // if (searchDT.Count == 2)
  7145. // {
  7146. // date1 = searchDT[0].ToString();
  7147. // date2 = searchDT[1].ToString();
  7148. // }
  7149. //}
  7150. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7151. //if (dw.Length > 0) lw.Add(dw);
  7152. string redate1 = GetPostString("refunddate1");
  7153. string redate2 = GetPostString("refunddate2");
  7154. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7155. if (dwdate.Length > 0) lw.Add(dwdate);
  7156. string price1 = GetPostString("price1");
  7157. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7158. string price2 = GetPostString("price2");
  7159. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7160. string ispartrefund = GetPostString("ispartrefund");
  7161. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7162. string refundState = GetPostString("refundvstate");
  7163. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7164. int st = GetInt("st");
  7165. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7166. {
  7167. string responsible = GetPostString("responsibleman");
  7168. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7169. lw.Add(string.Format("RefundState>={0}", st));
  7170. string code = CurrentUser.UserPost.Post.Code;
  7171. if (code == "CustomerService")
  7172. {
  7173. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7174. }
  7175. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7176. {
  7177. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7178. }
  7179. else if (code == "Place" || code == "PlaceMr")
  7180. {
  7181. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7182. }
  7183. dStruct.Order = "RefundState asc,created desc";
  7184. }
  7185. else if (st == 10)
  7186. {
  7187. string responsible = GetPostString("responsibleman");
  7188. if (responsible == "空白")
  7189. {
  7190. lw.Add(string.Format("ResponsibleUserName = ''"));
  7191. }
  7192. else if (responsible.Length > 0)
  7193. {
  7194. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7195. }
  7196. lw.Add(string.Format("RefundState>=0"));
  7197. dStruct.Order = "created desc";
  7198. }
  7199. else
  7200. {
  7201. string responsible = GetPostString("responsibleman");
  7202. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7203. lw.Add(string.Format("RefundState={0}", st));
  7204. dStruct.Order = "created desc";
  7205. }
  7206. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7207. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7208. dt.Columns.Add("refund_fees");
  7209. foreach (DataRow dr in dt.Rows)
  7210. {
  7211. String status = dr["status"].ToString();
  7212. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7213. {
  7214. dr["refund_fees"] = dr["refund_fee"];
  7215. }
  7216. else
  7217. {
  7218. dr["refund_fees"] = "0.0";
  7219. }
  7220. }
  7221. writeGridDataTableJson(dStruct.TotalCount, dt);
  7222. }
  7223. public void get_erp_refunddesignlist()
  7224. {
  7225. DataStruct dStruct = GetPostStruct();
  7226. List<string> lw = new List<string>();
  7227. string tid = GetPostString("tid");
  7228. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7229. string shopname = GetPostString("shopname");
  7230. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7231. string buyernick = GetPostString("buyer_nick");
  7232. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7233. string customer = GetPostString("customer");
  7234. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7235. string design = GetPostString("design");
  7236. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7237. string sellermemo = GetPostString("seller_memo");
  7238. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7239. string redate1 = GetPostString("refunddate1");
  7240. string redate2 = GetPostString("refunddate2");
  7241. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7242. if (dwdate.Length > 0) lw.Add(dwdate);
  7243. string price1 = GetPostString("price1");
  7244. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7245. string price2 = GetPostString("price2");
  7246. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7247. string ispartrefund = GetPostString("ispartrefund");
  7248. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7249. string designerorg = GetPostString("designerorg");
  7250. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7251. string refundState = GetPostString("refundState");
  7252. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7253. int myOrgid = CurrentUser.UserPost.OrgID;
  7254. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7255. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7256. {
  7257. if (CurrentUser.User.TeamIds.Length > 0)
  7258. {
  7259. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7260. }
  7261. else
  7262. {
  7263. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7264. }
  7265. }
  7266. else if ("SysAdmin".Equals(myOrgCode))
  7267. {
  7268. }
  7269. else
  7270. {
  7271. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7272. {
  7273. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7274. }
  7275. else
  7276. {
  7277. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7278. }
  7279. }
  7280. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7281. dStruct.Order = "created desc";
  7282. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7283. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7284. dt.Columns.Add("refund_fees");
  7285. foreach (DataRow dr in dt.Rows)
  7286. {
  7287. String status = dr["status"].ToString();
  7288. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7289. {
  7290. dr["refund_fees"] = dr["refund_fee"];
  7291. }
  7292. else
  7293. {
  7294. dr["refund_fees"] = "0.0";
  7295. }
  7296. }
  7297. writeGridDataTableJson(dStruct.TotalCount, dt);
  7298. }
  7299. public void handle_erp_refundtag()
  7300. {
  7301. if (UrlPostParmsCheck("refund_id"))
  7302. {
  7303. string eid = GetPostString("refund_id");
  7304. string respMan = GetPostString("ResponsibleName");
  7305. if (respMan.Length <= 0)
  7306. {
  7307. returnErrorMsg("责任人不能为空");
  7308. return;
  7309. }
  7310. CeErpTradeRefund entity = null;
  7311. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7312. if (entity != null)
  7313. {
  7314. entity.ResponsibleUserName = respMan;
  7315. string userid = GetPostString("ResponsibleUserId");
  7316. if (userid.Length > 0)
  7317. {
  7318. entity.ResponsibleUserId = userid;
  7319. }
  7320. entity.Memo = GetPostString("Memo");
  7321. if (respMan.IndexOf("客服") != -1 ||
  7322. respMan.IndexOf("设计师") != -1 ||
  7323. respMan.IndexOf("下单员") != -1)
  7324. {
  7325. entity.RefundState = 2;
  7326. }
  7327. else
  7328. {
  7329. entity.RefundState = 3;
  7330. }
  7331. entity.modified = DateTime.Now;
  7332. entity.Update();
  7333. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7334. returnSuccessMsg("操作成功!");
  7335. return;
  7336. }
  7337. returnErrorMsg("找不到订单记录");
  7338. }
  7339. }
  7340. public void handle_erp_designrefundtag()
  7341. {
  7342. if (UrlPostParmsCheck("refund_id"))
  7343. {
  7344. string eid = GetPostString("refund_id");
  7345. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7346. if (ceErpTradeCellExtend == null)
  7347. {
  7348. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7349. ceErpTradeCellExtend.ctid = eid;
  7350. }
  7351. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7352. if (ceErpTradeCellExtend.ID > 0)
  7353. {
  7354. ceErpTradeCellExtend.Update();
  7355. }
  7356. else
  7357. {
  7358. ceErpTradeCellExtend.Create();
  7359. }
  7360. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7361. returnSuccessMsg("操作成功!");
  7362. return;
  7363. }
  7364. returnErrorMsg("找不到订单记录");
  7365. }
  7366. public void upd_erp_refundverify()
  7367. {
  7368. if (UrlPostParmsCheck("refund_id"))
  7369. {
  7370. string eid = GetPostString("refund_id");
  7371. CeErpTradeRefund entity = null;
  7372. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7373. if (entity != null)
  7374. {
  7375. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7376. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7377. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7378. {
  7379. entity.RefundState = 2;
  7380. }
  7381. else
  7382. {
  7383. entity.RefundState = 3;
  7384. }
  7385. entity.Update();
  7386. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7387. returnSuccessMsg("操作成功!");
  7388. return;
  7389. }
  7390. returnErrorMsg("找不到订单记录");
  7391. }
  7392. }
  7393. public void upd_erp_refundapprove()
  7394. {
  7395. if (UrlPostParmsCheck("refund_id"))
  7396. {
  7397. string eid = GetPostString("refund_id");
  7398. CeErpTradeRefund entity = null;
  7399. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7400. if (entity != null)
  7401. {
  7402. int apr = GetPostInt("approve");
  7403. if (apr == 0)
  7404. {
  7405. entity.RefundState = 1;
  7406. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7407. }
  7408. else if (apr == 1)
  7409. {
  7410. entity.RefundState = 3;
  7411. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7412. }
  7413. entity.modified = DateTime.Now;
  7414. entity.Update();
  7415. returnSuccessMsg("操作成功!");
  7416. return;
  7417. }
  7418. returnErrorMsg("找不到订单记录");
  7419. }
  7420. }
  7421. public void get_erp_billlist()
  7422. {
  7423. DataStruct dStruct = GetPostStruct();
  7424. List<string> lw = new List<string>();
  7425. string title = GetPostString("title");
  7426. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7427. string tid = GetPostString("tid");
  7428. string tids = GetPostString("tids");
  7429. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7430. if (tids.Length > 0)
  7431. {
  7432. tids = "'" + tids + "'";
  7433. tids = tids.Replace(",", "','");
  7434. lw.Add(string.Format("tid in ({0})", tids));
  7435. }
  7436. string shopname = GetPostString("shopname");
  7437. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7438. string buyernick = GetPostString("buyer_nick");
  7439. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7440. string customer = GetPostString("customer");
  7441. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7442. string date1 = GetPostString("date1");
  7443. string date2 = GetPostString("date2");
  7444. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7445. if (dw.Length > 0) lw.Add(dw);
  7446. string price1 = GetPostString("price1");
  7447. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7448. string price2 = GetPostString("price2");
  7449. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7450. string returndate1 = GetPostString("returndate1");
  7451. string returndate2 = GetPostString("returndate2");
  7452. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7453. if (dw1.Length > 0) lw.Add(dw1);
  7454. string billtype = GetPostString("billtype");
  7455. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7456. string billstate = GetPostString("billstate");
  7457. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7458. string usershop = CurrentUser.User.pemShop;
  7459. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7460. dStruct.Order = "createTime desc";
  7461. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7462. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7463. //foreach (DataRow dr in dt.Rows)
  7464. //{
  7465. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7466. //}
  7467. writeGridDataTableJson(dStruct.TotalCount, dt);
  7468. }
  7469. public void modify_erp_billinfo()
  7470. {
  7471. if (UrlPostParmsCheck("ID"))
  7472. {
  7473. string eid = GetPostString("ID");
  7474. CeErpBill bill_entity = null;
  7475. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7476. if (bill_entity != null)
  7477. {
  7478. bill_entity.tid = GetPostString("tid");
  7479. bill_entity.title = GetPostString("title");
  7480. bill_entity.tax = GetPostString("tax");
  7481. bill_entity.bank = GetPostString("bank");
  7482. bill_entity.bankac = GetPostString("bankac");
  7483. bill_entity.address = GetPostString("address");
  7484. bill_entity.phone = GetPostString("phone");
  7485. bill_entity.price = GetPostString("price");
  7486. bill_entity.productId = GetPostInt("ProductName");
  7487. bill_entity.num = GetPostInt("num");
  7488. bill_entity.unit = GetPostString("unit");
  7489. bill_entity.type = GetPostString("type");
  7490. bill_entity.sendType = GetPostString("SendType");
  7491. bill_entity.email = GetPostString("email");
  7492. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7493. bill_entity.shopName = GetPostString("ShopName");
  7494. bill_entity.applymemo = GetPostString("applymemo");
  7495. bill_entity.modifyTime = DateTime.Now;
  7496. bill_entity.createTime = DateTime.Now;
  7497. bill_entity.state = 0;
  7498. bill_entity.Update();
  7499. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7500. returnSuccessMsg("发票修改成功!");
  7501. return;
  7502. }
  7503. returnErrorMsg("找不到对应记录");
  7504. }
  7505. }
  7506. public void set_erp_invoicing()
  7507. {
  7508. if (UrlPostParmsCheck("id"))
  7509. {
  7510. try
  7511. {
  7512. string eid = GetPostString("id");
  7513. CeErpBill bill_entity = null;
  7514. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7515. if (bill_entity != null)
  7516. {
  7517. int ComId = GetPostInt("ComId");
  7518. //string memo = GetPostString("Memo");
  7519. int allInfo = GetPostInt("allinfo");
  7520. string clert = CurrentUser.User.Name;
  7521. //string detailValue = GetPostString("detailvalue");
  7522. string billId = bill_entity.billOrderId;
  7523. string[] billIdList = billId.Split(',');
  7524. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7525. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7526. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7527. {
  7528. billCount += 1;
  7529. }
  7530. if (billId.Length <= 0 || billIdList.Length != billCount)
  7531. {
  7532. bill_entity.billOrderId = "";
  7533. string prebill = "ltb";
  7534. for (int idx = 1; idx <= billCount; idx++)
  7535. {
  7536. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7537. string billoid = prebill + idx + dtstr;
  7538. bill_entity.billOrderId += billoid;
  7539. if (idx < billCount)
  7540. {
  7541. bill_entity.billOrderId += ",";
  7542. }
  7543. }
  7544. }
  7545. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7546. if (bill_entity.state == 5)
  7547. {
  7548. string errMsg = bill_entity.failerror;
  7549. string[] errlist = errMsg.Split('|');
  7550. string[] errTags = new string[errlist.Length];
  7551. for (int itag = 0; itag < errlist.Length; itag++)
  7552. {
  7553. if (errlist[itag].Length <= 0) continue;
  7554. errTags[itag] = errlist[itag].Split('&')[0];
  7555. }
  7556. for (int iii = 0; iii < errTags.Length; iii++)
  7557. {
  7558. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7559. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7560. if (billOrderList.Length >= erroBillOrderTag)
  7561. {
  7562. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7563. if (needModifyBillId.Length <= 19)
  7564. {
  7565. needModifyBillId = needModifyBillId + "1";
  7566. }
  7567. else
  7568. {
  7569. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7570. last = last + 1;
  7571. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7572. }
  7573. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7574. }
  7575. }
  7576. }
  7577. bool isHaveBillSucces = false;
  7578. string totalRes = "";
  7579. bill_entity.failerror = "";
  7580. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7581. {
  7582. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7583. totalRes += res;
  7584. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7585. {
  7586. isHaveBillSucces = true;
  7587. bill_entity.comId = ComId;
  7588. bill_entity.state = 1;
  7589. bill_entity.executeTime = DateTime.Now;
  7590. bill_entity.executeUser = clert;
  7591. }
  7592. else
  7593. {
  7594. bill_entity.state = 5;
  7595. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7596. }
  7597. }
  7598. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7599. bill_entity.Update();
  7600. if (isHaveBillSucces)
  7601. {
  7602. StringBuilder sql = new StringBuilder();
  7603. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7604. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7605. }
  7606. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7607. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7608. {
  7609. returnErrorMsg("开票失败");
  7610. }
  7611. else
  7612. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7613. return;
  7614. }
  7615. returnErrorMsg("找不到对应记录");
  7616. }
  7617. catch (Exception ex)
  7618. {
  7619. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7620. returnErrorMsg("操作失败");
  7621. }
  7622. }
  7623. }
  7624. public void get_erp_invoicing_back()
  7625. {
  7626. if (UrlPostParmsCheck("id"))
  7627. {
  7628. try
  7629. {
  7630. string id = GetPostString("id");
  7631. CeErpBill entiy = CeErpBill.Get(id);
  7632. if (entiy != null)
  7633. {
  7634. if (entiy.state == 0)
  7635. {
  7636. returnErrorMsg("发票还未开具");
  7637. return;
  7638. }
  7639. string[] billOrderList = entiy.billOrderId.Split(',');
  7640. int iTag = 0;
  7641. entiy.fplsh = "";
  7642. entiy.fpdm = "";
  7643. entiy.fphm = "";
  7644. foreach (string billOrderId in billOrderList)
  7645. {
  7646. iTag++;
  7647. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7648. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7649. {
  7650. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7651. try
  7652. {
  7653. Invoicing_get_response_Obj iObj = null;
  7654. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7655. if (iObj != null)
  7656. {
  7657. entiy.state = 2;
  7658. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7659. entiy.fpdm += iObj.list[0].c_fpdm;
  7660. entiy.fphm += iObj.list[0].c_fphm;
  7661. if (iTag < billOrderList.Length)
  7662. {
  7663. entiy.fplsh += ",";
  7664. entiy.fpdm += ",";
  7665. entiy.fphm += ",";
  7666. }
  7667. entiy.Update();
  7668. }
  7669. StringBuilder sql = new StringBuilder();
  7670. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7671. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7672. returnSuccessMsg("开票成功");
  7673. }
  7674. catch (Exception ex)
  7675. {
  7676. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7677. }
  7678. return;
  7679. }
  7680. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7681. {
  7682. var res_obj = new
  7683. {
  7684. data = "开票中"
  7685. };
  7686. string ro_json = JsonConvert.SerializeObject(res_obj);
  7687. returnSuccess(ro_json);
  7688. return;
  7689. }
  7690. else
  7691. {
  7692. int eidx = res.IndexOf("c_resultmsg");
  7693. int lidx = res.IndexOf("c_status");
  7694. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7695. entiy.state = 5;
  7696. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7697. entiy.Update();
  7698. returnErrorMsg("开票失败");
  7699. return;
  7700. }
  7701. }
  7702. }
  7703. }
  7704. catch (Exception ex)
  7705. {
  7706. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7707. }
  7708. return;
  7709. }
  7710. }
  7711. public void get_erp_invoicing()
  7712. {
  7713. if (UrlPostParmsCheck("id"))
  7714. {
  7715. try
  7716. {
  7717. string id = GetPostString("id");
  7718. CeErpBill entiy = CeErpBill.Get(id);
  7719. if (entiy != null)
  7720. {
  7721. if (entiy.state == 0)
  7722. {
  7723. returnErrorMsg("发票还未开具");
  7724. return;
  7725. }
  7726. if (entiy.sendType == "纸质发票")
  7727. {
  7728. if (entiy.img.Length <= 0)
  7729. {
  7730. returnErrorMsg("查无纸质发票");
  7731. return;
  7732. }
  7733. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7734. returnSuccess(returnres);
  7735. return;
  7736. }
  7737. string[] billOrderList = entiy.billOrderId.Split(',');
  7738. int iTag = 0;
  7739. string fpUrl = "";
  7740. entiy.fplsh = "";
  7741. entiy.fpdm = "";
  7742. entiy.fphm = "";
  7743. foreach (string billOrderId in billOrderList)
  7744. {
  7745. iTag++;
  7746. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7747. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7748. {
  7749. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7750. Invoicing_get_response_Obj iObj = null;
  7751. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7752. if (iObj != null)
  7753. {
  7754. //entiy.state = 2;
  7755. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7756. entiy.fpdm += iObj.list[0].c_fpdm;
  7757. entiy.fphm += iObj.list[0].c_fphm;
  7758. if (iTag < billOrderList.Length)
  7759. {
  7760. entiy.fplsh += ",";
  7761. entiy.fpdm += ",";
  7762. entiy.fphm += ",";
  7763. }
  7764. entiy.Update();
  7765. fpUrl += iObj.list[0].c_url + ",";
  7766. }
  7767. //returnSuccess(res);
  7768. StringBuilder sql = new StringBuilder();
  7769. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7770. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7771. }
  7772. else
  7773. {
  7774. int eidx = res.IndexOf("c_resultmsg");
  7775. //int lidx = res.IndexOf("c_status");
  7776. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7777. //开票失败
  7778. entiy.state = 5;
  7779. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7780. entiy.Update();
  7781. returnErrorMsg("开票失败");
  7782. return;
  7783. }
  7784. }
  7785. var returnObj = new
  7786. {
  7787. data = fpUrl
  7788. };
  7789. string ro_json = JsonConvert.SerializeObject(returnObj);
  7790. returnSuccess(ro_json);
  7791. }
  7792. }
  7793. catch (Exception ex)
  7794. {
  7795. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7796. }
  7797. return;
  7798. }
  7799. }
  7800. public void save_erp_billimg()
  7801. {
  7802. if (UrlPostParmsCheck("id"))
  7803. {
  7804. string eid = GetPostString("id");
  7805. CeErpBill bill_entity = null;
  7806. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7807. if (bill_entity != null)
  7808. {
  7809. bill_entity.img = GetPostString("img");
  7810. bill_entity.executeTime = DateTime.Now;
  7811. bill_entity.state = 2;
  7812. bill_entity.Update();
  7813. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7814. returnSuccessMsg("保存成功");
  7815. }
  7816. return;
  7817. }
  7818. }
  7819. public void upd_erp_billreturnback()
  7820. {
  7821. if (UrlPostParmsCheck("id"))
  7822. {
  7823. int eid = GetPostInt("id");
  7824. CeErpBill bill_entity = null;
  7825. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7826. if (bill_entity != null)
  7827. {
  7828. bill_entity.state = 3;
  7829. bill_entity.returnReason = GetPostString("reason");
  7830. bill_entity.Update();
  7831. returnSuccessMsg("驳回成功!");
  7832. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7833. }
  7834. return;
  7835. }
  7836. }
  7837. public void cancel_erp_bill()
  7838. {
  7839. if (UrlPostParmsCheck("id"))
  7840. {
  7841. int eid = GetPostInt("id");
  7842. int detailValue = GetPostInt("detailvalue");
  7843. CeErpBill bill_entity = null;
  7844. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7845. string cres = "";
  7846. string gres = "";
  7847. if (bill_entity != null)
  7848. {
  7849. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7850. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  7851. {
  7852. int iTag = 0;
  7853. bill_entity.fplsh = "";
  7854. bill_entity.fpdm = "";
  7855. bill_entity.fphm = "";
  7856. foreach (string billOrderId in billOrderList)
  7857. {
  7858. iTag++;
  7859. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  7860. if (gres.IndexOf("success") != -1)
  7861. {
  7862. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  7863. Invoicing_get_response_Obj iObj = null;
  7864. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  7865. if (iObj != null)
  7866. {
  7867. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  7868. bill_entity.fpdm += iObj.list[0].c_fpdm;
  7869. bill_entity.fphm += iObj.list[0].c_fphm;
  7870. if (iTag < billOrderList.Length)
  7871. {
  7872. bill_entity.fplsh += ",";
  7873. bill_entity.fpdm += ",";
  7874. bill_entity.fphm += ",";
  7875. }
  7876. bill_entity.Update();
  7877. }
  7878. }
  7879. else
  7880. {
  7881. returnErrorMsg(gres);
  7882. return;
  7883. }
  7884. }
  7885. }
  7886. if (bill_entity.sendType == "纸质发票")
  7887. {
  7888. //作废
  7889. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  7890. //if (DateTime.Now.Month == extime.Month)
  7891. //{
  7892. //cres = taobaoHelper.cancel_invoicing(eid);
  7893. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  7894. //{
  7895. bill_entity.state = 4;//已作废
  7896. bill_entity.Update();
  7897. returnSuccessMsg("发票已作废");
  7898. return;
  7899. //}
  7900. //else
  7901. //{
  7902. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  7903. // bill_entity.Update();
  7904. // returnErrorMsg(cres);
  7905. // return;
  7906. //}
  7907. //}
  7908. //else
  7909. //{
  7910. // returnErrorMsg("纸质发票只能作废本月的发票");
  7911. // return;
  7912. //}
  7913. }
  7914. //红冲
  7915. int redTag = 0;
  7916. string[] fpdmList = bill_entity.fpdm.Split(',');
  7917. string[] fphmList = bill_entity.fphm.Split(',');
  7918. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  7919. {
  7920. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  7921. return;
  7922. }
  7923. foreach (string billOrderId in billOrderList)
  7924. {
  7925. redTag++;
  7926. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  7927. cres += onecres;
  7928. cres += ",";
  7929. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  7930. {
  7931. bill_entity.state = 4;//已作废
  7932. //bill_entity.Update();
  7933. //returnSuccessMsg("发票已红冲");
  7934. }
  7935. else if (onecres.IndexOf("重复冲红") != -1)
  7936. {
  7937. bill_entity.state = 4;//已作废
  7938. //bill_entity.Update();
  7939. //returnSuccessMsg("发票已红冲");
  7940. }
  7941. else
  7942. {
  7943. string errmsg = commonHelper.KeepChinese(onecres);
  7944. bill_entity.failerror += redTag + "&" + errmsg + "|";
  7945. }
  7946. }
  7947. bill_entity.Update();
  7948. if (cres.IndexOf("失败") != -1)
  7949. returnErrorMsg("红冲失败");
  7950. else
  7951. returnSuccessMsg("发票已红冲");
  7952. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  7953. return;
  7954. }
  7955. return;
  7956. }
  7957. }
  7958. public void del_erp_billorder()
  7959. {
  7960. if (UrlPostParmsCheck("id"))
  7961. {
  7962. string eid = GetPostString("id");
  7963. CeErpBill.Del(eid);
  7964. CeErpBill bill = CeErpBill.Get(eid);
  7965. if (bill != null)
  7966. {
  7967. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  7968. }
  7969. returnSuccessMsg("删除成功");
  7970. }
  7971. }
  7972. public void finish_erp_bill()
  7973. {
  7974. if (UrlPostParmsCheck("ids"))
  7975. {
  7976. string eids = GetPostString("ids");
  7977. string[] list = eids.Split(',');
  7978. foreach (string eid in list)
  7979. {
  7980. CeErpBill bill = CeErpBill.Get(eid);
  7981. if (bill != null)
  7982. {
  7983. bill.state = 2;
  7984. bill.Update();
  7985. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  7986. }
  7987. }
  7988. returnSuccessMsg("操作成功");
  7989. }
  7990. }
  7991. public void get_erp_returncash()
  7992. {
  7993. DataStruct dStruct = GetPostStruct();
  7994. List<string> lw = new List<string>();
  7995. string tid = GetPostString("tid");
  7996. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7997. string shopname = GetPostString("shopname");
  7998. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7999. string buyernick = GetPostString("buyer_nick");
  8000. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8001. string customer = GetPostString("customer");
  8002. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8003. string returndate1 = GetPostString("returndate1");
  8004. string returndate2 = GetPostString("returndate2");
  8005. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8006. if (dw.Length > 0) lw.Add(dw);
  8007. string finishDate1 = GetPostString("finishdate1");
  8008. string finishDate2 = GetPostString("finishdate2");
  8009. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8010. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8011. string returntype = GetPostString("returntype");
  8012. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8013. string returnvstate = GetPostString("returnvstate");
  8014. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8015. dStruct.Order = "created desc";
  8016. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8017. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8018. writeGridDataTableJson(dStruct.TotalCount, dt);
  8019. }
  8020. public void get_erp_staygoods()
  8021. {
  8022. DataStruct dStruct = GetPostStruct();
  8023. List<string> lw = new List<string>();
  8024. string tid = GetPostString("tid");
  8025. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8026. string shopname = GetPostString("shopname");
  8027. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8028. string wangwang = GetPostString("wangwang");
  8029. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8030. string customer = GetPostString("customer");
  8031. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8032. string returndate1 = GetPostString("returndate1");
  8033. string returndate2 = GetPostString("returndate2");
  8034. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8035. if (dw.Length > 0) lw.Add(dw);
  8036. string finishDate1 = GetPostString("finishdate1");
  8037. string finishDate2 = GetPostString("finishdate2");
  8038. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8039. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8040. string returnvstate = GetPostString("returnvstate");
  8041. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8042. string persuadetype = GetPostString("persuadetype");
  8043. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8044. string customerOrg = GetPostString("customerOrg");
  8045. if (customerOrg.Length > 0)
  8046. {
  8047. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8048. }
  8049. dStruct.Order = "creata_time desc";
  8050. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8051. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8052. writeGridDataTableJson(dStruct.TotalCount, dt);
  8053. }
  8054. public void upd_erp_staygoods()
  8055. {
  8056. if (UrlPostParmsCheck("id"))
  8057. {
  8058. int eid = GetPostInt("id");
  8059. CeErpStayGoods entity = null;
  8060. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8061. if (entity != null)
  8062. {
  8063. entity.audit_type = 1;
  8064. entity.audit_time = DateTime.Now;
  8065. entity.audit_u_id = CurrentUser.UserID;
  8066. entity.audit_u_name = CurrentUser.UserName;
  8067. entity.Update();
  8068. returnSuccessMsg("审核成功!");
  8069. return;
  8070. }
  8071. returnErrorMsg("找不到订单记录");
  8072. }
  8073. }
  8074. public void upd_erp_stayGoodsback()
  8075. {
  8076. if (UrlPostParmsCheck("id"))
  8077. {
  8078. int eid = GetPostInt("id");
  8079. CeErpStayGoods entity = null;
  8080. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8081. if (entity != null)
  8082. {
  8083. entity.audit_text = GetPostString("reason");
  8084. entity.audit_type = 2;
  8085. entity.audit_time = DateTime.Now;
  8086. entity.audit_u_id = CurrentUser.UserID;
  8087. entity.audit_u_name = CurrentUser.UserName;
  8088. entity.Update();
  8089. returnSuccessMsg("退回成功!");
  8090. return;
  8091. }
  8092. returnErrorMsg("找不到订单记录");
  8093. }
  8094. }
  8095. public void upd_erp_returncashverify()
  8096. {
  8097. if (UrlPostParmsCheck("ID"))
  8098. {
  8099. int eid = GetPostInt("ID");
  8100. CeErpReturnCash entity = null;
  8101. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8102. if (entity != null)
  8103. {
  8104. entity.cashstate = 1;
  8105. entity.verifytime = DateTime.Now;
  8106. entity.verifyuserid = CurrentUser.UserID;
  8107. entity.Update();
  8108. returnSuccessMsg("审核成功!");
  8109. return;
  8110. }
  8111. returnErrorMsg("找不到订单记录");
  8112. }
  8113. }
  8114. public void upd_all_erp_returncashverify()
  8115. {
  8116. if (UrlPostParmsCheck("ID"))
  8117. {
  8118. String[] list = GetPostString("ID").Split(',');
  8119. CeErpReturnCash entity = null;
  8120. for (int i = 0; i < list.Length; i++)
  8121. {
  8122. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8123. if (entity != null)
  8124. {
  8125. if (entity.cashstate == 1)
  8126. {
  8127. returnErrorMsg("已审核过的订单不需要在审核!");
  8128. return;
  8129. }
  8130. entity.cashstate = 1;
  8131. entity.verifytime = DateTime.Now;
  8132. entity.verifyuserid = CurrentUser.UserID;
  8133. entity.Update();
  8134. }
  8135. }
  8136. returnSuccessMsg("审核成功!");
  8137. return;
  8138. }
  8139. }
  8140. public void upd_erp_returncashback()
  8141. {
  8142. if (UrlPostParmsCheck("ID"))
  8143. {
  8144. int eid = GetPostInt("ID");
  8145. CeErpReturnCash entity = null;
  8146. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8147. if (entity != null)
  8148. {
  8149. entity.backreason = GetPostString("reason");
  8150. entity.cashstate = 2;
  8151. entity.verifytime = DateTime.Now;
  8152. entity.verifyuserid = CurrentUser.UserID;
  8153. entity.Update();
  8154. returnSuccessMsg("退回成功!");
  8155. return;
  8156. }
  8157. returnErrorMsg("找不到订单记录");
  8158. }
  8159. }
  8160. public void upd_erp_returnprice()
  8161. {
  8162. if (UrlPostParmsCheck("ID"))
  8163. {
  8164. int eid = GetPostInt("ID");
  8165. CeErpReturnCash entity = null;
  8166. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8167. if (entity != null)
  8168. {
  8169. if (entity.cashstate == 1)
  8170. {
  8171. returnErrorMsg("审核通过了不能改");
  8172. return;
  8173. }
  8174. entity.returnprice = GetPostDouble("returnprice");
  8175. entity.Update();
  8176. returnSuccessMsg("修改成功!");
  8177. return;
  8178. }
  8179. returnErrorMsg("找不到订单记录");
  8180. }
  8181. }
  8182. public void del_erp_returncash()
  8183. {
  8184. if (UrlPostParmsCheck("ID"))
  8185. {
  8186. int eid = GetPostInt("ID");
  8187. CeErpReturnCash.Del(eid);
  8188. returnSuccessMsg("操作成功");
  8189. return;
  8190. }
  8191. }
  8192. public void test_for_do_sql()
  8193. {
  8194. string sql = GetPostString("sqlstr");
  8195. if (sql.Length > 0)
  8196. {
  8197. try
  8198. {
  8199. DbHelper.DbConn.ExecuteNonQuery(sql);
  8200. var res_obj = new
  8201. {
  8202. data = "成功",
  8203. };
  8204. string ro_json = JsonConvert.SerializeObject(res_obj);
  8205. returnSuccess(ro_json);
  8206. }
  8207. catch (Exception ex)
  8208. {
  8209. var res_obj = new
  8210. {
  8211. data = ex.Message,
  8212. };
  8213. string ro_json = JsonConvert.SerializeObject(res_obj);
  8214. returnSuccess(ro_json);
  8215. }
  8216. }
  8217. }
  8218. public void get_user_info()
  8219. {
  8220. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8221. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8222. }
  8223. public void get_total_data()
  8224. {
  8225. int userId = CurrentUser.UserID;
  8226. string sql = "";
  8227. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8228. {
  8229. 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);
  8230. }
  8231. else
  8232. {
  8233. 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 " +
  8234. "(select ID from CE_ErpUser where ID = {0}) d " +
  8235. "left join " +
  8236. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8237. ") a on d.ID = a.id left join " +
  8238. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8239. ") b on a.id = b.id1 left join" +
  8240. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8241. ") c on a.id = c.id2;", userId);
  8242. }
  8243. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8244. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8245. }
  8246. public void get_date_area_total_data2()
  8247. {
  8248. int userId = CurrentUser.UserID;
  8249. string date_type = GetPostString("timetype");
  8250. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8251. string sql = "";
  8252. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8253. {
  8254. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8255. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8256. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8257. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8258. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8259. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8260. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8261. ") a on e.ID = a.id left join " +
  8262. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8263. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8264. ") b on a.id = b.id1 " +
  8265. "left join " +
  8266. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8267. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8268. ") c on a.id = c.id2 " +
  8269. "left join " +
  8270. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8271. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8272. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8273. }
  8274. else
  8275. {
  8276. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8277. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8278. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8279. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8280. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8281. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8282. ") a on e.ID = a.id left join " +
  8283. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8284. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8285. ") c on a.id = c.id2 " +
  8286. "left join " +
  8287. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8288. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8289. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8290. }
  8291. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8292. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8293. }
  8294. public void get_date_area_total_data()
  8295. {
  8296. int userId = CurrentUser.UserID;
  8297. string date_type = GetPostString("timetype");
  8298. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8299. string date1 = searchDT[0].ToString();
  8300. string date2 = searchDT[1].ToString();
  8301. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8302. {
  8303. SqlParameter[] sqlParameter ={
  8304. new SqlParameter("@userId", SqlDbType.Int,4),
  8305. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8306. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8307. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8308. };
  8309. sqlParameter[0].Value = userId;
  8310. sqlParameter[1].Value = date1;
  8311. sqlParameter[2].Value = date2;
  8312. sqlParameter[3].Direction = ParameterDirection.Output;
  8313. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8314. string res = sqlParameter[3].Value.ToString();
  8315. var res_obj = new
  8316. {
  8317. data = res
  8318. };
  8319. string ro_json = JsonConvert.SerializeObject(res_obj);
  8320. returnSuccess(ro_json);
  8321. }
  8322. else
  8323. {
  8324. SqlParameter[] sqlParameter ={
  8325. new SqlParameter("@userId", SqlDbType.Int,4),
  8326. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8327. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8328. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8329. };
  8330. sqlParameter[0].Value = userId;
  8331. sqlParameter[1].Value = date1;
  8332. sqlParameter[2].Value = date2;
  8333. sqlParameter[3].Direction = ParameterDirection.Output;
  8334. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8335. string res = sqlParameter[3].Value.ToString();
  8336. var res_obj = new
  8337. {
  8338. data = res
  8339. };
  8340. string ro_json = JsonConvert.SerializeObject(res_obj);
  8341. returnSuccess(ro_json);
  8342. }
  8343. //writeGridDataViewJson(dt.Rows.Count, dv);
  8344. }
  8345. public void get_order_list()
  8346. {
  8347. string strFields = GetPostString("paraFields");
  8348. string strOrder = GetPostString("paraOrder");
  8349. string strWhere = GetPostString("paraWhere");
  8350. string strPageSize = GetPostString("paraPageSize");
  8351. DataStruct dStruct = GetPostStruct();
  8352. dStruct.PageSize = int.Parse(strPageSize);
  8353. dStruct.Fileds = strFields;
  8354. dStruct.Order = strOrder;
  8355. dStruct.MainWhere = strWhere;
  8356. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8357. writeGridDataTableJson(dStruct.TotalCount, dt);
  8358. }
  8359. ////获取待开始订单列表
  8360. //public void get_wait_design_order_list()
  8361. //{
  8362. // string date_type = GetPostString("date_type");
  8363. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8364. // DataStruct dStruct = GetPostStruct();
  8365. // dStruct.PageSize = 1000;
  8366. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8367. // List<string> lw = new List<string>();
  8368. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8369. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8370. // dStruct.Order = "WaitDesignTime asc";
  8371. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8372. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8373. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8374. //}
  8375. //获取完成单量排名
  8376. public void get_finish_order_count_ranking()
  8377. {
  8378. /* string date_type = GetPostString("date_type");
  8379. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8380. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8381. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8382. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8383. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8384. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8385. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8386. writeGridDataTableJson(0, new DataTable());
  8387. }
  8388. public void get_finish_order_amount_ranking()
  8389. {
  8390. /*string date_type = GetPostString("date_type");
  8391. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8392. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8393. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8394. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8395. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8396. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8397. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8398. writeGridDataTableJson(0, new DataTable());
  8399. }
  8400. public void get_finish_refund_count_ranking()
  8401. {
  8402. string date_type = GetPostString("date_type");
  8403. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8404. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8405. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8406. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8407. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8408. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8409. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8410. writeGridDataTableJson(dt.Rows.Count, dt);
  8411. }
  8412. public void get_finish_refund_amount_ranking()
  8413. {
  8414. string date_type = GetPostString("date_type");
  8415. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8416. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8417. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8418. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8419. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8420. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8421. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8422. writeGridDataTableJson(dt.Rows.Count, dt);
  8423. }
  8424. public void set_erp_finishorder_director()
  8425. {
  8426. if (UrlPostParmsCheck("ctid"))
  8427. {
  8428. string eid = GetPostString("ctid");
  8429. CeErpTradeCell entity = null;
  8430. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8431. if (entity != null)
  8432. {
  8433. entity.OrderState = 8;
  8434. entity.Update();
  8435. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8436. returnSuccessMsg("操作成功!");
  8437. return;
  8438. }
  8439. returnErrorMsg("找不到记录");
  8440. }
  8441. }
  8442. public void get_erp_placeregistlist()
  8443. {
  8444. DataStruct dStruct = GetPostStruct();
  8445. List<string> lw = new List<string>();
  8446. string outsid = GetPostString("outsid");
  8447. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8448. string memo = GetPostString("memo");
  8449. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8450. string filename = GetPostString("filename");
  8451. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8452. string islate = GetPostString("islate");
  8453. if (islate.Length > 0)
  8454. {
  8455. if (islate == "1")
  8456. lw.Add(string.Format("OutLate>0"));
  8457. else
  8458. lw.Add(string.Format("OutLate=0"));
  8459. }
  8460. string placedate1 = GetPostString("placedate1");
  8461. string placedate2 = GetPostString("placedate2");
  8462. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8463. if (dw.Length > 0) lw.Add(dw);
  8464. string deliveryDate1 = GetPostString("deliverydate1");
  8465. string deliveryDate2 = GetPostString("deliverydate2");
  8466. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8467. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8468. dStruct.Order = "ID desc";
  8469. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8470. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8471. writeGridDataTableJson(dStruct.TotalCount, dt);
  8472. }
  8473. public void ins_erp_placeregist()
  8474. {
  8475. if (UrlPostParmsCheck("id"))
  8476. {
  8477. string eid = GetPostString("id");
  8478. CeErpPlaceRegister entity = null;
  8479. if (eid == "0")//新增
  8480. {
  8481. entity = new CeErpPlaceRegister();
  8482. string xdTime = GetPostString("placeTime");
  8483. if (xdTime.Length > 0)
  8484. {
  8485. entity.PlactTime = Convert.ToDateTime(xdTime);
  8486. }
  8487. string fhTime = GetPostString("deliveryTime");
  8488. if (fhTime.Length > 0)
  8489. {
  8490. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8491. }
  8492. string preTime = GetPostString("preOutTime");
  8493. if (preTime.Length > 0)
  8494. {
  8495. entity.PreOutTime = Convert.ToDateTime(preTime);
  8496. }
  8497. entity.DeliveryCount = GetPostInt("deliveryCount");
  8498. entity.ReceiveCount = GetPostInt("receiveCount");
  8499. entity.OutSid = GetPostString("outSid");
  8500. entity.FileName = GetPostString("fileName");
  8501. entity.Memo = GetPostString("memo");
  8502. entity.AddUserId = CurrentUser.UserID;
  8503. entity.CreateTime = DateTime.Now;
  8504. entity.Img = GetPostString("img");
  8505. entity.Supplier = GetPostInt("supplier");
  8506. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8507. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8508. {
  8509. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8510. DateTime dt2 = (DateTime)entity.PreOutTime;
  8511. TimeSpan span = dt1.Subtract(dt2);
  8512. if (span.Days > 0)
  8513. {
  8514. entity.OutLate = span.Days;
  8515. }
  8516. }
  8517. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8518. entity.Create();
  8519. returnSuccessMsg("添加成功!");
  8520. return;
  8521. }
  8522. else //修改
  8523. {
  8524. entity = CeErpPlaceRegister.Get(eid);
  8525. if (entity != null)
  8526. {
  8527. string xdTime = GetPostString("placeTime");
  8528. if (xdTime.Length > 0)
  8529. {
  8530. entity.PlactTime = Convert.ToDateTime(xdTime);
  8531. }
  8532. string fhTime = GetPostString("deliveryTime");
  8533. if (fhTime.Length > 0)
  8534. {
  8535. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8536. }
  8537. string preTime = GetPostString("preOutTime");
  8538. if (preTime.Length > 0)
  8539. {
  8540. entity.PreOutTime = Convert.ToDateTime(preTime);
  8541. }
  8542. entity.DeliveryCount = GetPostInt("deliveryCount");
  8543. entity.ReceiveCount = GetPostInt("receiveCount");
  8544. if (entity.DeliveryCount == entity.ReceiveCount)
  8545. {
  8546. entity.CurState = "已完成";
  8547. }
  8548. else
  8549. {
  8550. entity.CurState = "未完成";
  8551. }
  8552. entity.OutSid = GetPostString("outSid");
  8553. entity.FileName = GetPostString("fileName");
  8554. entity.Memo = GetPostString("memo");
  8555. entity.Img = GetPostString("img");
  8556. entity.Supplier = GetPostInt("supplier");
  8557. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8558. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8559. {
  8560. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8561. DateTime dt2 = (DateTime)entity.PreOutTime;
  8562. TimeSpan span = dt1.Subtract(dt2);
  8563. if (span.Days > 0)
  8564. {
  8565. entity.OutLate = span.Days;
  8566. }
  8567. }
  8568. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8569. entity.Update();
  8570. returnSuccessMsg("修改成功");
  8571. return;
  8572. }
  8573. returnErrorMsg("找不到对应的记录");
  8574. return;
  8575. }
  8576. }
  8577. returnErrorMsg("缺少必要参数");
  8578. }
  8579. public void del_erp_placeregist()
  8580. {
  8581. string eid = GetPostString("id");
  8582. CeErpPlaceRegister.Del(eid);
  8583. returnSuccessMsg("删除成功!");
  8584. return;
  8585. }
  8586. public void ins_erp_placeregistbyorder()
  8587. {
  8588. string ctid = GetPostString("ctid");
  8589. if (ctid.Length > 0)
  8590. {
  8591. StringBuilder sql = new StringBuilder();
  8592. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8593. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8594. if (dt.Rows.Count > 0)
  8595. {
  8596. foreach (DataRow dr in dt.Rows)
  8597. {
  8598. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8599. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8600. entity.AddUserId = CurrentUser.UserID;
  8601. entity.tid = dr["tid"].ToString();
  8602. entity.Did = Convert.ToString(dr["ctid"]);
  8603. entity.splitTag = dr["SplitTag"].ToString();
  8604. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8605. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8606. if (pre_ctid.Length > 0)
  8607. {
  8608. sellmemo = sellmemo.Replace(pre_ctid, "");
  8609. }
  8610. sellmemo = sellmemo.Replace("[", "");
  8611. sellmemo = sellmemo.Replace("]", "");
  8612. entity.FileName = sellmemo;
  8613. string count = dr["ProductCount"].ToString();
  8614. int usecount = commonHelper.getIntCountFromString(count);
  8615. entity.DeliveryCount = usecount;
  8616. entity.CurState = "未完成";
  8617. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8618. {
  8619. entity.Supplier = 24;//dl手提袋定制
  8620. }
  8621. else
  8622. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8623. entity.CreateTime = DateTime.Now;
  8624. entity.Create();
  8625. }
  8626. returnSuccessMsg("操作成功");
  8627. return;
  8628. }
  8629. returnErrorMsg("没有找到对应订单");
  8630. return;
  8631. }
  8632. returnErrorMsg("缺少订单编号");
  8633. return;
  8634. }
  8635. public void get_erp_persuadelist()
  8636. {
  8637. DataStruct dStruct = GetPostStruct();
  8638. List<string> lw = new List<string>();
  8639. string ctid = GetPostString("ctid");
  8640. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8641. string shopname = GetPostString("shopname");
  8642. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8643. string buyernick = GetPostString("buyer_nick");
  8644. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8645. string customer = GetPostString("customer");
  8646. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8647. string returndate1 = GetPostString("returndate1");
  8648. string returndate2 = GetPostString("returndate2");
  8649. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8650. if (dw.Length > 0) lw.Add(dw);
  8651. string finishDate1 = GetPostString("finishdate1");
  8652. string finishDate2 = GetPostString("finishdate2");
  8653. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8654. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8655. string persuadetype = GetPostString("persuadetype");
  8656. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8657. string returnvstate = GetPostString("returnvstate");
  8658. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8659. dStruct.Order = "created desc";
  8660. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8661. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8662. writeGridDataTableJson(dStruct.TotalCount, dt);
  8663. }
  8664. public void upd_erp_returnpersuadeback()
  8665. {
  8666. if (UrlPostParmsCheck("ID"))
  8667. {
  8668. int eid = GetPostInt("ID");
  8669. CeErpPersuade entity = null;
  8670. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8671. if (entity != null)
  8672. {
  8673. entity.backreason = GetPostString("reason");
  8674. entity.pstate = 2;
  8675. entity.verifytime = DateTime.Now;
  8676. entity.verifyuserid = CurrentUser.UserID;
  8677. entity.Update();
  8678. returnSuccessMsg("退回成功!");
  8679. return;
  8680. }
  8681. returnErrorMsg("找不到订单记录");
  8682. }
  8683. }
  8684. public void upd_erp_returnpersuadeverify()
  8685. {
  8686. if (UrlPostParmsCheck("ID"))
  8687. {
  8688. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8689. {
  8690. returnErrorMsg("暂无权限审核");
  8691. return;
  8692. }
  8693. int eid = GetPostInt("ID");
  8694. CeErpPersuade entity = null;
  8695. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8696. if (entity != null)
  8697. {
  8698. entity.pstate = 1;
  8699. entity.verifytime = DateTime.Now;
  8700. entity.verifyuserid = CurrentUser.UserID;
  8701. entity.Update();
  8702. returnSuccessMsg("审核成功!");
  8703. return;
  8704. }
  8705. returnErrorMsg("找不到订单记录");
  8706. }
  8707. }
  8708. public void del_erp_persuade()
  8709. {
  8710. if (UrlPostParmsCheck("ID"))
  8711. {
  8712. int eid = GetPostInt("ID");
  8713. CeErpPersuade.Del(eid);
  8714. returnSuccessMsg("操作成功");
  8715. return;
  8716. }
  8717. }
  8718. public void get_erp_oldcustoupload()
  8719. {
  8720. DataStruct dStruct = GetPostStruct();
  8721. List<string> lw = new List<string>();
  8722. string buyernick = GetPostString("buyer_nick");
  8723. if (buyernick.Length > 0)
  8724. {
  8725. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8726. }
  8727. else
  8728. return;
  8729. dStruct.Order = "pay_time desc";
  8730. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8731. DataTable dt = null;
  8732. dt = WebCache.GetData("view_erptradecell", dStruct);
  8733. writeGridDataTableJson(dStruct.TotalCount, dt);
  8734. }
  8735. public void get_erp_checkorderlist()
  8736. {
  8737. DataStruct dStruct = GetPostStruct();
  8738. List<string> lw = new List<string>();
  8739. string tid = GetPostString("ctid");
  8740. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8741. string shopname = GetPostString("shopname");
  8742. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8743. string buyernick = GetPostString("buyer_nick");
  8744. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8745. string customer = GetPostString("customer");
  8746. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8747. string design = GetPostString("design");
  8748. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8749. string orderState = GetPostString("orderState");
  8750. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8751. string address = GetPostString("address");
  8752. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8753. string sellermemo = GetPostString("seller_memo");
  8754. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8755. string supplier = GetPostString("supplier");
  8756. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8757. {
  8758. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8759. }
  8760. else
  8761. {
  8762. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8763. }
  8764. string date1 = GetPostString("date1");
  8765. string date2 = GetPostString("date2");
  8766. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8767. if (dw.Length > 0) lw.Add(dw);
  8768. string placedate1 = GetPostString("placedate1");
  8769. string placedate2 = GetPostString("placedate2");
  8770. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8771. if (fdw.Length > 0) lw.Add(fdw);
  8772. string price1 = GetPostString("price1");
  8773. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8774. string price2 = GetPostString("price2");
  8775. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8776. string checkst = GetPostString("checkstate");
  8777. if (checkst.Length > 0 && "10".Equals(checkst))
  8778. {
  8779. lw.Add(string.Format("CheckOut>0"));
  8780. }
  8781. else
  8782. {
  8783. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8784. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8785. }
  8786. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8787. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8788. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8789. writeGridDataTableJson(dStruct.TotalCount, dt);
  8790. }
  8791. public void ins_erp_startCheck()
  8792. {
  8793. if (UrlPostParmsCheck("ctid"))
  8794. {
  8795. string eid = GetPostString("ctid");
  8796. CeErpTradeCell entity = null;
  8797. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8798. if (entity != null)
  8799. {
  8800. entity.MemoOpt = 4;
  8801. entity.Update();
  8802. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8803. CeErpSukuraData.createInfo(entity.ctid, 6);
  8804. returnSuccessMsg("操作成功!");
  8805. return;
  8806. }
  8807. returnErrorMsg("找不到记录");
  8808. }
  8809. }
  8810. public void upd_erp_sendXlw()
  8811. {
  8812. if (UrlPostParmsCheck("ctid"))
  8813. {
  8814. string eid = GetPostString("ctid");
  8815. CeErpTradeCell entity = null;
  8816. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8817. if (entity != null)
  8818. {
  8819. if (entity.IsSendGift == 1)
  8820. {
  8821. returnErrorMsg("请勿重复标记");
  8822. return;
  8823. }
  8824. entity.IsSendGift = 1;
  8825. entity.Update();
  8826. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8827. returnSuccessMsg("操作成功!");
  8828. return;
  8829. }
  8830. returnErrorMsg("找不到记录");
  8831. }
  8832. }
  8833. public void cancel_sendXlw()
  8834. {
  8835. if (UrlPostParmsCheck("ctid"))
  8836. {
  8837. string eid = GetPostString("ctid");
  8838. CeErpTradeCell entity = null;
  8839. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8840. if (entity != null)
  8841. {
  8842. if (entity.IsSendGift == 0)
  8843. {
  8844. returnErrorMsg("未标记小礼物");
  8845. return;
  8846. }
  8847. entity.IsSendGift = 0;
  8848. entity.Update();
  8849. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  8850. returnSuccessMsg("操作成功!");
  8851. return;
  8852. }
  8853. returnErrorMsg("找不到记录");
  8854. }
  8855. }
  8856. public void get_erp_designbill()
  8857. {
  8858. DataStruct dStruct = GetPostStruct();
  8859. List<string> lw = new List<string>();
  8860. int isMy = GetInt("my");
  8861. if (isMy == 1)
  8862. {
  8863. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  8864. }
  8865. string tid = GetPostString("tid");
  8866. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8867. string userName = GetPostString("design");
  8868. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  8869. string price1 = GetPostString("price1");
  8870. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  8871. string price2 = GetPostString("price2");
  8872. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  8873. string rePrice1 = GetPostString("rePrice1");
  8874. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  8875. string rePrice2 = GetPostString("rePrice2");
  8876. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  8877. string designerType = GetPostString("designerType");
  8878. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  8879. string orderState = GetPostString("orderState");
  8880. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  8881. string endTime1 = GetPostString("endTime1");
  8882. string endTime2 = GetPostString("endTime2");
  8883. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  8884. if (dw.Length > 0) lw.Add(dw);
  8885. string isDk = GetPostString("isDk");
  8886. if (isDk == "1")
  8887. {
  8888. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  8889. }
  8890. else if (isDk == "0")
  8891. {
  8892. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  8893. }
  8894. dStruct.Order = "oid, create_time desc";
  8895. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8896. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  8897. writeGridDataTableJson(dStruct.TotalCount, dt);
  8898. }
  8899. public void upd_erp_designerbill()
  8900. {
  8901. if (UrlPostParmsCheck("ID"))
  8902. {
  8903. string eid = GetPostString("ID");
  8904. CeErpDesignerBill entity = null;
  8905. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8906. if (entity != null)
  8907. {
  8908. if (GetPostDouble("designerpirce") > 0)
  8909. {
  8910. entity.realPrice = GetPostDouble("designerpirce");
  8911. entity.update_time = DateTime.Now;
  8912. entity.update_u_id = CurrentUser.UserID;
  8913. entity.update_u_name = CurrentUser.UserName;
  8914. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  8915. entity.Update();
  8916. returnSuccessMsg("操作成功!");
  8917. return;
  8918. }
  8919. else
  8920. {
  8921. entity.price = GetPostDouble("price");
  8922. entity.update_time = DateTime.Now;
  8923. entity.update_u_id = CurrentUser.UserID;
  8924. entity.update_u_name = CurrentUser.UserName;
  8925. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  8926. entity.Update();
  8927. returnSuccessMsg("操作成功!");
  8928. return;
  8929. }
  8930. }
  8931. returnErrorMsg("找不到记录");
  8932. }
  8933. }
  8934. public void audit_erp_designerbill()
  8935. {
  8936. if (UrlPostParmsCheck("ID"))
  8937. {
  8938. string eid = GetPostString("ID");
  8939. CeErpDesignerBill entity = null;
  8940. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8941. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  8942. if (entity != null)
  8943. {
  8944. entity.realPrice = GetPostDouble("designerpirce");
  8945. entity.update_time = DateTime.Now;
  8946. entity.update_u_id = CurrentUser.UserID;
  8947. entity.update_u_name = CurrentUser.UserName;
  8948. entity.isAudit = 1;
  8949. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8950. entity.Update();
  8951. if (orderEntity != null)
  8952. {
  8953. orderEntity.IsReadTag = 3;
  8954. orderEntity.Update();
  8955. }
  8956. returnSuccessMsg("操作成功!");
  8957. return;
  8958. }
  8959. returnErrorMsg("找不到记录");
  8960. }
  8961. }
  8962. public void all_audit_erp_designerbill()
  8963. {
  8964. if (UrlPostParmsCheck("idList"))
  8965. {
  8966. string[] list = GetPostString("idList").Split(',');
  8967. CeErpDesignerBill entity = null;
  8968. for (int i = 0; i < list.Length; i++)
  8969. {
  8970. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  8971. if (entity == null) return;
  8972. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  8973. if (orderEntity == null) return;
  8974. if (entity.realPrice == 0) entity.realPrice = entity.price;
  8975. entity.update_time = DateTime.Now;
  8976. entity.update_u_id = CurrentUser.UserID;
  8977. entity.update_u_name = CurrentUser.UserName;
  8978. entity.isAudit = 1;
  8979. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8980. entity.Update();
  8981. orderEntity.IsReadTag = 3;
  8982. orderEntity.Update();
  8983. }
  8984. returnSuccessMsg("操作成功!");
  8985. return;
  8986. }
  8987. }
  8988. public void get_erp_sameorders()
  8989. {
  8990. if (UrlPostParmsCheck("ctid"))
  8991. {
  8992. string eid = GetPostString("ctid");
  8993. CeErpTradeCell entity = null;
  8994. entity = CeErpTradeCell.GetByCtid(eid);
  8995. if (entity != null)
  8996. {
  8997. StringBuilder sql = new StringBuilder();
  8998. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  8999. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9000. var res = new
  9001. {
  9002. data = dt.Rows.Count
  9003. };
  9004. string ro_jsond = JsonConvert.SerializeObject(res);
  9005. returnSuccess(ro_jsond);
  9006. return;
  9007. }
  9008. returnErrorMsg("未找到订单");
  9009. return;
  9010. }
  9011. returnErrorMsg("缺少必要的参数");
  9012. }
  9013. public void get_erp_islasthavesameorder()
  9014. {
  9015. if (UrlPostParmsCheck("ctid"))
  9016. {
  9017. string eid = GetPostString("ctid");
  9018. string[] ctidList = eid.Split(',');
  9019. StringBuilder sql = new StringBuilder();
  9020. string tisCtid = "";
  9021. foreach (string ctid in ctidList)
  9022. {
  9023. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9024. if (entity != null)
  9025. {
  9026. sql = new StringBuilder();
  9027. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9028. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9029. if (dth.Rows.Count > 0)
  9030. {
  9031. tisCtid += entity.ctid;
  9032. tisCtid += ",";
  9033. }
  9034. }
  9035. }
  9036. if (tisCtid.Length > 0)
  9037. {
  9038. var res = new
  9039. {
  9040. data = tisCtid
  9041. };
  9042. string ro_jsond = JsonConvert.SerializeObject(res);
  9043. returnSuccess(ro_jsond);
  9044. }
  9045. else
  9046. {
  9047. var res = new
  9048. {
  9049. data = ""
  9050. };
  9051. string ro_jsond = JsonConvert.SerializeObject(res);
  9052. returnSuccess(ro_jsond);
  9053. }
  9054. return;
  9055. }
  9056. returnErrorMsg("缺少必要的参数");
  9057. }
  9058. public void file_client_down_url()
  9059. {
  9060. if (!UrlPostParmsCheck("userId"))
  9061. {
  9062. returnErrorMsg("缺少必要的参数");
  9063. }
  9064. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9065. }
  9066. public void checkout_form_data()
  9067. {
  9068. if (!UrlPostParmsCheck("tid"))
  9069. {
  9070. returnErrorMsg("缺少必要的参数");
  9071. }
  9072. string tid = GetPostString("tid");
  9073. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9074. if (ceErpOrderFormData != null)
  9075. {
  9076. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9077. returnSuccess(ro_jsond);
  9078. return;
  9079. }
  9080. returnErrorMsg("尚未有文件!");
  9081. }
  9082. public void back_supplier_audit()
  9083. {
  9084. int userId = CurrentUser.UserID;
  9085. StringBuilder sql = new StringBuilder();
  9086. 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);
  9087. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9088. if (dt.Rows.Count > 0)
  9089. {
  9090. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9091. }
  9092. else
  9093. {
  9094. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9095. }
  9096. }
  9097. public void back_supplier_query()
  9098. {
  9099. string eid = GetPostString("ctid");
  9100. if (eid != "")
  9101. {
  9102. StringBuilder sql = new StringBuilder();
  9103. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9104. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9105. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9106. }
  9107. else
  9108. {
  9109. returnErrorMsg("找不到订单记录");
  9110. return;
  9111. }
  9112. }
  9113. public void verified_to_order()
  9114. {
  9115. int userId = CurrentUser.UserID;
  9116. StringBuilder sql = new StringBuilder();
  9117. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9118. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9119. if (dt.Rows.Count > 0)
  9120. {
  9121. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9122. }
  9123. else
  9124. {
  9125. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9126. }
  9127. }
  9128. public void upd_supplier_audit()
  9129. {
  9130. if (UrlPostParmsCheck("ctid"))
  9131. {
  9132. string eid = GetPostString("ctid");
  9133. string reason = GetPostString("returnreason");
  9134. CeErpTradeCell entity = null;
  9135. CeWithdraw withdraw = null;
  9136. withdraw = CeWithdraw.GetByTid(eid);
  9137. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9138. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9139. {
  9140. if (withdraw != null)
  9141. {
  9142. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9143. {
  9144. returnSuccessMsg("您没有权限操作!");
  9145. return;
  9146. }
  9147. else
  9148. {
  9149. if (reason.Equals("1"))
  9150. {
  9151. if (entity.OrderState == -1)
  9152. {
  9153. if (entity.FinishPlaceTime == null)
  9154. {
  9155. entity.OrderState = 2;
  9156. }
  9157. else
  9158. {
  9159. entity.OrderState = 6;
  9160. }
  9161. }
  9162. entity.Update();
  9163. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9164. if (withdraw != null)
  9165. {
  9166. withdraw.status = int.Parse(reason);
  9167. withdraw.Update();
  9168. }
  9169. returnSuccessMsg("操作成功!");
  9170. return;
  9171. }
  9172. else
  9173. {
  9174. withdraw.status = int.Parse(reason);
  9175. withdraw.acknowledgingtime = DateTime.Now;
  9176. withdraw.Update();
  9177. returnSuccessMsg("查看详细请点击线下订单查询");
  9178. return;
  9179. }
  9180. }
  9181. }
  9182. // 第一个字符是 'N'
  9183. }
  9184. if (eid[0] != 'N')
  9185. {
  9186. }
  9187. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9188. {
  9189. entity.IsVerifyToSupplier = false;
  9190. entity.IsReturn = 1;
  9191. entity.ReturnTime = DateTime.Now;
  9192. entity.ReturnReason = reason;
  9193. if (entity.OrderState == 6)
  9194. {
  9195. entity.OrderState = 5;
  9196. }
  9197. entity.Update();
  9198. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9199. if (withdraw != null)
  9200. {
  9201. withdraw.status = int.Parse(reason);
  9202. withdraw.Update();
  9203. }
  9204. returnSuccessMsg("操作成功!");
  9205. return;
  9206. }
  9207. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9208. {
  9209. ;
  9210. if (withdraw != null)
  9211. {
  9212. withdraw.status = int.Parse(reason);
  9213. withdraw.acknowledgingtime = DateTime.Now;
  9214. withdraw.Update();
  9215. returnSuccessMsg("供应商取消撤回!");
  9216. return;
  9217. }
  9218. }
  9219. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9220. {
  9221. if (entity.OrderState == -1)
  9222. {
  9223. if (entity.FinishPlaceTime == null)
  9224. {
  9225. entity.OrderState = 2;
  9226. }
  9227. else
  9228. {
  9229. entity.OrderState = 3;
  9230. }
  9231. commonHelper.getCytPrice(entity);
  9232. }
  9233. entity.Update();
  9234. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9235. if (withdraw != null)
  9236. {
  9237. withdraw.status = int.Parse(reason);
  9238. withdraw.Update();
  9239. }
  9240. returnSuccessMsg("操作成功!");
  9241. return;
  9242. }
  9243. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9244. {
  9245. if (withdraw == null)
  9246. {
  9247. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9248. return;
  9249. }
  9250. }
  9251. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9252. {
  9253. if (withdraw != null)
  9254. {
  9255. withdraw.status = int.Parse(reason);
  9256. withdraw.acknowledgingtime = DateTime.Now;
  9257. withdraw.Update();
  9258. returnSuccessMsg("查看详细请点击线下订单查询");
  9259. return;
  9260. }
  9261. }
  9262. return;
  9263. }
  9264. }
  9265. //校验报价
  9266. public void refund_order_tip()
  9267. {
  9268. int userid = CurrentUser.UserID;
  9269. int sectionId = CurrentUser.UserPost.OrgID;
  9270. StringBuilder sql = new StringBuilder();
  9271. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9272. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9273. List<string> ids = new List<string>();
  9274. if (dth.Rows.Count > 0)
  9275. {
  9276. foreach (DataRow dr in dth.Rows)
  9277. {
  9278. ids.Add(dr["ID"].ToString());
  9279. }
  9280. try
  9281. {
  9282. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9283. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9284. }
  9285. catch (Exception ex)
  9286. {
  9287. }
  9288. }
  9289. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9290. }
  9291. public void refund_order_Design()
  9292. {
  9293. int userid = CurrentUser.UserID;
  9294. int sectionId = CurrentUser.UserPost.OrgID;
  9295. StringBuilder sql = new StringBuilder();
  9296. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9297. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9298. List<string> ids = new List<string>();
  9299. if (dth.Rows.Count > 0)
  9300. {
  9301. foreach (DataRow dr in dth.Rows)
  9302. {
  9303. ids.Add(dr["ID"].ToString());
  9304. }
  9305. try
  9306. {
  9307. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9308. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9309. }
  9310. catch (Exception ex)
  9311. {
  9312. }
  9313. }
  9314. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9315. }
  9316. public void change_order_info()
  9317. {
  9318. int userid = CurrentUser.UserID;
  9319. StringBuilder sql = new StringBuilder();
  9320. 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);
  9321. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9322. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9323. }
  9324. public void change_win_mome()
  9325. {
  9326. if (UrlPostParmsCheck("id,ctid"))
  9327. {
  9328. string id = GetPostString("id");
  9329. string ctid = GetPostString("ctid");
  9330. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9331. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9332. if (ce == null || ceErpMessageTip == null)
  9333. {
  9334. returnSuccessMsg("未找到对应的订单!");
  9335. return;
  9336. }
  9337. int type = GetPostInt("type");
  9338. string content = GetPostString("content");
  9339. if (type == 0)
  9340. {
  9341. content = content.Replace("(", "(");
  9342. content = content.Replace(")", ")");
  9343. string check = MidStrEx(content, "(", ")").Trim();
  9344. if (string.IsNullOrEmpty(check))
  9345. {
  9346. returnSuccessMsg("文件名格式不正确");
  9347. return;
  9348. }
  9349. }
  9350. ce.seller_memo = content;
  9351. ce.Update();
  9352. ceErpMessageTip.isVisit = true;
  9353. ceErpMessageTip.Update();
  9354. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9355. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9356. ApiVo apiVo = new ApiVo();
  9357. apiVo.orderNumber = ce.ctid;
  9358. apiVo.actionName = "demandDesign";
  9359. apiVo.orderRemarks = content;
  9360. apiVo.demandExamine = type + 1;
  9361. designHelper.API_WorkCore(apiVo);//demandDesign
  9362. returnSuccessMsg("修改成功!");
  9363. }
  9364. }
  9365. public static string MidStrEx(string sourse, string startstr, string endstr)
  9366. {
  9367. string result = string.Empty;
  9368. int startindex, endindex;
  9369. try
  9370. {
  9371. startindex = sourse.IndexOf(startstr);
  9372. if (startindex == -1)
  9373. return result;
  9374. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9375. endindex = tmpstr.IndexOf(endstr);
  9376. if (endindex == -1)
  9377. return result;
  9378. result = tmpstr.Remove(endindex);
  9379. }
  9380. catch (Exception ex)
  9381. {
  9382. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9383. }
  9384. return result;
  9385. }
  9386. public void refund_order_list()
  9387. {
  9388. int userid = CurrentUser.UserID;
  9389. int sectionId = CurrentUser.UserPost.OrgID;
  9390. StringBuilder sql = new StringBuilder();
  9391. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9392. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9393. DataStruct dStruct = GetPostStruct();
  9394. DataTable dt = null;
  9395. List<string> ids = new List<string>();
  9396. List<string> tids = new List<string>();
  9397. if (dth.Rows.Count > 0)
  9398. {
  9399. foreach (DataRow dr in dth.Rows)
  9400. {
  9401. tids.Add("'" + dr["tid"].ToString() + "'");
  9402. ids.Add(dr["id"].ToString());
  9403. }
  9404. try
  9405. {
  9406. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9407. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9408. List<string> lw = new List<string>();
  9409. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9410. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9411. dt = WebCache.GetData("view_orderlist", dStruct);
  9412. }
  9413. catch (Exception ex)
  9414. {
  9415. }
  9416. }
  9417. writeGridDataTableJson(dStruct.TotalCount, dt);
  9418. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9419. }
  9420. //新增
  9421. public void order_batch_downloads()
  9422. {
  9423. string ceid = GetPostString("tid");
  9424. String[] tid = ceid.Split(',');
  9425. order_batch_caiyingtong(tid);
  9426. /* (string success, string errors) = UploadFiles(tid);
  9427. returnSuccessMsg(success + errors);*/
  9428. return;
  9429. }
  9430. //报价接口
  9431. public void Get_To_Quote()
  9432. {
  9433. string ceid = GetPostString("ctid");
  9434. if (ceid != null)
  9435. {
  9436. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9437. if (entity != null)
  9438. {
  9439. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9440. {
  9441. return;
  9442. }
  9443. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9444. double price = 0;
  9445. if (cp == null)
  9446. {
  9447. JObject jsonObject12 = new JObject
  9448. {
  9449. { "UserId", "77886" },
  9450. { "Pwd", "lt666888" },
  9451. { "Filename", entity.seller_memo }
  9452. };
  9453. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9454. JObject jsonObjects1 = JObject.Parse(response1);
  9455. string ms1g = (string)jsonObjects1["msg"];
  9456. if (ms1g == "报价成功")
  9457. {
  9458. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9459. string data = (string)jsonObject1["price"];
  9460. 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 + "');";
  9461. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9462. returnSuccessMsg("获取报价成功:" + data);
  9463. price = Convert.ToDouble(data);
  9464. }
  9465. else
  9466. {
  9467. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9468. return;
  9469. }
  9470. }
  9471. String[] beizhu = entity.seller_memo.Split('-');
  9472. String chanp = "";
  9473. if (beizhu.Length > 0)
  9474. {
  9475. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9476. }
  9477. else
  9478. {
  9479. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9480. }
  9481. JObject jsonObject = new JObject
  9482. {
  9483. { "UserId", "77886" },
  9484. { "Pwd", "lt666888" },
  9485. { "Filename", chanp }
  9486. };
  9487. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9488. JObject jsonObjects = JObject.Parse(response);
  9489. string msg = (string)jsonObjects["msg"];
  9490. if (msg == "报价成功")
  9491. {
  9492. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9493. string data = (string)jsonObject1["price"];
  9494. 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 + "');";
  9495. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9496. returnSuccessMsg("获取报价成功:" + data);
  9497. price = Convert.ToDouble(data);
  9498. }
  9499. else
  9500. {
  9501. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9502. return;
  9503. }
  9504. if (price > 0)
  9505. {
  9506. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9507. if (ceErpTradeCellExtend == null)
  9508. {
  9509. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9510. ceErpTradeCellExtend.ctid = entity.ctid;
  9511. ceErpTradeCellExtend.payment_cyt = price;
  9512. ceErpTradeCellExtend.Create();
  9513. }
  9514. else
  9515. {
  9516. ceErpTradeCellExtend.payment_cyt = price;
  9517. ceErpTradeCellExtend.Update();
  9518. }
  9519. }
  9520. return;
  9521. }
  9522. }
  9523. else
  9524. {
  9525. returnErrorMsg("请至少选择一条数据");
  9526. return;
  9527. }
  9528. }
  9529. //新增
  9530. public void order_To_Supplier()
  9531. {
  9532. string ceid = GetPostString("tid");
  9533. String[] tid = ceid.Split(',');
  9534. if (tid.Length > 0)
  9535. {
  9536. try
  9537. {
  9538. for (int i = 0; i < tid.Length; i++)
  9539. {
  9540. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9541. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9542. entity.SupplierId = suid;
  9543. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9544. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9545. entity.Update();
  9546. }
  9547. }
  9548. catch (Exception ex)
  9549. {
  9550. returnErrorMsg("自动匹配供应商失败");
  9551. return;
  9552. }
  9553. }
  9554. else
  9555. {
  9556. returnErrorMsg("请至少选择一条数据");
  9557. return;
  9558. }
  9559. returnSuccessMsg("自动匹配供应商成功");
  9560. return;
  9561. }
  9562. public (string, string) UploadFiles(string[] urls)
  9563. {
  9564. string success = "";
  9565. string errors = "";
  9566. int userid = CurrentUser.UserID;
  9567. foreach (string url in urls)
  9568. {
  9569. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9570. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9571. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9572. {
  9573. JObject jsonObject = new JObject
  9574. {
  9575. { "Userid", "77886" },
  9576. { "pwd", "cyt86435015" },
  9577. { "content", base64FileContent },
  9578. { "ext", Path.GetExtension(fileName) }
  9579. };
  9580. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9581. JObject jsonObjects = JObject.Parse(response);
  9582. string msg = (string)jsonObjects["msg"];
  9583. if (msg.Equals("上传成功"))
  9584. {
  9585. success += url + " 上传成功";
  9586. }
  9587. else
  9588. {
  9589. errors += url + " 上传失败";
  9590. }
  9591. }
  9592. else
  9593. {
  9594. errors += url + " 格式出现问题";
  9595. }
  9596. }
  9597. if (urls.Length == 0)
  9598. {
  9599. return (success, errors);
  9600. }
  9601. return (success, errors);
  9602. }
  9603. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9604. {
  9605. return true; //总是接受
  9606. }
  9607. public static string HttpPost(string url, string param = null)
  9608. {
  9609. HttpWebRequest request;
  9610. //如果是发送HTTPS请求
  9611. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9612. {
  9613. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9614. request = WebRequest.Create(url) as HttpWebRequest;
  9615. request.ProtocolVersion = HttpVersion.Version10;
  9616. }
  9617. else
  9618. {
  9619. request = WebRequest.Create(url) as HttpWebRequest;
  9620. }
  9621. request.Method = "POST";
  9622. request.ContentType = "application/json";
  9623. request.Accept = "*/*";
  9624. request.Timeout = 120000;
  9625. request.AllowAutoRedirect = false;
  9626. StreamWriter requestStream = null;
  9627. WebResponse response = null;
  9628. string responseStr = null;
  9629. try
  9630. {
  9631. requestStream = new StreamWriter(request.GetRequestStream());
  9632. requestStream.Write(param);
  9633. requestStream.Close();
  9634. response = request.GetResponse();
  9635. if (response != null)
  9636. {
  9637. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9638. responseStr = reader.ReadToEnd();
  9639. reader.Close();
  9640. }
  9641. }
  9642. catch (Exception ex)
  9643. {
  9644. return ex.Message;
  9645. }
  9646. finally
  9647. {
  9648. request = null;
  9649. requestStream = null;
  9650. response = null;
  9651. }
  9652. return responseStr;
  9653. }
  9654. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9655. {
  9656. string base64FileContent;
  9657. string fileName;
  9658. using (WebClient webClient = new WebClient())
  9659. {
  9660. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9661. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9662. {
  9663. using (Stream stream = response.GetResponseStream())
  9664. {
  9665. using (MemoryStream memoryStream = new MemoryStream())
  9666. {
  9667. stream.CopyTo(memoryStream);
  9668. byte[] fileBytes = memoryStream.ToArray();
  9669. base64FileContent = Convert.ToBase64String(fileBytes);
  9670. fileName = response.Headers["Content-Disposition"];
  9671. if (!string.IsNullOrEmpty(fileName))
  9672. {
  9673. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9674. if (index >= 0)
  9675. {
  9676. fileName = fileName.Substring(index + 9).Trim('\"');
  9677. }
  9678. }
  9679. else
  9680. {
  9681. fileName = Path.GetFileName(downloadUrl);
  9682. }
  9683. }
  9684. }
  9685. }
  9686. }
  9687. return (fileName, base64FileContent);
  9688. }
  9689. //新增
  9690. public void order_batch_caiyingtong(string[] downloadUrls)
  9691. {
  9692. try
  9693. {
  9694. //遍历文件
  9695. DataStruct dStruct = GetPostStruct();
  9696. DataTable dt = null;
  9697. int userid = CurrentUser.UserID;
  9698. List<string> ids = new List<string>();//失败组
  9699. List<string> tids = new List<string>();
  9700. using (WebClient webClient = new WebClient())
  9701. {
  9702. foreach (var url in downloadUrls)
  9703. {
  9704. try
  9705. {
  9706. tids.Add("'" + url + "'");
  9707. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9708. if (entity != null)
  9709. {
  9710. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9711. if (cp == null)
  9712. {
  9713. JObject jsonObject = new JObject
  9714. {
  9715. { "Userid", "77886" },
  9716. { "pwd", "lt666888" },
  9717. { "Filename",entity.seller_memo }
  9718. };
  9719. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9720. JObject jsonObjects = JObject.Parse(response);
  9721. string msg = (string)jsonObjects["msg"];
  9722. if (msg == "报价成功")
  9723. {
  9724. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9725. DownloadAndConvertToBase64(url1);
  9726. }
  9727. else
  9728. {
  9729. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9730. }
  9731. }
  9732. else
  9733. {
  9734. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9735. JObject jsonObject = new JObject
  9736. {
  9737. { "Userid", "77886" },
  9738. { "pwd", "lt666888" },
  9739. { "Filename",chanp }
  9740. };
  9741. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9742. JObject jsonObjects = JObject.Parse(response);
  9743. string msg = (string)jsonObjects["msg"];
  9744. if (msg == "报价成功")
  9745. {
  9746. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9747. DownloadAndConvertToBase64(url1);
  9748. }
  9749. else
  9750. {
  9751. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9752. }
  9753. }
  9754. }
  9755. // 上传文件到FTP
  9756. }
  9757. catch (Exception ex)
  9758. {
  9759. Console.WriteLine($"An error occurred: {ex.Message}");
  9760. }
  9761. }
  9762. List<string> lw = new List<string>();
  9763. lw.Add(string.Format("( OrderState < 6 )"));
  9764. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9765. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9766. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9767. if (dt.Rows.Count > 0)
  9768. {
  9769. foreach (DataRow dr in dt.Rows)
  9770. {
  9771. ids.Add(dr["ctid"].ToString());
  9772. }
  9773. }
  9774. String ErrorMsgs = "";
  9775. foreach (String id in ids)
  9776. {
  9777. ErrorMsgs += id + ",";
  9778. }
  9779. if (ErrorMsgs.Length > 1)
  9780. {
  9781. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9782. }
  9783. if (ErrorMsgs.Length < 1)
  9784. {
  9785. ErrorMsgs = "上传成功";
  9786. returnSuccessMsg(ErrorMsgs);
  9787. }
  9788. else
  9789. {
  9790. returnErrorMsg("以下订单" + ErrorMsgs);
  9791. }
  9792. }
  9793. // 删除文件夹及其内容
  9794. /* Directory.Delete(localDirectory, true);*/
  9795. }
  9796. catch { }
  9797. }
  9798. public void get_center_data()
  9799. {
  9800. int userId = CurrentUser.UserID;
  9801. string postCode = CurrentUser.UserPost.Post.Code;
  9802. List<string> lw = new List<string>();
  9803. List<string> ww = new List<string>();
  9804. DateTime currentTime = DateTime.Now;
  9805. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9806. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9807. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9808. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9809. string sql = " SELECT ";
  9810. string startTime = "2023-10-01 11:22:31";
  9811. //设计
  9812. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9813. {
  9814. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9815. 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));
  9816. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9817. 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));
  9818. }
  9819. //客服
  9820. else if (postCode == "CustomerService" || postCode == "Director")
  9821. {
  9822. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9823. 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));
  9824. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9825. 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));
  9826. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9827. 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));
  9828. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9829. 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));
  9830. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9831. 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));
  9832. }
  9833. //售后
  9834. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9835. {
  9836. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9837. 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));
  9838. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9839. 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));
  9840. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9841. 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));
  9842. }
  9843. //下单部
  9844. else if (postCode == "Place" || postCode == "PlaceMr")
  9845. {
  9846. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9847. 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));
  9848. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9849. 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));
  9850. }
  9851. //车间
  9852. else if (postCode == "Supplier")
  9853. {
  9854. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9855. 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));
  9856. }
  9857. DataTable dt = new DataTable();
  9858. if (lw.Count > 0)
  9859. {
  9860. sql += string.Join(" , ", lw);
  9861. sql += " FROM ";
  9862. sql += string.Join(" , ", ww);
  9863. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9864. }
  9865. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9866. }
  9867. public void get_center_data_list()
  9868. {
  9869. int userId = CurrentUser.UserID;
  9870. string postCode = CurrentUser.UserPost.Post.Code;
  9871. string shopIds = CurrentUser.User.pemShop;
  9872. DataStruct dStruct = GetPostStruct();
  9873. List<string> lw = new List<string>();
  9874. DateTime currentTime = DateTime.Now;
  9875. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9876. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9877. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9878. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9879. string startTime = "2023-10-01 11:22:31";
  9880. int order_type = GetPostInt("order_type");
  9881. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9882. {
  9883. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  9884. if (order_type == 0)
  9885. {
  9886. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9887. }
  9888. else if (order_type == 3)
  9889. {
  9890. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  9891. }
  9892. else
  9893. {
  9894. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9895. }
  9896. }
  9897. //客服
  9898. if (postCode == "CustomerService" || postCode == "Director")
  9899. {
  9900. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  9901. if (order_type == 0)
  9902. {
  9903. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9904. }
  9905. else if (order_type == 1)
  9906. {
  9907. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9908. }
  9909. else if (order_type == 2)
  9910. {
  9911. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9912. }
  9913. else if (order_type == 3)
  9914. {
  9915. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  9916. }
  9917. else if (order_type == 4)
  9918. {
  9919. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9920. }
  9921. else
  9922. {
  9923. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9924. }
  9925. }
  9926. //售后
  9927. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9928. {
  9929. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9930. if (shopIds != "")
  9931. {
  9932. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9933. }
  9934. if (order_type == 2)
  9935. {
  9936. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9937. }
  9938. else if (order_type == 4)
  9939. {
  9940. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9941. }
  9942. else if (order_type == 5)
  9943. {
  9944. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  9945. }
  9946. else
  9947. {
  9948. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9949. }
  9950. }
  9951. //下单部
  9952. if (postCode == "Place" || postCode == "PlaceMr")
  9953. {
  9954. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9955. if (shopIds != "")
  9956. {
  9957. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9958. }
  9959. else if (order_type == 1)
  9960. {
  9961. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9962. }
  9963. else if (order_type == 2)
  9964. {
  9965. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9966. }
  9967. else
  9968. {
  9969. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9970. }
  9971. }
  9972. //车间
  9973. if (postCode == "Supplier")
  9974. {
  9975. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9976. if (order_type == 5)
  9977. {
  9978. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  9979. }
  9980. else
  9981. {
  9982. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9983. }
  9984. }
  9985. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9986. dStruct.Fileds = "tid,ctid";
  9987. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  9988. writeGridDataTableJson(dStruct.TotalCount, dt);
  9989. }
  9990. public void aftersale_audit_master()
  9991. {
  9992. if (UrlPostParmsCheck("ctid"))
  9993. {
  9994. string ctid = GetPostString("ctid");
  9995. if (ctid.Length > 0)
  9996. {
  9997. bool result = aftersale_data_change(ctid);
  9998. if (result)
  9999. {
  10000. returnSuccessMsg("修改成功!");
  10001. return;
  10002. }
  10003. }
  10004. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10005. }
  10006. }
  10007. public void aftersale_batch_audit_master()
  10008. {
  10009. if (UrlPostParmsCheck("ctids"))
  10010. {
  10011. string ctids = GetPostString("ctids");
  10012. if (ctids.Length > 0)
  10013. {
  10014. List<string> list = new List<string>();
  10015. string[] ctid_list = ctids.Split(',');
  10016. foreach (var item in ctid_list)
  10017. {
  10018. bool result = aftersale_data_change(item);
  10019. if (!result)
  10020. {
  10021. list.Add(item);
  10022. }
  10023. }
  10024. if (list.Count > 0)
  10025. {
  10026. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10027. return;
  10028. }
  10029. returnSuccessMsg("修改成功!");
  10030. return;
  10031. }
  10032. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10033. }
  10034. }
  10035. public bool aftersale_data_change(string ctid)
  10036. {
  10037. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10038. if (ceErpTradeCell != null)
  10039. {
  10040. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10041. ceErpTradeCell.AfterSaleSupplierState = 0;
  10042. StringBuilder sql = new StringBuilder();
  10043. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10044. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10045. CeErpTradeResponsible.DelByTid(ctid, 0);
  10046. 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 == "不理赔")
  10047. {
  10048. CeErpTradeResponsible.DelByTid(ctid, 1);
  10049. ceErpTradeCell.AfterSaleSupplierState = 1;
  10050. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10051. ceErpTradeCell.AfterSaleState = 4;
  10052. }
  10053. else
  10054. {
  10055. ceErpTradeCell.AfterSaleState = 3;
  10056. }
  10057. bool needCyt = false;
  10058. if (dt != null)
  10059. {
  10060. if (dt.Rows.Count == 1)
  10061. {
  10062. bool isEnd = false;
  10063. foreach (DataRow dr in dt.Rows)
  10064. {
  10065. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10066. {
  10067. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10068. isEnd = true;
  10069. }
  10070. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10071. {
  10072. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10073. isEnd = true;
  10074. }
  10075. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10076. {
  10077. needCyt = true;
  10078. }
  10079. }
  10080. if (isEnd)
  10081. {
  10082. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10083. ceErpTradeCell.AfterSaleState = 4;
  10084. ceErpTradeCell.AfterSaleSupplierState = 1;
  10085. }
  10086. }
  10087. else
  10088. {
  10089. bool isAll = true;
  10090. foreach (DataRow dr in dt.Rows)
  10091. {
  10092. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10093. {
  10094. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10095. continue;
  10096. }
  10097. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10098. {
  10099. string path = "";
  10100. int OrgID = 0;
  10101. if (!Convert.IsDBNull(dr["OrgPath"]))
  10102. {
  10103. path = dr["OrgPath"].ToString();
  10104. }
  10105. if (!Convert.IsDBNull(dr["OrgID"]))
  10106. {
  10107. OrgID = Convert.ToInt32(dr["OrgID"]);
  10108. }
  10109. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10110. {
  10111. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10112. continue;
  10113. }
  10114. }
  10115. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10116. {
  10117. needCyt = true;
  10118. }
  10119. isAll = false;
  10120. }
  10121. if (isAll)
  10122. {
  10123. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10124. ceErpTradeCell.AfterSaleState = 4;
  10125. ceErpTradeCell.AfterSaleSupplierState = 1;
  10126. }
  10127. }
  10128. }
  10129. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10130. {
  10131. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10132. }
  10133. if (ceErpTradeCell.AfterSaleState == 4)
  10134. {
  10135. ApiVo apiVo = new ApiVo();
  10136. apiVo.orderNumber = ceErpTradeCell.ctid;
  10137. apiVo.actionName = "afterOver";
  10138. designHelper.API_WorkCore(apiVo); //afterOver
  10139. }
  10140. ceErpTradeCell.Update();
  10141. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10142. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10143. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10144. return true;
  10145. }
  10146. return false;
  10147. }
  10148. public void get_erp_wechatorder()
  10149. {
  10150. DataStruct dStruct = GetPostStruct();
  10151. List<string> lw = new List<string>();
  10152. string tid = GetPostString("tid");
  10153. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10154. string shopname = GetPostString("shopname");
  10155. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10156. string buyernick = GetPostString("buyer_nick");
  10157. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10158. string customer = GetPostString("customer");
  10159. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10160. string returndate1 = GetPostString("returndate1");
  10161. string returndate2 = GetPostString("returndate2");
  10162. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10163. if (dw.Length > 0) lw.Add(dw);
  10164. string finishDate1 = GetPostString("finishdate1");
  10165. string finishDate2 = GetPostString("finishdate2");
  10166. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10167. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10168. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10169. dStruct.Order = "created desc";
  10170. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10171. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10172. writeGridDataTableJson(dStruct.TotalCount, dt);
  10173. }
  10174. public void get_erp_wechatlist_sumprice()
  10175. {
  10176. DataStruct dStruct = GetPostStruct();
  10177. List<string> lw = new List<string>();
  10178. string tid = GetPostString("tid");
  10179. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10180. string shopname = GetPostString("shopname");
  10181. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10182. string buyernick = GetPostString("buyer_nick");
  10183. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10184. string customer = GetPostString("customer");
  10185. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10186. string returndate1 = GetPostString("returndate1");
  10187. string returndate2 = GetPostString("returndate2");
  10188. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10189. if (dw.Length > 0) lw.Add(dw);
  10190. string finishDate1 = GetPostString("finishdate1");
  10191. string finishDate2 = GetPostString("finishdate2");
  10192. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10193. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10194. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10195. string mainWhere = string.Join(" and ", lw.ToArray());
  10196. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10197. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10198. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10199. decimal total = 0;
  10200. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10201. {
  10202. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10203. }
  10204. var res = new
  10205. {
  10206. data = total
  10207. };
  10208. string ro_jsond = JsonConvert.SerializeObject(res);
  10209. returnSuccess(ro_jsond);
  10210. return;
  10211. }
  10212. public void get_erp_qr_waitdeliverylist()
  10213. {
  10214. DataStruct dStruct = GetPostStruct();
  10215. List<string> lw = new List<string>();
  10216. string tid = GetPostString("ctid");
  10217. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10218. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10219. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10220. var res_objz = new
  10221. {
  10222. restype = 1,
  10223. data = dt
  10224. };
  10225. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10226. returnSuccess(ro_jsonz);
  10227. }
  10228. public void get_erp_yield_list()
  10229. {
  10230. DataStruct dStruct = GetPostStruct();
  10231. List<string> lw = new List<string>();
  10232. string tid = GetPostString("ctid");
  10233. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10234. string shopname = GetPostString("shopname");
  10235. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10236. string buyernick = GetPostString("buyer_nick");
  10237. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10238. //if (tid.Length == 0 && buyernick.Length == 0)
  10239. //{
  10240. // lw.Add(string.Format("IsRefund<={0}", 1));
  10241. //}
  10242. string customer = GetPostString("customer");
  10243. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10244. string design = GetPostString("design");
  10245. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10246. string orderState = GetPostString("orderState");
  10247. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10248. string address = GetPostString("address");
  10249. 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));
  10250. string sellermemo = GetPostString("seller_memo");
  10251. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10252. string supplier = GetPostString("supplier");
  10253. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10254. string OrderArea = GetPostString("order_area");
  10255. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10256. string placedate1 = GetPostString("placedate1");
  10257. string placedate2 = GetPostString("placedate2");
  10258. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10259. if (fdw.Length > 0) lw.Add(fdw);
  10260. string price1 = GetPostString("price1");
  10261. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10262. string price2 = GetPostString("price2");
  10263. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10264. string unusualCon = GetPostString("unusualcon");
  10265. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10266. string posTag = CurrentUser.UserPost.Post.Code;
  10267. if (posTag == "Supplier")
  10268. {
  10269. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10270. }
  10271. lw.Add(string.Format("OrderState = 6 "));
  10272. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10273. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10274. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10275. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10276. writeGridDataTableJson(dStruct.TotalCount, dt);
  10277. }
  10278. public void change_erp_sup_state()
  10279. {
  10280. if (UrlPostParmsCheck("ctid"))
  10281. {
  10282. string ctid = GetPostString("ctid");
  10283. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10284. if (ceErpTradeCell != null)
  10285. {
  10286. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10287. if (ceErpTradeCellExtend == null)
  10288. {
  10289. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10290. ceErpTradeCellExtend.ctid = ctid;
  10291. ceErpTradeCellExtend.SupState = 1;
  10292. ceErpTradeCellExtend.Create();
  10293. }
  10294. else
  10295. {
  10296. ceErpTradeCellExtend.SupState = 1;
  10297. ceErpTradeCellExtend.Update();
  10298. }
  10299. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10300. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10301. return;
  10302. }
  10303. returnErrorMsg("找不到订单");
  10304. }
  10305. }
  10306. public void supplier_all_downs()
  10307. {
  10308. if (UrlPostParmsCheck("tids"))
  10309. {
  10310. string tids = GetPostString("tids");
  10311. if (tids != null && tids.Length > 0)
  10312. {
  10313. StringBuilder sql = new StringBuilder();
  10314. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10315. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10316. sql = new StringBuilder();
  10317. 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, "下载设计文件");
  10318. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10319. string[] list = tids.Split(',');
  10320. foreach (string ctid in list)
  10321. {
  10322. CeErpSukuraData.createInfo(ctid, 3);
  10323. }
  10324. designHelper.api_approveDesign(tids); //approveDesign
  10325. returnSuccessMsg("下载成功!");
  10326. return;
  10327. }
  10328. returnErrorMsg("下载订单更新失败");
  10329. }
  10330. }
  10331. public void uploaderFileSuccess()
  10332. {
  10333. if (UrlPostParmsCheck("fileName"))
  10334. {
  10335. string fileName = GetPostString("fileName");
  10336. ApiVo apiVo = new ApiVo();
  10337. apiVo.orderNumber = fileName;
  10338. apiVo.actionName = "finishDesign";
  10339. designHelper.API_WorkCore(apiVo);//finishDesign
  10340. returnSuccessMsg("");
  10341. }
  10342. }
  10343. public void get_sample2_order()
  10344. {
  10345. if (UrlPostParmsCheck("ctid"))
  10346. {
  10347. string ctid = GetPostString("ctid");
  10348. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10349. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10350. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10351. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10352. double total = 0.0;
  10353. double order_price = 0.0;
  10354. if (dt_bu.Rows.Count > 0)
  10355. {
  10356. foreach (DataRow dr in dt_bu.Rows)
  10357. {
  10358. total += Convert.ToDouble(dr["payment"]);
  10359. }
  10360. }
  10361. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10362. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10363. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10364. string tid = ctid.Replace("S_", "");
  10365. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10366. double paymant = 0.0;
  10367. if (entity != null)
  10368. {
  10369. paymant = entity.payment;
  10370. }
  10371. string return_reason = "";
  10372. if (dt_after != null && dt_after.Rows.Count > 0)
  10373. {
  10374. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10375. }
  10376. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10377. }
  10378. }
  10379. public void get_erp_design_status()
  10380. {
  10381. string designName = GetPostString("designName");
  10382. DataStruct dStruct = GetPostStruct();
  10383. if (designName.Length > 0)
  10384. {
  10385. 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";
  10386. sql_user += " and Name like '%" + designName + "%'";
  10387. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10388. List<string> ids_list = new List<string>();
  10389. if (user_table.Rows.Count > 0)
  10390. {
  10391. foreach (DataRow item in user_table.Rows)
  10392. {
  10393. ids_list.Add(item["id"].ToString());
  10394. string ids_s = item["TeamIds"].ToString();
  10395. if (ids_s.Length > 0)
  10396. {
  10397. ids_list.AddRange(ids_s.Split(','));
  10398. }
  10399. }
  10400. }
  10401. HashSet<string> set = new HashSet<string>(ids_list);
  10402. ids_list = set.ToList();
  10403. if (ids_list.Count > 0)
  10404. {
  10405. 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));
  10406. dStruct.MainWhere = sql;
  10407. DataTable dt = null;
  10408. dt = WebCache.GetData("view_ErpUser", dStruct);
  10409. writeGridDataTableJson(dStruct.TotalCount, dt);
  10410. }
  10411. }
  10412. }
  10413. public void change_erp_order_price()
  10414. {
  10415. string ctid = GetPostString("ctid");
  10416. double price = GetPostDouble("price");
  10417. if (ctid.Length > 0)
  10418. {
  10419. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10420. if (ceErpTradeCellExtend == null)
  10421. {
  10422. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10423. ceErpTradeCellExtend.ctid = ctid;
  10424. ceErpTradeCellExtend.payment_cyt = price;
  10425. ceErpTradeCellExtend.Create();
  10426. }
  10427. else
  10428. {
  10429. ceErpTradeCellExtend.payment_cyt = price;
  10430. ceErpTradeCellExtend.Update();
  10431. }
  10432. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10433. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10434. {
  10435. ceErpDataSendOrderInfo.isSync = false;
  10436. ceErpDataSendOrderInfo.Update();
  10437. }
  10438. if (ceErpDataSendOrderInfo == null)
  10439. {
  10440. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10441. ceErpDataSendOrderInfo.isSync = false;
  10442. ceErpDataSendOrderInfo.ctid = ctid;
  10443. ceErpDataSendOrderInfo.Create();
  10444. }
  10445. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10446. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10447. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10448. if (dth != null && dth.Rows.Count > 0)
  10449. {
  10450. dataSendOrderBean dataSendOrderBean = null;
  10451. foreach (DataRow item in dth.Rows)
  10452. {
  10453. try
  10454. {
  10455. dataSendOrderBean = new dataSendOrderBean();
  10456. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10457. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10458. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10459. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10460. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10461. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10462. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10463. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10464. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10465. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10466. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10467. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10468. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10469. if (result != null)
  10470. {
  10471. if ("0".Equals(result.errcode))
  10472. {
  10473. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10474. }
  10475. else
  10476. {
  10477. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10478. }
  10479. }
  10480. }
  10481. catch (Exception ex)
  10482. {
  10483. }
  10484. }
  10485. }
  10486. returnSuccessMsg("修改成功!");
  10487. return;
  10488. }
  10489. returnErrorMsg("找不到订单");
  10490. }
  10491. public void find_he_together()
  10492. {
  10493. string ctid = GetPostString("ctid");
  10494. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10495. List<string> list = new List<string>();
  10496. if (ceErpTradeCell != null)
  10497. {
  10498. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10499. {
  10500. 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);
  10501. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10502. if (table != null && table.Rows.Count > 0)
  10503. {
  10504. foreach (TableRow row in table.Rows)
  10505. {
  10506. }
  10507. }
  10508. }
  10509. }
  10510. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10511. }
  10512. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10513. {
  10514. //chy----19
  10515. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10516. //GD-CYT-----64
  10517. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10518. //ZHX----3
  10519. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10520. //JK----97
  10521. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10522. //ZT----70
  10523. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10524. //LHCY-----98
  10525. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10526. //XD-----90
  10527. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10528. //CYCY-----14
  10529. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10530. };
  10531. //其他改名
  10532. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10533. {
  10534. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10535. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10536. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10537. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10538. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10539. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10540. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10541. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10542. };
  10543. //不统计
  10544. List<int> no_suppliers = new List<int>()
  10545. {
  10546. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10547. };
  10548. //配件单
  10549. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10550. {
  10551. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10552. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10553. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10554. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10555. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10556. {"旗杆",new List<string>(){ "班旗" } },
  10557. {"牙签",new List<string>(){ "不干胶" } }
  10558. };
  10559. public void get_place_order_data()
  10560. {
  10561. string date1 = GetPostString("date1");
  10562. string date2 = GetPostString("date2");
  10563. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10564. DateTime start = DateTime.Parse(starttime);
  10565. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10566. DateTime end = DateTime.Parse(endtime);
  10567. if (date1 != null && date1.Length > 0)
  10568. {
  10569. DateTime dateTime = DateTime.Parse(date1);
  10570. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10571. start = DateTime.Parse(starttime);
  10572. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10573. end = DateTime.Parse(endtime);
  10574. }
  10575. if (date2 != null && date2.Length > 0)
  10576. {
  10577. DateTime dateTime = DateTime.Parse(date2);
  10578. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10579. end = DateTime.Parse(endtime);
  10580. }
  10581. 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);
  10582. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10583. //不干胶-----1,卡片-----29
  10584. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10585. foreach (DataRow row in data.Rows)
  10586. {
  10587. int productId = Convert.ToInt32(row["ProductId"]);
  10588. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10589. if (no_suppliers.Contains(supplierId))
  10590. {
  10591. continue;
  10592. }
  10593. string seller_memo = row["seller_memo"].ToString();
  10594. bool ispj = false;//是否配件单
  10595. bool isfirst = true;//第一个配
  10596. maps.Keys.ForEach(key =>
  10597. {
  10598. //备注包含配件
  10599. if (seller_memo.Contains(key) && isfirst)
  10600. {
  10601. List<string> list = maps[key];
  10602. ispj = true;
  10603. isfirst = false;
  10604. for (int i = 0; i < list.Count; i++)
  10605. {
  10606. if (seller_memo.Contains(list[i]))
  10607. {
  10608. ispj = false;
  10609. break;
  10610. }
  10611. }
  10612. }
  10613. });
  10614. if (ispj)
  10615. {
  10616. continue;
  10617. }
  10618. seller_memo = seller_memo.Replace("UV", "uv");
  10619. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10620. //吊牌归到卡片
  10621. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10622. seller_memo = seller_memo.Replace("卡套", "卡片");
  10623. seller_memo = seller_memo.Replace("封套", "卡片");
  10624. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10625. seller_memo = seller_memo.Replace("腰封", "卡片");
  10626. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10627. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10628. seller_memo = seller_memo.Replace("横幅", "条幅");
  10629. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10630. string map_key = "";
  10631. string type = "";
  10632. if (supplierMap.ContainsKey(supplierId))
  10633. {
  10634. foreach (var kvp in supplierMap[supplierId])
  10635. {
  10636. if (seller_memo.Contains(kvp.Key))
  10637. {
  10638. map_key = kvp.Value;
  10639. type = kvp.Value;
  10640. break;
  10641. }
  10642. }
  10643. }
  10644. if (map_key == "")
  10645. {
  10646. type = "其他";
  10647. map_key = "其他";
  10648. }
  10649. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10650. {
  10651. map_key = suppliers[supplierId];
  10652. }
  10653. if (supplierId == 70)
  10654. {
  10655. supplierId = 70;
  10656. }
  10657. map_key += "_" + row["SupplierName"].ToString();
  10658. Dictionary<string, int> map = null;
  10659. if (other_map.ContainsKey(map_key))
  10660. {
  10661. other_map.TryGetValue(map_key, out map);
  10662. }
  10663. else
  10664. {
  10665. map = new Dictionary<string, int>();
  10666. map.Add("dayDev", 0);//当天出货
  10667. map.Add("dayTotal", 0);//下单总数
  10668. map.Add("payTotal", 0);//500以上
  10669. map.Add("today", 0);//当天出货数量
  10670. map.Add("unusua", 0);//异常数
  10671. other_map.Add(map_key, map);
  10672. other_map.TryGetValue(map_key, out map);
  10673. }
  10674. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10675. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10676. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10677. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  10678. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10679. {
  10680. map["dayTotal"]++;
  10681. if (supplierId == 97)
  10682. {
  10683. supplierId = 97;
  10684. }
  10685. }
  10686. if (Convert.ToDecimal(row["payment"]) >= 500)
  10687. {
  10688. map["payTotal"]++;
  10689. }
  10690. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10691. {
  10692. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10693. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10694. {
  10695. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10696. {
  10697. map["today"]++;
  10698. }
  10699. }
  10700. else
  10701. {
  10702. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10703. {
  10704. map["today"]++;
  10705. }
  10706. }
  10707. }
  10708. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10709. {
  10710. map["unusua"]++;
  10711. }
  10712. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10713. //GD-CYT-----64
  10714. DateTime two = palceTimeStart.AddHours(14);
  10715. DateTime three = palceTimeStart.AddHours(15);
  10716. DateTime four = palceTimeStart.AddHours(16);
  10717. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10718. {
  10719. //下午四点前 500-1000
  10720. string count = row["ProductCount"].ToString();
  10721. if (count != null && count.Length > 0)
  10722. {
  10723. int productCount = commonHelper.getPlaceProductCount(count);
  10724. if (productCount >= 500 && productCount <= 1000)
  10725. {
  10726. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10727. {
  10728. map["dayDev"]++;
  10729. }
  10730. }
  10731. }
  10732. }
  10733. //UV
  10734. else if ("uv".Equals(type))
  10735. {
  10736. //ZT----70
  10737. //ZHX----3
  10738. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10739. {
  10740. map["dayDev"]++;
  10741. }
  10742. //JK----97
  10743. //HZX----105
  10744. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10745. {
  10746. map["dayDev"]++;
  10747. if (supplierId == 97)
  10748. {
  10749. supplierId = 97;
  10750. }
  10751. }
  10752. }
  10753. //帆布---52|条幅---27
  10754. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10755. {
  10756. //LHCY-----98
  10757. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10758. {
  10759. map["dayDev"]++;
  10760. }
  10761. }
  10762. //条幅
  10763. else if ("条幅".Equals(type))
  10764. {
  10765. //XD-----90
  10766. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10767. {
  10768. map["dayDev"]++;
  10769. }
  10770. }
  10771. //桌布
  10772. else if ("桌布".Equals(type))
  10773. {
  10774. //XD-----90
  10775. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10776. {
  10777. map["dayDev"]++;
  10778. }
  10779. }
  10780. //DL---10
  10781. //AYTW---119
  10782. //FS-CYT-DY ----80
  10783. //JK----97
  10784. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10785. {
  10786. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10787. {
  10788. map["dayDev"]++;
  10789. }
  10790. }
  10791. }
  10792. DataTable dt = new DataTable();
  10793. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10794. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10795. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10796. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10797. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10798. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10799. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10800. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10801. other_map.Keys.ForEach(key =>
  10802. {
  10803. DataRow dr = dt.NewRow();
  10804. Dictionary<string, int> map = other_map[key];
  10805. string[] key_list = key.Split('_');
  10806. dr[0] = key_list[0];
  10807. dr[1] = key_list[1];
  10808. if (key_list.Length > 2)
  10809. {
  10810. dr[1] += "(" + key_list[2] + ")";
  10811. }
  10812. dr[2] = map["dayTotal"];
  10813. dr[3] = map["payTotal"];
  10814. dr[4] = map["today"];
  10815. dr[5] = map["unusua"];
  10816. dr[6] = map["dayDev"];
  10817. double rate = 0.00;
  10818. if (map["dayDev"] > 0)
  10819. {
  10820. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10821. }
  10822. dr[7] = rate.ToString();
  10823. dt.Rows.Add(dr);
  10824. });
  10825. DataView dv = new DataView(dt);
  10826. dv.Sort = "SupplierName";
  10827. //dv.Sort = "AllOrder desc";
  10828. DataTable dtNew = dv.ToTable();
  10829. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10830. }
  10831. public void check_order_desing_info()
  10832. {
  10833. string ctid = GetPostString("ctid");
  10834. if (!string.IsNullOrEmpty(ctid))
  10835. {
  10836. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10837. if (ceErpTradeCell != null)
  10838. {
  10839. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10840. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10841. return;
  10842. }
  10843. returnErrorMsg("找不到订单");
  10844. return;
  10845. }
  10846. returnErrorMsg("找不到订单");
  10847. }
  10848. public void get_timeout_detail()
  10849. {
  10850. string poscode = CurrentUser.UserPost.Post.Code;
  10851. DataStruct dStruct = GetPostStruct();
  10852. List<string> lw = new List<string>();
  10853. string id = GetPostString("id");
  10854. string pay_date1 = GetPostString("pay_date1");
  10855. string pay_date2 = GetPostString("pay_date2");
  10856. int type = GetPostInt("type");
  10857. if (type == 0)
  10858. {
  10859. if (pay_date1.Length > 0)
  10860. {
  10861. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  10862. }
  10863. if (pay_date2.Length > 0)
  10864. {
  10865. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  10866. }
  10867. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  10868. }
  10869. if (type == 1)
  10870. {
  10871. if (pay_date1.Length > 0)
  10872. {
  10873. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  10874. }
  10875. if (pay_date2.Length > 0)
  10876. {
  10877. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  10878. }
  10879. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  10880. }
  10881. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10882. DataTable dt = null;
  10883. dt = WebCache.GetData("view_orderlist", dStruct);
  10884. writeGridDataTableJson(dStruct.TotalCount, dt);
  10885. }
  10886. public void saveUrgentChargePrice()
  10887. {
  10888. string ctid = GetPostString("ctid");
  10889. if (!string.IsNullOrEmpty(ctid))
  10890. {
  10891. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10892. if (ceErpTradeCell != null)
  10893. {
  10894. double price = GetPostDouble("price");
  10895. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  10896. if (ceErpTradeCellExtend == null)
  10897. {
  10898. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10899. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  10900. }
  10901. ceErpTradeCellExtend.urgentCharge = price;
  10902. if (ceErpTradeCellExtend.ID > 0)
  10903. {
  10904. ceErpTradeCellExtend.Update();
  10905. }
  10906. else
  10907. {
  10908. ceErpTradeCellExtend.Save();
  10909. }
  10910. returnSuccessMsg("修改成功!");
  10911. return;
  10912. }
  10913. returnErrorMsg("找不到订单");
  10914. return;
  10915. }
  10916. returnErrorMsg("找不到订单");
  10917. }
  10918. public void finish_erp_order()
  10919. {
  10920. string ctid = GetPostString("ctid");
  10921. if (!string.IsNullOrEmpty(ctid))
  10922. {
  10923. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  10924. {
  10925. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10926. if (ceErpTradeCell != null)
  10927. {
  10928. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  10929. ceErpTradeCell.Update();
  10930. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  10931. returnSuccessMsg("修改成功!");
  10932. return;
  10933. }
  10934. }
  10935. }
  10936. returnErrorMsg("找不到订单");
  10937. }
  10938. public void get_trade_order_list()
  10939. {
  10940. string tid = GetPostString("tid");
  10941. if (!string.IsNullOrEmpty(tid))
  10942. {
  10943. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  10944. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10945. writeGridDataTableJson(data.Rows.Count, data);
  10946. return;
  10947. }
  10948. returnErrorMsg("找不到订单");
  10949. }
  10950. public void save_cell_spu()
  10951. {
  10952. string ctid = GetPostString("ctid");
  10953. string spu_id = GetPostString("spu_id");
  10954. if (!string.IsNullOrEmpty(ctid))
  10955. {
  10956. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10957. if (ceErpTradeCellExtend == null)
  10958. {
  10959. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10960. ceErpTradeCellExtend.ctid = ctid;
  10961. }
  10962. ceErpTradeCellExtend.spu_id = spu_id;
  10963. if (ceErpTradeCellExtend.ID == 0)
  10964. {
  10965. ceErpTradeCellExtend.Create();
  10966. }
  10967. else
  10968. {
  10969. ceErpTradeCellExtend.Update();
  10970. }
  10971. returnSuccessMsg("修改成功!");
  10972. return;
  10973. }
  10974. returnErrorMsg("找不到订单");
  10975. }
  10976. public void change_express_info()
  10977. {
  10978. string ctid = GetPostString("ctid");
  10979. string transNo = GetPostString("transNo");
  10980. string transCom = GetPostString("transCom");
  10981. if (!string.IsNullOrEmpty(ctid))
  10982. {
  10983. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10984. if (ceErpTradeCellExtend == null)
  10985. {
  10986. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10987. ceErpTradeCellExtend.ctid = ctid;
  10988. }
  10989. ceErpTradeCellExtend.modExpressNo = transNo;
  10990. ceErpTradeCellExtend.modExpressCom = transCom;
  10991. ceErpTradeCellExtend.readMod = 2;
  10992. if (ceErpTradeCellExtend.ID == 0)
  10993. {
  10994. ceErpTradeCellExtend.Create();
  10995. }
  10996. else
  10997. {
  10998. ceErpTradeCellExtend.Update();
  10999. }
  11000. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11001. returnSuccessMsg("修改成功!");
  11002. return;
  11003. }
  11004. returnErrorMsg("找不到订单");
  11005. }
  11006. public void get_change_express_list()
  11007. {
  11008. DataStruct dStruct = GetPostStruct();
  11009. List<string> lw = new List<string>();
  11010. int st = 2;
  11011. string tid = GetPostString("ctid");
  11012. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  11013. string shopname = GetPostString("shopname");
  11014. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11015. string buyernick = GetPostString("buyer_nick");
  11016. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11017. string sellermemo = GetPostString("seller_memo");
  11018. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11019. string supplier = GetPostString("supplier");
  11020. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11021. string customer = GetPostString("customer");
  11022. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11023. string design = GetPostString("design");
  11024. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11025. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11026. string poscode = CurrentUser.UserPost.Post.Code;
  11027. if (poscode != "SysAdmin")
  11028. {
  11029. string shopid = CurrentUser.User.pemShop;
  11030. lw.Add(string.Format("shopId in ({0})", shopid));
  11031. }
  11032. lw.Add("readMod = 2");
  11033. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11034. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11035. writeGridDataTableJson(dStruct.TotalCount, dt);
  11036. }
  11037. public void deal_express_complete()
  11038. {
  11039. string ctid = GetPostString("ctid");
  11040. if (!string.IsNullOrEmpty(ctid))
  11041. {
  11042. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11043. if (ceErpTradeCellExtend == null)
  11044. {
  11045. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11046. ceErpTradeCellExtend.ctid = ctid;
  11047. }
  11048. ceErpTradeCellExtend.readMod = 1;
  11049. if (ceErpTradeCellExtend.ID == 0)
  11050. {
  11051. ceErpTradeCellExtend.Create();
  11052. }
  11053. else
  11054. {
  11055. ceErpTradeCellExtend.Update();
  11056. }
  11057. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11058. returnSuccessMsg("修改成功!");
  11059. return;
  11060. }
  11061. returnErrorMsg("找不到订单");
  11062. }
  11063. public void aftersale_return_visit()
  11064. {
  11065. string ctid = GetPostString("ctid");
  11066. if (!string.IsNullOrEmpty(ctid))
  11067. {
  11068. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11069. if (ceErpTradeCellExtend == null)
  11070. {
  11071. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11072. ceErpTradeCellExtend.ctid = ctid;
  11073. }
  11074. ceErpTradeCellExtend.returnVisit = 1;
  11075. if (ceErpTradeCellExtend.ID == 0)
  11076. {
  11077. ceErpTradeCellExtend.Create();
  11078. }
  11079. else
  11080. {
  11081. ceErpTradeCellExtend.Update();
  11082. }
  11083. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11084. if (ceErpTradeAfterSaleExtend != null)
  11085. {
  11086. ceErpTradeAfterSaleExtend.TextResult = "";
  11087. ceErpTradeAfterSaleExtend.Update();
  11088. }
  11089. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11090. returnSuccessMsg("修改成功!");
  11091. return;
  11092. }
  11093. returnErrorMsg("找不到订单");
  11094. }
  11095. public void orderPlaceInfo()
  11096. {
  11097. string ctids = GetPostString("ctids");
  11098. string[] list = ctids.Split(',');
  11099. foreach (string ctid in list)
  11100. {
  11101. CeErpSukuraData.createInfo(ctid, 3);
  11102. }
  11103. designHelper.api_approveDesign(ctids); //approveDesign
  11104. returnSuccessMsg("");
  11105. }
  11106. }
  11107. }