sync.order.cs 568 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238
  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. continue; // 跳过当前迭代
  253. }
  254. else if (refund_fees == total_fee)
  255. {
  256. dr["refund_fees"] = payment;
  257. continue; // 跳过当前迭代
  258. }
  259. else
  260. {
  261. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  262. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  263. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  264. }
  265. }
  266. // 对象操作
  267. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  268. ceErpTradeCell.ctid = dr["ctid"].ToString();
  269. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  270. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  271. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  272. if (dStruct.PageSize != 100000)
  273. {
  274. if (dr["DispatchSort"].ToString() == "2")
  275. {
  276. dr["gongchuang"] = 200;
  277. }
  278. else
  279. {
  280. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  281. dr["gongchuang"] = response.code;
  282. }
  283. }
  284. }
  285. catch (NullReferenceException ex)
  286. {
  287. // 处理空引用异常
  288. dr["refund_fees"] = "0.00";
  289. }
  290. }
  291. }
  292. writeGridDataTableJson(dStruct.TotalCount, dt);
  293. }
  294. public void get_erp_orderlist_sumprice()
  295. {
  296. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  297. return;
  298. List<string> lw = new List<string>();
  299. string tid = GetPostString("ctid");
  300. string date1 = GetPostString("date1");
  301. string date2 = GetPostString("date2");
  302. if (tid.Length > 0 || date1.Length > 0)
  303. {
  304. lw.Add(string.Format("ctid like '%{0}%'", tid));
  305. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  306. if (dw.Length > 0) lw.Add(dw);
  307. }
  308. else
  309. {
  310. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  311. }
  312. string shopname = GetPostString("shopname");
  313. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  314. string buyernick = GetPostString("buyer_nick");
  315. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  316. string customer = GetPostString("customer");
  317. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  318. string design = GetPostString("design");
  319. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  320. string orderState = GetPostString("orderState");
  321. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  322. string address = GetPostString("address");
  323. 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));
  324. string sellermemo = GetPostString("seller_memo");
  325. if (sellermemo.Length > 0)
  326. {
  327. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  328. }
  329. string apdate1 = GetPostString("apdate1");
  330. string apdate2 = GetPostString("apdate2");
  331. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  332. if (dwap.Length > 0) lw.Add(dwap);
  333. string price1 = GetPostString("price1");
  334. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  335. string price2 = GetPostString("price2");
  336. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  337. string isoldcustomer = GetPostString("isoldcus");
  338. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  339. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  340. if (PKey != "admin")
  341. {
  342. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  343. lw.Add(string.Format("shopId in ({0})", usershop));
  344. }
  345. //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";
  346. string mainWhere = string.Join(" and ", lw.ToArray());
  347. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  348. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  349. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  350. decimal total = 0;
  351. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  352. {
  353. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  354. }
  355. var res = new
  356. {
  357. data = total
  358. };
  359. string ro_jsond = JsonConvert.SerializeObject(res);
  360. returnSuccess(ro_jsond);
  361. return;
  362. }
  363. public void get_erp_CustomerServiceGather()
  364. {
  365. string userWhere = "", orderWhere = "";
  366. List<string> lw = new List<string>();
  367. string customer = GetPostString("customer");
  368. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  369. string shopname = GetPostString("shopname");
  370. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  371. string date1 = GetPostString("date1");
  372. string date2 = GetPostString("date2");
  373. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  374. if (dw.Length > 0) lw.Add(dw);
  375. orderWhere = string.Join(" and ", lw.ToArray());
  376. 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 " +
  377. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  378. "left join " +
  379. "( " +
  380. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  381. ") as b on a.ID = b.CustomerUserId " +
  382. "left join " +
  383. "( " +
  384. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  385. ") as d on a.ID = d.CustomerUserId " +
  386. "left join " +
  387. "( " +
  388. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  389. ") as e on a.ID = e.CustomerUserId " +
  390. "left join " +
  391. "( " +
  392. " select CustomerUserId, RefundCount, RefundSum from " +
  393. " ( " +
  394. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  395. " from CE_ErpTradeRefund a " +
  396. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  397. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  398. " group by CustomerUserId " +
  399. " ) as a " +
  400. ") as f on a.ID = f.CustomerUserId " +
  401. "where a.PostCode = 'CustomerService'",
  402. userWhere, orderWhere);
  403. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  404. writeGridDataTableJson(dt.Rows.Count, dt);
  405. //writeGridDataTableJson(dt.Rows.Count, dt);
  406. }
  407. //设计汇总
  408. public void get_erp_DesignerGather()
  409. {
  410. string userWhere = "", orderWhere = "";
  411. List<string> lw = new List<string>();
  412. string Designer = GetPostString("designer");
  413. int org = GetPostInt("org");
  414. if (Designer.Length > 0)
  415. {
  416. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  417. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  418. }
  419. else if (org > 0)
  420. {
  421. userWhere = string.Format(" where OrgID ={0}", org);
  422. }
  423. string shopname = GetPostString("shopname");
  424. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  425. string state = GetPostString("state");
  426. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  427. string OrderArea = GetPostString("order_area");
  428. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  429. string date1 = GetPostString("date1");
  430. string date2 = GetPostString("date2");
  431. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  432. if (dw.Length > 0) lw.Add(dw);
  433. string UpDate1 = GetPostString("UpDate1");
  434. string UpDate2 = GetPostString("UpDate2");
  435. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  436. if (dw.Length > 0) lw.Add(dw);
  437. orderWhere = string.Join(" and ", lw.ToArray());
  438. 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 (" +
  439. "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 " +
  440. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  441. "left join " +
  442. "( " +
  443. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  444. ") as b on a.ID = b.DesignUserId " +
  445. "left join " +
  446. "( " +
  447. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  448. ") as d on a.ID = d.DesignUserId " +
  449. "left join " +
  450. "( " +
  451. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  452. ") as e on a.ID = e.DesignUserId " +
  453. "left join " +
  454. "( " +
  455. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  456. ") as g on a.ID = g.DesignUserId " +
  457. "left join " +
  458. "( " +
  459. " select CustomerUserId, RefundCount, RefundSum from " +
  460. " ( " +
  461. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  462. " from CE_ErpTradeRefund a " +
  463. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  464. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  465. " group by CustomerUserId " +
  466. " ) as a " +
  467. ") as f on a.ID = f.CustomerUserId " +
  468. "where a.PostCode = 'Designer') as z",
  469. userWhere, orderWhere);
  470. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  471. writeGridDataTableJson(dt.Rows.Count, dt);
  472. }
  473. //删除tradecell的订单
  474. public void del_erp_cellorder()
  475. {
  476. if (UrlPostParmsCheck("ctid"))
  477. {
  478. string eid = GetPostString("ctid");
  479. CeErpTradeCell.DelByCtid(eid);
  480. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  481. returnSuccessMsg("删除成功");
  482. }
  483. }
  484. public void clear_erp_refundstate()
  485. {
  486. if (UrlPostParmsCheck("ids"))
  487. {
  488. string eids = GetPostString("ids");
  489. string[] ctidList = eids.Split(',');
  490. foreach (string ctid in ctidList)
  491. {
  492. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  493. if (entity != null)
  494. {
  495. entity.IsRefund = 0;
  496. entity.Update();
  497. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  498. }
  499. else
  500. continue;
  501. }
  502. returnSuccessMsg("操作成功");
  503. return;
  504. }
  505. returnErrorMsg("缺少必要参数");
  506. }
  507. public void set_erp_urgency()
  508. {
  509. if (UrlPostParmsCheck("ctid"))
  510. {
  511. string eid = GetPostString("ctid");
  512. CeErpTradeCell entity = null;
  513. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  514. if (entity != null)
  515. {
  516. string utime = GetPostString("urgencytime");
  517. if (utime.Length > 0)
  518. {
  519. entity.UrgencyTime = Convert.ToDateTime(utime);
  520. }
  521. else
  522. {
  523. returnErrorMsg("请选择加急时间");
  524. return;
  525. }
  526. if (entity.OrderState <= 4)
  527. {
  528. //entity.seller_memo = entity.seller_memo + "-加急";
  529. string smemo = entity.seller_memo;
  530. int kindex = smemo.IndexOf(")");
  531. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  532. if (lastoneStr != "-")
  533. {
  534. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  535. }
  536. string prememo = smemo.Substring(0, kindex + 2);
  537. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  538. int lastkindex = lastmemo.IndexOf("(");
  539. DateTime urgtime = Convert.ToDateTime(utime);
  540. string newlastmemo = "";
  541. if (lastkindex == 0)
  542. {
  543. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  544. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  545. }
  546. else
  547. {
  548. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  549. }
  550. entity.seller_memo = prememo + newlastmemo;
  551. }
  552. entity.IsUrgency = true;
  553. entity.Update();
  554. ApiVo apiVo = new ApiVo();
  555. apiVo.orderNumber = entity.ctid;
  556. apiVo.actionName = "changeDesign";
  557. apiVo.orderRemarks = entity.seller_memo;
  558. apiVo.remarkSign = 3;
  559. designHelper.API_WorkCore(apiVo); //changeDesign
  560. CeErpSukuraData.createInfo(entity.ctid, 7);
  561. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  562. returnSuccessMsg("设置成功!");
  563. return;
  564. }
  565. returnErrorMsg("找不到记录");
  566. }
  567. }
  568. public void set_erp_reset()
  569. {
  570. if (UrlPostParmsCheck("ctid"))
  571. {
  572. string eid = GetPostString("ctid");
  573. CeErpTradeCell entity = null;
  574. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  575. if (entity != null)
  576. {
  577. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  578. {
  579. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  580. {
  581. returnErrorMsg("财务要求已下单已发货无法重置");
  582. return;
  583. }
  584. }
  585. entity.IsUrgency = false;
  586. entity.seller_memo = "";
  587. entity.OtherMemo = "";
  588. entity.OrderState = 0;
  589. entity.IsReturn = 0;
  590. //entity.IsRefund = 0;
  591. entity.MemoOpt = 0;
  592. entity.AfterSaleState = 0;
  593. entity.AfterSaleResponsible = "";
  594. entity.AfterSaleUserId = 0;
  595. entity.IsNeedBill = 0;
  596. entity.CustomerUserId = 0;
  597. entity.DesignUserId = 0;
  598. entity.SupplierId = 0;
  599. entity.PlaceUserId = 0;
  600. entity.ptid = "";
  601. entity.IsSample = 0;
  602. entity.IsXianHuo = 0;
  603. entity.isDianziOrder = 0;
  604. entity.FinishPlaceTime = null;
  605. entity.Update();
  606. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  607. if (trade != null)
  608. {
  609. trade.seller_memo = "";
  610. trade.Update();
  611. }
  612. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  613. returnSuccessMsg("重置成功!");
  614. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  615. if (desginBill != null)
  616. {
  617. desginBill.isDel = 1;
  618. desginBill.Update();
  619. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  620. }
  621. ApiVo apiVo = new ApiVo();
  622. apiVo.orderNumber = entity.ctid;
  623. apiVo.actionName = "resetDesign";
  624. designHelper.API_WorkCore(apiVo);//resetDesign
  625. return;
  626. }
  627. returnErrorMsg("找不到记录");
  628. }
  629. }
  630. public void save_erp_sellermemo()
  631. {
  632. if (UrlPostParmsCheck("ctid"))
  633. {
  634. string ctid = GetPostString("ctid");
  635. CeErpTradeCell entity = null;
  636. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  637. if (entity != null)
  638. {
  639. string memo = GetPostString("seller_memo");
  640. memo = memo.Replace(" ", "");
  641. if (memo.Contains("补差"))
  642. {
  643. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  644. return;
  645. }
  646. if (entity.seller_memo != memo)
  647. {
  648. if (entity.IsSample == 2)
  649. {
  650. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  651. return;
  652. }
  653. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  654. {
  655. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  656. {
  657. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  658. return;
  659. }
  660. }
  661. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  662. }
  663. commonHelper.getCytPrice(entity);
  664. int memoopt = GetPostInt("MemoOpt");
  665. Boolean ismemoopt = false;
  666. if (memoopt > 0)
  667. {
  668. string stropt = "";
  669. if (memoopt == 1)
  670. {
  671. stropt = "“改稿”";
  672. ismemoopt = true;
  673. }
  674. else if (memoopt == 2)
  675. {
  676. stropt = "“定稿”";
  677. }
  678. else if (memoopt == 3)
  679. {
  680. stropt = "“查货”";
  681. CeErpSukuraData.createInfo(entity.ctid, 6);
  682. }
  683. entity.MemoOpt = Convert.ToInt32(memoopt);
  684. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  685. }
  686. if (entity.OrderState < 5)
  687. {
  688. memo = memo.Replace("(", "(");
  689. memo = memo.Replace(")", ")");
  690. }
  691. entity.seller_memo = memo;
  692. entity.Update();
  693. ApiVo apiVo = new ApiVo();
  694. apiVo.orderNumber = entity.ctid;
  695. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  696. apiVo.orderRemarks = memo;
  697. apiVo.remarkSign = memoopt;
  698. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  699. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  700. returnSuccessMsg("保存成功!");
  701. return;
  702. }
  703. returnErrorMsg("找不到记录");
  704. }
  705. }
  706. public void ins_erp_checkorder()
  707. {
  708. if (UrlPostParmsCheck("ctid"))
  709. {
  710. string ctid = GetPostString("ctid");
  711. CeErpTradeCell entity = null;
  712. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  713. if (entity != null)
  714. {
  715. if (entity.OrderState < 6)
  716. {
  717. returnErrorMsg("下单完成后才可查货");
  718. return;
  719. }
  720. /*if (entity.OrderState > 6)
  721. {
  722. returnErrorMsg("订单已发货");
  723. return;
  724. }*/
  725. if (entity.FinishPlaceTime != null)
  726. {
  727. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  728. {
  729. returnErrorMsg("下单时间不足,无法查货");
  730. return;
  731. }
  732. }
  733. entity.MemoOpt = 3;
  734. entity.CheckOrderTime = DateTime.Now;
  735. entity.Update();
  736. CeErpSukuraData.createInfo(entity.ctid, 6);
  737. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  738. returnSuccessMsg("操作成功!");
  739. return;
  740. }
  741. returnErrorMsg("找不到记录");
  742. }
  743. }
  744. public void save_erp_othermemo()
  745. {
  746. if (UrlPostParmsCheck("ctid"))
  747. {
  748. string ctid = GetPostString("ctid");
  749. CeErpTradeCell entity = null;
  750. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  751. if (entity != null)
  752. {
  753. entity.OtherMemo = GetPostString("otherMemo");
  754. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  755. {
  756. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  757. StringBuilder sql = new StringBuilder();
  758. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  759. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  760. if (dt != null && dt.Rows.Count > 0)
  761. {
  762. foreach (DataRow dr in dt.Rows)
  763. {
  764. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  765. {
  766. //品类一直
  767. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  768. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  769. if (ceErpSampleCustomer == null)
  770. {
  771. ceErpSampleCustomer = new CeErpSampleCustomer();
  772. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  773. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  774. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  775. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  776. ceErpSampleCustomer.shopId = entity.ShopId;
  777. }
  778. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  779. ceErpSampleCustomer.lastTid = entity.tid;
  780. if (ceErpSampleCustomer.ID > 0)
  781. {
  782. ceErpSampleCustomer.Update();
  783. }
  784. else
  785. {
  786. ceErpSampleCustomer.Create();
  787. }
  788. }
  789. }
  790. }
  791. }
  792. //if (entity.IsOldCustomer == 1)
  793. //{
  794. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  795. //{
  796. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  797. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  798. //}
  799. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  800. //{
  801. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  802. // {
  803. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  804. // {
  805. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  806. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  807. // }
  808. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  809. // {
  810. // entity.OrderState = 2;
  811. // entity.DesignUserId = 0;
  812. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  813. // }
  814. // else
  815. // {
  816. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  817. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  818. // }
  819. // }
  820. //}
  821. //}
  822. entity.Update();
  823. returnSuccessMsg("保存成功!");
  824. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  825. return;
  826. }
  827. returnErrorMsg("找不到记录");
  828. }
  829. }
  830. public void save_erp_customermemo()
  831. {
  832. if (UrlPostParmsCheck("ctid"))
  833. {
  834. string ctid = GetPostString("ctid");
  835. CeErpTradeCell entity = null;
  836. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  837. if (entity != null)
  838. {
  839. entity.CustomerMemo = GetPostString("CustomerMemo");
  840. entity.Update();
  841. ApiVo apiVo = new ApiVo();
  842. apiVo.orderNumber = entity.ctid;
  843. apiVo.actionName = "followRemarks";
  844. apiVo.orderRemarks = entity.CustomerMemo;
  845. designHelper.API_WorkCore(apiVo);//followRemarks
  846. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  847. returnSuccessMsg("保存成功!");
  848. return;
  849. }
  850. returnErrorMsg("找不到记录");
  851. }
  852. }
  853. public void upd_erp_addmemotag()
  854. {
  855. if (UrlPostParmsCheck("ctid"))
  856. {
  857. ;
  858. string eid = GetPostString("ctid");
  859. string sfTagstr = GetPostString("memotag");
  860. CeErpTradeCell entity = null;
  861. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  862. if (entity != null)
  863. {
  864. if (entity.OrderState == 0)
  865. {
  866. returnErrorMsg("请先领单");
  867. return;
  868. }
  869. //撤销顺丰
  870. if (sfTagstr == "撤销顺丰")
  871. {
  872. entity.IsSF = 0;
  873. string reMsg = "";
  874. string oldmemo = entity.seller_memo;
  875. if (entity.OrderState < 5)
  876. {
  877. oldmemo = oldmemo.Replace("顺丰到付", "");
  878. oldmemo = oldmemo.Replace("顺丰寄付", "");
  879. entity.seller_memo = oldmemo;
  880. }
  881. else
  882. {
  883. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  884. {
  885. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  886. }
  887. }
  888. entity.Update();
  889. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  890. api.orderNumber = entity.ctid;
  891. api.actionName = "followRemarks";
  892. api.orderRemarks = entity.seller_memo;
  893. api.isSf = entity.IsSF.ToString();
  894. designHelper.API_WorkCore(api);//followRemarks
  895. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  896. returnSuccessMsg("撤销成功!" + reMsg);
  897. return;
  898. }
  899. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  900. {
  901. //string oldmemo = entity.seller_memo;
  902. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  903. string sfStr = GetPostString("memotag");
  904. string smemo = entity.seller_memo;
  905. int kindex = smemo.IndexOf(")");
  906. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  907. if (lastoneStr != "-")
  908. {
  909. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  910. }
  911. string prememo = smemo.Substring(0, kindex + 2);
  912. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  913. int lastkindex = lastmemo.IndexOf("(");
  914. string newlastmemo = "";
  915. if (lastkindex == 0)
  916. {
  917. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  918. newlastmemo = "(" + sfStr + "." + useLastmemo;
  919. }
  920. else
  921. {
  922. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  923. }
  924. entity.seller_memo = prememo + newlastmemo;
  925. }
  926. string sfTagMSg = "";
  927. if (sfTagstr == "顺丰寄付")
  928. {
  929. entity.IsSF = 1;
  930. sfTagMSg = "顺丰寄付";
  931. }
  932. else if (sfTagstr == "顺丰到付")
  933. {
  934. entity.IsSF = 2;
  935. sfTagMSg = "顺丰到付";
  936. }
  937. entity.Update();
  938. ApiVo apiVo = new ApiVo();
  939. apiVo.orderNumber = entity.ctid;
  940. apiVo.actionName = "orderRemarks";
  941. apiVo.orderRemarks = entity.seller_memo;
  942. apiVo.isSf = entity.IsSF.ToString();
  943. designHelper.API_WorkCore(apiVo);//orderRemarks
  944. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  945. returnSuccessMsg("标记成功!");
  946. return;
  947. }
  948. returnErrorMsg("找不到记录");
  949. }
  950. }
  951. public void upd_erp_ordertag()
  952. {
  953. if (UrlPostParmsCheck("ctid"))
  954. {
  955. string eid = GetPostString("ctid");
  956. CeErpTradeCell entity = null;
  957. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  958. if (entity != null)
  959. {
  960. int tag = GetPostInt("wechattag");
  961. //if(tag==4 && entity.IsSample == 2)
  962. //{
  963. // returnErrorMsg("补差价单不能标记微信单");
  964. // return;
  965. //}
  966. entity.wechatTag = tag;
  967. entity.Update();
  968. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  969. if (tag == 1)
  970. {
  971. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  972. if (cash == null)
  973. {
  974. CeErpTrade main = CeErpTrade.Get(entity.tid);
  975. cash = new CeErpReturnCash();
  976. cash.tid = entity.tid;
  977. cash.seller_nick = main.seller_nick;
  978. cash.payment = trade.payment;
  979. cash.buyer_nick = main.buyer_nick;
  980. cash.cashstate = 0;
  981. cash.rtype = "微信返现";
  982. cash.returnprice = 0;
  983. cash.created = DateTime.Now;
  984. cash.con = "订单标记微信单";
  985. cash.img = "";
  986. cash.applyuserid = CurrentUser.UserID;
  987. cash.Create();
  988. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  989. }
  990. else
  991. {
  992. cash.cashstate = 0;
  993. cash.Update();
  994. }
  995. CeErpSukuraData.createInfo(entity.ctid, 9);
  996. }
  997. else if (tag == 2)
  998. {
  999. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1000. if (cash == null)
  1001. {
  1002. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1003. cash = new CeErpReturnCash();
  1004. cash.tid = entity.tid;
  1005. cash.seller_nick = main.seller_nick;
  1006. cash.payment = trade.payment;
  1007. cash.buyer_nick = main.buyer_nick;
  1008. cash.cashstate = 0;
  1009. cash.rtype = "推购返现";
  1010. cash.returnprice = 5;
  1011. cash.created = DateTime.Now;
  1012. cash.con = "订单标记推购单";
  1013. cash.img = "";
  1014. cash.applyuserid = CurrentUser.UserID;
  1015. cash.Create();
  1016. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1017. }
  1018. else
  1019. {
  1020. cash.cashstate = 0;
  1021. cash.Update();
  1022. }
  1023. CeErpSukuraData.createInfo(entity.ctid, 9);
  1024. }
  1025. else if (tag == 3)
  1026. {
  1027. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1028. if (pers == null)
  1029. {
  1030. pers = new CeErpPersuade();
  1031. pers.ctid = entity.ctid;
  1032. pers.pstate = 0;
  1033. pers.created = DateTime.Now;
  1034. pers.applyuserid = CurrentUser.UserID;
  1035. pers.Create();
  1036. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1037. }
  1038. else
  1039. {
  1040. pers.pstate = 0;
  1041. pers.Update();
  1042. }
  1043. }
  1044. else if (tag == 4 || tag == 5)
  1045. {
  1046. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1047. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1048. if (pers == null)
  1049. {
  1050. pers = new CeErpStayGoods();
  1051. pers.t_id = entity.tid;
  1052. pers.status = "待审核";
  1053. pers.audit_type = 0;
  1054. if (tag == 4)
  1055. {
  1056. pers.stay_type = "微信推购";
  1057. }
  1058. else
  1059. {
  1060. pers.stay_type = "旺旺推购";
  1061. }
  1062. if (entity.IsXianHuo == 0)
  1063. {
  1064. pers.product_id = entity.ProductId;
  1065. }
  1066. pers.wangwang = main.buyer_nick;
  1067. pers.shop_name = main.seller_nick;
  1068. pers.creata_time = DateTime.Now;
  1069. pers.create_u_id = CurrentUser.UserID;
  1070. pers.create_u_name = CurrentUser.UserName;
  1071. pers.Create();
  1072. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1073. }
  1074. else
  1075. {
  1076. pers.audit_type = 0;
  1077. pers.Update();
  1078. }
  1079. CeErpSukuraData.createInfo(entity.ctid, 10);
  1080. }
  1081. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1082. returnSuccessMsg("标记成功!");
  1083. return;
  1084. }
  1085. returnErrorMsg("找不到记录");
  1086. }
  1087. }
  1088. public void upd_erp_ordertag_cancel()
  1089. {
  1090. if (UrlPostParmsCheck("ctid"))
  1091. {
  1092. string eid = GetPostString("ctid");
  1093. CeErpTradeCell entity = null;
  1094. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1095. if (entity != null)
  1096. {
  1097. entity.wechatTag = 0;
  1098. entity.Update();
  1099. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1100. if (pers != null)
  1101. {
  1102. pers.status = "取消推购";
  1103. pers.audit_type = 3;
  1104. pers.Update();
  1105. }
  1106. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1107. returnSuccessMsg("标记成功!");
  1108. return;
  1109. }
  1110. returnErrorMsg("找不到记录");
  1111. }
  1112. }
  1113. public void upd_erp_addweichattag()
  1114. {
  1115. if (UrlPostParmsCheck("ctid"))
  1116. {
  1117. ;
  1118. string eid = GetPostString("ctid");
  1119. CeErpTradeCell entity = null;
  1120. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1121. if (entity != null)
  1122. {
  1123. if (entity.IsAddWechat > 0)
  1124. {
  1125. returnErrorMsg("此单已经标记过了");
  1126. return;
  1127. }
  1128. 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);
  1129. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1130. if (dt.Rows.Count > 0)
  1131. {
  1132. entity.IsAddWechat = 2;
  1133. }
  1134. else
  1135. {
  1136. entity.IsAddWechat = 1;
  1137. }
  1138. entity.Update();
  1139. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1140. returnSuccessMsg("标记成功!");
  1141. return;
  1142. }
  1143. returnErrorMsg("找不到记录");
  1144. }
  1145. }
  1146. public void upd_erp_getmyorder()
  1147. {
  1148. if (UrlPostParmsCheck("ctid"))
  1149. {
  1150. ;
  1151. string eid = GetPostString("ctid");
  1152. CeErpTradeCell entity = null;
  1153. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1154. if (entity != null)
  1155. {
  1156. if (entity.ctid.IndexOf("C") != -1)
  1157. {
  1158. StringBuilder sql = new StringBuilder();
  1159. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1160. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1161. if (dt.Rows.Count > 0)
  1162. {
  1163. decimal total = 0;
  1164. foreach (DataRow dr in dt.Rows)
  1165. {
  1166. total += Convert.ToDecimal(dr["payment"]);
  1167. }
  1168. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1169. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1170. {
  1171. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1172. return;
  1173. }
  1174. }
  1175. }
  1176. entity.CustomerUserId = CurrentUser.UserID;
  1177. if (entity.OrderState < 2)
  1178. {
  1179. entity.OrderState = 2;
  1180. if (entity.ShopId != 0)
  1181. {
  1182. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1183. }
  1184. }
  1185. entity.Update();
  1186. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1187. returnSuccessMsg("领单成功!");
  1188. return;
  1189. }
  1190. returnErrorMsg("找不到记录");
  1191. }
  1192. }
  1193. public void getmyorder_from_init()
  1194. {
  1195. if (UrlPostParmsCheck("ctid"))
  1196. {
  1197. string eid = GetPostString("ctid");
  1198. CeErpTradeCell entity = null;
  1199. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1200. if (entity != null)
  1201. {
  1202. string sellerMemo = GetPostString("sellerMemo");
  1203. if (sellerMemo.Length > 0)
  1204. {
  1205. entity.seller_memo = sellerMemo;
  1206. }
  1207. string oterhMemo = GetPostString("otherMemo");
  1208. if (oterhMemo.Length > 0)
  1209. {
  1210. entity.OtherMemo = oterhMemo;
  1211. }
  1212. int urg = GetPostInt("urgency");
  1213. entity.IsUrgency = (urg == 1 ? true : false);
  1214. int wechat = GetPostInt("wechat");
  1215. int command = GetPostInt("command");
  1216. if (wechat == 1)
  1217. {
  1218. entity.wechatTag = 1;
  1219. }
  1220. if (command == 1)
  1221. {
  1222. entity.wechatTag = 2;
  1223. }
  1224. string pPro = GetPostString("pprofession");
  1225. if (pPro.Length > 0)
  1226. {
  1227. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1228. string spro = GetPostString("profession");
  1229. if (spro.Length > 0)
  1230. {
  1231. entity.ProfessionId = Convert.ToInt32(spro);
  1232. }
  1233. }
  1234. string proId = GetPostString("productId");
  1235. if (proId.Length > 0)
  1236. {
  1237. entity.ProductId = Convert.ToInt32(proId);
  1238. }
  1239. entity.Material = GetPostString("material");
  1240. entity.Craft = GetPostString("craft");
  1241. entity.CustomerUserId = CurrentUser.UserID;
  1242. if (entity.OrderState < 2)
  1243. {
  1244. entity.OrderState = 2;
  1245. if (entity.ShopId != 0)
  1246. {
  1247. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1248. }
  1249. }
  1250. entity.Update();
  1251. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1252. returnSuccessMsg("领单成功!");
  1253. return;
  1254. }
  1255. returnErrorMsg("找不到记录");
  1256. }
  1257. }
  1258. public void upd_erp_setrelationorder()
  1259. {
  1260. if (UrlPostParmsCheck("ctid"))
  1261. {
  1262. ;
  1263. string eid = GetPostString("ctid");
  1264. string ftid = GetPostString("ftid");
  1265. CeErpTradeCell entity = null;
  1266. CeErpTradeCell fentity = null;
  1267. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1268. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1269. if (fentity == null)
  1270. {
  1271. returnErrorMsg("找不到关联的主订单");
  1272. return;
  1273. }
  1274. if (entity != null)
  1275. {
  1276. if (entity.OrderState >= 5)
  1277. {
  1278. returnErrorMsg("本单已经设计完成无法关联");
  1279. return;
  1280. }
  1281. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1282. {
  1283. returnErrorMsg("线下单续审核后才能关联!");
  1284. return;
  1285. }
  1286. entity.ptid = ftid;
  1287. entity.OrderState = fentity.OrderState;
  1288. //entity.status = fentity.status;
  1289. entity.CustomerUserId = fentity.CustomerUserId;
  1290. entity.DesignUserId = fentity.DesignUserId;
  1291. entity.seller_memo = "补差价单:" + ftid;
  1292. entity.IsSample = 2;
  1293. entity.Update();
  1294. ApiVo apiVo = new ApiVo();
  1295. apiVo.orderNumber = ftid;
  1296. apiVo.payment = entity.payment;
  1297. apiVo.actionName = "repairDesign";
  1298. designHelper.API_WorkCore(apiVo);//repairDesign
  1299. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1300. returnSuccessMsg("关联成功!");
  1301. return;
  1302. }
  1303. else
  1304. returnErrorMsg("找不到记录");
  1305. }
  1306. }
  1307. public void download_erp_neworder()
  1308. {
  1309. string seller = GetPostString("seller_nick");
  1310. string tid = GetPostString("tid");
  1311. if (seller.Length <= 0 || tid.Length <= 0)
  1312. {
  1313. returnErrorMsg("数据错误");
  1314. }
  1315. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1316. //{
  1317. // returnErrorMsg("找不到店铺Sessionkey");
  1318. //}
  1319. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1320. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1321. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1322. if (res.IndexOf("refOid") == -1)
  1323. {
  1324. returnErrorMsg("下载订单数据失败");
  1325. return;
  1326. }
  1327. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1328. returnSuccessMsg("下载完成");
  1329. //tmcHelper.createNewOrder(res);
  1330. //CeErpTrade entr = null;
  1331. //entr = CeErpTrade.Get(tid);
  1332. //if (entr != null)
  1333. //{
  1334. // returnSuccess("下载成功");
  1335. // //下载成功之后,Cell表生成对应的订单;
  1336. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1337. //}
  1338. //else
  1339. //{
  1340. // returnErrorMsg("下载失败或者创建订单失败");
  1341. //}
  1342. }
  1343. public void set_erp_atersale()
  1344. {
  1345. if (UrlPostParmsCheck("ctid"))
  1346. {
  1347. string eid = GetPostString("ctid");
  1348. string reason = GetPostString("AfterSaleReason");
  1349. CeErpTradeCell entity = null;
  1350. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1351. if (entity != null)
  1352. {
  1353. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1354. {
  1355. returnErrorMsg("此订单已经在售后");
  1356. return;
  1357. }
  1358. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1359. //entity.AfterSaleReason = reason;
  1360. entity.AfterSaleTime = DateTime.Now;
  1361. entity.Update();
  1362. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1363. returnSuccessMsg("转售后成功!");
  1364. return;
  1365. }
  1366. returnErrorMsg("找不到记录");
  1367. }
  1368. }
  1369. public void set_erp_withdraw()
  1370. {
  1371. if (UrlPostParmsCheck("ctid"))
  1372. {
  1373. try
  1374. {
  1375. string eid = GetPostString("ctid");//商品id
  1376. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1377. CeWithdraw ceWithdrawSelect = null;
  1378. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1379. if (ceWithdrawSelect != null)
  1380. {
  1381. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1382. {
  1383. ceWithdrawSelect.status = -1;
  1384. ceWithdrawSelect.Update();
  1385. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1386. returnSuccessMsg("重新发起审核成功");
  1387. return;
  1388. }
  1389. else
  1390. {
  1391. returnSuccessMsg("请勿重复申请!");
  1392. return;
  1393. }
  1394. }
  1395. else
  1396. {
  1397. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1398. if (string.IsNullOrEmpty(CustomerUserId))
  1399. {
  1400. CustomerUserId = "-1";
  1401. }
  1402. int Userid = CurrentUser.UserID;//用户id
  1403. CeWithdraw ceWithdraw = new CeWithdraw();
  1404. ceWithdraw.tid = eid;
  1405. ceWithdraw.userid = Userid;
  1406. ceWithdraw.providerid = CustomerUserId;
  1407. ceWithdraw.status = 3;
  1408. ceWithdraw.creationtime = DateTime.Now;
  1409. ceWithdraw.Create();
  1410. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1411. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1412. return;
  1413. }
  1414. }
  1415. catch
  1416. {
  1417. returnErrorMsg("申请撤回订单失败");
  1418. return;
  1419. }
  1420. }
  1421. }
  1422. public void ins_erp_billinfo()
  1423. {
  1424. if (UrlPostParmsCheck("ctid"))
  1425. {
  1426. string eid = GetPostString("ctid");
  1427. CeErpTradeCell entity = null;
  1428. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1429. if (entity != null)
  1430. {
  1431. CeErpBill bill = CeErpBill.GetByTid(eid);
  1432. bool isHave = false;
  1433. if (bill != null)
  1434. {
  1435. isHave = true;
  1436. if (bill.state != 4)
  1437. {
  1438. returnErrorMsg("此单已经申请过发票了");
  1439. return;
  1440. }
  1441. }
  1442. if (entity.IsNeedBill == 0)
  1443. {
  1444. entity.IsNeedBill = 1;
  1445. }
  1446. entity.Update();
  1447. string errjson = "";
  1448. try
  1449. {
  1450. CeErpBill bill_entity = new CeErpBill();
  1451. bill_entity.tid = entity.tid;
  1452. bill_entity.title = GetPostString("title");
  1453. string taxstr = GetPostString("tax");
  1454. taxstr = taxstr.Replace(" ", "");
  1455. bill_entity.tax = taxstr;
  1456. bill_entity.bank = GetPostString("bank");
  1457. string bankacstr = GetPostString("bankac");
  1458. bankacstr = bankacstr.Replace(" ", "");
  1459. bill_entity.bankac = bankacstr;
  1460. bill_entity.address = GetPostString("address");
  1461. bill_entity.phone = GetPostString("phone");
  1462. bill_entity.price = GetPostString("price");
  1463. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1464. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1465. {
  1466. billCount += 1;
  1467. }
  1468. string prebill = "ltb";
  1469. for (int idx = 1; idx <= billCount; idx++)
  1470. {
  1471. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1472. string billoid = prebill + idx + dtstr;
  1473. bill_entity.billOrderId += billoid;
  1474. if (idx < billCount)
  1475. {
  1476. bill_entity.billOrderId += ",";
  1477. }
  1478. }
  1479. bill_entity.productId = GetPostInt("ProductName");
  1480. bill_entity.num = GetPostInt("num");
  1481. bill_entity.unit = GetPostString("unit");
  1482. bill_entity.type = GetPostString("type");
  1483. bill_entity.sendType = GetPostString("SendType");
  1484. bill_entity.email = GetPostString("email");
  1485. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1486. bill_entity.shopName = GetPostString("ShopName");
  1487. bill_entity.applymemo = GetPostString("applyMemo");
  1488. bill_entity.createTime = DateTime.Now;
  1489. bill_entity.state = 0;
  1490. bill_entity.userId = CurrentUser.UserID;
  1491. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1492. bill_entity.Create();
  1493. }
  1494. catch (Exception ex)
  1495. {
  1496. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1497. returnErrorMsg("创建发票出错!");
  1498. return;
  1499. }
  1500. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1501. returnSuccessMsg("发票申请成功!");
  1502. return;
  1503. }
  1504. returnErrorMsg("找不到记录");
  1505. }
  1506. }
  1507. public void ins_erp_neworder()
  1508. {
  1509. if (UrlPostParmsCheck("receiver_name"))
  1510. {
  1511. CeErpTrade entity = new CeErpTrade();
  1512. string plat_form = GetPostString("platform");
  1513. string preStr = "N_";
  1514. if (plat_form == "拼多多")
  1515. {
  1516. preStr = "P_";
  1517. }
  1518. else if (plat_form == "阿里巴巴")
  1519. {
  1520. preStr = "A_";
  1521. }
  1522. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1523. entity.seller_nick = GetPostString("seller_nick");
  1524. entity.buyer_nick = GetPostString("buyer_nick");
  1525. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1526. entity.total_fee = entity.payment;
  1527. entity.pay_time = DateTime.Now;
  1528. entity.status = "NOT_SHIPPED";
  1529. entity.receiver_name = GetPostString("receiver_name");
  1530. entity.receiver_mobile = GetPostString("receiver_mobile");
  1531. entity.receiver_state = GetPostString("receiver_state");
  1532. entity.receiver_city = GetPostString("receiver_city");
  1533. entity.receiver_district = GetPostString("receiver_district");
  1534. entity.receiver_address = GetPostString("receiver_address");
  1535. if (entity.receiver_state == "" || entity.receiver_city == "")
  1536. {
  1537. returnErrorMsg("收件地址不能为空");
  1538. return;
  1539. }
  1540. int shopId = 0;
  1541. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1542. if (nShop != null)
  1543. {
  1544. shopId = nShop.ID;
  1545. }
  1546. if (shopId != 34 && entity.payment == 0)
  1547. {
  1548. returnErrorMsg("公司自用的单金额才能为0");
  1549. return;
  1550. }
  1551. entity.Create();
  1552. CeErpTradeCell entitycell = new CeErpTradeCell();
  1553. entitycell.ctid = entity.tid;
  1554. entitycell.tid = entity.tid;
  1555. entitycell.ShopId = shopId;
  1556. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1557. entitycell.OrderState = 0;
  1558. entitycell.pay_time = entity.pay_time;
  1559. entitycell.IsOffLineOrder = 1;
  1560. entitycell.Create();
  1561. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1562. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1563. return;
  1564. }
  1565. }
  1566. public void ins_erp_neworder2()
  1567. {
  1568. if (UrlPostParmsCheck("receiver_name"))
  1569. {
  1570. //string plat_form = GetPostString("platform");
  1571. string preStr = "X_";
  1572. string memo = GetPostString("memo");
  1573. string productId = GetPostString("productId");
  1574. string primg = GetPostString("proofimg");
  1575. string sellerNick = GetPostString("seller_nick");
  1576. string addFrom = GetPostString("addfrom");
  1577. if (addFrom == "1")
  1578. {
  1579. preStr = "N_";
  1580. }
  1581. int shopId = 0;
  1582. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1583. if (nShop != null)
  1584. {
  1585. shopId = nShop.ID;
  1586. }
  1587. else
  1588. {
  1589. returnErrorMsg("找不到对应店铺");
  1590. return;
  1591. }
  1592. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1593. {
  1594. returnErrorMsg("必须上传付款凭证");
  1595. return;
  1596. }
  1597. CeErpTrade entity = new CeErpTrade();
  1598. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1599. entity.seller_nick = sellerNick;
  1600. entity.buyer_nick = GetPostString("buyer_nick");
  1601. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1602. entity.total_fee = entity.payment;
  1603. entity.pay_time = DateTime.Now;
  1604. entity.status = "NOT_SHIPPED";
  1605. entity.receiver_name = GetPostString("receiver_name");
  1606. entity.receiver_mobile = GetPostString("receiver_mobile");
  1607. entity.receiver_state = GetPostString("receiver_state");
  1608. entity.receiver_city = GetPostString("receiver_city");
  1609. entity.receiver_district = GetPostString("receiver_district");
  1610. entity.receiver_address = GetPostString("receiver_address");
  1611. entity.seller_memo = memo;
  1612. entity.orderFrom = 20;
  1613. entity.orderType = 15;
  1614. if (entity.receiver_state == "" || entity.receiver_city == "")
  1615. {
  1616. returnErrorMsg("收件地址不能为空");
  1617. return;
  1618. }
  1619. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1620. {
  1621. returnErrorMsg("公司自用的单金额才能为0");
  1622. return;
  1623. }
  1624. entity.Create();
  1625. string toWhere = GetPostString("towhere");
  1626. CeErpTradeCell entitycell = new CeErpTradeCell();
  1627. entitycell.ctid = entity.tid;
  1628. //唯一标识
  1629. entitycell.OrderSn = entity.tid;
  1630. //string orderSn = dataHelper.getSaleOrderSn();
  1631. //if (orderSn != "")
  1632. // {
  1633. // entitycell.OrderSn = orderSn;
  1634. // }
  1635. entitycell.tid = entity.tid;
  1636. //if (preStr == "X_")
  1637. //{
  1638. entitycell.IsOffLineOrder = 1;
  1639. //}
  1640. entitycell.CustomerUserId = CurrentUser.UserID;
  1641. entitycell.PayProofImg = primg;
  1642. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1643. entitycell.ProductId = Convert.ToInt32(productId);
  1644. entitycell.ShopId = shopId;
  1645. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1646. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1647. {
  1648. entitycell.IsXianHuo = 1;
  1649. }
  1650. entitycell.pay_time = entity.pay_time;
  1651. if (toWhere == "1")
  1652. {
  1653. entitycell.OrderState = 2;
  1654. }
  1655. else
  1656. {
  1657. entitycell.OrderState = 6;
  1658. entitycell.FinishPlaceTime = entitycell.pay_time;
  1659. }
  1660. if (shopId == 94)
  1661. {
  1662. entitycell.OrderState = 4;
  1663. entitycell.WaitDesignTime = entitycell.pay_time;
  1664. entitycell.StartDesignTime = entitycell.pay_time;
  1665. entitycell.DesignUserId = 218;
  1666. }
  1667. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1668. {
  1669. entitycell.OrderState = -1;//修改12-5
  1670. CeWithdraw ceWithdraw = new CeWithdraw();
  1671. ceWithdraw.tid = entity.tid;
  1672. ceWithdraw.providerid = "-1";
  1673. ceWithdraw.status = -1;
  1674. ceWithdraw.creationtime = DateTime.Now;
  1675. ceWithdraw.userid = 1337;
  1676. ceWithdraw.Create();
  1677. }
  1678. entitycell.Create();
  1679. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1680. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1681. {
  1682. addPlaceRegist(entitycell, CurrentUser.UserID);
  1683. }
  1684. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1685. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1686. return;
  1687. }
  1688. }
  1689. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1690. {
  1691. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1692. entity.PlactTime = tradecell.pay_time;
  1693. entity.AddUserId = userid;
  1694. entity.FileName = tradecell.seller_memo;
  1695. entity.Supplier = 24;
  1696. entity.CreateTime = DateTime.Now;
  1697. entity.Did = tradecell.ctid;
  1698. entity.tid = tradecell.tid;
  1699. entity.splitTag = tradecell.SplitTag;
  1700. entity.CurState = "未完成";
  1701. entity.Create();
  1702. }
  1703. public void get_erp_offlinelist()
  1704. {
  1705. DataStruct dStruct = GetPostStruct();
  1706. List<string> lw = new List<string>();
  1707. string tid = GetPostString("ctid");
  1708. string date1 = GetPostString("date1");
  1709. string date2 = GetPostString("date2");
  1710. if (tid.Length > 0 || date1.Length > 0)
  1711. {
  1712. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1713. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1714. if (dw.Length > 0) lw.Add(dw);
  1715. }
  1716. else
  1717. {
  1718. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1719. }
  1720. string shopname = GetPostString("shopname");
  1721. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1722. string buyernick = GetPostString("buyer_nick");
  1723. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1724. string customer = GetPostString("customer");
  1725. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1726. string design = GetPostString("design");
  1727. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1728. string orderState = GetPostString("orderState");
  1729. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1730. string address = GetPostString("address");
  1731. 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));
  1732. string sellermemo = GetPostString("seller_memo");
  1733. if (sellermemo.Length > 0)
  1734. {
  1735. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1736. }
  1737. string price1 = GetPostString("price1");
  1738. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1739. string price2 = GetPostString("price2");
  1740. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1741. //if (PKey != "admin")
  1742. //{
  1743. // string usershop = CurrentUser.User.pemShop;
  1744. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1745. //}
  1746. //if (ex_psize > 0)
  1747. //{
  1748. dStruct.Order = "pay_time desc";
  1749. //}
  1750. //else
  1751. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1752. lw.Add(string.Format("IsOffLineOrder=1"));
  1753. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1754. DataTable dt = null;
  1755. dt = WebCache.GetData("view_erptradecell", dStruct);
  1756. writeGridDataTableJson(dStruct.TotalCount, dt);
  1757. }
  1758. public void get_erp_returncashrecord()
  1759. {
  1760. DataStruct dStruct = GetPostStruct();
  1761. List<string> lw = new List<string>();
  1762. string tid = GetPostString("ctid");
  1763. if (tid.Length > 0)
  1764. {
  1765. lw.Add(string.Format("tid like '%{0}%'", tid));
  1766. dStruct.Order = "id desc";
  1767. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1768. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1769. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1770. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1771. return;
  1772. }
  1773. returnErrorMsg("id数据错误!");
  1774. }
  1775. public void ins_erp_returncashrecord()
  1776. {
  1777. if (UrlPostParmsCheck("tid"))
  1778. {
  1779. string tid = GetPostString("tid");
  1780. string retype = GetPostString("type");
  1781. StringBuilder sql = new StringBuilder();
  1782. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1783. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1784. if (dt.Rows.Count > 0)
  1785. {
  1786. returnErrorMsg("相同返现类型记录已存在");
  1787. return;
  1788. }
  1789. CeErpReturnCash entity = new CeErpReturnCash();
  1790. entity.tid = tid;
  1791. entity.seller_nick = GetPostString("seller_nick");
  1792. string pment = GetPostString("payment");
  1793. if (pment.Length > 0)
  1794. {
  1795. entity.payment = Convert.ToDouble(pment);
  1796. }
  1797. entity.buyer_nick = GetPostString("buyer_nick");
  1798. entity.cashstate = 0;
  1799. entity.rtype = retype;
  1800. string rPrice = GetPostString("returnprice");
  1801. if (rPrice.Length > 0)
  1802. {
  1803. entity.returnprice = Convert.ToDouble(rPrice);
  1804. }
  1805. entity.created = DateTime.Now;
  1806. entity.con = GetPostString("con");
  1807. entity.img = GetPostString("img");
  1808. entity.applyuserid = CurrentUser.UserID;
  1809. entity.Create();
  1810. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1811. returnSuccessMsg("操作成功!");
  1812. return;
  1813. }
  1814. }
  1815. public void set_erp_predelivery()
  1816. {
  1817. if (UrlPostParmsCheck("ctid"))
  1818. {
  1819. string eid = GetPostString("ctid");
  1820. CeErpTradeCell entity = null;
  1821. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1822. if (entity != null)
  1823. {
  1824. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1825. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1826. //{
  1827. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1828. // return;
  1829. //}
  1830. entity.IsPreDelivery = 1;
  1831. entity.Update();
  1832. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1833. returnSuccessMsg("预发货成功!");
  1834. return;
  1835. //string shop = GetPostString("seller_nick");
  1836. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1837. //string comName = GetPostString("comName");
  1838. //string comCode = GetPostString("comCode");
  1839. //string outSid = GetPostString("outSid");//运单号
  1840. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1841. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1842. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1843. //string apires = "";
  1844. //if (deliveryType == "虚拟发货")
  1845. //{
  1846. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1847. //}
  1848. //else
  1849. //{
  1850. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1851. //}
  1852. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1853. ////{
  1854. //if (apires.IndexOf("发货成功") != -1)
  1855. //{
  1856. // if (deliveryType != "虚拟发货")
  1857. // {
  1858. // //还要插入快递信息到 快递信息表
  1859. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1860. // exinfo.tid = eid;
  1861. // exinfo.out_sid = outSid;
  1862. // exinfo.company_code = comCode;
  1863. // exinfo.company_name = comName;
  1864. // exinfo.delivery_memo = deliveryMemo;
  1865. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1866. // exinfo.deliveryType = deliveryType;
  1867. // exinfo.Create();
  1868. // }
  1869. // returnSuccessMsg("发货成功!");
  1870. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1871. //}
  1872. //else
  1873. //{
  1874. // returnErrorMsg("淘宝发货失败!!");
  1875. //}
  1876. //return;
  1877. }
  1878. returnErrorMsg("找不到订单记录");
  1879. }
  1880. }
  1881. public void get_erp_unusuallist()
  1882. {
  1883. DataStruct dStruct = GetPostStruct();
  1884. List<string> lw = new List<string>();
  1885. string tid = GetPostString("ctid");
  1886. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1887. string shopname = GetPostString("shopname");
  1888. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1889. string buyernick = GetPostString("buyer_nick");
  1890. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1891. string ResponsibleMan = GetPostString("responsible");
  1892. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1893. string date1 = GetPostString("date1");
  1894. string date2 = GetPostString("date2");
  1895. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1896. if (dw.Length > 0) lw.Add(dw);
  1897. string price1 = GetPostString("price1");
  1898. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1899. string price2 = GetPostString("price2");
  1900. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1901. string orderState = GetPostString("orderState");
  1902. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1903. string sellermemo = GetPostString("seller_memo");
  1904. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1905. lw.Add(string.Format("UnusualTag > 0"));
  1906. lw.Add(string.Format("IsRefund<={0}", 1));
  1907. dStruct.Order = "pay_time desc";
  1908. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1909. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1910. writeGridDataTableJson(dStruct.TotalCount, dt);
  1911. }
  1912. public void set_erp_unusualtonomal()
  1913. {
  1914. if (UrlPostParmsCheck("ctid"))
  1915. {
  1916. string eid = GetPostString("ctid");
  1917. CeErpTradeCell entity = null;
  1918. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1919. if (entity != null)
  1920. {
  1921. entity.UnusualTag = -1;
  1922. entity.Update();
  1923. returnSuccessMsg("忽略成功!");
  1924. return;
  1925. }
  1926. returnErrorMsg("找不到记录");
  1927. }
  1928. }
  1929. public void ins_erp_unusualreason()
  1930. {
  1931. if (UrlPostParmsCheck("ctid"))
  1932. {
  1933. string eid = GetPostString("ctid");
  1934. CeErpTradeCell entity = null;
  1935. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1936. if (entity != null)
  1937. {
  1938. entity.MemoOpt = 4;
  1939. entity.UnusualCon = GetPostString("con");
  1940. entity.Update();
  1941. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1942. if (trade != null)
  1943. {
  1944. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1945. }
  1946. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1947. returnSuccessMsg("操作成功!");
  1948. return;
  1949. }
  1950. returnErrorMsg("找不到记录");
  1951. }
  1952. }
  1953. public void upd_erp_sampleorder()
  1954. {
  1955. if (UrlPostParmsCheck("ctid"))
  1956. {
  1957. string eid = GetPostString("ctid");
  1958. string[] eArr = eid.Split(',');
  1959. if (eArr.Length > 1)
  1960. {
  1961. List<string> eLst = new List<string>();
  1962. for (int i = 0; i < eArr.Length; i++)
  1963. {
  1964. eLst.Add("'" + eArr[i] + "'");
  1965. }
  1966. eid = string.Join(",", eLst.ToArray());
  1967. }
  1968. else
  1969. {
  1970. eid = "'" + eid + "'";
  1971. }
  1972. StringBuilder sql = new StringBuilder();
  1973. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1974. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1975. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1976. if (dt.Rows.Count > 0)
  1977. {
  1978. string errmsg = "";
  1979. foreach (DataRow dr in dt.Rows)
  1980. {
  1981. StringBuilder sqlsb = new StringBuilder();
  1982. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  1983. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  1984. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  1985. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  1986. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  1987. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  1988. {
  1989. continue;
  1990. }
  1991. else
  1992. {
  1993. string emsg = commonHelper.KeepChinese(apires);
  1994. errmsg += emsg;
  1995. }
  1996. }
  1997. if (errmsg.Length > 0)
  1998. {
  1999. returnErrorMsg(errmsg);
  2000. return;
  2001. }
  2002. returnSuccessMsg("操作成功");
  2003. return;
  2004. }
  2005. returnErrorMsg("找不到记录");
  2006. }
  2007. }
  2008. public void upd_erp_transcustomer()
  2009. {
  2010. if (UrlPostParmsCheck("ctid"))
  2011. {
  2012. string eid = GetPostString("ctid");
  2013. int userid = GetPostInt("CustomerUserId");
  2014. CeErpTradeCell entity = null;
  2015. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2016. if (entity != null)
  2017. {
  2018. //string[] mlist = entity.seller_memo.Split('-');
  2019. //string sql = "select * from view_erpuser where id=" + userid;
  2020. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2021. //if (dt != null && dt.Rows.Count > 0)
  2022. //{
  2023. // string nmemo = "";
  2024. // for(int i = 0; i < mlist.Length - 1; i++)
  2025. // {
  2026. // nmemo += mlist[i];
  2027. // nmemo += "-";
  2028. // }
  2029. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2030. // entity.seller_memo = nmemo;
  2031. //}
  2032. entity.CustomerUserId = userid;
  2033. entity.Update();
  2034. returnSuccessMsg("操作成功!");
  2035. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2036. return;
  2037. }
  2038. returnErrorMsg("找不到记录");
  2039. }
  2040. }
  2041. public void upd_erp_transdesigner()
  2042. {
  2043. if (UrlPostParmsCheck("ctid"))
  2044. {
  2045. string eids = GetPostString("ctid");
  2046. string[] ctidList = eids.Split(',');
  2047. int userid = GetPostInt("DesignUserId");
  2048. foreach (string ctid in ctidList)
  2049. {
  2050. CeErpTradeCell entity = null;
  2051. CeErpDesignerBill entitys = null;
  2052. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2053. entitys = CeErpDesignerBill.GetByTid(ctid);
  2054. if (entity != null)
  2055. {
  2056. if (entity.OrderState > 4)
  2057. {
  2058. continue;
  2059. }
  2060. //存在退款不能流转
  2061. if (entity.IsRefund > 0)
  2062. {
  2063. continue;
  2064. }
  2065. entity.DesignUserId = userid;
  2066. entity.WaitDesignTime = DateTime.Now;
  2067. entity.Update();
  2068. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2069. }
  2070. }
  2071. returnSuccessMsg("操作成功!");
  2072. }
  2073. }
  2074. public void upd_erp_distributedesigner()
  2075. {
  2076. if (UrlPostParmsCheck("ctid"))
  2077. {
  2078. string eid = GetPostString("ctid");
  2079. int userid = GetPostInt("DesignUserId");
  2080. string[] idlist = eid.Split(',');
  2081. if (idlist.Length <= 0)
  2082. {
  2083. returnErrorMsg("订单不能为空");
  2084. return;
  2085. }
  2086. foreach (string ctid in idlist)
  2087. {
  2088. CeErpTradeCell entity = null;
  2089. CeErpDesignerBill entitys = null;
  2090. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2091. else continue;
  2092. if (entity != null)
  2093. {
  2094. if (userid == 2125 || userid == 3542)
  2095. { }
  2096. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2097. {
  2098. returnErrorMsg("金额错误的订单无法指派");
  2099. return;
  2100. }
  2101. if (entity.OrderState >= 5)
  2102. {
  2103. returnErrorMsg("已经设计完成无法指派");
  2104. return;
  2105. }
  2106. if (entity.OrderState == -1)
  2107. {
  2108. returnErrorMsg("审核中的订单无法指派");
  2109. return;
  2110. }
  2111. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2112. {
  2113. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2114. return;
  2115. }
  2116. if (entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize")
  2117. {
  2118. returnErrorMsg("指派设计共创无法再次指派!");
  2119. return;
  2120. }
  2121. entity.OrderState = 3;
  2122. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2123. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2124. {
  2125. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2126. entity.SupplierId = suid;
  2127. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2128. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2129. }
  2130. if (userid == 2125 && entity.seller_memo != "")
  2131. {
  2132. apiDesign.API_GetPrintData_CreateOrder(entity);
  2133. }
  2134. if (userid == 3542 && entity.seller_memo != "")
  2135. {
  2136. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2137. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2138. if (response.msg != "设计共创:成功")
  2139. {
  2140. returnErrorMsg(response.msg);
  2141. return;
  2142. }
  2143. entity.DispatchSort = 2;
  2144. entity.OrderState = 3;
  2145. }
  2146. entity.DesignUserId = userid;
  2147. entity.WaitDesignTime = DateTime.Now;
  2148. entity.Update();
  2149. string name = commonHelper.getUserNameById(userid);
  2150. commonHelper.UpdateRelationOrder(entity.ctid);
  2151. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2152. }
  2153. }
  2154. returnSuccessMsg("操作成功!");
  2155. return;
  2156. }
  2157. }
  2158. public void get_erp_myorderlist()
  2159. {
  2160. DataStruct dStruct = GetPostStruct();
  2161. List<string> lw = new List<string>();
  2162. string tid = GetPostString("ctid");
  2163. if (tid.Length > 0)
  2164. {
  2165. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2166. }
  2167. else
  2168. {
  2169. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2170. }
  2171. //12-1 修改
  2172. string urgent = GetPostString("urgent");
  2173. string back = GetPostString("back");
  2174. string offlineSearch = GetPostString("offlineSearch");
  2175. if (!string.IsNullOrWhiteSpace(urgent))
  2176. {
  2177. if (urgent.Equals("true"))
  2178. {
  2179. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2180. }
  2181. }
  2182. if (!string.IsNullOrWhiteSpace(back))
  2183. {
  2184. if (back.Equals("true"))
  2185. {
  2186. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2187. }
  2188. }
  2189. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2190. {
  2191. if (offlineSearch.Equals("true"))
  2192. {
  2193. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2194. }
  2195. }
  2196. //end
  2197. string shopname = GetPostString("shopname");
  2198. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2199. string buyernick = GetPostString("buyer_nick");
  2200. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2201. string design = GetPostString("design");
  2202. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2203. string orderState = GetPostString("orderState");
  2204. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2205. string sellermemo = GetPostString("seller_memo");
  2206. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2207. string date1 = GetPostString("date1");
  2208. string date2 = GetPostString("date2");
  2209. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2210. if (dw.Length > 0) lw.Add(dw);
  2211. string price1 = GetPostString("price1");
  2212. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2213. string price2 = GetPostString("price2");
  2214. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2215. string urgency = GetPostString("urgency");
  2216. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2217. string after = GetPostString("after");
  2218. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2219. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2220. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2221. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2222. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2223. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2224. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2225. if (dt != null && dt.Rows.Count > 0)
  2226. {
  2227. foreach (DataRow dr in dt.Rows)
  2228. {
  2229. try
  2230. {
  2231. // 对象操作
  2232. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2233. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2234. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2235. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2236. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2237. if (dStruct.PageSize != 100000)
  2238. {
  2239. if (dr["DispatchSort"].ToString() == "2")
  2240. {
  2241. dr["gongchuang"] = 200;
  2242. }
  2243. else
  2244. {
  2245. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2246. dr["gongchuang"] = response.code;
  2247. }
  2248. }
  2249. }
  2250. catch (NullReferenceException ex)
  2251. {
  2252. }
  2253. }
  2254. }
  2255. writeGridDataTableJson(dStruct.TotalCount, dt);
  2256. }
  2257. public void get_erp_myreturnorderlist()
  2258. {
  2259. DataStruct dStruct = GetPostStruct();
  2260. List<string> lw = new List<string>();
  2261. string tid = GetPostString("ctid");
  2262. if (tid.Length > 0)
  2263. {
  2264. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  2265. }
  2266. else
  2267. {
  2268. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2269. }
  2270. string shopname = GetPostString("shopname");
  2271. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2272. string buyernick = GetPostString("buyer_nick");
  2273. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2274. string design = GetPostString("design");
  2275. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2276. string orderState = GetPostString("orderState");
  2277. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2278. string sellermemo = GetPostString("seller_memo");
  2279. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2280. string date1 = GetPostString("date1");
  2281. string date2 = GetPostString("date2");
  2282. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2283. if (dw.Length > 0) lw.Add(dw);
  2284. string price1 = GetPostString("price1");
  2285. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2286. string price2 = GetPostString("price2");
  2287. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2288. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2289. {
  2290. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2291. }
  2292. else
  2293. {
  2294. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2295. }
  2296. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2297. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2298. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2299. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2300. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2301. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2302. if (dt != null && dt.Rows.Count > 0)
  2303. {
  2304. foreach (DataRow dr in dt.Rows)
  2305. {
  2306. try
  2307. {
  2308. // 对象操作
  2309. if (dStruct.PageSize != 100000)
  2310. {
  2311. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2312. dr["gongchuang"] = response.code;
  2313. }
  2314. }
  2315. catch (NullReferenceException ex)
  2316. {
  2317. // 处理空引用异常
  2318. }
  2319. }
  2320. }
  2321. writeGridDataTableJson(dStruct.TotalCount, dt);
  2322. }
  2323. public void get_erp_myorderlist_pregather()
  2324. {
  2325. string date1 = GetPostString("date1");
  2326. string date2 = GetPostString("date2");
  2327. int userId = CurrentUser.UserID; //客服id
  2328. string orderWhere = "";
  2329. List<string> lw = new List<string>();
  2330. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2331. if (dw.Length > 0) lw.Add(dw);
  2332. lw.Add(string.Format("CustomerUserId={0}", userId));
  2333. lw.Add(string.Format("OrderState<9"));
  2334. orderWhere = string.Join(" and ", lw.ToArray());
  2335. string orderWhere2 = "";
  2336. List<string> lw2 = new List<string>();
  2337. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2338. if (dw2.Length > 0) lw2.Add(dw2);
  2339. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2340. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2341. string sql = string.Format("select *" +
  2342. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2343. "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 " +
  2344. "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 " +
  2345. "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");
  2346. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2347. //writeGridDataTableJson(dt.Rows.Count, dt);
  2348. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2349. }
  2350. public void upd_erp_publishorder()
  2351. {
  2352. if (UrlPostParmsCheck("ctid"))
  2353. {
  2354. string eid = GetPostString("ctid");
  2355. CeErpTradeCell entity = null;
  2356. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2357. if (entity != null)
  2358. {
  2359. entity.OrderState = 0; //发布后,变为待抢单
  2360. entity.Update();
  2361. commonHelper.UpdateRelationOrder(entity.ctid);
  2362. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2363. returnSuccessMsg("发布成功!");
  2364. return;
  2365. }
  2366. returnErrorMsg("找不到记录");
  2367. }
  2368. }
  2369. public void get_erp_my_tiporder()
  2370. {
  2371. StringBuilder sql = new StringBuilder();
  2372. int userId = 0;
  2373. if (CurrentUser != null) userId = CurrentUser.UserID;
  2374. string posCode = CurrentUser.UserPost.Post.Code;
  2375. string isTipedAfterSaleVerify = GetPostString("af");
  2376. DataTable dt = new DataTable();
  2377. if (posCode != "Supplier")
  2378. {
  2379. if (posCode == "CustomerService" || posCode == "Director")
  2380. {
  2381. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2382. }
  2383. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2384. {
  2385. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2386. }
  2387. else
  2388. {
  2389. string teamIds = CurrentUser.User.TeamIds;
  2390. if (teamIds == "")
  2391. {
  2392. teamIds = "0";
  2393. }
  2394. 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);
  2395. }
  2396. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2397. }
  2398. if (dt.Rows.Count <= 0)
  2399. {
  2400. string key = "aftersale_order_" + userId;
  2401. if (RedisHelper.HasKey(key))
  2402. {
  2403. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2404. dt.Columns.Add("ctid", typeof(string));
  2405. dt.Columns.Add("IsReadTag", typeof(int));
  2406. foreach (var i in list)
  2407. {
  2408. DataRow data = dt.NewRow();
  2409. data["ctid"] = i;
  2410. data["IsReadTag"] = 4;
  2411. dt.Rows.Add(data);
  2412. }
  2413. RedisHelper.StringDelete(key);
  2414. }
  2415. }
  2416. if (dt.Rows.Count <= 0)
  2417. {
  2418. sql = new StringBuilder();
  2419. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2420. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2421. }
  2422. if (posCode == "Supplier")
  2423. {
  2424. string ids = CurrentUser.User.pemVend;
  2425. if (ids != null && ids.Length > 0)
  2426. {
  2427. string[] ids_list = ids.Split(',');
  2428. foreach (var item in ids_list)
  2429. {
  2430. string key = "return_order_" + item;
  2431. if (RedisHelper.HasKey(key))
  2432. {
  2433. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2434. dt.Columns.Add("ctid", typeof(string));
  2435. dt.Columns.Add("IsReadTag", typeof(int));
  2436. foreach (var i in list)
  2437. {
  2438. DataRow data = dt.NewRow();
  2439. data["ctid"] = i;
  2440. data["IsReadTag"] = 1;
  2441. dt.Rows.Add(data);
  2442. }
  2443. RedisHelper.StringDelete(key);
  2444. }
  2445. }
  2446. }
  2447. if (dt.Rows.Count <= 0)
  2448. {
  2449. sql = new StringBuilder();
  2450. 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);
  2451. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2452. }
  2453. }
  2454. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2455. }
  2456. public void reset_erp_tiporder()
  2457. {
  2458. string ids = GetPostString("ids");
  2459. string[] ctidList = ids.Split(',');
  2460. foreach (string ctid in ctidList)
  2461. {
  2462. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2463. if (enty != null)
  2464. {
  2465. enty.IsReadTag = 0;
  2466. enty.Update();
  2467. }
  2468. }
  2469. returnSuccessMsg("成功!");
  2470. return;
  2471. }
  2472. public void get_erp_designlist()
  2473. {
  2474. DataStruct dStruct = GetPostStruct();
  2475. List<string> lw = new List<string>();
  2476. string tid = GetPostString("ctid");
  2477. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  2478. string shopname = GetPostString("shopname");
  2479. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2480. string buyernick = GetPostString("buyer_nick");
  2481. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2482. string customer = GetPostString("customer");
  2483. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2484. string design = GetPostString("design");
  2485. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2486. string orderState = GetPostString("orderState");
  2487. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2488. lw.Add(string.Format("OrderState<6"));
  2489. string address = GetPostString("address");
  2490. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2491. string sellermemo = GetPostString("seller_memo");
  2492. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2493. string date1 = GetPostString("date1");
  2494. string date2 = GetPostString("date2");
  2495. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2496. if (dw.Length > 0) lw.Add(dw);
  2497. string apdate1 = GetPostString("apdate1");
  2498. string apdate2 = GetPostString("apdate2");
  2499. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2500. if (dwap.Length > 0) lw.Add(dwap);
  2501. string price1 = GetPostString("price1");
  2502. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2503. string price2 = GetPostString("price2");
  2504. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2505. string designTime = GetPostString("designtime");
  2506. if (designTime.Length > 0)
  2507. {
  2508. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2509. }
  2510. string usershop = CurrentUser.User.pemShop;
  2511. if (usershop.Length > 0)
  2512. {
  2513. lw.Add(string.Format("shopId in ({0})", usershop));
  2514. }
  2515. int myOrgid = CurrentUser.UserPost.OrgID;
  2516. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2517. if (myOrgCode.IndexOf("Designer") != -1)
  2518. {
  2519. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2520. {
  2521. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2522. }
  2523. else
  2524. {
  2525. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2526. }
  2527. }
  2528. else
  2529. {
  2530. string orgId = GetPostString("designerhd");
  2531. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2532. }
  2533. if (tid.Length > 0 || buyernick.Length > 0)
  2534. {
  2535. lw.Add(string.Format("OrderState >= 3"));
  2536. }
  2537. else
  2538. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2539. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2540. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2541. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2542. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2543. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2544. if (dt != null && dt.Rows.Count > 0)
  2545. {
  2546. foreach (DataRow dr in dt.Rows)
  2547. {
  2548. try
  2549. {
  2550. // 对象操作
  2551. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2552. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2553. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2554. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2555. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2556. if (dStruct.PageSize != 100000)
  2557. {
  2558. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2559. dr["gongchuang"] = response.code;
  2560. }
  2561. }
  2562. catch (NullReferenceException ex)
  2563. {
  2564. }
  2565. }
  2566. }
  2567. writeGridDataTableJson(dStruct.TotalCount, dt);
  2568. }
  2569. public void get_erp_mydesignlist()
  2570. {
  2571. DataStruct dStruct = GetPostStruct();
  2572. List<string> lw = new List<string>();
  2573. string tid = GetPostString("ctid");
  2574. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2575. string shopname = GetPostString("shopname");
  2576. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2577. string buyernick = GetPostString("buyer_nick");
  2578. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2579. string customer = GetPostString("customer");
  2580. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2581. string orderState = GetPostString("orderState");
  2582. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2583. //lw.Add(string.Format("OrderState<6"));
  2584. string date1 = GetPostString("date1");
  2585. string date2 = GetPostString("date2");
  2586. string dw = GetDateWhere("pay_time", date1, date2);
  2587. if (dw.Length > 0) lw.Add(dw);
  2588. string apdate1 = GetPostString("apdate1");
  2589. string apdate2 = GetPostString("apdate2");
  2590. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2591. if (dwap.Length > 0) lw.Add(dwap);
  2592. string price1 = GetPostString("price1");
  2593. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2594. string price2 = GetPostString("price2");
  2595. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2596. string olddownload = GetPostString("olddown");
  2597. if (olddownload == "1")
  2598. {
  2599. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2600. }
  2601. else if (olddownload == "2")
  2602. {
  2603. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2604. }
  2605. string sellermemo = GetPostString("seller_memo");
  2606. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2607. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2608. if (CurrentUser.User.TeamIds.Length > 0)
  2609. {
  2610. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2611. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2612. else
  2613. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2614. }
  2615. else
  2616. {
  2617. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2618. }
  2619. if (tid.Length <= 0)
  2620. {
  2621. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2622. }
  2623. lw.Add(string.Format("IsReturn!=3"));
  2624. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2625. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2626. string teamids = CurrentUser.User.TeamIds.ToString();
  2627. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2628. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2629. if (dt != null && dt.Rows.Count > 0)
  2630. {
  2631. foreach (DataRow dr in dt.Rows)
  2632. {
  2633. try
  2634. {
  2635. // 对象操作
  2636. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2637. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2638. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2639. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2640. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2641. if (dStruct.PageSize != 100000)
  2642. {
  2643. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2644. dr["gongchuang"] = response.code;
  2645. }
  2646. }
  2647. catch (NullReferenceException ex)
  2648. {
  2649. }
  2650. }
  2651. }
  2652. writeGridDataTableJson(dStruct.TotalCount, dt);
  2653. }
  2654. public void set_erp_startdesign()
  2655. {
  2656. if (UrlPostParmsCheck("ctid"))
  2657. {
  2658. string eid = GetPostString("ctid");
  2659. CeErpTradeCell entity = null;
  2660. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2661. if (entity != null)
  2662. {
  2663. if (entity.OrderState != 3)
  2664. {
  2665. returnErrorMsg("请刷新,订单已经设计了");
  2666. return;
  2667. }
  2668. entity.StartDesignTime = DateTime.Now;
  2669. entity.OrderState = 4;
  2670. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2671. {
  2672. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2673. entity.SupplierId = suid;
  2674. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2675. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2676. }
  2677. //entity.MakeSupplier = suname;
  2678. entity.Update();
  2679. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2680. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2681. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2682. commonHelper.getCytPrice(entity);
  2683. returnSuccessMsg("操作成功!");
  2684. return;
  2685. }
  2686. returnErrorMsg("找不到记录");
  2687. }
  2688. }
  2689. public void ins_erp_designselfmemo()
  2690. {
  2691. if (UrlPostParmsCheck("ctid"))
  2692. {
  2693. string eid = GetPostString("ctid");
  2694. string con = GetPostString("con");
  2695. CeErpTradeCell entity = null;
  2696. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2697. if (entity != null)
  2698. {
  2699. entity.DesignSelfMemo = con;
  2700. entity.Update();
  2701. returnSuccessMsg("操作成功!");
  2702. return;
  2703. }
  2704. returnErrorMsg("找不到记录");
  2705. }
  2706. }
  2707. public void ins_erp_designprice()
  2708. {
  2709. if (UrlPostParmsCheck("ctid"))
  2710. {
  2711. string eid = GetPostString("ctid");
  2712. int uid = CurrentUser.UserID;
  2713. string userName = CurrentUser.UserName;
  2714. CeErpTradeCell entity = null;
  2715. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2716. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2717. if (entitys == null)
  2718. {
  2719. entitys = new CeErpDesignerBill();
  2720. }
  2721. if (entity != null)
  2722. {
  2723. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2724. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2725. entity.StartDesignTime = DateTime.Now;
  2726. entity.OrderState = 4;
  2727. string suname = "";
  2728. if (entity.SupplierId == 0)
  2729. {
  2730. int sid = commonHelper.autoDistributeToSupplier(entity);
  2731. entity.SupplierId = sid;
  2732. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2733. }
  2734. entity.Update();
  2735. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2736. if (ceErpUserPost != null)
  2737. {
  2738. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2739. if (ceErpPost != null)
  2740. {
  2741. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2742. {
  2743. entitys.tid = entity.ctid;
  2744. entitys.oid = entity.tid;
  2745. entitys.uid = uid;
  2746. entitys.userName = userName;
  2747. entitys.designerType = 1;
  2748. entitys.designerTypeText = "内部设计师";
  2749. entitys.price = Convert.ToDouble(GetPostString("price"));
  2750. entitys.designNum = GetPostInt("designNum");
  2751. entitys.modifyNum = GetPostInt("modifyNum");
  2752. entitys.designSize = GetPostString("designSize");
  2753. entitys.modifySize = GetPostString("modifySize");
  2754. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2755. {
  2756. entitys.create_time = DateTime.Now;
  2757. entitys.create_u_id = uid;
  2758. entitys.create_u_name = userName;
  2759. entitys.Save();
  2760. }
  2761. else
  2762. {
  2763. entitys.update_time = DateTime.Now;
  2764. entitys.update_u_id = uid;
  2765. entitys.update_u_name = userName;
  2766. entitys.Update();
  2767. }
  2768. }
  2769. }
  2770. }
  2771. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2772. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2773. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2774. if (suname != "")
  2775. {
  2776. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2777. }
  2778. commonHelper.getCytPrice(entity);
  2779. returnSuccessMsg("操作成功!");
  2780. return;
  2781. }
  2782. returnErrorMsg("找不到记录");
  2783. }
  2784. }
  2785. public void upload_erp_filecomplete()
  2786. {
  2787. if (UrlPostParmsCheck("ctid"))
  2788. {
  2789. string eid = GetPostString("ctid");
  2790. CeErpTradeCell entity = null;
  2791. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2792. if (entity != null)
  2793. {
  2794. entity.OrderState = 5; //设计完成
  2795. entity.Update();
  2796. returnSuccessMsg(eid + "上传成功,设计完成!");
  2797. return;
  2798. }
  2799. returnErrorMsg("找不到订单记录");
  2800. }
  2801. }
  2802. public void get_erp_designovertimelist()
  2803. {
  2804. DataStruct dStruct = GetPostStruct();
  2805. List<string> lw = new List<string>();
  2806. string tid = GetPostString("ctid");
  2807. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2808. string shopname = GetPostString("shopname");
  2809. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2810. string buyernick = GetPostString("buyer_nick");
  2811. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2812. string ResponsibleMan = GetPostString("responsible");
  2813. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2814. string date1 = GetPostString("date1");
  2815. string date2 = GetPostString("date2");
  2816. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2817. if (dw.Length > 0) lw.Add(dw);
  2818. string price1 = GetPostString("price1");
  2819. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2820. string price2 = GetPostString("price2");
  2821. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2822. string orderState = GetPostString("orderState");
  2823. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2824. string sellermemo = GetPostString("seller_memo");
  2825. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2826. lw.Add(string.Format("UnusualTag=3"));
  2827. lw.Add(string.Format("IsRefund<={0}", 1));
  2828. dStruct.Order = "WaitDesignTime desc";
  2829. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2830. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2831. writeGridDataTableJson(dStruct.TotalCount, dt);
  2832. }
  2833. //设计管理 获取抢单大厅列表
  2834. public void get_erp_grabinglist()
  2835. {
  2836. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2837. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2838. bool oldOrder = false;
  2839. if (org != null)
  2840. {
  2841. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2842. }
  2843. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2844. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2845. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2846. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2847. //先处理订单数据
  2848. if (dt.Rows.Count > 0)
  2849. {
  2850. Dictionary<string, int> design = null;
  2851. int count = 0;
  2852. foreach (DataRow row in dt.Rows)
  2853. {
  2854. if (map.ContainsKey(row["ShopId"].ToString()))
  2855. {
  2856. map.TryGetValue(row["ShopId"].ToString(), out design);
  2857. }
  2858. else
  2859. {
  2860. design = new Dictionary<string, int>();
  2861. }
  2862. if (design.ContainsKey(row["ProductId"].ToString()))
  2863. {
  2864. design.TryGetValue(row["ProductId"].ToString(), out count);
  2865. }
  2866. count++;
  2867. design[row["ProductId"].ToString()] = count;
  2868. map[row["ShopId"].ToString()] = design;
  2869. }
  2870. }
  2871. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2872. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2873. //把店铺排序和技能排序分类
  2874. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2875. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2876. if (design_dt.Rows.Count > 0)
  2877. {
  2878. Dictionary<string, string> design = null;
  2879. List<string> shopIds = null;
  2880. foreach (DataRow row in design_dt.Rows)
  2881. {
  2882. if ("0".Equals(row["designId"].ToString()))
  2883. {
  2884. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2885. {
  2886. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2887. }
  2888. else
  2889. {
  2890. shopIds = new List<string>();
  2891. }
  2892. shopIds.Add(row["shopId"].ToString());
  2893. shop_orders[row["orders"].ToString()] = shopIds;
  2894. }
  2895. else
  2896. {
  2897. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2898. {
  2899. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2900. }
  2901. else
  2902. {
  2903. design = new Dictionary<string, string>();
  2904. }
  2905. design[row["orders"].ToString()] = row["designId"].ToString();
  2906. design_orders[row["shopId"].ToString()] = design;
  2907. }
  2908. }
  2909. //处理成key value后根据key排序
  2910. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2911. foreach (List<string> val in shop_orders.Values)
  2912. {
  2913. if (val != null)
  2914. {
  2915. foreach (string key in val)
  2916. {
  2917. if (design_orders.ContainsKey(key.ToString()))
  2918. {
  2919. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2920. }
  2921. }
  2922. }
  2923. }
  2924. }
  2925. //校验哪个优先级有订单
  2926. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2927. foreach (string key in shop_orders.Keys)
  2928. {
  2929. List<string> ids = null;
  2930. shop_orders.TryGetValue(key, out ids);
  2931. //id为shopid
  2932. foreach (string id in ids)
  2933. {
  2934. Dictionary<string, int> list = null;
  2935. Dictionary<string, string> desing = null;
  2936. map.TryGetValue(id, out list);
  2937. design_orders.TryGetValue(id, out desing);
  2938. if (list != null && desing != null)
  2939. {
  2940. foreach (var item in desing)
  2941. {
  2942. int count = 0;
  2943. if (list.ContainsKey(item.Value))
  2944. {
  2945. list.TryGetValue(item.Value, out count);
  2946. if (count > 0)
  2947. {
  2948. designIds[id] = item.Value;
  2949. break;
  2950. }
  2951. }
  2952. }
  2953. }
  2954. }
  2955. if (designIds.Count > 0)
  2956. {
  2957. break;
  2958. }
  2959. }
  2960. DataTable table = new DataTable();
  2961. table.Columns.Add("tid", typeof(string));
  2962. table.Columns.Add("ctid", typeof(string));
  2963. table.Columns.Add("seller_nick", typeof(string));
  2964. table.Columns.Add("productName", typeof(string));
  2965. table.Columns.Add("pay_time", typeof(string));
  2966. table.Columns.Add("seller_memo", typeof(string));
  2967. if (designIds.Count > 0)
  2968. {
  2969. string shopId = "";
  2970. string productId = "";
  2971. foreach (var designInfo in designIds)
  2972. {
  2973. shopId = designInfo.Key;
  2974. productId = designInfo.Value;
  2975. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  2976. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  2977. if (dt.Rows.Count > 0)
  2978. {
  2979. foreach (DataRow row in dt.Rows)
  2980. {
  2981. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  2982. {
  2983. DataRow data = table.NewRow();
  2984. data["ctid"] = row["ctid"].ToString();
  2985. data["tid"] = row["tid"].ToString();
  2986. data["seller_nick"] = ceErpShop.ShopName;
  2987. data["pay_time"] = row["pay_time"].ToString();
  2988. data["seller_memo"] = row["seller_memo"].ToString();
  2989. data["productName"] = ceErpProduct.PType;
  2990. table.Rows.Add(data);
  2991. }
  2992. }
  2993. }
  2994. }
  2995. }
  2996. writeGridDataTableJson(table.Rows.Count, table);
  2997. }
  2998. private object rushLockObject = new object();
  2999. public void set_erp_grabingorder()
  3000. {
  3001. if (UrlPostParmsCheck("ctid"))
  3002. {
  3003. int total = CurrentUser.User.Person.Total;
  3004. int userId = CurrentUser.User.ID;
  3005. int noFinish = CurrentUser.User.Person.NoFinish;
  3006. int finalization = CurrentUser.User.Person.Finalization;
  3007. string eids = GetPostString("ctid");
  3008. string key = "RushKey_" + userId;
  3009. int count = 0;
  3010. if (erpRedis.RedisHelper.KeyExists(key))
  3011. {
  3012. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3013. if (redisCount != null)
  3014. {
  3015. count = Convert.ToInt32(redisCount);
  3016. }
  3017. }
  3018. if (count >= total)
  3019. {
  3020. returnErrorMsg("半小时内已经抢" + total + "单");
  3021. return;
  3022. }
  3023. string[] ctidlist = eids.Split(',');
  3024. if (count + ctidlist.Length > total)
  3025. {
  3026. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3027. return;
  3028. }
  3029. int itag = 0;
  3030. lock (rushLockObject)
  3031. {
  3032. if (ctidlist.Length > 0)
  3033. {
  3034. string[] dtList = new string[ctidlist.Length];
  3035. for (int i = 0; i < ctidlist.Length; i++)
  3036. {
  3037. dtList[i] = "'" + ctidlist[i] + "'";
  3038. }
  3039. 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"));
  3040. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3041. if (dt_user.Rows.Count > 0)
  3042. {
  3043. int doing = 0;//未定稿
  3044. int finish = 0;//已完成
  3045. foreach (DataRow dr in dt_user.Rows)
  3046. {
  3047. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3048. {
  3049. doing++;
  3050. }
  3051. else
  3052. {
  3053. finish++;
  3054. }
  3055. }
  3056. if (doing >= noFinish)
  3057. {
  3058. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3059. return;
  3060. }
  3061. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3062. {
  3063. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3064. return;
  3065. }
  3066. }
  3067. //校验选择单子状态
  3068. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3069. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3070. if (dt.Rows.Count > 0)
  3071. {
  3072. List<string> list = new List<string>();
  3073. foreach (DataRow dr in dt.Rows)
  3074. {
  3075. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3076. {
  3077. list.Add(dr["ctid"].ToString());
  3078. }
  3079. }
  3080. if (list.Count > 0)
  3081. {
  3082. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3083. return;
  3084. }
  3085. }
  3086. foreach (string ctid in ctidlist)
  3087. {
  3088. CeErpTradeCell entity = null;
  3089. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3090. if (entity != null)
  3091. {
  3092. entity.OrderState = 3;
  3093. entity.DesignUserId = CurrentUser.UserID;
  3094. entity.WaitDesignTime = DateTime.Now;
  3095. entity.StartDesignTime = DateTime.Now;
  3096. entity.Update();
  3097. commonHelper.UpdateRelationOrder(entity.ctid);
  3098. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3099. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3100. itag++;
  3101. }
  3102. }
  3103. }
  3104. }
  3105. count += ctidlist.Length;
  3106. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3107. if (itag == 0)
  3108. returnErrorMsg("没有找到相关订单");
  3109. else
  3110. returnSuccessMsg("抢单成功!");
  3111. return;
  3112. }
  3113. }
  3114. public void get_erp_waitorderlist()
  3115. {
  3116. DataStruct dStruct = GetPostStruct();
  3117. List<string> lw = new List<string>();
  3118. string tid = GetPostString("ctid");
  3119. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3120. string shopname = GetPostString("shopname");
  3121. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3122. string buyernick = GetPostString("buyer_nick");
  3123. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3124. string customer = GetPostString("customer");
  3125. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3126. string design = GetPostString("design");
  3127. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3128. string orderState = GetPostString("orderState");
  3129. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3130. string supplier = GetPostString("supplier");
  3131. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3132. string sellermemo = GetPostString("seller_memo");
  3133. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3134. string otherMemo = GetPostString("otherMemo");
  3135. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3136. string address = GetPostString("address");
  3137. 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));
  3138. string date1 = GetPostString("date1");
  3139. string date2 = GetPostString("date2");
  3140. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3141. if (dw.Length > 0) lw.Add(dw);
  3142. string price1 = GetPostString("price1");
  3143. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3144. string price2 = GetPostString("price2");
  3145. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3146. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3147. lw.Add(string.Format("IsSample != 2 "));
  3148. lw.Add(string.Format("OrderState = 5 "));
  3149. lw.Add(string.Format("IsRefund<={0}", 1));
  3150. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3151. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3152. string pagesize = GetPostString("pagesize");
  3153. if (pagesize != null)
  3154. {
  3155. dStruct.PageSize = 200;
  3156. }
  3157. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3158. foreach (DataRow dr in dt.Rows)
  3159. {
  3160. 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();
  3161. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3162. {
  3163. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3164. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3165. entity.SupplierId = suid;
  3166. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3167. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3168. entity.Update();
  3169. }
  3170. }
  3171. writeGridDataTableJson(dStruct.TotalCount, dt);
  3172. }
  3173. public void get_erp_supplierwaitorderlist()
  3174. {
  3175. DataStruct dStruct = GetPostStruct();
  3176. List<string> lw = new List<string>();
  3177. string tid = GetPostString("ctid");
  3178. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3179. string shopname = GetPostString("shopname");
  3180. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3181. string sellermemo = GetPostString("seller_memo");
  3182. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3183. string date1 = GetPostString("date1");
  3184. string date2 = GetPostString("date2");
  3185. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3186. if (dw.Length > 0) lw.Add(dw);
  3187. lw.Add(string.Format("OrderState = 5 "));
  3188. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3189. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3190. {
  3191. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3192. }
  3193. string supplier = GetPostString("supplier");
  3194. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3195. {
  3196. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3197. }
  3198. lw.Add(string.Format("IsRefund<={0}", 1));
  3199. dStruct.Order = "FinishDesignTime desc";
  3200. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3201. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3202. if (dt != null)
  3203. {
  3204. foreach (DataRow dr in dt.Rows)
  3205. {
  3206. 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();
  3207. }
  3208. }
  3209. writeGridDataTableJson(dStruct.TotalCount, dt);
  3210. }
  3211. public void upd_erp_verifytosupplier()
  3212. {
  3213. if (UrlPostParmsCheck("ctid"))
  3214. {
  3215. string eids = GetPostString("ctid");
  3216. CeErpTradeCell entity = null;
  3217. string[] eidsList = eids.Split(',');
  3218. if (eidsList.Length <= 0)
  3219. {
  3220. returnErrorMsg("订单号不能空");
  3221. return;
  3222. }
  3223. List<string> tLst = new List<string>();
  3224. foreach (string ctidstr in eidsList)
  3225. {
  3226. tLst.Add("'" + ctidstr + "'");
  3227. CeErpDataSendOrderInfo.createObject(ctidstr);
  3228. }
  3229. string needtids = string.Join(",", tLst.ToArray());
  3230. StringBuilder sql = new StringBuilder();
  3231. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3232. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3233. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3234. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3235. returnSuccessMsg("操作成功!");
  3236. return;
  3237. /**foreach (string ctidstr in eidsList)
  3238. {
  3239. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3240. if (entity != null)
  3241. {
  3242. if (entity.SupplierId == 0)
  3243. {
  3244. continue;
  3245. }
  3246. entity.IsVerifyToSupplier = true;
  3247. if (entity.IsReturn == 1) //1是供应商打回
  3248. {
  3249. entity.IsReturn = 0;
  3250. }
  3251. entity.FinishPlaceTime = DateTime.Now;
  3252. entity.PlaceUserId = CurrentUser.UserID;
  3253. entity.Update();
  3254. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3255. }
  3256. }
  3257. returnSuccessMsg("操作成功!");
  3258. return;**/
  3259. }
  3260. }
  3261. public void upd_erp_supplierback()
  3262. {
  3263. if (UrlPostParmsCheck("ctid"))
  3264. {
  3265. string eid = GetPostString("ctid");
  3266. string reason = GetPostString("returnreason");
  3267. CeErpTradeCell entity = null;
  3268. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3269. if (entity != null)
  3270. {
  3271. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3272. {
  3273. string key = "return_order_" + entity.SupplierId;
  3274. List<string> list = new List<string>();
  3275. if (RedisHelper.HasKey(key))
  3276. {
  3277. object data = RedisHelper.StringGet(key);
  3278. list = Convert.ToString(data).Split(',').ToList();
  3279. }
  3280. list.Add(eid);
  3281. RedisHelper.StringSet(key, string.Join(",", list));
  3282. }
  3283. entity.IsVerifyToSupplier = false;
  3284. entity.IsReturn = 1;
  3285. entity.ReturnTime = DateTime.Now;
  3286. entity.ReturnReason = reason;
  3287. if (entity.OrderState == 6)
  3288. {
  3289. entity.OrderState = 5;
  3290. }
  3291. entity.Update();
  3292. CeErpSukuraData.createInfo(entity.ctid, 5);
  3293. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3294. returnSuccessMsg("操作成功!");
  3295. return;
  3296. }
  3297. returnErrorMsg("找不到订单记录");
  3298. }
  3299. }
  3300. public void upd_erp_toaftersaleorder()
  3301. {
  3302. if (UrlPostParmsCheck("ctid"))
  3303. {
  3304. string eid = GetPostString("ctid");
  3305. string reason = GetPostString("returnreason");
  3306. CeErpTradeCell entity = null;
  3307. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3308. if (entity != null)
  3309. {
  3310. if (entity.isAfterSaleOrder != 1)
  3311. {
  3312. returnErrorMsg("带S的售后单才能打回给售后");
  3313. return;
  3314. }
  3315. if (entity.OrderState >= 5)
  3316. {
  3317. returnErrorMsg("已经设计完成了不能打回给售后");
  3318. return;
  3319. }
  3320. entity.OrderState = 0;
  3321. entity.IsReturn = 3;
  3322. entity.ReturnTime = DateTime.Now;
  3323. entity.ReturnReason = reason;
  3324. entity.Update();
  3325. CeErpSukuraData.createInfo(entity.ctid, 5);
  3326. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3327. returnSuccessMsg("操作成功!");
  3328. return;
  3329. }
  3330. returnErrorMsg("找不到订单记录");
  3331. }
  3332. }
  3333. public void upd_erp_aftersaletodesign()
  3334. {
  3335. if (UrlPostParmsCheck("ctid"))
  3336. {
  3337. string eid = GetPostString("ctid");
  3338. CeErpTradeCell entity = null;
  3339. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3340. if (entity != null)
  3341. {
  3342. entity.OrderState = 3;
  3343. entity.IsReturn = 0;
  3344. entity.Update();
  3345. CeErpSukuraData.createInfo(entity.ctid, 5);
  3346. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3347. returnSuccessMsg("操作成功!");
  3348. return;
  3349. }
  3350. returnErrorMsg("找不到订单记录");
  3351. }
  3352. }
  3353. public void assign_erp_supplier()
  3354. {
  3355. if (UrlPostParmsCheck("ctid"))
  3356. {
  3357. string eids = GetPostString("ctid");
  3358. int sid = GetPostInt("SupplierName");
  3359. string fromTag = GetPostString("tag");
  3360. string[] eidList = eids.Split(',');
  3361. if (eidList.Length <= 0)
  3362. {
  3363. returnErrorMsg("指派不能为空");
  3364. return;
  3365. }
  3366. string errMsg = "";
  3367. string suname = commonHelper.getSupplierNameById(sid);
  3368. foreach (string ctid in eidList)
  3369. {
  3370. CeErpTradeCell entity = null;
  3371. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3372. if (entity != null)
  3373. {
  3374. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3375. {
  3376. errMsg += (ctid + "指派失败!!!");
  3377. continue;
  3378. }
  3379. entity.SupplierId = sid;
  3380. entity.Update();
  3381. commonHelper.UpdateRelationOrder(entity.ctid);
  3382. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3383. if (entity.OrderState >= 6)
  3384. {
  3385. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3386. //{
  3387. // string msl = entity.MakeSupplier;
  3388. // string[] mslist = msl.Split(',');
  3389. // 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);
  3390. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3391. //}
  3392. //else
  3393. //{
  3394. StringBuilder sql = new StringBuilder();
  3395. 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);
  3396. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3397. //}
  3398. }
  3399. }
  3400. else
  3401. {
  3402. continue;
  3403. }
  3404. }
  3405. if (errMsg.Length > 0)
  3406. {
  3407. returnErrorMsg(errMsg);
  3408. return;
  3409. }
  3410. returnSuccessMsg("操作成功!");
  3411. return;
  3412. }
  3413. }
  3414. public void assign_erp_makesupplier()
  3415. {
  3416. if (UrlPostParmsCheck("ctid"))
  3417. {
  3418. string eids = GetPostString("ctid");
  3419. string sname = GetPostString("SupplierName");
  3420. string[] eidList = eids.Split(',');
  3421. if (eidList.Length <= 0)
  3422. {
  3423. returnErrorMsg("指派不能为空");
  3424. return;
  3425. }
  3426. List<string> tLst = new List<string>();
  3427. foreach (string ctid in eidList)
  3428. {
  3429. CeErpTradeCell entity = null;
  3430. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3431. if (entity != null)
  3432. {
  3433. entity.MakeSupplier = sname;
  3434. entity.Update();
  3435. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3436. tLst.Add("'" + ctid + "'");
  3437. }
  3438. else
  3439. {
  3440. continue;
  3441. }
  3442. }
  3443. string ctids = string.Join(",", tLst.ToArray());
  3444. StringBuilder sql2 = new StringBuilder();
  3445. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3446. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3447. returnSuccessMsg("操作成功!");
  3448. return;
  3449. }
  3450. }
  3451. public void ins_erp_returnreason()
  3452. {
  3453. if (UrlPostParmsCheck("ctid"))
  3454. {
  3455. string eid = GetPostString("ctid");
  3456. CeErpTradeCell entity = null;
  3457. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3458. string userpost = CurrentUser.UserPost.Post.Code;
  3459. if (entity != null)
  3460. {
  3461. bool isPlace = false;
  3462. if (entity.OrderState > 6)
  3463. {
  3464. returnErrorMsg("已发货无法打回!");
  3465. return;
  3466. }
  3467. if (entity.OrderState == 6)
  3468. {
  3469. isPlace = true;
  3470. }
  3471. bool isNeedUpdateCell2 = false;
  3472. if (entity.OrderState >= 6)
  3473. {
  3474. isNeedUpdateCell2 = true;
  3475. }
  3476. int returnTag = 2;
  3477. if (userpost == "Supplier")
  3478. {
  3479. returnTag = 1;
  3480. }
  3481. if (entity.IsXianHuo == 0)
  3482. {
  3483. if (returnTag == 2)
  3484. {
  3485. int toType = GetPostInt("totype");
  3486. if (toType == 1)
  3487. {
  3488. entity.OrderState = 0;
  3489. entity.ReturnUserType = 1;
  3490. string clearman = GetPostString("clearman");
  3491. if (!string.IsNullOrEmpty(clearman))
  3492. {
  3493. entity.DesignUserId = 0;
  3494. }
  3495. }
  3496. else
  3497. {
  3498. entity.OrderState = 3;
  3499. entity.ReturnUserType = 2;
  3500. }
  3501. entity.IsReadTag = 1;
  3502. }
  3503. else if (returnTag == 1)
  3504. {
  3505. entity.OrderState = 5;
  3506. }
  3507. entity.IsVerifyToSupplier = false;
  3508. }
  3509. if (entity.IsXianHuo == 1)
  3510. {
  3511. entity.OrderState = 5;
  3512. }
  3513. entity.UnusualTag = 0;
  3514. entity.UnusualTime = null;
  3515. entity.UnusualCon = "";
  3516. entity.IsReturn = returnTag;
  3517. entity.ReturnTime = DateTime.Now;
  3518. entity.ReturnReason = GetPostString("returnreason");
  3519. entity.Update();
  3520. if (entity.OrderState == 3)
  3521. {
  3522. ApiVo apiVo = new ApiVo();
  3523. apiVo.orderNumber = entity.ctid;
  3524. apiVo.actionName = "rebutDesign";
  3525. apiVo.orderRemarks = entity.ReturnReason;
  3526. designHelper.API_WorkCore(apiVo);//rebutDesign
  3527. }
  3528. CeErpSukuraData.createInfo(entity.ctid, 5);
  3529. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3530. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3531. if (isPlace)
  3532. {
  3533. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3534. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3535. if (dth != null && dth.Rows.Count > 0)
  3536. {
  3537. dataSendOrderBean dataSendOrderBean = null;
  3538. foreach (DataRow item in dth.Rows)
  3539. {
  3540. try
  3541. {
  3542. dataSendOrderBean = new dataSendOrderBean();
  3543. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3544. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3545. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3546. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3547. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3548. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3549. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3550. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3551. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3552. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3553. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3554. dataSendOrderBean.Radio1723534706288 = "打回";
  3555. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3556. if (result != null)
  3557. {
  3558. if ("0".Equals(result.errcode))
  3559. {
  3560. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3561. }
  3562. else
  3563. {
  3564. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3565. }
  3566. }
  3567. }
  3568. catch (Exception ex)
  3569. {
  3570. }
  3571. }
  3572. }
  3573. }
  3574. if (isNeedUpdateCell2)
  3575. {
  3576. if (entity.MakeSupplier.IndexOf(",") != -1)
  3577. {
  3578. StringBuilder sql2 = new StringBuilder();
  3579. 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);
  3580. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3581. }
  3582. else
  3583. {
  3584. StringBuilder sql2 = new StringBuilder();
  3585. 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);
  3586. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3587. }
  3588. }
  3589. returnSuccessMsg("操作成功!");
  3590. return;
  3591. }
  3592. returnErrorMsg("找不到订单记录");
  3593. }
  3594. }
  3595. public void cyt_erp_returnreason()
  3596. {
  3597. if (UrlPostParmsCheck("ctid"))
  3598. {
  3599. string eid = GetPostString("ctid");
  3600. CeErpTradeCell entity = null;
  3601. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3602. string userpost = CurrentUser.UserPost.Post.Code;
  3603. if (entity != null)
  3604. {
  3605. if (entity.OrderState > 6)
  3606. {
  3607. returnErrorMsg("已发货无法打回!");
  3608. return;
  3609. }
  3610. JObject jsonObject = new JObject
  3611. {
  3612. { "Userid", "77886" },
  3613. { "Pwd", "lt666888" },
  3614. { "LTOrderId",eid }
  3615. };
  3616. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3617. JObject jsonObjects = JObject.Parse(response);
  3618. string msg = (string)jsonObjects["msg"];
  3619. if (msg != "取消成功")
  3620. {
  3621. returnErrorMsg(msg);
  3622. return;
  3623. }
  3624. bool isNeedUpdateCell2 = false;
  3625. if (entity.OrderState >= 6)
  3626. {
  3627. isNeedUpdateCell2 = true;
  3628. }
  3629. int returnTag = 2;
  3630. if (userpost == "Supplier")
  3631. {
  3632. returnTag = 1;
  3633. }
  3634. if (entity.IsXianHuo == 0)
  3635. {
  3636. if (returnTag == 2)
  3637. {
  3638. int toType = GetPostInt("totype");
  3639. if (toType == 1)
  3640. {
  3641. entity.OrderState = 0;
  3642. entity.ReturnUserType = 1;
  3643. }
  3644. else
  3645. {
  3646. entity.OrderState = 4;
  3647. entity.ReturnUserType = 2;
  3648. }
  3649. entity.IsReadTag = 1;
  3650. }
  3651. else if (returnTag == 1)
  3652. {
  3653. entity.OrderState = 5;
  3654. }
  3655. entity.IsVerifyToSupplier = false;
  3656. }
  3657. entity.UnusualTag = 0;
  3658. entity.UnusualTime = null;
  3659. entity.UnusualCon = "";
  3660. entity.IsReturn = returnTag;
  3661. entity.ReturnTime = DateTime.Now;
  3662. entity.ReturnReason = GetPostString("returnreason");
  3663. entity.Update();
  3664. if (entity.OrderState == 4)
  3665. {
  3666. ApiVo apiVo = new ApiVo();
  3667. apiVo.orderNumber = entity.ctid;
  3668. apiVo.actionName = "rebutDesign";
  3669. apiVo.orderRemarks = entity.ReturnReason;
  3670. designHelper.API_WorkCore(apiVo);//rebutDesign
  3671. }
  3672. CeErpSukuraData.createInfo(entity.ctid, 5);
  3673. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3674. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3675. if (isNeedUpdateCell2)
  3676. {
  3677. if (entity.MakeSupplier.IndexOf(",") != -1)
  3678. {
  3679. StringBuilder sql2 = new StringBuilder();
  3680. 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);
  3681. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3682. }
  3683. else
  3684. {
  3685. StringBuilder sql2 = new StringBuilder();
  3686. 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);
  3687. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3688. }
  3689. }
  3690. returnSuccessMsg("操作成功!");
  3691. return;
  3692. }
  3693. returnErrorMsg("找不到订单记录");
  3694. }
  3695. }
  3696. public void upd_erp_xianhuoreturntag()
  3697. {
  3698. if (UrlPostParmsCheck("ctid"))
  3699. {
  3700. string eids = GetPostString("ctid");
  3701. string[] ctids = eids.Split(',');
  3702. foreach (string ctid in ctids)
  3703. {
  3704. CeErpTradeCell entity = null;
  3705. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3706. if (entity != null)
  3707. {
  3708. entity.IsReturn = 0;
  3709. entity.Update();
  3710. CeErpSukuraData.createInfo(entity.ctid, 5);
  3711. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3712. }
  3713. }
  3714. returnSuccessMsg("操作成功!");
  3715. return;
  3716. }
  3717. }
  3718. public void get_erp_waitdeliverylist()
  3719. {
  3720. DataStruct dStruct = GetPostStruct();
  3721. List<string> lw = new List<string>();
  3722. string tid = GetPostString("ctid");
  3723. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3724. string shopname = GetPostString("shopname");
  3725. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3726. string buyernick = GetPostString("buyer_nick");
  3727. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3728. //if (tid.Length == 0 && buyernick.Length == 0)
  3729. //{
  3730. // lw.Add(string.Format("IsRefund<={0}", 1));
  3731. //}
  3732. string customer = GetPostString("customer");
  3733. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3734. string design = GetPostString("design");
  3735. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3736. string orderState = GetPostString("orderState");
  3737. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3738. string address = GetPostString("address");
  3739. 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));
  3740. string sellermemo = GetPostString("seller_memo");
  3741. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3742. string supplier = GetPostString("supplier");
  3743. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3744. string OrderArea = GetPostString("order_area");
  3745. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3746. string placedate1 = GetPostString("placedate1");
  3747. string placedate2 = GetPostString("placedate2");
  3748. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3749. if (fdw.Length > 0) lw.Add(fdw);
  3750. string price1 = GetPostString("price1");
  3751. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3752. string price2 = GetPostString("price2");
  3753. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3754. string unusualCon = GetPostString("unusualcon");
  3755. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3756. string otherMemo = GetPostString("otherMemo");
  3757. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3758. string posTag = CurrentUser.UserPost.Post.Code;
  3759. if (posTag == "Supplier")
  3760. {
  3761. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3762. }
  3763. lw.Add(string.Format("OrderState = 6 "));
  3764. lw.Add(string.Format("type != 'PDD' "));
  3765. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3766. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3767. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3768. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3769. writeGridDataTableJson(dStruct.TotalCount, dt);
  3770. }
  3771. public void get_erp_pddderiving()
  3772. {
  3773. DataStruct dStruct = GetPostStruct();
  3774. List<string> lw = new List<string>();
  3775. string tid = GetPostString("ctid");
  3776. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3777. string shopname = GetPostString("shopname");
  3778. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3779. string buyernick = GetPostString("buyer_nick");
  3780. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3781. //if (tid.Length == 0 && buyernick.Length == 0)
  3782. //{
  3783. // lw.Add(string.Format("IsRefund<={0}", 1));
  3784. //}
  3785. string customer = GetPostString("customer");
  3786. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3787. string design = GetPostString("design");
  3788. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3789. string orderState = GetPostString("orderState");
  3790. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3791. string address = GetPostString("address");
  3792. 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));
  3793. string sellermemo = GetPostString("seller_memo");
  3794. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3795. string supplier = GetPostString("supplier");
  3796. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3797. string OrderArea = GetPostString("order_area");
  3798. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3799. string placedate1 = GetPostString("placedate1");
  3800. string placedate2 = GetPostString("placedate2");
  3801. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3802. if (fdw.Length > 0) lw.Add(fdw);
  3803. string price1 = GetPostString("price1");
  3804. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3805. string price2 = GetPostString("price2");
  3806. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3807. string unusualCon = GetPostString("unusualcon");
  3808. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3809. string posTag = CurrentUser.UserPost.Post.Code;
  3810. if (posTag == "Supplier")
  3811. {
  3812. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3813. }
  3814. lw.Add(string.Format("OrderState = 6 "));
  3815. lw.Add(string.Format("type = 'PDD' "));
  3816. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3817. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3818. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3819. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3820. writeGridDataTableJson(dStruct.TotalCount, dt);
  3821. }
  3822. public void get_erp_jdderiving()
  3823. {
  3824. DataStruct dStruct = GetPostStruct();
  3825. List<string> lw = new List<string>();
  3826. string tid = GetPostString("ctid");
  3827. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3828. string shopname = GetPostString("shopname");
  3829. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3830. string buyernick = GetPostString("buyer_nick");
  3831. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3832. //if (tid.Length == 0 && buyernick.Length == 0)
  3833. //{
  3834. // lw.Add(string.Format("IsRefund<={0}", 1));
  3835. //}
  3836. string customer = GetPostString("customer");
  3837. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3838. string design = GetPostString("design");
  3839. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3840. string orderState = GetPostString("orderState");
  3841. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3842. string address = GetPostString("address");
  3843. 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));
  3844. string sellermemo = GetPostString("seller_memo");
  3845. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3846. string supplier = GetPostString("supplier");
  3847. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3848. string OrderArea = GetPostString("order_area");
  3849. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3850. string placedate1 = GetPostString("placedate1");
  3851. string placedate2 = GetPostString("placedate2");
  3852. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3853. if (fdw.Length > 0) lw.Add(fdw);
  3854. string price1 = GetPostString("price1");
  3855. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3856. string price2 = GetPostString("price2");
  3857. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3858. string unusualCon = GetPostString("unusualcon");
  3859. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3860. string posTag = CurrentUser.UserPost.Post.Code;
  3861. if (posTag == "Supplier")
  3862. {
  3863. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3864. }
  3865. lw.Add(string.Format("OrderState = 6 "));
  3866. lw.Add(string.Format("type = 'JD' "));
  3867. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3868. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3869. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3870. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3871. writeGridDataTableJson(dStruct.TotalCount, dt);
  3872. }
  3873. public void get_erp_demoorderlist()
  3874. {
  3875. DataStruct dStruct = GetPostStruct();
  3876. List<string> lw = new List<string>();
  3877. string tid = GetPostString("ctid");
  3878. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3879. string shopname = GetPostString("shopname");
  3880. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3881. string buyernick = GetPostString("buyer_nick");
  3882. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3883. string customer = GetPostString("customer");
  3884. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3885. string design = GetPostString("design");
  3886. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3887. string orderState = GetPostString("orderState");
  3888. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3889. string address = GetPostString("address");
  3890. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3891. string sellermemo = GetPostString("seller_memo");
  3892. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3893. string supplier = GetPostString("supplier");
  3894. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3895. string OrderArea = GetPostString("order_area");
  3896. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3897. string date1 = GetPostString("date1");
  3898. string date2 = GetPostString("date2");
  3899. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3900. if (dw.Length > 0) lw.Add(dw);
  3901. string price1 = GetPostString("price1");
  3902. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3903. string price2 = GetPostString("price2");
  3904. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3905. string posTag = CurrentUser.UserPost.Post.Code;
  3906. if (posTag == "Supplier")
  3907. {
  3908. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3909. }
  3910. //lw.Add(string.Format("OrderState = 6 "));
  3911. lw.Add(string.Format("IsSample={0}", 3));
  3912. lw.Add(string.Format("IsRefund<={0}", 1));
  3913. dStruct.Order = "pay_time desc";
  3914. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3915. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3916. writeGridDataTableJson(dStruct.TotalCount, dt);
  3917. }
  3918. public void save_erp_checkmemo()
  3919. {
  3920. if (UrlPostParmsCheck("ctid"))
  3921. {
  3922. string ctid = GetPostString("ctid");
  3923. CeErpTradeCell entity = null;
  3924. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3925. if (entity != null)
  3926. {
  3927. entity.CheckMemo = GetPostString("CheckMemo");
  3928. entity.Update();
  3929. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  3930. if (trade != null)
  3931. {
  3932. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  3933. }
  3934. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  3935. returnSuccessMsg("保存成功!");
  3936. return;
  3937. }
  3938. returnErrorMsg("找不到记录");
  3939. }
  3940. }
  3941. public void get_erp_returnlist()
  3942. {
  3943. DataStruct dStruct = GetPostStruct();
  3944. List<string> lw = new List<string>();
  3945. string tid = GetPostString("ctid");
  3946. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3947. string shopname = GetPostString("shopname");
  3948. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3949. string buyernick = GetPostString("buyer_nick");
  3950. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3951. string customer = GetPostString("customer");
  3952. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3953. string design = GetPostString("design");
  3954. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3955. string orderState = GetPostString("orderState");
  3956. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3957. string address = GetPostString("address");
  3958. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3959. string sellermemo = GetPostString("seller_memo");
  3960. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3961. string supplier = GetPostString("supplier");
  3962. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3963. string date1 = GetPostString("date1");
  3964. string date2 = GetPostString("date2");
  3965. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3966. if (dw.Length > 0) lw.Add(dw);
  3967. string bdate1 = GetPostString("backdate1");
  3968. string bdate2 = GetPostString("backdate2");
  3969. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3970. if (dw_back.Length > 0) lw.Add(dw_back);
  3971. string price1 = GetPostString("price1");
  3972. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3973. string price2 = GetPostString("price2");
  3974. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3975. lw.Add(string.Format("IsReturn>0"));
  3976. lw.Add(string.Format("IsXianHuo=0"));
  3977. lw.Add(string.Format("IsReturn!=3"));
  3978. string backtype = GetPostString("backtype");
  3979. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  3980. dStruct.Order = "FinishDesignTime desc";
  3981. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3982. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3983. writeGridDataTableJson(dStruct.TotalCount, dt);
  3984. }
  3985. public void get_erp_today_sumreturn()
  3986. {
  3987. DataStruct dStruct = GetPostStruct();
  3988. List<string> lw = new List<string>();
  3989. string bdate1 = GetPostString("returnTimeS");
  3990. string bdate2 = GetPostString("returnTimeE");
  3991. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3992. if (dw_back.Length > 0) lw.Add(dw_back);
  3993. lw.Add(string.Format("IsReturn=0"));
  3994. lw.Add(string.Format("IsXianHuo=0"));
  3995. string mainWhere = string.Join(" and ", lw.ToArray());
  3996. string sql = "";
  3997. if (dw_back.Length > 0)
  3998. {
  3999. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4000. }
  4001. else
  4002. {
  4003. 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 + "'";
  4004. }
  4005. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4006. decimal total = 0, today_finish = 0;
  4007. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4008. {
  4009. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4010. }
  4011. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4012. {
  4013. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4014. }
  4015. var res = new
  4016. {
  4017. data = total,
  4018. data1 = today_finish,
  4019. };
  4020. string ro_jsond = JsonConvert.SerializeObject(res);
  4021. returnSuccess(ro_jsond);
  4022. return;
  4023. }
  4024. public void get_erp_allreturnlist()
  4025. {
  4026. DataStruct dStruct = GetPostStruct();
  4027. List<string> lw = new List<string>();
  4028. string tid = GetPostString("ctid");
  4029. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4030. string shopname = GetPostString("shopname");
  4031. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4032. string buyernick = GetPostString("buyer_nick");
  4033. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4034. string customer = GetPostString("customer");
  4035. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4036. string design = GetPostString("design");
  4037. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4038. string orderState = GetPostString("orderState");
  4039. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4040. string address = GetPostString("address");
  4041. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4042. string sellermemo = GetPostString("seller_memo");
  4043. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4044. string supplier = GetPostString("supplier");
  4045. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4046. string date1 = GetPostString("date1");
  4047. string date2 = GetPostString("date2");
  4048. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4049. if (dw.Length > 0) lw.Add(dw);
  4050. string bdate1 = GetPostString("backdate1");
  4051. string bdate2 = GetPostString("backdate2");
  4052. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4053. if (dw_back.Length > 0) lw.Add(dw_back);
  4054. string price1 = GetPostString("price1");
  4055. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4056. string price2 = GetPostString("price2");
  4057. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4058. string backreason = GetPostString("backreason");
  4059. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4060. lw.Add(string.Format("IsXianHuo=0"));
  4061. lw.Add(string.Format("ReturnTime != ''"));
  4062. string backtype = GetPostString("backtype");
  4063. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4064. dStruct.Order = "FinishDesignTime desc";
  4065. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4066. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4067. writeGridDataTableJson(dStruct.TotalCount, dt);
  4068. }
  4069. public void get_erp_aftersalereturnlist()
  4070. {
  4071. DataStruct dStruct = GetPostStruct();
  4072. List<string> lw = new List<string>();
  4073. string tid = GetPostString("ctid");
  4074. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4075. string shopname = GetPostString("shopname");
  4076. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4077. string buyernick = GetPostString("buyer_nick");
  4078. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4079. string customer = GetPostString("customer");
  4080. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4081. string design = GetPostString("design");
  4082. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4083. string orderState = GetPostString("orderState");
  4084. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4085. string address = GetPostString("address");
  4086. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4087. string sellermemo = GetPostString("seller_memo");
  4088. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4089. string supplier = GetPostString("supplier");
  4090. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4091. string date1 = GetPostString("date1");
  4092. string date2 = GetPostString("date2");
  4093. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4094. if (dw.Length > 0) lw.Add(dw);
  4095. string bdate1 = GetPostString("backdate1");
  4096. string bdate2 = GetPostString("backdate2");
  4097. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4098. if (dw_back.Length > 0) lw.Add(dw_back);
  4099. string price1 = GetPostString("price1");
  4100. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4101. string price2 = GetPostString("price2");
  4102. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4103. lw.Add(string.Format("IsReturn=3"));
  4104. string backtype = GetPostString("backtype");
  4105. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4106. string backreason = GetPostString("backreason");
  4107. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4108. dStruct.Order = "ReturnTime desc";
  4109. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4110. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4111. writeGridDataTableJson(dStruct.TotalCount, dt);
  4112. }
  4113. public void get_erp_xianhuoreturnlist()
  4114. {
  4115. DataStruct dStruct = GetPostStruct();
  4116. List<string> lw = new List<string>();
  4117. string tid = GetPostString("ctid");
  4118. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4119. string shopname = GetPostString("shopname");
  4120. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4121. string buyernick = GetPostString("buyer_nick");
  4122. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4123. string customer = GetPostString("customer");
  4124. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4125. string design = GetPostString("design");
  4126. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4127. string orderState = GetPostString("orderState");
  4128. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4129. string address = GetPostString("address");
  4130. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4131. string sellermemo = GetPostString("seller_memo");
  4132. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4133. string supplier = GetPostString("supplier");
  4134. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4135. string OrderArea = GetPostString("order_area");
  4136. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4137. string date1 = GetPostString("date1");
  4138. string date2 = GetPostString("date2");
  4139. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4140. if (dw.Length > 0) lw.Add(dw);
  4141. string price1 = GetPostString("price1");
  4142. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4143. string price2 = GetPostString("price2");
  4144. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4145. string posTag = CurrentUser.UserPost.Post.Code;
  4146. if (posTag == "Supplier")
  4147. {
  4148. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4149. }
  4150. lw.Add(string.Format("OrderState=6 "));
  4151. lw.Add(string.Format("IsXianHuo=1 "));
  4152. lw.Add(string.Format("IsReturn>0 "));
  4153. lw.Add(string.Format("IsReturn!=3"));
  4154. lw.Add(string.Format("IsRefund<={0}", 1));
  4155. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4156. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4157. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4158. writeGridDataTableJson(dStruct.TotalCount, dt);
  4159. }
  4160. public void set_erp_orderdelivery()
  4161. {
  4162. if (UrlPostParmsCheck("ctid"))
  4163. {
  4164. string eid = GetPostString("ctid");
  4165. CeErpTradeCell entity = null;
  4166. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4167. if (entity != null)
  4168. {
  4169. if (entity.OrderState >= 7)
  4170. {
  4171. returnErrorMsg("此单已发货,无需重复发货");
  4172. return;
  4173. }
  4174. if (entity.OrderState != 6)
  4175. {
  4176. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4177. return;
  4178. }
  4179. string shop = GetPostString("seller_nick");
  4180. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4181. string comName = GetPostString("comName");
  4182. string comCode = GetPostString("comCode");
  4183. string outSid = GetPostString("outSid");
  4184. string deliveryType = GetPostString("deliveryType");
  4185. string deliveryMemo = GetPostString("deliveryMemo");
  4186. outSid = outSid.Trim();
  4187. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4188. if (mainEn == null)
  4189. {
  4190. returnErrorMsg("找不到原始订单记录");
  4191. return;
  4192. }
  4193. bool isInitOrderDeliv = false;
  4194. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4195. {
  4196. isInitOrderDeliv = true;
  4197. }
  4198. string apires = "";
  4199. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4200. 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)
  4201. {
  4202. apires = "发货成功true";
  4203. }
  4204. else
  4205. {
  4206. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4207. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4208. }
  4209. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4210. {
  4211. entity.OrderState = 7;//发货后订单已发货
  4212. entity.OutSid = outSid;
  4213. entity.MemoOpt = 0;
  4214. entity.FinishDeliveryTime = DateTime.Now;
  4215. entity.Update();
  4216. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4217. commonHelper.UpdateRelationOrder(entity.ctid);
  4218. //还要插入快递信息到 快递信息表
  4219. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4220. exinfo.tid = eid;
  4221. exinfo.out_sid = outSid;
  4222. exinfo.company_code = comCode;
  4223. exinfo.company_name = comName;
  4224. exinfo.delivery_memo = deliveryMemo;
  4225. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4226. exinfo.deliveryType = deliveryType;
  4227. exinfo.Create();
  4228. returnSuccessMsg("发货操作成功!");
  4229. commonHelper.UpdateRelationOrder(entity.ctid);
  4230. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4231. CeErpSukuraData.createInfo(entity.ctid, 4);
  4232. if (entity.SupplierId == 64)
  4233. {
  4234. commonHelper.sendCytExpress(exinfo);
  4235. }
  4236. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4237. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4238. }
  4239. else
  4240. {
  4241. string errmsg = commonHelper.KeepChinese(apires);
  4242. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4243. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4244. }
  4245. return;
  4246. }
  4247. returnErrorMsg("找不到订单记录");
  4248. }
  4249. }
  4250. public void set_erp_multidelivery()
  4251. {
  4252. string eids = GetPostString("tids");
  4253. string[] eidList = eids.Split(',');
  4254. if (eidList.Length <= 0)
  4255. {
  4256. returnErrorMsg("发货不能为空");
  4257. return;
  4258. }
  4259. foreach (string ctid in eidList)
  4260. {
  4261. if (ctid.Length <= 0) continue;
  4262. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4263. if (expInfo != null)
  4264. {
  4265. StringBuilder sql = new StringBuilder();
  4266. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4267. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4268. if (dt.Rows.Count > 0)
  4269. {
  4270. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4271. {
  4272. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4273. expInfo.state = "异常";
  4274. expInfo.isMultiDelivery = 1;
  4275. expInfo.Update();
  4276. continue;
  4277. }
  4278. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4279. {
  4280. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4281. expInfo.state = "异常";
  4282. expInfo.Update();
  4283. continue;
  4284. }
  4285. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4286. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4287. bool isInitOrderDeliv = false;
  4288. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4289. {
  4290. isInitOrderDeliv = true;
  4291. expInfo.isMultiDelivery = 1;
  4292. }
  4293. if (ctid.IndexOf("N") != -1)
  4294. {
  4295. StringBuilder sqlbucha = new StringBuilder();
  4296. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4297. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4298. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4299. commonHelper.UpdateRelationOrder(ctid);
  4300. expInfo.delivery_memo = "发货成功";
  4301. expInfo.state = "发货成功";
  4302. expInfo.isMultiDelivery = 1;
  4303. expInfo.Update();
  4304. }
  4305. else
  4306. {
  4307. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4308. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4309. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4310. {
  4311. expInfo.delivery_memo = "发货成功";
  4312. expInfo.state = "发货成功";
  4313. expInfo.isMultiDelivery = 1;
  4314. expInfo.Update();
  4315. commonHelper.UpdateRelationOrder(ctid);
  4316. CeErpSukuraData.createInfo(ctid, 4);
  4317. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4318. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4319. }
  4320. else
  4321. {
  4322. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4323. expInfo.state = "异常";
  4324. expInfo.Update();
  4325. }
  4326. }
  4327. }
  4328. }
  4329. }
  4330. returnSuccessMsg("操作完成");
  4331. }
  4332. public void reset_erp_memoopt()
  4333. {
  4334. if (UrlPostParmsCheck("ctid"))
  4335. {
  4336. string eid = GetPostString("ctid");
  4337. CeErpTradeCell entity = null;
  4338. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4339. if (entity != null)
  4340. {
  4341. string stropt = "";
  4342. if (entity.MemoOpt == 1)
  4343. {
  4344. stropt = "“改稿”";
  4345. }
  4346. else if (entity.MemoOpt == 2)
  4347. {
  4348. stropt = "“定稿”";
  4349. }
  4350. else if (entity.MemoOpt == 3)
  4351. {
  4352. stropt = "“完成查货”";
  4353. CeErpSukuraData.createInfo(entity.ctid, 6);
  4354. }
  4355. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4356. entity.MemoOpt = 0;
  4357. entity.Update();
  4358. returnSuccessMsg("操作成功!");
  4359. return;
  4360. }
  4361. returnErrorMsg("找不到记录");
  4362. }
  4363. }
  4364. public void get_erp_deliveryunusual()
  4365. {
  4366. DataStruct dStruct = GetPostStruct();
  4367. List<string> lw = new List<string>();
  4368. string tid = GetPostString("ctid");
  4369. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4370. string shopname = GetPostString("shopname");
  4371. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4372. string buyernick = GetPostString("buyer_nick");
  4373. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4374. string customer = GetPostString("customer");
  4375. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4376. string design = GetPostString("design");
  4377. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4378. string sellermemo = GetPostString("seller_memo");
  4379. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4380. string supplier = GetPostString("supplier");
  4381. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4382. string date1 = GetPostString("date1");
  4383. string date2 = GetPostString("date2");
  4384. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4385. if (dw.Length > 0) lw.Add(dw);
  4386. string placedate1 = GetPostString("placedate1");
  4387. string placedate2 = GetPostString("placedate2");
  4388. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4389. if (dw_place.Length > 0) lw.Add(dw_place);
  4390. string price1 = GetPostString("price1");
  4391. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4392. string price2 = GetPostString("price2");
  4393. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4394. string unusualCon = GetPostString("unusualcon");
  4395. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4396. string posTag = CurrentUser.UserPost.Post.Code;
  4397. if (posTag == "Supplier")
  4398. {
  4399. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4400. }
  4401. lw.Add(string.Format("OrderState = 6"));
  4402. lw.Add(string.Format("UnusualTag = 5"));
  4403. lw.Add(string.Format("IsRefund<={0}", 1));
  4404. dStruct.Order = "FinishPlaceTime desc";
  4405. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4406. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4407. writeGridDataTableJson(dStruct.TotalCount, dt);
  4408. }
  4409. public void get_erp_deliveryedlist()
  4410. {
  4411. DataStruct dStruct = GetPostStruct();
  4412. List<string> lw = new List<string>();
  4413. string tid = GetPostString("ctid");
  4414. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4415. string shopname = GetPostString("shopname");
  4416. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4417. string buyernick = GetPostString("buyer_nick");
  4418. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4419. string customer = GetPostString("customer");
  4420. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4421. string design = GetPostString("design");
  4422. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4423. string sellermemo = GetPostString("seller_memo");
  4424. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4425. string logistics = GetPostString("logistics");
  4426. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4427. string date1 = GetPostString("date1");
  4428. string date2 = GetPostString("date2");
  4429. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4430. //if (dw.Length > 0) lw.Add(dw);
  4431. string placedate1 = GetPostString("placedate1");
  4432. string placedate2 = GetPostString("placedate2");
  4433. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4434. if (fdw.Length > 0) lw.Add(fdw);
  4435. string devdate1 = GetPostString("deliverydate1");
  4436. string devdate2 = GetPostString("deliverydate2");
  4437. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4438. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4439. string price1 = GetPostString("price1");
  4440. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4441. string price2 = GetPostString("price2");
  4442. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4443. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4444. {
  4445. if (tid.Length > 0)
  4446. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4447. if (buyernick.Length > 0)
  4448. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4449. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4450. if (dw.Length > 0) lw.Add(dw);
  4451. }
  4452. else
  4453. {
  4454. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4455. }
  4456. string posTag = CurrentUser.UserPost.Post.Code;
  4457. if (posTag == "Supplier")
  4458. {
  4459. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4460. }
  4461. else
  4462. {
  4463. string supplier = GetPostString("supplier");
  4464. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4465. }
  4466. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4467. lw.Add(string.Format("IsRefund!={0}", 2));
  4468. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4469. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4470. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4471. if (dt != null)
  4472. {
  4473. foreach (DataRow dr in dt.Rows)
  4474. {
  4475. 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();
  4476. }
  4477. }
  4478. writeGridDataTableJson(dStruct.TotalCount, dt);
  4479. }
  4480. public void get_erp_pdddeliveryed()
  4481. {
  4482. DataStruct dStruct = GetPostStruct();
  4483. List<string> lw = new List<string>();
  4484. string tid = GetPostString("ctid");
  4485. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4486. string shopname = GetPostString("shopname");
  4487. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4488. string buyernick = GetPostString("buyer_nick");
  4489. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4490. string customer = GetPostString("customer");
  4491. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4492. string design = GetPostString("design");
  4493. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4494. string sellermemo = GetPostString("seller_memo");
  4495. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4496. string logistics = GetPostString("logistics");
  4497. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4498. string date1 = GetPostString("date1");
  4499. string date2 = GetPostString("date2");
  4500. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4501. //if (dw.Length > 0) lw.Add(dw);
  4502. string placedate1 = GetPostString("placedate1");
  4503. string placedate2 = GetPostString("placedate2");
  4504. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4505. if (fdw.Length > 0) lw.Add(fdw);
  4506. string devdate1 = GetPostString("deliverydate1");
  4507. string devdate2 = GetPostString("deliverydate2");
  4508. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4509. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4510. string price1 = GetPostString("price1");
  4511. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4512. string price2 = GetPostString("price2");
  4513. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4514. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4515. {
  4516. if (tid.Length > 0)
  4517. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4518. if (buyernick.Length > 0)
  4519. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4520. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4521. if (dw.Length > 0) lw.Add(dw);
  4522. }
  4523. else
  4524. {
  4525. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4526. }
  4527. string posTag = CurrentUser.UserPost.Post.Code;
  4528. if (posTag == "Supplier")
  4529. {
  4530. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4531. }
  4532. else
  4533. {
  4534. string supplier = GetPostString("supplier");
  4535. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4536. }
  4537. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4538. lw.Add(string.Format("type = 'PDD' "));
  4539. lw.Add(string.Format("IsRefund!={0}", 2));
  4540. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4541. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4542. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4543. foreach (DataRow dr in dt.Rows)
  4544. {
  4545. 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();
  4546. }
  4547. writeGridDataTableJson(dStruct.TotalCount, dt);
  4548. }
  4549. public void get_erp_jddeliveryed()
  4550. {
  4551. DataStruct dStruct = GetPostStruct();
  4552. List<string> lw = new List<string>();
  4553. string tid = GetPostString("ctid");
  4554. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4555. string shopname = GetPostString("shopname");
  4556. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4557. string buyernick = GetPostString("buyer_nick");
  4558. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4559. string customer = GetPostString("customer");
  4560. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4561. string design = GetPostString("design");
  4562. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4563. string sellermemo = GetPostString("seller_memo");
  4564. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4565. string date1 = GetPostString("date1");
  4566. string date2 = GetPostString("date2");
  4567. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4568. //if (dw.Length > 0) lw.Add(dw);
  4569. string placedate1 = GetPostString("placedate1");
  4570. string placedate2 = GetPostString("placedate2");
  4571. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4572. if (fdw.Length > 0) lw.Add(fdw);
  4573. string devdate1 = GetPostString("deliverydate1");
  4574. string devdate2 = GetPostString("deliverydate2");
  4575. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4576. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4577. string price1 = GetPostString("price1");
  4578. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4579. string price2 = GetPostString("price2");
  4580. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4581. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4582. {
  4583. if (tid.Length > 0)
  4584. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4585. if (buyernick.Length > 0)
  4586. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4587. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4588. if (dw.Length > 0) lw.Add(dw);
  4589. }
  4590. else
  4591. {
  4592. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4593. }
  4594. string posTag = CurrentUser.UserPost.Post.Code;
  4595. if (posTag == "Supplier")
  4596. {
  4597. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4598. }
  4599. else
  4600. {
  4601. string supplier = GetPostString("supplier");
  4602. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4603. }
  4604. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4605. lw.Add(string.Format("type = 'JD' "));
  4606. lw.Add(string.Format("IsRefund!={0}", 2));
  4607. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4608. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4609. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4610. foreach (DataRow dr in dt.Rows)
  4611. {
  4612. 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();
  4613. }
  4614. writeGridDataTableJson(dStruct.TotalCount, dt);
  4615. }
  4616. public void get_erp_allplacelist()
  4617. {
  4618. DataStruct dStruct = GetPostStruct();
  4619. List<string> lw = new List<string>();
  4620. string tid = GetPostString("ctid");
  4621. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4622. string shopname = GetPostString("shopname");
  4623. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4624. string buyernick = GetPostString("buyer_nick");
  4625. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4626. string customer = GetPostString("customer");
  4627. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4628. string design = GetPostString("design");
  4629. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4630. string sellermemo = GetPostString("seller_memo");
  4631. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4632. string supplier = GetPostString("supplier");
  4633. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4634. string date1 = GetPostString("date1");
  4635. string date2 = GetPostString("date2");
  4636. string pldate1 = GetPostString("placedate1");
  4637. string pldate2 = GetPostString("placedate2");
  4638. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4639. //if (dw.Length > 0) lw.Add(dw);
  4640. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4641. {
  4642. if (tid.Length > 0)
  4643. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4644. if (buyernick.Length > 0)
  4645. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4646. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4647. if (dw.Length > 0) lw.Add(dw);
  4648. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4649. if (dw_place.Length > 0) lw.Add(dw_place);
  4650. }
  4651. else
  4652. {
  4653. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4654. {
  4655. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4656. }
  4657. }
  4658. string price1 = GetPostString("price1");
  4659. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4660. string price2 = GetPostString("price2");
  4661. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4662. string posTag = CurrentUser.UserPost.Post.Code;
  4663. if (posTag == "Supplier")
  4664. {
  4665. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4666. }
  4667. lw.Add(string.Format("OrderState >= 6"));
  4668. lw.Add(string.Format("IsSample != 2 "));
  4669. lw.Add(string.Format("isDianziOrder = 0 "));
  4670. //lw.Add(string.Format("IsRefund<={0}", 1));
  4671. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4672. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4673. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4674. foreach (DataRow dr in dt.Rows)
  4675. {
  4676. 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();
  4677. }
  4678. writeGridDataTableJson(dStruct.TotalCount, dt);
  4679. }
  4680. public void get_erp_financeallplacelist()
  4681. {
  4682. DataStruct dStruct = GetPostStruct();
  4683. List<string> lw = new List<string>();
  4684. string tid = GetPostString("ctid");
  4685. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4686. string shopname = GetPostString("shopname");
  4687. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4688. string buyernick = GetPostString("buyer_nick");
  4689. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4690. string customer = GetPostString("customer");
  4691. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4692. string design = GetPostString("design");
  4693. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4694. string sellermemo = GetPostString("seller_memo");
  4695. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4696. string supplier = GetPostString("supplier");
  4697. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4698. string date1 = GetPostString("date1");
  4699. string date2 = GetPostString("date2");
  4700. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4701. if (dw.Length > 0) lw.Add(dw);
  4702. string pldate1 = GetPostString("placedate1");
  4703. string pldate2 = GetPostString("placedate2");
  4704. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4705. if (dw_place.Length > 0) lw.Add(dw_place);
  4706. string price1 = GetPostString("price1");
  4707. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4708. string price2 = GetPostString("price2");
  4709. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4710. string posTag = CurrentUser.UserPost.Post.Code;
  4711. if (posTag == "Supplier")
  4712. {
  4713. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4714. }
  4715. //lw.Add(string.Format("OrderState >= 6"));
  4716. lw.Add(string.Format("IsSample != 2 "));
  4717. lw.Add(string.Format("isDianziOrder = 0 "));
  4718. //lw.Add(string.Format("IsRefund<={0}", 1));
  4719. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4720. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4721. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4722. foreach (DataRow dr in dt.Rows)
  4723. {
  4724. 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();
  4725. }
  4726. writeGridDataTableJson(dStruct.TotalCount, dt);
  4727. }
  4728. public void get_erp_expresslist()
  4729. {
  4730. int listtype = GetInt("ltype");
  4731. DataStruct dStruct = GetPostStruct();
  4732. List<string> lw = new List<string>();
  4733. string tid = GetPostString("tid");
  4734. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4735. string outsid = GetPostString("out_sid");
  4736. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4737. string importer = GetPostString("ImportUserName");
  4738. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4739. string file = GetPostString("import_file");
  4740. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4741. string printman = GetPostString("printman");
  4742. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4743. string date1 = GetPostString("date1");
  4744. string date2 = GetPostString("date2");
  4745. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4746. if (dw.Length > 0) lw.Add(dw);
  4747. string fdate1 = GetPostString("finishdate1");
  4748. string fdate2 = GetPostString("finishdate2");
  4749. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4750. if (fdw.Length > 0) lw.Add(fdw);
  4751. if (listtype == 1)
  4752. {
  4753. lw.Add(string.Format("importUserId !=0"));
  4754. }
  4755. string posTag = CurrentUser.UserPost.Post.Code;
  4756. if (posTag == "Supplier")
  4757. {
  4758. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4759. }
  4760. if (dStruct.PageSize != 100000)
  4761. {
  4762. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4763. }
  4764. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4765. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4766. writeGridDataTableJson(dStruct.TotalCount, dt);
  4767. }
  4768. public void set_erp_buchaorderdelivery()
  4769. {
  4770. if (UrlPostParmsCheck("ctid"))
  4771. {
  4772. string eid = GetPostString("ctid");
  4773. CeErpTradeCell entity = null;
  4774. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4775. if (entity != null)
  4776. {
  4777. if (entity.IsSample != 2)
  4778. {
  4779. returnErrorMsg("补差价单才能标记为已发货");
  4780. return;
  4781. }
  4782. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4783. entity.OrderState = 7;
  4784. entity.Update();
  4785. returnSuccessMsg("操作成功!");
  4786. return;
  4787. }
  4788. returnErrorMsg("找不到记录");
  4789. }
  4790. }
  4791. public void get_stdtemplates()
  4792. {
  4793. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4794. //string res = taobaoHelper.test();
  4795. string res = apiHelper.API_PrintTemplate();
  4796. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4797. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4798. {
  4799. int sidx = res.IndexOf("error_code");
  4800. int eidx = res.IndexOf("success");
  4801. string msg = res.Substring(sidx, eidx - sidx);
  4802. returnErrorMsg(msg);
  4803. return;
  4804. }
  4805. if (res.Length <= 0)
  4806. {
  4807. returnErrorMsg("模板数据为空!");
  4808. return;
  4809. }
  4810. ReturnSuccess(res);
  4811. }
  4812. public void cancel_print_order()
  4813. {
  4814. if (UrlPostParmsCheck("ctid"))
  4815. {
  4816. string ctid = GetPostString("ctid");
  4817. CeErpTradeCell entity = null;
  4818. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4819. if (entity != null)
  4820. {
  4821. string res = "";
  4822. string code = entity.LastBillWaybillCode;
  4823. if (code == "")
  4824. {
  4825. code = entity.OutSid;
  4826. }
  4827. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  4828. XLog.SaveLog(0, "取消面单" + res);
  4829. }
  4830. }
  4831. }
  4832. public void set_erp_printwaybill()
  4833. {
  4834. if (UrlPostParmsCheck("ctid"))
  4835. {
  4836. string ctid = GetPostString("ctid");
  4837. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  4838. string cpName = GetPostString("cpname");
  4839. string isTogether = GetPostString("together");
  4840. //var res_obj = new
  4841. //{
  4842. // restype = 1,
  4843. // 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\"}"
  4844. //};
  4845. //string ro_json = JsonConvert.SerializeObject(res_obj);
  4846. //ReturnSuccess(ro_json);
  4847. //return;
  4848. bool isUseLastWayBillCode = false;
  4849. CeErpTradeCell entity = null;
  4850. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4851. if (entity != null)
  4852. {
  4853. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  4854. {
  4855. isUseLastWayBillCode = true;
  4856. }
  4857. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  4858. {
  4859. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  4860. return;
  4861. }
  4862. }
  4863. string res = "";
  4864. Api_waybill_code_response_Obj fullObj = null;
  4865. string pData_str = "";
  4866. string curUseWayBillCode = "";
  4867. if (isUseLastWayBillCode == false)
  4868. {
  4869. res = apiHelper.API_GetWaybill(cpCode, ctid);
  4870. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  4871. if (res.IndexOf("failure") != -1)
  4872. {
  4873. //int idx = res.IndexOf("sub_message");
  4874. //int idx2 = res.IndexOf("flag");
  4875. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  4876. string errMsgNeed = commonHelper.KeepChinese(res);
  4877. var res_objd = new
  4878. {
  4879. restype = 0,
  4880. data = "获取面单失败" + errMsgNeed
  4881. };
  4882. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  4883. returnSuccess(ro_jsond);
  4884. if (res.IndexOf("停发") != -1)
  4885. {
  4886. entity.UnusualCon = "物流停发";
  4887. entity.Update();
  4888. }
  4889. //returnErrorMsg("获取面单失败,"+emsg);
  4890. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  4891. return;
  4892. }
  4893. else if (res.IndexOf("errorMsg") != -1)
  4894. {
  4895. //int idx = res.IndexOf("errorMsg");
  4896. //int idx2 = res.IndexOf("}]}");
  4897. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  4898. string errMsgNeed = commonHelper.KeepChinese(res);
  4899. var res_objf = new
  4900. {
  4901. restype = 0,
  4902. data = "获取面单失败2" + errMsgNeed
  4903. };
  4904. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4905. if (res.IndexOf("停发") != -1)
  4906. {
  4907. entity.UnusualCon = "物流停发";
  4908. entity.Update();
  4909. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4910. if (trade != null)
  4911. {
  4912. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  4913. }
  4914. }
  4915. returnSuccess(ro_jsonf);
  4916. //returnErrorMsg("获取面单失败," + emsg);
  4917. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  4918. return;
  4919. }
  4920. try
  4921. {
  4922. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4923. //res = res.Replace(" ", "");
  4924. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  4925. }
  4926. catch (Exception ex)
  4927. {
  4928. XLog.SaveLog(0, "生成fullObj" + res);
  4929. var res_objf = new
  4930. {
  4931. restype = 0,
  4932. data = "生成fullObj发生错误" + ex.Message
  4933. };
  4934. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4935. returnSuccess(ro_jsonf);
  4936. return;
  4937. }
  4938. if (fullObj.response.data.content.Count > 0)
  4939. {
  4940. ContentItem codeObj = fullObj.response.data.content[0];
  4941. if (cpCode.IndexOf("SFFQ-") != -1)
  4942. {
  4943. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  4944. }
  4945. else
  4946. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  4947. curUseWayBillCode = codeObj.waybillCode;
  4948. }
  4949. else
  4950. {
  4951. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  4952. var res_objf = new
  4953. {
  4954. restype = 0,
  4955. data = "生成fullObj找不到快递单号waybillCode"
  4956. };
  4957. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4958. returnSuccess(ro_jsonf);
  4959. return;
  4960. }
  4961. }
  4962. else
  4963. {
  4964. //使用上次打印的快递单号
  4965. if (cpCode == "SFFQ-LY")
  4966. {
  4967. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  4968. }
  4969. else
  4970. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  4971. curUseWayBillCode = entity.LastBillWaybillCode;
  4972. }
  4973. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  4974. {
  4975. var res_obje = new
  4976. {
  4977. restype = 0,
  4978. data = "获取加密打印数据失败"
  4979. };
  4980. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  4981. returnSuccess(ro_jsone);
  4982. entity.LastBillCpCode = cpCode;
  4983. entity.LastBillWaybillCode = curUseWayBillCode;
  4984. entity.Update();
  4985. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  4986. //returnErrorMsg("获取加密打印数据失败");
  4987. return;
  4988. }
  4989. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  4990. //string msg = "{\"data\":\""+pageUrl+"\"}";
  4991. string btnType = "";
  4992. if (entity != null)
  4993. {
  4994. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4995. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4996. //cpcode是 YTO-CAINIAO
  4997. //string comCode = cpCode.Split('-')[0].ToString();
  4998. string apires = "";
  4999. if (ctid.IndexOf("N") != -1)
  5000. {
  5001. apires = "发货成功";
  5002. }
  5003. else
  5004. {
  5005. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5006. }
  5007. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5008. //打单后发货
  5009. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5010. {
  5011. try
  5012. {
  5013. btnType = "待发货";
  5014. entity.OutSid = curUseWayBillCode;
  5015. entity.OrderState = 7;
  5016. entity.IsUrgency = false;
  5017. entity.LastBillCpCode = "";
  5018. entity.LastBillWaybillCode = "";
  5019. entity.FinishDeliveryTime = DateTime.Now;
  5020. entity.IsReturn = 0;
  5021. entity.MemoOpt = 0;
  5022. entity.Update();
  5023. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5024. //还要插入快递信息到 快递信息表
  5025. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5026. exinfo.tid = entity.ctid;
  5027. exinfo.out_sid = entity.OutSid;
  5028. exinfo.company_code = cpCode;
  5029. exinfo.company_name = cpName;
  5030. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5031. exinfo.deliveryType = "发货成功";
  5032. exinfo.print_time = DateTime.Now;
  5033. exinfo.printUser = CurrentUser.UserName;
  5034. exinfo.Create();
  5035. commonHelper.UpdateRelationOrder(entity.ctid);
  5036. CeErpSukuraData.createInfo(ctid, 4);
  5037. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5038. if (entity.SupplierId == 64)
  5039. {
  5040. commonHelper.sendCytExpress(exinfo);
  5041. }
  5042. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5043. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5044. if (isTogether == "1")
  5045. {
  5046. StringBuilder sqlsb = new StringBuilder();
  5047. 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);
  5048. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5049. }
  5050. }
  5051. catch (Exception ex)
  5052. {
  5053. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5054. }
  5055. }
  5056. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5057. {
  5058. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5059. if (entity.OrderState == 6)
  5060. {
  5061. entity.OrderState = 7;
  5062. }
  5063. entity.FinishDeliveryTime = DateTime.Now;
  5064. btnType = "已发货";
  5065. entity.Update();
  5066. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5067. exinfo.tid = entity.ctid;
  5068. exinfo.out_sid = entity.OutSid;
  5069. exinfo.company_code = cpCode;
  5070. exinfo.company_name = cpName;
  5071. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5072. exinfo.deliveryType = "发货成功";
  5073. exinfo.print_time = DateTime.Now;
  5074. exinfo.printUser = CurrentUser.UserName;
  5075. exinfo.Create();
  5076. commonHelper.UpdateRelationOrder(entity.ctid);
  5077. CeErpSukuraData.createInfo(entity.ctid, 4);
  5078. if (entity.SupplierId == 64)
  5079. {
  5080. commonHelper.sendCytExpress(exinfo);
  5081. }
  5082. if (isTogether == "1")
  5083. {
  5084. StringBuilder sqlsb = new StringBuilder();
  5085. 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);
  5086. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5087. }
  5088. //不处理
  5089. }
  5090. else
  5091. {
  5092. entity.LastBillCpCode = cpCode;
  5093. entity.LastBillWaybillCode = curUseWayBillCode;
  5094. entity.Update();
  5095. string errmsg = commonHelper.KeepChinese(apires);
  5096. var res_objz = new
  5097. {
  5098. restype = 0,
  5099. data = "打单后发货失败"
  5100. };
  5101. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5102. returnSuccess(ro_jsonz);
  5103. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5104. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5105. return;
  5106. }
  5107. }
  5108. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5109. var res_obj = new
  5110. {
  5111. restype = 1,
  5112. data = pData_str
  5113. };
  5114. string ro_json = JsonConvert.SerializeObject(res_obj);
  5115. ReturnSuccess(ro_json);
  5116. return;
  5117. }
  5118. }
  5119. private string GetUTF8String(byte[] vs)
  5120. {
  5121. throw new NotImplementedException();
  5122. }
  5123. public void set_erp_printwaybill_cn()
  5124. {
  5125. if (UrlPostParmsCheck("ctid"))
  5126. {
  5127. string ctid = GetPostString("ctid");
  5128. string cpCode = GetPostString("cpcode");
  5129. string cpName = GetPostString("cpname");
  5130. string tempUrl = GetPostString("tempurl");
  5131. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5132. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5133. //string res = taobaoHelper.test();
  5134. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5135. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5136. {
  5137. int sidx = res.IndexOf("errorMsg");
  5138. int eidx = res.IndexOf("}");
  5139. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5140. var res_objzxx = new
  5141. {
  5142. restype = 0,
  5143. data = msg
  5144. };
  5145. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5146. returnSuccess(ro_jsonzxx);
  5147. //returnErrorMsg(msg);
  5148. return;
  5149. }
  5150. int idx = res.IndexOf("waybillCode");
  5151. int idx2 = res.IndexOf("printData");
  5152. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5153. string eid = GetPostString("ctid");
  5154. CeErpTradeCell entity = null;
  5155. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5156. if (entity != null)
  5157. {
  5158. string osid = entity.OutSid;
  5159. entity.OutSid = osid + "," + outsid;
  5160. entity.FinishDeliveryTime = DateTime.Now;
  5161. entity.OrderState = 7;
  5162. entity.IsReturn = 0;
  5163. entity.Update();
  5164. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5165. exinfo.tid = entity.ctid;
  5166. exinfo.out_sid = outsid;
  5167. exinfo.company_code = cpCode;
  5168. exinfo.company_name = cpName;
  5169. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5170. exinfo.deliveryType = "发货成功";
  5171. exinfo.print_time = DateTime.Now;
  5172. exinfo.printUser = CurrentUser.UserName;
  5173. exinfo.Create();
  5174. if (entity.SupplierId == 64)
  5175. {
  5176. commonHelper.sendCytExpress(exinfo);
  5177. }
  5178. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5179. }
  5180. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5181. var res_objz = new
  5182. {
  5183. restype = 1,
  5184. data = res
  5185. };
  5186. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5187. returnSuccess(ro_jsonz);
  5188. //ReturnSuccess(res);
  5189. }
  5190. }
  5191. ////打单,打印面单 获取面单号
  5192. //public void set_erp_printwaybill()
  5193. //{
  5194. // if (UrlPostParmsCheck("ctid"))
  5195. // {
  5196. // string ctid = GetPostString("ctid");
  5197. // string cpCode = GetPostString("cpcode");
  5198. // string tempUrl = GetPostString("tempurl");
  5199. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5200. // //string res = taobaoHelper.test();
  5201. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5202. // if (res.IndexOf("error_response") != -1)
  5203. // {
  5204. // int sidx = res.IndexOf("sub_msg");
  5205. // int eidx = res.IndexOf("request_id");
  5206. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5207. // returnErrorMsg(msg);
  5208. // return;
  5209. // }
  5210. // int idx = res.IndexOf("waybill_code");
  5211. // int idx2 = res.IndexOf("}]}");
  5212. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5213. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5214. // ReturnSuccess(res);
  5215. // }
  5216. //}
  5217. public void cancel_erp_aftersale()
  5218. {
  5219. if (UrlPostParmsCheck("ctid"))
  5220. {
  5221. string eid = GetPostString("ctid");
  5222. CeErpTradeCell entity = null;
  5223. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5224. if (entity != null)
  5225. {
  5226. //有过处理的售后,取消也不能删除 售 字,保留
  5227. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5228. {
  5229. entity.AfterSaleState = 4;
  5230. }
  5231. else
  5232. entity.AfterSaleState = 0;
  5233. entity.Update();
  5234. returnSuccessMsg("操作成功!");
  5235. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5236. return;
  5237. }
  5238. returnErrorMsg("找不到订单记录");
  5239. }
  5240. }
  5241. public void get_erp_aftersalelist()
  5242. {
  5243. DataStruct dStruct = GetPostStruct();
  5244. List<string> lw = new List<string>();
  5245. int st = GetInt("st");
  5246. string tid = GetPostString("ctid");
  5247. if (st == 3)
  5248. {
  5249. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5250. }
  5251. else
  5252. {
  5253. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5254. }
  5255. string shopname = GetPostString("shopname");
  5256. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5257. string buyernick = GetPostString("buyer_nick");
  5258. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5259. string sellermemo = GetPostString("seller_memo");
  5260. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5261. string orderState = GetPostString("orderState");
  5262. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5263. string afterState = GetPostString("afterstate");
  5264. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5265. string date1 = GetPostString("date1");
  5266. string date2 = GetPostString("date2");
  5267. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5268. if (dw.Length > 0) lw.Add(dw);
  5269. string price1 = GetPostString("price1");
  5270. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5271. string price2 = GetPostString("price2");
  5272. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5273. //lw.Add(string.Format("IsRefund!={0}", 1));
  5274. string reason = GetPostString("reason");
  5275. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5276. string method = GetPostString("method");
  5277. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5278. string handler = GetPostString("handler");
  5279. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5280. string handledate1 = GetPostString("handledate1");
  5281. string handledate2 = GetPostString("handledate2");
  5282. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5283. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5284. string finish1 = GetPostString("finishdate1");
  5285. string finish2 = GetPostString("finishdate2");
  5286. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5287. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5288. string afterdate1 = GetPostString("afterdate1");
  5289. string afterdate2 = GetPostString("afterdate2");
  5290. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5291. if (afterDate.Length > 0) lw.Add(afterDate);
  5292. string supplier = GetPostString("supplier");
  5293. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5294. string responsible = GetPostString("responsibleman");
  5295. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5296. string customer = GetPostString("customer");
  5297. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5298. string design = GetPostString("design");
  5299. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5300. string afterMemoType = GetPostString("aftermemotype");
  5301. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5302. string posCode = CurrentUser.UserPost.Post.Code;
  5303. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5304. //{
  5305. // string vstate = GetPostString("vstate");
  5306. // if (vstate.Length > 0)
  5307. // {
  5308. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5309. // }
  5310. // if (posCode == "Supplier")
  5311. // {
  5312. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5313. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5314. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5315. // }
  5316. // else
  5317. // {
  5318. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5319. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5320. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5321. // {
  5322. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5323. // }
  5324. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5325. // {
  5326. // int orgid = CurrentUser.UserPost.OrgID;
  5327. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5328. // }
  5329. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5330. // {
  5331. // string shopid = CurrentUser.User.pemShop;
  5332. // lw.Add(string.Format("shopId in ({0})", shopid));
  5333. // }
  5334. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5335. // //{
  5336. // // int org_id = CurrentUser.UserPost.OrgID;
  5337. // // lw.Add(string.Format("OrgID={0}", org_id));
  5338. // //}
  5339. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5340. // }
  5341. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5342. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5343. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5344. //}
  5345. if (st == 5)
  5346. {
  5347. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5348. {
  5349. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5350. {
  5351. string shopid = CurrentUser.User.pemShop;
  5352. lw.Add(string.Format("shopId in ({0})", shopid));
  5353. }
  5354. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5355. {
  5356. int mrOrgid = CurrentUser.UserPost.OrgID;
  5357. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5358. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5359. }
  5360. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5361. //{
  5362. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5363. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5364. //}
  5365. else
  5366. {
  5367. string userIdStr = "";
  5368. if (posCode == "CustomerService")
  5369. {
  5370. userIdStr = CurrentUser.UserID + "_k";
  5371. }
  5372. else if (posCode == "Designer" || posCode == "wxDesigner")
  5373. {
  5374. userIdStr = CurrentUser.UserID + "_s";
  5375. }
  5376. else if (posCode == "Place")
  5377. {
  5378. userIdStr = CurrentUser.UserID + "_x";
  5379. }
  5380. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5381. }
  5382. }
  5383. string placedate1 = GetPostString("placedate1");
  5384. string placedate2 = GetPostString("placedate2");
  5385. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5386. if (dwplace.Length > 0) lw.Add(dwplace);
  5387. string supState = GetPostString("supState");
  5388. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5389. string searchType = GetPostString("searchType");
  5390. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5391. {
  5392. lw.Add(string.Format("BackNum>1"));
  5393. }
  5394. lw.Add(string.Format("AfterSaleState>0"));
  5395. if (ex_psize > 0)
  5396. {
  5397. if (CurrentUser.UserPost.Post.Code == "Finance")
  5398. dStruct.Order = "pay_time desc";
  5399. else
  5400. dStruct.Order = "HandleTime desc";
  5401. }
  5402. else
  5403. dStruct.Order = "HandleTime desc";
  5404. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5405. DataTable dt = WebCache.GetData("view_test", dStruct);
  5406. writeGridDataTableJson(dStruct.TotalCount, dt);
  5407. }
  5408. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5409. //{
  5410. // lw.Add(string.Format("AfterSaleState=4"));
  5411. // string code = CurrentUser.UserPost.Post.Code;
  5412. // if (code == "CustomerService")
  5413. // {
  5414. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5415. // }
  5416. // else if (code == "Designer" || code == "DesignerMr")
  5417. // {
  5418. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5419. // }
  5420. // else if (code == "Place" || code == "PlaceMr")
  5421. // {
  5422. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5423. // }
  5424. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5425. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5426. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5427. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5428. //}
  5429. //else //处理中的售后,待处理和处理中合并
  5430. //{
  5431. // if (afterState.Length <= 0)
  5432. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5433. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5434. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5435. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5436. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5437. //}
  5438. }
  5439. public void get_erp_disagreeftersalelist()
  5440. {
  5441. DataStruct dStruct = GetPostStruct();
  5442. List<string> lw = new List<string>();
  5443. int st = 2;
  5444. string tid = GetPostString("ctid");
  5445. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5446. string shopname = GetPostString("shopname");
  5447. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5448. string buyernick = GetPostString("buyer_nick");
  5449. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5450. string sellermemo = GetPostString("seller_memo");
  5451. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5452. string orderState = GetPostString("orderState");
  5453. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5454. string afterState = GetPostString("afterstate");
  5455. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5456. string date1 = GetPostString("date1");
  5457. string date2 = GetPostString("date2");
  5458. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5459. if (dw.Length > 0) lw.Add(dw);
  5460. string price1 = GetPostString("price1");
  5461. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5462. string price2 = GetPostString("price2");
  5463. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5464. //lw.Add(string.Format("IsRefund!={0}", 1));
  5465. string reason = GetPostString("reason");
  5466. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5467. string method = GetPostString("method");
  5468. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5469. string handler = GetPostString("handler");
  5470. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5471. string handledate1 = GetPostString("handledate1");
  5472. string handledate2 = GetPostString("handledate2");
  5473. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5474. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5475. string afterdate1 = GetPostString("afterdate1");
  5476. string afterdate2 = GetPostString("afterdate2");
  5477. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5478. if (afterDate.Length > 0) lw.Add(afterDate);
  5479. string backdate1 = GetPostString("backdate1");
  5480. string backdate2 = GetPostString("backdate2");
  5481. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5482. if (backDate.Length > 0) lw.Add(backDate);
  5483. string supplier = GetPostString("supplier");
  5484. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5485. string responsible = GetPostString("responsibleman");
  5486. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5487. string customer = GetPostString("customer");
  5488. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5489. string design = GetPostString("design");
  5490. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5491. string afterSaleMemo = GetPostString("afterSaleMemo");
  5492. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5493. string afterMemoType = GetPostString("aftermemotype");
  5494. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5495. string aftersakereason = GetPostString("aftersakereason");
  5496. if (aftersakereason.Length > 0)
  5497. {
  5498. if (aftersakereason == "1")
  5499. {
  5500. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5501. }
  5502. if (aftersakereason == "2")
  5503. {
  5504. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5505. }
  5506. }
  5507. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5508. string poscode = CurrentUser.UserPost.Post.Code;
  5509. if (poscode != "SysAdmin")
  5510. {
  5511. string shopid = CurrentUser.User.pemShop;
  5512. lw.Add(string.Format("shopId in ({0})", shopid));
  5513. }
  5514. string searchType = GetPostString("searchType");
  5515. if (searchType == "wait")
  5516. {
  5517. lw.Add(string.Format("HandleTime is null"));
  5518. }
  5519. if (searchType == "handling")
  5520. {
  5521. lw.Add(string.Format("HandleTime is not null "));
  5522. }
  5523. if (searchType == "back" || searchType == "puBack")
  5524. {
  5525. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5526. }
  5527. if (searchType == "reBack")
  5528. {
  5529. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5530. }
  5531. if (searchType == "moreBack")
  5532. {
  5533. lw.Add(string.Format("backNum > 1"));
  5534. }
  5535. lw.Add(string.Format("(AfterSaleState=5)"));
  5536. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5537. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5538. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5539. writeGridDataTableJson(dStruct.TotalCount, dt);
  5540. }
  5541. public void get_erp_handlingaftersalelist()
  5542. {
  5543. DataStruct dStruct = GetPostStruct();
  5544. List<string> lw = new List<string>();
  5545. int st = 2;
  5546. string tid = GetPostString("ctid");
  5547. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5548. string shopname = GetPostString("shopname");
  5549. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5550. string buyernick = GetPostString("buyer_nick");
  5551. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5552. string sellermemo = GetPostString("seller_memo");
  5553. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5554. string orderState = GetPostString("orderState");
  5555. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5556. string afterState = GetPostString("afterstate");
  5557. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5558. string date1 = GetPostString("date1");
  5559. string date2 = GetPostString("date2");
  5560. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5561. if (dw.Length > 0) lw.Add(dw);
  5562. string price1 = GetPostString("price1");
  5563. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5564. string price2 = GetPostString("price2");
  5565. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5566. //lw.Add(string.Format("IsRefund!={0}", 1));
  5567. string reason = GetPostString("reason");
  5568. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5569. string method = GetPostString("method");
  5570. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5571. string handler = GetPostString("handler");
  5572. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5573. string handledate1 = GetPostString("handledate1");
  5574. string handledate2 = GetPostString("handledate2");
  5575. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5576. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5577. string afterdate1 = GetPostString("afterdate1");
  5578. string afterdate2 = GetPostString("afterdate2");
  5579. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5580. if (afterDate.Length > 0) lw.Add(afterDate);
  5581. string supplier = GetPostString("supplier");
  5582. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5583. string responsible = GetPostString("responsibleman");
  5584. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5585. string customer = GetPostString("customer");
  5586. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5587. string design = GetPostString("design");
  5588. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5589. string afterSaleMemo = GetPostString("afterSaleMemo");
  5590. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5591. string afterMemoType = GetPostString("aftermemotype");
  5592. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5593. string afterresult = GetPostString("afterresult");
  5594. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5595. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5596. string poscode = CurrentUser.UserPost.Post.Code;
  5597. if (poscode != "SysAdmin")
  5598. {
  5599. string shopid = CurrentUser.User.pemShop;
  5600. lw.Add(string.Format("shopId in ({0})", shopid));
  5601. }
  5602. string searchType = GetPostString("searchType");
  5603. if (searchType == "wait")
  5604. {
  5605. lw.Add(string.Format("HandleTime is null"));
  5606. }
  5607. if (searchType == "documentary")
  5608. {
  5609. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5610. }
  5611. if (searchType == "handling")
  5612. {
  5613. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5614. }
  5615. if (searchType == "back" || searchType == "puBack")
  5616. {
  5617. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5618. }
  5619. if (searchType == "reBack")
  5620. {
  5621. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5622. }
  5623. if (afterState.Length <= 0)
  5624. {
  5625. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5626. }
  5627. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5628. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5629. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5630. writeGridDataTableJson(dStruct.TotalCount, dt);
  5631. }
  5632. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5633. //public void get_erp_back_handlingaftersalelist()
  5634. //{
  5635. // DataStruct dStruct = GetPostStruct();
  5636. // List<string> lw = new List<string>();
  5637. // string tid = GetPostString("ctid");
  5638. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5639. // string shopname = GetPostString("shopname");
  5640. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5641. // string buyernick = GetPostString("buyer_nick");
  5642. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5643. // string sellermemo = GetPostString("seller_memo");
  5644. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5645. // string orderState = GetPostString("orderState");
  5646. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5647. // string afterState = GetPostString("afterstate");
  5648. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5649. // string date1 = GetPostString("date1");
  5650. // string date2 = GetPostString("date2");
  5651. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5652. // if (dw.Length > 0) lw.Add(dw);
  5653. // string price1 = GetPostString("price1");
  5654. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5655. // string price2 = GetPostString("price2");
  5656. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5657. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5658. // string reason = GetPostString("reason");
  5659. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5660. // string method = GetPostString("method");
  5661. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5662. // string handler = GetPostString("handler");
  5663. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5664. // string handledate1 = GetPostString("handledate1");
  5665. // string handledate2 = GetPostString("handledate2");
  5666. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5667. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5668. // string afterdate1 = GetPostString("afterdate1");
  5669. // string afterdate2 = GetPostString("afterdate2");
  5670. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5671. // if (afterDate.Length > 0) lw.Add(afterDate);
  5672. // string supplier = GetPostString("supplier");
  5673. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5674. // string responsible = GetPostString("responsibleman");
  5675. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5676. // string customer = GetPostString("customer");
  5677. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5678. // string design = GetPostString("design");
  5679. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5680. // string afterMemoType = GetPostString("aftermemotype");
  5681. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5682. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5683. // if (afterState.Length <= 0)
  5684. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5685. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5686. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5687. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5688. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5689. //}
  5690. public void get_erp_aftersaleverifylist()
  5691. {
  5692. DataStruct dStruct = GetPostStruct();
  5693. List<string> lw = new List<string>();
  5694. string tid = GetPostString("ctid");
  5695. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5696. string shopname = GetPostString("shopname");
  5697. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5698. string buyernick = GetPostString("buyer_nick");
  5699. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5700. string sellermemo = GetPostString("seller_memo");
  5701. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5702. string orderState = GetPostString("orderState");
  5703. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5704. //lw.Add(string.Format("IsRefund!={0}", 1));
  5705. string reason = GetPostString("reason");
  5706. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5707. string method = GetPostString("method");
  5708. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5709. string handler = GetPostString("handler");
  5710. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5711. string handledate1 = GetPostString("handledate1");
  5712. string handledate2 = GetPostString("handledate2");
  5713. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5714. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5715. string finish1 = GetPostString("finishdate1");
  5716. string finish2 = GetPostString("finishdate2");
  5717. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5718. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5719. string supplier = GetPostString("supplier");
  5720. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5721. string responsible = GetPostString("responsibleman");
  5722. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5723. string posCode = CurrentUser.UserPost.Post.Code;
  5724. string vstate = GetPostString("vstate");
  5725. if (vstate.Length > 0)
  5726. {
  5727. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5728. }
  5729. if (posCode == "Supplier")
  5730. {
  5731. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5732. lw.Add(string.Format("VerifyState = 0"));
  5733. lw.Add("type = 1");
  5734. lw.Add(string.Format("AfterSaleState={0}", 3));
  5735. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5736. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5737. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5738. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5739. writeGridDataTableJson(dStruct.TotalCount, dt);
  5740. }
  5741. else if (posCode == "logistics")
  5742. {
  5743. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5744. lw.Add(string.Format("VerifyState = 0"));
  5745. lw.Add("type = 2");
  5746. lw.Add(string.Format("AfterSaleState={0}", 3));
  5747. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5748. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5749. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5750. writeGridDataTableJson(dStruct.TotalCount, dt);
  5751. }
  5752. else
  5753. {
  5754. lw.Add(string.Format("(AfterSaleState = 3)"));
  5755. string reasonState = GetPostString("reasonState");
  5756. lw.Add("type = 0");
  5757. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5758. || posCode == "Summarize" || posCode == "Finance")
  5759. {
  5760. if (reasonState == "2")
  5761. {
  5762. lw.Add("VerifyState = 3");
  5763. }
  5764. else if (reasonState == "1")
  5765. {
  5766. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5767. }
  5768. else
  5769. {
  5770. lw.Add("VerifyState in (0,3)");
  5771. }
  5772. //不加条件,可以看全部
  5773. }
  5774. 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")
  5775. {
  5776. int orgid = CurrentUser.UserPost.OrgID;
  5777. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5778. if (string.IsNullOrEmpty(manageOrgId))
  5779. {
  5780. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5781. }
  5782. else
  5783. {
  5784. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5785. }
  5786. if (reasonState == "1")
  5787. {
  5788. lw.Add("VerifyState = 3");
  5789. }
  5790. else if (reasonState == "2")
  5791. {
  5792. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5793. }
  5794. else
  5795. {
  5796. }
  5797. }
  5798. else
  5799. {
  5800. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5801. }
  5802. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5803. //{
  5804. // int org_id = CurrentUser.UserPost.OrgID;
  5805. // lw.Add(string.Format("OrgID={0}", org_id));
  5806. //}
  5807. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  5808. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5809. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5810. writeGridDataTableJson(dStruct.TotalCount, dt);
  5811. }
  5812. }
  5813. public void get_erp_finishaftersalelist()
  5814. {
  5815. DataStruct dStruct = GetPostStruct();
  5816. List<string> lw = new List<string>();
  5817. int st = 4;
  5818. string tid = GetPostString("ctid");
  5819. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  5820. string shopname = GetPostString("shopname");
  5821. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5822. //lw.Add(string.Format("IsRefund!={0}", 1));
  5823. string reason = GetPostString("reason");
  5824. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5825. string method = GetPostString("method");
  5826. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5827. string buyernick = GetPostString("buyer_nick");
  5828. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5829. string handler = GetPostString("handler");
  5830. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5831. string handledate1 = GetPostString("handledate1");
  5832. string handledate2 = GetPostString("handledate2");
  5833. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5834. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5835. string finish1 = GetPostString("finishdate1");
  5836. string finish2 = GetPostString("finishdate2");
  5837. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5838. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5839. string supplier = GetPostString("supplier");
  5840. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5841. string responsible = GetPostString("responsibleman");
  5842. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5843. string vstate = GetPostString("vstate");
  5844. if (vstate.Length > 0)
  5845. {
  5846. if ("3".Equals(vstate))
  5847. {
  5848. lw.Add(string.Format("IsTem=1"));
  5849. }
  5850. else
  5851. {
  5852. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5853. }
  5854. }
  5855. lw.Add(string.Format("AfterSaleState=4"));
  5856. string code = CurrentUser.UserPost.Post.Code;
  5857. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  5858. {
  5859. //不加条件,可以看全部
  5860. }
  5861. else if (code == "Supplier")
  5862. {
  5863. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5864. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5865. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5866. }
  5867. else if (code == "logistics")
  5868. {
  5869. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  5870. lw.Add("type = 2");
  5871. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5872. }
  5873. 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")
  5874. {
  5875. int orgid = CurrentUser.UserPost.OrgID;
  5876. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  5877. if (string.IsNullOrEmpty(manageOrgIds))
  5878. {
  5879. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  5880. }
  5881. else
  5882. {
  5883. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  5884. }
  5885. }
  5886. else
  5887. {
  5888. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  5889. }
  5890. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5891. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5892. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5893. writeGridDataTableJson(dStruct.TotalCount, dt);
  5894. }
  5895. public void handle_erp_aftersale()
  5896. {
  5897. if (UrlPostParmsCheck("ctid"))
  5898. {
  5899. string eid = GetPostString("ctid");
  5900. string responStr = GetPostString("AfterSaleResponsible");
  5901. if (responStr.Length <= 0)
  5902. {
  5903. returnErrorMsg("售后责任人不能为空");
  5904. return;
  5905. }
  5906. bool isDesign = false;
  5907. double designFree = 0.00;
  5908. int responsibleId = 0;
  5909. CeErpTradeCell entity = null;
  5910. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5911. if (entity != null)
  5912. {
  5913. int isNeedNewOrder = GetPostInt("IsNewOrder");
  5914. string afterMethod = GetPostString("AfterSaleMethod");
  5915. if (isNeedNewOrder == 1)
  5916. {
  5917. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  5918. bool ishav = true;
  5919. if (newentity == null)
  5920. {
  5921. newentity = entity.Clone() as CeErpTradeCell;
  5922. ishav = false;
  5923. newentity.ctid = "S_" + entity.ctid;
  5924. newentity.OrderState = 0;
  5925. }
  5926. //唯一标识
  5927. newentity.OrderSn = newentity.ctid;
  5928. /* string orderSn = dataHelper.getSaleOrderSn();
  5929. if (orderSn != "")
  5930. {
  5931. newentity.OrderSn = orderSn;
  5932. }*/
  5933. newentity.AfterSaleState = 0;
  5934. newentity.AfterSaleMethod = afterMethod;
  5935. if (!ishav)
  5936. {
  5937. string memo_str = newentity.seller_memo;
  5938. memo_str = memo_str.Replace("(", "(");
  5939. memo_str = memo_str.Replace(")", ")");
  5940. int sIndex = memo_str.IndexOf("(");
  5941. int eIndex = memo_str.IndexOf(")");
  5942. if (sIndex == -1 || eIndex == -1)
  5943. {
  5944. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  5945. return;
  5946. }
  5947. string first = memo_str.Substring(0, sIndex + 1);
  5948. string memoCtid = newentity.OrderSn;
  5949. //if (memoCtid.IndexOf("C") != -1)
  5950. //{
  5951. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  5952. //if (CIdx.IndexOf("+") != -1)
  5953. //{
  5954. //CIdx = "C" + CIdx.Split('+')[1];
  5955. //}
  5956. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  5957. //}
  5958. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  5959. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  5960. string newMemo = first + memoCtid + last;
  5961. newentity.seller_memo = newMemo;
  5962. newentity.FinishPlaceTime = null;
  5963. newentity.UnusualTag = 0;
  5964. newentity.UnusualCon = "";
  5965. newentity.UnusualTime = null;
  5966. newentity.AfterSaleMemo = "";
  5967. newentity.AfterSaleMethod = afterMethod;
  5968. newentity.AfterSalePreTime = null;
  5969. newentity.AfterSaleReason = "";
  5970. newentity.AfterSaleResponsible = "";
  5971. newentity.AfterSaleState = 0;
  5972. newentity.AfterSaleTime = null;
  5973. newentity.AfterSaleUserId = 0;
  5974. newentity.AfterSaleSupplierState = 0;
  5975. newentity.LastBillWaybillCode = "";
  5976. newentity.LastBillCpCode = "";
  5977. newentity.FinishAfterSaleTime = null;
  5978. newentity.HandleTime = null;
  5979. newentity.IsSF = 0;
  5980. newentity.IsOldCustomer = 0;
  5981. newentity.UrgencyTime = null;
  5982. newentity.ResponsibleUserId = "";
  5983. newentity.IsVerifyToSupplier = false;
  5984. newentity.payment = 0;
  5985. newentity.CheckMemo = "";
  5986. newentity.OutSid = "";
  5987. newentity.CheckOrderTime = null;
  5988. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  5989. }
  5990. newentity.isAfterSaleOrder = 1;
  5991. newentity.IsRefund = 0;
  5992. string receiveMobile = GetPostString("receiver_mobile");
  5993. if (receiveMobile.Length > 0)
  5994. {
  5995. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  5996. if (trade != null)
  5997. {
  5998. trade.receiver_name = GetPostString("receiver_name");
  5999. trade.receiver_mobile = receiveMobile;
  6000. trade.receiver_state = GetPostString("receiver_state");
  6001. trade.receiver_city = GetPostString("receiver_city");
  6002. trade.receiver_district = GetPostString("receiver_district");
  6003. trade.receiver_address = GetPostString("receiver_address");
  6004. newentity.IsOffLineOrder = 1;
  6005. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6006. }
  6007. }
  6008. string st = GetPostString("ToState");
  6009. if (st.Length > 0)
  6010. {
  6011. if (newentity.OrderState <= 3)
  6012. {
  6013. newentity.WaitDesignTime = DateTime.Now;
  6014. newentity.StartDesignTime = null;
  6015. newentity.FinishDesignTime = null;
  6016. newentity.OrderState = 3;
  6017. if (st == "下单员")
  6018. {
  6019. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6020. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6021. {
  6022. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6023. }
  6024. }
  6025. else
  6026. {
  6027. newentity.WaitDesignTime = DateTime.Now;
  6028. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6029. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6030. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6031. {
  6032. DataRow user = dt1.Rows[0];
  6033. //找主管
  6034. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6035. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6036. if (dt != null && dt.Rows.Count > 0)
  6037. {
  6038. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6039. newentity.DesignUserId = designMr;
  6040. string key = "aftersale_order_" + designMr;
  6041. if (RedisHelper.HasKey(key))
  6042. {
  6043. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6044. list.Add(newentity.ctid);
  6045. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6046. }
  6047. }
  6048. //账号正常
  6049. if (user["State"].ToString() == "0")
  6050. {
  6051. newentity.DesignUserId = entity.DesignUserId;
  6052. string key = "aftersale_order_" + entity.DesignUserId;
  6053. if (RedisHelper.HasKey(key))
  6054. {
  6055. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6056. list.Add(newentity.ctid);
  6057. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6058. }
  6059. }
  6060. }
  6061. }
  6062. }
  6063. if (entity.IsXianHuo == 1)
  6064. {
  6065. newentity.OrderState = 6;
  6066. entity.FinishPlaceTime = DateTime.Now;
  6067. }
  6068. }
  6069. if (ishav)
  6070. {
  6071. newentity.Update();
  6072. }
  6073. else
  6074. {
  6075. newentity.Create();
  6076. CeErpTradeCellExtend.createInfo(newentity.ctid, 30, 20);
  6077. }
  6078. if (st != "下单员")
  6079. {
  6080. designHelper.API_GetPrintData_CreateOrder(newentity);
  6081. }
  6082. }
  6083. //处理售后扩展
  6084. string resIdStr = GetPostString("ResponsibleUserId");
  6085. string refundFees = GetPostString("refundFrees");
  6086. int IsComplain = GetPostInt("isComplain");
  6087. int IsBad = GetPostInt("isBad");
  6088. string IsOriginal = GetPostString("isOriginal");
  6089. double diffResultPrice = GetPostDouble("diffResultPrice");
  6090. string textResult = GetPostString("textResult");
  6091. string supplierResponsible = GetPostString("supplierResponsible");
  6092. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6093. if (ceErpTradeAfterSaleExtend == null)
  6094. {
  6095. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6096. ceErpTradeAfterSaleExtend.tid = eid;
  6097. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6098. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6099. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6100. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6101. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6102. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6103. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6104. ceErpTradeAfterSaleExtend.Create();
  6105. }
  6106. else
  6107. {
  6108. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6109. {
  6110. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6111. }
  6112. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6113. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6114. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6115. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6116. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6117. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6118. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6119. ceErpTradeAfterSaleExtend.Update();
  6120. }
  6121. int gysid = GetPostInt("ResponsibleSupId");
  6122. entity.AfterSaleUserId = CurrentUser.UserID;
  6123. entity.ResponsibleUserId = resIdStr;
  6124. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6125. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6126. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6127. {
  6128. CeErpTradeResponsible.DelByTid(eid, -1);
  6129. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6130. int backNum = 0;
  6131. if (number != null)
  6132. {
  6133. backNum = number.BackNum;
  6134. }
  6135. char[] separator = { ',' };
  6136. string[] sArray = resIdStr.Split(separator);
  6137. string[] refundFreeList = { };
  6138. if (refundFees.Length > 0)
  6139. {
  6140. refundFreeList = refundFees.Split(separator);
  6141. }
  6142. int index = -1;
  6143. foreach (string i in sArray)
  6144. {
  6145. index++;
  6146. if (i.Length <= 0) continue;
  6147. char[] separator2 = { '_' };
  6148. string idstr = i.Split(separator2)[0];
  6149. string idtype = i.Split(separator2)[1];
  6150. double refudFree = 0;
  6151. if (refundFreeList.Length > 0)
  6152. {
  6153. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6154. }
  6155. if (idtype == "s")
  6156. {
  6157. isDesign = true;
  6158. designFree = refudFree;
  6159. }
  6160. int userId = Convert.ToInt32(idstr);
  6161. int type = 0;
  6162. if (idtype == "g")
  6163. {
  6164. type = 1;
  6165. }
  6166. if (idtype == "w")
  6167. {
  6168. type = 2;
  6169. }
  6170. if (idtype == "t")
  6171. {
  6172. type = 3;
  6173. }
  6174. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6175. if (ceErpTradeResponsible == null)
  6176. {
  6177. ceErpTradeResponsible = new CeErpTradeResponsible();
  6178. ceErpTradeResponsible.tid = eid;
  6179. ceErpTradeResponsible.UserId = userId;
  6180. ceErpTradeResponsible.createdTime = DateTime.Now;
  6181. ceErpTradeResponsible.type = type;
  6182. if (type == 1)
  6183. {
  6184. ceErpTradeResponsible.IsSup = 1;
  6185. }
  6186. if (type == 2)
  6187. {
  6188. ceErpTradeResponsible.IsFlow = 1;
  6189. }
  6190. }
  6191. ceErpTradeResponsible.RefundFee = refudFree;
  6192. ceErpTradeResponsible.VerifyState = 0;
  6193. if (userId == 2125 || idtype == "w")
  6194. {
  6195. ceErpTradeResponsible.VerifyState = 1;
  6196. }
  6197. if (idtype == "w" && userId == 101)
  6198. {
  6199. ceErpTradeResponsible.VerifyState = 0;
  6200. }
  6201. if (ceErpTradeResponsible.ID > 0)
  6202. {
  6203. ceErpTradeResponsible.Update();
  6204. }
  6205. else
  6206. {
  6207. ceErpTradeResponsible.Create();
  6208. }
  6209. if (isDesign)
  6210. {
  6211. responsibleId = ceErpTradeResponsible.ID;
  6212. }
  6213. }
  6214. CeErpTradeResponsible.NumByTid(backNum, eid);
  6215. }
  6216. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6217. if (ceErpTradeCellExtend != null)
  6218. {
  6219. ceErpTradeCellExtend.returnVisit = 0;
  6220. ceErpTradeCellExtend.Update();
  6221. }
  6222. if (entity.HandleTime != null)
  6223. {
  6224. if (entity.AfterSaleState == 1)
  6225. {
  6226. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6227. }
  6228. else
  6229. {
  6230. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6231. }
  6232. }
  6233. else
  6234. {
  6235. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6236. entity.HandleTime = DateTime.Now;
  6237. }
  6238. bool isCompale = false;
  6239. if (entity.AfterSaleState == 5)
  6240. {
  6241. isCompale = true;
  6242. entity.AfterSaleState = 3;
  6243. }
  6244. entity.AfterSaleSupplierState = 0;
  6245. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6246. {
  6247. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6248. }
  6249. string sImgs = GetPostString("img");
  6250. entity.AfterSaleSupplierImg = sImgs;
  6251. entity.supRefundType = GetPostString("supRefundType");
  6252. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6253. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6254. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6255. entity.AfterSaleMemoType = GetPostString("MemoType");
  6256. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6257. {
  6258. entity.AfterSaleSupplierState = 2;
  6259. }
  6260. string df = GetPostString("DeductFee");
  6261. if (df == "")
  6262. {
  6263. df = "0";
  6264. }
  6265. string rf = GetPostString("RefundFee");
  6266. if (rf == "")
  6267. {
  6268. rf = "0";
  6269. }
  6270. string pm = GetPostString("AfterSalePayment");
  6271. if (pm == "")
  6272. {
  6273. pm = "0";
  6274. }
  6275. entity.AfterSalePayment = Convert.ToDouble(pm);
  6276. entity.DeductFee = Convert.ToDouble(df);
  6277. entity.RefundFee = Convert.ToDouble(rf);
  6278. entity.Update();
  6279. string toState = GetPostString("ToState");
  6280. string original = GetPostString("isOriginal");
  6281. ApiVo apiVo = new ApiVo();
  6282. apiVo.orderNumber = entity.ctid;
  6283. apiVo.actionName = "afterDesign";
  6284. apiVo.orderRemarks = entity.AfterSaleMethod;
  6285. apiVo.reasonRemarks = entity.AfterSaleReason;
  6286. apiVo.isDesign = isDesign;
  6287. apiVo.designFree = designFree;
  6288. apiVo.responsibleId = responsibleId;
  6289. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6290. if (toState == "设计师")
  6291. {
  6292. apiVo.isOriginal = Convert.ToBoolean(original);
  6293. }
  6294. designHelper.API_WorkCore(apiVo);//afterDesign
  6295. CeErpMethod methodSql = new CeErpMethod();
  6296. methodSql.con = entity.AfterSaleMethod;
  6297. methodSql.addTime = DateTime.Now;
  6298. methodSql.Create();
  6299. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6300. CeErpMethod.ExecuteNonQuery(delsql);
  6301. if (isCompale)
  6302. {
  6303. aftersale_data_change(entity.ctid);
  6304. }
  6305. returnSuccessMsg("操作成功!");
  6306. return;
  6307. }
  6308. returnErrorMsg("找不到订单记录");
  6309. }
  6310. }
  6311. public void ins_erp_toresponsible()
  6312. {
  6313. if (UrlPostParmsCheck("ctid"))
  6314. {
  6315. string eid = GetPostString("ctid");
  6316. CeErpTradeCell entity = null;
  6317. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6318. if (entity != null)
  6319. {
  6320. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6321. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6322. {
  6323. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6324. return;
  6325. }
  6326. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6327. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6328. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6329. entity.AfterSalePreTime = DateTime.Now;
  6330. //预完成给售后主管审核客户问题直接完成
  6331. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6332. {
  6333. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) == 0)
  6334. {
  6335. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6336. }
  6337. }
  6338. entity.AfterSaleState = 2;
  6339. entity.Update();
  6340. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6341. aftersale_data_change(entity.ctid);
  6342. returnSuccessMsg("操作成功!");
  6343. return;
  6344. }
  6345. returnErrorMsg("找不到订单记录");
  6346. }
  6347. }
  6348. public void cancel_erp_aftersaleanddelnew()
  6349. {
  6350. if (UrlPostParmsCheck("ctid"))
  6351. {
  6352. string eid = GetPostString("ctid");
  6353. CeErpTradeCell entity = null;
  6354. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6355. if (entity != null)
  6356. {
  6357. entity.AfterSaleState = 0;
  6358. entity.AfterSaleReason = "";
  6359. entity.AfterSaleMethod = "";
  6360. entity.AfterSaleMemo = "";
  6361. entity.AfterSaleResponsible = "";
  6362. entity.ResponsibleUserId = "";
  6363. entity.DeductFee = 0;
  6364. entity.RefundFee = 0;
  6365. entity.IsArbitrate = 0;
  6366. CeErpTradeResponsible.DelByTid(eid, -1);
  6367. entity.Update();
  6368. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6369. if (after != null)
  6370. {
  6371. if (after.OrderState < 5)
  6372. CeErpTradeCell.DelByCtid("S_" + eid);
  6373. }
  6374. returnSuccessMsg("操作成功!");
  6375. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6376. return;
  6377. }
  6378. returnErrorMsg("找不到订单记录");
  6379. }
  6380. }
  6381. public void get_erp_aftersale_pregather()
  6382. {
  6383. List<string> lw = new List<string>();
  6384. int st = GetInt("st");
  6385. string tid = GetPostString("ctid");
  6386. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or orderSn = '{0}')", tid));
  6387. string shopname = GetPostString("shopname");
  6388. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6389. string buyernick = GetPostString("buyer_nick");
  6390. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6391. string sellermemo = GetPostString("seller_memo");
  6392. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6393. string orderState = GetPostString("orderState");
  6394. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6395. string reason = GetPostString("reason");
  6396. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6397. string method = GetPostString("method");
  6398. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6399. string handler = GetPostString("handler");
  6400. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6401. string handledate1 = GetPostString("handledate1");
  6402. string handledate2 = GetPostString("handledate2");
  6403. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6404. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6405. string supplier = GetPostString("supplier");
  6406. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6407. string responsible = GetPostString("responsibleman");
  6408. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6409. string customer = GetPostString("customer");
  6410. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6411. string design = GetPostString("design");
  6412. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6413. string afterMemoType = GetPostString("aftermemotype");
  6414. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6415. string afterSaleMemo = GetPostString("afterSaleMemo");
  6416. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6417. string afterresult = GetPostString("afterresult");
  6418. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6419. string poscode = CurrentUser.UserPost.Post.Code;
  6420. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6421. {
  6422. string shopid = CurrentUser.User.pemShop;
  6423. lw.Add(string.Format("shopId in ({0})", shopid));
  6424. }
  6425. var mainwhere = string.Join(" and ", lw.ToArray());
  6426. string ro_json = "";
  6427. string type = GetPostString("gather_type");
  6428. if (poscode == "AfterSale")
  6429. {
  6430. //处理中
  6431. if (type == "Handling")
  6432. {
  6433. 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) : ""));
  6434. DataTable dt = null;
  6435. try
  6436. {
  6437. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6438. }
  6439. catch (Exception e)
  6440. {
  6441. dt = new DataTable();
  6442. }
  6443. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6444. return;
  6445. }
  6446. if (type == "Wait")
  6447. {
  6448. //待处理
  6449. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6450. DataTable dt1 = null;
  6451. try
  6452. {
  6453. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6454. }
  6455. catch (Exception e)
  6456. {
  6457. dt1 = new DataTable();
  6458. }
  6459. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6460. return;
  6461. }
  6462. if (type == "back")
  6463. {
  6464. //打回
  6465. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6466. DataTable dt2 = null;
  6467. try
  6468. {
  6469. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6470. }
  6471. catch (Exception e)
  6472. {
  6473. dt2 = new DataTable();
  6474. }
  6475. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6476. return;
  6477. }
  6478. if (type == "preCompletion")
  6479. {
  6480. //预完成
  6481. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6482. DataTable dt3 = null;
  6483. try
  6484. {
  6485. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6486. }
  6487. catch (Exception e)
  6488. {
  6489. dt3 = new DataTable();
  6490. }
  6491. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6492. return;
  6493. }
  6494. if (type == "documentary")
  6495. {
  6496. //跟单中
  6497. 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) : ""));
  6498. DataTable dt4 = null;
  6499. try
  6500. {
  6501. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6502. }
  6503. catch (Exception e)
  6504. {
  6505. dt4 = new DataTable();
  6506. }
  6507. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6508. return;
  6509. }
  6510. if (type == "reBack")
  6511. {
  6512. //被打回
  6513. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6514. DataTable dt1 = null;
  6515. try
  6516. {
  6517. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6518. }
  6519. catch (Exception e)
  6520. {
  6521. dt1 = new DataTable();
  6522. }
  6523. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6524. return;
  6525. }
  6526. }
  6527. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6528. {
  6529. if (type == "puBack")
  6530. {
  6531. //退回
  6532. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6533. DataTable dt = null;
  6534. try
  6535. {
  6536. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6537. }
  6538. catch (Exception e)
  6539. {
  6540. dt = new DataTable();
  6541. }
  6542. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6543. return;
  6544. }
  6545. if (type == "reBack")
  6546. {
  6547. //打回
  6548. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6549. DataTable dt1 = null;
  6550. try
  6551. {
  6552. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6553. }
  6554. catch (Exception e)
  6555. {
  6556. dt1 = new DataTable();
  6557. }
  6558. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6559. return;
  6560. }
  6561. if (type == "examEd")
  6562. {
  6563. //已审核
  6564. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6565. DataTable dt2 = null;
  6566. try
  6567. {
  6568. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6569. }
  6570. catch (Exception e)
  6571. {
  6572. dt2 = new DataTable();
  6573. }
  6574. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6575. return;
  6576. }
  6577. if (type == "waitExam")
  6578. {
  6579. //待审核
  6580. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6581. DataTable dt3 = null;
  6582. try
  6583. {
  6584. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6585. }
  6586. catch (Exception e)
  6587. {
  6588. dt3 = new DataTable();
  6589. }
  6590. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6591. return;
  6592. }
  6593. if (type == "Handling")
  6594. {
  6595. //处理中
  6596. 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) : ""));
  6597. DataTable dt4 = null;
  6598. try
  6599. {
  6600. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6601. }
  6602. catch (Exception e)
  6603. {
  6604. dt4 = new DataTable();
  6605. }
  6606. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6607. return;
  6608. }
  6609. if (type == "Wait")
  6610. {
  6611. //待处理
  6612. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6613. DataTable dt5 = null;
  6614. try
  6615. {
  6616. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6617. }
  6618. catch (Exception e)
  6619. {
  6620. dt5 = new DataTable();
  6621. }
  6622. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6623. return;
  6624. }
  6625. if (type == "documentary")
  6626. {
  6627. //跟单中
  6628. 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) : ""));
  6629. DataTable dt6 = null;
  6630. try
  6631. {
  6632. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6633. }
  6634. catch (Exception e)
  6635. {
  6636. dt6 = new DataTable();
  6637. }
  6638. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6639. return;
  6640. }
  6641. }
  6642. returnSuccess(ro_json);
  6643. }
  6644. public void end_erp_aftersale()
  6645. {
  6646. if (UrlPostParmsCheck("ctid"))
  6647. {
  6648. string eid = GetPostString("ctid");
  6649. CeErpTradeCell entity = null;
  6650. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6651. if (entity != null)
  6652. {
  6653. string stype = GetPostString("stype");
  6654. string typeStr = stype;
  6655. entity.AfterSaleState = 4;
  6656. entity.FinishAfterSaleTime = DateTime.Now;
  6657. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6658. entity.Update();
  6659. ApiVo apiVo = new ApiVo();
  6660. apiVo.orderNumber = entity.ctid;
  6661. apiVo.actionName = "afterOver";
  6662. designHelper.API_WorkCore(apiVo); //afterOver
  6663. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6664. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6665. CeErpSukuraData.createInfo(entity.ctid, 8);
  6666. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6667. returnSuccessMsg("操作成功!");
  6668. return;
  6669. }
  6670. returnErrorMsg("找不到订单记录");
  6671. }
  6672. }
  6673. public void ins_erp_finishaftersale()
  6674. {
  6675. if (UrlPostParmsCheck("id"))
  6676. {
  6677. string eid = GetPostString("id");
  6678. CeErpTradeResponsible entity = null;
  6679. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6680. if (entity != null)
  6681. {
  6682. entity.VerifyState = 1;
  6683. entity.VerifyTime = DateTime.Now;
  6684. entity.Update();
  6685. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6686. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6687. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6688. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6689. if (dt.Rows.Count <= 0)
  6690. {
  6691. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6692. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6693. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6694. CeErpSukuraData.createInfo(entity.tid, 8);
  6695. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6696. {
  6697. CeErpDesignerBill.Del(entity.tid);
  6698. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6699. }
  6700. }
  6701. returnSuccessMsg("操作成功!");
  6702. return;
  6703. }
  6704. returnErrorMsg("找不到订单记录");
  6705. }
  6706. }
  6707. public void upd_erp_arbitrateaftersale()
  6708. {
  6709. if (UrlPostParmsCheck("id"))
  6710. {
  6711. string eid = GetPostString("id");
  6712. CeErpTradeResponsible entity = null;
  6713. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6714. if (entity != null)
  6715. {
  6716. entity.IsArbitrate = 1;
  6717. entity.ArbitradeMemo = GetPostString("reason");
  6718. entity.VerifyState = 2;
  6719. entity.Update();
  6720. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6721. if (tradecell != null)
  6722. {
  6723. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6724. tradecell.IsArbitrate = 1;
  6725. tradecell.Update();
  6726. }
  6727. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6728. returnSuccessMsg("操作成功!");
  6729. return;
  6730. }
  6731. returnErrorMsg("找不到订单记录");
  6732. }
  6733. }
  6734. public void upd_erp_backaftersale()
  6735. {
  6736. if (UrlPostParmsCheck("tid"))
  6737. {
  6738. string eid = GetPostString("tid");
  6739. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6740. int backNum = 0;
  6741. if (number != null)
  6742. {
  6743. backNum = number.BackNum;
  6744. }
  6745. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6746. CeErpTradeCell entity = null;
  6747. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6748. if (entity != null)
  6749. {
  6750. entity.AfterSaleBackReason = GetPostString("backreason");
  6751. entity.AfterSaleState = 1;
  6752. entity.AfterSaleSupplierState = 0;
  6753. entity.Update();
  6754. returnSuccessMsg("操作成功!");
  6755. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6756. return;
  6757. }
  6758. returnErrorMsg("找不到订单记录");
  6759. }
  6760. }
  6761. public void get_erp_supplieraftersalelist()
  6762. {
  6763. DataStruct dStruct = GetPostStruct();
  6764. List<string> lw = new List<string>();
  6765. string tid = GetPostString("ctid");
  6766. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6767. string shopname = GetPostString("shopname");
  6768. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6769. string buyernick = GetPostString("buyer_nick");
  6770. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6771. string sellermemo = GetPostString("seller_memo");
  6772. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6773. string orderState = GetPostString("orderState");
  6774. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6775. string afterState = GetPostString("afterstate");
  6776. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6777. string date1 = GetPostString("date1");
  6778. string date2 = GetPostString("date2");
  6779. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6780. if (dw.Length > 0) lw.Add(dw);
  6781. string price1 = GetPostString("price1");
  6782. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6783. string price2 = GetPostString("price2");
  6784. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6785. string reason = GetPostString("reason");
  6786. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6787. string method = GetPostString("method");
  6788. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6789. string handledate1 = GetPostString("handledate1");
  6790. string handledate2 = GetPostString("handledate2");
  6791. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6792. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6793. string handler = GetPostString("handler");
  6794. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6795. string afterdate1 = GetPostString("afterdate1");
  6796. string afterdate2 = GetPostString("afterdate2");
  6797. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6798. if (afterDate.Length > 0) lw.Add(afterDate);
  6799. string customer = GetPostString("customer");
  6800. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6801. string design = GetPostString("design");
  6802. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6803. string afterMemoType = GetPostString("aftermemotype");
  6804. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6805. string vstate = GetPostString("vstate");
  6806. if (vstate.Length > 0)
  6807. {
  6808. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6809. }
  6810. lw.Add(string.Format("AfterSaleState>={0}", 2));
  6811. string supplier = GetPostString("supplier");
  6812. int supid = commonHelper.getSupplierIDByName(supplier);
  6813. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  6814. string posCode = CurrentUser.UserPost.Post.Code;
  6815. if (posCode == "Supplier")
  6816. {
  6817. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6818. }
  6819. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  6820. {
  6821. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  6822. }
  6823. else
  6824. {
  6825. lw.Add(string.Format("AfterSaleResSupId != 0"));
  6826. }
  6827. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6828. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6829. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6830. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6831. writeGridDataTableJson(dStruct.TotalCount, dt);
  6832. }
  6833. public void upd_erp_supverifyaftersale()
  6834. {
  6835. if (UrlPostParmsCheck("id"))
  6836. {
  6837. string id = GetPostString("id");
  6838. int st = GetPostInt("afterstate");
  6839. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6840. CeErpTradeCell entity = null;
  6841. if (ceErpTradeResponsible != null)
  6842. {
  6843. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6844. }
  6845. string afmemo = GetPostString("supmemo");
  6846. string image = GetPostString("image");
  6847. if (entity != null)
  6848. {
  6849. entity.AfterSaleSupplierState = st;
  6850. entity.AfterSaleSupplierMemo = afmemo;
  6851. entity.AfterSaleSupplierState = st;
  6852. if (st == 1)
  6853. {
  6854. ceErpTradeResponsible.VerifyState = 1;
  6855. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6856. ceErpTradeResponsible.Update();
  6857. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6858. if (isAll)
  6859. {
  6860. entity.AfterSaleState = 4;
  6861. entity.FinishAfterSaleTime = DateTime.Now;
  6862. }
  6863. }
  6864. else
  6865. {
  6866. CeErpTradeResponsible.dateByTid(entity.ctid);
  6867. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6868. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6869. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6870. if (num <= 1)
  6871. {
  6872. entity.AfterSaleState = 1;
  6873. }
  6874. else
  6875. {
  6876. entity.AfterSaleState = 5;
  6877. }
  6878. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6879. if (ceErpTradeAfterSaleExtend != null)
  6880. {
  6881. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6882. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6883. ceErpTradeAfterSaleExtend.Update();
  6884. }
  6885. else
  6886. {
  6887. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6888. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6889. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6890. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6891. ceErpTradeAfterSaleExtend.Create();
  6892. }
  6893. }
  6894. if (entity.AfterSaleState == 4)
  6895. {
  6896. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6897. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  6898. {
  6899. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6900. }
  6901. ApiVo apiVo = new ApiVo();
  6902. apiVo.orderNumber = entity.ctid;
  6903. apiVo.actionName = "afterOver";
  6904. designHelper.API_WorkCore(apiVo); //afterOver
  6905. }
  6906. entity.Update();
  6907. returnSuccessMsg("操作成功!");
  6908. CeErpSukuraData.createInfo(entity.ctid, 8);
  6909. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6910. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6911. return;
  6912. }
  6913. returnErrorMsg("找不到订单记录");
  6914. }
  6915. }
  6916. public void upd_erp_masteraftersale()
  6917. {
  6918. if (UrlPostParmsCheck("id"))
  6919. {
  6920. string id = GetPostString("id");
  6921. int st = GetPostInt("afterstate");
  6922. string afmemo = GetPostString("supmemo");
  6923. string image = GetPostString("image");
  6924. string textResult = GetPostString("textResult");
  6925. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6926. if (ceErpTradeResponsible != null)
  6927. {
  6928. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  6929. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6930. ceErpTradeResponsible.Update();
  6931. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6932. if (entity != null)
  6933. {
  6934. entity.AfterSaleSupplierState = st;
  6935. entity.AfterSaleSupplierMemo = afmemo;
  6936. if (st == 1)
  6937. {
  6938. }
  6939. else
  6940. {
  6941. CeErpTradeResponsible.dateByTid(entity.ctid);
  6942. //退回到售后
  6943. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6944. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6945. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6946. if (num <= 1)
  6947. {
  6948. entity.AfterSaleState = 1;
  6949. }
  6950. else
  6951. {
  6952. entity.AfterSaleState = 5;
  6953. }
  6954. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6955. if (ceErpTradeAfterSaleExtend != null)
  6956. {
  6957. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6958. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6959. ceErpTradeAfterSaleExtend.Update();
  6960. }
  6961. else
  6962. {
  6963. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6964. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6965. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6966. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6967. ceErpTradeAfterSaleExtend.Create();
  6968. }
  6969. }
  6970. entity.Update();
  6971. returnSuccessMsg("操作成功!");
  6972. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6973. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6974. return;
  6975. }
  6976. }
  6977. returnErrorMsg("找不到订单记录");
  6978. }
  6979. }
  6980. public void upd_erp_personaftersale()
  6981. {
  6982. if (UrlPostParmsCheck("id"))
  6983. {
  6984. string id = GetPostString("id");
  6985. int st = GetPostInt("afterstate");
  6986. string afmemo = GetPostString("supmemo");
  6987. string image = GetPostString("image");
  6988. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6989. if (ceErpTradeResponsible != null)
  6990. {
  6991. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  6992. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6993. ceErpTradeResponsible.Update();
  6994. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6995. if (entity != null)
  6996. {
  6997. entity.AfterSaleSupplierMemo = afmemo;
  6998. entity.AfterSaleSupplierState = st;
  6999. if (st == 1)
  7000. {
  7001. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7002. if (isAll)
  7003. {
  7004. entity.AfterSaleState = 4;
  7005. entity.FinishAfterSaleTime = DateTime.Now;
  7006. }
  7007. }
  7008. else
  7009. {
  7010. CeErpTradeResponsible.dateByTid(entity.ctid);
  7011. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7012. if (ceErpTradeAfterSaleExtend != null)
  7013. {
  7014. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7015. ceErpTradeAfterSaleExtend.Update();
  7016. }
  7017. else
  7018. {
  7019. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7020. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7021. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7022. ceErpTradeAfterSaleExtend.Create();
  7023. }
  7024. //退回到主管
  7025. //entity.AfterSaleState = 2;
  7026. }
  7027. if (entity.AfterSaleState == 4)
  7028. {
  7029. ApiVo apiVo = new ApiVo();
  7030. apiVo.orderNumber = entity.ctid;
  7031. apiVo.actionName = "afterOver";
  7032. designHelper.API_WorkCore(apiVo); //afterOver
  7033. }
  7034. entity.Update();
  7035. returnSuccessMsg("操作成功!");
  7036. CeErpSukuraData.createInfo(entity.ctid, 8);
  7037. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7038. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7039. return;
  7040. }
  7041. }
  7042. returnErrorMsg("找不到订单记录");
  7043. }
  7044. }
  7045. public void set_erp_supplierrefundtag()
  7046. {
  7047. if (UrlPostParmsCheck("ctid"))
  7048. {
  7049. string eid = GetPostString("ctid");
  7050. CeErpTradeCell entity = null;
  7051. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7052. if (entity != null)
  7053. {
  7054. entity.IsSupplierRefund = GetPostInt("tag");
  7055. entity.Update();
  7056. returnSuccessMsg("操作成功!");
  7057. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7058. return;
  7059. }
  7060. returnErrorMsg("找不到订单记录");
  7061. }
  7062. }
  7063. public void get_erp_refundlist()
  7064. {
  7065. DataStruct dStruct = GetPostStruct();
  7066. List<string> lw = new List<string>();
  7067. string tid = GetPostString("tid");
  7068. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7069. //string rid = GetPostString("refund_id");
  7070. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7071. string shopname = GetPostString("shopname");
  7072. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7073. string buyernick = GetPostString("buyer_nick");
  7074. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7075. string customer = GetPostString("customer");
  7076. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7077. string design = GetPostString("design");
  7078. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7079. string sellermemo = GetPostString("seller_memo");
  7080. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7081. //string date1 = GetPostString("date1");
  7082. //string date2 = GetPostString("date2");
  7083. //string dateType = GetPostString("dateType");
  7084. //if (dateType.Length > 0)
  7085. //{
  7086. // if (dateType == "1001") dateType = "0";
  7087. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7088. // if (searchDT.Count == 2)
  7089. // {
  7090. // date1 = searchDT[0].ToString();
  7091. // date2 = searchDT[1].ToString();
  7092. // }
  7093. //}
  7094. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7095. //if (dw.Length > 0) lw.Add(dw);
  7096. string redate1 = GetPostString("refunddate1");
  7097. string redate2 = GetPostString("refunddate2");
  7098. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7099. if (dwdate.Length > 0) lw.Add(dwdate);
  7100. string price1 = GetPostString("price1");
  7101. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7102. string price2 = GetPostString("price2");
  7103. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7104. string ispartrefund = GetPostString("ispartrefund");
  7105. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7106. string refundState = GetPostString("refundvstate");
  7107. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7108. int st = GetInt("st");
  7109. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7110. {
  7111. string responsible = GetPostString("responsibleman");
  7112. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7113. lw.Add(string.Format("RefundState>={0}", st));
  7114. string code = CurrentUser.UserPost.Post.Code;
  7115. if (code == "CustomerService")
  7116. {
  7117. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7118. }
  7119. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7120. {
  7121. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7122. }
  7123. else if (code == "Place" || code == "PlaceMr")
  7124. {
  7125. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7126. }
  7127. dStruct.Order = "RefundState asc,created desc";
  7128. }
  7129. else if (st == 10)
  7130. {
  7131. string responsible = GetPostString("responsibleman");
  7132. if (responsible == "空白")
  7133. {
  7134. lw.Add(string.Format("ResponsibleUserName = ''"));
  7135. }
  7136. else if (responsible.Length > 0)
  7137. {
  7138. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7139. }
  7140. lw.Add(string.Format("RefundState>=0"));
  7141. dStruct.Order = "created desc";
  7142. }
  7143. else
  7144. {
  7145. string responsible = GetPostString("responsibleman");
  7146. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7147. lw.Add(string.Format("RefundState={0}", st));
  7148. dStruct.Order = "created desc";
  7149. }
  7150. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7151. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7152. dt.Columns.Add("refund_fees");
  7153. foreach (DataRow dr in dt.Rows)
  7154. {
  7155. String status = dr["status"].ToString();
  7156. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7157. {
  7158. dr["refund_fees"] = dr["refund_fee"];
  7159. }
  7160. else
  7161. {
  7162. dr["refund_fees"] = "0.0";
  7163. }
  7164. }
  7165. writeGridDataTableJson(dStruct.TotalCount, dt);
  7166. }
  7167. public void get_erp_refunddesignlist()
  7168. {
  7169. DataStruct dStruct = GetPostStruct();
  7170. List<string> lw = new List<string>();
  7171. string tid = GetPostString("tid");
  7172. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7173. string shopname = GetPostString("shopname");
  7174. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7175. string buyernick = GetPostString("buyer_nick");
  7176. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7177. string customer = GetPostString("customer");
  7178. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7179. string design = GetPostString("design");
  7180. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7181. string sellermemo = GetPostString("seller_memo");
  7182. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7183. string redate1 = GetPostString("refunddate1");
  7184. string redate2 = GetPostString("refunddate2");
  7185. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7186. if (dwdate.Length > 0) lw.Add(dwdate);
  7187. string price1 = GetPostString("price1");
  7188. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7189. string price2 = GetPostString("price2");
  7190. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7191. string ispartrefund = GetPostString("ispartrefund");
  7192. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7193. string designerorg = GetPostString("designerorg");
  7194. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7195. string refundState = GetPostString("refundState");
  7196. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7197. int myOrgid = CurrentUser.UserPost.OrgID;
  7198. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7199. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7200. {
  7201. if (CurrentUser.User.TeamIds.Length > 0)
  7202. {
  7203. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7204. }
  7205. else
  7206. {
  7207. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7208. }
  7209. }
  7210. else if ("SysAdmin".Equals(myOrgCode))
  7211. {
  7212. }
  7213. else
  7214. {
  7215. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7216. {
  7217. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7218. }
  7219. else
  7220. {
  7221. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7222. }
  7223. }
  7224. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7225. dStruct.Order = "created desc";
  7226. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7227. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7228. dt.Columns.Add("refund_fees");
  7229. foreach (DataRow dr in dt.Rows)
  7230. {
  7231. String status = dr["status"].ToString();
  7232. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7233. {
  7234. dr["refund_fees"] = dr["refund_fee"];
  7235. }
  7236. else
  7237. {
  7238. dr["refund_fees"] = "0.0";
  7239. }
  7240. }
  7241. writeGridDataTableJson(dStruct.TotalCount, dt);
  7242. }
  7243. public void handle_erp_refundtag()
  7244. {
  7245. if (UrlPostParmsCheck("refund_id"))
  7246. {
  7247. string eid = GetPostString("refund_id");
  7248. string respMan = GetPostString("ResponsibleName");
  7249. if (respMan.Length <= 0)
  7250. {
  7251. returnErrorMsg("责任人不能为空");
  7252. return;
  7253. }
  7254. CeErpTradeRefund entity = null;
  7255. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7256. if (entity != null)
  7257. {
  7258. entity.ResponsibleUserName = respMan;
  7259. string userid = GetPostString("ResponsibleUserId");
  7260. if (userid.Length > 0)
  7261. {
  7262. entity.ResponsibleUserId = userid;
  7263. }
  7264. entity.Memo = GetPostString("Memo");
  7265. if (respMan.IndexOf("客服") != -1 ||
  7266. respMan.IndexOf("设计师") != -1 ||
  7267. respMan.IndexOf("下单员") != -1)
  7268. {
  7269. entity.RefundState = 2;
  7270. }
  7271. else
  7272. {
  7273. entity.RefundState = 3;
  7274. }
  7275. entity.modified = DateTime.Now;
  7276. entity.Update();
  7277. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7278. returnSuccessMsg("操作成功!");
  7279. return;
  7280. }
  7281. returnErrorMsg("找不到订单记录");
  7282. }
  7283. }
  7284. public void handle_erp_designrefundtag()
  7285. {
  7286. if (UrlPostParmsCheck("refund_id"))
  7287. {
  7288. string eid = GetPostString("refund_id");
  7289. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7290. if (ceErpTradeCellExtend == null)
  7291. {
  7292. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7293. ceErpTradeCellExtend.ctid = eid;
  7294. }
  7295. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7296. if (ceErpTradeCellExtend.ID > 0)
  7297. {
  7298. ceErpTradeCellExtend.Update();
  7299. }
  7300. else
  7301. {
  7302. ceErpTradeCellExtend.Create();
  7303. }
  7304. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7305. returnSuccessMsg("操作成功!");
  7306. return;
  7307. }
  7308. returnErrorMsg("找不到订单记录");
  7309. }
  7310. public void upd_erp_refundverify()
  7311. {
  7312. if (UrlPostParmsCheck("refund_id"))
  7313. {
  7314. string eid = GetPostString("refund_id");
  7315. CeErpTradeRefund entity = null;
  7316. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7317. if (entity != null)
  7318. {
  7319. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7320. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7321. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7322. {
  7323. entity.RefundState = 2;
  7324. }
  7325. else
  7326. {
  7327. entity.RefundState = 3;
  7328. }
  7329. entity.Update();
  7330. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7331. returnSuccessMsg("操作成功!");
  7332. return;
  7333. }
  7334. returnErrorMsg("找不到订单记录");
  7335. }
  7336. }
  7337. public void upd_erp_refundapprove()
  7338. {
  7339. if (UrlPostParmsCheck("refund_id"))
  7340. {
  7341. string eid = GetPostString("refund_id");
  7342. CeErpTradeRefund entity = null;
  7343. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7344. if (entity != null)
  7345. {
  7346. int apr = GetPostInt("approve");
  7347. if (apr == 0)
  7348. {
  7349. entity.RefundState = 1;
  7350. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7351. }
  7352. else if (apr == 1)
  7353. {
  7354. entity.RefundState = 3;
  7355. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7356. }
  7357. entity.modified = DateTime.Now;
  7358. entity.Update();
  7359. returnSuccessMsg("操作成功!");
  7360. return;
  7361. }
  7362. returnErrorMsg("找不到订单记录");
  7363. }
  7364. }
  7365. public void get_erp_billlist()
  7366. {
  7367. DataStruct dStruct = GetPostStruct();
  7368. List<string> lw = new List<string>();
  7369. string title = GetPostString("title");
  7370. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7371. string tid = GetPostString("tid");
  7372. string tids = GetPostString("tids");
  7373. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7374. if (tids.Length > 0)
  7375. {
  7376. tids = "'" + tids + "'";
  7377. tids = tids.Replace(",", "','");
  7378. lw.Add(string.Format("tid in ({0})", tids));
  7379. }
  7380. string shopname = GetPostString("shopname");
  7381. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7382. string buyernick = GetPostString("buyer_nick");
  7383. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7384. string customer = GetPostString("customer");
  7385. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7386. string date1 = GetPostString("date1");
  7387. string date2 = GetPostString("date2");
  7388. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7389. if (dw.Length > 0) lw.Add(dw);
  7390. string price1 = GetPostString("price1");
  7391. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7392. string price2 = GetPostString("price2");
  7393. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7394. string returndate1 = GetPostString("returndate1");
  7395. string returndate2 = GetPostString("returndate2");
  7396. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7397. if (dw1.Length > 0) lw.Add(dw1);
  7398. string billtype = GetPostString("billtype");
  7399. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7400. string billstate = GetPostString("billstate");
  7401. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7402. string usershop = CurrentUser.User.pemShop;
  7403. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7404. dStruct.Order = "createTime desc";
  7405. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7406. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7407. //foreach (DataRow dr in dt.Rows)
  7408. //{
  7409. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7410. //}
  7411. writeGridDataTableJson(dStruct.TotalCount, dt);
  7412. }
  7413. public void modify_erp_billinfo()
  7414. {
  7415. if (UrlPostParmsCheck("ID"))
  7416. {
  7417. string eid = GetPostString("ID");
  7418. CeErpBill bill_entity = null;
  7419. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7420. if (bill_entity != null)
  7421. {
  7422. bill_entity.tid = GetPostString("tid");
  7423. bill_entity.title = GetPostString("title");
  7424. bill_entity.tax = GetPostString("tax");
  7425. bill_entity.bank = GetPostString("bank");
  7426. bill_entity.bankac = GetPostString("bankac");
  7427. bill_entity.address = GetPostString("address");
  7428. bill_entity.phone = GetPostString("phone");
  7429. bill_entity.price = GetPostString("price");
  7430. bill_entity.productId = GetPostInt("ProductName");
  7431. bill_entity.num = GetPostInt("num");
  7432. bill_entity.unit = GetPostString("unit");
  7433. bill_entity.type = GetPostString("type");
  7434. bill_entity.sendType = GetPostString("SendType");
  7435. bill_entity.email = GetPostString("email");
  7436. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7437. bill_entity.shopName = GetPostString("ShopName");
  7438. bill_entity.applymemo = GetPostString("applymemo");
  7439. bill_entity.modifyTime = DateTime.Now;
  7440. bill_entity.createTime = DateTime.Now;
  7441. bill_entity.state = 0;
  7442. bill_entity.Update();
  7443. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7444. returnSuccessMsg("发票修改成功!");
  7445. return;
  7446. }
  7447. returnErrorMsg("找不到对应记录");
  7448. }
  7449. }
  7450. public void set_erp_invoicing()
  7451. {
  7452. if (UrlPostParmsCheck("id"))
  7453. {
  7454. try
  7455. {
  7456. string eid = GetPostString("id");
  7457. CeErpBill bill_entity = null;
  7458. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7459. if (bill_entity != null)
  7460. {
  7461. int ComId = GetPostInt("ComId");
  7462. //string memo = GetPostString("Memo");
  7463. int allInfo = GetPostInt("allinfo");
  7464. string clert = CurrentUser.User.Name;
  7465. //string detailValue = GetPostString("detailvalue");
  7466. string billId = bill_entity.billOrderId;
  7467. string[] billIdList = billId.Split(',');
  7468. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7469. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7470. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7471. {
  7472. billCount += 1;
  7473. }
  7474. if (billId.Length <= 0 || billIdList.Length != billCount)
  7475. {
  7476. bill_entity.billOrderId = "";
  7477. string prebill = "ltb";
  7478. for (int idx = 1; idx <= billCount; idx++)
  7479. {
  7480. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7481. string billoid = prebill + idx + dtstr;
  7482. bill_entity.billOrderId += billoid;
  7483. if (idx < billCount)
  7484. {
  7485. bill_entity.billOrderId += ",";
  7486. }
  7487. }
  7488. }
  7489. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7490. if (bill_entity.state == 5)
  7491. {
  7492. string errMsg = bill_entity.failerror;
  7493. string[] errlist = errMsg.Split('|');
  7494. string[] errTags = new string[errlist.Length];
  7495. for (int itag = 0; itag < errlist.Length; itag++)
  7496. {
  7497. if (errlist[itag].Length <= 0) continue;
  7498. errTags[itag] = errlist[itag].Split('&')[0];
  7499. }
  7500. for (int iii = 0; iii < errTags.Length; iii++)
  7501. {
  7502. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7503. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7504. if (billOrderList.Length >= erroBillOrderTag)
  7505. {
  7506. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7507. if (needModifyBillId.Length <= 19)
  7508. {
  7509. needModifyBillId = needModifyBillId + "1";
  7510. }
  7511. else
  7512. {
  7513. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7514. last = last + 1;
  7515. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7516. }
  7517. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7518. }
  7519. }
  7520. }
  7521. bool isHaveBillSucces = false;
  7522. string totalRes = "";
  7523. bill_entity.failerror = "";
  7524. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7525. {
  7526. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7527. totalRes += res;
  7528. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7529. {
  7530. isHaveBillSucces = true;
  7531. bill_entity.comId = ComId;
  7532. bill_entity.state = 1;
  7533. bill_entity.executeTime = DateTime.Now;
  7534. bill_entity.executeUser = clert;
  7535. }
  7536. else
  7537. {
  7538. bill_entity.state = 5;
  7539. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7540. }
  7541. }
  7542. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7543. bill_entity.Update();
  7544. if (isHaveBillSucces)
  7545. {
  7546. StringBuilder sql = new StringBuilder();
  7547. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7548. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7549. }
  7550. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7551. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7552. {
  7553. returnErrorMsg("开票失败");
  7554. }
  7555. else
  7556. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7557. return;
  7558. }
  7559. returnErrorMsg("找不到对应记录");
  7560. }
  7561. catch (Exception ex)
  7562. {
  7563. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7564. returnErrorMsg("操作失败");
  7565. }
  7566. }
  7567. }
  7568. public void get_erp_invoicing_back()
  7569. {
  7570. if (UrlPostParmsCheck("id"))
  7571. {
  7572. try
  7573. {
  7574. string id = GetPostString("id");
  7575. CeErpBill entiy = CeErpBill.Get(id);
  7576. if (entiy != null)
  7577. {
  7578. if (entiy.state == 0)
  7579. {
  7580. returnErrorMsg("发票还未开具");
  7581. return;
  7582. }
  7583. string[] billOrderList = entiy.billOrderId.Split(',');
  7584. int iTag = 0;
  7585. entiy.fplsh = "";
  7586. entiy.fpdm = "";
  7587. entiy.fphm = "";
  7588. foreach (string billOrderId in billOrderList)
  7589. {
  7590. iTag++;
  7591. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7592. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7593. {
  7594. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7595. try
  7596. {
  7597. Invoicing_get_response_Obj iObj = null;
  7598. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7599. if (iObj != null)
  7600. {
  7601. entiy.state = 2;
  7602. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7603. entiy.fpdm += iObj.list[0].c_fpdm;
  7604. entiy.fphm += iObj.list[0].c_fphm;
  7605. if (iTag < billOrderList.Length)
  7606. {
  7607. entiy.fplsh += ",";
  7608. entiy.fpdm += ",";
  7609. entiy.fphm += ",";
  7610. }
  7611. entiy.Update();
  7612. }
  7613. StringBuilder sql = new StringBuilder();
  7614. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7615. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7616. returnSuccessMsg("开票成功");
  7617. }
  7618. catch (Exception ex)
  7619. {
  7620. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7621. }
  7622. return;
  7623. }
  7624. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7625. {
  7626. var res_obj = new
  7627. {
  7628. data = "开票中"
  7629. };
  7630. string ro_json = JsonConvert.SerializeObject(res_obj);
  7631. returnSuccess(ro_json);
  7632. return;
  7633. }
  7634. else
  7635. {
  7636. int eidx = res.IndexOf("c_resultmsg");
  7637. int lidx = res.IndexOf("c_status");
  7638. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7639. entiy.state = 5;
  7640. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7641. entiy.Update();
  7642. returnErrorMsg("开票失败");
  7643. return;
  7644. }
  7645. }
  7646. }
  7647. }
  7648. catch (Exception ex)
  7649. {
  7650. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7651. }
  7652. return;
  7653. }
  7654. }
  7655. public void get_erp_invoicing()
  7656. {
  7657. if (UrlPostParmsCheck("id"))
  7658. {
  7659. try
  7660. {
  7661. string id = GetPostString("id");
  7662. CeErpBill entiy = CeErpBill.Get(id);
  7663. if (entiy != null)
  7664. {
  7665. if (entiy.state == 0)
  7666. {
  7667. returnErrorMsg("发票还未开具");
  7668. return;
  7669. }
  7670. if (entiy.sendType == "纸质发票")
  7671. {
  7672. if (entiy.img.Length <= 0)
  7673. {
  7674. returnErrorMsg("查无纸质发票");
  7675. return;
  7676. }
  7677. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7678. returnSuccess(returnres);
  7679. return;
  7680. }
  7681. string[] billOrderList = entiy.billOrderId.Split(',');
  7682. int iTag = 0;
  7683. string fpUrl = "";
  7684. entiy.fplsh = "";
  7685. entiy.fpdm = "";
  7686. entiy.fphm = "";
  7687. foreach (string billOrderId in billOrderList)
  7688. {
  7689. iTag++;
  7690. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7691. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7692. {
  7693. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7694. Invoicing_get_response_Obj iObj = null;
  7695. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7696. if (iObj != null)
  7697. {
  7698. //entiy.state = 2;
  7699. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7700. entiy.fpdm += iObj.list[0].c_fpdm;
  7701. entiy.fphm += iObj.list[0].c_fphm;
  7702. if (iTag < billOrderList.Length)
  7703. {
  7704. entiy.fplsh += ",";
  7705. entiy.fpdm += ",";
  7706. entiy.fphm += ",";
  7707. }
  7708. entiy.Update();
  7709. fpUrl += iObj.list[0].c_url + ",";
  7710. }
  7711. //returnSuccess(res);
  7712. StringBuilder sql = new StringBuilder();
  7713. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7714. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7715. }
  7716. else
  7717. {
  7718. int eidx = res.IndexOf("c_resultmsg");
  7719. //int lidx = res.IndexOf("c_status");
  7720. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7721. //开票失败
  7722. entiy.state = 5;
  7723. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7724. entiy.Update();
  7725. returnErrorMsg("开票失败");
  7726. return;
  7727. }
  7728. }
  7729. var returnObj = new
  7730. {
  7731. data = fpUrl
  7732. };
  7733. string ro_json = JsonConvert.SerializeObject(returnObj);
  7734. returnSuccess(ro_json);
  7735. }
  7736. }
  7737. catch (Exception ex)
  7738. {
  7739. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7740. }
  7741. return;
  7742. }
  7743. }
  7744. public void save_erp_billimg()
  7745. {
  7746. if (UrlPostParmsCheck("id"))
  7747. {
  7748. string eid = GetPostString("id");
  7749. CeErpBill bill_entity = null;
  7750. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7751. if (bill_entity != null)
  7752. {
  7753. bill_entity.img = GetPostString("img");
  7754. bill_entity.executeTime = DateTime.Now;
  7755. bill_entity.state = 2;
  7756. bill_entity.Update();
  7757. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7758. returnSuccessMsg("保存成功");
  7759. }
  7760. return;
  7761. }
  7762. }
  7763. public void upd_erp_billreturnback()
  7764. {
  7765. if (UrlPostParmsCheck("id"))
  7766. {
  7767. int eid = GetPostInt("id");
  7768. CeErpBill bill_entity = null;
  7769. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7770. if (bill_entity != null)
  7771. {
  7772. bill_entity.state = 3;
  7773. bill_entity.returnReason = GetPostString("reason");
  7774. bill_entity.Update();
  7775. returnSuccessMsg("驳回成功!");
  7776. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7777. }
  7778. return;
  7779. }
  7780. }
  7781. public void cancel_erp_bill()
  7782. {
  7783. if (UrlPostParmsCheck("id"))
  7784. {
  7785. int eid = GetPostInt("id");
  7786. int detailValue = GetPostInt("detailvalue");
  7787. CeErpBill bill_entity = null;
  7788. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7789. string cres = "";
  7790. string gres = "";
  7791. if (bill_entity != null)
  7792. {
  7793. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7794. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  7795. {
  7796. int iTag = 0;
  7797. bill_entity.fplsh = "";
  7798. bill_entity.fpdm = "";
  7799. bill_entity.fphm = "";
  7800. foreach (string billOrderId in billOrderList)
  7801. {
  7802. iTag++;
  7803. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  7804. if (gres.IndexOf("success") != -1)
  7805. {
  7806. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  7807. Invoicing_get_response_Obj iObj = null;
  7808. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  7809. if (iObj != null)
  7810. {
  7811. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  7812. bill_entity.fpdm += iObj.list[0].c_fpdm;
  7813. bill_entity.fphm += iObj.list[0].c_fphm;
  7814. if (iTag < billOrderList.Length)
  7815. {
  7816. bill_entity.fplsh += ",";
  7817. bill_entity.fpdm += ",";
  7818. bill_entity.fphm += ",";
  7819. }
  7820. bill_entity.Update();
  7821. }
  7822. }
  7823. else
  7824. {
  7825. returnErrorMsg(gres);
  7826. return;
  7827. }
  7828. }
  7829. }
  7830. if (bill_entity.sendType == "纸质发票")
  7831. {
  7832. //作废
  7833. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  7834. //if (DateTime.Now.Month == extime.Month)
  7835. //{
  7836. //cres = taobaoHelper.cancel_invoicing(eid);
  7837. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  7838. //{
  7839. bill_entity.state = 4;//已作废
  7840. bill_entity.Update();
  7841. returnSuccessMsg("发票已作废");
  7842. return;
  7843. //}
  7844. //else
  7845. //{
  7846. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  7847. // bill_entity.Update();
  7848. // returnErrorMsg(cres);
  7849. // return;
  7850. //}
  7851. //}
  7852. //else
  7853. //{
  7854. // returnErrorMsg("纸质发票只能作废本月的发票");
  7855. // return;
  7856. //}
  7857. }
  7858. //红冲
  7859. int redTag = 0;
  7860. string[] fpdmList = bill_entity.fpdm.Split(',');
  7861. string[] fphmList = bill_entity.fphm.Split(',');
  7862. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  7863. {
  7864. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  7865. return;
  7866. }
  7867. foreach (string billOrderId in billOrderList)
  7868. {
  7869. redTag++;
  7870. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  7871. cres += onecres;
  7872. cres += ",";
  7873. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  7874. {
  7875. bill_entity.state = 4;//已作废
  7876. //bill_entity.Update();
  7877. //returnSuccessMsg("发票已红冲");
  7878. }
  7879. else if (onecres.IndexOf("重复冲红") != -1)
  7880. {
  7881. bill_entity.state = 4;//已作废
  7882. //bill_entity.Update();
  7883. //returnSuccessMsg("发票已红冲");
  7884. }
  7885. else
  7886. {
  7887. string errmsg = commonHelper.KeepChinese(onecres);
  7888. bill_entity.failerror += redTag + "&" + errmsg + "|";
  7889. }
  7890. }
  7891. bill_entity.Update();
  7892. if (cres.IndexOf("失败") != -1)
  7893. returnErrorMsg("红冲失败");
  7894. else
  7895. returnSuccessMsg("发票已红冲");
  7896. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  7897. return;
  7898. }
  7899. return;
  7900. }
  7901. }
  7902. public void del_erp_billorder()
  7903. {
  7904. if (UrlPostParmsCheck("id"))
  7905. {
  7906. string eid = GetPostString("id");
  7907. CeErpBill.Del(eid);
  7908. CeErpBill bill = CeErpBill.Get(eid);
  7909. if (bill != null)
  7910. {
  7911. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  7912. }
  7913. returnSuccessMsg("删除成功");
  7914. }
  7915. }
  7916. public void finish_erp_bill()
  7917. {
  7918. if (UrlPostParmsCheck("ids"))
  7919. {
  7920. string eids = GetPostString("ids");
  7921. string[] list = eids.Split(',');
  7922. foreach (string eid in list)
  7923. {
  7924. CeErpBill bill = CeErpBill.Get(eid);
  7925. if (bill != null)
  7926. {
  7927. bill.state = 2;
  7928. bill.Update();
  7929. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  7930. }
  7931. }
  7932. returnSuccessMsg("操作成功");
  7933. }
  7934. }
  7935. public void get_erp_returncash()
  7936. {
  7937. DataStruct dStruct = GetPostStruct();
  7938. List<string> lw = new List<string>();
  7939. string tid = GetPostString("tid");
  7940. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7941. string shopname = GetPostString("shopname");
  7942. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7943. string buyernick = GetPostString("buyer_nick");
  7944. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7945. string customer = GetPostString("customer");
  7946. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  7947. string returndate1 = GetPostString("returndate1");
  7948. string returndate2 = GetPostString("returndate2");
  7949. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  7950. if (dw.Length > 0) lw.Add(dw);
  7951. string finishDate1 = GetPostString("finishdate1");
  7952. string finishDate2 = GetPostString("finishdate2");
  7953. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  7954. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7955. string returntype = GetPostString("returntype");
  7956. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  7957. string returnvstate = GetPostString("returnvstate");
  7958. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  7959. dStruct.Order = "created desc";
  7960. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7961. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  7962. writeGridDataTableJson(dStruct.TotalCount, dt);
  7963. }
  7964. public void get_erp_staygoods()
  7965. {
  7966. DataStruct dStruct = GetPostStruct();
  7967. List<string> lw = new List<string>();
  7968. string tid = GetPostString("tid");
  7969. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7970. string shopname = GetPostString("shopname");
  7971. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  7972. string wangwang = GetPostString("wangwang");
  7973. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  7974. string customer = GetPostString("customer");
  7975. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  7976. string returndate1 = GetPostString("returndate1");
  7977. string returndate2 = GetPostString("returndate2");
  7978. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  7979. if (dw.Length > 0) lw.Add(dw);
  7980. string finishDate1 = GetPostString("finishdate1");
  7981. string finishDate2 = GetPostString("finishdate2");
  7982. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  7983. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7984. string returnvstate = GetPostString("returnvstate");
  7985. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  7986. string persuadetype = GetPostString("persuadetype");
  7987. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  7988. string customerOrg = GetPostString("customerOrg");
  7989. if (customerOrg.Length > 0)
  7990. {
  7991. lw.Add(string.Format("OrgID = {0}", customerOrg));
  7992. }
  7993. dStruct.Order = "creata_time desc";
  7994. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7995. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  7996. writeGridDataTableJson(dStruct.TotalCount, dt);
  7997. }
  7998. public void upd_erp_staygoods()
  7999. {
  8000. if (UrlPostParmsCheck("id"))
  8001. {
  8002. int eid = GetPostInt("id");
  8003. CeErpStayGoods entity = null;
  8004. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8005. if (entity != null)
  8006. {
  8007. entity.audit_type = 1;
  8008. entity.audit_time = DateTime.Now;
  8009. entity.audit_u_id = CurrentUser.UserID;
  8010. entity.audit_u_name = CurrentUser.UserName;
  8011. entity.Update();
  8012. returnSuccessMsg("审核成功!");
  8013. return;
  8014. }
  8015. returnErrorMsg("找不到订单记录");
  8016. }
  8017. }
  8018. public void upd_erp_stayGoodsback()
  8019. {
  8020. if (UrlPostParmsCheck("id"))
  8021. {
  8022. int eid = GetPostInt("id");
  8023. CeErpStayGoods entity = null;
  8024. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8025. if (entity != null)
  8026. {
  8027. entity.audit_text = GetPostString("reason");
  8028. entity.audit_type = 2;
  8029. entity.audit_time = DateTime.Now;
  8030. entity.audit_u_id = CurrentUser.UserID;
  8031. entity.audit_u_name = CurrentUser.UserName;
  8032. entity.Update();
  8033. returnSuccessMsg("退回成功!");
  8034. return;
  8035. }
  8036. returnErrorMsg("找不到订单记录");
  8037. }
  8038. }
  8039. public void upd_erp_returncashverify()
  8040. {
  8041. if (UrlPostParmsCheck("ID"))
  8042. {
  8043. int eid = GetPostInt("ID");
  8044. CeErpReturnCash entity = null;
  8045. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8046. if (entity != null)
  8047. {
  8048. entity.cashstate = 1;
  8049. entity.verifytime = DateTime.Now;
  8050. entity.verifyuserid = CurrentUser.UserID;
  8051. entity.Update();
  8052. returnSuccessMsg("审核成功!");
  8053. return;
  8054. }
  8055. returnErrorMsg("找不到订单记录");
  8056. }
  8057. }
  8058. public void upd_all_erp_returncashverify()
  8059. {
  8060. if (UrlPostParmsCheck("ID"))
  8061. {
  8062. String[] list = GetPostString("ID").Split(',');
  8063. CeErpReturnCash entity = null;
  8064. for (int i = 0; i < list.Length; i++)
  8065. {
  8066. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8067. if (entity != null)
  8068. {
  8069. if (entity.cashstate == 1)
  8070. {
  8071. returnErrorMsg("已审核过的订单不需要在审核!");
  8072. return;
  8073. }
  8074. entity.cashstate = 1;
  8075. entity.verifytime = DateTime.Now;
  8076. entity.verifyuserid = CurrentUser.UserID;
  8077. entity.Update();
  8078. }
  8079. }
  8080. returnSuccessMsg("审核成功!");
  8081. return;
  8082. }
  8083. }
  8084. public void upd_erp_returncashback()
  8085. {
  8086. if (UrlPostParmsCheck("ID"))
  8087. {
  8088. int eid = GetPostInt("ID");
  8089. CeErpReturnCash entity = null;
  8090. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8091. if (entity != null)
  8092. {
  8093. entity.backreason = GetPostString("reason");
  8094. entity.cashstate = 2;
  8095. entity.verifytime = DateTime.Now;
  8096. entity.verifyuserid = CurrentUser.UserID;
  8097. entity.Update();
  8098. returnSuccessMsg("退回成功!");
  8099. return;
  8100. }
  8101. returnErrorMsg("找不到订单记录");
  8102. }
  8103. }
  8104. public void upd_erp_returnprice()
  8105. {
  8106. if (UrlPostParmsCheck("ID"))
  8107. {
  8108. int eid = GetPostInt("ID");
  8109. CeErpReturnCash entity = null;
  8110. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8111. if (entity != null)
  8112. {
  8113. if (entity.cashstate == 1)
  8114. {
  8115. returnErrorMsg("审核通过了不能改");
  8116. return;
  8117. }
  8118. entity.returnprice = GetPostDouble("returnprice");
  8119. entity.Update();
  8120. returnSuccessMsg("修改成功!");
  8121. return;
  8122. }
  8123. returnErrorMsg("找不到订单记录");
  8124. }
  8125. }
  8126. public void del_erp_returncash()
  8127. {
  8128. if (UrlPostParmsCheck("ID"))
  8129. {
  8130. int eid = GetPostInt("ID");
  8131. CeErpReturnCash.Del(eid);
  8132. returnSuccessMsg("操作成功");
  8133. return;
  8134. }
  8135. }
  8136. public void test_for_do_sql()
  8137. {
  8138. string sql = GetPostString("sqlstr");
  8139. if (sql.Length > 0)
  8140. {
  8141. try
  8142. {
  8143. DbHelper.DbConn.ExecuteNonQuery(sql);
  8144. var res_obj = new
  8145. {
  8146. data = "成功",
  8147. };
  8148. string ro_json = JsonConvert.SerializeObject(res_obj);
  8149. returnSuccess(ro_json);
  8150. }
  8151. catch (Exception ex)
  8152. {
  8153. var res_obj = new
  8154. {
  8155. data = ex.Message,
  8156. };
  8157. string ro_json = JsonConvert.SerializeObject(res_obj);
  8158. returnSuccess(ro_json);
  8159. }
  8160. }
  8161. }
  8162. public void get_user_info()
  8163. {
  8164. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8165. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8166. }
  8167. public void get_total_data()
  8168. {
  8169. int userId = CurrentUser.UserID;
  8170. string sql = "";
  8171. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8172. {
  8173. 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);
  8174. }
  8175. else
  8176. {
  8177. 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 " +
  8178. "(select ID from CE_ErpUser where ID = {0}) d " +
  8179. "left join " +
  8180. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8181. ") a on d.ID = a.id left join " +
  8182. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8183. ") b on a.id = b.id1 left join" +
  8184. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8185. ") c on a.id = c.id2;", userId);
  8186. }
  8187. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8188. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8189. }
  8190. public void get_date_area_total_data2()
  8191. {
  8192. int userId = CurrentUser.UserID;
  8193. string date_type = GetPostString("timetype");
  8194. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8195. string sql = "";
  8196. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8197. {
  8198. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8199. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8200. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8201. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8202. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8203. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8204. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8205. ") a on e.ID = a.id left join " +
  8206. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8207. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8208. ") b on a.id = b.id1 " +
  8209. "left join " +
  8210. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8211. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8212. ") c on a.id = c.id2 " +
  8213. "left join " +
  8214. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8215. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8216. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8217. }
  8218. else
  8219. {
  8220. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8221. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8222. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8223. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8224. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8225. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8226. ") a on e.ID = a.id left join " +
  8227. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8228. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8229. ") c on a.id = c.id2 " +
  8230. "left join " +
  8231. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8232. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8233. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8234. }
  8235. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8236. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8237. }
  8238. public void get_date_area_total_data()
  8239. {
  8240. int userId = CurrentUser.UserID;
  8241. string date_type = GetPostString("timetype");
  8242. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8243. string date1 = searchDT[0].ToString();
  8244. string date2 = searchDT[1].ToString();
  8245. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8246. {
  8247. SqlParameter[] sqlParameter ={
  8248. new SqlParameter("@userId", SqlDbType.Int,4),
  8249. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8250. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8251. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8252. };
  8253. sqlParameter[0].Value = userId;
  8254. sqlParameter[1].Value = date1;
  8255. sqlParameter[2].Value = date2;
  8256. sqlParameter[3].Direction = ParameterDirection.Output;
  8257. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8258. string res = sqlParameter[3].Value.ToString();
  8259. var res_obj = new
  8260. {
  8261. data = res
  8262. };
  8263. string ro_json = JsonConvert.SerializeObject(res_obj);
  8264. returnSuccess(ro_json);
  8265. }
  8266. else
  8267. {
  8268. SqlParameter[] sqlParameter ={
  8269. new SqlParameter("@userId", SqlDbType.Int,4),
  8270. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8271. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8272. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8273. };
  8274. sqlParameter[0].Value = userId;
  8275. sqlParameter[1].Value = date1;
  8276. sqlParameter[2].Value = date2;
  8277. sqlParameter[3].Direction = ParameterDirection.Output;
  8278. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8279. string res = sqlParameter[3].Value.ToString();
  8280. var res_obj = new
  8281. {
  8282. data = res
  8283. };
  8284. string ro_json = JsonConvert.SerializeObject(res_obj);
  8285. returnSuccess(ro_json);
  8286. }
  8287. //writeGridDataViewJson(dt.Rows.Count, dv);
  8288. }
  8289. public void get_order_list()
  8290. {
  8291. string strFields = GetPostString("paraFields");
  8292. string strOrder = GetPostString("paraOrder");
  8293. string strWhere = GetPostString("paraWhere");
  8294. string strPageSize = GetPostString("paraPageSize");
  8295. DataStruct dStruct = GetPostStruct();
  8296. dStruct.PageSize = int.Parse(strPageSize);
  8297. dStruct.Fileds = strFields;
  8298. dStruct.Order = strOrder;
  8299. dStruct.MainWhere = strWhere;
  8300. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8301. writeGridDataTableJson(dStruct.TotalCount, dt);
  8302. }
  8303. ////获取待开始订单列表
  8304. //public void get_wait_design_order_list()
  8305. //{
  8306. // string date_type = GetPostString("date_type");
  8307. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8308. // DataStruct dStruct = GetPostStruct();
  8309. // dStruct.PageSize = 1000;
  8310. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8311. // List<string> lw = new List<string>();
  8312. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8313. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8314. // dStruct.Order = "WaitDesignTime asc";
  8315. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8316. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8317. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8318. //}
  8319. //获取完成单量排名
  8320. public void get_finish_order_count_ranking()
  8321. {
  8322. /* string date_type = GetPostString("date_type");
  8323. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8324. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8325. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8326. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8327. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8328. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8329. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8330. writeGridDataTableJson(0, new DataTable());
  8331. }
  8332. public void get_finish_order_amount_ranking()
  8333. {
  8334. /*string date_type = GetPostString("date_type");
  8335. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8336. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8337. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8338. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8339. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8340. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8341. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8342. writeGridDataTableJson(0, new DataTable());
  8343. }
  8344. public void get_finish_refund_count_ranking()
  8345. {
  8346. string date_type = GetPostString("date_type");
  8347. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8348. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8349. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8350. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8351. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8352. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8353. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8354. writeGridDataTableJson(dt.Rows.Count, dt);
  8355. }
  8356. public void get_finish_refund_amount_ranking()
  8357. {
  8358. string date_type = GetPostString("date_type");
  8359. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8360. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8361. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8362. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8363. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8364. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8365. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8366. writeGridDataTableJson(dt.Rows.Count, dt);
  8367. }
  8368. public void set_erp_finishorder_director()
  8369. {
  8370. if (UrlPostParmsCheck("ctid"))
  8371. {
  8372. string eid = GetPostString("ctid");
  8373. CeErpTradeCell entity = null;
  8374. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8375. if (entity != null)
  8376. {
  8377. entity.OrderState = 8;
  8378. entity.Update();
  8379. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8380. returnSuccessMsg("操作成功!");
  8381. return;
  8382. }
  8383. returnErrorMsg("找不到记录");
  8384. }
  8385. }
  8386. public void get_erp_placeregistlist()
  8387. {
  8388. DataStruct dStruct = GetPostStruct();
  8389. List<string> lw = new List<string>();
  8390. string outsid = GetPostString("outsid");
  8391. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8392. string memo = GetPostString("memo");
  8393. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8394. string filename = GetPostString("filename");
  8395. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8396. string islate = GetPostString("islate");
  8397. if (islate.Length > 0)
  8398. {
  8399. if (islate == "1")
  8400. lw.Add(string.Format("OutLate>0"));
  8401. else
  8402. lw.Add(string.Format("OutLate=0"));
  8403. }
  8404. string placedate1 = GetPostString("placedate1");
  8405. string placedate2 = GetPostString("placedate2");
  8406. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8407. if (dw.Length > 0) lw.Add(dw);
  8408. string deliveryDate1 = GetPostString("deliverydate1");
  8409. string deliveryDate2 = GetPostString("deliverydate2");
  8410. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8411. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8412. dStruct.Order = "ID desc";
  8413. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8414. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8415. writeGridDataTableJson(dStruct.TotalCount, dt);
  8416. }
  8417. public void ins_erp_placeregist()
  8418. {
  8419. if (UrlPostParmsCheck("id"))
  8420. {
  8421. string eid = GetPostString("id");
  8422. CeErpPlaceRegister entity = null;
  8423. if (eid == "0")//新增
  8424. {
  8425. entity = new CeErpPlaceRegister();
  8426. string xdTime = GetPostString("placeTime");
  8427. if (xdTime.Length > 0)
  8428. {
  8429. entity.PlactTime = Convert.ToDateTime(xdTime);
  8430. }
  8431. string fhTime = GetPostString("deliveryTime");
  8432. if (fhTime.Length > 0)
  8433. {
  8434. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8435. }
  8436. string preTime = GetPostString("preOutTime");
  8437. if (preTime.Length > 0)
  8438. {
  8439. entity.PreOutTime = Convert.ToDateTime(preTime);
  8440. }
  8441. entity.DeliveryCount = GetPostInt("deliveryCount");
  8442. entity.ReceiveCount = GetPostInt("receiveCount");
  8443. entity.OutSid = GetPostString("outSid");
  8444. entity.FileName = GetPostString("fileName");
  8445. entity.Memo = GetPostString("memo");
  8446. entity.AddUserId = CurrentUser.UserID;
  8447. entity.CreateTime = DateTime.Now;
  8448. entity.Img = GetPostString("img");
  8449. entity.Supplier = GetPostInt("supplier");
  8450. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8451. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8452. {
  8453. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8454. DateTime dt2 = (DateTime)entity.PreOutTime;
  8455. TimeSpan span = dt1.Subtract(dt2);
  8456. if (span.Days > 0)
  8457. {
  8458. entity.OutLate = span.Days;
  8459. }
  8460. }
  8461. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8462. entity.Create();
  8463. returnSuccessMsg("添加成功!");
  8464. return;
  8465. }
  8466. else //修改
  8467. {
  8468. entity = CeErpPlaceRegister.Get(eid);
  8469. if (entity != null)
  8470. {
  8471. string xdTime = GetPostString("placeTime");
  8472. if (xdTime.Length > 0)
  8473. {
  8474. entity.PlactTime = Convert.ToDateTime(xdTime);
  8475. }
  8476. string fhTime = GetPostString("deliveryTime");
  8477. if (fhTime.Length > 0)
  8478. {
  8479. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8480. }
  8481. string preTime = GetPostString("preOutTime");
  8482. if (preTime.Length > 0)
  8483. {
  8484. entity.PreOutTime = Convert.ToDateTime(preTime);
  8485. }
  8486. entity.DeliveryCount = GetPostInt("deliveryCount");
  8487. entity.ReceiveCount = GetPostInt("receiveCount");
  8488. if (entity.DeliveryCount == entity.ReceiveCount)
  8489. {
  8490. entity.CurState = "已完成";
  8491. }
  8492. else
  8493. {
  8494. entity.CurState = "未完成";
  8495. }
  8496. entity.OutSid = GetPostString("outSid");
  8497. entity.FileName = GetPostString("fileName");
  8498. entity.Memo = GetPostString("memo");
  8499. entity.Img = GetPostString("img");
  8500. entity.Supplier = GetPostInt("supplier");
  8501. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8502. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8503. {
  8504. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8505. DateTime dt2 = (DateTime)entity.PreOutTime;
  8506. TimeSpan span = dt1.Subtract(dt2);
  8507. if (span.Days > 0)
  8508. {
  8509. entity.OutLate = span.Days;
  8510. }
  8511. }
  8512. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8513. entity.Update();
  8514. returnSuccessMsg("修改成功");
  8515. return;
  8516. }
  8517. returnErrorMsg("找不到对应的记录");
  8518. return;
  8519. }
  8520. }
  8521. returnErrorMsg("缺少必要参数");
  8522. }
  8523. public void del_erp_placeregist()
  8524. {
  8525. string eid = GetPostString("id");
  8526. CeErpPlaceRegister.Del(eid);
  8527. returnSuccessMsg("删除成功!");
  8528. return;
  8529. }
  8530. public void ins_erp_placeregistbyorder()
  8531. {
  8532. string ctid = GetPostString("ctid");
  8533. if (ctid.Length > 0)
  8534. {
  8535. StringBuilder sql = new StringBuilder();
  8536. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8537. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8538. if (dt.Rows.Count > 0)
  8539. {
  8540. foreach (DataRow dr in dt.Rows)
  8541. {
  8542. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8543. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8544. entity.AddUserId = CurrentUser.UserID;
  8545. entity.tid = dr["tid"].ToString();
  8546. entity.Did = Convert.ToString(dr["ctid"]);
  8547. entity.splitTag = dr["SplitTag"].ToString();
  8548. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8549. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8550. if (pre_ctid.Length > 0)
  8551. {
  8552. sellmemo = sellmemo.Replace(pre_ctid, "");
  8553. }
  8554. sellmemo = sellmemo.Replace("[", "");
  8555. sellmemo = sellmemo.Replace("]", "");
  8556. entity.FileName = sellmemo;
  8557. string count = dr["ProductCount"].ToString();
  8558. int usecount = commonHelper.getIntCountFromString(count);
  8559. entity.DeliveryCount = usecount;
  8560. entity.CurState = "未完成";
  8561. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8562. {
  8563. entity.Supplier = 24;//dl手提袋定制
  8564. }
  8565. else
  8566. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8567. entity.CreateTime = DateTime.Now;
  8568. entity.Create();
  8569. }
  8570. returnSuccessMsg("操作成功");
  8571. return;
  8572. }
  8573. returnErrorMsg("没有找到对应订单");
  8574. return;
  8575. }
  8576. returnErrorMsg("缺少订单编号");
  8577. return;
  8578. }
  8579. public void get_erp_persuadelist()
  8580. {
  8581. DataStruct dStruct = GetPostStruct();
  8582. List<string> lw = new List<string>();
  8583. string ctid = GetPostString("ctid");
  8584. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8585. string shopname = GetPostString("shopname");
  8586. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8587. string buyernick = GetPostString("buyer_nick");
  8588. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8589. string customer = GetPostString("customer");
  8590. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8591. string returndate1 = GetPostString("returndate1");
  8592. string returndate2 = GetPostString("returndate2");
  8593. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8594. if (dw.Length > 0) lw.Add(dw);
  8595. string finishDate1 = GetPostString("finishdate1");
  8596. string finishDate2 = GetPostString("finishdate2");
  8597. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8598. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8599. string persuadetype = GetPostString("persuadetype");
  8600. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8601. string returnvstate = GetPostString("returnvstate");
  8602. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8603. dStruct.Order = "created desc";
  8604. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8605. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8606. writeGridDataTableJson(dStruct.TotalCount, dt);
  8607. }
  8608. public void upd_erp_returnpersuadeback()
  8609. {
  8610. if (UrlPostParmsCheck("ID"))
  8611. {
  8612. int eid = GetPostInt("ID");
  8613. CeErpPersuade entity = null;
  8614. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8615. if (entity != null)
  8616. {
  8617. entity.backreason = GetPostString("reason");
  8618. entity.pstate = 2;
  8619. entity.verifytime = DateTime.Now;
  8620. entity.verifyuserid = CurrentUser.UserID;
  8621. entity.Update();
  8622. returnSuccessMsg("退回成功!");
  8623. return;
  8624. }
  8625. returnErrorMsg("找不到订单记录");
  8626. }
  8627. }
  8628. public void upd_erp_returnpersuadeverify()
  8629. {
  8630. if (UrlPostParmsCheck("ID"))
  8631. {
  8632. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8633. {
  8634. returnErrorMsg("暂无权限审核");
  8635. return;
  8636. }
  8637. int eid = GetPostInt("ID");
  8638. CeErpPersuade entity = null;
  8639. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8640. if (entity != null)
  8641. {
  8642. entity.pstate = 1;
  8643. entity.verifytime = DateTime.Now;
  8644. entity.verifyuserid = CurrentUser.UserID;
  8645. entity.Update();
  8646. returnSuccessMsg("审核成功!");
  8647. return;
  8648. }
  8649. returnErrorMsg("找不到订单记录");
  8650. }
  8651. }
  8652. public void del_erp_persuade()
  8653. {
  8654. if (UrlPostParmsCheck("ID"))
  8655. {
  8656. int eid = GetPostInt("ID");
  8657. CeErpPersuade.Del(eid);
  8658. returnSuccessMsg("操作成功");
  8659. return;
  8660. }
  8661. }
  8662. public void get_erp_oldcustoupload()
  8663. {
  8664. DataStruct dStruct = GetPostStruct();
  8665. List<string> lw = new List<string>();
  8666. string buyernick = GetPostString("buyer_nick");
  8667. if (buyernick.Length > 0)
  8668. {
  8669. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8670. }
  8671. else
  8672. return;
  8673. dStruct.Order = "pay_time desc";
  8674. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8675. DataTable dt = null;
  8676. dt = WebCache.GetData("view_erptradecell", dStruct);
  8677. writeGridDataTableJson(dStruct.TotalCount, dt);
  8678. }
  8679. public void get_erp_checkorderlist()
  8680. {
  8681. DataStruct dStruct = GetPostStruct();
  8682. List<string> lw = new List<string>();
  8683. string tid = GetPostString("ctid");
  8684. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8685. string shopname = GetPostString("shopname");
  8686. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8687. string buyernick = GetPostString("buyer_nick");
  8688. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8689. string customer = GetPostString("customer");
  8690. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8691. string design = GetPostString("design");
  8692. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8693. string orderState = GetPostString("orderState");
  8694. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8695. string address = GetPostString("address");
  8696. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8697. string sellermemo = GetPostString("seller_memo");
  8698. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8699. string supplier = GetPostString("supplier");
  8700. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8701. {
  8702. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8703. }
  8704. else
  8705. {
  8706. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8707. }
  8708. string checkst = GetPostString("checkstate");
  8709. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8710. string date1 = GetPostString("date1");
  8711. string date2 = GetPostString("date2");
  8712. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8713. if (dw.Length > 0) lw.Add(dw);
  8714. string placedate1 = GetPostString("placedate1");
  8715. string placedate2 = GetPostString("placedate2");
  8716. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8717. if (fdw.Length > 0) lw.Add(fdw);
  8718. string price1 = GetPostString("price1");
  8719. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8720. string price2 = GetPostString("price2");
  8721. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8722. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8723. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8724. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8725. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8726. writeGridDataTableJson(dStruct.TotalCount, dt);
  8727. }
  8728. public void ins_erp_startCheck()
  8729. {
  8730. if (UrlPostParmsCheck("ctid"))
  8731. {
  8732. string eid = GetPostString("ctid");
  8733. CeErpTradeCell entity = null;
  8734. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8735. if (entity != null)
  8736. {
  8737. entity.MemoOpt = 4;
  8738. entity.Update();
  8739. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8740. CeErpSukuraData.createInfo(entity.ctid, 6);
  8741. returnSuccessMsg("操作成功!");
  8742. return;
  8743. }
  8744. returnErrorMsg("找不到记录");
  8745. }
  8746. }
  8747. public void upd_erp_sendXlw()
  8748. {
  8749. if (UrlPostParmsCheck("ctid"))
  8750. {
  8751. string eid = GetPostString("ctid");
  8752. CeErpTradeCell entity = null;
  8753. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8754. if (entity != null)
  8755. {
  8756. if (entity.IsSendGift == 1)
  8757. {
  8758. returnErrorMsg("请勿重复标记");
  8759. return;
  8760. }
  8761. entity.IsSendGift = 1;
  8762. entity.Update();
  8763. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8764. returnSuccessMsg("操作成功!");
  8765. return;
  8766. }
  8767. returnErrorMsg("找不到记录");
  8768. }
  8769. }
  8770. public void cancel_sendXlw()
  8771. {
  8772. if (UrlPostParmsCheck("ctid"))
  8773. {
  8774. string eid = GetPostString("ctid");
  8775. CeErpTradeCell entity = null;
  8776. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8777. if (entity != null)
  8778. {
  8779. if (entity.IsSendGift == 0)
  8780. {
  8781. returnErrorMsg("未标记小礼物");
  8782. return;
  8783. }
  8784. entity.IsSendGift = 0;
  8785. entity.Update();
  8786. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  8787. returnSuccessMsg("操作成功!");
  8788. return;
  8789. }
  8790. returnErrorMsg("找不到记录");
  8791. }
  8792. }
  8793. public void get_erp_designbill()
  8794. {
  8795. DataStruct dStruct = GetPostStruct();
  8796. List<string> lw = new List<string>();
  8797. int isMy = GetInt("my");
  8798. if (isMy == 1)
  8799. {
  8800. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  8801. }
  8802. string tid = GetPostString("tid");
  8803. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8804. string userName = GetPostString("design");
  8805. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  8806. string price1 = GetPostString("price1");
  8807. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  8808. string price2 = GetPostString("price2");
  8809. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  8810. string rePrice1 = GetPostString("rePrice1");
  8811. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  8812. string rePrice2 = GetPostString("rePrice2");
  8813. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  8814. string designerType = GetPostString("designerType");
  8815. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  8816. string orderState = GetPostString("orderState");
  8817. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  8818. string endTime1 = GetPostString("endTime1");
  8819. string endTime2 = GetPostString("endTime2");
  8820. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  8821. if (dw.Length > 0) lw.Add(dw);
  8822. string isDk = GetPostString("isDk");
  8823. if (isDk == "1")
  8824. {
  8825. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  8826. }
  8827. else if (isDk == "0")
  8828. {
  8829. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  8830. }
  8831. dStruct.Order = "oid, create_time desc";
  8832. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8833. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  8834. writeGridDataTableJson(dStruct.TotalCount, dt);
  8835. }
  8836. public void upd_erp_designerbill()
  8837. {
  8838. if (UrlPostParmsCheck("ID"))
  8839. {
  8840. string eid = GetPostString("ID");
  8841. CeErpDesignerBill entity = null;
  8842. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8843. if (entity != null)
  8844. {
  8845. if (GetPostDouble("designerpirce") > 0)
  8846. {
  8847. entity.realPrice = GetPostDouble("designerpirce");
  8848. entity.update_time = DateTime.Now;
  8849. entity.update_u_id = CurrentUser.UserID;
  8850. entity.update_u_name = CurrentUser.UserName;
  8851. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  8852. entity.Update();
  8853. returnSuccessMsg("操作成功!");
  8854. return;
  8855. }
  8856. else
  8857. {
  8858. entity.price = GetPostDouble("price");
  8859. entity.update_time = DateTime.Now;
  8860. entity.update_u_id = CurrentUser.UserID;
  8861. entity.update_u_name = CurrentUser.UserName;
  8862. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  8863. entity.Update();
  8864. returnSuccessMsg("操作成功!");
  8865. return;
  8866. }
  8867. }
  8868. returnErrorMsg("找不到记录");
  8869. }
  8870. }
  8871. public void audit_erp_designerbill()
  8872. {
  8873. if (UrlPostParmsCheck("ID"))
  8874. {
  8875. string eid = GetPostString("ID");
  8876. CeErpDesignerBill entity = null;
  8877. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8878. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  8879. if (entity != null)
  8880. {
  8881. entity.realPrice = GetPostDouble("designerpirce");
  8882. entity.update_time = DateTime.Now;
  8883. entity.update_u_id = CurrentUser.UserID;
  8884. entity.update_u_name = CurrentUser.UserName;
  8885. entity.isAudit = 1;
  8886. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8887. entity.Update();
  8888. if (orderEntity != null)
  8889. {
  8890. orderEntity.IsReadTag = 3;
  8891. orderEntity.Update();
  8892. }
  8893. returnSuccessMsg("操作成功!");
  8894. return;
  8895. }
  8896. returnErrorMsg("找不到记录");
  8897. }
  8898. }
  8899. public void all_audit_erp_designerbill()
  8900. {
  8901. if (UrlPostParmsCheck("idList"))
  8902. {
  8903. string[] list = GetPostString("idList").Split(',');
  8904. CeErpDesignerBill entity = null;
  8905. for (int i = 0; i < list.Length; i++)
  8906. {
  8907. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  8908. if (entity == null) return;
  8909. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  8910. if (orderEntity == null) return;
  8911. if (entity.realPrice == 0) entity.realPrice = entity.price;
  8912. entity.update_time = DateTime.Now;
  8913. entity.update_u_id = CurrentUser.UserID;
  8914. entity.update_u_name = CurrentUser.UserName;
  8915. entity.isAudit = 1;
  8916. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8917. entity.Update();
  8918. orderEntity.IsReadTag = 3;
  8919. orderEntity.Update();
  8920. }
  8921. returnSuccessMsg("操作成功!");
  8922. return;
  8923. }
  8924. }
  8925. public void get_erp_sameorders()
  8926. {
  8927. if (UrlPostParmsCheck("ctid"))
  8928. {
  8929. string eid = GetPostString("ctid");
  8930. CeErpTradeCell entity = null;
  8931. entity = CeErpTradeCell.GetByCtid(eid);
  8932. if (entity != null)
  8933. {
  8934. StringBuilder sql = new StringBuilder();
  8935. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  8936. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8937. var res = new
  8938. {
  8939. data = dt.Rows.Count
  8940. };
  8941. string ro_jsond = JsonConvert.SerializeObject(res);
  8942. returnSuccess(ro_jsond);
  8943. return;
  8944. }
  8945. returnErrorMsg("未找到订单");
  8946. return;
  8947. }
  8948. returnErrorMsg("缺少必要的参数");
  8949. }
  8950. public void get_erp_islasthavesameorder()
  8951. {
  8952. if (UrlPostParmsCheck("ctid"))
  8953. {
  8954. string eid = GetPostString("ctid");
  8955. string[] ctidList = eid.Split(',');
  8956. StringBuilder sql = new StringBuilder();
  8957. string tisCtid = "";
  8958. foreach (string ctid in ctidList)
  8959. {
  8960. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  8961. if (entity != null)
  8962. {
  8963. sql = new StringBuilder();
  8964. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  8965. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8966. if (dth.Rows.Count > 0)
  8967. {
  8968. tisCtid += entity.ctid;
  8969. tisCtid += ",";
  8970. }
  8971. }
  8972. }
  8973. if (tisCtid.Length > 0)
  8974. {
  8975. var res = new
  8976. {
  8977. data = tisCtid
  8978. };
  8979. string ro_jsond = JsonConvert.SerializeObject(res);
  8980. returnSuccess(ro_jsond);
  8981. }
  8982. else
  8983. {
  8984. var res = new
  8985. {
  8986. data = ""
  8987. };
  8988. string ro_jsond = JsonConvert.SerializeObject(res);
  8989. returnSuccess(ro_jsond);
  8990. }
  8991. return;
  8992. }
  8993. returnErrorMsg("缺少必要的参数");
  8994. }
  8995. public void file_client_down_url()
  8996. {
  8997. if (!UrlPostParmsCheck("userId"))
  8998. {
  8999. returnErrorMsg("缺少必要的参数");
  9000. }
  9001. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9002. }
  9003. public void checkout_form_data()
  9004. {
  9005. if (!UrlPostParmsCheck("tid"))
  9006. {
  9007. returnErrorMsg("缺少必要的参数");
  9008. }
  9009. string tid = GetPostString("tid");
  9010. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9011. if (ceErpOrderFormData != null)
  9012. {
  9013. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9014. returnSuccess(ro_jsond);
  9015. return;
  9016. }
  9017. returnErrorMsg("尚未有文件!");
  9018. }
  9019. public void back_supplier_audit()
  9020. {
  9021. int userId = CurrentUser.UserID;
  9022. StringBuilder sql = new StringBuilder();
  9023. 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);
  9024. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9025. if (dt.Rows.Count > 0)
  9026. {
  9027. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9028. }
  9029. else
  9030. {
  9031. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9032. }
  9033. }
  9034. public void back_supplier_query()
  9035. {
  9036. string eid = GetPostString("ctid");
  9037. if (eid != "")
  9038. {
  9039. StringBuilder sql = new StringBuilder();
  9040. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9041. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9042. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9043. }
  9044. else
  9045. {
  9046. returnErrorMsg("找不到订单记录");
  9047. return;
  9048. }
  9049. }
  9050. public void verified_to_order()
  9051. {
  9052. int userId = CurrentUser.UserID;
  9053. StringBuilder sql = new StringBuilder();
  9054. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9055. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9056. if (dt.Rows.Count > 0)
  9057. {
  9058. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9059. }
  9060. else
  9061. {
  9062. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9063. }
  9064. }
  9065. public void upd_supplier_audit()
  9066. {
  9067. if (UrlPostParmsCheck("ctid"))
  9068. {
  9069. string eid = GetPostString("ctid");
  9070. string reason = GetPostString("returnreason");
  9071. CeErpTradeCell entity = null;
  9072. CeWithdraw withdraw = null;
  9073. withdraw = CeWithdraw.GetByTid(eid);
  9074. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9075. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9076. {
  9077. if (withdraw != null)
  9078. {
  9079. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9080. {
  9081. returnSuccessMsg("您没有权限操作!");
  9082. return;
  9083. }
  9084. else
  9085. {
  9086. if (reason.Equals("1"))
  9087. {
  9088. if (entity.OrderState == -1)
  9089. {
  9090. if (entity.FinishPlaceTime == null)
  9091. {
  9092. entity.OrderState = 2;
  9093. }
  9094. else
  9095. {
  9096. entity.OrderState = 6;
  9097. }
  9098. }
  9099. entity.Update();
  9100. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9101. if (withdraw != null)
  9102. {
  9103. withdraw.status = int.Parse(reason);
  9104. withdraw.Update();
  9105. }
  9106. returnSuccessMsg("操作成功!");
  9107. return;
  9108. }
  9109. else
  9110. {
  9111. withdraw.status = int.Parse(reason);
  9112. withdraw.acknowledgingtime = DateTime.Now;
  9113. withdraw.Update();
  9114. returnSuccessMsg("查看详细请点击线下订单查询");
  9115. return;
  9116. }
  9117. }
  9118. }
  9119. // 第一个字符是 'N'
  9120. }
  9121. if (eid[0] != 'N')
  9122. {
  9123. }
  9124. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9125. {
  9126. entity.IsVerifyToSupplier = false;
  9127. entity.IsReturn = 1;
  9128. entity.ReturnTime = DateTime.Now;
  9129. entity.ReturnReason = reason;
  9130. if (entity.OrderState == 6)
  9131. {
  9132. entity.OrderState = 5;
  9133. }
  9134. entity.Update();
  9135. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9136. if (withdraw != null)
  9137. {
  9138. withdraw.status = int.Parse(reason);
  9139. withdraw.Update();
  9140. }
  9141. returnSuccessMsg("操作成功!");
  9142. return;
  9143. }
  9144. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9145. {
  9146. ;
  9147. if (withdraw != null)
  9148. {
  9149. withdraw.status = int.Parse(reason);
  9150. withdraw.acknowledgingtime = DateTime.Now;
  9151. withdraw.Update();
  9152. returnSuccessMsg("供应商取消撤回!");
  9153. return;
  9154. }
  9155. }
  9156. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9157. {
  9158. if (entity.OrderState == -1)
  9159. {
  9160. if (entity.FinishPlaceTime == null)
  9161. {
  9162. entity.OrderState = 2;
  9163. }
  9164. else
  9165. {
  9166. entity.OrderState = 3;
  9167. }
  9168. commonHelper.getCytPrice(entity);
  9169. }
  9170. entity.Update();
  9171. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9172. if (withdraw != null)
  9173. {
  9174. withdraw.status = int.Parse(reason);
  9175. withdraw.Update();
  9176. }
  9177. returnSuccessMsg("操作成功!");
  9178. return;
  9179. }
  9180. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9181. {
  9182. if (withdraw == null)
  9183. {
  9184. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9185. return;
  9186. }
  9187. }
  9188. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9189. {
  9190. if (withdraw != null)
  9191. {
  9192. withdraw.status = int.Parse(reason);
  9193. withdraw.acknowledgingtime = DateTime.Now;
  9194. withdraw.Update();
  9195. returnSuccessMsg("查看详细请点击线下订单查询");
  9196. return;
  9197. }
  9198. }
  9199. return;
  9200. }
  9201. }
  9202. //校验报价
  9203. public void refund_order_tip()
  9204. {
  9205. int userid = CurrentUser.UserID;
  9206. int sectionId = CurrentUser.UserPost.OrgID;
  9207. StringBuilder sql = new StringBuilder();
  9208. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9209. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9210. List<string> ids = new List<string>();
  9211. if (dth.Rows.Count > 0)
  9212. {
  9213. foreach (DataRow dr in dth.Rows)
  9214. {
  9215. ids.Add(dr["ID"].ToString());
  9216. }
  9217. try
  9218. {
  9219. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9220. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9221. }
  9222. catch (Exception ex)
  9223. {
  9224. }
  9225. }
  9226. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9227. }
  9228. public void refund_order_Design()
  9229. {
  9230. int userid = CurrentUser.UserID;
  9231. int sectionId = CurrentUser.UserPost.OrgID;
  9232. StringBuilder sql = new StringBuilder();
  9233. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9234. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9235. List<string> ids = new List<string>();
  9236. if (dth.Rows.Count > 0)
  9237. {
  9238. foreach (DataRow dr in dth.Rows)
  9239. {
  9240. ids.Add(dr["ID"].ToString());
  9241. }
  9242. try
  9243. {
  9244. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9245. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9246. }
  9247. catch (Exception ex)
  9248. {
  9249. }
  9250. }
  9251. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9252. }
  9253. public void change_order_info()
  9254. {
  9255. int userid = CurrentUser.UserID;
  9256. StringBuilder sql = new StringBuilder();
  9257. 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);
  9258. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9259. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9260. }
  9261. public void change_win_mome()
  9262. {
  9263. if (UrlPostParmsCheck("id,ctid"))
  9264. {
  9265. string id = GetPostString("id");
  9266. string ctid = GetPostString("ctid");
  9267. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9268. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9269. if (ce == null || ceErpMessageTip == null)
  9270. {
  9271. returnSuccessMsg("未找到对应的订单!");
  9272. return;
  9273. }
  9274. int type = GetPostInt("type");
  9275. string content = GetPostString("content");
  9276. if (type == 0)
  9277. {
  9278. content = content.Replace("(", "(");
  9279. content = content.Replace(")", ")");
  9280. string check = MidStrEx(content, "(", ")").Trim();
  9281. if (string.IsNullOrEmpty(check))
  9282. {
  9283. returnSuccessMsg("文件名格式不正确");
  9284. return;
  9285. }
  9286. }
  9287. ce.seller_memo = content;
  9288. ce.Update();
  9289. ceErpMessageTip.isVisit = true;
  9290. ceErpMessageTip.Update();
  9291. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9292. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9293. ApiVo apiVo = new ApiVo();
  9294. apiVo.orderNumber = ce.ctid;
  9295. apiVo.actionName = "demandDesign";
  9296. apiVo.orderRemarks = content;
  9297. apiVo.demandExamine = type + 1;
  9298. designHelper.API_WorkCore(apiVo);//demandDesign
  9299. returnSuccessMsg("修改成功!");
  9300. }
  9301. }
  9302. public static string MidStrEx(string sourse, string startstr, string endstr)
  9303. {
  9304. string result = string.Empty;
  9305. int startindex, endindex;
  9306. try
  9307. {
  9308. startindex = sourse.IndexOf(startstr);
  9309. if (startindex == -1)
  9310. return result;
  9311. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9312. endindex = tmpstr.IndexOf(endstr);
  9313. if (endindex == -1)
  9314. return result;
  9315. result = tmpstr.Remove(endindex);
  9316. }
  9317. catch (Exception ex)
  9318. {
  9319. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9320. }
  9321. return result;
  9322. }
  9323. public void refund_order_list()
  9324. {
  9325. int userid = CurrentUser.UserID;
  9326. int sectionId = CurrentUser.UserPost.OrgID;
  9327. StringBuilder sql = new StringBuilder();
  9328. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9329. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9330. DataStruct dStruct = GetPostStruct();
  9331. DataTable dt = null;
  9332. List<string> ids = new List<string>();
  9333. List<string> tids = new List<string>();
  9334. if (dth.Rows.Count > 0)
  9335. {
  9336. foreach (DataRow dr in dth.Rows)
  9337. {
  9338. tids.Add("'" + dr["tid"].ToString() + "'");
  9339. ids.Add(dr["id"].ToString());
  9340. }
  9341. try
  9342. {
  9343. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9344. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9345. List<string> lw = new List<string>();
  9346. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9347. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9348. dt = WebCache.GetData("view_orderlist", dStruct);
  9349. }
  9350. catch (Exception ex)
  9351. {
  9352. }
  9353. }
  9354. writeGridDataTableJson(dStruct.TotalCount, dt);
  9355. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9356. }
  9357. //新增
  9358. public void order_batch_downloads()
  9359. {
  9360. string ceid = GetPostString("tid");
  9361. String[] tid = ceid.Split(',');
  9362. order_batch_caiyingtong(tid);
  9363. /* (string success, string errors) = UploadFiles(tid);
  9364. returnSuccessMsg(success + errors);*/
  9365. return;
  9366. }
  9367. //报价接口
  9368. public void Get_To_Quote()
  9369. {
  9370. string ceid = GetPostString("ctid");
  9371. if (ceid != null)
  9372. {
  9373. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9374. if (entity != null)
  9375. {
  9376. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9377. {
  9378. return;
  9379. }
  9380. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9381. double price = 0;
  9382. if (cp == null)
  9383. {
  9384. JObject jsonObject12 = new JObject
  9385. {
  9386. { "UserId", "77886" },
  9387. { "Pwd", "lt666888" },
  9388. { "Filename", entity.seller_memo }
  9389. };
  9390. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9391. JObject jsonObjects1 = JObject.Parse(response1);
  9392. string ms1g = (string)jsonObjects1["msg"];
  9393. if (ms1g == "报价成功")
  9394. {
  9395. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9396. string data = (string)jsonObject1["price"];
  9397. 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 + "');";
  9398. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9399. returnSuccessMsg("获取报价成功:" + data);
  9400. price = Convert.ToDouble(data);
  9401. }
  9402. else
  9403. {
  9404. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9405. return;
  9406. }
  9407. }
  9408. String[] beizhu = entity.seller_memo.Split('-');
  9409. String chanp = "";
  9410. if (beizhu.Length > 0)
  9411. {
  9412. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9413. }
  9414. else
  9415. {
  9416. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9417. }
  9418. JObject jsonObject = new JObject
  9419. {
  9420. { "UserId", "77886" },
  9421. { "Pwd", "lt666888" },
  9422. { "Filename", chanp }
  9423. };
  9424. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9425. JObject jsonObjects = JObject.Parse(response);
  9426. string msg = (string)jsonObjects["msg"];
  9427. if (msg == "报价成功")
  9428. {
  9429. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9430. string data = (string)jsonObject1["price"];
  9431. 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 + "');";
  9432. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9433. returnSuccessMsg("获取报价成功:" + data);
  9434. price = Convert.ToDouble(data);
  9435. }
  9436. else
  9437. {
  9438. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9439. return;
  9440. }
  9441. if (price > 0)
  9442. {
  9443. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9444. if (ceErpTradeCellExtend == null)
  9445. {
  9446. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9447. ceErpTradeCellExtend.ctid = entity.ctid;
  9448. ceErpTradeCellExtend.payment_cyt = price;
  9449. ceErpTradeCellExtend.Create();
  9450. }
  9451. else
  9452. {
  9453. ceErpTradeCellExtend.payment_cyt = price;
  9454. ceErpTradeCellExtend.Update();
  9455. }
  9456. }
  9457. return;
  9458. }
  9459. }
  9460. else
  9461. {
  9462. returnErrorMsg("请至少选择一条数据");
  9463. return;
  9464. }
  9465. }
  9466. //新增
  9467. public void order_To_Supplier()
  9468. {
  9469. string ceid = GetPostString("tid");
  9470. String[] tid = ceid.Split(',');
  9471. if (tid.Length > 0)
  9472. {
  9473. try
  9474. {
  9475. for (int i = 0; i < tid.Length; i++)
  9476. {
  9477. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9478. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9479. entity.SupplierId = suid;
  9480. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9481. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9482. entity.Update();
  9483. }
  9484. }
  9485. catch (Exception ex)
  9486. {
  9487. returnErrorMsg("自动匹配供应商失败");
  9488. return;
  9489. }
  9490. }
  9491. else
  9492. {
  9493. returnErrorMsg("请至少选择一条数据");
  9494. return;
  9495. }
  9496. returnSuccessMsg("自动匹配供应商成功");
  9497. return;
  9498. }
  9499. public (string, string) UploadFiles(string[] urls)
  9500. {
  9501. string success = "";
  9502. string errors = "";
  9503. int userid = CurrentUser.UserID;
  9504. foreach (string url in urls)
  9505. {
  9506. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9507. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9508. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9509. {
  9510. JObject jsonObject = new JObject
  9511. {
  9512. { "Userid", "77886" },
  9513. { "pwd", "cyt86435015" },
  9514. { "content", base64FileContent },
  9515. { "ext", Path.GetExtension(fileName) }
  9516. };
  9517. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9518. JObject jsonObjects = JObject.Parse(response);
  9519. string msg = (string)jsonObjects["msg"];
  9520. if (msg.Equals("上传成功"))
  9521. {
  9522. success += url + " 上传成功";
  9523. }
  9524. else
  9525. {
  9526. errors += url + " 上传失败";
  9527. }
  9528. }
  9529. else
  9530. {
  9531. errors += url + " 格式出现问题";
  9532. }
  9533. }
  9534. if (urls.Length == 0)
  9535. {
  9536. return (success, errors);
  9537. }
  9538. return (success, errors);
  9539. }
  9540. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9541. {
  9542. return true; //总是接受
  9543. }
  9544. public static string HttpPost(string url, string param = null)
  9545. {
  9546. HttpWebRequest request;
  9547. //如果是发送HTTPS请求
  9548. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9549. {
  9550. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9551. request = WebRequest.Create(url) as HttpWebRequest;
  9552. request.ProtocolVersion = HttpVersion.Version10;
  9553. }
  9554. else
  9555. {
  9556. request = WebRequest.Create(url) as HttpWebRequest;
  9557. }
  9558. request.Method = "POST";
  9559. request.ContentType = "application/json";
  9560. request.Accept = "*/*";
  9561. request.Timeout = 120000;
  9562. request.AllowAutoRedirect = false;
  9563. StreamWriter requestStream = null;
  9564. WebResponse response = null;
  9565. string responseStr = null;
  9566. try
  9567. {
  9568. requestStream = new StreamWriter(request.GetRequestStream());
  9569. requestStream.Write(param);
  9570. requestStream.Close();
  9571. response = request.GetResponse();
  9572. if (response != null)
  9573. {
  9574. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9575. responseStr = reader.ReadToEnd();
  9576. reader.Close();
  9577. }
  9578. }
  9579. catch (Exception ex)
  9580. {
  9581. return ex.Message;
  9582. }
  9583. finally
  9584. {
  9585. request = null;
  9586. requestStream = null;
  9587. response = null;
  9588. }
  9589. return responseStr;
  9590. }
  9591. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9592. {
  9593. string base64FileContent;
  9594. string fileName;
  9595. using (WebClient webClient = new WebClient())
  9596. {
  9597. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9598. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9599. {
  9600. using (Stream stream = response.GetResponseStream())
  9601. {
  9602. using (MemoryStream memoryStream = new MemoryStream())
  9603. {
  9604. stream.CopyTo(memoryStream);
  9605. byte[] fileBytes = memoryStream.ToArray();
  9606. base64FileContent = Convert.ToBase64String(fileBytes);
  9607. fileName = response.Headers["Content-Disposition"];
  9608. if (!string.IsNullOrEmpty(fileName))
  9609. {
  9610. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9611. if (index >= 0)
  9612. {
  9613. fileName = fileName.Substring(index + 9).Trim('\"');
  9614. }
  9615. }
  9616. else
  9617. {
  9618. fileName = Path.GetFileName(downloadUrl);
  9619. }
  9620. }
  9621. }
  9622. }
  9623. }
  9624. return (fileName, base64FileContent);
  9625. }
  9626. //新增
  9627. public void order_batch_caiyingtong(string[] downloadUrls)
  9628. {
  9629. try
  9630. {
  9631. //遍历文件
  9632. DataStruct dStruct = GetPostStruct();
  9633. DataTable dt = null;
  9634. int userid = CurrentUser.UserID;
  9635. List<string> ids = new List<string>();//失败组
  9636. List<string> tids = new List<string>();
  9637. using (WebClient webClient = new WebClient())
  9638. {
  9639. foreach (var url in downloadUrls)
  9640. {
  9641. try
  9642. {
  9643. tids.Add("'" + url + "'");
  9644. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9645. if (entity != null)
  9646. {
  9647. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9648. if (cp == null)
  9649. {
  9650. JObject jsonObject = new JObject
  9651. {
  9652. { "Userid", "77886" },
  9653. { "pwd", "lt666888" },
  9654. { "Filename",entity.seller_memo }
  9655. };
  9656. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9657. JObject jsonObjects = JObject.Parse(response);
  9658. string msg = (string)jsonObjects["msg"];
  9659. if (msg == "报价成功")
  9660. {
  9661. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9662. DownloadAndConvertToBase64(url1);
  9663. }
  9664. else
  9665. {
  9666. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9667. }
  9668. }
  9669. else
  9670. {
  9671. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9672. JObject jsonObject = new JObject
  9673. {
  9674. { "Userid", "77886" },
  9675. { "pwd", "lt666888" },
  9676. { "Filename",chanp }
  9677. };
  9678. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9679. JObject jsonObjects = JObject.Parse(response);
  9680. string msg = (string)jsonObjects["msg"];
  9681. if (msg == "报价成功")
  9682. {
  9683. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9684. DownloadAndConvertToBase64(url1);
  9685. }
  9686. else
  9687. {
  9688. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9689. }
  9690. }
  9691. }
  9692. // 上传文件到FTP
  9693. }
  9694. catch (Exception ex)
  9695. {
  9696. Console.WriteLine($"An error occurred: {ex.Message}");
  9697. }
  9698. }
  9699. List<string> lw = new List<string>();
  9700. lw.Add(string.Format("( OrderState < 6 )"));
  9701. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9702. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9703. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9704. if (dt.Rows.Count > 0)
  9705. {
  9706. foreach (DataRow dr in dt.Rows)
  9707. {
  9708. ids.Add(dr["ctid"].ToString());
  9709. }
  9710. }
  9711. String ErrorMsgs = "";
  9712. foreach (String id in ids)
  9713. {
  9714. ErrorMsgs += id + ",";
  9715. }
  9716. if (ErrorMsgs.Length > 1)
  9717. {
  9718. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9719. }
  9720. if (ErrorMsgs.Length < 1)
  9721. {
  9722. ErrorMsgs = "上传成功";
  9723. returnSuccessMsg(ErrorMsgs);
  9724. }
  9725. else
  9726. {
  9727. returnErrorMsg("以下订单" + ErrorMsgs);
  9728. }
  9729. }
  9730. // 删除文件夹及其内容
  9731. /* Directory.Delete(localDirectory, true);*/
  9732. }
  9733. catch { }
  9734. }
  9735. public void get_center_data()
  9736. {
  9737. int userId = CurrentUser.UserID;
  9738. string postCode = CurrentUser.UserPost.Post.Code;
  9739. List<string> lw = new List<string>();
  9740. List<string> ww = new List<string>();
  9741. DateTime currentTime = DateTime.Now;
  9742. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9743. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9744. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9745. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9746. string sql = " SELECT ";
  9747. string startTime = "2023-10-01 11:22:31";
  9748. //设计
  9749. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9750. {
  9751. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9752. 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));
  9753. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9754. 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));
  9755. }
  9756. //客服
  9757. else if (postCode == "CustomerService" || postCode == "Director")
  9758. {
  9759. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9760. 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));
  9761. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9762. 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));
  9763. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9764. 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));
  9765. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9766. 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));
  9767. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9768. 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));
  9769. }
  9770. //售后
  9771. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9772. {
  9773. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9774. 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));
  9775. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9776. 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));
  9777. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9778. 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));
  9779. }
  9780. //下单部
  9781. else if (postCode == "Place" || postCode == "PlaceMr")
  9782. {
  9783. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9784. 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));
  9785. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9786. 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));
  9787. }
  9788. //车间
  9789. else if (postCode == "Supplier")
  9790. {
  9791. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9792. 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));
  9793. }
  9794. DataTable dt = new DataTable();
  9795. if (lw.Count > 0)
  9796. {
  9797. sql += string.Join(" , ", lw);
  9798. sql += " FROM ";
  9799. sql += string.Join(" , ", ww);
  9800. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9801. }
  9802. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9803. }
  9804. public void get_center_data_list()
  9805. {
  9806. int userId = CurrentUser.UserID;
  9807. string postCode = CurrentUser.UserPost.Post.Code;
  9808. string shopIds = CurrentUser.User.pemShop;
  9809. DataStruct dStruct = GetPostStruct();
  9810. List<string> lw = new List<string>();
  9811. DateTime currentTime = DateTime.Now;
  9812. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9813. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9814. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9815. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9816. string startTime = "2023-10-01 11:22:31";
  9817. int order_type = GetPostInt("order_type");
  9818. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9819. {
  9820. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  9821. if (order_type == 0)
  9822. {
  9823. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9824. }
  9825. else if (order_type == 3)
  9826. {
  9827. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  9828. }
  9829. else
  9830. {
  9831. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9832. }
  9833. }
  9834. //客服
  9835. if (postCode == "CustomerService" || postCode == "Director")
  9836. {
  9837. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  9838. if (order_type == 0)
  9839. {
  9840. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9841. }
  9842. else if (order_type == 1)
  9843. {
  9844. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9845. }
  9846. else if (order_type == 2)
  9847. {
  9848. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9849. }
  9850. else if (order_type == 3)
  9851. {
  9852. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  9853. }
  9854. else if (order_type == 4)
  9855. {
  9856. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9857. }
  9858. else
  9859. {
  9860. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9861. }
  9862. }
  9863. //售后
  9864. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9865. {
  9866. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9867. if (shopIds != "")
  9868. {
  9869. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9870. }
  9871. if (order_type == 2)
  9872. {
  9873. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9874. }
  9875. else if (order_type == 4)
  9876. {
  9877. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9878. }
  9879. else if (order_type == 5)
  9880. {
  9881. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  9882. }
  9883. else
  9884. {
  9885. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9886. }
  9887. }
  9888. //下单部
  9889. if (postCode == "Place" || postCode == "PlaceMr")
  9890. {
  9891. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9892. if (shopIds != "")
  9893. {
  9894. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9895. }
  9896. else if (order_type == 1)
  9897. {
  9898. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9899. }
  9900. else if (order_type == 2)
  9901. {
  9902. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9903. }
  9904. else
  9905. {
  9906. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9907. }
  9908. }
  9909. //车间
  9910. if (postCode == "Supplier")
  9911. {
  9912. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9913. if (order_type == 5)
  9914. {
  9915. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  9916. }
  9917. else
  9918. {
  9919. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9920. }
  9921. }
  9922. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9923. dStruct.Fileds = "tid,ctid";
  9924. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  9925. writeGridDataTableJson(dStruct.TotalCount, dt);
  9926. }
  9927. public void aftersale_audit_master()
  9928. {
  9929. if (UrlPostParmsCheck("ctid"))
  9930. {
  9931. string ctid = GetPostString("ctid");
  9932. if (ctid.Length > 0)
  9933. {
  9934. bool result = aftersale_data_change(ctid);
  9935. if (result)
  9936. {
  9937. returnSuccessMsg("修改成功!");
  9938. return;
  9939. }
  9940. }
  9941. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9942. }
  9943. }
  9944. public void aftersale_batch_audit_master()
  9945. {
  9946. if (UrlPostParmsCheck("ctids"))
  9947. {
  9948. string ctids = GetPostString("ctids");
  9949. if (ctids.Length > 0)
  9950. {
  9951. List<string> list = new List<string>();
  9952. string[] ctid_list = ctids.Split(',');
  9953. foreach (var item in ctid_list)
  9954. {
  9955. bool result = aftersale_data_change(item);
  9956. if (!result)
  9957. {
  9958. list.Add(item);
  9959. }
  9960. }
  9961. if (list.Count > 0)
  9962. {
  9963. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  9964. return;
  9965. }
  9966. returnSuccessMsg("修改成功!");
  9967. return;
  9968. }
  9969. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9970. }
  9971. }
  9972. public bool aftersale_data_change(string ctid)
  9973. {
  9974. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  9975. if (ceErpTradeCell != null)
  9976. {
  9977. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  9978. ceErpTradeCell.AfterSaleSupplierState = 0;
  9979. StringBuilder sql = new StringBuilder();
  9980. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  9981. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9982. CeErpTradeResponsible.DelByTid(ctid, 0);
  9983. 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 == "不理赔")
  9984. {
  9985. CeErpTradeResponsible.DelByTid(ctid, 1);
  9986. ceErpTradeCell.AfterSaleSupplierState = 1;
  9987. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9988. ceErpTradeCell.AfterSaleState = 4;
  9989. }
  9990. else
  9991. {
  9992. ceErpTradeCell.AfterSaleState = 3;
  9993. }
  9994. bool needCyt = false;
  9995. if (dt != null)
  9996. {
  9997. if (dt.Rows.Count == 1)
  9998. {
  9999. bool isEnd = false;
  10000. foreach (DataRow dr in dt.Rows)
  10001. {
  10002. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10003. {
  10004. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10005. isEnd = true;
  10006. }
  10007. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10008. {
  10009. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10010. isEnd = true;
  10011. }
  10012. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10013. {
  10014. needCyt = true;
  10015. }
  10016. }
  10017. if (isEnd)
  10018. {
  10019. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10020. ceErpTradeCell.AfterSaleState = 4;
  10021. ceErpTradeCell.AfterSaleSupplierState = 1;
  10022. }
  10023. }
  10024. else
  10025. {
  10026. bool isAll = true;
  10027. foreach (DataRow dr in dt.Rows)
  10028. {
  10029. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10030. {
  10031. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10032. continue;
  10033. }
  10034. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10035. {
  10036. string path = "";
  10037. int OrgID = 0;
  10038. if (!Convert.IsDBNull(dr["OrgPath"]))
  10039. {
  10040. path = dr["OrgPath"].ToString();
  10041. }
  10042. if (!Convert.IsDBNull(dr["OrgID"]))
  10043. {
  10044. OrgID = Convert.ToInt32(dr["OrgID"]);
  10045. }
  10046. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10047. {
  10048. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10049. continue;
  10050. }
  10051. }
  10052. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10053. {
  10054. needCyt = true;
  10055. }
  10056. isAll = false;
  10057. }
  10058. if (isAll)
  10059. {
  10060. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10061. ceErpTradeCell.AfterSaleState = 4;
  10062. ceErpTradeCell.AfterSaleSupplierState = 1;
  10063. }
  10064. }
  10065. }
  10066. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10067. {
  10068. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10069. }
  10070. if (ceErpTradeCell.AfterSaleState == 4)
  10071. {
  10072. ApiVo apiVo = new ApiVo();
  10073. apiVo.orderNumber = ceErpTradeCell.ctid;
  10074. apiVo.actionName = "afterOver";
  10075. designHelper.API_WorkCore(apiVo); //afterOver
  10076. }
  10077. ceErpTradeCell.Update();
  10078. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10079. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10080. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10081. return true;
  10082. }
  10083. return false;
  10084. }
  10085. public void get_erp_wechatorder()
  10086. {
  10087. DataStruct dStruct = GetPostStruct();
  10088. List<string> lw = new List<string>();
  10089. string tid = GetPostString("tid");
  10090. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10091. string shopname = GetPostString("shopname");
  10092. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10093. string buyernick = GetPostString("buyer_nick");
  10094. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10095. string customer = GetPostString("customer");
  10096. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10097. string returndate1 = GetPostString("returndate1");
  10098. string returndate2 = GetPostString("returndate2");
  10099. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10100. if (dw.Length > 0) lw.Add(dw);
  10101. string finishDate1 = GetPostString("finishdate1");
  10102. string finishDate2 = GetPostString("finishdate2");
  10103. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10104. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10105. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10106. dStruct.Order = "created desc";
  10107. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10108. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10109. writeGridDataTableJson(dStruct.TotalCount, dt);
  10110. }
  10111. public void get_erp_wechatlist_sumprice()
  10112. {
  10113. DataStruct dStruct = GetPostStruct();
  10114. List<string> lw = new List<string>();
  10115. string tid = GetPostString("tid");
  10116. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10117. string shopname = GetPostString("shopname");
  10118. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10119. string buyernick = GetPostString("buyer_nick");
  10120. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10121. string customer = GetPostString("customer");
  10122. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10123. string returndate1 = GetPostString("returndate1");
  10124. string returndate2 = GetPostString("returndate2");
  10125. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10126. if (dw.Length > 0) lw.Add(dw);
  10127. string finishDate1 = GetPostString("finishdate1");
  10128. string finishDate2 = GetPostString("finishdate2");
  10129. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10130. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10131. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10132. string mainWhere = string.Join(" and ", lw.ToArray());
  10133. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10134. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10135. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10136. decimal total = 0;
  10137. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10138. {
  10139. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10140. }
  10141. var res = new
  10142. {
  10143. data = total
  10144. };
  10145. string ro_jsond = JsonConvert.SerializeObject(res);
  10146. returnSuccess(ro_jsond);
  10147. return;
  10148. }
  10149. public void get_erp_qr_waitdeliverylist()
  10150. {
  10151. DataStruct dStruct = GetPostStruct();
  10152. List<string> lw = new List<string>();
  10153. string tid = GetPostString("ctid");
  10154. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10155. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10156. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10157. var res_objz = new
  10158. {
  10159. restype = 1,
  10160. data = dt
  10161. };
  10162. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10163. returnSuccess(ro_jsonz);
  10164. }
  10165. public void get_erp_yield_list()
  10166. {
  10167. DataStruct dStruct = GetPostStruct();
  10168. List<string> lw = new List<string>();
  10169. string tid = GetPostString("ctid");
  10170. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10171. string shopname = GetPostString("shopname");
  10172. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10173. string buyernick = GetPostString("buyer_nick");
  10174. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10175. //if (tid.Length == 0 && buyernick.Length == 0)
  10176. //{
  10177. // lw.Add(string.Format("IsRefund<={0}", 1));
  10178. //}
  10179. string customer = GetPostString("customer");
  10180. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10181. string design = GetPostString("design");
  10182. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10183. string orderState = GetPostString("orderState");
  10184. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10185. string address = GetPostString("address");
  10186. 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));
  10187. string sellermemo = GetPostString("seller_memo");
  10188. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10189. string supplier = GetPostString("supplier");
  10190. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10191. string OrderArea = GetPostString("order_area");
  10192. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10193. string placedate1 = GetPostString("placedate1");
  10194. string placedate2 = GetPostString("placedate2");
  10195. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10196. if (fdw.Length > 0) lw.Add(fdw);
  10197. string price1 = GetPostString("price1");
  10198. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10199. string price2 = GetPostString("price2");
  10200. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10201. string unusualCon = GetPostString("unusualcon");
  10202. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10203. string posTag = CurrentUser.UserPost.Post.Code;
  10204. if (posTag == "Supplier")
  10205. {
  10206. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10207. }
  10208. lw.Add(string.Format("OrderState = 6 "));
  10209. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10210. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10211. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10212. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10213. writeGridDataTableJson(dStruct.TotalCount, dt);
  10214. }
  10215. public void change_erp_sup_state()
  10216. {
  10217. if (UrlPostParmsCheck("ctid"))
  10218. {
  10219. string ctid = GetPostString("ctid");
  10220. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10221. if (ceErpTradeCell != null)
  10222. {
  10223. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10224. if (ceErpTradeCellExtend == null)
  10225. {
  10226. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10227. ceErpTradeCellExtend.ctid = ctid;
  10228. ceErpTradeCellExtend.SupState = 1;
  10229. ceErpTradeCellExtend.Create();
  10230. }
  10231. else
  10232. {
  10233. ceErpTradeCellExtend.SupState = 1;
  10234. ceErpTradeCellExtend.Update();
  10235. }
  10236. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10237. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10238. return;
  10239. }
  10240. returnErrorMsg("找不到订单");
  10241. }
  10242. }
  10243. public void supplier_all_downs()
  10244. {
  10245. if (UrlPostParmsCheck("tids"))
  10246. {
  10247. string tids = GetPostString("tids");
  10248. if (tids != null && tids.Length > 0)
  10249. {
  10250. StringBuilder sql = new StringBuilder();
  10251. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10252. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10253. sql = new StringBuilder();
  10254. 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, "下载设计文件");
  10255. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10256. string[] list = tids.Split(',');
  10257. foreach (string ctid in list)
  10258. {
  10259. CeErpSukuraData.createInfo(ctid, 3);
  10260. }
  10261. designHelper.api_approveDesign(tids); //approveDesign
  10262. returnSuccessMsg("下载成功!");
  10263. return;
  10264. }
  10265. returnErrorMsg("下载订单更新失败");
  10266. }
  10267. }
  10268. public void uploaderFileSuccess()
  10269. {
  10270. if (UrlPostParmsCheck("fileName"))
  10271. {
  10272. string fileName = GetPostString("fileName");
  10273. ApiVo apiVo = new ApiVo();
  10274. apiVo.orderNumber = fileName;
  10275. apiVo.actionName = "finishDesign";
  10276. designHelper.API_WorkCore(apiVo);//finishDesign
  10277. returnSuccessMsg("");
  10278. }
  10279. }
  10280. public void get_sample2_order()
  10281. {
  10282. if (UrlPostParmsCheck("ctid"))
  10283. {
  10284. string ctid = GetPostString("ctid");
  10285. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10286. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10287. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10288. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10289. double total = 0.0;
  10290. double order_price = 0.0;
  10291. if (dt_bu.Rows.Count > 0)
  10292. {
  10293. foreach (DataRow dr in dt_bu.Rows)
  10294. {
  10295. total += Convert.ToDouble(dr["payment"]);
  10296. }
  10297. }
  10298. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10299. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10300. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10301. string tid = ctid.Replace("S_", "");
  10302. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10303. double paymant = 0.0;
  10304. if (entity != null)
  10305. {
  10306. paymant = entity.payment;
  10307. }
  10308. string return_reason = "";
  10309. if (dt_after != null && dt_after.Rows.Count > 0)
  10310. {
  10311. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10312. }
  10313. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10314. }
  10315. }
  10316. public void get_erp_design_status()
  10317. {
  10318. string designName = GetPostString("designName");
  10319. DataStruct dStruct = GetPostStruct();
  10320. if (designName.Length > 0)
  10321. {
  10322. 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";
  10323. sql_user += " and Name like '%" + designName + "%'";
  10324. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10325. List<string> ids_list = new List<string>();
  10326. if (user_table.Rows.Count > 0)
  10327. {
  10328. foreach (DataRow item in user_table.Rows)
  10329. {
  10330. ids_list.Add(item["id"].ToString());
  10331. string ids_s = item["TeamIds"].ToString();
  10332. if (ids_s.Length > 0)
  10333. {
  10334. ids_list.AddRange(ids_s.Split(','));
  10335. }
  10336. }
  10337. }
  10338. HashSet<string> set = new HashSet<string>(ids_list);
  10339. ids_list = set.ToList();
  10340. if (ids_list.Count > 0)
  10341. {
  10342. 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));
  10343. dStruct.MainWhere = sql;
  10344. DataTable dt = null;
  10345. dt = WebCache.GetData("view_ErpUser", dStruct);
  10346. writeGridDataTableJson(dStruct.TotalCount, dt);
  10347. }
  10348. }
  10349. }
  10350. public void change_erp_order_price()
  10351. {
  10352. string ctid = GetPostString("ctid");
  10353. double price = GetPostDouble("price");
  10354. if (ctid.Length > 0)
  10355. {
  10356. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10357. if (ceErpTradeCellExtend == null)
  10358. {
  10359. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10360. ceErpTradeCellExtend.ctid = ctid;
  10361. ceErpTradeCellExtend.payment_cyt = price;
  10362. ceErpTradeCellExtend.Create();
  10363. }
  10364. else
  10365. {
  10366. ceErpTradeCellExtend.payment_cyt = price;
  10367. ceErpTradeCellExtend.Update();
  10368. }
  10369. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10370. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10371. {
  10372. ceErpDataSendOrderInfo.isSync = false;
  10373. ceErpDataSendOrderInfo.Update();
  10374. }
  10375. if (ceErpDataSendOrderInfo == null)
  10376. {
  10377. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10378. ceErpDataSendOrderInfo.isSync = false;
  10379. ceErpDataSendOrderInfo.ctid = ctid;
  10380. ceErpDataSendOrderInfo.Create();
  10381. }
  10382. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10383. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10384. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10385. if (dth != null && dth.Rows.Count > 0)
  10386. {
  10387. dataSendOrderBean dataSendOrderBean = null;
  10388. foreach (DataRow item in dth.Rows)
  10389. {
  10390. try
  10391. {
  10392. dataSendOrderBean = new dataSendOrderBean();
  10393. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10394. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10395. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10396. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10397. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10398. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10399. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10400. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10401. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10402. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10403. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10404. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10405. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10406. if (result != null)
  10407. {
  10408. if ("0".Equals(result.errcode))
  10409. {
  10410. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10411. }
  10412. else
  10413. {
  10414. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10415. }
  10416. }
  10417. }
  10418. catch (Exception ex)
  10419. {
  10420. }
  10421. }
  10422. }
  10423. returnSuccessMsg("修改成功!");
  10424. return;
  10425. }
  10426. returnErrorMsg("找不到订单");
  10427. }
  10428. public void find_he_together()
  10429. {
  10430. string ctid = GetPostString("ctid");
  10431. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10432. List<string> list = new List<string>();
  10433. if (ceErpTradeCell != null)
  10434. {
  10435. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10436. {
  10437. 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);
  10438. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10439. if (table != null && table.Rows.Count > 0)
  10440. {
  10441. foreach (TableRow row in table.Rows)
  10442. {
  10443. }
  10444. }
  10445. }
  10446. }
  10447. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10448. }
  10449. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10450. {
  10451. //chy----19
  10452. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10453. //GD-CYT-----64
  10454. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10455. //ZHX----3
  10456. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10457. //JK----97
  10458. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10459. //ZT----70
  10460. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10461. //LHCY-----98
  10462. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10463. //XD-----90
  10464. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10465. //CYCY-----14
  10466. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10467. };
  10468. //其他改名
  10469. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10470. {
  10471. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10472. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10473. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10474. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10475. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10476. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10477. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10478. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10479. };
  10480. //不统计
  10481. List<int> no_suppliers = new List<int>()
  10482. {
  10483. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10484. };
  10485. //配件单
  10486. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10487. {
  10488. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10489. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10490. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10491. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10492. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10493. {"旗杆",new List<string>(){ "班旗" } },
  10494. {"牙签",new List<string>(){ "不干胶" } }
  10495. };
  10496. public void get_place_order_data()
  10497. {
  10498. string date1 = GetPostString("date1");
  10499. string date2 = GetPostString("date2");
  10500. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10501. DateTime start = DateTime.Parse(starttime);
  10502. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10503. DateTime end = DateTime.Parse(endtime);
  10504. if (date1 != null && date1.Length > 0)
  10505. {
  10506. DateTime dateTime = DateTime.Parse(date1);
  10507. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10508. start = DateTime.Parse(starttime);
  10509. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10510. end = DateTime.Parse(endtime);
  10511. }
  10512. if (date2 != null && date2.Length > 0)
  10513. {
  10514. DateTime dateTime = DateTime.Parse(date2);
  10515. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10516. end = DateTime.Parse(endtime);
  10517. }
  10518. 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);
  10519. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10520. //不干胶-----1,卡片-----29
  10521. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10522. foreach (DataRow row in data.Rows)
  10523. {
  10524. int productId = Convert.ToInt32(row["ProductId"]);
  10525. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10526. if (no_suppliers.Contains(supplierId))
  10527. {
  10528. continue;
  10529. }
  10530. string seller_memo = row["seller_memo"].ToString();
  10531. bool ispj = false;//是否配件单
  10532. bool isfirst = true;//第一个配
  10533. maps.Keys.ForEach(key =>
  10534. {
  10535. //备注包含配件
  10536. if (seller_memo.Contains(key) && isfirst)
  10537. {
  10538. List<string> list = maps[key];
  10539. ispj = true;
  10540. isfirst = false;
  10541. for (int i = 0; i < list.Count; i++)
  10542. {
  10543. if (seller_memo.Contains(list[i]))
  10544. {
  10545. ispj = false;
  10546. break;
  10547. }
  10548. }
  10549. }
  10550. });
  10551. if (ispj)
  10552. {
  10553. continue;
  10554. }
  10555. seller_memo = seller_memo.Replace("UV", "uv");
  10556. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10557. //吊牌归到卡片
  10558. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10559. seller_memo = seller_memo.Replace("卡套", "卡片");
  10560. seller_memo = seller_memo.Replace("封套", "卡片");
  10561. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10562. seller_memo = seller_memo.Replace("腰封", "卡片");
  10563. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10564. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10565. seller_memo = seller_memo.Replace("横幅", "条幅");
  10566. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10567. string map_key = "";
  10568. string type = "";
  10569. if (supplierMap.ContainsKey(supplierId))
  10570. {
  10571. foreach (var kvp in supplierMap[supplierId])
  10572. {
  10573. if (seller_memo.Contains(kvp.Key))
  10574. {
  10575. map_key = kvp.Value;
  10576. type = kvp.Value;
  10577. break;
  10578. }
  10579. }
  10580. }
  10581. if (map_key == "")
  10582. {
  10583. type = "其他";
  10584. map_key = "其他";
  10585. }
  10586. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10587. {
  10588. map_key = suppliers[supplierId];
  10589. }
  10590. if (supplierId == 70)
  10591. {
  10592. supplierId = 70;
  10593. }
  10594. map_key += "_" + row["SupplierName"].ToString();
  10595. Dictionary<string, int> map = null;
  10596. if (other_map.ContainsKey(map_key))
  10597. {
  10598. other_map.TryGetValue(map_key, out map);
  10599. }
  10600. else
  10601. {
  10602. map = new Dictionary<string, int>();
  10603. map.Add("dayDev", 0);//当天出货
  10604. map.Add("dayTotal", 0);//下单总数
  10605. map.Add("payTotal", 0);//500以上
  10606. map.Add("today", 0);//当天出货数量
  10607. map.Add("unusua", 0);//异常数
  10608. other_map.Add(map_key, map);
  10609. other_map.TryGetValue(map_key, out map);
  10610. }
  10611. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10612. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10613. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10614. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10615. {
  10616. map["dayTotal"]++;
  10617. if (supplierId == 97)
  10618. {
  10619. supplierId = 97;
  10620. }
  10621. }
  10622. if (Convert.ToDecimal(row["payment"]) >= 500)
  10623. {
  10624. map["payTotal"]++;
  10625. }
  10626. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10627. {
  10628. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10629. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10630. {
  10631. map["today"]++;
  10632. }
  10633. }
  10634. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10635. {
  10636. map["unusua"]++;
  10637. }
  10638. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10639. //GD-CYT-----64
  10640. DateTime two = palceTimeStart.AddHours(14);
  10641. DateTime three = palceTimeStart.AddHours(15);
  10642. DateTime four = palceTimeStart.AddHours(16);
  10643. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10644. {
  10645. //下午四点前 500-1000
  10646. string count = row["ProductCount"].ToString();
  10647. if (count != null && count.Length > 0)
  10648. {
  10649. int productCount = commonHelper.getPlaceProductCount(count);
  10650. if (productCount >= 500 && productCount <= 1000)
  10651. {
  10652. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10653. {
  10654. map["dayDev"]++;
  10655. }
  10656. }
  10657. }
  10658. }
  10659. //UV
  10660. else if ("uv".Equals(type))
  10661. {
  10662. //ZT----70
  10663. //ZHX----3
  10664. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10665. {
  10666. map["dayDev"]++;
  10667. }
  10668. //JK----97
  10669. //HZX----105
  10670. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10671. {
  10672. map["dayDev"]++;
  10673. if (supplierId == 97)
  10674. {
  10675. supplierId = 97;
  10676. Debug.WriteLine(map["dayTotal"].ToString() + "-" + map["dayDev"].ToString());
  10677. }
  10678. }
  10679. }
  10680. //帆布---52|条幅---27
  10681. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10682. {
  10683. //LHCY-----98
  10684. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10685. {
  10686. map["dayDev"]++;
  10687. }
  10688. }
  10689. //条幅
  10690. else if ("条幅".Equals(type))
  10691. {
  10692. //XD-----90
  10693. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10694. {
  10695. map["dayDev"]++;
  10696. }
  10697. }
  10698. //桌布
  10699. else if ("桌布".Equals(type))
  10700. {
  10701. //XD-----90
  10702. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10703. {
  10704. map["dayDev"]++;
  10705. }
  10706. }
  10707. //DL---10
  10708. //AYTW---119
  10709. //FS-CYT-DY ----80
  10710. //JK----97
  10711. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10712. {
  10713. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10714. {
  10715. map["dayDev"]++;
  10716. }
  10717. }
  10718. }
  10719. DataTable dt = new DataTable();
  10720. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10721. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10722. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10723. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10724. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10725. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10726. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10727. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10728. other_map.Keys.ForEach(key =>
  10729. {
  10730. DataRow dr = dt.NewRow();
  10731. Dictionary<string, int> map = other_map[key];
  10732. string[] key_list = key.Split('_');
  10733. dr[0] = key_list[0];
  10734. dr[1] = key_list[1];
  10735. if (key_list.Length > 2)
  10736. {
  10737. dr[1] += "(" + key_list[2] + ")";
  10738. }
  10739. dr[2] = map["dayTotal"];
  10740. dr[3] = map["payTotal"];
  10741. dr[4] = map["today"];
  10742. dr[5] = map["unusua"];
  10743. dr[6] = map["dayDev"];
  10744. double rate = 0.00;
  10745. if (map["dayDev"] > 0)
  10746. {
  10747. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10748. }
  10749. dr[7] = rate.ToString();
  10750. dt.Rows.Add(dr);
  10751. });
  10752. DataView dv = new DataView(dt);
  10753. dv.Sort = "SupplierName";
  10754. //dv.Sort = "AllOrder desc";
  10755. DataTable dtNew = dv.ToTable();
  10756. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10757. }
  10758. public void check_order_desing_info()
  10759. {
  10760. string ctid = GetPostString("ctid");
  10761. if (!string.IsNullOrEmpty(ctid))
  10762. {
  10763. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10764. if (ceErpTradeCell != null)
  10765. {
  10766. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10767. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10768. return;
  10769. }
  10770. returnErrorMsg("找不到订单");
  10771. return;
  10772. }
  10773. returnErrorMsg("找不到订单");
  10774. }
  10775. public void get_timeout_detail()
  10776. {
  10777. string poscode = CurrentUser.UserPost.Post.Code;
  10778. DataStruct dStruct = GetPostStruct();
  10779. List<string> lw = new List<string>();
  10780. string id = GetPostString("id");
  10781. string pay_date1 = GetPostString("pay_date1");
  10782. string pay_date2 = GetPostString("pay_date2");
  10783. int type = GetPostInt("type");
  10784. if (type == 0)
  10785. {
  10786. if (pay_date1.Length > 0)
  10787. {
  10788. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  10789. }
  10790. if (pay_date2.Length > 0)
  10791. {
  10792. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  10793. }
  10794. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  10795. }
  10796. if (type == 1)
  10797. {
  10798. if (pay_date1.Length > 0)
  10799. {
  10800. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  10801. }
  10802. if (pay_date2.Length > 0)
  10803. {
  10804. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  10805. }
  10806. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  10807. }
  10808. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10809. DataTable dt = null;
  10810. dt = WebCache.GetData("view_orderlist", dStruct);
  10811. writeGridDataTableJson(dStruct.TotalCount, dt);
  10812. }
  10813. public void saveUrgentChargePrice()
  10814. {
  10815. string ctid = GetPostString("ctid");
  10816. if (!string.IsNullOrEmpty(ctid))
  10817. {
  10818. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10819. if (ceErpTradeCell != null)
  10820. {
  10821. double price = GetPostDouble("price");
  10822. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  10823. if (ceErpTradeCellExtend == null)
  10824. {
  10825. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10826. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  10827. }
  10828. ceErpTradeCellExtend.urgentCharge = price;
  10829. if (ceErpTradeCellExtend.ID > 0)
  10830. {
  10831. ceErpTradeCellExtend.Update();
  10832. }
  10833. else
  10834. {
  10835. ceErpTradeCellExtend.Save();
  10836. }
  10837. returnSuccessMsg("修改成功!");
  10838. return;
  10839. }
  10840. returnErrorMsg("找不到订单");
  10841. return;
  10842. }
  10843. returnErrorMsg("找不到订单");
  10844. }
  10845. public void finish_erp_order()
  10846. {
  10847. string ctid = GetPostString("ctid");
  10848. if (!string.IsNullOrEmpty(ctid))
  10849. {
  10850. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  10851. {
  10852. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10853. if (ceErpTradeCell != null)
  10854. {
  10855. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  10856. ceErpTradeCell.Update();
  10857. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  10858. returnSuccessMsg("修改成功!");
  10859. return;
  10860. }
  10861. }
  10862. }
  10863. returnErrorMsg("找不到订单");
  10864. }
  10865. public void get_trade_order_list()
  10866. {
  10867. string tid = GetPostString("tid");
  10868. if (!string.IsNullOrEmpty(tid))
  10869. {
  10870. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  10871. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10872. writeGridDataTableJson(data.Rows.Count, data);
  10873. return;
  10874. }
  10875. returnErrorMsg("找不到订单");
  10876. }
  10877. public void save_cell_spu()
  10878. {
  10879. string ctid = GetPostString("ctid");
  10880. string spu_id = GetPostString("spu_id");
  10881. if (!string.IsNullOrEmpty(ctid))
  10882. {
  10883. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10884. if (ceErpTradeCellExtend == null)
  10885. {
  10886. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10887. ceErpTradeCellExtend.ctid = ctid;
  10888. }
  10889. ceErpTradeCellExtend.spu_id = spu_id;
  10890. if (ceErpTradeCellExtend.ID == 0)
  10891. {
  10892. ceErpTradeCellExtend.Create();
  10893. }
  10894. else
  10895. {
  10896. ceErpTradeCellExtend.Update();
  10897. }
  10898. returnSuccessMsg("修改成功!");
  10899. return;
  10900. }
  10901. returnErrorMsg("找不到订单");
  10902. }
  10903. public void change_express_info()
  10904. {
  10905. string ctid = GetPostString("ctid");
  10906. string transNo = GetPostString("transNo");
  10907. string transCom = GetPostString("transCom");
  10908. if (!string.IsNullOrEmpty(ctid))
  10909. {
  10910. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10911. if (ceErpTradeCellExtend == null)
  10912. {
  10913. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10914. ceErpTradeCellExtend.ctid = ctid;
  10915. }
  10916. ceErpTradeCellExtend.modExpressNo = transNo;
  10917. ceErpTradeCellExtend.modExpressCom = transCom;
  10918. ceErpTradeCellExtend.readMod = 2;
  10919. if (ceErpTradeCellExtend.ID == 0)
  10920. {
  10921. ceErpTradeCellExtend.Create();
  10922. }
  10923. else
  10924. {
  10925. ceErpTradeCellExtend.Update();
  10926. }
  10927. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  10928. returnSuccessMsg("修改成功!");
  10929. return;
  10930. }
  10931. returnErrorMsg("找不到订单");
  10932. }
  10933. public void get_change_express_list()
  10934. {
  10935. DataStruct dStruct = GetPostStruct();
  10936. List<string> lw = new List<string>();
  10937. int st = 2;
  10938. string tid = GetPostString("ctid");
  10939. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  10940. string shopname = GetPostString("shopname");
  10941. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10942. string buyernick = GetPostString("buyer_nick");
  10943. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10944. string sellermemo = GetPostString("seller_memo");
  10945. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10946. string supplier = GetPostString("supplier");
  10947. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10948. string customer = GetPostString("customer");
  10949. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10950. string design = GetPostString("design");
  10951. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10952. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  10953. string poscode = CurrentUser.UserPost.Post.Code;
  10954. if (poscode != "SysAdmin")
  10955. {
  10956. string shopid = CurrentUser.User.pemShop;
  10957. lw.Add(string.Format("shopId in ({0})", shopid));
  10958. }
  10959. lw.Add("readMod = 2");
  10960. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10961. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10962. writeGridDataTableJson(dStruct.TotalCount, dt);
  10963. }
  10964. public void deal_express_complete()
  10965. {
  10966. string ctid = GetPostString("ctid");
  10967. if (!string.IsNullOrEmpty(ctid))
  10968. {
  10969. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10970. if (ceErpTradeCellExtend == null)
  10971. {
  10972. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10973. ceErpTradeCellExtend.ctid = ctid;
  10974. }
  10975. ceErpTradeCellExtend.readMod = 1;
  10976. if (ceErpTradeCellExtend.ID == 0)
  10977. {
  10978. ceErpTradeCellExtend.Create();
  10979. }
  10980. else
  10981. {
  10982. ceErpTradeCellExtend.Update();
  10983. }
  10984. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  10985. returnSuccessMsg("修改成功!");
  10986. return;
  10987. }
  10988. returnErrorMsg("找不到订单");
  10989. }
  10990. public void aftersale_return_visit()
  10991. {
  10992. string ctid = GetPostString("ctid");
  10993. if (!string.IsNullOrEmpty(ctid))
  10994. {
  10995. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10996. if (ceErpTradeCellExtend == null)
  10997. {
  10998. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10999. ceErpTradeCellExtend.ctid = ctid;
  11000. }
  11001. ceErpTradeCellExtend.returnVisit = 1;
  11002. if (ceErpTradeCellExtend.ID == 0)
  11003. {
  11004. ceErpTradeCellExtend.Create();
  11005. }
  11006. else
  11007. {
  11008. ceErpTradeCellExtend.Update();
  11009. }
  11010. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11011. if (ceErpTradeAfterSaleExtend != null)
  11012. {
  11013. ceErpTradeAfterSaleExtend.TextResult = "";
  11014. ceErpTradeAfterSaleExtend.Update();
  11015. }
  11016. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11017. returnSuccessMsg("修改成功!");
  11018. return;
  11019. }
  11020. returnErrorMsg("找不到订单");
  11021. }
  11022. public void orderPlaceInfo()
  11023. {
  11024. string ctids = GetPostString("ctids");
  11025. string[] list = ctids.Split(',');
  11026. foreach (string ctid in list)
  11027. {
  11028. CeErpSukuraData.createInfo(ctid, 3);
  11029. }
  11030. designHelper.api_approveDesign(ctids); //approveDesign
  11031. returnSuccessMsg("");
  11032. }
  11033. }
  11034. }