sync.order.cs 568 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223
  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. /*string createtime = "2024-01-22 13:50:39.000";
  52. string textContent = "";
  53. int row_num = 100;
  54. while (row_num == 100)
  55. {
  56. string conSql = string.Format("SELECT TOP 100 posCode, buyer_nick,pay_time FROM [dbo].[CE_ErpTrade] WHERE pay_time > '{0}' AND ( buyer_id IS NULL OR buyer_id = '' ) AND posCode != '' AND buyer_nick != '' ORDER By pay_time ASC", createtime);
  57. DataTable table = DbHelper.DbConn.ExecuteDataset(conSql).Tables[0];
  58. if (table != null)
  59. {
  60. row_num = table.Rows.Count;
  61. foreach (DataRow row in table.Rows)
  62. {
  63. createtime = row["pay_time"].ToString();
  64. string buyerId = apiHelper.API_GetUserId(row["posCode"].ToString(), row["buyer_nick"].ToString());
  65. if (string.IsNullOrEmpty(buyerId))
  66. {
  67. continue;
  68. }
  69. textContent += string.Format("update [dbo].[CE_ErpTrade] set buyer_id='{2}' WHERE posCode='{0}' and buyer_nick='{1}';\r\n", row["posCode"].ToString(), row["buyer_nick"].ToString(), buyerId);
  70. }
  71. }
  72. try
  73. {
  74. StreamWriter fs = new StreamWriter("C:/Users/231010/Desktop/updateSql.txt", true);
  75. fs.WriteLine(textContent);
  76. fs.Close();
  77. }
  78. catch (Exception e)
  79. {
  80. }
  81. textContent = "";
  82. }*/
  83. //apiHelper.Api_SyncOrderByTime("598825");
  84. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  85. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  86. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  87. //banniuApiHelper.sendLogisticsInfo(null);
  88. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  89. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  90. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  91. //int sid = commonHelper.autoDistributeToSupplier(entity);
  92. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  93. //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\"}}");
  94. //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}}");
  95. List<string> lw = new List<string>();
  96. string tid = GetPostString("ctid");
  97. string date1 = GetPostString("date1");
  98. //12-1 修改
  99. string urgent = GetPostString("urgent");
  100. string back = GetPostString("back");
  101. string offlineSearch = GetPostString("offlineSearch");
  102. int paramsCount = 0;
  103. if (!string.IsNullOrWhiteSpace(urgent))
  104. {
  105. if (urgent.Equals("true"))
  106. {
  107. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  108. }
  109. }
  110. if (!string.IsNullOrWhiteSpace(back))
  111. {
  112. if (back.Equals("true"))
  113. {
  114. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  115. }
  116. }
  117. if (!string.IsNullOrWhiteSpace(offlineSearch))
  118. {
  119. if (offlineSearch.Equals("true"))
  120. {
  121. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  122. }
  123. }
  124. //end
  125. string date2 = GetPostString("date2");
  126. string buyernick = GetPostString("buyer_nick");
  127. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  128. {
  129. if (tid.Length <= 0 && buyernick.Length <= 0)
  130. {
  131. return;
  132. }
  133. }
  134. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  135. {
  136. if (tid.Length > 0)
  137. {
  138. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
  139. }
  140. if (buyernick.Length > 0)
  141. {
  142. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  143. }
  144. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  145. if (dw.Length > 0)
  146. {
  147. lw.Add(dw);
  148. }
  149. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  150. {
  151. string usershop = CurrentUser.User.pemShop;
  152. lw.Add(string.Format("ShopId in ({0})", usershop));
  153. }
  154. }
  155. else
  156. {
  157. if (ex_psize == 0)
  158. {
  159. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  160. }
  161. if (PKey != "admin")
  162. {
  163. string usershop = CurrentUser.User.pemShop;
  164. lw.Add(string.Format("ShopId in ({0})", usershop));
  165. paramsCount++;
  166. }
  167. }
  168. string uploaddate1 = GetPostString("uploaddate1");
  169. string uploaddate2 = GetPostString("uploaddate2");
  170. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  171. if (update.Length > 0) lw.Add(update);
  172. string deliverydate1 = GetPostString("deliverydate1");
  173. string deliverydate2 = GetPostString("deliverydate2");
  174. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  175. if (deliverydate.Length > 0)
  176. {
  177. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  178. };
  179. string shopname = GetPostString("shopname");
  180. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  181. string addwechat = GetPostString("addwechat");
  182. if (addwechat.Length > 0)
  183. {
  184. int addWt = Convert.ToInt32(addwechat);
  185. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  186. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  187. }
  188. string customer = GetPostString("customer");
  189. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  190. string design = GetPostString("design");
  191. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  192. string orderState = GetPostString("orderState");
  193. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  194. string address = GetPostString("address");
  195. 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));
  196. string sellermemo = GetPostString("seller_memo");
  197. if (sellermemo.Length > 0)
  198. {
  199. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  200. }
  201. string backReason = GetPostString("backReason");
  202. if (backReason.Length > 0)
  203. {
  204. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  205. }
  206. string apdate1 = GetPostString("apdate1");
  207. string apdate2 = GetPostString("apdate2");
  208. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  209. if (dwap.Length > 0) lw.Add(dwap);
  210. string price1 = GetPostString("price1");
  211. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  212. string price2 = GetPostString("price2");
  213. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  214. string isoldcustomer = GetPostString("isoldcus");
  215. string finishdate1 = GetPostString("finishdate1");
  216. string finishdate2 = GetPostString("finishdate2");
  217. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  218. bool isFinish = false;
  219. if (finishdate.Length > 0)
  220. {
  221. lw.Add(finishdate);
  222. isFinish = true;
  223. paramsCount++;
  224. }
  225. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  226. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  227. if (ex_psize > 0)
  228. {
  229. int UserID = CurrentUser.UserID;
  230. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  231. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  232. {
  233. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  234. }
  235. dStruct.Order = "pay_time desc";
  236. }
  237. string isNew = GetPostString("isNew");
  238. if (isNew == "true")
  239. {
  240. lw.Add(string.Format("IsNew = {0}", 1));
  241. }
  242. string overtime = GetPostString("overtime");
  243. if (overtime == "1")
  244. {
  245. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  246. }
  247. String usePost = CurrentUser.UserPost.Post.Code;
  248. if (usePost.Equals("Operation") == true)
  249. {
  250. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  251. }
  252. else
  253. {
  254. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  255. }
  256. //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";
  257. if (dStruct.PageSize == 100000)
  258. {
  259. dStruct.Order = "";
  260. }
  261. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  262. DataTable dt = null;
  263. string tablename = "view_orderlist";
  264. if (isFinish)
  265. {
  266. tablename = "view_orderlist_end";
  267. }
  268. dt = WebCache.GetData(tablename, dStruct);
  269. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  270. if (dt != null && dt.Rows.Count > 0)
  271. {
  272. foreach (DataRow dr in dt.Rows)
  273. {
  274. try
  275. {
  276. if (dr["refund_fees"] != null)
  277. {
  278. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  279. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  280. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  281. if (payment == refund_fees)
  282. {
  283. dr["refund_fees"] = Math.Round(refund_fees, 2);
  284. continue; // 跳过当前迭代
  285. }
  286. else if (refund_fees == total_fee)
  287. {
  288. dr["refund_fees"] = payment;
  289. continue; // 跳过当前迭代
  290. }
  291. else
  292. {
  293. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  294. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  295. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  296. }
  297. }
  298. // 对象操作
  299. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  300. ceErpTradeCell.ctid = dr["ctid"].ToString();
  301. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  302. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  303. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  304. if (dStruct.PageSize != 100000)
  305. {
  306. if (dr["DispatchSort"].ToString() == "2")
  307. {
  308. dr["gongchuang"] = 200;
  309. }
  310. else
  311. {
  312. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  313. dr["gongchuang"] = response.code;
  314. }
  315. }
  316. }
  317. catch (NullReferenceException ex)
  318. {
  319. // 处理空引用异常
  320. dr["refund_fees"] = "0.00";
  321. }
  322. }
  323. }
  324. writeGridDataTableJson(dStruct.TotalCount, dt);
  325. }
  326. public void get_erp_orderlist_sumprice()
  327. {
  328. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  329. return;
  330. List<string> lw = new List<string>();
  331. string tid = GetPostString("ctid");
  332. string date1 = GetPostString("date1");
  333. string date2 = GetPostString("date2");
  334. if (tid.Length > 0 || date1.Length > 0)
  335. {
  336. lw.Add(string.Format("ctid like '%{0}%'", tid));
  337. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  338. if (dw.Length > 0) lw.Add(dw);
  339. }
  340. else
  341. {
  342. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  343. }
  344. string shopname = GetPostString("shopname");
  345. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  346. string buyernick = GetPostString("buyer_nick");
  347. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  348. string customer = GetPostString("customer");
  349. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  350. string design = GetPostString("design");
  351. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  352. string orderState = GetPostString("orderState");
  353. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  354. string address = GetPostString("address");
  355. 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));
  356. string sellermemo = GetPostString("seller_memo");
  357. if (sellermemo.Length > 0)
  358. {
  359. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  360. }
  361. string apdate1 = GetPostString("apdate1");
  362. string apdate2 = GetPostString("apdate2");
  363. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  364. if (dwap.Length > 0) lw.Add(dwap);
  365. string price1 = GetPostString("price1");
  366. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  367. string price2 = GetPostString("price2");
  368. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  369. string isoldcustomer = GetPostString("isoldcus");
  370. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  371. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  372. if (PKey != "admin")
  373. {
  374. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  375. lw.Add(string.Format("shopId in ({0})", usershop));
  376. }
  377. //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";
  378. string mainWhere = string.Join(" and ", lw.ToArray());
  379. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  380. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  381. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  382. decimal total = 0;
  383. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  384. {
  385. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  386. }
  387. var res = new
  388. {
  389. data = total
  390. };
  391. string ro_jsond = JsonConvert.SerializeObject(res);
  392. returnSuccess(ro_jsond);
  393. return;
  394. }
  395. public void get_erp_CustomerServiceGather()
  396. {
  397. string userWhere = "", orderWhere = "";
  398. List<string> lw = new List<string>();
  399. string customer = GetPostString("customer");
  400. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  401. string shopname = GetPostString("shopname");
  402. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  403. string date1 = GetPostString("date1");
  404. string date2 = GetPostString("date2");
  405. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  406. if (dw.Length > 0) lw.Add(dw);
  407. orderWhere = string.Join(" and ", lw.ToArray());
  408. 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 " +
  409. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  410. "left join " +
  411. "( " +
  412. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  413. ") as b on a.ID = b.CustomerUserId " +
  414. "left join " +
  415. "( " +
  416. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  417. ") as d on a.ID = d.CustomerUserId " +
  418. "left join " +
  419. "( " +
  420. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  421. ") as e on a.ID = e.CustomerUserId " +
  422. "left join " +
  423. "( " +
  424. " select CustomerUserId, RefundCount, RefundSum from " +
  425. " ( " +
  426. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  427. " from CE_ErpTradeRefund a " +
  428. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  429. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  430. " group by CustomerUserId " +
  431. " ) as a " +
  432. ") as f on a.ID = f.CustomerUserId " +
  433. "where a.PostCode = 'CustomerService'",
  434. userWhere, orderWhere);
  435. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  436. writeGridDataTableJson(dt.Rows.Count, dt);
  437. //writeGridDataTableJson(dt.Rows.Count, dt);
  438. }
  439. //设计汇总
  440. public void get_erp_DesignerGather()
  441. {
  442. string userWhere = "", orderWhere = "";
  443. List<string> lw = new List<string>();
  444. string Designer = GetPostString("designer");
  445. int org = GetPostInt("org");
  446. if (Designer.Length > 0)
  447. {
  448. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  449. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  450. }
  451. else if (org > 0)
  452. {
  453. userWhere = string.Format(" where OrgID ={0}", org);
  454. }
  455. string shopname = GetPostString("shopname");
  456. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  457. string state = GetPostString("state");
  458. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  459. string OrderArea = GetPostString("order_area");
  460. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  461. string date1 = GetPostString("date1");
  462. string date2 = GetPostString("date2");
  463. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  464. if (dw.Length > 0) lw.Add(dw);
  465. string UpDate1 = GetPostString("UpDate1");
  466. string UpDate2 = GetPostString("UpDate2");
  467. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  468. if (dw.Length > 0) lw.Add(dw);
  469. orderWhere = string.Join(" and ", lw.ToArray());
  470. 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 (" +
  471. "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 " +
  472. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  473. "left join " +
  474. "( " +
  475. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  476. ") as b on a.ID = b.DesignUserId " +
  477. "left join " +
  478. "( " +
  479. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  480. ") as d on a.ID = d.DesignUserId " +
  481. "left join " +
  482. "( " +
  483. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  484. ") as e on a.ID = e.DesignUserId " +
  485. "left join " +
  486. "( " +
  487. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  488. ") as g on a.ID = g.DesignUserId " +
  489. "left join " +
  490. "( " +
  491. " select CustomerUserId, RefundCount, RefundSum from " +
  492. " ( " +
  493. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  494. " from CE_ErpTradeRefund a " +
  495. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  496. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  497. " group by CustomerUserId " +
  498. " ) as a " +
  499. ") as f on a.ID = f.CustomerUserId " +
  500. "where a.PostCode = 'Designer') as z",
  501. userWhere, orderWhere);
  502. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  503. writeGridDataTableJson(dt.Rows.Count, dt);
  504. }
  505. //删除tradecell的订单
  506. public void del_erp_cellorder()
  507. {
  508. if (UrlPostParmsCheck("ctid"))
  509. {
  510. string eid = GetPostString("ctid");
  511. CeErpTradeCell.DelByCtid(eid);
  512. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  513. returnSuccessMsg("删除成功");
  514. }
  515. }
  516. public void clear_erp_refundstate()
  517. {
  518. if (UrlPostParmsCheck("ids"))
  519. {
  520. string eids = GetPostString("ids");
  521. string[] ctidList = eids.Split(',');
  522. foreach (string ctid in ctidList)
  523. {
  524. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  525. if (entity != null)
  526. {
  527. entity.IsRefund = 0;
  528. entity.Update();
  529. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  530. }
  531. else
  532. continue;
  533. }
  534. returnSuccessMsg("操作成功");
  535. return;
  536. }
  537. returnErrorMsg("缺少必要参数");
  538. }
  539. public void set_erp_urgency()
  540. {
  541. if (UrlPostParmsCheck("ctid"))
  542. {
  543. string eid = GetPostString("ctid");
  544. CeErpTradeCell entity = null;
  545. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  546. if (entity != null)
  547. {
  548. string utime = GetPostString("urgencytime");
  549. if (utime.Length > 0)
  550. {
  551. entity.UrgencyTime = Convert.ToDateTime(utime);
  552. }
  553. else
  554. {
  555. returnErrorMsg("请选择加急时间");
  556. return;
  557. }
  558. if (entity.OrderState <= 4)
  559. {
  560. //entity.seller_memo = entity.seller_memo + "-加急";
  561. string smemo = entity.seller_memo;
  562. int kindex = smemo.IndexOf(")");
  563. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  564. if (lastoneStr != "-")
  565. {
  566. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  567. }
  568. string prememo = smemo.Substring(0, kindex + 2);
  569. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  570. int lastkindex = lastmemo.IndexOf("(");
  571. DateTime urgtime = Convert.ToDateTime(utime);
  572. string newlastmemo = "";
  573. if (lastkindex == 0)
  574. {
  575. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  576. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  577. }
  578. else
  579. {
  580. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  581. }
  582. entity.seller_memo = prememo + newlastmemo;
  583. }
  584. entity.IsUrgency = true;
  585. entity.Update();
  586. ApiVo apiVo = new ApiVo();
  587. apiVo.orderNumber = entity.ctid;
  588. apiVo.actionName = "changeDesign";
  589. apiVo.orderRemarks = entity.seller_memo;
  590. apiVo.remarkSign = 3;
  591. designHelper.API_WorkCore(apiVo); //changeDesign
  592. CeErpSukuraData.createInfo(entity.ctid, 7);
  593. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  594. returnSuccessMsg("设置成功!");
  595. return;
  596. }
  597. returnErrorMsg("找不到记录");
  598. }
  599. }
  600. public void set_erp_reset()
  601. {
  602. if (UrlPostParmsCheck("ctid"))
  603. {
  604. string eid = GetPostString("ctid");
  605. CeErpTradeCell entity = null;
  606. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  607. if (entity != null)
  608. {
  609. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  610. {
  611. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  612. {
  613. returnErrorMsg("财务要求已下单已发货无法重置");
  614. return;
  615. }
  616. }
  617. entity.IsUrgency = false;
  618. entity.seller_memo = "";
  619. entity.OtherMemo = "";
  620. entity.OrderState = 0;
  621. entity.IsReturn = 0;
  622. //entity.IsRefund = 0;
  623. entity.MemoOpt = 0;
  624. entity.AfterSaleState = 0;
  625. entity.AfterSaleResponsible = "";
  626. entity.AfterSaleUserId = 0;
  627. entity.IsNeedBill = 0;
  628. entity.CustomerUserId = 0;
  629. entity.DesignUserId = 0;
  630. entity.SupplierId = 0;
  631. entity.PlaceUserId = 0;
  632. entity.ptid = "";
  633. entity.IsSample = 0;
  634. entity.IsXianHuo = 0;
  635. entity.isDianziOrder = 0;
  636. entity.FinishPlaceTime = null;
  637. entity.Update();
  638. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  639. if (trade != null)
  640. {
  641. trade.seller_memo = "";
  642. trade.Update();
  643. }
  644. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  645. returnSuccessMsg("重置成功!");
  646. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  647. if (desginBill != null)
  648. {
  649. desginBill.isDel = 1;
  650. desginBill.Update();
  651. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  652. }
  653. ApiVo apiVo = new ApiVo();
  654. apiVo.orderNumber = entity.ctid;
  655. apiVo.actionName = "resetDesign";
  656. designHelper.API_WorkCore(apiVo);//resetDesign
  657. return;
  658. }
  659. returnErrorMsg("找不到记录");
  660. }
  661. }
  662. public void save_erp_sellermemo()
  663. {
  664. if (UrlPostParmsCheck("ctid"))
  665. {
  666. string ctid = GetPostString("ctid");
  667. CeErpTradeCell entity = null;
  668. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  669. if (entity != null)
  670. {
  671. string memo = GetPostString("seller_memo");
  672. memo = memo.Replace(" ", "");
  673. if (memo.Contains("补差"))
  674. {
  675. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  676. return;
  677. }
  678. if (entity.seller_memo != memo)
  679. {
  680. if (entity.IsSample == 2)
  681. {
  682. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  683. return;
  684. }
  685. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  686. {
  687. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  688. {
  689. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  690. return;
  691. }
  692. }
  693. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  694. }
  695. commonHelper.getCytPrice(entity);
  696. int memoopt = GetPostInt("MemoOpt");
  697. Boolean ismemoopt = false;
  698. if (memoopt > 0)
  699. {
  700. string stropt = "";
  701. if (memoopt == 1)
  702. {
  703. stropt = "“改稿”";
  704. ismemoopt = true;
  705. }
  706. else if (memoopt == 2)
  707. {
  708. stropt = "“定稿”";
  709. }
  710. else if (memoopt == 3)
  711. {
  712. stropt = "“查货”";
  713. CeErpSukuraData.createInfo(entity.ctid, 6);
  714. }
  715. entity.MemoOpt = Convert.ToInt32(memoopt);
  716. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  717. }
  718. if (entity.OrderState < 5)
  719. {
  720. memo = memo.Replace("(", "(");
  721. memo = memo.Replace(")", ")");
  722. }
  723. entity.seller_memo = memo;
  724. entity.Update();
  725. ApiVo apiVo = new ApiVo();
  726. apiVo.orderNumber = entity.ctid;
  727. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  728. apiVo.orderRemarks = memo;
  729. apiVo.remarkSign = memoopt;
  730. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  731. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  732. returnSuccessMsg("保存成功!");
  733. return;
  734. }
  735. returnErrorMsg("找不到记录");
  736. }
  737. }
  738. public void ins_erp_checkorder()
  739. {
  740. if (UrlPostParmsCheck("ctid"))
  741. {
  742. string ctid = GetPostString("ctid");
  743. CeErpTradeCell entity = null;
  744. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  745. if (entity != null)
  746. {
  747. if (entity.OrderState < 6)
  748. {
  749. returnErrorMsg("下单完成后才可查货");
  750. return;
  751. }
  752. /*if (entity.OrderState > 6)
  753. {
  754. returnErrorMsg("订单已发货");
  755. return;
  756. }*/
  757. if (entity.FinishPlaceTime != null)
  758. {
  759. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  760. {
  761. returnErrorMsg("下单时间不足,无法查货");
  762. return;
  763. }
  764. }
  765. entity.MemoOpt = 3;
  766. entity.CheckOrderTime = DateTime.Now;
  767. entity.Update();
  768. CeErpSukuraData.createInfo(entity.ctid, 6);
  769. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  770. returnSuccessMsg("操作成功!");
  771. return;
  772. }
  773. returnErrorMsg("找不到记录");
  774. }
  775. }
  776. public void save_erp_othermemo()
  777. {
  778. if (UrlPostParmsCheck("ctid"))
  779. {
  780. string ctid = GetPostString("ctid");
  781. CeErpTradeCell entity = null;
  782. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  783. if (entity != null)
  784. {
  785. entity.OtherMemo = GetPostString("otherMemo");
  786. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  787. {
  788. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  789. StringBuilder sql = new StringBuilder();
  790. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  791. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  792. if (dt != null && dt.Rows.Count > 0)
  793. {
  794. foreach (DataRow dr in dt.Rows)
  795. {
  796. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  797. {
  798. //品类一直
  799. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  800. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  801. if (ceErpSampleCustomer == null)
  802. {
  803. ceErpSampleCustomer = new CeErpSampleCustomer();
  804. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  805. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  806. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  807. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  808. ceErpSampleCustomer.shopId = entity.ShopId;
  809. }
  810. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  811. ceErpSampleCustomer.lastTid = entity.tid;
  812. if (ceErpSampleCustomer.ID > 0)
  813. {
  814. ceErpSampleCustomer.Update();
  815. }
  816. else
  817. {
  818. ceErpSampleCustomer.Create();
  819. }
  820. }
  821. }
  822. }
  823. }
  824. //if (entity.IsOldCustomer == 1)
  825. //{
  826. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  827. //{
  828. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  829. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  830. //}
  831. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  832. //{
  833. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  834. // {
  835. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  836. // {
  837. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  838. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  839. // }
  840. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  841. // {
  842. // entity.OrderState = 2;
  843. // entity.DesignUserId = 0;
  844. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  845. // }
  846. // else
  847. // {
  848. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  849. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  850. // }
  851. // }
  852. //}
  853. //}
  854. entity.Update();
  855. returnSuccessMsg("保存成功!");
  856. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  857. return;
  858. }
  859. returnErrorMsg("找不到记录");
  860. }
  861. }
  862. public void save_erp_customermemo()
  863. {
  864. if (UrlPostParmsCheck("ctid"))
  865. {
  866. string ctid = GetPostString("ctid");
  867. CeErpTradeCell entity = null;
  868. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  869. if (entity != null)
  870. {
  871. entity.CustomerMemo = GetPostString("CustomerMemo");
  872. entity.Update();
  873. ApiVo apiVo = new ApiVo();
  874. apiVo.orderNumber = entity.ctid;
  875. apiVo.actionName = "followRemarks";
  876. apiVo.orderRemarks = entity.CustomerMemo;
  877. designHelper.API_WorkCore(apiVo);//followRemarks
  878. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  879. returnSuccessMsg("保存成功!");
  880. return;
  881. }
  882. returnErrorMsg("找不到记录");
  883. }
  884. }
  885. public void upd_erp_addmemotag()
  886. {
  887. if (UrlPostParmsCheck("ctid"))
  888. {
  889. ;
  890. string eid = GetPostString("ctid");
  891. string sfTagstr = GetPostString("memotag");
  892. CeErpTradeCell entity = null;
  893. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  894. if (entity != null)
  895. {
  896. if (entity.OrderState == 0)
  897. {
  898. returnErrorMsg("请先领单");
  899. return;
  900. }
  901. //撤销顺丰
  902. if (sfTagstr == "撤销顺丰")
  903. {
  904. entity.IsSF = 0;
  905. string reMsg = "";
  906. string oldmemo = entity.seller_memo;
  907. if (entity.OrderState < 5)
  908. {
  909. oldmemo = oldmemo.Replace("顺丰到付", "");
  910. oldmemo = oldmemo.Replace("顺丰寄付", "");
  911. entity.seller_memo = oldmemo;
  912. }
  913. else
  914. {
  915. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  916. {
  917. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  918. }
  919. }
  920. entity.Update();
  921. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  922. api.orderNumber = entity.ctid;
  923. api.actionName = "followRemarks";
  924. api.orderRemarks = entity.seller_memo;
  925. api.isSf = entity.IsSF.ToString();
  926. designHelper.API_WorkCore(api);//followRemarks
  927. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  928. returnSuccessMsg("撤销成功!" + reMsg);
  929. return;
  930. }
  931. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  932. {
  933. //string oldmemo = entity.seller_memo;
  934. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  935. string sfStr = GetPostString("memotag");
  936. string smemo = entity.seller_memo;
  937. int kindex = smemo.IndexOf(")");
  938. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  939. if (lastoneStr != "-")
  940. {
  941. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  942. }
  943. string prememo = smemo.Substring(0, kindex + 2);
  944. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  945. int lastkindex = lastmemo.IndexOf("(");
  946. string newlastmemo = "";
  947. if (lastkindex == 0)
  948. {
  949. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  950. newlastmemo = "(" + sfStr + "." + useLastmemo;
  951. }
  952. else
  953. {
  954. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  955. }
  956. entity.seller_memo = prememo + newlastmemo;
  957. }
  958. string sfTagMSg = "";
  959. if (sfTagstr == "顺丰寄付")
  960. {
  961. entity.IsSF = 1;
  962. sfTagMSg = "顺丰寄付";
  963. }
  964. else if (sfTagstr == "顺丰到付")
  965. {
  966. entity.IsSF = 2;
  967. sfTagMSg = "顺丰到付";
  968. }
  969. entity.Update();
  970. ApiVo apiVo = new ApiVo();
  971. apiVo.orderNumber = entity.ctid;
  972. apiVo.actionName = "orderRemarks";
  973. apiVo.orderRemarks = entity.seller_memo;
  974. apiVo.isSf = entity.IsSF.ToString();
  975. designHelper.API_WorkCore(apiVo);//orderRemarks
  976. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  977. returnSuccessMsg("标记成功!");
  978. return;
  979. }
  980. returnErrorMsg("找不到记录");
  981. }
  982. }
  983. public void upd_erp_ordertag()
  984. {
  985. if (UrlPostParmsCheck("ctid"))
  986. {
  987. string eid = GetPostString("ctid");
  988. CeErpTradeCell entity = null;
  989. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  990. if (entity != null)
  991. {
  992. int tag = GetPostInt("wechattag");
  993. //if(tag==4 && entity.IsSample == 2)
  994. //{
  995. // returnErrorMsg("补差价单不能标记微信单");
  996. // return;
  997. //}
  998. entity.wechatTag = tag;
  999. entity.Update();
  1000. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1001. if (tag == 1)
  1002. {
  1003. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1004. if (cash == null)
  1005. {
  1006. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1007. cash = new CeErpReturnCash();
  1008. cash.tid = entity.tid;
  1009. cash.seller_nick = main.seller_nick;
  1010. cash.payment = trade.payment;
  1011. cash.buyer_nick = main.buyer_nick;
  1012. cash.cashstate = 0;
  1013. cash.rtype = "微信返现";
  1014. cash.returnprice = 0;
  1015. cash.created = DateTime.Now;
  1016. cash.con = "订单标记微信单";
  1017. cash.img = "";
  1018. cash.applyuserid = CurrentUser.UserID;
  1019. cash.Create();
  1020. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1021. }
  1022. else
  1023. {
  1024. cash.cashstate = 0;
  1025. cash.Update();
  1026. }
  1027. CeErpSukuraData.createInfo(entity.ctid, 9);
  1028. }
  1029. else if (tag == 2)
  1030. {
  1031. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1032. if (cash == null)
  1033. {
  1034. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1035. cash = new CeErpReturnCash();
  1036. cash.tid = entity.tid;
  1037. cash.seller_nick = main.seller_nick;
  1038. cash.payment = trade.payment;
  1039. cash.buyer_nick = main.buyer_nick;
  1040. cash.cashstate = 0;
  1041. cash.rtype = "推购返现";
  1042. cash.returnprice = 5;
  1043. cash.created = DateTime.Now;
  1044. cash.con = "订单标记推购单";
  1045. cash.img = "";
  1046. cash.applyuserid = CurrentUser.UserID;
  1047. cash.Create();
  1048. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1049. }
  1050. else
  1051. {
  1052. cash.cashstate = 0;
  1053. cash.Update();
  1054. }
  1055. CeErpSukuraData.createInfo(entity.ctid, 9);
  1056. }
  1057. else if (tag == 3)
  1058. {
  1059. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1060. if (pers == null)
  1061. {
  1062. pers = new CeErpPersuade();
  1063. pers.ctid = entity.ctid;
  1064. pers.pstate = 0;
  1065. pers.created = DateTime.Now;
  1066. pers.applyuserid = CurrentUser.UserID;
  1067. pers.Create();
  1068. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1069. }
  1070. else
  1071. {
  1072. pers.pstate = 0;
  1073. pers.Update();
  1074. }
  1075. }
  1076. else if (tag == 4 || tag == 5)
  1077. {
  1078. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1079. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1080. if (pers == null)
  1081. {
  1082. pers = new CeErpStayGoods();
  1083. pers.t_id = entity.tid;
  1084. pers.status = "待审核";
  1085. pers.audit_type = 0;
  1086. if (tag == 4)
  1087. {
  1088. pers.stay_type = "微信推购";
  1089. }
  1090. else
  1091. {
  1092. pers.stay_type = "旺旺推购";
  1093. }
  1094. if (entity.IsXianHuo == 0)
  1095. {
  1096. pers.product_id = entity.ProductId;
  1097. }
  1098. pers.wangwang = main.buyer_nick;
  1099. pers.shop_name = main.seller_nick;
  1100. pers.creata_time = DateTime.Now;
  1101. pers.create_u_id = CurrentUser.UserID;
  1102. pers.create_u_name = CurrentUser.UserName;
  1103. pers.Create();
  1104. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1105. }
  1106. else
  1107. {
  1108. pers.audit_type = 0;
  1109. pers.Update();
  1110. }
  1111. CeErpSukuraData.createInfo(entity.ctid, 10);
  1112. }
  1113. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1114. returnSuccessMsg("标记成功!");
  1115. return;
  1116. }
  1117. returnErrorMsg("找不到记录");
  1118. }
  1119. }
  1120. public void upd_erp_ordertag_cancel()
  1121. {
  1122. if (UrlPostParmsCheck("ctid"))
  1123. {
  1124. string eid = GetPostString("ctid");
  1125. CeErpTradeCell entity = null;
  1126. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1127. if (entity != null)
  1128. {
  1129. entity.wechatTag = 0;
  1130. entity.Update();
  1131. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1132. if (pers != null)
  1133. {
  1134. pers.status = "取消推购";
  1135. pers.audit_type = 3;
  1136. pers.Update();
  1137. }
  1138. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1139. returnSuccessMsg("标记成功!");
  1140. return;
  1141. }
  1142. returnErrorMsg("找不到记录");
  1143. }
  1144. }
  1145. public void upd_erp_addweichattag()
  1146. {
  1147. if (UrlPostParmsCheck("ctid"))
  1148. {
  1149. ;
  1150. string eid = GetPostString("ctid");
  1151. CeErpTradeCell entity = null;
  1152. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1153. if (entity != null)
  1154. {
  1155. if (entity.IsAddWechat > 0)
  1156. {
  1157. returnErrorMsg("此单已经标记过了");
  1158. return;
  1159. }
  1160. 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);
  1161. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1162. if (dt.Rows.Count > 0)
  1163. {
  1164. entity.IsAddWechat = 2;
  1165. }
  1166. else
  1167. {
  1168. entity.IsAddWechat = 1;
  1169. }
  1170. entity.Update();
  1171. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1172. returnSuccessMsg("标记成功!");
  1173. return;
  1174. }
  1175. returnErrorMsg("找不到记录");
  1176. }
  1177. }
  1178. public void upd_erp_getmyorder()
  1179. {
  1180. if (UrlPostParmsCheck("ctid"))
  1181. {
  1182. ;
  1183. string eid = GetPostString("ctid");
  1184. CeErpTradeCell entity = null;
  1185. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1186. if (entity != null)
  1187. {
  1188. if (entity.ctid.IndexOf("C") != -1)
  1189. {
  1190. StringBuilder sql = new StringBuilder();
  1191. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1192. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1193. if (dt.Rows.Count > 0)
  1194. {
  1195. decimal total = 0;
  1196. foreach (DataRow dr in dt.Rows)
  1197. {
  1198. total += Convert.ToDecimal(dr["payment"]);
  1199. }
  1200. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1201. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1202. {
  1203. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1204. return;
  1205. }
  1206. }
  1207. }
  1208. entity.CustomerUserId = CurrentUser.UserID;
  1209. if (entity.OrderState < 2)
  1210. {
  1211. entity.OrderState = 2;
  1212. if (entity.ShopId != 0)
  1213. {
  1214. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1215. }
  1216. }
  1217. entity.Update();
  1218. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1219. returnSuccessMsg("领单成功!");
  1220. return;
  1221. }
  1222. returnErrorMsg("找不到记录");
  1223. }
  1224. }
  1225. public void getmyorder_from_init()
  1226. {
  1227. if (UrlPostParmsCheck("ctid"))
  1228. {
  1229. string eid = GetPostString("ctid");
  1230. CeErpTradeCell entity = null;
  1231. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1232. if (entity != null)
  1233. {
  1234. string sellerMemo = GetPostString("sellerMemo");
  1235. if (sellerMemo.Length > 0)
  1236. {
  1237. entity.seller_memo = sellerMemo;
  1238. }
  1239. string oterhMemo = GetPostString("otherMemo");
  1240. if (oterhMemo.Length > 0)
  1241. {
  1242. entity.OtherMemo = oterhMemo;
  1243. }
  1244. int urg = GetPostInt("urgency");
  1245. entity.IsUrgency = (urg == 1 ? true : false);
  1246. int wechat = GetPostInt("wechat");
  1247. int command = GetPostInt("command");
  1248. if (wechat == 1)
  1249. {
  1250. entity.wechatTag = 1;
  1251. }
  1252. if (command == 1)
  1253. {
  1254. entity.wechatTag = 2;
  1255. }
  1256. string pPro = GetPostString("pprofession");
  1257. if (pPro.Length > 0)
  1258. {
  1259. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1260. string spro = GetPostString("profession");
  1261. if (spro.Length > 0)
  1262. {
  1263. entity.ProfessionId = Convert.ToInt32(spro);
  1264. }
  1265. }
  1266. string proId = GetPostString("productId");
  1267. if (proId.Length > 0)
  1268. {
  1269. entity.ProductId = Convert.ToInt32(proId);
  1270. }
  1271. entity.Material = GetPostString("material");
  1272. entity.Craft = GetPostString("craft");
  1273. entity.CustomerUserId = CurrentUser.UserID;
  1274. if (entity.OrderState < 2)
  1275. {
  1276. entity.OrderState = 2;
  1277. if (entity.ShopId != 0)
  1278. {
  1279. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1280. }
  1281. }
  1282. entity.Update();
  1283. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1284. returnSuccessMsg("领单成功!");
  1285. return;
  1286. }
  1287. returnErrorMsg("找不到记录");
  1288. }
  1289. }
  1290. public void upd_erp_setrelationorder()
  1291. {
  1292. if (UrlPostParmsCheck("ctid"))
  1293. {
  1294. ;
  1295. string eid = GetPostString("ctid");
  1296. string ftid = GetPostString("ftid");
  1297. CeErpTradeCell entity = null;
  1298. CeErpTradeCell fentity = null;
  1299. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1300. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1301. if (fentity == null)
  1302. {
  1303. returnErrorMsg("找不到关联的主订单");
  1304. return;
  1305. }
  1306. if (entity != null)
  1307. {
  1308. if (entity.OrderState >= 5)
  1309. {
  1310. returnErrorMsg("本单已经设计完成无法关联");
  1311. return;
  1312. }
  1313. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1314. {
  1315. returnErrorMsg("线下单续审核后才能关联!");
  1316. return;
  1317. }
  1318. entity.ptid = ftid;
  1319. entity.OrderState = fentity.OrderState;
  1320. //entity.status = fentity.status;
  1321. entity.CustomerUserId = fentity.CustomerUserId;
  1322. entity.DesignUserId = fentity.DesignUserId;
  1323. entity.seller_memo = "补差价单:" + ftid;
  1324. entity.IsSample = 2;
  1325. entity.Update();
  1326. ApiVo apiVo = new ApiVo();
  1327. apiVo.orderNumber = ftid;
  1328. apiVo.payment = entity.payment;
  1329. apiVo.actionName = "repairDesign";
  1330. designHelper.API_WorkCore(apiVo);//repairDesign
  1331. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1332. returnSuccessMsg("关联成功!");
  1333. return;
  1334. }
  1335. else
  1336. returnErrorMsg("找不到记录");
  1337. }
  1338. }
  1339. public void download_erp_neworder()
  1340. {
  1341. string seller = GetPostString("seller_nick");
  1342. string tid = GetPostString("tid");
  1343. if (seller.Length <= 0 || tid.Length <= 0)
  1344. {
  1345. returnErrorMsg("数据错误");
  1346. }
  1347. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1348. //{
  1349. // returnErrorMsg("找不到店铺Sessionkey");
  1350. //}
  1351. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1352. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1353. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1354. if (res.IndexOf("refOid") == -1)
  1355. {
  1356. returnErrorMsg("下载订单数据失败");
  1357. return;
  1358. }
  1359. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1360. returnSuccessMsg("下载完成");
  1361. //tmcHelper.createNewOrder(res);
  1362. //CeErpTrade entr = null;
  1363. //entr = CeErpTrade.Get(tid);
  1364. //if (entr != null)
  1365. //{
  1366. // returnSuccess("下载成功");
  1367. // //下载成功之后,Cell表生成对应的订单;
  1368. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1369. //}
  1370. //else
  1371. //{
  1372. // returnErrorMsg("下载失败或者创建订单失败");
  1373. //}
  1374. }
  1375. public void set_erp_atersale()
  1376. {
  1377. if (UrlPostParmsCheck("ctid"))
  1378. {
  1379. string eid = GetPostString("ctid");
  1380. string reason = GetPostString("AfterSaleReason");
  1381. CeErpTradeCell entity = null;
  1382. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1383. if (entity != null)
  1384. {
  1385. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1386. {
  1387. returnErrorMsg("此订单已经在售后");
  1388. return;
  1389. }
  1390. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1391. //entity.AfterSaleReason = reason;
  1392. entity.AfterSaleTime = DateTime.Now;
  1393. entity.Update();
  1394. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1395. returnSuccessMsg("转售后成功!");
  1396. return;
  1397. }
  1398. returnErrorMsg("找不到记录");
  1399. }
  1400. }
  1401. public void set_erp_withdraw()
  1402. {
  1403. if (UrlPostParmsCheck("ctid"))
  1404. {
  1405. try
  1406. {
  1407. string eid = GetPostString("ctid");//商品id
  1408. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1409. CeWithdraw ceWithdrawSelect = null;
  1410. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1411. if (ceWithdrawSelect != null)
  1412. {
  1413. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1414. {
  1415. ceWithdrawSelect.status = -1;
  1416. ceWithdrawSelect.Update();
  1417. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1418. returnSuccessMsg("重新发起审核成功");
  1419. return;
  1420. }
  1421. else
  1422. {
  1423. returnSuccessMsg("请勿重复申请!");
  1424. return;
  1425. }
  1426. }
  1427. else
  1428. {
  1429. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1430. if (string.IsNullOrEmpty(CustomerUserId))
  1431. {
  1432. CustomerUserId = "-1";
  1433. }
  1434. int Userid = CurrentUser.UserID;//用户id
  1435. CeWithdraw ceWithdraw = new CeWithdraw();
  1436. ceWithdraw.tid = eid;
  1437. ceWithdraw.userid = Userid;
  1438. ceWithdraw.providerid = CustomerUserId;
  1439. ceWithdraw.status = 3;
  1440. ceWithdraw.creationtime = DateTime.Now;
  1441. ceWithdraw.Create();
  1442. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1443. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1444. return;
  1445. }
  1446. }
  1447. catch
  1448. {
  1449. returnErrorMsg("申请撤回订单失败");
  1450. return;
  1451. }
  1452. }
  1453. }
  1454. public void ins_erp_billinfo()
  1455. {
  1456. if (UrlPostParmsCheck("ctid"))
  1457. {
  1458. string eid = GetPostString("ctid");
  1459. CeErpTradeCell entity = null;
  1460. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1461. if (entity != null)
  1462. {
  1463. CeErpBill bill = CeErpBill.GetByTid(eid);
  1464. bool isHave = false;
  1465. if (bill != null)
  1466. {
  1467. isHave = true;
  1468. if (bill.state != 4)
  1469. {
  1470. returnErrorMsg("此单已经申请过发票了");
  1471. return;
  1472. }
  1473. }
  1474. if (entity.IsNeedBill == 0)
  1475. {
  1476. entity.IsNeedBill = 1;
  1477. }
  1478. entity.Update();
  1479. string errjson = "";
  1480. try
  1481. {
  1482. CeErpBill bill_entity = new CeErpBill();
  1483. bill_entity.tid = entity.tid;
  1484. bill_entity.title = GetPostString("title");
  1485. string taxstr = GetPostString("tax");
  1486. taxstr = taxstr.Replace(" ", "");
  1487. bill_entity.tax = taxstr;
  1488. bill_entity.bank = GetPostString("bank");
  1489. string bankacstr = GetPostString("bankac");
  1490. bankacstr = bankacstr.Replace(" ", "");
  1491. bill_entity.bankac = bankacstr;
  1492. bill_entity.address = GetPostString("address");
  1493. bill_entity.phone = GetPostString("phone");
  1494. bill_entity.price = GetPostString("price");
  1495. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1496. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1497. {
  1498. billCount += 1;
  1499. }
  1500. string prebill = "ltb";
  1501. for (int idx = 1; idx <= billCount; idx++)
  1502. {
  1503. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1504. string billoid = prebill + idx + dtstr;
  1505. bill_entity.billOrderId += billoid;
  1506. if (idx < billCount)
  1507. {
  1508. bill_entity.billOrderId += ",";
  1509. }
  1510. }
  1511. bill_entity.productId = GetPostInt("ProductName");
  1512. bill_entity.num = GetPostInt("num");
  1513. bill_entity.unit = GetPostString("unit");
  1514. bill_entity.type = GetPostString("type");
  1515. bill_entity.sendType = GetPostString("SendType");
  1516. bill_entity.email = GetPostString("email");
  1517. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1518. bill_entity.shopName = GetPostString("ShopName");
  1519. bill_entity.applymemo = GetPostString("applyMemo");
  1520. bill_entity.createTime = DateTime.Now;
  1521. bill_entity.state = 0;
  1522. bill_entity.userId = CurrentUser.UserID;
  1523. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1524. bill_entity.Create();
  1525. }
  1526. catch (Exception ex)
  1527. {
  1528. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1529. returnErrorMsg("创建发票出错!");
  1530. return;
  1531. }
  1532. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1533. returnSuccessMsg("发票申请成功!");
  1534. return;
  1535. }
  1536. returnErrorMsg("找不到记录");
  1537. }
  1538. }
  1539. public void ins_erp_neworder()
  1540. {
  1541. if (UrlPostParmsCheck("receiver_name"))
  1542. {
  1543. CeErpTrade entity = new CeErpTrade();
  1544. string plat_form = GetPostString("platform");
  1545. string preStr = "N_";
  1546. if (plat_form == "拼多多")
  1547. {
  1548. preStr = "P_";
  1549. }
  1550. else if (plat_form == "阿里巴巴")
  1551. {
  1552. preStr = "A_";
  1553. }
  1554. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1555. entity.seller_nick = GetPostString("seller_nick");
  1556. entity.buyer_nick = GetPostString("buyer_nick");
  1557. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1558. entity.total_fee = entity.payment;
  1559. entity.pay_time = DateTime.Now;
  1560. entity.status = "NOT_SHIPPED";
  1561. entity.receiver_name = GetPostString("receiver_name");
  1562. entity.receiver_mobile = GetPostString("receiver_mobile");
  1563. entity.receiver_state = GetPostString("receiver_state");
  1564. entity.receiver_city = GetPostString("receiver_city");
  1565. entity.receiver_district = GetPostString("receiver_district");
  1566. entity.receiver_address = GetPostString("receiver_address");
  1567. if (entity.receiver_state == "" || entity.receiver_city == "")
  1568. {
  1569. returnErrorMsg("收件地址不能为空");
  1570. return;
  1571. }
  1572. int shopId = 0;
  1573. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1574. if (nShop != null)
  1575. {
  1576. shopId = nShop.ID;
  1577. }
  1578. if (shopId != 34 && entity.payment == 0)
  1579. {
  1580. returnErrorMsg("公司自用的单金额才能为0");
  1581. return;
  1582. }
  1583. entity.Create();
  1584. CeErpTradeCell entitycell = new CeErpTradeCell();
  1585. entitycell.ctid = entity.tid;
  1586. entitycell.tid = entity.tid;
  1587. entitycell.ShopId = shopId;
  1588. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1589. entitycell.OrderState = 0;
  1590. entitycell.pay_time = entity.pay_time;
  1591. entitycell.IsOffLineOrder = 1;
  1592. entitycell.Create();
  1593. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1594. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1595. return;
  1596. }
  1597. }
  1598. public void ins_erp_neworder2()
  1599. {
  1600. if (UrlPostParmsCheck("receiver_name"))
  1601. {
  1602. //string plat_form = GetPostString("platform");
  1603. string preStr = "X_";
  1604. string memo = GetPostString("memo");
  1605. string productId = GetPostString("productId");
  1606. string primg = GetPostString("proofimg");
  1607. string sellerNick = GetPostString("seller_nick");
  1608. string addFrom = GetPostString("addfrom");
  1609. if (addFrom == "1")
  1610. {
  1611. preStr = "N_";
  1612. }
  1613. int shopId = 0;
  1614. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1615. if (nShop != null)
  1616. {
  1617. shopId = nShop.ID;
  1618. }
  1619. else
  1620. {
  1621. returnErrorMsg("找不到对应店铺");
  1622. return;
  1623. }
  1624. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1625. {
  1626. returnErrorMsg("必须上传付款凭证");
  1627. return;
  1628. }
  1629. CeErpTrade entity = new CeErpTrade();
  1630. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1631. entity.seller_nick = sellerNick;
  1632. entity.buyer_nick = GetPostString("buyer_nick");
  1633. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1634. entity.total_fee = entity.payment;
  1635. entity.pay_time = DateTime.Now;
  1636. entity.status = "NOT_SHIPPED";
  1637. entity.receiver_name = GetPostString("receiver_name");
  1638. entity.receiver_mobile = GetPostString("receiver_mobile");
  1639. entity.receiver_state = GetPostString("receiver_state");
  1640. entity.receiver_city = GetPostString("receiver_city");
  1641. entity.receiver_district = GetPostString("receiver_district");
  1642. entity.receiver_address = GetPostString("receiver_address");
  1643. entity.seller_memo = memo;
  1644. entity.orderFrom = 20;
  1645. entity.orderType = 15;
  1646. if (entity.receiver_state == "" || entity.receiver_city == "")
  1647. {
  1648. returnErrorMsg("收件地址不能为空");
  1649. return;
  1650. }
  1651. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1652. {
  1653. returnErrorMsg("公司自用的单金额才能为0");
  1654. return;
  1655. }
  1656. entity.Create();
  1657. string toWhere = GetPostString("towhere");
  1658. CeErpTradeCell entitycell = new CeErpTradeCell();
  1659. entitycell.ctid = entity.tid;
  1660. //唯一标识
  1661. entitycell.OrderSn = entity.tid;
  1662. //string orderSn = dataHelper.getSaleOrderSn();
  1663. //if (orderSn != "")
  1664. // {
  1665. // entitycell.OrderSn = orderSn;
  1666. // }
  1667. entitycell.tid = entity.tid;
  1668. //if (preStr == "X_")
  1669. //{
  1670. entitycell.IsOffLineOrder = 1;
  1671. //}
  1672. entitycell.CustomerUserId = CurrentUser.UserID;
  1673. entitycell.PayProofImg = primg;
  1674. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1675. entitycell.ProductId = Convert.ToInt32(productId);
  1676. entitycell.ShopId = shopId;
  1677. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1678. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1679. {
  1680. entitycell.IsXianHuo = 1;
  1681. }
  1682. entitycell.pay_time = entity.pay_time;
  1683. if (toWhere == "1")
  1684. {
  1685. entitycell.OrderState = 2;
  1686. }
  1687. else
  1688. {
  1689. entitycell.OrderState = 6;
  1690. entitycell.FinishPlaceTime = entitycell.pay_time;
  1691. }
  1692. if (shopId == 94)
  1693. {
  1694. entitycell.OrderState = 4;
  1695. entitycell.WaitDesignTime = entitycell.pay_time;
  1696. entitycell.StartDesignTime = entitycell.pay_time;
  1697. entitycell.DesignUserId = 218;
  1698. }
  1699. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1700. {
  1701. entitycell.OrderState = -1;//修改12-5
  1702. CeWithdraw ceWithdraw = new CeWithdraw();
  1703. ceWithdraw.tid = entity.tid;
  1704. ceWithdraw.providerid = "-1";
  1705. ceWithdraw.status = -1;
  1706. ceWithdraw.creationtime = DateTime.Now;
  1707. ceWithdraw.userid = 1337;
  1708. ceWithdraw.Create();
  1709. }
  1710. entitycell.Create();
  1711. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1712. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1713. {
  1714. addPlaceRegist(entitycell, CurrentUser.UserID);
  1715. }
  1716. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1717. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1718. return;
  1719. }
  1720. }
  1721. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1722. {
  1723. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1724. entity.PlactTime = tradecell.pay_time;
  1725. entity.AddUserId = userid;
  1726. entity.FileName = tradecell.seller_memo;
  1727. entity.Supplier = 24;
  1728. entity.CreateTime = DateTime.Now;
  1729. entity.Did = tradecell.ctid;
  1730. entity.tid = tradecell.tid;
  1731. entity.splitTag = tradecell.SplitTag;
  1732. entity.CurState = "未完成";
  1733. entity.Create();
  1734. }
  1735. public void get_erp_offlinelist()
  1736. {
  1737. DataStruct dStruct = GetPostStruct();
  1738. List<string> lw = new List<string>();
  1739. string tid = GetPostString("ctid");
  1740. string date1 = GetPostString("date1");
  1741. string date2 = GetPostString("date2");
  1742. if (tid.Length > 0 || date1.Length > 0)
  1743. {
  1744. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1745. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1746. if (dw.Length > 0) lw.Add(dw);
  1747. }
  1748. else
  1749. {
  1750. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1751. }
  1752. string shopname = GetPostString("shopname");
  1753. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1754. string buyernick = GetPostString("buyer_nick");
  1755. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1756. string customer = GetPostString("customer");
  1757. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1758. string design = GetPostString("design");
  1759. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1760. string orderState = GetPostString("orderState");
  1761. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1762. string address = GetPostString("address");
  1763. 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));
  1764. string sellermemo = GetPostString("seller_memo");
  1765. if (sellermemo.Length > 0)
  1766. {
  1767. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1768. }
  1769. string price1 = GetPostString("price1");
  1770. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1771. string price2 = GetPostString("price2");
  1772. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1773. //if (PKey != "admin")
  1774. //{
  1775. // string usershop = CurrentUser.User.pemShop;
  1776. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1777. //}
  1778. //if (ex_psize > 0)
  1779. //{
  1780. dStruct.Order = "pay_time desc";
  1781. //}
  1782. //else
  1783. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1784. lw.Add(string.Format("IsOffLineOrder=1"));
  1785. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1786. DataTable dt = null;
  1787. dt = WebCache.GetData("view_erptradecell", dStruct);
  1788. writeGridDataTableJson(dStruct.TotalCount, dt);
  1789. }
  1790. public void get_erp_returncashrecord()
  1791. {
  1792. DataStruct dStruct = GetPostStruct();
  1793. List<string> lw = new List<string>();
  1794. string tid = GetPostString("ctid");
  1795. if (tid.Length > 0)
  1796. {
  1797. lw.Add(string.Format("tid like '%{0}%'", tid));
  1798. dStruct.Order = "id desc";
  1799. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1800. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1801. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1802. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1803. return;
  1804. }
  1805. returnErrorMsg("id数据错误!");
  1806. }
  1807. public void ins_erp_returncashrecord()
  1808. {
  1809. if (UrlPostParmsCheck("tid"))
  1810. {
  1811. string tid = GetPostString("tid");
  1812. string retype = GetPostString("type");
  1813. StringBuilder sql = new StringBuilder();
  1814. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1815. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1816. if (dt.Rows.Count > 0)
  1817. {
  1818. returnErrorMsg("相同返现类型记录已存在");
  1819. return;
  1820. }
  1821. CeErpReturnCash entity = new CeErpReturnCash();
  1822. entity.tid = tid;
  1823. entity.seller_nick = GetPostString("seller_nick");
  1824. string pment = GetPostString("payment");
  1825. if (pment.Length > 0)
  1826. {
  1827. entity.payment = Convert.ToDouble(pment);
  1828. }
  1829. entity.buyer_nick = GetPostString("buyer_nick");
  1830. entity.cashstate = 0;
  1831. entity.rtype = retype;
  1832. string rPrice = GetPostString("returnprice");
  1833. if (rPrice.Length > 0)
  1834. {
  1835. entity.returnprice = Convert.ToDouble(rPrice);
  1836. }
  1837. entity.created = DateTime.Now;
  1838. entity.con = GetPostString("con");
  1839. entity.img = GetPostString("img");
  1840. entity.applyuserid = CurrentUser.UserID;
  1841. entity.Create();
  1842. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1843. returnSuccessMsg("操作成功!");
  1844. return;
  1845. }
  1846. }
  1847. public void set_erp_predelivery()
  1848. {
  1849. if (UrlPostParmsCheck("ctid"))
  1850. {
  1851. string eid = GetPostString("ctid");
  1852. CeErpTradeCell entity = null;
  1853. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1854. if (entity != null)
  1855. {
  1856. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1857. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1858. //{
  1859. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1860. // return;
  1861. //}
  1862. entity.IsPreDelivery = 1;
  1863. entity.Update();
  1864. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1865. returnSuccessMsg("预发货成功!");
  1866. return;
  1867. //string shop = GetPostString("seller_nick");
  1868. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1869. //string comName = GetPostString("comName");
  1870. //string comCode = GetPostString("comCode");
  1871. //string outSid = GetPostString("outSid");//运单号
  1872. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1873. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1874. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1875. //string apires = "";
  1876. //if (deliveryType == "虚拟发货")
  1877. //{
  1878. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1879. //}
  1880. //else
  1881. //{
  1882. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1883. //}
  1884. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1885. ////{
  1886. //if (apires.IndexOf("发货成功") != -1)
  1887. //{
  1888. // if (deliveryType != "虚拟发货")
  1889. // {
  1890. // //还要插入快递信息到 快递信息表
  1891. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1892. // exinfo.tid = eid;
  1893. // exinfo.out_sid = outSid;
  1894. // exinfo.company_code = comCode;
  1895. // exinfo.company_name = comName;
  1896. // exinfo.delivery_memo = deliveryMemo;
  1897. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1898. // exinfo.deliveryType = deliveryType;
  1899. // exinfo.Create();
  1900. // }
  1901. // returnSuccessMsg("发货成功!");
  1902. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1903. //}
  1904. //else
  1905. //{
  1906. // returnErrorMsg("淘宝发货失败!!");
  1907. //}
  1908. //return;
  1909. }
  1910. returnErrorMsg("找不到订单记录");
  1911. }
  1912. }
  1913. public void get_erp_unusuallist()
  1914. {
  1915. DataStruct dStruct = GetPostStruct();
  1916. List<string> lw = new List<string>();
  1917. string tid = GetPostString("ctid");
  1918. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1919. string shopname = GetPostString("shopname");
  1920. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1921. string buyernick = GetPostString("buyer_nick");
  1922. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1923. string ResponsibleMan = GetPostString("responsible");
  1924. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1925. string date1 = GetPostString("date1");
  1926. string date2 = GetPostString("date2");
  1927. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1928. if (dw.Length > 0) lw.Add(dw);
  1929. string price1 = GetPostString("price1");
  1930. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1931. string price2 = GetPostString("price2");
  1932. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1933. string orderState = GetPostString("orderState");
  1934. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1935. string sellermemo = GetPostString("seller_memo");
  1936. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1937. lw.Add(string.Format("UnusualTag > 0"));
  1938. lw.Add(string.Format("IsRefund<={0}", 1));
  1939. dStruct.Order = "pay_time desc";
  1940. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1941. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1942. writeGridDataTableJson(dStruct.TotalCount, dt);
  1943. }
  1944. public void set_erp_unusualtonomal()
  1945. {
  1946. if (UrlPostParmsCheck("ctid"))
  1947. {
  1948. string eid = GetPostString("ctid");
  1949. CeErpTradeCell entity = null;
  1950. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1951. if (entity != null)
  1952. {
  1953. entity.UnusualTag = -1;
  1954. entity.Update();
  1955. returnSuccessMsg("忽略成功!");
  1956. return;
  1957. }
  1958. returnErrorMsg("找不到记录");
  1959. }
  1960. }
  1961. public void ins_erp_unusualreason()
  1962. {
  1963. if (UrlPostParmsCheck("ctid"))
  1964. {
  1965. string eid = GetPostString("ctid");
  1966. CeErpTradeCell entity = null;
  1967. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1968. if (entity != null)
  1969. {
  1970. entity.MemoOpt = 4;
  1971. entity.UnusualCon = GetPostString("con");
  1972. entity.Update();
  1973. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1974. if (trade != null)
  1975. {
  1976. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1977. }
  1978. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1979. returnSuccessMsg("操作成功!");
  1980. return;
  1981. }
  1982. returnErrorMsg("找不到记录");
  1983. }
  1984. }
  1985. public void upd_erp_sampleorder()
  1986. {
  1987. if (UrlPostParmsCheck("ctid"))
  1988. {
  1989. string eid = GetPostString("ctid");
  1990. string[] eArr = eid.Split(',');
  1991. if (eArr.Length > 1)
  1992. {
  1993. List<string> eLst = new List<string>();
  1994. for (int i = 0; i < eArr.Length; i++)
  1995. {
  1996. eLst.Add("'" + eArr[i] + "'");
  1997. }
  1998. eid = string.Join(",", eLst.ToArray());
  1999. }
  2000. else
  2001. {
  2002. eid = "'" + eid + "'";
  2003. }
  2004. StringBuilder sql = new StringBuilder();
  2005. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2006. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2007. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2008. if (dt.Rows.Count > 0)
  2009. {
  2010. string errmsg = "";
  2011. foreach (DataRow dr in dt.Rows)
  2012. {
  2013. StringBuilder sqlsb = new StringBuilder();
  2014. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2015. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2016. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2017. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2018. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2019. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2020. {
  2021. continue;
  2022. }
  2023. else
  2024. {
  2025. string emsg = commonHelper.KeepChinese(apires);
  2026. errmsg += emsg;
  2027. }
  2028. }
  2029. if (errmsg.Length > 0)
  2030. {
  2031. returnErrorMsg(errmsg);
  2032. return;
  2033. }
  2034. returnSuccessMsg("操作成功");
  2035. return;
  2036. }
  2037. returnErrorMsg("找不到记录");
  2038. }
  2039. }
  2040. public void upd_erp_transcustomer()
  2041. {
  2042. if (UrlPostParmsCheck("ctid"))
  2043. {
  2044. string eid = GetPostString("ctid");
  2045. int userid = GetPostInt("CustomerUserId");
  2046. CeErpTradeCell entity = null;
  2047. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2048. if (entity != null)
  2049. {
  2050. //string[] mlist = entity.seller_memo.Split('-');
  2051. //string sql = "select * from view_erpuser where id=" + userid;
  2052. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2053. //if (dt != null && dt.Rows.Count > 0)
  2054. //{
  2055. // string nmemo = "";
  2056. // for(int i = 0; i < mlist.Length - 1; i++)
  2057. // {
  2058. // nmemo += mlist[i];
  2059. // nmemo += "-";
  2060. // }
  2061. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2062. // entity.seller_memo = nmemo;
  2063. //}
  2064. entity.CustomerUserId = userid;
  2065. entity.Update();
  2066. returnSuccessMsg("操作成功!");
  2067. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2068. return;
  2069. }
  2070. returnErrorMsg("找不到记录");
  2071. }
  2072. }
  2073. public void upd_erp_transdesigner()
  2074. {
  2075. if (UrlPostParmsCheck("ctid"))
  2076. {
  2077. string eids = GetPostString("ctid");
  2078. string[] ctidList = eids.Split(',');
  2079. int userid = GetPostInt("DesignUserId");
  2080. foreach (string ctid in ctidList)
  2081. {
  2082. CeErpTradeCell entity = null;
  2083. CeErpDesignerBill entitys = null;
  2084. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2085. entitys = CeErpDesignerBill.GetByTid(ctid);
  2086. if (entity != null)
  2087. {
  2088. if (entity.OrderState > 4)
  2089. {
  2090. continue;
  2091. }
  2092. //存在退款不能流转
  2093. if (entity.IsRefund > 0)
  2094. {
  2095. continue;
  2096. }
  2097. entity.DesignUserId = userid;
  2098. entity.WaitDesignTime = DateTime.Now;
  2099. entity.Update();
  2100. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2101. }
  2102. }
  2103. returnSuccessMsg("操作成功!");
  2104. }
  2105. }
  2106. public void upd_erp_distributedesigner()
  2107. {
  2108. if (UrlPostParmsCheck("ctid"))
  2109. {
  2110. string eid = GetPostString("ctid");
  2111. int userid = GetPostInt("DesignUserId");
  2112. string[] idlist = eid.Split(',');
  2113. if (idlist.Length <= 0)
  2114. {
  2115. returnErrorMsg("订单不能为空");
  2116. return;
  2117. }
  2118. foreach (string ctid in idlist)
  2119. {
  2120. CeErpTradeCell entity = null;
  2121. CeErpDesignerBill entitys = null;
  2122. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2123. else continue;
  2124. if (entity != null)
  2125. {
  2126. if (userid == 2125 || userid == 3542)
  2127. { }
  2128. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2129. {
  2130. returnErrorMsg("金额错误的订单无法指派");
  2131. return;
  2132. }
  2133. if (entity.OrderState >= 5)
  2134. {
  2135. returnErrorMsg("已经设计完成无法指派");
  2136. return;
  2137. }
  2138. if (entity.OrderState == -1)
  2139. {
  2140. returnErrorMsg("审核中的订单无法指派");
  2141. return;
  2142. }
  2143. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2144. {
  2145. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2146. return;
  2147. }
  2148. if (entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize")
  2149. {
  2150. returnErrorMsg("指派设计共创无法再次指派!");
  2151. return;
  2152. }
  2153. entity.OrderState = 3;
  2154. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2155. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2156. {
  2157. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2158. entity.SupplierId = suid;
  2159. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2160. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2161. }
  2162. if (userid == 2125 && entity.seller_memo != "")
  2163. {
  2164. apiDesign.API_GetPrintData_CreateOrder(entity);
  2165. }
  2166. if (userid == 3542 && entity.seller_memo != "")
  2167. {
  2168. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2169. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2170. if (response.msg != "设计共创:成功")
  2171. {
  2172. returnErrorMsg(response.msg);
  2173. return;
  2174. }
  2175. entity.DispatchSort = 2;
  2176. entity.OrderState = 3;
  2177. }
  2178. entity.DesignUserId = userid;
  2179. entity.WaitDesignTime = DateTime.Now;
  2180. entity.Update();
  2181. string name = commonHelper.getUserNameById(userid);
  2182. commonHelper.UpdateRelationOrder(entity.ctid);
  2183. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2184. }
  2185. }
  2186. returnSuccessMsg("操作成功!");
  2187. return;
  2188. }
  2189. }
  2190. public void get_erp_myorderlist()
  2191. {
  2192. DataStruct dStruct = GetPostStruct();
  2193. List<string> lw = new List<string>();
  2194. string tid = GetPostString("ctid");
  2195. if (tid.Length > 0)
  2196. {
  2197. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2198. }
  2199. else
  2200. {
  2201. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2202. }
  2203. //12-1 修改
  2204. string urgent = GetPostString("urgent");
  2205. string back = GetPostString("back");
  2206. string offlineSearch = GetPostString("offlineSearch");
  2207. if (!string.IsNullOrWhiteSpace(urgent))
  2208. {
  2209. if (urgent.Equals("true"))
  2210. {
  2211. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2212. }
  2213. }
  2214. if (!string.IsNullOrWhiteSpace(back))
  2215. {
  2216. if (back.Equals("true"))
  2217. {
  2218. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2219. }
  2220. }
  2221. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2222. {
  2223. if (offlineSearch.Equals("true"))
  2224. {
  2225. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2226. }
  2227. }
  2228. //end
  2229. string shopname = GetPostString("shopname");
  2230. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2231. string buyernick = GetPostString("buyer_nick");
  2232. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2233. string design = GetPostString("design");
  2234. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2235. string orderState = GetPostString("orderState");
  2236. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2237. string sellermemo = GetPostString("seller_memo");
  2238. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2239. string date1 = GetPostString("date1");
  2240. string date2 = GetPostString("date2");
  2241. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2242. if (dw.Length > 0) lw.Add(dw);
  2243. string price1 = GetPostString("price1");
  2244. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2245. string price2 = GetPostString("price2");
  2246. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2247. string urgency = GetPostString("urgency");
  2248. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2249. string after = GetPostString("after");
  2250. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2251. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2252. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2253. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2254. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2255. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2256. writeGridDataTableJson(dStruct.TotalCount, dt);
  2257. }
  2258. public void get_erp_myreturnorderlist()
  2259. {
  2260. DataStruct dStruct = GetPostStruct();
  2261. List<string> lw = new List<string>();
  2262. string tid = GetPostString("ctid");
  2263. if (tid.Length > 0)
  2264. {
  2265. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  2266. }
  2267. else
  2268. {
  2269. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2270. }
  2271. string shopname = GetPostString("shopname");
  2272. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2273. string buyernick = GetPostString("buyer_nick");
  2274. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2275. string design = GetPostString("design");
  2276. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2277. string orderState = GetPostString("orderState");
  2278. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2279. string sellermemo = GetPostString("seller_memo");
  2280. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2281. string date1 = GetPostString("date1");
  2282. string date2 = GetPostString("date2");
  2283. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2284. if (dw.Length > 0) lw.Add(dw);
  2285. string price1 = GetPostString("price1");
  2286. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2287. string price2 = GetPostString("price2");
  2288. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2289. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2290. {
  2291. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2292. }
  2293. else
  2294. {
  2295. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2296. }
  2297. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2298. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2299. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2300. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2301. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2302. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2303. if (dt != null && dt.Rows.Count > 0)
  2304. {
  2305. foreach (DataRow dr in dt.Rows)
  2306. {
  2307. try
  2308. {
  2309. // 对象操作
  2310. if (dStruct.PageSize != 100000)
  2311. {
  2312. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2313. dr["gongchuang"] = response.code;
  2314. }
  2315. }
  2316. catch (NullReferenceException ex)
  2317. {
  2318. // 处理空引用异常
  2319. }
  2320. }
  2321. }
  2322. writeGridDataTableJson(dStruct.TotalCount, dt);
  2323. }
  2324. public void get_erp_myorderlist_pregather()
  2325. {
  2326. string date1 = GetPostString("date1");
  2327. string date2 = GetPostString("date2");
  2328. int userId = CurrentUser.UserID; //客服id
  2329. string orderWhere = "";
  2330. List<string> lw = new List<string>();
  2331. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2332. if (dw.Length > 0) lw.Add(dw);
  2333. lw.Add(string.Format("CustomerUserId={0}", userId));
  2334. lw.Add(string.Format("OrderState<9"));
  2335. orderWhere = string.Join(" and ", lw.ToArray());
  2336. string orderWhere2 = "";
  2337. List<string> lw2 = new List<string>();
  2338. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2339. if (dw2.Length > 0) lw2.Add(dw2);
  2340. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2341. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2342. string sql = string.Format("select *" +
  2343. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2344. "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 " +
  2345. "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 " +
  2346. "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");
  2347. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2348. //writeGridDataTableJson(dt.Rows.Count, dt);
  2349. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2350. }
  2351. public void upd_erp_publishorder()
  2352. {
  2353. if (UrlPostParmsCheck("ctid"))
  2354. {
  2355. string eid = GetPostString("ctid");
  2356. CeErpTradeCell entity = null;
  2357. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2358. if (entity != null)
  2359. {
  2360. entity.OrderState = 0; //发布后,变为待抢单
  2361. entity.Update();
  2362. commonHelper.UpdateRelationOrder(entity.ctid);
  2363. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2364. returnSuccessMsg("发布成功!");
  2365. return;
  2366. }
  2367. returnErrorMsg("找不到记录");
  2368. }
  2369. }
  2370. public void get_erp_my_tiporder()
  2371. {
  2372. StringBuilder sql = new StringBuilder();
  2373. int userId = 0;
  2374. if (CurrentUser != null) userId = CurrentUser.UserID;
  2375. string posCode = CurrentUser.UserPost.Post.Code;
  2376. string isTipedAfterSaleVerify = GetPostString("af");
  2377. DataTable dt = new DataTable();
  2378. if (posCode != "Supplier")
  2379. {
  2380. if (posCode == "CustomerService" || posCode == "Director")
  2381. {
  2382. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2383. }
  2384. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2385. {
  2386. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2387. }
  2388. else
  2389. {
  2390. string teamIds = CurrentUser.User.TeamIds;
  2391. if (teamIds == "")
  2392. {
  2393. teamIds = "0";
  2394. }
  2395. 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);
  2396. }
  2397. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2398. }
  2399. if (dt.Rows.Count <= 0)
  2400. {
  2401. string key = "aftersale_order_" + userId;
  2402. if (RedisHelper.HasKey(key))
  2403. {
  2404. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2405. dt.Columns.Add("ctid", typeof(string));
  2406. dt.Columns.Add("IsReadTag", typeof(int));
  2407. foreach (var i in list)
  2408. {
  2409. DataRow data = dt.NewRow();
  2410. data["ctid"] = i;
  2411. data["IsReadTag"] = 4;
  2412. dt.Rows.Add(data);
  2413. }
  2414. RedisHelper.StringDelete(key);
  2415. }
  2416. }
  2417. if (dt.Rows.Count <= 0)
  2418. {
  2419. sql = new StringBuilder();
  2420. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2421. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2422. }
  2423. if (posCode == "Supplier")
  2424. {
  2425. string ids = CurrentUser.User.pemVend;
  2426. if (ids != null && ids.Length > 0)
  2427. {
  2428. string[] ids_list = ids.Split(',');
  2429. foreach (var item in ids_list)
  2430. {
  2431. string key = "return_order_" + item;
  2432. if (RedisHelper.HasKey(key))
  2433. {
  2434. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2435. dt.Columns.Add("ctid", typeof(string));
  2436. dt.Columns.Add("IsReadTag", typeof(int));
  2437. foreach (var i in list)
  2438. {
  2439. DataRow data = dt.NewRow();
  2440. data["ctid"] = i;
  2441. data["IsReadTag"] = 1;
  2442. dt.Rows.Add(data);
  2443. }
  2444. RedisHelper.StringDelete(key);
  2445. }
  2446. }
  2447. }
  2448. if (dt.Rows.Count <= 0)
  2449. {
  2450. sql = new StringBuilder();
  2451. 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);
  2452. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2453. }
  2454. }
  2455. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2456. }
  2457. public void reset_erp_tiporder()
  2458. {
  2459. string ids = GetPostString("ids");
  2460. string[] ctidList = ids.Split(',');
  2461. foreach (string ctid in ctidList)
  2462. {
  2463. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2464. if (enty != null)
  2465. {
  2466. enty.IsReadTag = 0;
  2467. enty.Update();
  2468. }
  2469. }
  2470. returnSuccessMsg("成功!");
  2471. return;
  2472. }
  2473. public void get_erp_designlist()
  2474. {
  2475. DataStruct dStruct = GetPostStruct();
  2476. List<string> lw = new List<string>();
  2477. string tid = GetPostString("ctid");
  2478. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  2479. string shopname = GetPostString("shopname");
  2480. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2481. string buyernick = GetPostString("buyer_nick");
  2482. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2483. string customer = GetPostString("customer");
  2484. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2485. string design = GetPostString("design");
  2486. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2487. string orderState = GetPostString("orderState");
  2488. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2489. lw.Add(string.Format("OrderState<6"));
  2490. string address = GetPostString("address");
  2491. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2492. string sellermemo = GetPostString("seller_memo");
  2493. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2494. string date1 = GetPostString("date1");
  2495. string date2 = GetPostString("date2");
  2496. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2497. if (dw.Length > 0) lw.Add(dw);
  2498. string apdate1 = GetPostString("apdate1");
  2499. string apdate2 = GetPostString("apdate2");
  2500. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2501. if (dwap.Length > 0) lw.Add(dwap);
  2502. string price1 = GetPostString("price1");
  2503. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2504. string price2 = GetPostString("price2");
  2505. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2506. string designTime = GetPostString("designtime");
  2507. if (designTime.Length > 0)
  2508. {
  2509. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2510. }
  2511. string usershop = CurrentUser.User.pemShop;
  2512. if (usershop.Length > 0)
  2513. {
  2514. lw.Add(string.Format("shopId in ({0})", usershop));
  2515. }
  2516. int myOrgid = CurrentUser.UserPost.OrgID;
  2517. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2518. if (myOrgCode.IndexOf("Designer") != -1)
  2519. {
  2520. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2521. {
  2522. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2523. }
  2524. else
  2525. {
  2526. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2527. }
  2528. }
  2529. else
  2530. {
  2531. string orgId = GetPostString("designerhd");
  2532. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2533. }
  2534. if (tid.Length > 0 || buyernick.Length > 0)
  2535. {
  2536. lw.Add(string.Format("OrderState >= 3"));
  2537. }
  2538. else
  2539. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2540. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2541. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2542. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2543. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2544. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2545. if (dt != null && dt.Rows.Count > 0)
  2546. {
  2547. foreach (DataRow dr in dt.Rows)
  2548. {
  2549. try
  2550. {
  2551. // 对象操作
  2552. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2553. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2554. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2555. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2556. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2557. if (dStruct.PageSize != 100000)
  2558. {
  2559. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2560. dr["gongchuang"] = response.code;
  2561. }
  2562. }
  2563. catch (NullReferenceException ex)
  2564. {
  2565. }
  2566. }
  2567. }
  2568. writeGridDataTableJson(dStruct.TotalCount, dt);
  2569. }
  2570. public void get_erp_mydesignlist()
  2571. {
  2572. DataStruct dStruct = GetPostStruct();
  2573. List<string> lw = new List<string>();
  2574. string tid = GetPostString("ctid");
  2575. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2576. string shopname = GetPostString("shopname");
  2577. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2578. string buyernick = GetPostString("buyer_nick");
  2579. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2580. string customer = GetPostString("customer");
  2581. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2582. string orderState = GetPostString("orderState");
  2583. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2584. //lw.Add(string.Format("OrderState<6"));
  2585. string date1 = GetPostString("date1");
  2586. string date2 = GetPostString("date2");
  2587. string dw = GetDateWhere("pay_time", date1, date2);
  2588. if (dw.Length > 0) lw.Add(dw);
  2589. string apdate1 = GetPostString("apdate1");
  2590. string apdate2 = GetPostString("apdate2");
  2591. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2592. if (dwap.Length > 0) lw.Add(dwap);
  2593. string price1 = GetPostString("price1");
  2594. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2595. string price2 = GetPostString("price2");
  2596. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2597. string olddownload = GetPostString("olddown");
  2598. if (olddownload == "1")
  2599. {
  2600. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2601. }
  2602. else if (olddownload == "2")
  2603. {
  2604. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2605. }
  2606. string sellermemo = GetPostString("seller_memo");
  2607. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2608. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2609. if (CurrentUser.User.TeamIds.Length > 0)
  2610. {
  2611. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2612. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2613. else
  2614. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2615. }
  2616. else
  2617. {
  2618. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2619. }
  2620. if (tid.Length <= 0)
  2621. {
  2622. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2623. }
  2624. lw.Add(string.Format("IsReturn!=3"));
  2625. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2626. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2627. string teamids = CurrentUser.User.TeamIds.ToString();
  2628. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2629. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2630. if (dt != null && dt.Rows.Count > 0)
  2631. {
  2632. foreach (DataRow dr in dt.Rows)
  2633. {
  2634. try
  2635. {
  2636. // 对象操作
  2637. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2638. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2639. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2640. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2641. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2642. if (dStruct.PageSize != 100000)
  2643. {
  2644. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2645. dr["gongchuang"] = response.code;
  2646. }
  2647. }
  2648. catch (NullReferenceException ex)
  2649. {
  2650. }
  2651. }
  2652. }
  2653. writeGridDataTableJson(dStruct.TotalCount, dt);
  2654. }
  2655. public void set_erp_startdesign()
  2656. {
  2657. if (UrlPostParmsCheck("ctid"))
  2658. {
  2659. string eid = GetPostString("ctid");
  2660. CeErpTradeCell entity = null;
  2661. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2662. if (entity != null)
  2663. {
  2664. if (entity.OrderState != 3)
  2665. {
  2666. returnErrorMsg("请刷新,订单已经设计了");
  2667. return;
  2668. }
  2669. entity.StartDesignTime = DateTime.Now;
  2670. entity.OrderState = 4;
  2671. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2672. {
  2673. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2674. entity.SupplierId = suid;
  2675. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2676. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2677. }
  2678. //entity.MakeSupplier = suname;
  2679. entity.Update();
  2680. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2681. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2682. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2683. commonHelper.getCytPrice(entity);
  2684. returnSuccessMsg("操作成功!");
  2685. return;
  2686. }
  2687. returnErrorMsg("找不到记录");
  2688. }
  2689. }
  2690. public void ins_erp_designselfmemo()
  2691. {
  2692. if (UrlPostParmsCheck("ctid"))
  2693. {
  2694. string eid = GetPostString("ctid");
  2695. string con = GetPostString("con");
  2696. CeErpTradeCell entity = null;
  2697. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2698. if (entity != null)
  2699. {
  2700. entity.DesignSelfMemo = con;
  2701. entity.Update();
  2702. returnSuccessMsg("操作成功!");
  2703. return;
  2704. }
  2705. returnErrorMsg("找不到记录");
  2706. }
  2707. }
  2708. public void ins_erp_designprice()
  2709. {
  2710. if (UrlPostParmsCheck("ctid"))
  2711. {
  2712. string eid = GetPostString("ctid");
  2713. int uid = CurrentUser.UserID;
  2714. string userName = CurrentUser.UserName;
  2715. CeErpTradeCell entity = null;
  2716. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2717. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2718. if (entitys == null)
  2719. {
  2720. entitys = new CeErpDesignerBill();
  2721. }
  2722. if (entity != null)
  2723. {
  2724. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2725. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2726. entity.StartDesignTime = DateTime.Now;
  2727. entity.OrderState = 4;
  2728. string suname = "";
  2729. if (entity.SupplierId == 0)
  2730. {
  2731. int sid = commonHelper.autoDistributeToSupplier(entity);
  2732. entity.SupplierId = sid;
  2733. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2734. }
  2735. entity.Update();
  2736. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2737. if (ceErpUserPost != null)
  2738. {
  2739. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2740. if (ceErpPost != null)
  2741. {
  2742. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2743. {
  2744. entitys.tid = entity.ctid;
  2745. entitys.oid = entity.tid;
  2746. entitys.uid = uid;
  2747. entitys.userName = userName;
  2748. entitys.designerType = 1;
  2749. entitys.designerTypeText = "内部设计师";
  2750. entitys.price = Convert.ToDouble(GetPostString("price"));
  2751. entitys.designNum = GetPostInt("designNum");
  2752. entitys.modifyNum = GetPostInt("modifyNum");
  2753. entitys.designSize = GetPostString("designSize");
  2754. entitys.modifySize = GetPostString("modifySize");
  2755. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2756. {
  2757. entitys.create_time = DateTime.Now;
  2758. entitys.create_u_id = uid;
  2759. entitys.create_u_name = userName;
  2760. entitys.Save();
  2761. }
  2762. else
  2763. {
  2764. entitys.update_time = DateTime.Now;
  2765. entitys.update_u_id = uid;
  2766. entitys.update_u_name = userName;
  2767. entitys.Update();
  2768. }
  2769. }
  2770. }
  2771. }
  2772. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2773. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2774. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2775. if (suname != "")
  2776. {
  2777. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2778. }
  2779. commonHelper.getCytPrice(entity);
  2780. returnSuccessMsg("操作成功!");
  2781. return;
  2782. }
  2783. returnErrorMsg("找不到记录");
  2784. }
  2785. }
  2786. public void upload_erp_filecomplete()
  2787. {
  2788. if (UrlPostParmsCheck("ctid"))
  2789. {
  2790. string eid = GetPostString("ctid");
  2791. CeErpTradeCell entity = null;
  2792. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2793. if (entity != null)
  2794. {
  2795. entity.OrderState = 5; //设计完成
  2796. entity.Update();
  2797. returnSuccessMsg(eid + "上传成功,设计完成!");
  2798. return;
  2799. }
  2800. returnErrorMsg("找不到订单记录");
  2801. }
  2802. }
  2803. public void get_erp_designovertimelist()
  2804. {
  2805. DataStruct dStruct = GetPostStruct();
  2806. List<string> lw = new List<string>();
  2807. string tid = GetPostString("ctid");
  2808. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2809. string shopname = GetPostString("shopname");
  2810. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2811. string buyernick = GetPostString("buyer_nick");
  2812. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2813. string ResponsibleMan = GetPostString("responsible");
  2814. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2815. string date1 = GetPostString("date1");
  2816. string date2 = GetPostString("date2");
  2817. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2818. if (dw.Length > 0) lw.Add(dw);
  2819. string price1 = GetPostString("price1");
  2820. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2821. string price2 = GetPostString("price2");
  2822. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2823. string orderState = GetPostString("orderState");
  2824. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2825. string sellermemo = GetPostString("seller_memo");
  2826. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2827. lw.Add(string.Format("UnusualTag=3"));
  2828. lw.Add(string.Format("IsRefund<={0}", 1));
  2829. dStruct.Order = "WaitDesignTime desc";
  2830. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2831. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2832. writeGridDataTableJson(dStruct.TotalCount, dt);
  2833. }
  2834. //设计管理 获取抢单大厅列表
  2835. public void get_erp_grabinglist()
  2836. {
  2837. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2838. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2839. bool oldOrder = false;
  2840. if (org != null)
  2841. {
  2842. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2843. }
  2844. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2845. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2846. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2847. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2848. //先处理订单数据
  2849. if (dt.Rows.Count > 0)
  2850. {
  2851. Dictionary<string, int> design = null;
  2852. int count = 0;
  2853. foreach (DataRow row in dt.Rows)
  2854. {
  2855. if (map.ContainsKey(row["ShopId"].ToString()))
  2856. {
  2857. map.TryGetValue(row["ShopId"].ToString(), out design);
  2858. }
  2859. else
  2860. {
  2861. design = new Dictionary<string, int>();
  2862. }
  2863. if (design.ContainsKey(row["ProductId"].ToString()))
  2864. {
  2865. design.TryGetValue(row["ProductId"].ToString(), out count);
  2866. }
  2867. count++;
  2868. design[row["ProductId"].ToString()] = count;
  2869. map[row["ShopId"].ToString()] = design;
  2870. }
  2871. }
  2872. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2873. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2874. //把店铺排序和技能排序分类
  2875. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2876. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2877. if (design_dt.Rows.Count > 0)
  2878. {
  2879. Dictionary<string, string> design = null;
  2880. List<string> shopIds = null;
  2881. foreach (DataRow row in design_dt.Rows)
  2882. {
  2883. if ("0".Equals(row["designId"].ToString()))
  2884. {
  2885. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2886. {
  2887. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2888. }
  2889. else
  2890. {
  2891. shopIds = new List<string>();
  2892. }
  2893. shopIds.Add(row["shopId"].ToString());
  2894. shop_orders[row["orders"].ToString()] = shopIds;
  2895. }
  2896. else
  2897. {
  2898. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2899. {
  2900. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2901. }
  2902. else
  2903. {
  2904. design = new Dictionary<string, string>();
  2905. }
  2906. design[row["orders"].ToString()] = row["designId"].ToString();
  2907. design_orders[row["shopId"].ToString()] = design;
  2908. }
  2909. }
  2910. //处理成key value后根据key排序
  2911. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2912. foreach (List<string> val in shop_orders.Values)
  2913. {
  2914. if (val != null)
  2915. {
  2916. foreach (string key in val)
  2917. {
  2918. if (design_orders.ContainsKey(key.ToString()))
  2919. {
  2920. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2921. }
  2922. }
  2923. }
  2924. }
  2925. }
  2926. //校验哪个优先级有订单
  2927. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2928. foreach (string key in shop_orders.Keys)
  2929. {
  2930. List<string> ids = null;
  2931. shop_orders.TryGetValue(key, out ids);
  2932. //id为shopid
  2933. foreach (string id in ids)
  2934. {
  2935. Dictionary<string, int> list = null;
  2936. Dictionary<string, string> desing = null;
  2937. map.TryGetValue(id, out list);
  2938. design_orders.TryGetValue(id, out desing);
  2939. if (list != null && desing != null)
  2940. {
  2941. foreach (var item in desing)
  2942. {
  2943. int count = 0;
  2944. if (list.ContainsKey(item.Value))
  2945. {
  2946. list.TryGetValue(item.Value, out count);
  2947. if (count > 0)
  2948. {
  2949. designIds[id] = item.Value;
  2950. break;
  2951. }
  2952. }
  2953. }
  2954. }
  2955. }
  2956. if (designIds.Count > 0)
  2957. {
  2958. break;
  2959. }
  2960. }
  2961. DataTable table = new DataTable();
  2962. table.Columns.Add("tid", typeof(string));
  2963. table.Columns.Add("ctid", typeof(string));
  2964. table.Columns.Add("seller_nick", typeof(string));
  2965. table.Columns.Add("productName", typeof(string));
  2966. table.Columns.Add("pay_time", typeof(string));
  2967. table.Columns.Add("seller_memo", typeof(string));
  2968. if (designIds.Count > 0)
  2969. {
  2970. string shopId = "";
  2971. string productId = "";
  2972. foreach (var designInfo in designIds)
  2973. {
  2974. shopId = designInfo.Key;
  2975. productId = designInfo.Value;
  2976. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  2977. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  2978. if (dt.Rows.Count > 0)
  2979. {
  2980. foreach (DataRow row in dt.Rows)
  2981. {
  2982. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  2983. {
  2984. DataRow data = table.NewRow();
  2985. data["ctid"] = row["ctid"].ToString();
  2986. data["tid"] = row["tid"].ToString();
  2987. data["seller_nick"] = ceErpShop.ShopName;
  2988. data["pay_time"] = row["pay_time"].ToString();
  2989. data["seller_memo"] = row["seller_memo"].ToString();
  2990. data["productName"] = ceErpProduct.PType;
  2991. table.Rows.Add(data);
  2992. }
  2993. }
  2994. }
  2995. }
  2996. }
  2997. writeGridDataTableJson(table.Rows.Count, table);
  2998. }
  2999. private object rushLockObject = new object();
  3000. public void set_erp_grabingorder()
  3001. {
  3002. if (UrlPostParmsCheck("ctid"))
  3003. {
  3004. int total = CurrentUser.User.Person.Total;
  3005. int userId = CurrentUser.User.ID;
  3006. int noFinish = CurrentUser.User.Person.NoFinish;
  3007. int finalization = CurrentUser.User.Person.Finalization;
  3008. string eids = GetPostString("ctid");
  3009. string key = "RushKey_" + userId;
  3010. int count = 0;
  3011. if (erpRedis.RedisHelper.KeyExists(key))
  3012. {
  3013. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3014. if (redisCount != null)
  3015. {
  3016. count = Convert.ToInt32(redisCount);
  3017. }
  3018. }
  3019. if (count >= total)
  3020. {
  3021. returnErrorMsg("半小时内已经抢" + total + "单");
  3022. return;
  3023. }
  3024. string[] ctidlist = eids.Split(',');
  3025. if (count + ctidlist.Length > total)
  3026. {
  3027. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3028. return;
  3029. }
  3030. int itag = 0;
  3031. lock (rushLockObject)
  3032. {
  3033. if (ctidlist.Length > 0)
  3034. {
  3035. string[] dtList = new string[ctidlist.Length];
  3036. for (int i = 0; i < ctidlist.Length; i++)
  3037. {
  3038. dtList[i] = "'" + ctidlist[i] + "'";
  3039. }
  3040. 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"));
  3041. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3042. if (dt_user.Rows.Count > 0)
  3043. {
  3044. int doing = 0;//未定稿
  3045. int finish = 0;//已完成
  3046. foreach (DataRow dr in dt_user.Rows)
  3047. {
  3048. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3049. {
  3050. doing++;
  3051. }
  3052. else
  3053. {
  3054. finish++;
  3055. }
  3056. }
  3057. if (doing >= noFinish)
  3058. {
  3059. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3060. return;
  3061. }
  3062. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3063. {
  3064. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3065. return;
  3066. }
  3067. }
  3068. //校验选择单子状态
  3069. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3070. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3071. if (dt.Rows.Count > 0)
  3072. {
  3073. List<string> list = new List<string>();
  3074. foreach (DataRow dr in dt.Rows)
  3075. {
  3076. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3077. {
  3078. list.Add(dr["ctid"].ToString());
  3079. }
  3080. }
  3081. if (list.Count > 0)
  3082. {
  3083. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3084. return;
  3085. }
  3086. }
  3087. foreach (string ctid in ctidlist)
  3088. {
  3089. CeErpTradeCell entity = null;
  3090. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3091. if (entity != null)
  3092. {
  3093. entity.OrderState = 3;
  3094. entity.DesignUserId = CurrentUser.UserID;
  3095. entity.WaitDesignTime = DateTime.Now;
  3096. entity.StartDesignTime = DateTime.Now;
  3097. entity.Update();
  3098. commonHelper.UpdateRelationOrder(entity.ctid);
  3099. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3100. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3101. itag++;
  3102. }
  3103. }
  3104. }
  3105. }
  3106. count += ctidlist.Length;
  3107. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3108. if (itag == 0)
  3109. returnErrorMsg("没有找到相关订单");
  3110. else
  3111. returnSuccessMsg("抢单成功!");
  3112. return;
  3113. }
  3114. }
  3115. public void get_erp_waitorderlist()
  3116. {
  3117. DataStruct dStruct = GetPostStruct();
  3118. List<string> lw = new List<string>();
  3119. string tid = GetPostString("ctid");
  3120. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3121. string shopname = GetPostString("shopname");
  3122. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3123. string buyernick = GetPostString("buyer_nick");
  3124. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3125. string customer = GetPostString("customer");
  3126. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3127. string design = GetPostString("design");
  3128. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3129. string orderState = GetPostString("orderState");
  3130. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3131. string supplier = GetPostString("supplier");
  3132. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3133. string sellermemo = GetPostString("seller_memo");
  3134. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3135. string otherMemo = GetPostString("otherMemo");
  3136. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3137. string address = GetPostString("address");
  3138. 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));
  3139. string date1 = GetPostString("date1");
  3140. string date2 = GetPostString("date2");
  3141. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3142. if (dw.Length > 0) lw.Add(dw);
  3143. string price1 = GetPostString("price1");
  3144. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3145. string price2 = GetPostString("price2");
  3146. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3147. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3148. lw.Add(string.Format("IsSample != 2 "));
  3149. lw.Add(string.Format("OrderState = 5 "));
  3150. lw.Add(string.Format("IsRefund<={0}", 1));
  3151. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3152. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3153. string pagesize = GetPostString("pagesize");
  3154. if (pagesize != null)
  3155. {
  3156. dStruct.PageSize = 200;
  3157. }
  3158. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3159. foreach (DataRow dr in dt.Rows)
  3160. {
  3161. 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();
  3162. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3163. {
  3164. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3165. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3166. entity.SupplierId = suid;
  3167. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3168. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3169. entity.Update();
  3170. }
  3171. }
  3172. writeGridDataTableJson(dStruct.TotalCount, dt);
  3173. }
  3174. public void get_erp_supplierwaitorderlist()
  3175. {
  3176. DataStruct dStruct = GetPostStruct();
  3177. List<string> lw = new List<string>();
  3178. string tid = GetPostString("ctid");
  3179. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3180. string shopname = GetPostString("shopname");
  3181. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3182. string sellermemo = GetPostString("seller_memo");
  3183. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3184. string date1 = GetPostString("date1");
  3185. string date2 = GetPostString("date2");
  3186. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3187. if (dw.Length > 0) lw.Add(dw);
  3188. lw.Add(string.Format("OrderState = 5 "));
  3189. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3190. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3191. {
  3192. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3193. }
  3194. string supplier = GetPostString("supplier");
  3195. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3196. {
  3197. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3198. }
  3199. lw.Add(string.Format("IsRefund<={0}", 1));
  3200. dStruct.Order = "FinishDesignTime desc";
  3201. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3202. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3203. if (dt != null)
  3204. {
  3205. foreach (DataRow dr in dt.Rows)
  3206. {
  3207. 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();
  3208. }
  3209. }
  3210. writeGridDataTableJson(dStruct.TotalCount, dt);
  3211. }
  3212. public void upd_erp_verifytosupplier()
  3213. {
  3214. if (UrlPostParmsCheck("ctid"))
  3215. {
  3216. string eids = GetPostString("ctid");
  3217. CeErpTradeCell entity = null;
  3218. string[] eidsList = eids.Split(',');
  3219. if (eidsList.Length <= 0)
  3220. {
  3221. returnErrorMsg("订单号不能空");
  3222. return;
  3223. }
  3224. List<string> tLst = new List<string>();
  3225. foreach (string ctidstr in eidsList)
  3226. {
  3227. tLst.Add("'" + ctidstr + "'");
  3228. CeErpDataSendOrderInfo.createObject(ctidstr);
  3229. }
  3230. string needtids = string.Join(",", tLst.ToArray());
  3231. StringBuilder sql = new StringBuilder();
  3232. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3233. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3234. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3235. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3236. returnSuccessMsg("操作成功!");
  3237. return;
  3238. /**foreach (string ctidstr in eidsList)
  3239. {
  3240. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3241. if (entity != null)
  3242. {
  3243. if (entity.SupplierId == 0)
  3244. {
  3245. continue;
  3246. }
  3247. entity.IsVerifyToSupplier = true;
  3248. if (entity.IsReturn == 1) //1是供应商打回
  3249. {
  3250. entity.IsReturn = 0;
  3251. }
  3252. entity.FinishPlaceTime = DateTime.Now;
  3253. entity.PlaceUserId = CurrentUser.UserID;
  3254. entity.Update();
  3255. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3256. }
  3257. }
  3258. returnSuccessMsg("操作成功!");
  3259. return;**/
  3260. }
  3261. }
  3262. public void upd_erp_supplierback()
  3263. {
  3264. if (UrlPostParmsCheck("ctid"))
  3265. {
  3266. string eid = GetPostString("ctid");
  3267. string reason = GetPostString("returnreason");
  3268. CeErpTradeCell entity = null;
  3269. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3270. if (entity != null)
  3271. {
  3272. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3273. {
  3274. string key = "return_order_" + entity.SupplierId;
  3275. List<string> list = new List<string>();
  3276. if (RedisHelper.HasKey(key))
  3277. {
  3278. object data = RedisHelper.StringGet(key);
  3279. list = Convert.ToString(data).Split(',').ToList();
  3280. }
  3281. list.Add(eid);
  3282. RedisHelper.StringSet(key, string.Join(",", list));
  3283. }
  3284. entity.IsVerifyToSupplier = false;
  3285. entity.IsReturn = 1;
  3286. entity.ReturnTime = DateTime.Now;
  3287. entity.ReturnReason = reason;
  3288. if (entity.OrderState == 6)
  3289. {
  3290. entity.OrderState = 5;
  3291. }
  3292. entity.Update();
  3293. CeErpSukuraData.createInfo(entity.ctid, 5);
  3294. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3295. returnSuccessMsg("操作成功!");
  3296. return;
  3297. }
  3298. returnErrorMsg("找不到订单记录");
  3299. }
  3300. }
  3301. public void upd_erp_toaftersaleorder()
  3302. {
  3303. if (UrlPostParmsCheck("ctid"))
  3304. {
  3305. string eid = GetPostString("ctid");
  3306. string reason = GetPostString("returnreason");
  3307. CeErpTradeCell entity = null;
  3308. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3309. if (entity != null)
  3310. {
  3311. if (entity.isAfterSaleOrder != 1)
  3312. {
  3313. returnErrorMsg("带S的售后单才能打回给售后");
  3314. return;
  3315. }
  3316. if (entity.OrderState >= 5)
  3317. {
  3318. returnErrorMsg("已经设计完成了不能打回给售后");
  3319. return;
  3320. }
  3321. entity.OrderState = 0;
  3322. entity.IsReturn = 3;
  3323. entity.ReturnTime = DateTime.Now;
  3324. entity.ReturnReason = reason;
  3325. entity.Update();
  3326. CeErpSukuraData.createInfo(entity.ctid, 5);
  3327. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3328. returnSuccessMsg("操作成功!");
  3329. return;
  3330. }
  3331. returnErrorMsg("找不到订单记录");
  3332. }
  3333. }
  3334. public void upd_erp_aftersaletodesign()
  3335. {
  3336. if (UrlPostParmsCheck("ctid"))
  3337. {
  3338. string eid = GetPostString("ctid");
  3339. CeErpTradeCell entity = null;
  3340. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3341. if (entity != null)
  3342. {
  3343. entity.OrderState = 3;
  3344. entity.IsReturn = 0;
  3345. entity.Update();
  3346. CeErpSukuraData.createInfo(entity.ctid, 5);
  3347. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3348. returnSuccessMsg("操作成功!");
  3349. return;
  3350. }
  3351. returnErrorMsg("找不到订单记录");
  3352. }
  3353. }
  3354. public void assign_erp_supplier()
  3355. {
  3356. if (UrlPostParmsCheck("ctid"))
  3357. {
  3358. string eids = GetPostString("ctid");
  3359. int sid = GetPostInt("SupplierName");
  3360. string fromTag = GetPostString("tag");
  3361. string[] eidList = eids.Split(',');
  3362. if (eidList.Length <= 0)
  3363. {
  3364. returnErrorMsg("指派不能为空");
  3365. return;
  3366. }
  3367. string errMsg = "";
  3368. string suname = commonHelper.getSupplierNameById(sid);
  3369. foreach (string ctid in eidList)
  3370. {
  3371. CeErpTradeCell entity = null;
  3372. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3373. if (entity != null)
  3374. {
  3375. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3376. {
  3377. errMsg += (ctid + "指派失败!!!");
  3378. continue;
  3379. }
  3380. entity.SupplierId = sid;
  3381. entity.Update();
  3382. commonHelper.UpdateRelationOrder(entity.ctid);
  3383. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3384. if (entity.OrderState >= 6)
  3385. {
  3386. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3387. //{
  3388. // string msl = entity.MakeSupplier;
  3389. // string[] mslist = msl.Split(',');
  3390. // 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);
  3391. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3392. //}
  3393. //else
  3394. //{
  3395. StringBuilder sql = new StringBuilder();
  3396. 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);
  3397. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3398. //}
  3399. }
  3400. }
  3401. else
  3402. {
  3403. continue;
  3404. }
  3405. }
  3406. if (errMsg.Length > 0)
  3407. {
  3408. returnErrorMsg(errMsg);
  3409. return;
  3410. }
  3411. returnSuccessMsg("操作成功!");
  3412. return;
  3413. }
  3414. }
  3415. public void assign_erp_makesupplier()
  3416. {
  3417. if (UrlPostParmsCheck("ctid"))
  3418. {
  3419. string eids = GetPostString("ctid");
  3420. string sname = GetPostString("SupplierName");
  3421. string[] eidList = eids.Split(',');
  3422. if (eidList.Length <= 0)
  3423. {
  3424. returnErrorMsg("指派不能为空");
  3425. return;
  3426. }
  3427. List<string> tLst = new List<string>();
  3428. foreach (string ctid in eidList)
  3429. {
  3430. CeErpTradeCell entity = null;
  3431. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3432. if (entity != null)
  3433. {
  3434. entity.MakeSupplier = sname;
  3435. entity.Update();
  3436. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3437. tLst.Add("'" + ctid + "'");
  3438. }
  3439. else
  3440. {
  3441. continue;
  3442. }
  3443. }
  3444. string ctids = string.Join(",", tLst.ToArray());
  3445. StringBuilder sql2 = new StringBuilder();
  3446. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3447. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3448. returnSuccessMsg("操作成功!");
  3449. return;
  3450. }
  3451. }
  3452. public void ins_erp_returnreason()
  3453. {
  3454. if (UrlPostParmsCheck("ctid"))
  3455. {
  3456. string eid = GetPostString("ctid");
  3457. CeErpTradeCell entity = null;
  3458. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3459. string userpost = CurrentUser.UserPost.Post.Code;
  3460. if (entity != null)
  3461. {
  3462. bool isPlace = false;
  3463. if (entity.OrderState > 6)
  3464. {
  3465. returnErrorMsg("已发货无法打回!");
  3466. return;
  3467. }
  3468. if (entity.OrderState == 6)
  3469. {
  3470. isPlace = true;
  3471. }
  3472. bool isNeedUpdateCell2 = false;
  3473. if (entity.OrderState >= 6)
  3474. {
  3475. isNeedUpdateCell2 = true;
  3476. }
  3477. int returnTag = 2;
  3478. if (userpost == "Supplier")
  3479. {
  3480. returnTag = 1;
  3481. }
  3482. if (entity.IsXianHuo == 0)
  3483. {
  3484. if (returnTag == 2)
  3485. {
  3486. int toType = GetPostInt("totype");
  3487. if (toType == 1)
  3488. {
  3489. entity.OrderState = 0;
  3490. entity.ReturnUserType = 1;
  3491. string clearman = GetPostString("clearman");
  3492. if (!string.IsNullOrEmpty(clearman))
  3493. {
  3494. entity.DesignUserId = 0;
  3495. }
  3496. }
  3497. else
  3498. {
  3499. entity.OrderState = 3;
  3500. entity.ReturnUserType = 2;
  3501. }
  3502. entity.IsReadTag = 1;
  3503. }
  3504. else if (returnTag == 1)
  3505. {
  3506. entity.OrderState = 5;
  3507. }
  3508. entity.IsVerifyToSupplier = false;
  3509. }
  3510. if (entity.IsXianHuo == 1)
  3511. {
  3512. entity.OrderState = 5;
  3513. }
  3514. entity.UnusualTag = 0;
  3515. entity.UnusualTime = null;
  3516. entity.UnusualCon = "";
  3517. entity.IsReturn = returnTag;
  3518. entity.ReturnTime = DateTime.Now;
  3519. entity.ReturnReason = GetPostString("returnreason");
  3520. entity.Update();
  3521. if (entity.OrderState == 3)
  3522. {
  3523. ApiVo apiVo = new ApiVo();
  3524. apiVo.orderNumber = entity.ctid;
  3525. apiVo.actionName = "rebutDesign";
  3526. apiVo.orderRemarks = entity.ReturnReason;
  3527. designHelper.API_WorkCore(apiVo);//rebutDesign
  3528. }
  3529. CeErpSukuraData.createInfo(entity.ctid, 5);
  3530. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3531. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3532. if (isPlace)
  3533. {
  3534. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3535. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3536. if (dth != null && dth.Rows.Count > 0)
  3537. {
  3538. dataSendOrderBean dataSendOrderBean = null;
  3539. foreach (DataRow item in dth.Rows)
  3540. {
  3541. try
  3542. {
  3543. dataSendOrderBean = new dataSendOrderBean();
  3544. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3545. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3546. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3547. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3548. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3549. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3550. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3551. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3552. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3553. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3554. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3555. dataSendOrderBean.Radio1723534706288 = "打回";
  3556. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3557. if (result != null)
  3558. {
  3559. if ("0".Equals(result.errcode))
  3560. {
  3561. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3562. }
  3563. else
  3564. {
  3565. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3566. }
  3567. }
  3568. }
  3569. catch (Exception ex)
  3570. {
  3571. }
  3572. }
  3573. }
  3574. }
  3575. if (isNeedUpdateCell2)
  3576. {
  3577. if (entity.MakeSupplier.IndexOf(",") != -1)
  3578. {
  3579. StringBuilder sql2 = new StringBuilder();
  3580. 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);
  3581. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3582. }
  3583. else
  3584. {
  3585. StringBuilder sql2 = new StringBuilder();
  3586. 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);
  3587. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3588. }
  3589. }
  3590. returnSuccessMsg("操作成功!");
  3591. return;
  3592. }
  3593. returnErrorMsg("找不到订单记录");
  3594. }
  3595. }
  3596. public void cyt_erp_returnreason()
  3597. {
  3598. if (UrlPostParmsCheck("ctid"))
  3599. {
  3600. string eid = GetPostString("ctid");
  3601. CeErpTradeCell entity = null;
  3602. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3603. string userpost = CurrentUser.UserPost.Post.Code;
  3604. if (entity != null)
  3605. {
  3606. if (entity.OrderState > 6)
  3607. {
  3608. returnErrorMsg("已发货无法打回!");
  3609. return;
  3610. }
  3611. JObject jsonObject = new JObject
  3612. {
  3613. { "Userid", "77886" },
  3614. { "Pwd", "lt666888" },
  3615. { "LTOrderId",eid }
  3616. };
  3617. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3618. JObject jsonObjects = JObject.Parse(response);
  3619. string msg = (string)jsonObjects["msg"];
  3620. if (msg != "取消成功")
  3621. {
  3622. returnErrorMsg(msg);
  3623. return;
  3624. }
  3625. bool isNeedUpdateCell2 = false;
  3626. if (entity.OrderState >= 6)
  3627. {
  3628. isNeedUpdateCell2 = true;
  3629. }
  3630. int returnTag = 2;
  3631. if (userpost == "Supplier")
  3632. {
  3633. returnTag = 1;
  3634. }
  3635. if (entity.IsXianHuo == 0)
  3636. {
  3637. if (returnTag == 2)
  3638. {
  3639. int toType = GetPostInt("totype");
  3640. if (toType == 1)
  3641. {
  3642. entity.OrderState = 0;
  3643. entity.ReturnUserType = 1;
  3644. }
  3645. else
  3646. {
  3647. entity.OrderState = 4;
  3648. entity.ReturnUserType = 2;
  3649. }
  3650. entity.IsReadTag = 1;
  3651. }
  3652. else if (returnTag == 1)
  3653. {
  3654. entity.OrderState = 5;
  3655. }
  3656. entity.IsVerifyToSupplier = false;
  3657. }
  3658. entity.UnusualTag = 0;
  3659. entity.UnusualTime = null;
  3660. entity.UnusualCon = "";
  3661. entity.IsReturn = returnTag;
  3662. entity.ReturnTime = DateTime.Now;
  3663. entity.ReturnReason = GetPostString("returnreason");
  3664. entity.Update();
  3665. if (entity.OrderState == 4)
  3666. {
  3667. ApiVo apiVo = new ApiVo();
  3668. apiVo.orderNumber = entity.ctid;
  3669. apiVo.actionName = "rebutDesign";
  3670. apiVo.orderRemarks = entity.ReturnReason;
  3671. designHelper.API_WorkCore(apiVo);//rebutDesign
  3672. }
  3673. CeErpSukuraData.createInfo(entity.ctid, 5);
  3674. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3675. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3676. if (isNeedUpdateCell2)
  3677. {
  3678. if (entity.MakeSupplier.IndexOf(",") != -1)
  3679. {
  3680. StringBuilder sql2 = new StringBuilder();
  3681. 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);
  3682. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3683. }
  3684. else
  3685. {
  3686. StringBuilder sql2 = new StringBuilder();
  3687. 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);
  3688. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3689. }
  3690. }
  3691. returnSuccessMsg("操作成功!");
  3692. return;
  3693. }
  3694. returnErrorMsg("找不到订单记录");
  3695. }
  3696. }
  3697. public void upd_erp_xianhuoreturntag()
  3698. {
  3699. if (UrlPostParmsCheck("ctid"))
  3700. {
  3701. string eids = GetPostString("ctid");
  3702. string[] ctids = eids.Split(',');
  3703. foreach (string ctid in ctids)
  3704. {
  3705. CeErpTradeCell entity = null;
  3706. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3707. if (entity != null)
  3708. {
  3709. entity.IsReturn = 0;
  3710. entity.Update();
  3711. CeErpSukuraData.createInfo(entity.ctid, 5);
  3712. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3713. }
  3714. }
  3715. returnSuccessMsg("操作成功!");
  3716. return;
  3717. }
  3718. }
  3719. public void get_erp_waitdeliverylist()
  3720. {
  3721. DataStruct dStruct = GetPostStruct();
  3722. List<string> lw = new List<string>();
  3723. string tid = GetPostString("ctid");
  3724. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3725. string shopname = GetPostString("shopname");
  3726. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3727. string buyernick = GetPostString("buyer_nick");
  3728. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3729. //if (tid.Length == 0 && buyernick.Length == 0)
  3730. //{
  3731. // lw.Add(string.Format("IsRefund<={0}", 1));
  3732. //}
  3733. string customer = GetPostString("customer");
  3734. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3735. string design = GetPostString("design");
  3736. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3737. string orderState = GetPostString("orderState");
  3738. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3739. string address = GetPostString("address");
  3740. 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));
  3741. string sellermemo = GetPostString("seller_memo");
  3742. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3743. string supplier = GetPostString("supplier");
  3744. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3745. string OrderArea = GetPostString("order_area");
  3746. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3747. string placedate1 = GetPostString("placedate1");
  3748. string placedate2 = GetPostString("placedate2");
  3749. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3750. if (fdw.Length > 0) lw.Add(fdw);
  3751. string price1 = GetPostString("price1");
  3752. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3753. string price2 = GetPostString("price2");
  3754. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3755. string unusualCon = GetPostString("unusualcon");
  3756. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3757. string otherMemo = GetPostString("otherMemo");
  3758. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3759. string posTag = CurrentUser.UserPost.Post.Code;
  3760. if (posTag == "Supplier")
  3761. {
  3762. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3763. }
  3764. lw.Add(string.Format("OrderState = 6 "));
  3765. lw.Add(string.Format("type != 'PDD' "));
  3766. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3767. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3768. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3769. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3770. writeGridDataTableJson(dStruct.TotalCount, dt);
  3771. }
  3772. public void get_erp_pddderiving()
  3773. {
  3774. DataStruct dStruct = GetPostStruct();
  3775. List<string> lw = new List<string>();
  3776. string tid = GetPostString("ctid");
  3777. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3778. string shopname = GetPostString("shopname");
  3779. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3780. string buyernick = GetPostString("buyer_nick");
  3781. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3782. //if (tid.Length == 0 && buyernick.Length == 0)
  3783. //{
  3784. // lw.Add(string.Format("IsRefund<={0}", 1));
  3785. //}
  3786. string customer = GetPostString("customer");
  3787. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3788. string design = GetPostString("design");
  3789. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3790. string orderState = GetPostString("orderState");
  3791. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3792. string address = GetPostString("address");
  3793. 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));
  3794. string sellermemo = GetPostString("seller_memo");
  3795. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3796. string supplier = GetPostString("supplier");
  3797. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3798. string OrderArea = GetPostString("order_area");
  3799. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3800. string placedate1 = GetPostString("placedate1");
  3801. string placedate2 = GetPostString("placedate2");
  3802. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3803. if (fdw.Length > 0) lw.Add(fdw);
  3804. string price1 = GetPostString("price1");
  3805. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3806. string price2 = GetPostString("price2");
  3807. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3808. string unusualCon = GetPostString("unusualcon");
  3809. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3810. string posTag = CurrentUser.UserPost.Post.Code;
  3811. if (posTag == "Supplier")
  3812. {
  3813. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3814. }
  3815. lw.Add(string.Format("OrderState = 6 "));
  3816. lw.Add(string.Format("type = 'PDD' "));
  3817. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3818. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3819. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3820. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3821. writeGridDataTableJson(dStruct.TotalCount, dt);
  3822. }
  3823. public void get_erp_jdderiving()
  3824. {
  3825. DataStruct dStruct = GetPostStruct();
  3826. List<string> lw = new List<string>();
  3827. string tid = GetPostString("ctid");
  3828. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3829. string shopname = GetPostString("shopname");
  3830. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3831. string buyernick = GetPostString("buyer_nick");
  3832. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3833. //if (tid.Length == 0 && buyernick.Length == 0)
  3834. //{
  3835. // lw.Add(string.Format("IsRefund<={0}", 1));
  3836. //}
  3837. string customer = GetPostString("customer");
  3838. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3839. string design = GetPostString("design");
  3840. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3841. string orderState = GetPostString("orderState");
  3842. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3843. string address = GetPostString("address");
  3844. 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));
  3845. string sellermemo = GetPostString("seller_memo");
  3846. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3847. string supplier = GetPostString("supplier");
  3848. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3849. string OrderArea = GetPostString("order_area");
  3850. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3851. string placedate1 = GetPostString("placedate1");
  3852. string placedate2 = GetPostString("placedate2");
  3853. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3854. if (fdw.Length > 0) lw.Add(fdw);
  3855. string price1 = GetPostString("price1");
  3856. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3857. string price2 = GetPostString("price2");
  3858. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3859. string unusualCon = GetPostString("unusualcon");
  3860. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3861. string posTag = CurrentUser.UserPost.Post.Code;
  3862. if (posTag == "Supplier")
  3863. {
  3864. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3865. }
  3866. lw.Add(string.Format("OrderState = 6 "));
  3867. lw.Add(string.Format("type = 'JD' "));
  3868. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3869. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3870. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3871. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3872. writeGridDataTableJson(dStruct.TotalCount, dt);
  3873. }
  3874. public void get_erp_demoorderlist()
  3875. {
  3876. DataStruct dStruct = GetPostStruct();
  3877. List<string> lw = new List<string>();
  3878. string tid = GetPostString("ctid");
  3879. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3880. string shopname = GetPostString("shopname");
  3881. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3882. string buyernick = GetPostString("buyer_nick");
  3883. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3884. string customer = GetPostString("customer");
  3885. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3886. string design = GetPostString("design");
  3887. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3888. string orderState = GetPostString("orderState");
  3889. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3890. string address = GetPostString("address");
  3891. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3892. string sellermemo = GetPostString("seller_memo");
  3893. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3894. string supplier = GetPostString("supplier");
  3895. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3896. string OrderArea = GetPostString("order_area");
  3897. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3898. string date1 = GetPostString("date1");
  3899. string date2 = GetPostString("date2");
  3900. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3901. if (dw.Length > 0) lw.Add(dw);
  3902. string price1 = GetPostString("price1");
  3903. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3904. string price2 = GetPostString("price2");
  3905. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3906. string posTag = CurrentUser.UserPost.Post.Code;
  3907. if (posTag == "Supplier")
  3908. {
  3909. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3910. }
  3911. //lw.Add(string.Format("OrderState = 6 "));
  3912. lw.Add(string.Format("IsSample={0}", 3));
  3913. lw.Add(string.Format("IsRefund<={0}", 1));
  3914. dStruct.Order = "pay_time desc";
  3915. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3916. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3917. writeGridDataTableJson(dStruct.TotalCount, dt);
  3918. }
  3919. public void save_erp_checkmemo()
  3920. {
  3921. if (UrlPostParmsCheck("ctid"))
  3922. {
  3923. string ctid = GetPostString("ctid");
  3924. CeErpTradeCell entity = null;
  3925. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3926. if (entity != null)
  3927. {
  3928. entity.CheckMemo = GetPostString("CheckMemo");
  3929. entity.Update();
  3930. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  3931. if (trade != null)
  3932. {
  3933. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  3934. }
  3935. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  3936. returnSuccessMsg("保存成功!");
  3937. return;
  3938. }
  3939. returnErrorMsg("找不到记录");
  3940. }
  3941. }
  3942. public void get_erp_returnlist()
  3943. {
  3944. DataStruct dStruct = GetPostStruct();
  3945. List<string> lw = new List<string>();
  3946. string tid = GetPostString("ctid");
  3947. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3948. string shopname = GetPostString("shopname");
  3949. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3950. string buyernick = GetPostString("buyer_nick");
  3951. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3952. string customer = GetPostString("customer");
  3953. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3954. string design = GetPostString("design");
  3955. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3956. string orderState = GetPostString("orderState");
  3957. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3958. string address = GetPostString("address");
  3959. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3960. string sellermemo = GetPostString("seller_memo");
  3961. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3962. string supplier = GetPostString("supplier");
  3963. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3964. string date1 = GetPostString("date1");
  3965. string date2 = GetPostString("date2");
  3966. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3967. if (dw.Length > 0) lw.Add(dw);
  3968. string bdate1 = GetPostString("backdate1");
  3969. string bdate2 = GetPostString("backdate2");
  3970. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3971. if (dw_back.Length > 0) lw.Add(dw_back);
  3972. string price1 = GetPostString("price1");
  3973. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3974. string price2 = GetPostString("price2");
  3975. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3976. lw.Add(string.Format("IsReturn>0"));
  3977. lw.Add(string.Format("IsXianHuo=0"));
  3978. lw.Add(string.Format("IsReturn!=3"));
  3979. string backtype = GetPostString("backtype");
  3980. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  3981. dStruct.Order = "FinishDesignTime desc";
  3982. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3983. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3984. writeGridDataTableJson(dStruct.TotalCount, dt);
  3985. }
  3986. public void get_erp_today_sumreturn()
  3987. {
  3988. DataStruct dStruct = GetPostStruct();
  3989. List<string> lw = new List<string>();
  3990. string bdate1 = GetPostString("returnTimeS");
  3991. string bdate2 = GetPostString("returnTimeE");
  3992. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3993. if (dw_back.Length > 0) lw.Add(dw_back);
  3994. lw.Add(string.Format("IsReturn=0"));
  3995. lw.Add(string.Format("IsXianHuo=0"));
  3996. string mainWhere = string.Join(" and ", lw.ToArray());
  3997. string sql = "";
  3998. if (dw_back.Length > 0)
  3999. {
  4000. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4001. }
  4002. else
  4003. {
  4004. 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 + "'";
  4005. }
  4006. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4007. decimal total = 0, today_finish = 0;
  4008. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4009. {
  4010. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4011. }
  4012. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4013. {
  4014. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4015. }
  4016. var res = new
  4017. {
  4018. data = total,
  4019. data1 = today_finish,
  4020. };
  4021. string ro_jsond = JsonConvert.SerializeObject(res);
  4022. returnSuccess(ro_jsond);
  4023. return;
  4024. }
  4025. public void get_erp_allreturnlist()
  4026. {
  4027. DataStruct dStruct = GetPostStruct();
  4028. List<string> lw = new List<string>();
  4029. string tid = GetPostString("ctid");
  4030. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4031. string shopname = GetPostString("shopname");
  4032. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4033. string buyernick = GetPostString("buyer_nick");
  4034. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4035. string customer = GetPostString("customer");
  4036. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4037. string design = GetPostString("design");
  4038. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4039. string orderState = GetPostString("orderState");
  4040. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4041. string address = GetPostString("address");
  4042. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4043. string sellermemo = GetPostString("seller_memo");
  4044. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4045. string supplier = GetPostString("supplier");
  4046. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4047. string date1 = GetPostString("date1");
  4048. string date2 = GetPostString("date2");
  4049. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4050. if (dw.Length > 0) lw.Add(dw);
  4051. string bdate1 = GetPostString("backdate1");
  4052. string bdate2 = GetPostString("backdate2");
  4053. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4054. if (dw_back.Length > 0) lw.Add(dw_back);
  4055. string price1 = GetPostString("price1");
  4056. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4057. string price2 = GetPostString("price2");
  4058. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4059. string backreason = GetPostString("backreason");
  4060. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4061. lw.Add(string.Format("IsXianHuo=0"));
  4062. lw.Add(string.Format("ReturnTime != ''"));
  4063. string backtype = GetPostString("backtype");
  4064. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4065. dStruct.Order = "FinishDesignTime desc";
  4066. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4067. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4068. writeGridDataTableJson(dStruct.TotalCount, dt);
  4069. }
  4070. public void get_erp_aftersalereturnlist()
  4071. {
  4072. DataStruct dStruct = GetPostStruct();
  4073. List<string> lw = new List<string>();
  4074. string tid = GetPostString("ctid");
  4075. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4076. string shopname = GetPostString("shopname");
  4077. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4078. string buyernick = GetPostString("buyer_nick");
  4079. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4080. string customer = GetPostString("customer");
  4081. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4082. string design = GetPostString("design");
  4083. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4084. string orderState = GetPostString("orderState");
  4085. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4086. string address = GetPostString("address");
  4087. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4088. string sellermemo = GetPostString("seller_memo");
  4089. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4090. string supplier = GetPostString("supplier");
  4091. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4092. string date1 = GetPostString("date1");
  4093. string date2 = GetPostString("date2");
  4094. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4095. if (dw.Length > 0) lw.Add(dw);
  4096. string bdate1 = GetPostString("backdate1");
  4097. string bdate2 = GetPostString("backdate2");
  4098. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4099. if (dw_back.Length > 0) lw.Add(dw_back);
  4100. string price1 = GetPostString("price1");
  4101. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4102. string price2 = GetPostString("price2");
  4103. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4104. lw.Add(string.Format("IsReturn=3"));
  4105. string backtype = GetPostString("backtype");
  4106. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4107. string backreason = GetPostString("backreason");
  4108. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4109. dStruct.Order = "ReturnTime desc";
  4110. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4111. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4112. writeGridDataTableJson(dStruct.TotalCount, dt);
  4113. }
  4114. public void get_erp_xianhuoreturnlist()
  4115. {
  4116. DataStruct dStruct = GetPostStruct();
  4117. List<string> lw = new List<string>();
  4118. string tid = GetPostString("ctid");
  4119. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4120. string shopname = GetPostString("shopname");
  4121. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4122. string buyernick = GetPostString("buyer_nick");
  4123. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4124. string customer = GetPostString("customer");
  4125. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4126. string design = GetPostString("design");
  4127. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4128. string orderState = GetPostString("orderState");
  4129. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4130. string address = GetPostString("address");
  4131. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4132. string sellermemo = GetPostString("seller_memo");
  4133. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4134. string supplier = GetPostString("supplier");
  4135. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4136. string OrderArea = GetPostString("order_area");
  4137. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4138. string date1 = GetPostString("date1");
  4139. string date2 = GetPostString("date2");
  4140. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4141. if (dw.Length > 0) lw.Add(dw);
  4142. string price1 = GetPostString("price1");
  4143. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4144. string price2 = GetPostString("price2");
  4145. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4146. string posTag = CurrentUser.UserPost.Post.Code;
  4147. if (posTag == "Supplier")
  4148. {
  4149. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4150. }
  4151. lw.Add(string.Format("OrderState=6 "));
  4152. lw.Add(string.Format("IsXianHuo=1 "));
  4153. lw.Add(string.Format("IsReturn>0 "));
  4154. lw.Add(string.Format("IsReturn!=3"));
  4155. lw.Add(string.Format("IsRefund<={0}", 1));
  4156. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4157. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4158. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4159. writeGridDataTableJson(dStruct.TotalCount, dt);
  4160. }
  4161. public void set_erp_orderdelivery()
  4162. {
  4163. if (UrlPostParmsCheck("ctid"))
  4164. {
  4165. string eid = GetPostString("ctid");
  4166. CeErpTradeCell entity = null;
  4167. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4168. if (entity != null)
  4169. {
  4170. if (entity.OrderState >= 7)
  4171. {
  4172. returnErrorMsg("此单已发货,无需重复发货");
  4173. return;
  4174. }
  4175. if (entity.OrderState != 6)
  4176. {
  4177. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4178. return;
  4179. }
  4180. string shop = GetPostString("seller_nick");
  4181. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4182. string comName = GetPostString("comName");
  4183. string comCode = GetPostString("comCode");
  4184. string outSid = GetPostString("outSid");
  4185. string deliveryType = GetPostString("deliveryType");
  4186. string deliveryMemo = GetPostString("deliveryMemo");
  4187. outSid = outSid.Trim();
  4188. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4189. if (mainEn == null)
  4190. {
  4191. returnErrorMsg("找不到原始订单记录");
  4192. return;
  4193. }
  4194. bool isInitOrderDeliv = false;
  4195. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4196. {
  4197. isInitOrderDeliv = true;
  4198. }
  4199. string apires = "";
  4200. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4201. 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)
  4202. {
  4203. apires = "发货成功true";
  4204. }
  4205. else
  4206. {
  4207. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4208. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4209. }
  4210. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4211. {
  4212. entity.OrderState = 7;//发货后订单已发货
  4213. entity.OutSid = outSid;
  4214. entity.MemoOpt = 0;
  4215. entity.FinishDeliveryTime = DateTime.Now;
  4216. entity.Update();
  4217. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4218. commonHelper.UpdateRelationOrder(entity.ctid);
  4219. //还要插入快递信息到 快递信息表
  4220. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4221. exinfo.tid = eid;
  4222. exinfo.out_sid = outSid;
  4223. exinfo.company_code = comCode;
  4224. exinfo.company_name = comName;
  4225. exinfo.delivery_memo = deliveryMemo;
  4226. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4227. exinfo.deliveryType = deliveryType;
  4228. exinfo.Create();
  4229. returnSuccessMsg("发货操作成功!");
  4230. commonHelper.UpdateRelationOrder(entity.ctid);
  4231. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4232. CeErpSukuraData.createInfo(entity.ctid, 4);
  4233. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4234. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4235. }
  4236. else
  4237. {
  4238. string errmsg = commonHelper.KeepChinese(apires);
  4239. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4240. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4241. }
  4242. return;
  4243. }
  4244. returnErrorMsg("找不到订单记录");
  4245. }
  4246. }
  4247. public void set_erp_multidelivery()
  4248. {
  4249. string eids = GetPostString("tids");
  4250. string[] eidList = eids.Split(',');
  4251. if (eidList.Length <= 0)
  4252. {
  4253. returnErrorMsg("发货不能为空");
  4254. return;
  4255. }
  4256. foreach (string ctid in eidList)
  4257. {
  4258. if (ctid.Length <= 0) continue;
  4259. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4260. if (expInfo != null)
  4261. {
  4262. StringBuilder sql = new StringBuilder();
  4263. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4264. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4265. if (dt.Rows.Count > 0)
  4266. {
  4267. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4268. {
  4269. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4270. expInfo.state = "异常";
  4271. expInfo.isMultiDelivery = 1;
  4272. expInfo.Update();
  4273. continue;
  4274. }
  4275. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4276. {
  4277. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4278. expInfo.state = "异常";
  4279. expInfo.Update();
  4280. continue;
  4281. }
  4282. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4283. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4284. bool isInitOrderDeliv = false;
  4285. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4286. {
  4287. isInitOrderDeliv = true;
  4288. expInfo.isMultiDelivery = 1;
  4289. }
  4290. if (ctid.IndexOf("N") != -1)
  4291. {
  4292. StringBuilder sqlbucha = new StringBuilder();
  4293. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4294. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4295. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4296. commonHelper.UpdateRelationOrder(ctid);
  4297. expInfo.delivery_memo = "发货成功";
  4298. expInfo.state = "发货成功";
  4299. expInfo.isMultiDelivery = 1;
  4300. expInfo.Update();
  4301. }
  4302. else
  4303. {
  4304. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4305. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4306. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4307. {
  4308. expInfo.delivery_memo = "发货成功";
  4309. expInfo.state = "发货成功";
  4310. expInfo.isMultiDelivery = 1;
  4311. expInfo.Update();
  4312. commonHelper.UpdateRelationOrder(ctid);
  4313. CeErpSukuraData.createInfo(ctid, 4);
  4314. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4315. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4316. }
  4317. else
  4318. {
  4319. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4320. expInfo.state = "异常";
  4321. expInfo.Update();
  4322. }
  4323. }
  4324. }
  4325. }
  4326. }
  4327. returnSuccessMsg("操作完成");
  4328. }
  4329. public void reset_erp_memoopt()
  4330. {
  4331. if (UrlPostParmsCheck("ctid"))
  4332. {
  4333. string eid = GetPostString("ctid");
  4334. CeErpTradeCell entity = null;
  4335. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4336. if (entity != null)
  4337. {
  4338. string stropt = "";
  4339. if (entity.MemoOpt == 1)
  4340. {
  4341. stropt = "“改稿”";
  4342. }
  4343. else if (entity.MemoOpt == 2)
  4344. {
  4345. stropt = "“定稿”";
  4346. }
  4347. else if (entity.MemoOpt == 3)
  4348. {
  4349. stropt = "“完成查货”";
  4350. CeErpSukuraData.createInfo(entity.ctid, 6);
  4351. }
  4352. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4353. entity.MemoOpt = 0;
  4354. entity.Update();
  4355. returnSuccessMsg("操作成功!");
  4356. return;
  4357. }
  4358. returnErrorMsg("找不到记录");
  4359. }
  4360. }
  4361. public void get_erp_deliveryunusual()
  4362. {
  4363. DataStruct dStruct = GetPostStruct();
  4364. List<string> lw = new List<string>();
  4365. string tid = GetPostString("ctid");
  4366. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4367. string shopname = GetPostString("shopname");
  4368. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4369. string buyernick = GetPostString("buyer_nick");
  4370. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4371. string customer = GetPostString("customer");
  4372. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4373. string design = GetPostString("design");
  4374. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4375. string sellermemo = GetPostString("seller_memo");
  4376. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4377. string supplier = GetPostString("supplier");
  4378. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4379. string date1 = GetPostString("date1");
  4380. string date2 = GetPostString("date2");
  4381. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4382. if (dw.Length > 0) lw.Add(dw);
  4383. string placedate1 = GetPostString("placedate1");
  4384. string placedate2 = GetPostString("placedate2");
  4385. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4386. if (dw_place.Length > 0) lw.Add(dw_place);
  4387. string price1 = GetPostString("price1");
  4388. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4389. string price2 = GetPostString("price2");
  4390. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4391. string unusualCon = GetPostString("unusualcon");
  4392. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4393. string posTag = CurrentUser.UserPost.Post.Code;
  4394. if (posTag == "Supplier")
  4395. {
  4396. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4397. }
  4398. lw.Add(string.Format("OrderState = 6"));
  4399. lw.Add(string.Format("UnusualTag = 5"));
  4400. lw.Add(string.Format("IsRefund<={0}", 1));
  4401. dStruct.Order = "FinishPlaceTime desc";
  4402. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4403. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4404. writeGridDataTableJson(dStruct.TotalCount, dt);
  4405. }
  4406. public void get_erp_deliveryedlist()
  4407. {
  4408. DataStruct dStruct = GetPostStruct();
  4409. List<string> lw = new List<string>();
  4410. string tid = GetPostString("ctid");
  4411. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4412. string shopname = GetPostString("shopname");
  4413. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4414. string buyernick = GetPostString("buyer_nick");
  4415. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4416. string customer = GetPostString("customer");
  4417. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4418. string design = GetPostString("design");
  4419. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4420. string sellermemo = GetPostString("seller_memo");
  4421. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4422. string logistics = GetPostString("logistics");
  4423. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4424. string date1 = GetPostString("date1");
  4425. string date2 = GetPostString("date2");
  4426. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4427. //if (dw.Length > 0) lw.Add(dw);
  4428. string placedate1 = GetPostString("placedate1");
  4429. string placedate2 = GetPostString("placedate2");
  4430. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4431. if (fdw.Length > 0) lw.Add(fdw);
  4432. string devdate1 = GetPostString("deliverydate1");
  4433. string devdate2 = GetPostString("deliverydate2");
  4434. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4435. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4436. string price1 = GetPostString("price1");
  4437. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4438. string price2 = GetPostString("price2");
  4439. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4440. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4441. {
  4442. if (tid.Length > 0)
  4443. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4444. if (buyernick.Length > 0)
  4445. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4446. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4447. if (dw.Length > 0) lw.Add(dw);
  4448. }
  4449. else
  4450. {
  4451. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4452. }
  4453. string posTag = CurrentUser.UserPost.Post.Code;
  4454. if (posTag == "Supplier")
  4455. {
  4456. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4457. }
  4458. else
  4459. {
  4460. string supplier = GetPostString("supplier");
  4461. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4462. }
  4463. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4464. lw.Add(string.Format("IsRefund!={0}", 2));
  4465. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4466. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4467. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4468. if (dt != null)
  4469. {
  4470. foreach (DataRow dr in dt.Rows)
  4471. {
  4472. 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();
  4473. }
  4474. }
  4475. writeGridDataTableJson(dStruct.TotalCount, dt);
  4476. }
  4477. public void get_erp_pdddeliveryed()
  4478. {
  4479. DataStruct dStruct = GetPostStruct();
  4480. List<string> lw = new List<string>();
  4481. string tid = GetPostString("ctid");
  4482. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4483. string shopname = GetPostString("shopname");
  4484. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4485. string buyernick = GetPostString("buyer_nick");
  4486. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4487. string customer = GetPostString("customer");
  4488. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4489. string design = GetPostString("design");
  4490. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4491. string sellermemo = GetPostString("seller_memo");
  4492. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4493. string logistics = GetPostString("logistics");
  4494. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4495. string date1 = GetPostString("date1");
  4496. string date2 = GetPostString("date2");
  4497. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4498. //if (dw.Length > 0) lw.Add(dw);
  4499. string placedate1 = GetPostString("placedate1");
  4500. string placedate2 = GetPostString("placedate2");
  4501. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4502. if (fdw.Length > 0) lw.Add(fdw);
  4503. string devdate1 = GetPostString("deliverydate1");
  4504. string devdate2 = GetPostString("deliverydate2");
  4505. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4506. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4507. string price1 = GetPostString("price1");
  4508. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4509. string price2 = GetPostString("price2");
  4510. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4511. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4512. {
  4513. if (tid.Length > 0)
  4514. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4515. if (buyernick.Length > 0)
  4516. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4517. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4518. if (dw.Length > 0) lw.Add(dw);
  4519. }
  4520. else
  4521. {
  4522. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4523. }
  4524. string posTag = CurrentUser.UserPost.Post.Code;
  4525. if (posTag == "Supplier")
  4526. {
  4527. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4528. }
  4529. else
  4530. {
  4531. string supplier = GetPostString("supplier");
  4532. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4533. }
  4534. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4535. lw.Add(string.Format("type = 'PDD' "));
  4536. lw.Add(string.Format("IsRefund!={0}", 2));
  4537. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4538. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4539. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4540. foreach (DataRow dr in dt.Rows)
  4541. {
  4542. 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();
  4543. }
  4544. writeGridDataTableJson(dStruct.TotalCount, dt);
  4545. }
  4546. public void get_erp_jddeliveryed()
  4547. {
  4548. DataStruct dStruct = GetPostStruct();
  4549. List<string> lw = new List<string>();
  4550. string tid = GetPostString("ctid");
  4551. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4552. string shopname = GetPostString("shopname");
  4553. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4554. string buyernick = GetPostString("buyer_nick");
  4555. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4556. string customer = GetPostString("customer");
  4557. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4558. string design = GetPostString("design");
  4559. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4560. string sellermemo = GetPostString("seller_memo");
  4561. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4562. string date1 = GetPostString("date1");
  4563. string date2 = GetPostString("date2");
  4564. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4565. //if (dw.Length > 0) lw.Add(dw);
  4566. string placedate1 = GetPostString("placedate1");
  4567. string placedate2 = GetPostString("placedate2");
  4568. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4569. if (fdw.Length > 0) lw.Add(fdw);
  4570. string devdate1 = GetPostString("deliverydate1");
  4571. string devdate2 = GetPostString("deliverydate2");
  4572. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4573. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4574. string price1 = GetPostString("price1");
  4575. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4576. string price2 = GetPostString("price2");
  4577. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4578. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4579. {
  4580. if (tid.Length > 0)
  4581. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4582. if (buyernick.Length > 0)
  4583. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4584. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4585. if (dw.Length > 0) lw.Add(dw);
  4586. }
  4587. else
  4588. {
  4589. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4590. }
  4591. string posTag = CurrentUser.UserPost.Post.Code;
  4592. if (posTag == "Supplier")
  4593. {
  4594. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4595. }
  4596. else
  4597. {
  4598. string supplier = GetPostString("supplier");
  4599. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4600. }
  4601. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4602. lw.Add(string.Format("type = 'JD' "));
  4603. lw.Add(string.Format("IsRefund!={0}", 2));
  4604. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4605. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4606. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4607. foreach (DataRow dr in dt.Rows)
  4608. {
  4609. 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();
  4610. }
  4611. writeGridDataTableJson(dStruct.TotalCount, dt);
  4612. }
  4613. public void get_erp_allplacelist()
  4614. {
  4615. DataStruct dStruct = GetPostStruct();
  4616. List<string> lw = new List<string>();
  4617. string tid = GetPostString("ctid");
  4618. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4619. string shopname = GetPostString("shopname");
  4620. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4621. string buyernick = GetPostString("buyer_nick");
  4622. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4623. string customer = GetPostString("customer");
  4624. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4625. string design = GetPostString("design");
  4626. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4627. string sellermemo = GetPostString("seller_memo");
  4628. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4629. string supplier = GetPostString("supplier");
  4630. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4631. string date1 = GetPostString("date1");
  4632. string date2 = GetPostString("date2");
  4633. string pldate1 = GetPostString("placedate1");
  4634. string pldate2 = GetPostString("placedate2");
  4635. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4636. //if (dw.Length > 0) lw.Add(dw);
  4637. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4638. {
  4639. if (tid.Length > 0)
  4640. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4641. if (buyernick.Length > 0)
  4642. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4643. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4644. if (dw.Length > 0) lw.Add(dw);
  4645. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4646. if (dw_place.Length > 0) lw.Add(dw_place);
  4647. }
  4648. else
  4649. {
  4650. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4651. {
  4652. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4653. }
  4654. }
  4655. string price1 = GetPostString("price1");
  4656. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4657. string price2 = GetPostString("price2");
  4658. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4659. string posTag = CurrentUser.UserPost.Post.Code;
  4660. if (posTag == "Supplier")
  4661. {
  4662. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4663. }
  4664. lw.Add(string.Format("OrderState >= 6"));
  4665. lw.Add(string.Format("IsSample != 2 "));
  4666. lw.Add(string.Format("isDianziOrder = 0 "));
  4667. //lw.Add(string.Format("IsRefund<={0}", 1));
  4668. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4669. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4670. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4671. foreach (DataRow dr in dt.Rows)
  4672. {
  4673. 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();
  4674. }
  4675. writeGridDataTableJson(dStruct.TotalCount, dt);
  4676. }
  4677. public void get_erp_financeallplacelist()
  4678. {
  4679. DataStruct dStruct = GetPostStruct();
  4680. List<string> lw = new List<string>();
  4681. string tid = GetPostString("ctid");
  4682. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4683. string shopname = GetPostString("shopname");
  4684. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4685. string buyernick = GetPostString("buyer_nick");
  4686. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4687. string customer = GetPostString("customer");
  4688. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4689. string design = GetPostString("design");
  4690. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4691. string sellermemo = GetPostString("seller_memo");
  4692. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4693. string supplier = GetPostString("supplier");
  4694. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4695. string date1 = GetPostString("date1");
  4696. string date2 = GetPostString("date2");
  4697. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4698. if (dw.Length > 0) lw.Add(dw);
  4699. string pldate1 = GetPostString("placedate1");
  4700. string pldate2 = GetPostString("placedate2");
  4701. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4702. if (dw_place.Length > 0) lw.Add(dw_place);
  4703. string price1 = GetPostString("price1");
  4704. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4705. string price2 = GetPostString("price2");
  4706. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4707. string posTag = CurrentUser.UserPost.Post.Code;
  4708. if (posTag == "Supplier")
  4709. {
  4710. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4711. }
  4712. //lw.Add(string.Format("OrderState >= 6"));
  4713. lw.Add(string.Format("IsSample != 2 "));
  4714. lw.Add(string.Format("isDianziOrder = 0 "));
  4715. //lw.Add(string.Format("IsRefund<={0}", 1));
  4716. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4717. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4718. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4719. foreach (DataRow dr in dt.Rows)
  4720. {
  4721. 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();
  4722. }
  4723. writeGridDataTableJson(dStruct.TotalCount, dt);
  4724. }
  4725. public void get_erp_expresslist()
  4726. {
  4727. int listtype = GetInt("ltype");
  4728. DataStruct dStruct = GetPostStruct();
  4729. List<string> lw = new List<string>();
  4730. string tid = GetPostString("tid");
  4731. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4732. string outsid = GetPostString("out_sid");
  4733. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4734. string importer = GetPostString("ImportUserName");
  4735. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4736. string file = GetPostString("import_file");
  4737. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4738. string printman = GetPostString("printman");
  4739. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4740. string date1 = GetPostString("date1");
  4741. string date2 = GetPostString("date2");
  4742. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4743. if (dw.Length > 0) lw.Add(dw);
  4744. string fdate1 = GetPostString("finishdate1");
  4745. string fdate2 = GetPostString("finishdate2");
  4746. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4747. if (fdw.Length > 0) lw.Add(fdw);
  4748. if (listtype == 1)
  4749. {
  4750. lw.Add(string.Format("importUserId !=0"));
  4751. }
  4752. string posTag = CurrentUser.UserPost.Post.Code;
  4753. if (posTag == "Supplier")
  4754. {
  4755. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4756. }
  4757. if (dStruct.PageSize != 100000)
  4758. {
  4759. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4760. }
  4761. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4762. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4763. writeGridDataTableJson(dStruct.TotalCount, dt);
  4764. }
  4765. public void set_erp_buchaorderdelivery()
  4766. {
  4767. if (UrlPostParmsCheck("ctid"))
  4768. {
  4769. string eid = GetPostString("ctid");
  4770. CeErpTradeCell entity = null;
  4771. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4772. if (entity != null)
  4773. {
  4774. if (entity.IsSample != 2)
  4775. {
  4776. returnErrorMsg("补差价单才能标记为已发货");
  4777. return;
  4778. }
  4779. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4780. entity.OrderState = 7;
  4781. entity.Update();
  4782. returnSuccessMsg("操作成功!");
  4783. return;
  4784. }
  4785. returnErrorMsg("找不到记录");
  4786. }
  4787. }
  4788. public void get_stdtemplates()
  4789. {
  4790. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4791. //string res = taobaoHelper.test();
  4792. string res = apiHelper.API_PrintTemplate();
  4793. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4794. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4795. {
  4796. int sidx = res.IndexOf("error_code");
  4797. int eidx = res.IndexOf("success");
  4798. string msg = res.Substring(sidx, eidx - sidx);
  4799. returnErrorMsg(msg);
  4800. return;
  4801. }
  4802. if (res.Length <= 0)
  4803. {
  4804. returnErrorMsg("模板数据为空!");
  4805. return;
  4806. }
  4807. ReturnSuccess(res);
  4808. }
  4809. public void cancel_print_order()
  4810. {
  4811. if (UrlPostParmsCheck("ctid"))
  4812. {
  4813. string ctid = GetPostString("ctid");
  4814. CeErpTradeCell entity = null;
  4815. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4816. if (entity != null)
  4817. {
  4818. string res = "";
  4819. string code = entity.LastBillWaybillCode;
  4820. if (code == "")
  4821. {
  4822. code = entity.OutSid;
  4823. }
  4824. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  4825. XLog.SaveLog(0, "取消面单" + res);
  4826. }
  4827. }
  4828. }
  4829. public void set_erp_printwaybill()
  4830. {
  4831. if (UrlPostParmsCheck("ctid"))
  4832. {
  4833. string ctid = GetPostString("ctid");
  4834. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  4835. string cpName = GetPostString("cpname");
  4836. string isTogether = GetPostString("together");
  4837. //var res_obj = new
  4838. //{
  4839. // restype = 1,
  4840. // 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\"}"
  4841. //};
  4842. //string ro_json = JsonConvert.SerializeObject(res_obj);
  4843. //ReturnSuccess(ro_json);
  4844. //return;
  4845. bool isUseLastWayBillCode = false;
  4846. CeErpTradeCell entity = null;
  4847. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4848. if (entity != null)
  4849. {
  4850. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  4851. {
  4852. isUseLastWayBillCode = true;
  4853. }
  4854. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  4855. {
  4856. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  4857. return;
  4858. }
  4859. }
  4860. string res = "";
  4861. Api_waybill_code_response_Obj fullObj = null;
  4862. string pData_str = "";
  4863. string curUseWayBillCode = "";
  4864. if (isUseLastWayBillCode == false)
  4865. {
  4866. res = apiHelper.API_GetWaybill(cpCode, ctid);
  4867. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  4868. if (res.IndexOf("failure") != -1)
  4869. {
  4870. //int idx = res.IndexOf("sub_message");
  4871. //int idx2 = res.IndexOf("flag");
  4872. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  4873. string errMsgNeed = commonHelper.KeepChinese(res);
  4874. var res_objd = new
  4875. {
  4876. restype = 0,
  4877. data = "获取面单失败" + errMsgNeed
  4878. };
  4879. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  4880. returnSuccess(ro_jsond);
  4881. if (res.IndexOf("停发") != -1)
  4882. {
  4883. entity.UnusualCon = "物流停发";
  4884. entity.Update();
  4885. }
  4886. //returnErrorMsg("获取面单失败,"+emsg);
  4887. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  4888. return;
  4889. }
  4890. else if (res.IndexOf("errorMsg") != -1)
  4891. {
  4892. //int idx = res.IndexOf("errorMsg");
  4893. //int idx2 = res.IndexOf("}]}");
  4894. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  4895. string errMsgNeed = commonHelper.KeepChinese(res);
  4896. var res_objf = new
  4897. {
  4898. restype = 0,
  4899. data = "获取面单失败2" + errMsgNeed
  4900. };
  4901. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4902. if (res.IndexOf("停发") != -1)
  4903. {
  4904. entity.UnusualCon = "物流停发";
  4905. entity.Update();
  4906. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4907. if (trade != null)
  4908. {
  4909. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  4910. }
  4911. }
  4912. returnSuccess(ro_jsonf);
  4913. //returnErrorMsg("获取面单失败," + emsg);
  4914. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  4915. return;
  4916. }
  4917. try
  4918. {
  4919. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4920. //res = res.Replace(" ", "");
  4921. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  4922. }
  4923. catch (Exception ex)
  4924. {
  4925. XLog.SaveLog(0, "生成fullObj" + res);
  4926. var res_objf = new
  4927. {
  4928. restype = 0,
  4929. data = "生成fullObj发生错误" + ex.Message
  4930. };
  4931. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4932. returnSuccess(ro_jsonf);
  4933. return;
  4934. }
  4935. if (fullObj.response.data.content.Count > 0)
  4936. {
  4937. ContentItem codeObj = fullObj.response.data.content[0];
  4938. if (cpCode.IndexOf("SFFQ-") != -1)
  4939. {
  4940. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  4941. }
  4942. else
  4943. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  4944. curUseWayBillCode = codeObj.waybillCode;
  4945. }
  4946. else
  4947. {
  4948. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  4949. var res_objf = new
  4950. {
  4951. restype = 0,
  4952. data = "生成fullObj找不到快递单号waybillCode"
  4953. };
  4954. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4955. returnSuccess(ro_jsonf);
  4956. return;
  4957. }
  4958. }
  4959. else
  4960. {
  4961. //使用上次打印的快递单号
  4962. if (cpCode == "SFFQ-LY")
  4963. {
  4964. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  4965. }
  4966. else
  4967. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  4968. curUseWayBillCode = entity.LastBillWaybillCode;
  4969. }
  4970. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  4971. {
  4972. var res_obje = new
  4973. {
  4974. restype = 0,
  4975. data = "获取加密打印数据失败"
  4976. };
  4977. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  4978. returnSuccess(ro_jsone);
  4979. entity.LastBillCpCode = cpCode;
  4980. entity.LastBillWaybillCode = curUseWayBillCode;
  4981. entity.Update();
  4982. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  4983. //returnErrorMsg("获取加密打印数据失败");
  4984. return;
  4985. }
  4986. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  4987. //string msg = "{\"data\":\""+pageUrl+"\"}";
  4988. string btnType = "";
  4989. if (entity != null)
  4990. {
  4991. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4992. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4993. //cpcode是 YTO-CAINIAO
  4994. //string comCode = cpCode.Split('-')[0].ToString();
  4995. string apires = "";
  4996. if (ctid.IndexOf("N") != -1)
  4997. {
  4998. apires = "发货成功";
  4999. }
  5000. else
  5001. {
  5002. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5003. }
  5004. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5005. //打单后发货
  5006. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5007. {
  5008. try
  5009. {
  5010. btnType = "待发货";
  5011. entity.OutSid = curUseWayBillCode;
  5012. entity.OrderState = 7;
  5013. entity.IsUrgency = false;
  5014. entity.LastBillCpCode = "";
  5015. entity.LastBillWaybillCode = "";
  5016. entity.FinishDeliveryTime = DateTime.Now;
  5017. entity.IsReturn = 0;
  5018. entity.MemoOpt = 0;
  5019. entity.Update();
  5020. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5021. //还要插入快递信息到 快递信息表
  5022. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5023. exinfo.tid = entity.ctid;
  5024. exinfo.out_sid = entity.OutSid;
  5025. exinfo.company_code = cpCode;
  5026. exinfo.company_name = cpName;
  5027. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5028. exinfo.deliveryType = "发货成功";
  5029. exinfo.print_time = DateTime.Now;
  5030. exinfo.printUser = CurrentUser.UserName;
  5031. exinfo.Create();
  5032. commonHelper.UpdateRelationOrder(entity.ctid);
  5033. CeErpSukuraData.createInfo(ctid, 4);
  5034. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5035. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5036. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5037. if (isTogether == "1")
  5038. {
  5039. StringBuilder sqlsb = new StringBuilder();
  5040. 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);
  5041. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5042. }
  5043. }
  5044. catch (Exception ex)
  5045. {
  5046. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5047. }
  5048. }
  5049. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5050. {
  5051. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5052. if (entity.OrderState == 6)
  5053. {
  5054. entity.OrderState = 7;
  5055. }
  5056. entity.FinishDeliveryTime = DateTime.Now;
  5057. btnType = "已发货";
  5058. entity.Update();
  5059. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5060. exinfo.tid = entity.ctid;
  5061. exinfo.out_sid = entity.OutSid;
  5062. exinfo.company_code = cpCode;
  5063. exinfo.company_name = cpName;
  5064. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5065. exinfo.deliveryType = "发货成功";
  5066. exinfo.print_time = DateTime.Now;
  5067. exinfo.printUser = CurrentUser.UserName;
  5068. exinfo.Create();
  5069. commonHelper.UpdateRelationOrder(entity.ctid);
  5070. CeErpSukuraData.createInfo(entity.ctid, 4);
  5071. if (isTogether == "1")
  5072. {
  5073. StringBuilder sqlsb = new StringBuilder();
  5074. 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);
  5075. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5076. }
  5077. //不处理
  5078. }
  5079. else
  5080. {
  5081. entity.LastBillCpCode = cpCode;
  5082. entity.LastBillWaybillCode = curUseWayBillCode;
  5083. entity.Update();
  5084. string errmsg = commonHelper.KeepChinese(apires);
  5085. var res_objz = new
  5086. {
  5087. restype = 0,
  5088. data = "打单后发货失败"
  5089. };
  5090. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5091. returnSuccess(ro_jsonz);
  5092. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5093. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5094. return;
  5095. }
  5096. }
  5097. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5098. var res_obj = new
  5099. {
  5100. restype = 1,
  5101. data = pData_str
  5102. };
  5103. string ro_json = JsonConvert.SerializeObject(res_obj);
  5104. ReturnSuccess(ro_json);
  5105. return;
  5106. }
  5107. }
  5108. private string GetUTF8String(byte[] vs)
  5109. {
  5110. throw new NotImplementedException();
  5111. }
  5112. public void set_erp_printwaybill_cn()
  5113. {
  5114. if (UrlPostParmsCheck("ctid"))
  5115. {
  5116. string ctid = GetPostString("ctid");
  5117. string cpCode = GetPostString("cpcode");
  5118. string cpName = GetPostString("cpname");
  5119. string tempUrl = GetPostString("tempurl");
  5120. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5121. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5122. //string res = taobaoHelper.test();
  5123. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5124. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5125. {
  5126. int sidx = res.IndexOf("errorMsg");
  5127. int eidx = res.IndexOf("}");
  5128. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5129. var res_objzxx = new
  5130. {
  5131. restype = 0,
  5132. data = msg
  5133. };
  5134. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5135. returnSuccess(ro_jsonzxx);
  5136. //returnErrorMsg(msg);
  5137. return;
  5138. }
  5139. int idx = res.IndexOf("waybillCode");
  5140. int idx2 = res.IndexOf("printData");
  5141. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5142. string eid = GetPostString("ctid");
  5143. CeErpTradeCell entity = null;
  5144. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5145. if (entity != null)
  5146. {
  5147. string osid = entity.OutSid;
  5148. entity.OutSid = osid + "," + outsid;
  5149. entity.FinishDeliveryTime = DateTime.Now;
  5150. entity.OrderState = 7;
  5151. entity.IsReturn = 0;
  5152. entity.Update();
  5153. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5154. exinfo.tid = entity.ctid;
  5155. exinfo.out_sid = outsid;
  5156. exinfo.company_code = cpCode;
  5157. exinfo.company_name = cpName;
  5158. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5159. exinfo.deliveryType = "发货成功";
  5160. exinfo.print_time = DateTime.Now;
  5161. exinfo.printUser = CurrentUser.UserName;
  5162. exinfo.Create();
  5163. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5164. }
  5165. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5166. var res_objz = new
  5167. {
  5168. restype = 1,
  5169. data = res
  5170. };
  5171. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5172. returnSuccess(ro_jsonz);
  5173. //ReturnSuccess(res);
  5174. }
  5175. }
  5176. ////打单,打印面单 获取面单号
  5177. //public void set_erp_printwaybill()
  5178. //{
  5179. // if (UrlPostParmsCheck("ctid"))
  5180. // {
  5181. // string ctid = GetPostString("ctid");
  5182. // string cpCode = GetPostString("cpcode");
  5183. // string tempUrl = GetPostString("tempurl");
  5184. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5185. // //string res = taobaoHelper.test();
  5186. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5187. // if (res.IndexOf("error_response") != -1)
  5188. // {
  5189. // int sidx = res.IndexOf("sub_msg");
  5190. // int eidx = res.IndexOf("request_id");
  5191. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5192. // returnErrorMsg(msg);
  5193. // return;
  5194. // }
  5195. // int idx = res.IndexOf("waybill_code");
  5196. // int idx2 = res.IndexOf("}]}");
  5197. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5198. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5199. // ReturnSuccess(res);
  5200. // }
  5201. //}
  5202. public void cancel_erp_aftersale()
  5203. {
  5204. if (UrlPostParmsCheck("ctid"))
  5205. {
  5206. string eid = GetPostString("ctid");
  5207. CeErpTradeCell entity = null;
  5208. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5209. if (entity != null)
  5210. {
  5211. //有过处理的售后,取消也不能删除 售 字,保留
  5212. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5213. {
  5214. entity.AfterSaleState = 4;
  5215. }
  5216. else
  5217. entity.AfterSaleState = 0;
  5218. entity.Update();
  5219. returnSuccessMsg("操作成功!");
  5220. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5221. return;
  5222. }
  5223. returnErrorMsg("找不到订单记录");
  5224. }
  5225. }
  5226. public void get_erp_aftersalelist()
  5227. {
  5228. DataStruct dStruct = GetPostStruct();
  5229. List<string> lw = new List<string>();
  5230. int st = GetInt("st");
  5231. string tid = GetPostString("ctid");
  5232. if (st == 3)
  5233. {
  5234. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5235. }
  5236. else
  5237. {
  5238. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5239. }
  5240. string shopname = GetPostString("shopname");
  5241. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5242. string buyernick = GetPostString("buyer_nick");
  5243. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5244. string sellermemo = GetPostString("seller_memo");
  5245. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5246. string orderState = GetPostString("orderState");
  5247. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5248. string afterState = GetPostString("afterstate");
  5249. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5250. string date1 = GetPostString("date1");
  5251. string date2 = GetPostString("date2");
  5252. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5253. if (dw.Length > 0) lw.Add(dw);
  5254. string price1 = GetPostString("price1");
  5255. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5256. string price2 = GetPostString("price2");
  5257. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5258. //lw.Add(string.Format("IsRefund!={0}", 1));
  5259. string reason = GetPostString("reason");
  5260. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5261. string method = GetPostString("method");
  5262. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5263. string handler = GetPostString("handler");
  5264. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5265. string handledate1 = GetPostString("handledate1");
  5266. string handledate2 = GetPostString("handledate2");
  5267. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5268. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5269. string finish1 = GetPostString("finishdate1");
  5270. string finish2 = GetPostString("finishdate2");
  5271. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5272. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5273. string afterdate1 = GetPostString("afterdate1");
  5274. string afterdate2 = GetPostString("afterdate2");
  5275. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5276. if (afterDate.Length > 0) lw.Add(afterDate);
  5277. string supplier = GetPostString("supplier");
  5278. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5279. string responsible = GetPostString("responsibleman");
  5280. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5281. string customer = GetPostString("customer");
  5282. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5283. string design = GetPostString("design");
  5284. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5285. string afterMemoType = GetPostString("aftermemotype");
  5286. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5287. string posCode = CurrentUser.UserPost.Post.Code;
  5288. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5289. //{
  5290. // string vstate = GetPostString("vstate");
  5291. // if (vstate.Length > 0)
  5292. // {
  5293. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5294. // }
  5295. // if (posCode == "Supplier")
  5296. // {
  5297. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5298. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5299. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5300. // }
  5301. // else
  5302. // {
  5303. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5304. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5305. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5306. // {
  5307. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5308. // }
  5309. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5310. // {
  5311. // int orgid = CurrentUser.UserPost.OrgID;
  5312. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5313. // }
  5314. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5315. // {
  5316. // string shopid = CurrentUser.User.pemShop;
  5317. // lw.Add(string.Format("shopId in ({0})", shopid));
  5318. // }
  5319. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5320. // //{
  5321. // // int org_id = CurrentUser.UserPost.OrgID;
  5322. // // lw.Add(string.Format("OrgID={0}", org_id));
  5323. // //}
  5324. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5325. // }
  5326. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5327. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5328. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5329. //}
  5330. if (st == 5)
  5331. {
  5332. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5333. {
  5334. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5335. {
  5336. string shopid = CurrentUser.User.pemShop;
  5337. lw.Add(string.Format("shopId in ({0})", shopid));
  5338. }
  5339. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5340. {
  5341. int mrOrgid = CurrentUser.UserPost.OrgID;
  5342. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5343. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5344. }
  5345. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5346. //{
  5347. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5348. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5349. //}
  5350. else
  5351. {
  5352. string userIdStr = "";
  5353. if (posCode == "CustomerService")
  5354. {
  5355. userIdStr = CurrentUser.UserID + "_k";
  5356. }
  5357. else if (posCode == "Designer" || posCode == "wxDesigner")
  5358. {
  5359. userIdStr = CurrentUser.UserID + "_s";
  5360. }
  5361. else if (posCode == "Place")
  5362. {
  5363. userIdStr = CurrentUser.UserID + "_x";
  5364. }
  5365. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5366. }
  5367. }
  5368. string placedate1 = GetPostString("placedate1");
  5369. string placedate2 = GetPostString("placedate2");
  5370. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5371. if (dwplace.Length > 0) lw.Add(dwplace);
  5372. string supState = GetPostString("supState");
  5373. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5374. string searchType = GetPostString("searchType");
  5375. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5376. {
  5377. lw.Add(string.Format("BackNum>1"));
  5378. }
  5379. lw.Add(string.Format("AfterSaleState>0"));
  5380. if (ex_psize > 0)
  5381. {
  5382. if (CurrentUser.UserPost.Post.Code == "Finance")
  5383. dStruct.Order = "pay_time desc";
  5384. else
  5385. dStruct.Order = "HandleTime desc";
  5386. }
  5387. else
  5388. dStruct.Order = "HandleTime desc";
  5389. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5390. DataTable dt = WebCache.GetData("view_test", dStruct);
  5391. writeGridDataTableJson(dStruct.TotalCount, dt);
  5392. }
  5393. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5394. //{
  5395. // lw.Add(string.Format("AfterSaleState=4"));
  5396. // string code = CurrentUser.UserPost.Post.Code;
  5397. // if (code == "CustomerService")
  5398. // {
  5399. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5400. // }
  5401. // else if (code == "Designer" || code == "DesignerMr")
  5402. // {
  5403. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5404. // }
  5405. // else if (code == "Place" || code == "PlaceMr")
  5406. // {
  5407. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5408. // }
  5409. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5410. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5411. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5412. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5413. //}
  5414. //else //处理中的售后,待处理和处理中合并
  5415. //{
  5416. // if (afterState.Length <= 0)
  5417. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5418. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5419. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5420. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5421. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5422. //}
  5423. }
  5424. public void get_erp_disagreeftersalelist()
  5425. {
  5426. DataStruct dStruct = GetPostStruct();
  5427. List<string> lw = new List<string>();
  5428. int st = 2;
  5429. string tid = GetPostString("ctid");
  5430. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5431. string shopname = GetPostString("shopname");
  5432. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5433. string buyernick = GetPostString("buyer_nick");
  5434. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5435. string sellermemo = GetPostString("seller_memo");
  5436. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5437. string orderState = GetPostString("orderState");
  5438. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5439. string afterState = GetPostString("afterstate");
  5440. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5441. string date1 = GetPostString("date1");
  5442. string date2 = GetPostString("date2");
  5443. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5444. if (dw.Length > 0) lw.Add(dw);
  5445. string price1 = GetPostString("price1");
  5446. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5447. string price2 = GetPostString("price2");
  5448. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5449. //lw.Add(string.Format("IsRefund!={0}", 1));
  5450. string reason = GetPostString("reason");
  5451. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5452. string method = GetPostString("method");
  5453. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5454. string handler = GetPostString("handler");
  5455. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5456. string handledate1 = GetPostString("handledate1");
  5457. string handledate2 = GetPostString("handledate2");
  5458. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5459. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5460. string afterdate1 = GetPostString("afterdate1");
  5461. string afterdate2 = GetPostString("afterdate2");
  5462. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5463. if (afterDate.Length > 0) lw.Add(afterDate);
  5464. string backdate1 = GetPostString("backdate1");
  5465. string backdate2 = GetPostString("backdate2");
  5466. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5467. if (backDate.Length > 0) lw.Add(backDate);
  5468. string supplier = GetPostString("supplier");
  5469. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5470. string responsible = GetPostString("responsibleman");
  5471. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5472. string customer = GetPostString("customer");
  5473. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5474. string design = GetPostString("design");
  5475. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5476. string afterSaleMemo = GetPostString("afterSaleMemo");
  5477. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5478. string afterMemoType = GetPostString("aftermemotype");
  5479. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5480. string aftersakereason = GetPostString("aftersakereason");
  5481. if (aftersakereason.Length > 0)
  5482. {
  5483. if (aftersakereason == "1")
  5484. {
  5485. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5486. }
  5487. if (aftersakereason == "2")
  5488. {
  5489. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5490. }
  5491. }
  5492. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5493. string poscode = CurrentUser.UserPost.Post.Code;
  5494. if (poscode != "SysAdmin")
  5495. {
  5496. string shopid = CurrentUser.User.pemShop;
  5497. lw.Add(string.Format("shopId in ({0})", shopid));
  5498. }
  5499. string searchType = GetPostString("searchType");
  5500. if (searchType == "wait")
  5501. {
  5502. lw.Add(string.Format("HandleTime is null"));
  5503. }
  5504. if (searchType == "handling")
  5505. {
  5506. lw.Add(string.Format("HandleTime is not null "));
  5507. }
  5508. if (searchType == "back" || searchType == "puBack")
  5509. {
  5510. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5511. }
  5512. if (searchType == "reBack")
  5513. {
  5514. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5515. }
  5516. if (searchType == "moreBack")
  5517. {
  5518. lw.Add(string.Format("backNum > 1"));
  5519. }
  5520. lw.Add(string.Format("(AfterSaleState=5)"));
  5521. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5522. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5523. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5524. writeGridDataTableJson(dStruct.TotalCount, dt);
  5525. }
  5526. public void get_erp_handlingaftersalelist()
  5527. {
  5528. DataStruct dStruct = GetPostStruct();
  5529. List<string> lw = new List<string>();
  5530. int st = 2;
  5531. string tid = GetPostString("ctid");
  5532. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5533. string shopname = GetPostString("shopname");
  5534. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5535. string buyernick = GetPostString("buyer_nick");
  5536. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5537. string sellermemo = GetPostString("seller_memo");
  5538. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5539. string orderState = GetPostString("orderState");
  5540. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5541. string afterState = GetPostString("afterstate");
  5542. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5543. string date1 = GetPostString("date1");
  5544. string date2 = GetPostString("date2");
  5545. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5546. if (dw.Length > 0) lw.Add(dw);
  5547. string price1 = GetPostString("price1");
  5548. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5549. string price2 = GetPostString("price2");
  5550. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5551. //lw.Add(string.Format("IsRefund!={0}", 1));
  5552. string reason = GetPostString("reason");
  5553. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5554. string method = GetPostString("method");
  5555. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5556. string handler = GetPostString("handler");
  5557. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5558. string handledate1 = GetPostString("handledate1");
  5559. string handledate2 = GetPostString("handledate2");
  5560. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5561. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5562. string afterdate1 = GetPostString("afterdate1");
  5563. string afterdate2 = GetPostString("afterdate2");
  5564. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5565. if (afterDate.Length > 0) lw.Add(afterDate);
  5566. string supplier = GetPostString("supplier");
  5567. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5568. string responsible = GetPostString("responsibleman");
  5569. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5570. string customer = GetPostString("customer");
  5571. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5572. string design = GetPostString("design");
  5573. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5574. string afterSaleMemo = GetPostString("afterSaleMemo");
  5575. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5576. string afterMemoType = GetPostString("aftermemotype");
  5577. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5578. string afterresult = GetPostString("afterresult");
  5579. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5580. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5581. string poscode = CurrentUser.UserPost.Post.Code;
  5582. if (poscode != "SysAdmin")
  5583. {
  5584. string shopid = CurrentUser.User.pemShop;
  5585. lw.Add(string.Format("shopId in ({0})", shopid));
  5586. }
  5587. string searchType = GetPostString("searchType");
  5588. if (searchType == "wait")
  5589. {
  5590. lw.Add(string.Format("HandleTime is null"));
  5591. }
  5592. if (searchType == "documentary")
  5593. {
  5594. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5595. }
  5596. if (searchType == "handling")
  5597. {
  5598. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5599. }
  5600. if (searchType == "back" || searchType == "puBack")
  5601. {
  5602. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5603. }
  5604. if (searchType == "reBack")
  5605. {
  5606. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5607. }
  5608. if (afterState.Length <= 0)
  5609. {
  5610. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5611. }
  5612. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5613. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5614. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5615. writeGridDataTableJson(dStruct.TotalCount, dt);
  5616. }
  5617. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5618. //public void get_erp_back_handlingaftersalelist()
  5619. //{
  5620. // DataStruct dStruct = GetPostStruct();
  5621. // List<string> lw = new List<string>();
  5622. // string tid = GetPostString("ctid");
  5623. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5624. // string shopname = GetPostString("shopname");
  5625. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5626. // string buyernick = GetPostString("buyer_nick");
  5627. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5628. // string sellermemo = GetPostString("seller_memo");
  5629. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5630. // string orderState = GetPostString("orderState");
  5631. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5632. // string afterState = GetPostString("afterstate");
  5633. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5634. // string date1 = GetPostString("date1");
  5635. // string date2 = GetPostString("date2");
  5636. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5637. // if (dw.Length > 0) lw.Add(dw);
  5638. // string price1 = GetPostString("price1");
  5639. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5640. // string price2 = GetPostString("price2");
  5641. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5642. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5643. // string reason = GetPostString("reason");
  5644. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5645. // string method = GetPostString("method");
  5646. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5647. // string handler = GetPostString("handler");
  5648. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5649. // string handledate1 = GetPostString("handledate1");
  5650. // string handledate2 = GetPostString("handledate2");
  5651. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5652. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5653. // string afterdate1 = GetPostString("afterdate1");
  5654. // string afterdate2 = GetPostString("afterdate2");
  5655. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5656. // if (afterDate.Length > 0) lw.Add(afterDate);
  5657. // string supplier = GetPostString("supplier");
  5658. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5659. // string responsible = GetPostString("responsibleman");
  5660. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5661. // string customer = GetPostString("customer");
  5662. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5663. // string design = GetPostString("design");
  5664. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5665. // string afterMemoType = GetPostString("aftermemotype");
  5666. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5667. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5668. // if (afterState.Length <= 0)
  5669. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5670. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5671. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5672. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5673. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5674. //}
  5675. public void get_erp_aftersaleverifylist()
  5676. {
  5677. DataStruct dStruct = GetPostStruct();
  5678. List<string> lw = new List<string>();
  5679. string tid = GetPostString("ctid");
  5680. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5681. string shopname = GetPostString("shopname");
  5682. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5683. string buyernick = GetPostString("buyer_nick");
  5684. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5685. string sellermemo = GetPostString("seller_memo");
  5686. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5687. string orderState = GetPostString("orderState");
  5688. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5689. //lw.Add(string.Format("IsRefund!={0}", 1));
  5690. string reason = GetPostString("reason");
  5691. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5692. string method = GetPostString("method");
  5693. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5694. string handler = GetPostString("handler");
  5695. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5696. string handledate1 = GetPostString("handledate1");
  5697. string handledate2 = GetPostString("handledate2");
  5698. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5699. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5700. string finish1 = GetPostString("finishdate1");
  5701. string finish2 = GetPostString("finishdate2");
  5702. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5703. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5704. string supplier = GetPostString("supplier");
  5705. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5706. string responsible = GetPostString("responsibleman");
  5707. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5708. string posCode = CurrentUser.UserPost.Post.Code;
  5709. string vstate = GetPostString("vstate");
  5710. if (vstate.Length > 0)
  5711. {
  5712. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5713. }
  5714. if (posCode == "Supplier")
  5715. {
  5716. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5717. lw.Add(string.Format("VerifyState = 0"));
  5718. lw.Add("type = 1");
  5719. lw.Add(string.Format("AfterSaleState={0}", 3));
  5720. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5721. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5722. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5723. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5724. writeGridDataTableJson(dStruct.TotalCount, dt);
  5725. }
  5726. else if (posCode == "logistics")
  5727. {
  5728. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5729. lw.Add(string.Format("VerifyState = 0"));
  5730. lw.Add("type = 2");
  5731. lw.Add(string.Format("AfterSaleState={0}", 3));
  5732. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5733. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5734. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5735. writeGridDataTableJson(dStruct.TotalCount, dt);
  5736. }
  5737. else
  5738. {
  5739. lw.Add(string.Format("(AfterSaleState = 3)"));
  5740. string reasonState = GetPostString("reasonState");
  5741. lw.Add("type = 0");
  5742. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5743. || posCode == "Summarize" || posCode == "Finance")
  5744. {
  5745. if (reasonState == "2")
  5746. {
  5747. lw.Add("VerifyState = 3");
  5748. }
  5749. else if (reasonState == "1")
  5750. {
  5751. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5752. }
  5753. else
  5754. {
  5755. lw.Add("VerifyState in (0,3)");
  5756. }
  5757. //不加条件,可以看全部
  5758. }
  5759. 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")
  5760. {
  5761. int orgid = CurrentUser.UserPost.OrgID;
  5762. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5763. if (string.IsNullOrEmpty(manageOrgId))
  5764. {
  5765. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5766. }
  5767. else
  5768. {
  5769. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5770. }
  5771. if (reasonState == "1")
  5772. {
  5773. lw.Add("VerifyState = 3");
  5774. }
  5775. else if (reasonState == "2")
  5776. {
  5777. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5778. }
  5779. else
  5780. {
  5781. }
  5782. }
  5783. else
  5784. {
  5785. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5786. }
  5787. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5788. //{
  5789. // int org_id = CurrentUser.UserPost.OrgID;
  5790. // lw.Add(string.Format("OrgID={0}", org_id));
  5791. //}
  5792. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  5793. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5794. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5795. writeGridDataTableJson(dStruct.TotalCount, dt);
  5796. }
  5797. }
  5798. public void get_erp_finishaftersalelist()
  5799. {
  5800. DataStruct dStruct = GetPostStruct();
  5801. List<string> lw = new List<string>();
  5802. int st = 4;
  5803. string tid = GetPostString("ctid");
  5804. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  5805. string shopname = GetPostString("shopname");
  5806. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5807. //lw.Add(string.Format("IsRefund!={0}", 1));
  5808. string reason = GetPostString("reason");
  5809. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5810. string method = GetPostString("method");
  5811. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5812. string buyernick = GetPostString("buyer_nick");
  5813. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5814. string handler = GetPostString("handler");
  5815. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5816. string handledate1 = GetPostString("handledate1");
  5817. string handledate2 = GetPostString("handledate2");
  5818. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5819. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5820. string finish1 = GetPostString("finishdate1");
  5821. string finish2 = GetPostString("finishdate2");
  5822. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5823. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5824. string supplier = GetPostString("supplier");
  5825. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5826. string responsible = GetPostString("responsibleman");
  5827. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5828. string vstate = GetPostString("vstate");
  5829. if (vstate.Length > 0)
  5830. {
  5831. if ("3".Equals(vstate))
  5832. {
  5833. lw.Add(string.Format("IsTem=1"));
  5834. }
  5835. else
  5836. {
  5837. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5838. }
  5839. }
  5840. lw.Add(string.Format("AfterSaleState=4"));
  5841. string code = CurrentUser.UserPost.Post.Code;
  5842. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  5843. {
  5844. //不加条件,可以看全部
  5845. }
  5846. else if (code == "Supplier")
  5847. {
  5848. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5849. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5850. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5851. }
  5852. else if (code == "logistics")
  5853. {
  5854. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  5855. lw.Add("type = 2");
  5856. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5857. }
  5858. 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")
  5859. {
  5860. int orgid = CurrentUser.UserPost.OrgID;
  5861. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  5862. if (string.IsNullOrEmpty(manageOrgIds))
  5863. {
  5864. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  5865. }
  5866. else
  5867. {
  5868. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  5869. }
  5870. }
  5871. else
  5872. {
  5873. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  5874. }
  5875. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5876. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5877. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5878. writeGridDataTableJson(dStruct.TotalCount, dt);
  5879. }
  5880. public void handle_erp_aftersale()
  5881. {
  5882. if (UrlPostParmsCheck("ctid"))
  5883. {
  5884. string eid = GetPostString("ctid");
  5885. string responStr = GetPostString("AfterSaleResponsible");
  5886. if (responStr.Length <= 0)
  5887. {
  5888. returnErrorMsg("售后责任人不能为空");
  5889. return;
  5890. }
  5891. bool isDesign = false;
  5892. double designFree = 0.00;
  5893. int responsibleId = 0;
  5894. CeErpTradeCell entity = null;
  5895. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5896. if (entity != null)
  5897. {
  5898. int isNeedNewOrder = GetPostInt("IsNewOrder");
  5899. string afterMethod = GetPostString("AfterSaleMethod");
  5900. if (isNeedNewOrder == 1)
  5901. {
  5902. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  5903. bool ishav = true;
  5904. if (newentity == null)
  5905. {
  5906. newentity = entity.Clone() as CeErpTradeCell;
  5907. ishav = false;
  5908. newentity.ctid = "S_" + entity.ctid;
  5909. newentity.OrderState = 0;
  5910. }
  5911. //唯一标识
  5912. newentity.OrderSn = newentity.ctid;
  5913. /* string orderSn = dataHelper.getSaleOrderSn();
  5914. if (orderSn != "")
  5915. {
  5916. newentity.OrderSn = orderSn;
  5917. }*/
  5918. newentity.AfterSaleState = 0;
  5919. newentity.AfterSaleMethod = afterMethod;
  5920. if (!ishav)
  5921. {
  5922. string memo_str = newentity.seller_memo;
  5923. memo_str = memo_str.Replace("(", "(");
  5924. memo_str = memo_str.Replace(")", ")");
  5925. int sIndex = memo_str.IndexOf("(");
  5926. int eIndex = memo_str.IndexOf(")");
  5927. if (sIndex == -1 || eIndex == -1)
  5928. {
  5929. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  5930. return;
  5931. }
  5932. string first = memo_str.Substring(0, sIndex + 1);
  5933. string memoCtid = newentity.OrderSn;
  5934. //if (memoCtid.IndexOf("C") != -1)
  5935. //{
  5936. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  5937. //if (CIdx.IndexOf("+") != -1)
  5938. //{
  5939. //CIdx = "C" + CIdx.Split('+')[1];
  5940. //}
  5941. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  5942. //}
  5943. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  5944. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  5945. string newMemo = first + memoCtid + last;
  5946. newentity.seller_memo = newMemo;
  5947. newentity.FinishPlaceTime = null;
  5948. newentity.UnusualTag = 0;
  5949. newentity.UnusualCon = "";
  5950. newentity.UnusualTime = null;
  5951. newentity.AfterSaleMemo = "";
  5952. newentity.AfterSaleMethod = afterMethod;
  5953. newentity.AfterSalePreTime = null;
  5954. newentity.AfterSaleReason = "";
  5955. newentity.AfterSaleResponsible = "";
  5956. newentity.AfterSaleState = 0;
  5957. newentity.AfterSaleTime = null;
  5958. newentity.AfterSaleUserId = 0;
  5959. newentity.AfterSaleSupplierState = 0;
  5960. newentity.LastBillWaybillCode = "";
  5961. newentity.LastBillCpCode = "";
  5962. newentity.FinishAfterSaleTime = null;
  5963. newentity.HandleTime = null;
  5964. newentity.IsSF = 0;
  5965. newentity.IsOldCustomer = 0;
  5966. newentity.UrgencyTime = null;
  5967. newentity.ResponsibleUserId = "";
  5968. newentity.IsVerifyToSupplier = false;
  5969. newentity.payment = 0;
  5970. newentity.CheckMemo = "";
  5971. newentity.OutSid = "";
  5972. newentity.CheckOrderTime = null;
  5973. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  5974. }
  5975. newentity.isAfterSaleOrder = 1;
  5976. newentity.IsRefund = 0;
  5977. string receiveMobile = GetPostString("receiver_mobile");
  5978. if (receiveMobile.Length > 0)
  5979. {
  5980. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  5981. if (trade != null)
  5982. {
  5983. trade.receiver_name = GetPostString("receiver_name");
  5984. trade.receiver_mobile = receiveMobile;
  5985. trade.receiver_state = GetPostString("receiver_state");
  5986. trade.receiver_city = GetPostString("receiver_city");
  5987. trade.receiver_district = GetPostString("receiver_district");
  5988. trade.receiver_address = GetPostString("receiver_address");
  5989. newentity.IsOffLineOrder = 1;
  5990. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  5991. }
  5992. }
  5993. string st = GetPostString("ToState");
  5994. if (st.Length > 0)
  5995. {
  5996. if (newentity.OrderState <= 3)
  5997. {
  5998. newentity.WaitDesignTime = DateTime.Now;
  5999. newentity.StartDesignTime = null;
  6000. newentity.FinishDesignTime = null;
  6001. newentity.OrderState = 3;
  6002. if (st == "下单员")
  6003. {
  6004. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6005. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6006. {
  6007. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6008. }
  6009. }
  6010. else
  6011. {
  6012. newentity.WaitDesignTime = DateTime.Now;
  6013. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6014. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6015. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6016. {
  6017. DataRow user = dt1.Rows[0];
  6018. //找主管
  6019. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6020. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6021. if (dt != null && dt.Rows.Count > 0)
  6022. {
  6023. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6024. newentity.DesignUserId = designMr;
  6025. string key = "aftersale_order_" + designMr;
  6026. if (RedisHelper.HasKey(key))
  6027. {
  6028. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6029. list.Add(newentity.ctid);
  6030. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6031. }
  6032. }
  6033. //账号正常
  6034. if (user["State"].ToString() == "0")
  6035. {
  6036. newentity.DesignUserId = entity.DesignUserId;
  6037. string key = "aftersale_order_" + entity.DesignUserId;
  6038. if (RedisHelper.HasKey(key))
  6039. {
  6040. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6041. list.Add(newentity.ctid);
  6042. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6043. }
  6044. }
  6045. }
  6046. }
  6047. }
  6048. if (entity.IsXianHuo == 1)
  6049. {
  6050. newentity.OrderState = 6;
  6051. entity.FinishPlaceTime = DateTime.Now;
  6052. }
  6053. }
  6054. if (ishav)
  6055. {
  6056. newentity.Update();
  6057. }
  6058. else
  6059. {
  6060. newentity.Create();
  6061. CeErpTradeCellExtend.createInfo(newentity.ctid, 30, 20);
  6062. }
  6063. if (st != "下单员")
  6064. {
  6065. designHelper.API_GetPrintData_CreateOrder(newentity);
  6066. }
  6067. }
  6068. //处理售后扩展
  6069. string resIdStr = GetPostString("ResponsibleUserId");
  6070. string refundFees = GetPostString("refundFrees");
  6071. int IsComplain = GetPostInt("isComplain");
  6072. int IsBad = GetPostInt("isBad");
  6073. string IsOriginal = GetPostString("isOriginal");
  6074. double diffResultPrice = GetPostDouble("diffResultPrice");
  6075. string textResult = GetPostString("textResult");
  6076. string supplierResponsible = GetPostString("supplierResponsible");
  6077. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6078. if (ceErpTradeAfterSaleExtend == null)
  6079. {
  6080. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6081. ceErpTradeAfterSaleExtend.tid = eid;
  6082. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6083. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6084. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6085. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6086. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6087. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6088. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6089. ceErpTradeAfterSaleExtend.Create();
  6090. }
  6091. else
  6092. {
  6093. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6094. {
  6095. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6096. }
  6097. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6098. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6099. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6100. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6101. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6102. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6103. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6104. ceErpTradeAfterSaleExtend.Update();
  6105. }
  6106. int gysid = GetPostInt("ResponsibleSupId");
  6107. entity.AfterSaleUserId = CurrentUser.UserID;
  6108. entity.ResponsibleUserId = resIdStr;
  6109. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6110. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6111. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6112. {
  6113. CeErpTradeResponsible.DelByTid(eid, -1);
  6114. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6115. int backNum = 0;
  6116. if (number != null)
  6117. {
  6118. backNum = number.BackNum;
  6119. }
  6120. char[] separator = { ',' };
  6121. string[] sArray = resIdStr.Split(separator);
  6122. string[] refundFreeList = { };
  6123. if (refundFees.Length > 0)
  6124. {
  6125. refundFreeList = refundFees.Split(separator);
  6126. }
  6127. int index = -1;
  6128. foreach (string i in sArray)
  6129. {
  6130. index++;
  6131. if (i.Length <= 0) continue;
  6132. char[] separator2 = { '_' };
  6133. string idstr = i.Split(separator2)[0];
  6134. string idtype = i.Split(separator2)[1];
  6135. double refudFree = 0;
  6136. if (refundFreeList.Length > 0)
  6137. {
  6138. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6139. }
  6140. if (idtype == "s")
  6141. {
  6142. isDesign = true;
  6143. designFree = refudFree;
  6144. }
  6145. int userId = Convert.ToInt32(idstr);
  6146. int type = 0;
  6147. if (idtype == "g")
  6148. {
  6149. type = 1;
  6150. }
  6151. if (idtype == "w")
  6152. {
  6153. type = 2;
  6154. }
  6155. if (idtype == "t")
  6156. {
  6157. type = 3;
  6158. }
  6159. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6160. if (ceErpTradeResponsible == null)
  6161. {
  6162. ceErpTradeResponsible = new CeErpTradeResponsible();
  6163. ceErpTradeResponsible.tid = eid;
  6164. ceErpTradeResponsible.UserId = userId;
  6165. ceErpTradeResponsible.createdTime = DateTime.Now;
  6166. ceErpTradeResponsible.type = type;
  6167. if (type == 1)
  6168. {
  6169. ceErpTradeResponsible.IsSup = 1;
  6170. }
  6171. if (type == 2)
  6172. {
  6173. ceErpTradeResponsible.IsFlow = 1;
  6174. }
  6175. }
  6176. ceErpTradeResponsible.RefundFee = refudFree;
  6177. ceErpTradeResponsible.VerifyState = 0;
  6178. if (userId == 2125 || idtype == "w")
  6179. {
  6180. ceErpTradeResponsible.VerifyState = 1;
  6181. }
  6182. if (idtype == "w" && userId == 101)
  6183. {
  6184. ceErpTradeResponsible.VerifyState = 0;
  6185. }
  6186. if (ceErpTradeResponsible.ID > 0)
  6187. {
  6188. ceErpTradeResponsible.Update();
  6189. }
  6190. else
  6191. {
  6192. ceErpTradeResponsible.Create();
  6193. }
  6194. if (isDesign)
  6195. {
  6196. responsibleId = ceErpTradeResponsible.ID;
  6197. }
  6198. }
  6199. CeErpTradeResponsible.NumByTid(backNum, eid);
  6200. }
  6201. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6202. if (ceErpTradeCellExtend != null)
  6203. {
  6204. ceErpTradeCellExtend.returnVisit = 0;
  6205. ceErpTradeCellExtend.Update();
  6206. }
  6207. if (entity.HandleTime != null)
  6208. {
  6209. if (entity.AfterSaleState == 1)
  6210. {
  6211. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6212. }
  6213. else
  6214. {
  6215. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6216. }
  6217. }
  6218. else
  6219. {
  6220. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6221. entity.HandleTime = DateTime.Now;
  6222. }
  6223. bool isCompale = false;
  6224. if (entity.AfterSaleState == 5)
  6225. {
  6226. isCompale = true;
  6227. entity.AfterSaleState = 3;
  6228. }
  6229. entity.AfterSaleSupplierState = 0;
  6230. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6231. {
  6232. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6233. }
  6234. string sImgs = GetPostString("img");
  6235. entity.AfterSaleSupplierImg = sImgs;
  6236. entity.supRefundType = GetPostString("supRefundType");
  6237. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6238. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6239. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6240. entity.AfterSaleMemoType = GetPostString("MemoType");
  6241. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6242. {
  6243. entity.AfterSaleSupplierState = 2;
  6244. }
  6245. string df = GetPostString("DeductFee");
  6246. if (df == "")
  6247. {
  6248. df = "0";
  6249. }
  6250. string rf = GetPostString("RefundFee");
  6251. if (rf == "")
  6252. {
  6253. rf = "0";
  6254. }
  6255. string pm = GetPostString("AfterSalePayment");
  6256. if (pm == "")
  6257. {
  6258. pm = "0";
  6259. }
  6260. entity.AfterSalePayment = Convert.ToDouble(pm);
  6261. entity.DeductFee = Convert.ToDouble(df);
  6262. entity.RefundFee = Convert.ToDouble(rf);
  6263. entity.Update();
  6264. string toState = GetPostString("ToState");
  6265. string original = GetPostString("isOriginal");
  6266. ApiVo apiVo = new ApiVo();
  6267. apiVo.orderNumber = entity.ctid;
  6268. apiVo.actionName = "afterDesign";
  6269. apiVo.orderRemarks = entity.AfterSaleMethod;
  6270. apiVo.reasonRemarks = entity.AfterSaleReason;
  6271. apiVo.isDesign = isDesign;
  6272. apiVo.designFree = designFree;
  6273. apiVo.responsibleId = responsibleId;
  6274. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6275. if (toState == "设计师")
  6276. {
  6277. apiVo.isOriginal = Convert.ToBoolean(original);
  6278. }
  6279. designHelper.API_WorkCore(apiVo);//afterDesign
  6280. CeErpMethod methodSql = new CeErpMethod();
  6281. methodSql.con = entity.AfterSaleMethod;
  6282. methodSql.addTime = DateTime.Now;
  6283. methodSql.Create();
  6284. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6285. CeErpMethod.ExecuteNonQuery(delsql);
  6286. if (isCompale)
  6287. {
  6288. aftersale_data_change(entity.ctid);
  6289. }
  6290. returnSuccessMsg("操作成功!");
  6291. return;
  6292. }
  6293. returnErrorMsg("找不到订单记录");
  6294. }
  6295. }
  6296. public void ins_erp_toresponsible()
  6297. {
  6298. if (UrlPostParmsCheck("ctid"))
  6299. {
  6300. string eid = GetPostString("ctid");
  6301. CeErpTradeCell entity = null;
  6302. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6303. if (entity != null)
  6304. {
  6305. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6306. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6307. {
  6308. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6309. return;
  6310. }
  6311. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6312. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6313. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6314. entity.AfterSalePreTime = DateTime.Now;
  6315. //预完成给售后主管审核客户问题直接完成
  6316. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6317. {
  6318. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) == 0)
  6319. {
  6320. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6321. }
  6322. }
  6323. entity.AfterSaleState = 2;
  6324. entity.Update();
  6325. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6326. aftersale_data_change(entity.ctid);
  6327. returnSuccessMsg("操作成功!");
  6328. return;
  6329. }
  6330. returnErrorMsg("找不到订单记录");
  6331. }
  6332. }
  6333. public void cancel_erp_aftersaleanddelnew()
  6334. {
  6335. if (UrlPostParmsCheck("ctid"))
  6336. {
  6337. string eid = GetPostString("ctid");
  6338. CeErpTradeCell entity = null;
  6339. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6340. if (entity != null)
  6341. {
  6342. entity.AfterSaleState = 0;
  6343. entity.AfterSaleReason = "";
  6344. entity.AfterSaleMethod = "";
  6345. entity.AfterSaleMemo = "";
  6346. entity.AfterSaleResponsible = "";
  6347. entity.ResponsibleUserId = "";
  6348. entity.DeductFee = 0;
  6349. entity.RefundFee = 0;
  6350. entity.IsArbitrate = 0;
  6351. CeErpTradeResponsible.DelByTid(eid, -1);
  6352. entity.Update();
  6353. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6354. if (after != null)
  6355. {
  6356. if (after.OrderState < 5)
  6357. CeErpTradeCell.DelByCtid("S_" + eid);
  6358. }
  6359. returnSuccessMsg("操作成功!");
  6360. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6361. return;
  6362. }
  6363. returnErrorMsg("找不到订单记录");
  6364. }
  6365. }
  6366. public void get_erp_aftersale_pregather()
  6367. {
  6368. List<string> lw = new List<string>();
  6369. int st = GetInt("st");
  6370. string tid = GetPostString("ctid");
  6371. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or orderSn = '{0}')", tid));
  6372. string shopname = GetPostString("shopname");
  6373. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6374. string buyernick = GetPostString("buyer_nick");
  6375. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6376. string sellermemo = GetPostString("seller_memo");
  6377. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6378. string orderState = GetPostString("orderState");
  6379. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6380. string reason = GetPostString("reason");
  6381. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6382. string method = GetPostString("method");
  6383. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6384. string handler = GetPostString("handler");
  6385. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6386. string handledate1 = GetPostString("handledate1");
  6387. string handledate2 = GetPostString("handledate2");
  6388. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6389. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6390. string supplier = GetPostString("supplier");
  6391. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6392. string responsible = GetPostString("responsibleman");
  6393. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6394. string customer = GetPostString("customer");
  6395. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6396. string design = GetPostString("design");
  6397. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6398. string afterMemoType = GetPostString("aftermemotype");
  6399. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6400. string afterSaleMemo = GetPostString("afterSaleMemo");
  6401. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6402. string afterresult = GetPostString("afterresult");
  6403. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6404. string poscode = CurrentUser.UserPost.Post.Code;
  6405. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6406. {
  6407. string shopid = CurrentUser.User.pemShop;
  6408. lw.Add(string.Format("shopId in ({0})", shopid));
  6409. }
  6410. var mainwhere = string.Join(" and ", lw.ToArray());
  6411. string ro_json = "";
  6412. string type = GetPostString("gather_type");
  6413. if (poscode == "AfterSale")
  6414. {
  6415. //处理中
  6416. if (type == "Handling")
  6417. {
  6418. 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) : ""));
  6419. DataTable dt = null;
  6420. try
  6421. {
  6422. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6423. }
  6424. catch (Exception e)
  6425. {
  6426. dt = new DataTable();
  6427. }
  6428. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6429. return;
  6430. }
  6431. if (type == "Wait")
  6432. {
  6433. //待处理
  6434. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6435. DataTable dt1 = null;
  6436. try
  6437. {
  6438. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6439. }
  6440. catch (Exception e)
  6441. {
  6442. dt1 = new DataTable();
  6443. }
  6444. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6445. return;
  6446. }
  6447. if (type == "back")
  6448. {
  6449. //打回
  6450. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6451. DataTable dt2 = null;
  6452. try
  6453. {
  6454. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6455. }
  6456. catch (Exception e)
  6457. {
  6458. dt2 = new DataTable();
  6459. }
  6460. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6461. return;
  6462. }
  6463. if (type == "preCompletion")
  6464. {
  6465. //预完成
  6466. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6467. DataTable dt3 = null;
  6468. try
  6469. {
  6470. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6471. }
  6472. catch (Exception e)
  6473. {
  6474. dt3 = new DataTable();
  6475. }
  6476. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6477. return;
  6478. }
  6479. if (type == "documentary")
  6480. {
  6481. //跟单中
  6482. 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) : ""));
  6483. DataTable dt4 = null;
  6484. try
  6485. {
  6486. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6487. }
  6488. catch (Exception e)
  6489. {
  6490. dt4 = new DataTable();
  6491. }
  6492. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6493. return;
  6494. }
  6495. if (type == "reBack")
  6496. {
  6497. //被打回
  6498. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6499. DataTable dt1 = null;
  6500. try
  6501. {
  6502. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6503. }
  6504. catch (Exception e)
  6505. {
  6506. dt1 = new DataTable();
  6507. }
  6508. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6509. return;
  6510. }
  6511. }
  6512. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6513. {
  6514. if (type == "puBack")
  6515. {
  6516. //退回
  6517. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6518. DataTable dt = null;
  6519. try
  6520. {
  6521. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6522. }
  6523. catch (Exception e)
  6524. {
  6525. dt = new DataTable();
  6526. }
  6527. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6528. return;
  6529. }
  6530. if (type == "reBack")
  6531. {
  6532. //打回
  6533. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6534. DataTable dt1 = null;
  6535. try
  6536. {
  6537. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6538. }
  6539. catch (Exception e)
  6540. {
  6541. dt1 = new DataTable();
  6542. }
  6543. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6544. return;
  6545. }
  6546. if (type == "examEd")
  6547. {
  6548. //已审核
  6549. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6550. DataTable dt2 = null;
  6551. try
  6552. {
  6553. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6554. }
  6555. catch (Exception e)
  6556. {
  6557. dt2 = new DataTable();
  6558. }
  6559. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6560. return;
  6561. }
  6562. if (type == "waitExam")
  6563. {
  6564. //待审核
  6565. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6566. DataTable dt3 = null;
  6567. try
  6568. {
  6569. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6570. }
  6571. catch (Exception e)
  6572. {
  6573. dt3 = new DataTable();
  6574. }
  6575. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6576. return;
  6577. }
  6578. if (type == "Handling")
  6579. {
  6580. //处理中
  6581. 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) : ""));
  6582. DataTable dt4 = null;
  6583. try
  6584. {
  6585. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6586. }
  6587. catch (Exception e)
  6588. {
  6589. dt4 = new DataTable();
  6590. }
  6591. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6592. return;
  6593. }
  6594. if (type == "Wait")
  6595. {
  6596. //待处理
  6597. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6598. DataTable dt5 = null;
  6599. try
  6600. {
  6601. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6602. }
  6603. catch (Exception e)
  6604. {
  6605. dt5 = new DataTable();
  6606. }
  6607. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6608. return;
  6609. }
  6610. if (type == "documentary")
  6611. {
  6612. //跟单中
  6613. 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) : ""));
  6614. DataTable dt6 = null;
  6615. try
  6616. {
  6617. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6618. }
  6619. catch (Exception e)
  6620. {
  6621. dt6 = new DataTable();
  6622. }
  6623. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6624. return;
  6625. }
  6626. }
  6627. returnSuccess(ro_json);
  6628. }
  6629. public void end_erp_aftersale()
  6630. {
  6631. if (UrlPostParmsCheck("ctid"))
  6632. {
  6633. string eid = GetPostString("ctid");
  6634. CeErpTradeCell entity = null;
  6635. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6636. if (entity != null)
  6637. {
  6638. string stype = GetPostString("stype");
  6639. string typeStr = stype;
  6640. entity.AfterSaleState = 4;
  6641. entity.FinishAfterSaleTime = DateTime.Now;
  6642. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6643. entity.Update();
  6644. ApiVo apiVo = new ApiVo();
  6645. apiVo.orderNumber = entity.ctid;
  6646. apiVo.actionName = "afterOver";
  6647. designHelper.API_WorkCore(apiVo); //afterOver
  6648. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6649. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6650. CeErpSukuraData.createInfo(entity.ctid, 8);
  6651. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6652. returnSuccessMsg("操作成功!");
  6653. return;
  6654. }
  6655. returnErrorMsg("找不到订单记录");
  6656. }
  6657. }
  6658. public void ins_erp_finishaftersale()
  6659. {
  6660. if (UrlPostParmsCheck("id"))
  6661. {
  6662. string eid = GetPostString("id");
  6663. CeErpTradeResponsible entity = null;
  6664. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6665. if (entity != null)
  6666. {
  6667. entity.VerifyState = 1;
  6668. entity.VerifyTime = DateTime.Now;
  6669. entity.Update();
  6670. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6671. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6672. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6673. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6674. if (dt.Rows.Count <= 0)
  6675. {
  6676. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6677. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6678. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6679. CeErpSukuraData.createInfo(entity.tid, 8);
  6680. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6681. {
  6682. CeErpDesignerBill.Del(entity.tid);
  6683. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6684. }
  6685. }
  6686. returnSuccessMsg("操作成功!");
  6687. return;
  6688. }
  6689. returnErrorMsg("找不到订单记录");
  6690. }
  6691. }
  6692. public void upd_erp_arbitrateaftersale()
  6693. {
  6694. if (UrlPostParmsCheck("id"))
  6695. {
  6696. string eid = GetPostString("id");
  6697. CeErpTradeResponsible entity = null;
  6698. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6699. if (entity != null)
  6700. {
  6701. entity.IsArbitrate = 1;
  6702. entity.ArbitradeMemo = GetPostString("reason");
  6703. entity.VerifyState = 2;
  6704. entity.Update();
  6705. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6706. if (tradecell != null)
  6707. {
  6708. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6709. tradecell.IsArbitrate = 1;
  6710. tradecell.Update();
  6711. }
  6712. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6713. returnSuccessMsg("操作成功!");
  6714. return;
  6715. }
  6716. returnErrorMsg("找不到订单记录");
  6717. }
  6718. }
  6719. public void upd_erp_backaftersale()
  6720. {
  6721. if (UrlPostParmsCheck("tid"))
  6722. {
  6723. string eid = GetPostString("tid");
  6724. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6725. int backNum = 0;
  6726. if (number != null)
  6727. {
  6728. backNum = number.BackNum;
  6729. }
  6730. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6731. CeErpTradeCell entity = null;
  6732. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6733. if (entity != null)
  6734. {
  6735. entity.AfterSaleBackReason = GetPostString("backreason");
  6736. entity.AfterSaleState = 1;
  6737. entity.AfterSaleSupplierState = 0;
  6738. entity.Update();
  6739. returnSuccessMsg("操作成功!");
  6740. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6741. return;
  6742. }
  6743. returnErrorMsg("找不到订单记录");
  6744. }
  6745. }
  6746. public void get_erp_supplieraftersalelist()
  6747. {
  6748. DataStruct dStruct = GetPostStruct();
  6749. List<string> lw = new List<string>();
  6750. string tid = GetPostString("ctid");
  6751. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6752. string shopname = GetPostString("shopname");
  6753. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6754. string buyernick = GetPostString("buyer_nick");
  6755. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6756. string sellermemo = GetPostString("seller_memo");
  6757. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6758. string orderState = GetPostString("orderState");
  6759. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6760. string afterState = GetPostString("afterstate");
  6761. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6762. string date1 = GetPostString("date1");
  6763. string date2 = GetPostString("date2");
  6764. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6765. if (dw.Length > 0) lw.Add(dw);
  6766. string price1 = GetPostString("price1");
  6767. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6768. string price2 = GetPostString("price2");
  6769. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6770. string reason = GetPostString("reason");
  6771. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6772. string method = GetPostString("method");
  6773. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6774. string handledate1 = GetPostString("handledate1");
  6775. string handledate2 = GetPostString("handledate2");
  6776. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6777. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6778. string handler = GetPostString("handler");
  6779. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6780. string afterdate1 = GetPostString("afterdate1");
  6781. string afterdate2 = GetPostString("afterdate2");
  6782. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6783. if (afterDate.Length > 0) lw.Add(afterDate);
  6784. string customer = GetPostString("customer");
  6785. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6786. string design = GetPostString("design");
  6787. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6788. string afterMemoType = GetPostString("aftermemotype");
  6789. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6790. string vstate = GetPostString("vstate");
  6791. if (vstate.Length > 0)
  6792. {
  6793. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6794. }
  6795. lw.Add(string.Format("AfterSaleState>={0}", 2));
  6796. string supplier = GetPostString("supplier");
  6797. int supid = commonHelper.getSupplierIDByName(supplier);
  6798. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  6799. string posCode = CurrentUser.UserPost.Post.Code;
  6800. if (posCode == "Supplier")
  6801. {
  6802. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6803. }
  6804. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  6805. {
  6806. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  6807. }
  6808. else
  6809. {
  6810. lw.Add(string.Format("AfterSaleResSupId != 0"));
  6811. }
  6812. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6813. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6814. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6815. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6816. writeGridDataTableJson(dStruct.TotalCount, dt);
  6817. }
  6818. public void upd_erp_supverifyaftersale()
  6819. {
  6820. if (UrlPostParmsCheck("id"))
  6821. {
  6822. string id = GetPostString("id");
  6823. int st = GetPostInt("afterstate");
  6824. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6825. CeErpTradeCell entity = null;
  6826. if (ceErpTradeResponsible != null)
  6827. {
  6828. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6829. }
  6830. string afmemo = GetPostString("supmemo");
  6831. string image = GetPostString("image");
  6832. if (entity != null)
  6833. {
  6834. entity.AfterSaleSupplierState = st;
  6835. entity.AfterSaleSupplierMemo = afmemo;
  6836. entity.AfterSaleSupplierState = st;
  6837. if (st == 1)
  6838. {
  6839. ceErpTradeResponsible.VerifyState = 1;
  6840. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6841. ceErpTradeResponsible.Update();
  6842. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6843. if (isAll)
  6844. {
  6845. entity.AfterSaleState = 4;
  6846. entity.FinishAfterSaleTime = DateTime.Now;
  6847. }
  6848. }
  6849. else
  6850. {
  6851. CeErpTradeResponsible.dateByTid(entity.ctid);
  6852. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6853. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6854. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6855. if (num <= 1)
  6856. {
  6857. entity.AfterSaleState = 1;
  6858. }
  6859. else
  6860. {
  6861. entity.AfterSaleState = 5;
  6862. }
  6863. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6864. if (ceErpTradeAfterSaleExtend != null)
  6865. {
  6866. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6867. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6868. ceErpTradeAfterSaleExtend.Update();
  6869. }
  6870. else
  6871. {
  6872. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6873. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6874. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6875. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6876. ceErpTradeAfterSaleExtend.Create();
  6877. }
  6878. }
  6879. if (entity.AfterSaleState == 4)
  6880. {
  6881. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6882. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  6883. {
  6884. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6885. }
  6886. ApiVo apiVo = new ApiVo();
  6887. apiVo.orderNumber = entity.ctid;
  6888. apiVo.actionName = "afterOver";
  6889. designHelper.API_WorkCore(apiVo); //afterOver
  6890. }
  6891. entity.Update();
  6892. returnSuccessMsg("操作成功!");
  6893. CeErpSukuraData.createInfo(entity.ctid, 8);
  6894. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6895. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6896. return;
  6897. }
  6898. returnErrorMsg("找不到订单记录");
  6899. }
  6900. }
  6901. public void upd_erp_masteraftersale()
  6902. {
  6903. if (UrlPostParmsCheck("id"))
  6904. {
  6905. string id = GetPostString("id");
  6906. int st = GetPostInt("afterstate");
  6907. string afmemo = GetPostString("supmemo");
  6908. string image = GetPostString("image");
  6909. string textResult = GetPostString("textResult");
  6910. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6911. if (ceErpTradeResponsible != null)
  6912. {
  6913. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  6914. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6915. ceErpTradeResponsible.Update();
  6916. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6917. if (entity != null)
  6918. {
  6919. entity.AfterSaleSupplierState = st;
  6920. entity.AfterSaleSupplierMemo = afmemo;
  6921. if (st == 1)
  6922. {
  6923. }
  6924. else
  6925. {
  6926. CeErpTradeResponsible.dateByTid(entity.ctid);
  6927. //退回到售后
  6928. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6929. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6930. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6931. if (num <= 1)
  6932. {
  6933. entity.AfterSaleState = 1;
  6934. }
  6935. else
  6936. {
  6937. entity.AfterSaleState = 5;
  6938. }
  6939. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6940. if (ceErpTradeAfterSaleExtend != null)
  6941. {
  6942. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6943. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6944. ceErpTradeAfterSaleExtend.Update();
  6945. }
  6946. else
  6947. {
  6948. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6949. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6950. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6951. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6952. ceErpTradeAfterSaleExtend.Create();
  6953. }
  6954. }
  6955. entity.Update();
  6956. returnSuccessMsg("操作成功!");
  6957. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6958. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6959. return;
  6960. }
  6961. }
  6962. returnErrorMsg("找不到订单记录");
  6963. }
  6964. }
  6965. public void upd_erp_personaftersale()
  6966. {
  6967. if (UrlPostParmsCheck("id"))
  6968. {
  6969. string id = GetPostString("id");
  6970. int st = GetPostInt("afterstate");
  6971. string afmemo = GetPostString("supmemo");
  6972. string image = GetPostString("image");
  6973. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6974. if (ceErpTradeResponsible != null)
  6975. {
  6976. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  6977. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6978. ceErpTradeResponsible.Update();
  6979. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6980. if (entity != null)
  6981. {
  6982. entity.AfterSaleSupplierMemo = afmemo;
  6983. entity.AfterSaleSupplierState = st;
  6984. if (st == 1)
  6985. {
  6986. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6987. if (isAll)
  6988. {
  6989. entity.AfterSaleState = 4;
  6990. entity.FinishAfterSaleTime = DateTime.Now;
  6991. }
  6992. }
  6993. else
  6994. {
  6995. CeErpTradeResponsible.dateByTid(entity.ctid);
  6996. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6997. if (ceErpTradeAfterSaleExtend != null)
  6998. {
  6999. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7000. ceErpTradeAfterSaleExtend.Update();
  7001. }
  7002. else
  7003. {
  7004. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7005. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7006. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7007. ceErpTradeAfterSaleExtend.Create();
  7008. }
  7009. //退回到主管
  7010. //entity.AfterSaleState = 2;
  7011. }
  7012. if (entity.AfterSaleState == 4)
  7013. {
  7014. ApiVo apiVo = new ApiVo();
  7015. apiVo.orderNumber = entity.ctid;
  7016. apiVo.actionName = "afterOver";
  7017. designHelper.API_WorkCore(apiVo); //afterOver
  7018. }
  7019. entity.Update();
  7020. returnSuccessMsg("操作成功!");
  7021. CeErpSukuraData.createInfo(entity.ctid, 8);
  7022. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7023. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7024. return;
  7025. }
  7026. }
  7027. returnErrorMsg("找不到订单记录");
  7028. }
  7029. }
  7030. public void set_erp_supplierrefundtag()
  7031. {
  7032. if (UrlPostParmsCheck("ctid"))
  7033. {
  7034. string eid = GetPostString("ctid");
  7035. CeErpTradeCell entity = null;
  7036. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7037. if (entity != null)
  7038. {
  7039. entity.IsSupplierRefund = GetPostInt("tag");
  7040. entity.Update();
  7041. returnSuccessMsg("操作成功!");
  7042. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7043. return;
  7044. }
  7045. returnErrorMsg("找不到订单记录");
  7046. }
  7047. }
  7048. public void get_erp_refundlist()
  7049. {
  7050. DataStruct dStruct = GetPostStruct();
  7051. List<string> lw = new List<string>();
  7052. string tid = GetPostString("tid");
  7053. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7054. //string rid = GetPostString("refund_id");
  7055. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7056. string shopname = GetPostString("shopname");
  7057. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7058. string buyernick = GetPostString("buyer_nick");
  7059. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7060. string customer = GetPostString("customer");
  7061. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7062. string design = GetPostString("design");
  7063. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7064. string sellermemo = GetPostString("seller_memo");
  7065. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7066. //string date1 = GetPostString("date1");
  7067. //string date2 = GetPostString("date2");
  7068. //string dateType = GetPostString("dateType");
  7069. //if (dateType.Length > 0)
  7070. //{
  7071. // if (dateType == "1001") dateType = "0";
  7072. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7073. // if (searchDT.Count == 2)
  7074. // {
  7075. // date1 = searchDT[0].ToString();
  7076. // date2 = searchDT[1].ToString();
  7077. // }
  7078. //}
  7079. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7080. //if (dw.Length > 0) lw.Add(dw);
  7081. string redate1 = GetPostString("refunddate1");
  7082. string redate2 = GetPostString("refunddate2");
  7083. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7084. if (dwdate.Length > 0) lw.Add(dwdate);
  7085. string price1 = GetPostString("price1");
  7086. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7087. string price2 = GetPostString("price2");
  7088. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7089. string ispartrefund = GetPostString("ispartrefund");
  7090. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7091. string refundState = GetPostString("refundvstate");
  7092. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7093. int st = GetInt("st");
  7094. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7095. {
  7096. string responsible = GetPostString("responsibleman");
  7097. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7098. lw.Add(string.Format("RefundState>={0}", st));
  7099. string code = CurrentUser.UserPost.Post.Code;
  7100. if (code == "CustomerService")
  7101. {
  7102. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7103. }
  7104. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7105. {
  7106. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7107. }
  7108. else if (code == "Place" || code == "PlaceMr")
  7109. {
  7110. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7111. }
  7112. dStruct.Order = "RefundState asc,created desc";
  7113. }
  7114. else if (st == 10)
  7115. {
  7116. string responsible = GetPostString("responsibleman");
  7117. if (responsible == "空白")
  7118. {
  7119. lw.Add(string.Format("ResponsibleUserName = ''"));
  7120. }
  7121. else if (responsible.Length > 0)
  7122. {
  7123. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7124. }
  7125. lw.Add(string.Format("RefundState>=0"));
  7126. dStruct.Order = "created desc";
  7127. }
  7128. else
  7129. {
  7130. string responsible = GetPostString("responsibleman");
  7131. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7132. lw.Add(string.Format("RefundState={0}", st));
  7133. dStruct.Order = "created desc";
  7134. }
  7135. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7136. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7137. dt.Columns.Add("refund_fees");
  7138. foreach (DataRow dr in dt.Rows)
  7139. {
  7140. String status = dr["status"].ToString();
  7141. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7142. {
  7143. dr["refund_fees"] = dr["refund_fee"];
  7144. }
  7145. else
  7146. {
  7147. dr["refund_fees"] = "0.0";
  7148. }
  7149. }
  7150. writeGridDataTableJson(dStruct.TotalCount, dt);
  7151. }
  7152. public void get_erp_refunddesignlist()
  7153. {
  7154. DataStruct dStruct = GetPostStruct();
  7155. List<string> lw = new List<string>();
  7156. string tid = GetPostString("tid");
  7157. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7158. string shopname = GetPostString("shopname");
  7159. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7160. string buyernick = GetPostString("buyer_nick");
  7161. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7162. string customer = GetPostString("customer");
  7163. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7164. string design = GetPostString("design");
  7165. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7166. string sellermemo = GetPostString("seller_memo");
  7167. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7168. string redate1 = GetPostString("refunddate1");
  7169. string redate2 = GetPostString("refunddate2");
  7170. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7171. if (dwdate.Length > 0) lw.Add(dwdate);
  7172. string price1 = GetPostString("price1");
  7173. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7174. string price2 = GetPostString("price2");
  7175. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7176. string ispartrefund = GetPostString("ispartrefund");
  7177. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7178. string designerorg = GetPostString("designerorg");
  7179. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7180. string refundState = GetPostString("refundState");
  7181. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7182. int myOrgid = CurrentUser.UserPost.OrgID;
  7183. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7184. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7185. {
  7186. if (CurrentUser.User.TeamIds.Length > 0)
  7187. {
  7188. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7189. }
  7190. else
  7191. {
  7192. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7193. }
  7194. }
  7195. else if ("SysAdmin".Equals(myOrgCode))
  7196. {
  7197. }
  7198. else
  7199. {
  7200. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7201. {
  7202. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7203. }
  7204. else
  7205. {
  7206. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7207. }
  7208. }
  7209. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7210. dStruct.Order = "created desc";
  7211. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7212. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7213. dt.Columns.Add("refund_fees");
  7214. foreach (DataRow dr in dt.Rows)
  7215. {
  7216. String status = dr["status"].ToString();
  7217. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7218. {
  7219. dr["refund_fees"] = dr["refund_fee"];
  7220. }
  7221. else
  7222. {
  7223. dr["refund_fees"] = "0.0";
  7224. }
  7225. }
  7226. writeGridDataTableJson(dStruct.TotalCount, dt);
  7227. }
  7228. public void handle_erp_refundtag()
  7229. {
  7230. if (UrlPostParmsCheck("refund_id"))
  7231. {
  7232. string eid = GetPostString("refund_id");
  7233. string respMan = GetPostString("ResponsibleName");
  7234. if (respMan.Length <= 0)
  7235. {
  7236. returnErrorMsg("责任人不能为空");
  7237. return;
  7238. }
  7239. CeErpTradeRefund entity = null;
  7240. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7241. if (entity != null)
  7242. {
  7243. entity.ResponsibleUserName = respMan;
  7244. string userid = GetPostString("ResponsibleUserId");
  7245. if (userid.Length > 0)
  7246. {
  7247. entity.ResponsibleUserId = userid;
  7248. }
  7249. entity.Memo = GetPostString("Memo");
  7250. if (respMan.IndexOf("客服") != -1 ||
  7251. respMan.IndexOf("设计师") != -1 ||
  7252. respMan.IndexOf("下单员") != -1)
  7253. {
  7254. entity.RefundState = 2;
  7255. }
  7256. else
  7257. {
  7258. entity.RefundState = 3;
  7259. }
  7260. entity.modified = DateTime.Now;
  7261. entity.Update();
  7262. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7263. returnSuccessMsg("操作成功!");
  7264. return;
  7265. }
  7266. returnErrorMsg("找不到订单记录");
  7267. }
  7268. }
  7269. public void handle_erp_designrefundtag()
  7270. {
  7271. if (UrlPostParmsCheck("refund_id"))
  7272. {
  7273. string eid = GetPostString("refund_id");
  7274. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7275. if (ceErpTradeCellExtend == null)
  7276. {
  7277. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7278. ceErpTradeCellExtend.ctid = eid;
  7279. }
  7280. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7281. if (ceErpTradeCellExtend.ID > 0)
  7282. {
  7283. ceErpTradeCellExtend.Update();
  7284. }
  7285. else
  7286. {
  7287. ceErpTradeCellExtend.Create();
  7288. }
  7289. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7290. returnSuccessMsg("操作成功!");
  7291. return;
  7292. }
  7293. returnErrorMsg("找不到订单记录");
  7294. }
  7295. public void upd_erp_refundverify()
  7296. {
  7297. if (UrlPostParmsCheck("refund_id"))
  7298. {
  7299. string eid = GetPostString("refund_id");
  7300. CeErpTradeRefund entity = null;
  7301. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7302. if (entity != null)
  7303. {
  7304. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7305. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7306. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7307. {
  7308. entity.RefundState = 2;
  7309. }
  7310. else
  7311. {
  7312. entity.RefundState = 3;
  7313. }
  7314. entity.Update();
  7315. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7316. returnSuccessMsg("操作成功!");
  7317. return;
  7318. }
  7319. returnErrorMsg("找不到订单记录");
  7320. }
  7321. }
  7322. public void upd_erp_refundapprove()
  7323. {
  7324. if (UrlPostParmsCheck("refund_id"))
  7325. {
  7326. string eid = GetPostString("refund_id");
  7327. CeErpTradeRefund entity = null;
  7328. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7329. if (entity != null)
  7330. {
  7331. int apr = GetPostInt("approve");
  7332. if (apr == 0)
  7333. {
  7334. entity.RefundState = 1;
  7335. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7336. }
  7337. else if (apr == 1)
  7338. {
  7339. entity.RefundState = 3;
  7340. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7341. }
  7342. entity.modified = DateTime.Now;
  7343. entity.Update();
  7344. returnSuccessMsg("操作成功!");
  7345. return;
  7346. }
  7347. returnErrorMsg("找不到订单记录");
  7348. }
  7349. }
  7350. public void get_erp_billlist()
  7351. {
  7352. DataStruct dStruct = GetPostStruct();
  7353. List<string> lw = new List<string>();
  7354. string title = GetPostString("title");
  7355. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7356. string tid = GetPostString("tid");
  7357. string tids = GetPostString("tids");
  7358. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7359. if (tids.Length > 0)
  7360. {
  7361. tids = "'" + tids + "'";
  7362. tids = tids.Replace(",", "','");
  7363. lw.Add(string.Format("tid in ({0})", tids));
  7364. }
  7365. string shopname = GetPostString("shopname");
  7366. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7367. string buyernick = GetPostString("buyer_nick");
  7368. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7369. string customer = GetPostString("customer");
  7370. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7371. string date1 = GetPostString("date1");
  7372. string date2 = GetPostString("date2");
  7373. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7374. if (dw.Length > 0) lw.Add(dw);
  7375. string price1 = GetPostString("price1");
  7376. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7377. string price2 = GetPostString("price2");
  7378. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7379. string returndate1 = GetPostString("returndate1");
  7380. string returndate2 = GetPostString("returndate2");
  7381. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7382. if (dw1.Length > 0) lw.Add(dw1);
  7383. string billtype = GetPostString("billtype");
  7384. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7385. string billstate = GetPostString("billstate");
  7386. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7387. string usershop = CurrentUser.User.pemShop;
  7388. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7389. dStruct.Order = "createTime desc";
  7390. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7391. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7392. //foreach (DataRow dr in dt.Rows)
  7393. //{
  7394. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7395. //}
  7396. writeGridDataTableJson(dStruct.TotalCount, dt);
  7397. }
  7398. public void modify_erp_billinfo()
  7399. {
  7400. if (UrlPostParmsCheck("ID"))
  7401. {
  7402. string eid = GetPostString("ID");
  7403. CeErpBill bill_entity = null;
  7404. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7405. if (bill_entity != null)
  7406. {
  7407. bill_entity.tid = GetPostString("tid");
  7408. bill_entity.title = GetPostString("title");
  7409. bill_entity.tax = GetPostString("tax");
  7410. bill_entity.bank = GetPostString("bank");
  7411. bill_entity.bankac = GetPostString("bankac");
  7412. bill_entity.address = GetPostString("address");
  7413. bill_entity.phone = GetPostString("phone");
  7414. bill_entity.price = GetPostString("price");
  7415. bill_entity.productId = GetPostInt("ProductName");
  7416. bill_entity.num = GetPostInt("num");
  7417. bill_entity.unit = GetPostString("unit");
  7418. bill_entity.type = GetPostString("type");
  7419. bill_entity.sendType = GetPostString("SendType");
  7420. bill_entity.email = GetPostString("email");
  7421. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7422. bill_entity.shopName = GetPostString("ShopName");
  7423. bill_entity.applymemo = GetPostString("applymemo");
  7424. bill_entity.modifyTime = DateTime.Now;
  7425. bill_entity.createTime = DateTime.Now;
  7426. bill_entity.state = 0;
  7427. bill_entity.Update();
  7428. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7429. returnSuccessMsg("发票修改成功!");
  7430. return;
  7431. }
  7432. returnErrorMsg("找不到对应记录");
  7433. }
  7434. }
  7435. public void set_erp_invoicing()
  7436. {
  7437. if (UrlPostParmsCheck("id"))
  7438. {
  7439. try
  7440. {
  7441. string eid = GetPostString("id");
  7442. CeErpBill bill_entity = null;
  7443. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7444. if (bill_entity != null)
  7445. {
  7446. int ComId = GetPostInt("ComId");
  7447. //string memo = GetPostString("Memo");
  7448. int allInfo = GetPostInt("allinfo");
  7449. string clert = CurrentUser.User.Name;
  7450. //string detailValue = GetPostString("detailvalue");
  7451. string billId = bill_entity.billOrderId;
  7452. string[] billIdList = billId.Split(',');
  7453. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7454. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7455. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7456. {
  7457. billCount += 1;
  7458. }
  7459. if (billId.Length <= 0 || billIdList.Length != billCount)
  7460. {
  7461. bill_entity.billOrderId = "";
  7462. string prebill = "ltb";
  7463. for (int idx = 1; idx <= billCount; idx++)
  7464. {
  7465. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7466. string billoid = prebill + idx + dtstr;
  7467. bill_entity.billOrderId += billoid;
  7468. if (idx < billCount)
  7469. {
  7470. bill_entity.billOrderId += ",";
  7471. }
  7472. }
  7473. }
  7474. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7475. if (bill_entity.state == 5)
  7476. {
  7477. string errMsg = bill_entity.failerror;
  7478. string[] errlist = errMsg.Split('|');
  7479. string[] errTags = new string[errlist.Length];
  7480. for (int itag = 0; itag < errlist.Length; itag++)
  7481. {
  7482. if (errlist[itag].Length <= 0) continue;
  7483. errTags[itag] = errlist[itag].Split('&')[0];
  7484. }
  7485. for (int iii = 0; iii < errTags.Length; iii++)
  7486. {
  7487. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7488. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7489. if (billOrderList.Length >= erroBillOrderTag)
  7490. {
  7491. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7492. if (needModifyBillId.Length <= 19)
  7493. {
  7494. needModifyBillId = needModifyBillId + "1";
  7495. }
  7496. else
  7497. {
  7498. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7499. last = last + 1;
  7500. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7501. }
  7502. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7503. }
  7504. }
  7505. }
  7506. bool isHaveBillSucces = false;
  7507. string totalRes = "";
  7508. bill_entity.failerror = "";
  7509. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7510. {
  7511. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7512. totalRes += res;
  7513. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7514. {
  7515. isHaveBillSucces = true;
  7516. bill_entity.comId = ComId;
  7517. bill_entity.state = 1;
  7518. bill_entity.executeTime = DateTime.Now;
  7519. bill_entity.executeUser = clert;
  7520. }
  7521. else
  7522. {
  7523. bill_entity.state = 5;
  7524. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7525. }
  7526. }
  7527. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7528. bill_entity.Update();
  7529. if (isHaveBillSucces)
  7530. {
  7531. StringBuilder sql = new StringBuilder();
  7532. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7533. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7534. }
  7535. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7536. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7537. {
  7538. returnErrorMsg("开票失败");
  7539. }
  7540. else
  7541. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7542. return;
  7543. }
  7544. returnErrorMsg("找不到对应记录");
  7545. }
  7546. catch (Exception ex)
  7547. {
  7548. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7549. returnErrorMsg("操作失败");
  7550. }
  7551. }
  7552. }
  7553. public void get_erp_invoicing_back()
  7554. {
  7555. if (UrlPostParmsCheck("id"))
  7556. {
  7557. try
  7558. {
  7559. string id = GetPostString("id");
  7560. CeErpBill entiy = CeErpBill.Get(id);
  7561. if (entiy != null)
  7562. {
  7563. if (entiy.state == 0)
  7564. {
  7565. returnErrorMsg("发票还未开具");
  7566. return;
  7567. }
  7568. string[] billOrderList = entiy.billOrderId.Split(',');
  7569. int iTag = 0;
  7570. entiy.fplsh = "";
  7571. entiy.fpdm = "";
  7572. entiy.fphm = "";
  7573. foreach (string billOrderId in billOrderList)
  7574. {
  7575. iTag++;
  7576. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7577. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7578. {
  7579. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7580. try
  7581. {
  7582. Invoicing_get_response_Obj iObj = null;
  7583. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7584. if (iObj != null)
  7585. {
  7586. entiy.state = 2;
  7587. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7588. entiy.fpdm += iObj.list[0].c_fpdm;
  7589. entiy.fphm += iObj.list[0].c_fphm;
  7590. if (iTag < billOrderList.Length)
  7591. {
  7592. entiy.fplsh += ",";
  7593. entiy.fpdm += ",";
  7594. entiy.fphm += ",";
  7595. }
  7596. entiy.Update();
  7597. }
  7598. StringBuilder sql = new StringBuilder();
  7599. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7600. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7601. returnSuccessMsg("开票成功");
  7602. }
  7603. catch (Exception ex)
  7604. {
  7605. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7606. }
  7607. return;
  7608. }
  7609. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7610. {
  7611. var res_obj = new
  7612. {
  7613. data = "开票中"
  7614. };
  7615. string ro_json = JsonConvert.SerializeObject(res_obj);
  7616. returnSuccess(ro_json);
  7617. return;
  7618. }
  7619. else
  7620. {
  7621. int eidx = res.IndexOf("c_resultmsg");
  7622. int lidx = res.IndexOf("c_status");
  7623. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7624. entiy.state = 5;
  7625. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7626. entiy.Update();
  7627. returnErrorMsg("开票失败");
  7628. return;
  7629. }
  7630. }
  7631. }
  7632. }
  7633. catch (Exception ex)
  7634. {
  7635. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7636. }
  7637. return;
  7638. }
  7639. }
  7640. public void get_erp_invoicing()
  7641. {
  7642. if (UrlPostParmsCheck("id"))
  7643. {
  7644. try
  7645. {
  7646. string id = GetPostString("id");
  7647. CeErpBill entiy = CeErpBill.Get(id);
  7648. if (entiy != null)
  7649. {
  7650. if (entiy.state == 0)
  7651. {
  7652. returnErrorMsg("发票还未开具");
  7653. return;
  7654. }
  7655. if (entiy.sendType == "纸质发票")
  7656. {
  7657. if (entiy.img.Length <= 0)
  7658. {
  7659. returnErrorMsg("查无纸质发票");
  7660. return;
  7661. }
  7662. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7663. returnSuccess(returnres);
  7664. return;
  7665. }
  7666. string[] billOrderList = entiy.billOrderId.Split(',');
  7667. int iTag = 0;
  7668. string fpUrl = "";
  7669. entiy.fplsh = "";
  7670. entiy.fpdm = "";
  7671. entiy.fphm = "";
  7672. foreach (string billOrderId in billOrderList)
  7673. {
  7674. iTag++;
  7675. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7676. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7677. {
  7678. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7679. Invoicing_get_response_Obj iObj = null;
  7680. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7681. if (iObj != null)
  7682. {
  7683. //entiy.state = 2;
  7684. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7685. entiy.fpdm += iObj.list[0].c_fpdm;
  7686. entiy.fphm += iObj.list[0].c_fphm;
  7687. if (iTag < billOrderList.Length)
  7688. {
  7689. entiy.fplsh += ",";
  7690. entiy.fpdm += ",";
  7691. entiy.fphm += ",";
  7692. }
  7693. entiy.Update();
  7694. fpUrl += iObj.list[0].c_url + ",";
  7695. }
  7696. //returnSuccess(res);
  7697. StringBuilder sql = new StringBuilder();
  7698. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7699. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7700. }
  7701. else
  7702. {
  7703. int eidx = res.IndexOf("c_resultmsg");
  7704. //int lidx = res.IndexOf("c_status");
  7705. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7706. //开票失败
  7707. entiy.state = 5;
  7708. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7709. entiy.Update();
  7710. returnErrorMsg("开票失败");
  7711. return;
  7712. }
  7713. }
  7714. var returnObj = new
  7715. {
  7716. data = fpUrl
  7717. };
  7718. string ro_json = JsonConvert.SerializeObject(returnObj);
  7719. returnSuccess(ro_json);
  7720. }
  7721. }
  7722. catch (Exception ex)
  7723. {
  7724. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7725. }
  7726. return;
  7727. }
  7728. }
  7729. public void save_erp_billimg()
  7730. {
  7731. if (UrlPostParmsCheck("id"))
  7732. {
  7733. string eid = GetPostString("id");
  7734. CeErpBill bill_entity = null;
  7735. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7736. if (bill_entity != null)
  7737. {
  7738. bill_entity.img = GetPostString("img");
  7739. bill_entity.executeTime = DateTime.Now;
  7740. bill_entity.state = 2;
  7741. bill_entity.Update();
  7742. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7743. returnSuccessMsg("保存成功");
  7744. }
  7745. return;
  7746. }
  7747. }
  7748. public void upd_erp_billreturnback()
  7749. {
  7750. if (UrlPostParmsCheck("id"))
  7751. {
  7752. int eid = GetPostInt("id");
  7753. CeErpBill bill_entity = null;
  7754. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7755. if (bill_entity != null)
  7756. {
  7757. bill_entity.state = 3;
  7758. bill_entity.returnReason = GetPostString("reason");
  7759. bill_entity.Update();
  7760. returnSuccessMsg("驳回成功!");
  7761. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7762. }
  7763. return;
  7764. }
  7765. }
  7766. public void cancel_erp_bill()
  7767. {
  7768. if (UrlPostParmsCheck("id"))
  7769. {
  7770. int eid = GetPostInt("id");
  7771. int detailValue = GetPostInt("detailvalue");
  7772. CeErpBill bill_entity = null;
  7773. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7774. string cres = "";
  7775. string gres = "";
  7776. if (bill_entity != null)
  7777. {
  7778. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7779. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  7780. {
  7781. int iTag = 0;
  7782. bill_entity.fplsh = "";
  7783. bill_entity.fpdm = "";
  7784. bill_entity.fphm = "";
  7785. foreach (string billOrderId in billOrderList)
  7786. {
  7787. iTag++;
  7788. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  7789. if (gres.IndexOf("success") != -1)
  7790. {
  7791. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  7792. Invoicing_get_response_Obj iObj = null;
  7793. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  7794. if (iObj != null)
  7795. {
  7796. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  7797. bill_entity.fpdm += iObj.list[0].c_fpdm;
  7798. bill_entity.fphm += iObj.list[0].c_fphm;
  7799. if (iTag < billOrderList.Length)
  7800. {
  7801. bill_entity.fplsh += ",";
  7802. bill_entity.fpdm += ",";
  7803. bill_entity.fphm += ",";
  7804. }
  7805. bill_entity.Update();
  7806. }
  7807. }
  7808. else
  7809. {
  7810. returnErrorMsg(gres);
  7811. return;
  7812. }
  7813. }
  7814. }
  7815. if (bill_entity.sendType == "纸质发票")
  7816. {
  7817. //作废
  7818. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  7819. //if (DateTime.Now.Month == extime.Month)
  7820. //{
  7821. //cres = taobaoHelper.cancel_invoicing(eid);
  7822. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  7823. //{
  7824. bill_entity.state = 4;//已作废
  7825. bill_entity.Update();
  7826. returnSuccessMsg("发票已作废");
  7827. return;
  7828. //}
  7829. //else
  7830. //{
  7831. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  7832. // bill_entity.Update();
  7833. // returnErrorMsg(cres);
  7834. // return;
  7835. //}
  7836. //}
  7837. //else
  7838. //{
  7839. // returnErrorMsg("纸质发票只能作废本月的发票");
  7840. // return;
  7841. //}
  7842. }
  7843. //红冲
  7844. int redTag = 0;
  7845. string[] fpdmList = bill_entity.fpdm.Split(',');
  7846. string[] fphmList = bill_entity.fphm.Split(',');
  7847. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  7848. {
  7849. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  7850. return;
  7851. }
  7852. foreach (string billOrderId in billOrderList)
  7853. {
  7854. redTag++;
  7855. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  7856. cres += onecres;
  7857. cres += ",";
  7858. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  7859. {
  7860. bill_entity.state = 4;//已作废
  7861. //bill_entity.Update();
  7862. //returnSuccessMsg("发票已红冲");
  7863. }
  7864. else if (onecres.IndexOf("重复冲红") != -1)
  7865. {
  7866. bill_entity.state = 4;//已作废
  7867. //bill_entity.Update();
  7868. //returnSuccessMsg("发票已红冲");
  7869. }
  7870. else
  7871. {
  7872. string errmsg = commonHelper.KeepChinese(onecres);
  7873. bill_entity.failerror += redTag + "&" + errmsg + "|";
  7874. }
  7875. }
  7876. bill_entity.Update();
  7877. if (cres.IndexOf("失败") != -1)
  7878. returnErrorMsg("红冲失败");
  7879. else
  7880. returnSuccessMsg("发票已红冲");
  7881. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  7882. return;
  7883. }
  7884. return;
  7885. }
  7886. }
  7887. public void del_erp_billorder()
  7888. {
  7889. if (UrlPostParmsCheck("id"))
  7890. {
  7891. string eid = GetPostString("id");
  7892. CeErpBill.Del(eid);
  7893. CeErpBill bill = CeErpBill.Get(eid);
  7894. if (bill != null)
  7895. {
  7896. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  7897. }
  7898. returnSuccessMsg("删除成功");
  7899. }
  7900. }
  7901. public void finish_erp_bill()
  7902. {
  7903. if (UrlPostParmsCheck("ids"))
  7904. {
  7905. string eids = GetPostString("ids");
  7906. string[] list = eids.Split(',');
  7907. foreach (string eid in list)
  7908. {
  7909. CeErpBill bill = CeErpBill.Get(eid);
  7910. if (bill != null)
  7911. {
  7912. bill.state = 2;
  7913. bill.Update();
  7914. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  7915. }
  7916. }
  7917. returnSuccessMsg("操作成功");
  7918. }
  7919. }
  7920. public void get_erp_returncash()
  7921. {
  7922. DataStruct dStruct = GetPostStruct();
  7923. List<string> lw = new List<string>();
  7924. string tid = GetPostString("tid");
  7925. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7926. string shopname = GetPostString("shopname");
  7927. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7928. string buyernick = GetPostString("buyer_nick");
  7929. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7930. string customer = GetPostString("customer");
  7931. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  7932. string returndate1 = GetPostString("returndate1");
  7933. string returndate2 = GetPostString("returndate2");
  7934. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  7935. if (dw.Length > 0) lw.Add(dw);
  7936. string finishDate1 = GetPostString("finishdate1");
  7937. string finishDate2 = GetPostString("finishdate2");
  7938. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  7939. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7940. string returntype = GetPostString("returntype");
  7941. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  7942. string returnvstate = GetPostString("returnvstate");
  7943. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  7944. dStruct.Order = "created desc";
  7945. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7946. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  7947. writeGridDataTableJson(dStruct.TotalCount, dt);
  7948. }
  7949. public void get_erp_staygoods()
  7950. {
  7951. DataStruct dStruct = GetPostStruct();
  7952. List<string> lw = new List<string>();
  7953. string tid = GetPostString("tid");
  7954. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7955. string shopname = GetPostString("shopname");
  7956. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  7957. string wangwang = GetPostString("wangwang");
  7958. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  7959. string customer = GetPostString("customer");
  7960. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  7961. string returndate1 = GetPostString("returndate1");
  7962. string returndate2 = GetPostString("returndate2");
  7963. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  7964. if (dw.Length > 0) lw.Add(dw);
  7965. string finishDate1 = GetPostString("finishdate1");
  7966. string finishDate2 = GetPostString("finishdate2");
  7967. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  7968. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7969. string returnvstate = GetPostString("returnvstate");
  7970. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  7971. string persuadetype = GetPostString("persuadetype");
  7972. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  7973. string customerOrg = GetPostString("customerOrg");
  7974. if (customerOrg.Length > 0)
  7975. {
  7976. lw.Add(string.Format("OrgID = {0}", customerOrg));
  7977. }
  7978. dStruct.Order = "creata_time desc";
  7979. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7980. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  7981. writeGridDataTableJson(dStruct.TotalCount, dt);
  7982. }
  7983. public void upd_erp_staygoods()
  7984. {
  7985. if (UrlPostParmsCheck("id"))
  7986. {
  7987. int eid = GetPostInt("id");
  7988. CeErpStayGoods entity = null;
  7989. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  7990. if (entity != null)
  7991. {
  7992. entity.audit_type = 1;
  7993. entity.audit_time = DateTime.Now;
  7994. entity.audit_u_id = CurrentUser.UserID;
  7995. entity.audit_u_name = CurrentUser.UserName;
  7996. entity.Update();
  7997. returnSuccessMsg("审核成功!");
  7998. return;
  7999. }
  8000. returnErrorMsg("找不到订单记录");
  8001. }
  8002. }
  8003. public void upd_erp_stayGoodsback()
  8004. {
  8005. if (UrlPostParmsCheck("id"))
  8006. {
  8007. int eid = GetPostInt("id");
  8008. CeErpStayGoods entity = null;
  8009. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8010. if (entity != null)
  8011. {
  8012. entity.audit_text = GetPostString("reason");
  8013. entity.audit_type = 2;
  8014. entity.audit_time = DateTime.Now;
  8015. entity.audit_u_id = CurrentUser.UserID;
  8016. entity.audit_u_name = CurrentUser.UserName;
  8017. entity.Update();
  8018. returnSuccessMsg("退回成功!");
  8019. return;
  8020. }
  8021. returnErrorMsg("找不到订单记录");
  8022. }
  8023. }
  8024. public void upd_erp_returncashverify()
  8025. {
  8026. if (UrlPostParmsCheck("ID"))
  8027. {
  8028. int eid = GetPostInt("ID");
  8029. CeErpReturnCash entity = null;
  8030. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8031. if (entity != null)
  8032. {
  8033. entity.cashstate = 1;
  8034. entity.verifytime = DateTime.Now;
  8035. entity.verifyuserid = CurrentUser.UserID;
  8036. entity.Update();
  8037. returnSuccessMsg("审核成功!");
  8038. return;
  8039. }
  8040. returnErrorMsg("找不到订单记录");
  8041. }
  8042. }
  8043. public void upd_all_erp_returncashverify()
  8044. {
  8045. if (UrlPostParmsCheck("ID"))
  8046. {
  8047. String[] list = GetPostString("ID").Split(',');
  8048. CeErpReturnCash entity = null;
  8049. for (int i = 0; i < list.Length; i++)
  8050. {
  8051. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8052. if (entity != null)
  8053. {
  8054. if (entity.cashstate == 1)
  8055. {
  8056. returnErrorMsg("已审核过的订单不需要在审核!");
  8057. return;
  8058. }
  8059. entity.cashstate = 1;
  8060. entity.verifytime = DateTime.Now;
  8061. entity.verifyuserid = CurrentUser.UserID;
  8062. entity.Update();
  8063. }
  8064. }
  8065. returnSuccessMsg("审核成功!");
  8066. return;
  8067. }
  8068. }
  8069. public void upd_erp_returncashback()
  8070. {
  8071. if (UrlPostParmsCheck("ID"))
  8072. {
  8073. int eid = GetPostInt("ID");
  8074. CeErpReturnCash entity = null;
  8075. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8076. if (entity != null)
  8077. {
  8078. entity.backreason = GetPostString("reason");
  8079. entity.cashstate = 2;
  8080. entity.verifytime = DateTime.Now;
  8081. entity.verifyuserid = CurrentUser.UserID;
  8082. entity.Update();
  8083. returnSuccessMsg("退回成功!");
  8084. return;
  8085. }
  8086. returnErrorMsg("找不到订单记录");
  8087. }
  8088. }
  8089. public void upd_erp_returnprice()
  8090. {
  8091. if (UrlPostParmsCheck("ID"))
  8092. {
  8093. int eid = GetPostInt("ID");
  8094. CeErpReturnCash entity = null;
  8095. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8096. if (entity != null)
  8097. {
  8098. if (entity.cashstate == 1)
  8099. {
  8100. returnErrorMsg("审核通过了不能改");
  8101. return;
  8102. }
  8103. entity.returnprice = GetPostDouble("returnprice");
  8104. entity.Update();
  8105. returnSuccessMsg("修改成功!");
  8106. return;
  8107. }
  8108. returnErrorMsg("找不到订单记录");
  8109. }
  8110. }
  8111. public void del_erp_returncash()
  8112. {
  8113. if (UrlPostParmsCheck("ID"))
  8114. {
  8115. int eid = GetPostInt("ID");
  8116. CeErpReturnCash.Del(eid);
  8117. returnSuccessMsg("操作成功");
  8118. return;
  8119. }
  8120. }
  8121. public void test_for_do_sql()
  8122. {
  8123. string sql = GetPostString("sqlstr");
  8124. if (sql.Length > 0)
  8125. {
  8126. try
  8127. {
  8128. DbHelper.DbConn.ExecuteNonQuery(sql);
  8129. var res_obj = new
  8130. {
  8131. data = "成功",
  8132. };
  8133. string ro_json = JsonConvert.SerializeObject(res_obj);
  8134. returnSuccess(ro_json);
  8135. }
  8136. catch (Exception ex)
  8137. {
  8138. var res_obj = new
  8139. {
  8140. data = ex.Message,
  8141. };
  8142. string ro_json = JsonConvert.SerializeObject(res_obj);
  8143. returnSuccess(ro_json);
  8144. }
  8145. }
  8146. }
  8147. public void get_user_info()
  8148. {
  8149. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8150. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8151. }
  8152. public void get_total_data()
  8153. {
  8154. int userId = CurrentUser.UserID;
  8155. string sql = "";
  8156. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8157. {
  8158. 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);
  8159. }
  8160. else
  8161. {
  8162. 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 " +
  8163. "(select ID from CE_ErpUser where ID = {0}) d " +
  8164. "left join " +
  8165. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8166. ") a on d.ID = a.id left join " +
  8167. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8168. ") b on a.id = b.id1 left join" +
  8169. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8170. ") c on a.id = c.id2;", userId);
  8171. }
  8172. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8173. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8174. }
  8175. public void get_date_area_total_data2()
  8176. {
  8177. int userId = CurrentUser.UserID;
  8178. string date_type = GetPostString("timetype");
  8179. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8180. string sql = "";
  8181. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8182. {
  8183. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8184. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8185. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8186. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8187. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8188. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8189. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8190. ") a on e.ID = a.id left join " +
  8191. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8192. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8193. ") b on a.id = b.id1 " +
  8194. "left join " +
  8195. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8196. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8197. ") c on a.id = c.id2 " +
  8198. "left join " +
  8199. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8200. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8201. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8202. }
  8203. else
  8204. {
  8205. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8206. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8207. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8208. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8209. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8210. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8211. ") a on e.ID = a.id left join " +
  8212. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8213. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8214. ") c on a.id = c.id2 " +
  8215. "left join " +
  8216. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8217. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8218. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8219. }
  8220. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8221. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8222. }
  8223. public void get_date_area_total_data()
  8224. {
  8225. int userId = CurrentUser.UserID;
  8226. string date_type = GetPostString("timetype");
  8227. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8228. string date1 = searchDT[0].ToString();
  8229. string date2 = searchDT[1].ToString();
  8230. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8231. {
  8232. SqlParameter[] sqlParameter ={
  8233. new SqlParameter("@userId", SqlDbType.Int,4),
  8234. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8235. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8236. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8237. };
  8238. sqlParameter[0].Value = userId;
  8239. sqlParameter[1].Value = date1;
  8240. sqlParameter[2].Value = date2;
  8241. sqlParameter[3].Direction = ParameterDirection.Output;
  8242. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8243. string res = sqlParameter[3].Value.ToString();
  8244. var res_obj = new
  8245. {
  8246. data = res
  8247. };
  8248. string ro_json = JsonConvert.SerializeObject(res_obj);
  8249. returnSuccess(ro_json);
  8250. }
  8251. else
  8252. {
  8253. SqlParameter[] sqlParameter ={
  8254. new SqlParameter("@userId", SqlDbType.Int,4),
  8255. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8256. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8257. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8258. };
  8259. sqlParameter[0].Value = userId;
  8260. sqlParameter[1].Value = date1;
  8261. sqlParameter[2].Value = date2;
  8262. sqlParameter[3].Direction = ParameterDirection.Output;
  8263. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8264. string res = sqlParameter[3].Value.ToString();
  8265. var res_obj = new
  8266. {
  8267. data = res
  8268. };
  8269. string ro_json = JsonConvert.SerializeObject(res_obj);
  8270. returnSuccess(ro_json);
  8271. }
  8272. //writeGridDataViewJson(dt.Rows.Count, dv);
  8273. }
  8274. public void get_order_list()
  8275. {
  8276. string strFields = GetPostString("paraFields");
  8277. string strOrder = GetPostString("paraOrder");
  8278. string strWhere = GetPostString("paraWhere");
  8279. string strPageSize = GetPostString("paraPageSize");
  8280. DataStruct dStruct = GetPostStruct();
  8281. dStruct.PageSize = int.Parse(strPageSize);
  8282. dStruct.Fileds = strFields;
  8283. dStruct.Order = strOrder;
  8284. dStruct.MainWhere = strWhere;
  8285. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8286. writeGridDataTableJson(dStruct.TotalCount, dt);
  8287. }
  8288. ////获取待开始订单列表
  8289. //public void get_wait_design_order_list()
  8290. //{
  8291. // string date_type = GetPostString("date_type");
  8292. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8293. // DataStruct dStruct = GetPostStruct();
  8294. // dStruct.PageSize = 1000;
  8295. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8296. // List<string> lw = new List<string>();
  8297. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8298. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8299. // dStruct.Order = "WaitDesignTime asc";
  8300. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8301. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8302. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8303. //}
  8304. //获取完成单量排名
  8305. public void get_finish_order_count_ranking()
  8306. {
  8307. /* string date_type = GetPostString("date_type");
  8308. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8309. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8310. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8311. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8312. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8313. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8314. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8315. writeGridDataTableJson(0, new DataTable());
  8316. }
  8317. public void get_finish_order_amount_ranking()
  8318. {
  8319. /*string date_type = GetPostString("date_type");
  8320. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8321. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8322. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8323. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8324. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8325. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8326. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8327. writeGridDataTableJson(0, new DataTable());
  8328. }
  8329. public void get_finish_refund_count_ranking()
  8330. {
  8331. string date_type = GetPostString("date_type");
  8332. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8333. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8334. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8335. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8336. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8337. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8338. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8339. writeGridDataTableJson(dt.Rows.Count, dt);
  8340. }
  8341. public void get_finish_refund_amount_ranking()
  8342. {
  8343. string date_type = GetPostString("date_type");
  8344. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8345. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8346. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8347. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8348. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8349. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8350. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8351. writeGridDataTableJson(dt.Rows.Count, dt);
  8352. }
  8353. public void set_erp_finishorder_director()
  8354. {
  8355. if (UrlPostParmsCheck("ctid"))
  8356. {
  8357. string eid = GetPostString("ctid");
  8358. CeErpTradeCell entity = null;
  8359. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8360. if (entity != null)
  8361. {
  8362. entity.OrderState = 8;
  8363. entity.Update();
  8364. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8365. returnSuccessMsg("操作成功!");
  8366. return;
  8367. }
  8368. returnErrorMsg("找不到记录");
  8369. }
  8370. }
  8371. public void get_erp_placeregistlist()
  8372. {
  8373. DataStruct dStruct = GetPostStruct();
  8374. List<string> lw = new List<string>();
  8375. string outsid = GetPostString("outsid");
  8376. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8377. string memo = GetPostString("memo");
  8378. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8379. string filename = GetPostString("filename");
  8380. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8381. string islate = GetPostString("islate");
  8382. if (islate.Length > 0)
  8383. {
  8384. if (islate == "1")
  8385. lw.Add(string.Format("OutLate>0"));
  8386. else
  8387. lw.Add(string.Format("OutLate=0"));
  8388. }
  8389. string placedate1 = GetPostString("placedate1");
  8390. string placedate2 = GetPostString("placedate2");
  8391. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8392. if (dw.Length > 0) lw.Add(dw);
  8393. string deliveryDate1 = GetPostString("deliverydate1");
  8394. string deliveryDate2 = GetPostString("deliverydate2");
  8395. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8396. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8397. dStruct.Order = "ID desc";
  8398. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8399. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8400. writeGridDataTableJson(dStruct.TotalCount, dt);
  8401. }
  8402. public void ins_erp_placeregist()
  8403. {
  8404. if (UrlPostParmsCheck("id"))
  8405. {
  8406. string eid = GetPostString("id");
  8407. CeErpPlaceRegister entity = null;
  8408. if (eid == "0")//新增
  8409. {
  8410. entity = new CeErpPlaceRegister();
  8411. string xdTime = GetPostString("placeTime");
  8412. if (xdTime.Length > 0)
  8413. {
  8414. entity.PlactTime = Convert.ToDateTime(xdTime);
  8415. }
  8416. string fhTime = GetPostString("deliveryTime");
  8417. if (fhTime.Length > 0)
  8418. {
  8419. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8420. }
  8421. string preTime = GetPostString("preOutTime");
  8422. if (preTime.Length > 0)
  8423. {
  8424. entity.PreOutTime = Convert.ToDateTime(preTime);
  8425. }
  8426. entity.DeliveryCount = GetPostInt("deliveryCount");
  8427. entity.ReceiveCount = GetPostInt("receiveCount");
  8428. entity.OutSid = GetPostString("outSid");
  8429. entity.FileName = GetPostString("fileName");
  8430. entity.Memo = GetPostString("memo");
  8431. entity.AddUserId = CurrentUser.UserID;
  8432. entity.CreateTime = DateTime.Now;
  8433. entity.Img = GetPostString("img");
  8434. entity.Supplier = GetPostInt("supplier");
  8435. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8436. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8437. {
  8438. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8439. DateTime dt2 = (DateTime)entity.PreOutTime;
  8440. TimeSpan span = dt1.Subtract(dt2);
  8441. if (span.Days > 0)
  8442. {
  8443. entity.OutLate = span.Days;
  8444. }
  8445. }
  8446. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8447. entity.Create();
  8448. returnSuccessMsg("添加成功!");
  8449. return;
  8450. }
  8451. else //修改
  8452. {
  8453. entity = CeErpPlaceRegister.Get(eid);
  8454. if (entity != null)
  8455. {
  8456. string xdTime = GetPostString("placeTime");
  8457. if (xdTime.Length > 0)
  8458. {
  8459. entity.PlactTime = Convert.ToDateTime(xdTime);
  8460. }
  8461. string fhTime = GetPostString("deliveryTime");
  8462. if (fhTime.Length > 0)
  8463. {
  8464. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8465. }
  8466. string preTime = GetPostString("preOutTime");
  8467. if (preTime.Length > 0)
  8468. {
  8469. entity.PreOutTime = Convert.ToDateTime(preTime);
  8470. }
  8471. entity.DeliveryCount = GetPostInt("deliveryCount");
  8472. entity.ReceiveCount = GetPostInt("receiveCount");
  8473. if (entity.DeliveryCount == entity.ReceiveCount)
  8474. {
  8475. entity.CurState = "已完成";
  8476. }
  8477. else
  8478. {
  8479. entity.CurState = "未完成";
  8480. }
  8481. entity.OutSid = GetPostString("outSid");
  8482. entity.FileName = GetPostString("fileName");
  8483. entity.Memo = GetPostString("memo");
  8484. entity.Img = GetPostString("img");
  8485. entity.Supplier = GetPostInt("supplier");
  8486. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8487. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8488. {
  8489. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8490. DateTime dt2 = (DateTime)entity.PreOutTime;
  8491. TimeSpan span = dt1.Subtract(dt2);
  8492. if (span.Days > 0)
  8493. {
  8494. entity.OutLate = span.Days;
  8495. }
  8496. }
  8497. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8498. entity.Update();
  8499. returnSuccessMsg("修改成功");
  8500. return;
  8501. }
  8502. returnErrorMsg("找不到对应的记录");
  8503. return;
  8504. }
  8505. }
  8506. returnErrorMsg("缺少必要参数");
  8507. }
  8508. public void del_erp_placeregist()
  8509. {
  8510. string eid = GetPostString("id");
  8511. CeErpPlaceRegister.Del(eid);
  8512. returnSuccessMsg("删除成功!");
  8513. return;
  8514. }
  8515. public void ins_erp_placeregistbyorder()
  8516. {
  8517. string ctid = GetPostString("ctid");
  8518. if (ctid.Length > 0)
  8519. {
  8520. StringBuilder sql = new StringBuilder();
  8521. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8522. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8523. if (dt.Rows.Count > 0)
  8524. {
  8525. foreach (DataRow dr in dt.Rows)
  8526. {
  8527. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8528. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8529. entity.AddUserId = CurrentUser.UserID;
  8530. entity.tid = dr["tid"].ToString();
  8531. entity.Did = Convert.ToString(dr["ctid"]);
  8532. entity.splitTag = dr["SplitTag"].ToString();
  8533. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8534. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8535. if (pre_ctid.Length > 0)
  8536. {
  8537. sellmemo = sellmemo.Replace(pre_ctid, "");
  8538. }
  8539. sellmemo = sellmemo.Replace("[", "");
  8540. sellmemo = sellmemo.Replace("]", "");
  8541. entity.FileName = sellmemo;
  8542. string count = dr["ProductCount"].ToString();
  8543. int usecount = commonHelper.getIntCountFromString(count);
  8544. entity.DeliveryCount = usecount;
  8545. entity.CurState = "未完成";
  8546. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8547. {
  8548. entity.Supplier = 24;//dl手提袋定制
  8549. }
  8550. else
  8551. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8552. entity.CreateTime = DateTime.Now;
  8553. entity.Create();
  8554. }
  8555. returnSuccessMsg("操作成功");
  8556. return;
  8557. }
  8558. returnErrorMsg("没有找到对应订单");
  8559. return;
  8560. }
  8561. returnErrorMsg("缺少订单编号");
  8562. return;
  8563. }
  8564. public void get_erp_persuadelist()
  8565. {
  8566. DataStruct dStruct = GetPostStruct();
  8567. List<string> lw = new List<string>();
  8568. string ctid = GetPostString("ctid");
  8569. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8570. string shopname = GetPostString("shopname");
  8571. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8572. string buyernick = GetPostString("buyer_nick");
  8573. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8574. string customer = GetPostString("customer");
  8575. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8576. string returndate1 = GetPostString("returndate1");
  8577. string returndate2 = GetPostString("returndate2");
  8578. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8579. if (dw.Length > 0) lw.Add(dw);
  8580. string finishDate1 = GetPostString("finishdate1");
  8581. string finishDate2 = GetPostString("finishdate2");
  8582. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8583. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8584. string persuadetype = GetPostString("persuadetype");
  8585. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8586. string returnvstate = GetPostString("returnvstate");
  8587. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8588. dStruct.Order = "created desc";
  8589. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8590. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8591. writeGridDataTableJson(dStruct.TotalCount, dt);
  8592. }
  8593. public void upd_erp_returnpersuadeback()
  8594. {
  8595. if (UrlPostParmsCheck("ID"))
  8596. {
  8597. int eid = GetPostInt("ID");
  8598. CeErpPersuade entity = null;
  8599. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8600. if (entity != null)
  8601. {
  8602. entity.backreason = GetPostString("reason");
  8603. entity.pstate = 2;
  8604. entity.verifytime = DateTime.Now;
  8605. entity.verifyuserid = CurrentUser.UserID;
  8606. entity.Update();
  8607. returnSuccessMsg("退回成功!");
  8608. return;
  8609. }
  8610. returnErrorMsg("找不到订单记录");
  8611. }
  8612. }
  8613. public void upd_erp_returnpersuadeverify()
  8614. {
  8615. if (UrlPostParmsCheck("ID"))
  8616. {
  8617. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8618. {
  8619. returnErrorMsg("暂无权限审核");
  8620. return;
  8621. }
  8622. int eid = GetPostInt("ID");
  8623. CeErpPersuade entity = null;
  8624. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8625. if (entity != null)
  8626. {
  8627. entity.pstate = 1;
  8628. entity.verifytime = DateTime.Now;
  8629. entity.verifyuserid = CurrentUser.UserID;
  8630. entity.Update();
  8631. returnSuccessMsg("审核成功!");
  8632. return;
  8633. }
  8634. returnErrorMsg("找不到订单记录");
  8635. }
  8636. }
  8637. public void del_erp_persuade()
  8638. {
  8639. if (UrlPostParmsCheck("ID"))
  8640. {
  8641. int eid = GetPostInt("ID");
  8642. CeErpPersuade.Del(eid);
  8643. returnSuccessMsg("操作成功");
  8644. return;
  8645. }
  8646. }
  8647. public void get_erp_oldcustoupload()
  8648. {
  8649. DataStruct dStruct = GetPostStruct();
  8650. List<string> lw = new List<string>();
  8651. string buyernick = GetPostString("buyer_nick");
  8652. if (buyernick.Length > 0)
  8653. {
  8654. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8655. }
  8656. else
  8657. return;
  8658. dStruct.Order = "pay_time desc";
  8659. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8660. DataTable dt = null;
  8661. dt = WebCache.GetData("view_erptradecell", dStruct);
  8662. writeGridDataTableJson(dStruct.TotalCount, dt);
  8663. }
  8664. public void get_erp_checkorderlist()
  8665. {
  8666. DataStruct dStruct = GetPostStruct();
  8667. List<string> lw = new List<string>();
  8668. string tid = GetPostString("ctid");
  8669. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8670. string shopname = GetPostString("shopname");
  8671. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8672. string buyernick = GetPostString("buyer_nick");
  8673. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8674. string customer = GetPostString("customer");
  8675. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8676. string design = GetPostString("design");
  8677. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8678. string orderState = GetPostString("orderState");
  8679. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8680. string address = GetPostString("address");
  8681. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8682. string sellermemo = GetPostString("seller_memo");
  8683. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8684. string supplier = GetPostString("supplier");
  8685. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8686. {
  8687. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8688. }
  8689. else
  8690. {
  8691. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8692. }
  8693. string checkst = GetPostString("checkstate");
  8694. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8695. string date1 = GetPostString("date1");
  8696. string date2 = GetPostString("date2");
  8697. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8698. if (dw.Length > 0) lw.Add(dw);
  8699. string placedate1 = GetPostString("placedate1");
  8700. string placedate2 = GetPostString("placedate2");
  8701. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8702. if (fdw.Length > 0) lw.Add(fdw);
  8703. string price1 = GetPostString("price1");
  8704. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8705. string price2 = GetPostString("price2");
  8706. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8707. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8708. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8709. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8710. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8711. writeGridDataTableJson(dStruct.TotalCount, dt);
  8712. }
  8713. public void ins_erp_startCheck()
  8714. {
  8715. if (UrlPostParmsCheck("ctid"))
  8716. {
  8717. string eid = GetPostString("ctid");
  8718. CeErpTradeCell entity = null;
  8719. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8720. if (entity != null)
  8721. {
  8722. entity.MemoOpt = 4;
  8723. entity.Update();
  8724. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8725. CeErpSukuraData.createInfo(entity.ctid, 6);
  8726. returnSuccessMsg("操作成功!");
  8727. return;
  8728. }
  8729. returnErrorMsg("找不到记录");
  8730. }
  8731. }
  8732. public void upd_erp_sendXlw()
  8733. {
  8734. if (UrlPostParmsCheck("ctid"))
  8735. {
  8736. string eid = GetPostString("ctid");
  8737. CeErpTradeCell entity = null;
  8738. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8739. if (entity != null)
  8740. {
  8741. if (entity.IsSendGift == 1)
  8742. {
  8743. returnErrorMsg("请勿重复标记");
  8744. return;
  8745. }
  8746. entity.IsSendGift = 1;
  8747. entity.Update();
  8748. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8749. returnSuccessMsg("操作成功!");
  8750. return;
  8751. }
  8752. returnErrorMsg("找不到记录");
  8753. }
  8754. }
  8755. public void cancel_sendXlw()
  8756. {
  8757. if (UrlPostParmsCheck("ctid"))
  8758. {
  8759. string eid = GetPostString("ctid");
  8760. CeErpTradeCell entity = null;
  8761. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8762. if (entity != null)
  8763. {
  8764. if (entity.IsSendGift == 0)
  8765. {
  8766. returnErrorMsg("未标记小礼物");
  8767. return;
  8768. }
  8769. entity.IsSendGift = 0;
  8770. entity.Update();
  8771. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  8772. returnSuccessMsg("操作成功!");
  8773. return;
  8774. }
  8775. returnErrorMsg("找不到记录");
  8776. }
  8777. }
  8778. public void get_erp_designbill()
  8779. {
  8780. DataStruct dStruct = GetPostStruct();
  8781. List<string> lw = new List<string>();
  8782. int isMy = GetInt("my");
  8783. if (isMy == 1)
  8784. {
  8785. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  8786. }
  8787. string tid = GetPostString("tid");
  8788. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8789. string userName = GetPostString("design");
  8790. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  8791. string price1 = GetPostString("price1");
  8792. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  8793. string price2 = GetPostString("price2");
  8794. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  8795. string rePrice1 = GetPostString("rePrice1");
  8796. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  8797. string rePrice2 = GetPostString("rePrice2");
  8798. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  8799. string designerType = GetPostString("designerType");
  8800. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  8801. string orderState = GetPostString("orderState");
  8802. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  8803. string endTime1 = GetPostString("endTime1");
  8804. string endTime2 = GetPostString("endTime2");
  8805. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  8806. if (dw.Length > 0) lw.Add(dw);
  8807. string isDk = GetPostString("isDk");
  8808. if (isDk == "1")
  8809. {
  8810. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  8811. }
  8812. else if (isDk == "0")
  8813. {
  8814. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  8815. }
  8816. dStruct.Order = "oid, create_time desc";
  8817. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8818. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  8819. writeGridDataTableJson(dStruct.TotalCount, dt);
  8820. }
  8821. public void upd_erp_designerbill()
  8822. {
  8823. if (UrlPostParmsCheck("ID"))
  8824. {
  8825. string eid = GetPostString("ID");
  8826. CeErpDesignerBill entity = null;
  8827. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8828. if (entity != null)
  8829. {
  8830. if (GetPostDouble("designerpirce") > 0)
  8831. {
  8832. entity.realPrice = GetPostDouble("designerpirce");
  8833. entity.update_time = DateTime.Now;
  8834. entity.update_u_id = CurrentUser.UserID;
  8835. entity.update_u_name = CurrentUser.UserName;
  8836. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  8837. entity.Update();
  8838. returnSuccessMsg("操作成功!");
  8839. return;
  8840. }
  8841. else
  8842. {
  8843. entity.price = GetPostDouble("price");
  8844. entity.update_time = DateTime.Now;
  8845. entity.update_u_id = CurrentUser.UserID;
  8846. entity.update_u_name = CurrentUser.UserName;
  8847. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  8848. entity.Update();
  8849. returnSuccessMsg("操作成功!");
  8850. return;
  8851. }
  8852. }
  8853. returnErrorMsg("找不到记录");
  8854. }
  8855. }
  8856. public void audit_erp_designerbill()
  8857. {
  8858. if (UrlPostParmsCheck("ID"))
  8859. {
  8860. string eid = GetPostString("ID");
  8861. CeErpDesignerBill entity = null;
  8862. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8863. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  8864. if (entity != null)
  8865. {
  8866. entity.realPrice = GetPostDouble("designerpirce");
  8867. entity.update_time = DateTime.Now;
  8868. entity.update_u_id = CurrentUser.UserID;
  8869. entity.update_u_name = CurrentUser.UserName;
  8870. entity.isAudit = 1;
  8871. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8872. entity.Update();
  8873. if (orderEntity != null)
  8874. {
  8875. orderEntity.IsReadTag = 3;
  8876. orderEntity.Update();
  8877. }
  8878. returnSuccessMsg("操作成功!");
  8879. return;
  8880. }
  8881. returnErrorMsg("找不到记录");
  8882. }
  8883. }
  8884. public void all_audit_erp_designerbill()
  8885. {
  8886. if (UrlPostParmsCheck("idList"))
  8887. {
  8888. string[] list = GetPostString("idList").Split(',');
  8889. CeErpDesignerBill entity = null;
  8890. for (int i = 0; i < list.Length; i++)
  8891. {
  8892. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  8893. if (entity == null) return;
  8894. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  8895. if (orderEntity == null) return;
  8896. if (entity.realPrice == 0) entity.realPrice = entity.price;
  8897. entity.update_time = DateTime.Now;
  8898. entity.update_u_id = CurrentUser.UserID;
  8899. entity.update_u_name = CurrentUser.UserName;
  8900. entity.isAudit = 1;
  8901. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8902. entity.Update();
  8903. orderEntity.IsReadTag = 3;
  8904. orderEntity.Update();
  8905. }
  8906. returnSuccessMsg("操作成功!");
  8907. return;
  8908. }
  8909. }
  8910. public void get_erp_sameorders()
  8911. {
  8912. if (UrlPostParmsCheck("ctid"))
  8913. {
  8914. string eid = GetPostString("ctid");
  8915. CeErpTradeCell entity = null;
  8916. entity = CeErpTradeCell.GetByCtid(eid);
  8917. if (entity != null)
  8918. {
  8919. StringBuilder sql = new StringBuilder();
  8920. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  8921. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8922. var res = new
  8923. {
  8924. data = dt.Rows.Count
  8925. };
  8926. string ro_jsond = JsonConvert.SerializeObject(res);
  8927. returnSuccess(ro_jsond);
  8928. return;
  8929. }
  8930. returnErrorMsg("未找到订单");
  8931. return;
  8932. }
  8933. returnErrorMsg("缺少必要的参数");
  8934. }
  8935. public void get_erp_islasthavesameorder()
  8936. {
  8937. if (UrlPostParmsCheck("ctid"))
  8938. {
  8939. string eid = GetPostString("ctid");
  8940. string[] ctidList = eid.Split(',');
  8941. StringBuilder sql = new StringBuilder();
  8942. string tisCtid = "";
  8943. foreach (string ctid in ctidList)
  8944. {
  8945. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  8946. if (entity != null)
  8947. {
  8948. sql = new StringBuilder();
  8949. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  8950. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8951. if (dth.Rows.Count > 0)
  8952. {
  8953. tisCtid += entity.ctid;
  8954. tisCtid += ",";
  8955. }
  8956. }
  8957. }
  8958. if (tisCtid.Length > 0)
  8959. {
  8960. var res = new
  8961. {
  8962. data = tisCtid
  8963. };
  8964. string ro_jsond = JsonConvert.SerializeObject(res);
  8965. returnSuccess(ro_jsond);
  8966. }
  8967. else
  8968. {
  8969. var res = new
  8970. {
  8971. data = ""
  8972. };
  8973. string ro_jsond = JsonConvert.SerializeObject(res);
  8974. returnSuccess(ro_jsond);
  8975. }
  8976. return;
  8977. }
  8978. returnErrorMsg("缺少必要的参数");
  8979. }
  8980. public void file_client_down_url()
  8981. {
  8982. if (!UrlPostParmsCheck("userId"))
  8983. {
  8984. returnErrorMsg("缺少必要的参数");
  8985. }
  8986. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  8987. }
  8988. public void checkout_form_data()
  8989. {
  8990. if (!UrlPostParmsCheck("tid"))
  8991. {
  8992. returnErrorMsg("缺少必要的参数");
  8993. }
  8994. string tid = GetPostString("tid");
  8995. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  8996. if (ceErpOrderFormData != null)
  8997. {
  8998. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  8999. returnSuccess(ro_jsond);
  9000. return;
  9001. }
  9002. returnErrorMsg("尚未有文件!");
  9003. }
  9004. public void back_supplier_audit()
  9005. {
  9006. int userId = CurrentUser.UserID;
  9007. StringBuilder sql = new StringBuilder();
  9008. 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);
  9009. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9010. if (dt.Rows.Count > 0)
  9011. {
  9012. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9013. }
  9014. else
  9015. {
  9016. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9017. }
  9018. }
  9019. public void back_supplier_query()
  9020. {
  9021. string eid = GetPostString("ctid");
  9022. if (eid != "")
  9023. {
  9024. StringBuilder sql = new StringBuilder();
  9025. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9026. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9027. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9028. }
  9029. else
  9030. {
  9031. returnErrorMsg("找不到订单记录");
  9032. return;
  9033. }
  9034. }
  9035. public void verified_to_order()
  9036. {
  9037. int userId = CurrentUser.UserID;
  9038. StringBuilder sql = new StringBuilder();
  9039. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9040. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9041. if (dt.Rows.Count > 0)
  9042. {
  9043. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9044. }
  9045. else
  9046. {
  9047. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9048. }
  9049. }
  9050. public void upd_supplier_audit()
  9051. {
  9052. if (UrlPostParmsCheck("ctid"))
  9053. {
  9054. string eid = GetPostString("ctid");
  9055. string reason = GetPostString("returnreason");
  9056. CeErpTradeCell entity = null;
  9057. CeWithdraw withdraw = null;
  9058. withdraw = CeWithdraw.GetByTid(eid);
  9059. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9060. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9061. {
  9062. if (withdraw != null)
  9063. {
  9064. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9065. {
  9066. returnSuccessMsg("您没有权限操作!");
  9067. return;
  9068. }
  9069. else
  9070. {
  9071. if (reason.Equals("1"))
  9072. {
  9073. if (entity.OrderState == -1)
  9074. {
  9075. if (entity.FinishPlaceTime == null)
  9076. {
  9077. entity.OrderState = 2;
  9078. }
  9079. else
  9080. {
  9081. entity.OrderState = 6;
  9082. }
  9083. }
  9084. entity.Update();
  9085. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9086. if (withdraw != null)
  9087. {
  9088. withdraw.status = int.Parse(reason);
  9089. withdraw.Update();
  9090. }
  9091. returnSuccessMsg("操作成功!");
  9092. return;
  9093. }
  9094. else
  9095. {
  9096. withdraw.status = int.Parse(reason);
  9097. withdraw.acknowledgingtime = DateTime.Now;
  9098. withdraw.Update();
  9099. returnSuccessMsg("查看详细请点击线下订单查询");
  9100. return;
  9101. }
  9102. }
  9103. }
  9104. // 第一个字符是 'N'
  9105. }
  9106. if (eid[0] != 'N')
  9107. {
  9108. }
  9109. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9110. {
  9111. entity.IsVerifyToSupplier = false;
  9112. entity.IsReturn = 1;
  9113. entity.ReturnTime = DateTime.Now;
  9114. entity.ReturnReason = reason;
  9115. if (entity.OrderState == 6)
  9116. {
  9117. entity.OrderState = 5;
  9118. }
  9119. entity.Update();
  9120. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9121. if (withdraw != null)
  9122. {
  9123. withdraw.status = int.Parse(reason);
  9124. withdraw.Update();
  9125. }
  9126. returnSuccessMsg("操作成功!");
  9127. return;
  9128. }
  9129. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9130. {
  9131. ;
  9132. if (withdraw != null)
  9133. {
  9134. withdraw.status = int.Parse(reason);
  9135. withdraw.acknowledgingtime = DateTime.Now;
  9136. withdraw.Update();
  9137. returnSuccessMsg("供应商取消撤回!");
  9138. return;
  9139. }
  9140. }
  9141. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9142. {
  9143. if (entity.OrderState == -1)
  9144. {
  9145. if (entity.FinishPlaceTime == null)
  9146. {
  9147. entity.OrderState = 2;
  9148. }
  9149. else
  9150. {
  9151. entity.OrderState = 3;
  9152. }
  9153. commonHelper.getCytPrice(entity);
  9154. }
  9155. entity.Update();
  9156. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9157. if (withdraw != null)
  9158. {
  9159. withdraw.status = int.Parse(reason);
  9160. withdraw.Update();
  9161. }
  9162. returnSuccessMsg("操作成功!");
  9163. return;
  9164. }
  9165. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9166. {
  9167. if (withdraw == null)
  9168. {
  9169. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9170. return;
  9171. }
  9172. }
  9173. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9174. {
  9175. if (withdraw != null)
  9176. {
  9177. withdraw.status = int.Parse(reason);
  9178. withdraw.acknowledgingtime = DateTime.Now;
  9179. withdraw.Update();
  9180. returnSuccessMsg("查看详细请点击线下订单查询");
  9181. return;
  9182. }
  9183. }
  9184. return;
  9185. }
  9186. }
  9187. //校验报价
  9188. public void refund_order_tip()
  9189. {
  9190. int userid = CurrentUser.UserID;
  9191. int sectionId = CurrentUser.UserPost.OrgID;
  9192. StringBuilder sql = new StringBuilder();
  9193. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9194. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9195. List<string> ids = new List<string>();
  9196. if (dth.Rows.Count > 0)
  9197. {
  9198. foreach (DataRow dr in dth.Rows)
  9199. {
  9200. ids.Add(dr["ID"].ToString());
  9201. }
  9202. try
  9203. {
  9204. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9205. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9206. }
  9207. catch (Exception ex)
  9208. {
  9209. }
  9210. }
  9211. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9212. }
  9213. public void refund_order_Design()
  9214. {
  9215. int userid = CurrentUser.UserID;
  9216. int sectionId = CurrentUser.UserPost.OrgID;
  9217. StringBuilder sql = new StringBuilder();
  9218. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9219. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9220. List<string> ids = new List<string>();
  9221. if (dth.Rows.Count > 0)
  9222. {
  9223. foreach (DataRow dr in dth.Rows)
  9224. {
  9225. ids.Add(dr["ID"].ToString());
  9226. }
  9227. try
  9228. {
  9229. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9230. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9231. }
  9232. catch (Exception ex)
  9233. {
  9234. }
  9235. }
  9236. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9237. }
  9238. public void change_order_info()
  9239. {
  9240. int userid = CurrentUser.UserID;
  9241. StringBuilder sql = new StringBuilder();
  9242. 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);
  9243. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9244. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9245. }
  9246. public void change_win_mome()
  9247. {
  9248. if (UrlPostParmsCheck("id,ctid"))
  9249. {
  9250. string id = GetPostString("id");
  9251. string ctid = GetPostString("ctid");
  9252. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9253. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9254. if (ce == null || ceErpMessageTip == null)
  9255. {
  9256. returnSuccessMsg("未找到对应的订单!");
  9257. return;
  9258. }
  9259. int type = GetPostInt("type");
  9260. string content = GetPostString("content");
  9261. if (type == 0)
  9262. {
  9263. content = content.Replace("(", "(");
  9264. content = content.Replace(")", ")");
  9265. string check = MidStrEx(content, "(", ")").Trim();
  9266. if (string.IsNullOrEmpty(check))
  9267. {
  9268. returnSuccessMsg("文件名格式不正确");
  9269. return;
  9270. }
  9271. }
  9272. ce.seller_memo = content;
  9273. ce.Update();
  9274. ceErpMessageTip.isVisit = true;
  9275. ceErpMessageTip.Update();
  9276. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9277. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9278. ApiVo apiVo = new ApiVo();
  9279. apiVo.orderNumber = ce.ctid;
  9280. apiVo.actionName = "demandDesign";
  9281. apiVo.orderRemarks = content;
  9282. apiVo.demandExamine = type + 1;
  9283. designHelper.API_WorkCore(apiVo);//demandDesign
  9284. returnSuccessMsg("修改成功!");
  9285. }
  9286. }
  9287. public static string MidStrEx(string sourse, string startstr, string endstr)
  9288. {
  9289. string result = string.Empty;
  9290. int startindex, endindex;
  9291. try
  9292. {
  9293. startindex = sourse.IndexOf(startstr);
  9294. if (startindex == -1)
  9295. return result;
  9296. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9297. endindex = tmpstr.IndexOf(endstr);
  9298. if (endindex == -1)
  9299. return result;
  9300. result = tmpstr.Remove(endindex);
  9301. }
  9302. catch (Exception ex)
  9303. {
  9304. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9305. }
  9306. return result;
  9307. }
  9308. public void refund_order_list()
  9309. {
  9310. int userid = CurrentUser.UserID;
  9311. int sectionId = CurrentUser.UserPost.OrgID;
  9312. StringBuilder sql = new StringBuilder();
  9313. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9314. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9315. DataStruct dStruct = GetPostStruct();
  9316. DataTable dt = null;
  9317. List<string> ids = new List<string>();
  9318. List<string> tids = new List<string>();
  9319. if (dth.Rows.Count > 0)
  9320. {
  9321. foreach (DataRow dr in dth.Rows)
  9322. {
  9323. tids.Add("'" + dr["tid"].ToString() + "'");
  9324. ids.Add(dr["id"].ToString());
  9325. }
  9326. try
  9327. {
  9328. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9329. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9330. List<string> lw = new List<string>();
  9331. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9332. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9333. dt = WebCache.GetData("view_orderlist", dStruct);
  9334. }
  9335. catch (Exception ex)
  9336. {
  9337. }
  9338. }
  9339. writeGridDataTableJson(dStruct.TotalCount, dt);
  9340. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9341. }
  9342. //新增
  9343. public void order_batch_downloads()
  9344. {
  9345. string ceid = GetPostString("tid");
  9346. String[] tid = ceid.Split(',');
  9347. order_batch_caiyingtong(tid);
  9348. /* (string success, string errors) = UploadFiles(tid);
  9349. returnSuccessMsg(success + errors);*/
  9350. return;
  9351. }
  9352. //报价接口
  9353. public void Get_To_Quote()
  9354. {
  9355. string ceid = GetPostString("ctid");
  9356. if (ceid != null)
  9357. {
  9358. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9359. if (entity != null)
  9360. {
  9361. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9362. {
  9363. return;
  9364. }
  9365. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9366. double price = 0;
  9367. if (cp == null)
  9368. {
  9369. JObject jsonObject12 = new JObject
  9370. {
  9371. { "UserId", "77886" },
  9372. { "Pwd", "lt666888" },
  9373. { "Filename", entity.seller_memo }
  9374. };
  9375. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9376. JObject jsonObjects1 = JObject.Parse(response1);
  9377. string ms1g = (string)jsonObjects1["msg"];
  9378. if (ms1g == "报价成功")
  9379. {
  9380. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9381. string data = (string)jsonObject1["price"];
  9382. 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 + "');";
  9383. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9384. returnSuccessMsg("获取报价成功:" + data);
  9385. price = Convert.ToDouble(data);
  9386. }
  9387. else
  9388. {
  9389. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9390. return;
  9391. }
  9392. }
  9393. String[] beizhu = entity.seller_memo.Split('-');
  9394. String chanp = "";
  9395. if (beizhu.Length > 0)
  9396. {
  9397. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9398. }
  9399. else
  9400. {
  9401. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9402. }
  9403. JObject jsonObject = new JObject
  9404. {
  9405. { "UserId", "77886" },
  9406. { "Pwd", "lt666888" },
  9407. { "Filename", chanp }
  9408. };
  9409. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9410. JObject jsonObjects = JObject.Parse(response);
  9411. string msg = (string)jsonObjects["msg"];
  9412. if (msg == "报价成功")
  9413. {
  9414. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9415. string data = (string)jsonObject1["price"];
  9416. 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 + "');";
  9417. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9418. returnSuccessMsg("获取报价成功:" + data);
  9419. price = Convert.ToDouble(data);
  9420. }
  9421. else
  9422. {
  9423. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9424. return;
  9425. }
  9426. if (price > 0)
  9427. {
  9428. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9429. if (ceErpTradeCellExtend == null)
  9430. {
  9431. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9432. ceErpTradeCellExtend.ctid = entity.ctid;
  9433. ceErpTradeCellExtend.payment_cyt = price;
  9434. ceErpTradeCellExtend.Create();
  9435. }
  9436. else
  9437. {
  9438. ceErpTradeCellExtend.payment_cyt = price;
  9439. ceErpTradeCellExtend.Update();
  9440. }
  9441. }
  9442. return;
  9443. }
  9444. }
  9445. else
  9446. {
  9447. returnErrorMsg("请至少选择一条数据");
  9448. return;
  9449. }
  9450. }
  9451. //新增
  9452. public void order_To_Supplier()
  9453. {
  9454. string ceid = GetPostString("tid");
  9455. String[] tid = ceid.Split(',');
  9456. if (tid.Length > 0)
  9457. {
  9458. try
  9459. {
  9460. for (int i = 0; i < tid.Length; i++)
  9461. {
  9462. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9463. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9464. entity.SupplierId = suid;
  9465. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9466. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9467. entity.Update();
  9468. }
  9469. }
  9470. catch (Exception ex)
  9471. {
  9472. returnErrorMsg("自动匹配供应商失败");
  9473. return;
  9474. }
  9475. }
  9476. else
  9477. {
  9478. returnErrorMsg("请至少选择一条数据");
  9479. return;
  9480. }
  9481. returnSuccessMsg("自动匹配供应商成功");
  9482. return;
  9483. }
  9484. public (string, string) UploadFiles(string[] urls)
  9485. {
  9486. string success = "";
  9487. string errors = "";
  9488. int userid = CurrentUser.UserID;
  9489. foreach (string url in urls)
  9490. {
  9491. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9492. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9493. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9494. {
  9495. JObject jsonObject = new JObject
  9496. {
  9497. { "Userid", "77886" },
  9498. { "pwd", "cyt86435015" },
  9499. { "content", base64FileContent },
  9500. { "ext", Path.GetExtension(fileName) }
  9501. };
  9502. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9503. JObject jsonObjects = JObject.Parse(response);
  9504. string msg = (string)jsonObjects["msg"];
  9505. if (msg.Equals("上传成功"))
  9506. {
  9507. success += url + " 上传成功";
  9508. }
  9509. else
  9510. {
  9511. errors += url + " 上传失败";
  9512. }
  9513. }
  9514. else
  9515. {
  9516. errors += url + " 格式出现问题";
  9517. }
  9518. }
  9519. if (urls.Length == 0)
  9520. {
  9521. return (success, errors);
  9522. }
  9523. return (success, errors);
  9524. }
  9525. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9526. {
  9527. return true; //总是接受
  9528. }
  9529. public static string HttpPost(string url, string param = null)
  9530. {
  9531. HttpWebRequest request;
  9532. //如果是发送HTTPS请求
  9533. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9534. {
  9535. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9536. request = WebRequest.Create(url) as HttpWebRequest;
  9537. request.ProtocolVersion = HttpVersion.Version10;
  9538. }
  9539. else
  9540. {
  9541. request = WebRequest.Create(url) as HttpWebRequest;
  9542. }
  9543. request.Method = "POST";
  9544. request.ContentType = "application/json";
  9545. request.Accept = "*/*";
  9546. request.Timeout = 120000;
  9547. request.AllowAutoRedirect = false;
  9548. StreamWriter requestStream = null;
  9549. WebResponse response = null;
  9550. string responseStr = null;
  9551. try
  9552. {
  9553. requestStream = new StreamWriter(request.GetRequestStream());
  9554. requestStream.Write(param);
  9555. requestStream.Close();
  9556. response = request.GetResponse();
  9557. if (response != null)
  9558. {
  9559. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9560. responseStr = reader.ReadToEnd();
  9561. reader.Close();
  9562. }
  9563. }
  9564. catch (Exception ex)
  9565. {
  9566. return ex.Message;
  9567. }
  9568. finally
  9569. {
  9570. request = null;
  9571. requestStream = null;
  9572. response = null;
  9573. }
  9574. return responseStr;
  9575. }
  9576. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9577. {
  9578. string base64FileContent;
  9579. string fileName;
  9580. using (WebClient webClient = new WebClient())
  9581. {
  9582. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9583. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9584. {
  9585. using (Stream stream = response.GetResponseStream())
  9586. {
  9587. using (MemoryStream memoryStream = new MemoryStream())
  9588. {
  9589. stream.CopyTo(memoryStream);
  9590. byte[] fileBytes = memoryStream.ToArray();
  9591. base64FileContent = Convert.ToBase64String(fileBytes);
  9592. fileName = response.Headers["Content-Disposition"];
  9593. if (!string.IsNullOrEmpty(fileName))
  9594. {
  9595. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9596. if (index >= 0)
  9597. {
  9598. fileName = fileName.Substring(index + 9).Trim('\"');
  9599. }
  9600. }
  9601. else
  9602. {
  9603. fileName = Path.GetFileName(downloadUrl);
  9604. }
  9605. }
  9606. }
  9607. }
  9608. }
  9609. return (fileName, base64FileContent);
  9610. }
  9611. //新增
  9612. public void order_batch_caiyingtong(string[] downloadUrls)
  9613. {
  9614. try
  9615. {
  9616. //遍历文件
  9617. DataStruct dStruct = GetPostStruct();
  9618. DataTable dt = null;
  9619. int userid = CurrentUser.UserID;
  9620. List<string> ids = new List<string>();//失败组
  9621. List<string> tids = new List<string>();
  9622. using (WebClient webClient = new WebClient())
  9623. {
  9624. foreach (var url in downloadUrls)
  9625. {
  9626. try
  9627. {
  9628. tids.Add("'" + url + "'");
  9629. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9630. if (entity != null)
  9631. {
  9632. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9633. if (cp == null)
  9634. {
  9635. JObject jsonObject = new JObject
  9636. {
  9637. { "Userid", "77886" },
  9638. { "pwd", "lt666888" },
  9639. { "Filename",entity.seller_memo }
  9640. };
  9641. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9642. JObject jsonObjects = JObject.Parse(response);
  9643. string msg = (string)jsonObjects["msg"];
  9644. if (msg == "报价成功")
  9645. {
  9646. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9647. DownloadAndConvertToBase64(url1);
  9648. }
  9649. else
  9650. {
  9651. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9652. }
  9653. }
  9654. else
  9655. {
  9656. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9657. JObject jsonObject = new JObject
  9658. {
  9659. { "Userid", "77886" },
  9660. { "pwd", "lt666888" },
  9661. { "Filename",chanp }
  9662. };
  9663. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9664. JObject jsonObjects = JObject.Parse(response);
  9665. string msg = (string)jsonObjects["msg"];
  9666. if (msg == "报价成功")
  9667. {
  9668. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9669. DownloadAndConvertToBase64(url1);
  9670. }
  9671. else
  9672. {
  9673. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9674. }
  9675. }
  9676. }
  9677. // 上传文件到FTP
  9678. }
  9679. catch (Exception ex)
  9680. {
  9681. Console.WriteLine($"An error occurred: {ex.Message}");
  9682. }
  9683. }
  9684. List<string> lw = new List<string>();
  9685. lw.Add(string.Format("( OrderState < 6 )"));
  9686. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9687. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9688. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9689. if (dt.Rows.Count > 0)
  9690. {
  9691. foreach (DataRow dr in dt.Rows)
  9692. {
  9693. ids.Add(dr["ctid"].ToString());
  9694. }
  9695. }
  9696. String ErrorMsgs = "";
  9697. foreach (String id in ids)
  9698. {
  9699. ErrorMsgs += id + ",";
  9700. }
  9701. if (ErrorMsgs.Length > 1)
  9702. {
  9703. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9704. }
  9705. if (ErrorMsgs.Length < 1)
  9706. {
  9707. ErrorMsgs = "上传成功";
  9708. returnSuccessMsg(ErrorMsgs);
  9709. }
  9710. else
  9711. {
  9712. returnErrorMsg("以下订单" + ErrorMsgs);
  9713. }
  9714. }
  9715. // 删除文件夹及其内容
  9716. /* Directory.Delete(localDirectory, true);*/
  9717. }
  9718. catch { }
  9719. }
  9720. public void get_center_data()
  9721. {
  9722. int userId = CurrentUser.UserID;
  9723. string postCode = CurrentUser.UserPost.Post.Code;
  9724. List<string> lw = new List<string>();
  9725. List<string> ww = new List<string>();
  9726. DateTime currentTime = DateTime.Now;
  9727. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9728. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9729. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9730. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9731. string sql = " SELECT ";
  9732. string startTime = "2023-10-01 11:22:31";
  9733. //设计
  9734. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9735. {
  9736. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9737. 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));
  9738. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9739. 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));
  9740. }
  9741. //客服
  9742. else if (postCode == "CustomerService" || postCode == "Director")
  9743. {
  9744. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9745. 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));
  9746. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9747. 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));
  9748. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9749. 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));
  9750. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9751. 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));
  9752. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9753. 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));
  9754. }
  9755. //售后
  9756. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9757. {
  9758. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9759. 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));
  9760. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9761. 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));
  9762. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9763. 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));
  9764. }
  9765. //下单部
  9766. else if (postCode == "Place" || postCode == "PlaceMr")
  9767. {
  9768. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9769. 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));
  9770. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9771. 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));
  9772. }
  9773. //车间
  9774. else if (postCode == "Supplier")
  9775. {
  9776. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9777. 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));
  9778. }
  9779. DataTable dt = new DataTable();
  9780. if (lw.Count > 0)
  9781. {
  9782. sql += string.Join(" , ", lw);
  9783. sql += " FROM ";
  9784. sql += string.Join(" , ", ww);
  9785. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9786. }
  9787. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9788. }
  9789. public void get_center_data_list()
  9790. {
  9791. int userId = CurrentUser.UserID;
  9792. string postCode = CurrentUser.UserPost.Post.Code;
  9793. string shopIds = CurrentUser.User.pemShop;
  9794. DataStruct dStruct = GetPostStruct();
  9795. List<string> lw = new List<string>();
  9796. DateTime currentTime = DateTime.Now;
  9797. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9798. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9799. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9800. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9801. string startTime = "2023-10-01 11:22:31";
  9802. int order_type = GetPostInt("order_type");
  9803. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9804. {
  9805. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  9806. if (order_type == 0)
  9807. {
  9808. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9809. }
  9810. else if (order_type == 3)
  9811. {
  9812. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  9813. }
  9814. else
  9815. {
  9816. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9817. }
  9818. }
  9819. //客服
  9820. if (postCode == "CustomerService" || postCode == "Director")
  9821. {
  9822. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  9823. if (order_type == 0)
  9824. {
  9825. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9826. }
  9827. else if (order_type == 1)
  9828. {
  9829. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9830. }
  9831. else if (order_type == 2)
  9832. {
  9833. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9834. }
  9835. else if (order_type == 3)
  9836. {
  9837. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  9838. }
  9839. else if (order_type == 4)
  9840. {
  9841. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9842. }
  9843. else
  9844. {
  9845. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9846. }
  9847. }
  9848. //售后
  9849. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9850. {
  9851. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9852. if (shopIds != "")
  9853. {
  9854. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9855. }
  9856. if (order_type == 2)
  9857. {
  9858. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9859. }
  9860. else if (order_type == 4)
  9861. {
  9862. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9863. }
  9864. else if (order_type == 5)
  9865. {
  9866. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  9867. }
  9868. else
  9869. {
  9870. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9871. }
  9872. }
  9873. //下单部
  9874. if (postCode == "Place" || postCode == "PlaceMr")
  9875. {
  9876. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9877. if (shopIds != "")
  9878. {
  9879. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9880. }
  9881. else if (order_type == 1)
  9882. {
  9883. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9884. }
  9885. else if (order_type == 2)
  9886. {
  9887. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9888. }
  9889. else
  9890. {
  9891. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9892. }
  9893. }
  9894. //车间
  9895. if (postCode == "Supplier")
  9896. {
  9897. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9898. if (order_type == 5)
  9899. {
  9900. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  9901. }
  9902. else
  9903. {
  9904. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9905. }
  9906. }
  9907. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9908. dStruct.Fileds = "tid,ctid";
  9909. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  9910. writeGridDataTableJson(dStruct.TotalCount, dt);
  9911. }
  9912. public void aftersale_audit_master()
  9913. {
  9914. if (UrlPostParmsCheck("ctid"))
  9915. {
  9916. string ctid = GetPostString("ctid");
  9917. if (ctid.Length > 0)
  9918. {
  9919. bool result = aftersale_data_change(ctid);
  9920. if (result)
  9921. {
  9922. returnSuccessMsg("修改成功!");
  9923. return;
  9924. }
  9925. }
  9926. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9927. }
  9928. }
  9929. public void aftersale_batch_audit_master()
  9930. {
  9931. if (UrlPostParmsCheck("ctids"))
  9932. {
  9933. string ctids = GetPostString("ctids");
  9934. if (ctids.Length > 0)
  9935. {
  9936. List<string> list = new List<string>();
  9937. string[] ctid_list = ctids.Split(',');
  9938. foreach (var item in ctid_list)
  9939. {
  9940. bool result = aftersale_data_change(item);
  9941. if (!result)
  9942. {
  9943. list.Add(item);
  9944. }
  9945. }
  9946. if (list.Count > 0)
  9947. {
  9948. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  9949. return;
  9950. }
  9951. returnSuccessMsg("修改成功!");
  9952. return;
  9953. }
  9954. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9955. }
  9956. }
  9957. public bool aftersale_data_change(string ctid)
  9958. {
  9959. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  9960. if (ceErpTradeCell != null)
  9961. {
  9962. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  9963. ceErpTradeCell.AfterSaleSupplierState = 0;
  9964. StringBuilder sql = new StringBuilder();
  9965. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  9966. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9967. CeErpTradeResponsible.DelByTid(ctid, 0);
  9968. 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 == "不理赔")
  9969. {
  9970. CeErpTradeResponsible.DelByTid(ctid, 1);
  9971. ceErpTradeCell.AfterSaleSupplierState = 1;
  9972. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9973. ceErpTradeCell.AfterSaleState = 4;
  9974. }
  9975. else
  9976. {
  9977. ceErpTradeCell.AfterSaleState = 3;
  9978. }
  9979. bool needCyt = false;
  9980. if (dt != null)
  9981. {
  9982. if (dt.Rows.Count == 1)
  9983. {
  9984. bool isEnd = false;
  9985. foreach (DataRow dr in dt.Rows)
  9986. {
  9987. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  9988. {
  9989. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9990. isEnd = true;
  9991. }
  9992. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  9993. {
  9994. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9995. isEnd = true;
  9996. }
  9997. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  9998. {
  9999. needCyt = true;
  10000. }
  10001. }
  10002. if (isEnd)
  10003. {
  10004. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10005. ceErpTradeCell.AfterSaleState = 4;
  10006. ceErpTradeCell.AfterSaleSupplierState = 1;
  10007. }
  10008. }
  10009. else
  10010. {
  10011. bool isAll = true;
  10012. foreach (DataRow dr in dt.Rows)
  10013. {
  10014. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10015. {
  10016. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10017. continue;
  10018. }
  10019. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10020. {
  10021. string path = "";
  10022. int OrgID = 0;
  10023. if (!Convert.IsDBNull(dr["OrgPath"]))
  10024. {
  10025. path = dr["OrgPath"].ToString();
  10026. }
  10027. if (!Convert.IsDBNull(dr["OrgID"]))
  10028. {
  10029. OrgID = Convert.ToInt32(dr["OrgID"]);
  10030. }
  10031. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10032. {
  10033. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10034. continue;
  10035. }
  10036. }
  10037. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10038. {
  10039. needCyt = true;
  10040. }
  10041. isAll = false;
  10042. }
  10043. if (isAll)
  10044. {
  10045. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10046. ceErpTradeCell.AfterSaleState = 4;
  10047. ceErpTradeCell.AfterSaleSupplierState = 1;
  10048. }
  10049. }
  10050. }
  10051. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10052. {
  10053. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10054. }
  10055. if (ceErpTradeCell.AfterSaleState == 4)
  10056. {
  10057. ApiVo apiVo = new ApiVo();
  10058. apiVo.orderNumber = ceErpTradeCell.ctid;
  10059. apiVo.actionName = "afterOver";
  10060. designHelper.API_WorkCore(apiVo); //afterOver
  10061. }
  10062. ceErpTradeCell.Update();
  10063. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10064. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10065. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10066. return true;
  10067. }
  10068. return false;
  10069. }
  10070. public void get_erp_wechatorder()
  10071. {
  10072. DataStruct dStruct = GetPostStruct();
  10073. List<string> lw = new List<string>();
  10074. string tid = GetPostString("tid");
  10075. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10076. string shopname = GetPostString("shopname");
  10077. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10078. string buyernick = GetPostString("buyer_nick");
  10079. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10080. string customer = GetPostString("customer");
  10081. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10082. string returndate1 = GetPostString("returndate1");
  10083. string returndate2 = GetPostString("returndate2");
  10084. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10085. if (dw.Length > 0) lw.Add(dw);
  10086. string finishDate1 = GetPostString("finishdate1");
  10087. string finishDate2 = GetPostString("finishdate2");
  10088. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10089. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10090. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10091. dStruct.Order = "created desc";
  10092. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10093. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10094. writeGridDataTableJson(dStruct.TotalCount, dt);
  10095. }
  10096. public void get_erp_wechatlist_sumprice()
  10097. {
  10098. DataStruct dStruct = GetPostStruct();
  10099. List<string> lw = new List<string>();
  10100. string tid = GetPostString("tid");
  10101. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10102. string shopname = GetPostString("shopname");
  10103. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10104. string buyernick = GetPostString("buyer_nick");
  10105. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10106. string customer = GetPostString("customer");
  10107. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10108. string returndate1 = GetPostString("returndate1");
  10109. string returndate2 = GetPostString("returndate2");
  10110. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10111. if (dw.Length > 0) lw.Add(dw);
  10112. string finishDate1 = GetPostString("finishdate1");
  10113. string finishDate2 = GetPostString("finishdate2");
  10114. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10115. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10116. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10117. string mainWhere = string.Join(" and ", lw.ToArray());
  10118. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10119. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10120. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10121. decimal total = 0;
  10122. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10123. {
  10124. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10125. }
  10126. var res = new
  10127. {
  10128. data = total
  10129. };
  10130. string ro_jsond = JsonConvert.SerializeObject(res);
  10131. returnSuccess(ro_jsond);
  10132. return;
  10133. }
  10134. public void get_erp_qr_waitdeliverylist()
  10135. {
  10136. DataStruct dStruct = GetPostStruct();
  10137. List<string> lw = new List<string>();
  10138. string tid = GetPostString("ctid");
  10139. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10140. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10141. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10142. var res_objz = new
  10143. {
  10144. restype = 1,
  10145. data = dt
  10146. };
  10147. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10148. returnSuccess(ro_jsonz);
  10149. }
  10150. public void get_erp_yield_list()
  10151. {
  10152. DataStruct dStruct = GetPostStruct();
  10153. List<string> lw = new List<string>();
  10154. string tid = GetPostString("ctid");
  10155. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10156. string shopname = GetPostString("shopname");
  10157. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10158. string buyernick = GetPostString("buyer_nick");
  10159. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10160. //if (tid.Length == 0 && buyernick.Length == 0)
  10161. //{
  10162. // lw.Add(string.Format("IsRefund<={0}", 1));
  10163. //}
  10164. string customer = GetPostString("customer");
  10165. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10166. string design = GetPostString("design");
  10167. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10168. string orderState = GetPostString("orderState");
  10169. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10170. string address = GetPostString("address");
  10171. 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));
  10172. string sellermemo = GetPostString("seller_memo");
  10173. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10174. string supplier = GetPostString("supplier");
  10175. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10176. string OrderArea = GetPostString("order_area");
  10177. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10178. string placedate1 = GetPostString("placedate1");
  10179. string placedate2 = GetPostString("placedate2");
  10180. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10181. if (fdw.Length > 0) lw.Add(fdw);
  10182. string price1 = GetPostString("price1");
  10183. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10184. string price2 = GetPostString("price2");
  10185. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10186. string unusualCon = GetPostString("unusualcon");
  10187. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10188. string posTag = CurrentUser.UserPost.Post.Code;
  10189. if (posTag == "Supplier")
  10190. {
  10191. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10192. }
  10193. lw.Add(string.Format("OrderState = 6 "));
  10194. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10195. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10196. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10197. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10198. writeGridDataTableJson(dStruct.TotalCount, dt);
  10199. }
  10200. public void change_erp_sup_state()
  10201. {
  10202. if (UrlPostParmsCheck("ctid"))
  10203. {
  10204. string ctid = GetPostString("ctid");
  10205. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10206. if (ceErpTradeCell != null)
  10207. {
  10208. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10209. if (ceErpTradeCellExtend == null)
  10210. {
  10211. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10212. ceErpTradeCellExtend.ctid = ctid;
  10213. ceErpTradeCellExtend.SupState = 1;
  10214. ceErpTradeCellExtend.Create();
  10215. }
  10216. else
  10217. {
  10218. ceErpTradeCellExtend.SupState = 1;
  10219. ceErpTradeCellExtend.Update();
  10220. }
  10221. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10222. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10223. return;
  10224. }
  10225. returnErrorMsg("找不到订单");
  10226. }
  10227. }
  10228. public void supplier_all_downs()
  10229. {
  10230. if (UrlPostParmsCheck("tids"))
  10231. {
  10232. string tids = GetPostString("tids");
  10233. if (tids != null && tids.Length > 0)
  10234. {
  10235. StringBuilder sql = new StringBuilder();
  10236. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10237. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10238. sql = new StringBuilder();
  10239. 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, "下载设计文件");
  10240. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10241. string[] list = tids.Split(',');
  10242. foreach (string ctid in list)
  10243. {
  10244. CeErpSukuraData.createInfo(ctid, 3);
  10245. }
  10246. designHelper.api_approveDesign(tids); //approveDesign
  10247. returnSuccessMsg("下载成功!");
  10248. return;
  10249. }
  10250. returnErrorMsg("下载订单更新失败");
  10251. }
  10252. }
  10253. public void uploaderFileSuccess()
  10254. {
  10255. if (UrlPostParmsCheck("fileName"))
  10256. {
  10257. string fileName = GetPostString("fileName");
  10258. ApiVo apiVo = new ApiVo();
  10259. apiVo.orderNumber = fileName;
  10260. apiVo.actionName = "finishDesign";
  10261. designHelper.API_WorkCore(apiVo);//finishDesign
  10262. returnSuccessMsg("");
  10263. }
  10264. }
  10265. public void get_sample2_order()
  10266. {
  10267. if (UrlPostParmsCheck("ctid"))
  10268. {
  10269. string ctid = GetPostString("ctid");
  10270. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10271. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10272. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10273. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10274. double total = 0.0;
  10275. double order_price = 0.0;
  10276. if (dt_bu.Rows.Count > 0)
  10277. {
  10278. foreach (DataRow dr in dt_bu.Rows)
  10279. {
  10280. total += Convert.ToDouble(dr["payment"]);
  10281. }
  10282. }
  10283. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10284. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10285. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10286. string tid = ctid.Replace("S_", "");
  10287. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10288. double paymant = 0.0;
  10289. if (entity != null)
  10290. {
  10291. paymant = entity.payment;
  10292. }
  10293. string return_reason = "";
  10294. if (dt_after != null && dt_after.Rows.Count > 0)
  10295. {
  10296. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10297. }
  10298. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10299. }
  10300. }
  10301. public void get_erp_design_status()
  10302. {
  10303. string designName = GetPostString("designName");
  10304. DataStruct dStruct = GetPostStruct();
  10305. if (designName.Length > 0)
  10306. {
  10307. 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";
  10308. sql_user += " and Name like '%" + designName + "%'";
  10309. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10310. List<string> ids_list = new List<string>();
  10311. if (user_table.Rows.Count > 0)
  10312. {
  10313. foreach (DataRow item in user_table.Rows)
  10314. {
  10315. ids_list.Add(item["id"].ToString());
  10316. string ids_s = item["TeamIds"].ToString();
  10317. if (ids_s.Length > 0)
  10318. {
  10319. ids_list.AddRange(ids_s.Split(','));
  10320. }
  10321. }
  10322. }
  10323. HashSet<string> set = new HashSet<string>(ids_list);
  10324. ids_list = set.ToList();
  10325. if (ids_list.Count > 0)
  10326. {
  10327. 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));
  10328. dStruct.MainWhere = sql;
  10329. DataTable dt = null;
  10330. dt = WebCache.GetData("view_ErpUser", dStruct);
  10331. writeGridDataTableJson(dStruct.TotalCount, dt);
  10332. }
  10333. }
  10334. }
  10335. public void change_erp_order_price()
  10336. {
  10337. string ctid = GetPostString("ctid");
  10338. double price = GetPostDouble("price");
  10339. if (ctid.Length > 0)
  10340. {
  10341. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10342. if (ceErpTradeCellExtend == null)
  10343. {
  10344. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10345. ceErpTradeCellExtend.ctid = ctid;
  10346. ceErpTradeCellExtend.payment_cyt = price;
  10347. ceErpTradeCellExtend.Create();
  10348. }
  10349. else
  10350. {
  10351. ceErpTradeCellExtend.payment_cyt = price;
  10352. ceErpTradeCellExtend.Update();
  10353. }
  10354. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10355. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10356. {
  10357. ceErpDataSendOrderInfo.isSync = false;
  10358. ceErpDataSendOrderInfo.Update();
  10359. }
  10360. if (ceErpDataSendOrderInfo == null)
  10361. {
  10362. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10363. ceErpDataSendOrderInfo.isSync = false;
  10364. ceErpDataSendOrderInfo.ctid = ctid;
  10365. ceErpDataSendOrderInfo.Create();
  10366. }
  10367. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10368. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10369. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10370. if (dth != null && dth.Rows.Count > 0)
  10371. {
  10372. dataSendOrderBean dataSendOrderBean = null;
  10373. foreach (DataRow item in dth.Rows)
  10374. {
  10375. try
  10376. {
  10377. dataSendOrderBean = new dataSendOrderBean();
  10378. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10379. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10380. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10381. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10382. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10383. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10384. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10385. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10386. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10387. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10388. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10389. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10390. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10391. if (result != null)
  10392. {
  10393. if ("0".Equals(result.errcode))
  10394. {
  10395. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10396. }
  10397. else
  10398. {
  10399. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10400. }
  10401. }
  10402. }
  10403. catch (Exception ex)
  10404. {
  10405. }
  10406. }
  10407. }
  10408. returnSuccessMsg("修改成功!");
  10409. return;
  10410. }
  10411. returnErrorMsg("找不到订单");
  10412. }
  10413. public void find_he_together()
  10414. {
  10415. string ctid = GetPostString("ctid");
  10416. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10417. List<string> list = new List<string>();
  10418. if (ceErpTradeCell != null)
  10419. {
  10420. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10421. {
  10422. 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);
  10423. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10424. if (table != null && table.Rows.Count > 0)
  10425. {
  10426. foreach (TableRow row in table.Rows)
  10427. {
  10428. }
  10429. }
  10430. }
  10431. }
  10432. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10433. }
  10434. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10435. {
  10436. //chy----19
  10437. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10438. //GD-CYT-----64
  10439. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10440. //ZHX----3
  10441. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10442. //JK----97
  10443. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10444. //ZT----70
  10445. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10446. //LHCY-----98
  10447. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10448. //XD-----90
  10449. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10450. //CYCY-----14
  10451. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10452. };
  10453. //其他改名
  10454. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10455. {
  10456. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10457. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10458. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10459. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10460. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10461. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10462. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10463. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10464. };
  10465. //不统计
  10466. List<int> no_suppliers = new List<int>()
  10467. {
  10468. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10469. };
  10470. //配件单
  10471. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10472. {
  10473. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10474. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10475. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10476. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10477. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10478. {"旗杆",new List<string>(){ "班旗" } },
  10479. {"牙签",new List<string>(){ "不干胶" } }
  10480. };
  10481. public void get_place_order_data()
  10482. {
  10483. string date1 = GetPostString("date1");
  10484. string date2 = GetPostString("date2");
  10485. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10486. DateTime start = DateTime.Parse(starttime);
  10487. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10488. DateTime end = DateTime.Parse(endtime);
  10489. if (date1 != null && date1.Length > 0)
  10490. {
  10491. DateTime dateTime = DateTime.Parse(date1);
  10492. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10493. start = DateTime.Parse(starttime);
  10494. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10495. end = DateTime.Parse(endtime);
  10496. }
  10497. if (date2 != null && date2.Length > 0)
  10498. {
  10499. DateTime dateTime = DateTime.Parse(date2);
  10500. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10501. end = DateTime.Parse(endtime);
  10502. }
  10503. 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);
  10504. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10505. //不干胶-----1,卡片-----29
  10506. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10507. foreach (DataRow row in data.Rows)
  10508. {
  10509. int productId = Convert.ToInt32(row["ProductId"]);
  10510. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10511. if (no_suppliers.Contains(supplierId))
  10512. {
  10513. continue;
  10514. }
  10515. string seller_memo = row["seller_memo"].ToString();
  10516. bool ispj = false;//是否配件单
  10517. bool isfirst = true;//第一个配
  10518. maps.Keys.ForEach(key =>
  10519. {
  10520. //备注包含配件
  10521. if (seller_memo.Contains(key) && isfirst)
  10522. {
  10523. List<string> list = maps[key];
  10524. ispj = true;
  10525. isfirst = false;
  10526. for (int i = 0; i < list.Count; i++)
  10527. {
  10528. if (seller_memo.Contains(list[i]))
  10529. {
  10530. ispj = false;
  10531. break;
  10532. }
  10533. }
  10534. }
  10535. });
  10536. if (ispj)
  10537. {
  10538. continue;
  10539. }
  10540. seller_memo = seller_memo.Replace("UV", "uv");
  10541. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10542. //吊牌归到卡片
  10543. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10544. seller_memo = seller_memo.Replace("卡套", "卡片");
  10545. seller_memo = seller_memo.Replace("封套", "卡片");
  10546. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10547. seller_memo = seller_memo.Replace("腰封", "卡片");
  10548. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10549. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10550. seller_memo = seller_memo.Replace("横幅", "条幅");
  10551. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10552. string map_key = "";
  10553. string type = "";
  10554. if (supplierMap.ContainsKey(supplierId))
  10555. {
  10556. foreach (var kvp in supplierMap[supplierId])
  10557. {
  10558. if (seller_memo.Contains(kvp.Key))
  10559. {
  10560. map_key = kvp.Value;
  10561. type = kvp.Value;
  10562. break;
  10563. }
  10564. }
  10565. }
  10566. if (map_key == "")
  10567. {
  10568. type = "其他";
  10569. map_key = "其他";
  10570. }
  10571. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10572. {
  10573. map_key = suppliers[supplierId];
  10574. }
  10575. if (supplierId == 70)
  10576. {
  10577. supplierId = 70;
  10578. }
  10579. map_key += "_" + row["SupplierName"].ToString();
  10580. Dictionary<string, int> map = null;
  10581. if (other_map.ContainsKey(map_key))
  10582. {
  10583. other_map.TryGetValue(map_key, out map);
  10584. }
  10585. else
  10586. {
  10587. map = new Dictionary<string, int>();
  10588. map.Add("dayDev", 0);//当天出货
  10589. map.Add("dayTotal", 0);//下单总数
  10590. map.Add("payTotal", 0);//500以上
  10591. map.Add("today", 0);//当天出货数量
  10592. map.Add("unusua", 0);//异常数
  10593. other_map.Add(map_key, map);
  10594. other_map.TryGetValue(map_key, out map);
  10595. }
  10596. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10597. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10598. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10599. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10600. {
  10601. map["dayTotal"]++;
  10602. if (supplierId == 97)
  10603. {
  10604. supplierId = 97;
  10605. }
  10606. }
  10607. if (Convert.ToDecimal(row["payment"]) >= 500)
  10608. {
  10609. map["payTotal"]++;
  10610. }
  10611. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10612. {
  10613. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10614. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10615. {
  10616. map["today"]++;
  10617. }
  10618. }
  10619. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10620. {
  10621. map["unusua"]++;
  10622. }
  10623. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10624. //GD-CYT-----64
  10625. DateTime two = palceTimeStart.AddHours(14);
  10626. DateTime three = palceTimeStart.AddHours(15);
  10627. DateTime four = palceTimeStart.AddHours(16);
  10628. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10629. {
  10630. //下午四点前 500-1000
  10631. string count = row["ProductCount"].ToString();
  10632. if (count != null && count.Length > 0)
  10633. {
  10634. int productCount = commonHelper.getPlaceProductCount(count);
  10635. if (productCount >= 500 && productCount <= 1000)
  10636. {
  10637. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10638. {
  10639. map["dayDev"]++;
  10640. }
  10641. }
  10642. }
  10643. }
  10644. //UV
  10645. else if ("uv".Equals(type))
  10646. {
  10647. //ZT----70
  10648. //ZHX----3
  10649. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10650. {
  10651. map["dayDev"]++;
  10652. }
  10653. //JK----97
  10654. //HZX----105
  10655. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10656. {
  10657. map["dayDev"]++;
  10658. if (supplierId == 97)
  10659. {
  10660. supplierId = 97;
  10661. Debug.WriteLine(map["dayTotal"].ToString() + "-" + map["dayDev"].ToString());
  10662. }
  10663. }
  10664. }
  10665. //帆布---52|条幅---27
  10666. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10667. {
  10668. //LHCY-----98
  10669. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10670. {
  10671. map["dayDev"]++;
  10672. }
  10673. }
  10674. //条幅
  10675. else if ("条幅".Equals(type))
  10676. {
  10677. //XD-----90
  10678. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10679. {
  10680. map["dayDev"]++;
  10681. }
  10682. }
  10683. //桌布
  10684. else if ("桌布".Equals(type))
  10685. {
  10686. //XD-----90
  10687. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10688. {
  10689. map["dayDev"]++;
  10690. }
  10691. }
  10692. //DL---10
  10693. //AYTW---119
  10694. //FS-CYT-DY ----80
  10695. //JK----97
  10696. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10697. {
  10698. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10699. {
  10700. map["dayDev"]++;
  10701. }
  10702. }
  10703. }
  10704. DataTable dt = new DataTable();
  10705. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10706. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10707. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10708. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10709. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10710. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10711. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10712. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10713. other_map.Keys.ForEach(key =>
  10714. {
  10715. DataRow dr = dt.NewRow();
  10716. Dictionary<string, int> map = other_map[key];
  10717. string[] key_list = key.Split('_');
  10718. dr[0] = key_list[0];
  10719. dr[1] = key_list[1];
  10720. if (key_list.Length > 2)
  10721. {
  10722. dr[1] += "(" + key_list[2] + ")";
  10723. }
  10724. dr[2] = map["dayTotal"];
  10725. dr[3] = map["payTotal"];
  10726. dr[4] = map["today"];
  10727. dr[5] = map["unusua"];
  10728. dr[6] = map["dayDev"];
  10729. double rate = 0.00;
  10730. if (map["dayDev"] > 0)
  10731. {
  10732. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10733. }
  10734. dr[7] = rate.ToString();
  10735. dt.Rows.Add(dr);
  10736. });
  10737. DataView dv = new DataView(dt);
  10738. dv.Sort = "SupplierName";
  10739. //dv.Sort = "AllOrder desc";
  10740. DataTable dtNew = dv.ToTable();
  10741. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10742. }
  10743. public void check_order_desing_info()
  10744. {
  10745. string ctid = GetPostString("ctid");
  10746. if (!string.IsNullOrEmpty(ctid))
  10747. {
  10748. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10749. if (ceErpTradeCell != null)
  10750. {
  10751. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10752. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10753. return;
  10754. }
  10755. returnErrorMsg("找不到订单");
  10756. return;
  10757. }
  10758. returnErrorMsg("找不到订单");
  10759. }
  10760. public void get_timeout_detail()
  10761. {
  10762. string poscode = CurrentUser.UserPost.Post.Code;
  10763. DataStruct dStruct = GetPostStruct();
  10764. List<string> lw = new List<string>();
  10765. string id = GetPostString("id");
  10766. string pay_date1 = GetPostString("pay_date1");
  10767. string pay_date2 = GetPostString("pay_date2");
  10768. int type = GetPostInt("type");
  10769. if (type == 0)
  10770. {
  10771. if (pay_date1.Length > 0)
  10772. {
  10773. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  10774. }
  10775. if (pay_date2.Length > 0)
  10776. {
  10777. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  10778. }
  10779. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  10780. }
  10781. if (type == 1)
  10782. {
  10783. if (pay_date1.Length > 0)
  10784. {
  10785. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  10786. }
  10787. if (pay_date2.Length > 0)
  10788. {
  10789. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  10790. }
  10791. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  10792. }
  10793. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10794. DataTable dt = null;
  10795. dt = WebCache.GetData("view_orderlist", dStruct);
  10796. writeGridDataTableJson(dStruct.TotalCount, dt);
  10797. }
  10798. public void saveUrgentChargePrice()
  10799. {
  10800. string ctid = GetPostString("ctid");
  10801. if (!string.IsNullOrEmpty(ctid))
  10802. {
  10803. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10804. if (ceErpTradeCell != null)
  10805. {
  10806. double price = GetPostDouble("price");
  10807. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  10808. if (ceErpTradeCellExtend == null)
  10809. {
  10810. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10811. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  10812. }
  10813. ceErpTradeCellExtend.urgentCharge = price;
  10814. if (ceErpTradeCellExtend.ID > 0)
  10815. {
  10816. ceErpTradeCellExtend.Update();
  10817. }
  10818. else
  10819. {
  10820. ceErpTradeCellExtend.Save();
  10821. }
  10822. returnSuccessMsg("修改成功!");
  10823. return;
  10824. }
  10825. returnErrorMsg("找不到订单");
  10826. return;
  10827. }
  10828. returnErrorMsg("找不到订单");
  10829. }
  10830. public void finish_erp_order()
  10831. {
  10832. string ctid = GetPostString("ctid");
  10833. if (!string.IsNullOrEmpty(ctid))
  10834. {
  10835. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  10836. {
  10837. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10838. if (ceErpTradeCell != null)
  10839. {
  10840. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  10841. ceErpTradeCell.Update();
  10842. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  10843. returnSuccessMsg("修改成功!");
  10844. return;
  10845. }
  10846. }
  10847. }
  10848. returnErrorMsg("找不到订单");
  10849. }
  10850. public void get_trade_order_list()
  10851. {
  10852. string tid = GetPostString("tid");
  10853. if (!string.IsNullOrEmpty(tid))
  10854. {
  10855. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  10856. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10857. writeGridDataTableJson(data.Rows.Count, data);
  10858. return;
  10859. }
  10860. returnErrorMsg("找不到订单");
  10861. }
  10862. public void save_cell_spu()
  10863. {
  10864. string ctid = GetPostString("ctid");
  10865. string spu_id = GetPostString("spu_id");
  10866. if (!string.IsNullOrEmpty(ctid))
  10867. {
  10868. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10869. if (ceErpTradeCellExtend == null)
  10870. {
  10871. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10872. ceErpTradeCellExtend.ctid = ctid;
  10873. }
  10874. ceErpTradeCellExtend.spu_id = spu_id;
  10875. if (ceErpTradeCellExtend.ID == 0)
  10876. {
  10877. ceErpTradeCellExtend.Create();
  10878. }
  10879. else
  10880. {
  10881. ceErpTradeCellExtend.Update();
  10882. }
  10883. returnSuccessMsg("修改成功!");
  10884. return;
  10885. }
  10886. returnErrorMsg("找不到订单");
  10887. }
  10888. public void change_express_info()
  10889. {
  10890. string ctid = GetPostString("ctid");
  10891. string transNo = GetPostString("transNo");
  10892. string transCom = GetPostString("transCom");
  10893. if (!string.IsNullOrEmpty(ctid))
  10894. {
  10895. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10896. if (ceErpTradeCellExtend == null)
  10897. {
  10898. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10899. ceErpTradeCellExtend.ctid = ctid;
  10900. }
  10901. ceErpTradeCellExtend.modExpressNo = transNo;
  10902. ceErpTradeCellExtend.modExpressCom = transCom;
  10903. ceErpTradeCellExtend.readMod = 2;
  10904. if (ceErpTradeCellExtend.ID == 0)
  10905. {
  10906. ceErpTradeCellExtend.Create();
  10907. }
  10908. else
  10909. {
  10910. ceErpTradeCellExtend.Update();
  10911. }
  10912. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  10913. returnSuccessMsg("修改成功!");
  10914. return;
  10915. }
  10916. returnErrorMsg("找不到订单");
  10917. }
  10918. public void get_change_express_list()
  10919. {
  10920. DataStruct dStruct = GetPostStruct();
  10921. List<string> lw = new List<string>();
  10922. int st = 2;
  10923. string tid = GetPostString("ctid");
  10924. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  10925. string shopname = GetPostString("shopname");
  10926. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10927. string buyernick = GetPostString("buyer_nick");
  10928. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10929. string sellermemo = GetPostString("seller_memo");
  10930. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10931. string supplier = GetPostString("supplier");
  10932. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10933. string customer = GetPostString("customer");
  10934. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10935. string design = GetPostString("design");
  10936. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10937. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  10938. string poscode = CurrentUser.UserPost.Post.Code;
  10939. if (poscode != "SysAdmin")
  10940. {
  10941. string shopid = CurrentUser.User.pemShop;
  10942. lw.Add(string.Format("shopId in ({0})", shopid));
  10943. }
  10944. lw.Add("readMod = 2");
  10945. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10946. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10947. writeGridDataTableJson(dStruct.TotalCount, dt);
  10948. }
  10949. public void deal_express_complete()
  10950. {
  10951. string ctid = GetPostString("ctid");
  10952. if (!string.IsNullOrEmpty(ctid))
  10953. {
  10954. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10955. if (ceErpTradeCellExtend == null)
  10956. {
  10957. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10958. ceErpTradeCellExtend.ctid = ctid;
  10959. }
  10960. ceErpTradeCellExtend.readMod = 1;
  10961. if (ceErpTradeCellExtend.ID == 0)
  10962. {
  10963. ceErpTradeCellExtend.Create();
  10964. }
  10965. else
  10966. {
  10967. ceErpTradeCellExtend.Update();
  10968. }
  10969. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  10970. returnSuccessMsg("修改成功!");
  10971. return;
  10972. }
  10973. returnErrorMsg("找不到订单");
  10974. }
  10975. public void aftersale_return_visit()
  10976. {
  10977. string ctid = GetPostString("ctid");
  10978. if (!string.IsNullOrEmpty(ctid))
  10979. {
  10980. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10981. if (ceErpTradeCellExtend == null)
  10982. {
  10983. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10984. ceErpTradeCellExtend.ctid = ctid;
  10985. }
  10986. ceErpTradeCellExtend.returnVisit = 1;
  10987. if (ceErpTradeCellExtend.ID == 0)
  10988. {
  10989. ceErpTradeCellExtend.Create();
  10990. }
  10991. else
  10992. {
  10993. ceErpTradeCellExtend.Update();
  10994. }
  10995. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  10996. if (ceErpTradeAfterSaleExtend != null)
  10997. {
  10998. ceErpTradeAfterSaleExtend.TextResult = "";
  10999. ceErpTradeAfterSaleExtend.Update();
  11000. }
  11001. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11002. returnSuccessMsg("修改成功!");
  11003. return;
  11004. }
  11005. returnErrorMsg("找不到订单");
  11006. }
  11007. public void orderPlaceInfo()
  11008. {
  11009. string ctids = GetPostString("ctids");
  11010. string[] list = ctids.Split(',');
  11011. foreach (string ctid in list)
  11012. {
  11013. CeErpSukuraData.createInfo(ctid, 3);
  11014. }
  11015. designHelper.api_approveDesign(ctids); //approveDesign
  11016. returnSuccessMsg("");
  11017. }
  11018. }
  11019. }