sync.order.cs 569 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI.WebControls;
  37. using Utils;
  38. using Utils.Serialization;
  39. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  40. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  41. using static SiteCore.taoObj.work_core_vo;
  42. using static System.Net.Mime.MediaTypeNames;
  43. namespace SiteCore.Handler
  44. {
  45. public partial class sync
  46. {
  47. public void get_erp_orderlist()
  48. {
  49. string poscode = CurrentUser.UserPost.Post.Code;
  50. DataStruct dStruct = GetPostStruct();
  51. //apiHelper.Api_SyncOrderByTime("598825");
  52. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  53. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  54. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  55. //banniuApiHelper.sendLogisticsInfo(null);
  56. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  57. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  58. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  59. //int sid = commonHelper.autoDistributeToSupplier(entity);
  60. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  61. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1740972223000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1741145016000,\"lines\":[{\"mark2\":[],\"num\":1,\"outerId\":\"\",\"payment\":10.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2208932202028/O1CN01SQkhPk1QqsBIMPegn_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":10.0,\"refOlId\":\"2484480075794418199\",\"refSkuId\":\"0\",\"refSpuId\":\"787248116865\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":10.0,\"singleFee\":10.0,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"饰品售后卡片定制珠宝项链购后感谢卡硬卡设计金银保养留言卡纸制作电商包裹贺卡高级明信片首饰好平小卡印刷\",\"totalFee\":10.0,\"totalPrice\":10.0,\"totalSellPrice\":10.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1740995566000,\"openBuyerId\":\"AAFoRHraABkUZRPgSx0XdWH-\",\"openBuyerNick\":\"t**\",\"openSellerNick\":\"麦郁旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1740972209000,\"payTime\":1740972216000,\"payment\":10.0,\"platServiceFee\":0.0,\"posCode\":\"maiyu\",\"posId\":598808,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"湖州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吴兴区\",\"receiverId\":\"82b7afe37a7abf32c5a68285642bc6c7$\",\"receiverState\":\"浙江省\",\"receiverTown\":\"织里镇\",\"refOid\":\"2484480075794418199\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"寄样-卡片-300克铜版纸-tb90589912-小元-2,寄样-卡片-300克雅柔纸-tb90589912-小元-2,寄样-卡片-300克蛋壳纸-tb90589912-小元-2,寄样-卡片-300克刚古水纹纸-tb90589912-小元-2,寄样-卡片-300克荷兰白卡纸-tb90589912-小元-2\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":10.0,\"totalPrice\":10.0,\"totalSellPrice\":10.0,\"type\":\"SALE\"}}");
  62. //refundTmcHelper.Api_TmcRefundMsg("{\"content\":{\"afterStatus\":\"SUCCESS\",\"createTime\":1735287446000,\"desc\":\"\",\"interceptInvestor\":\"NONE\",\"interceptStatus\":\"NONE\",\"interceptType\":\"NONE\",\"lines\":[{\"num\":2,\"outerId\":\"\",\"price\":50.0,\"refAid\":\"313001208133750610\",\"refAlId\":\"313001208133750610\",\"refBoughtSkuId\":\"\",\"refOid\":\"4181722704291751006\",\"refOlId\":\"4181722704291751006\",\"refSkuId\":\"0\",\"refSpuId\":\"865893808768\",\"refundFee\":98.86,\"refundStatus\":\"SUCCESS\",\"title\":\"新年会抽奖券定制2025蛇年公司活动正副可撕代金券打印纪念票根奖品兑换尾牙晚宴邀请卡号码牌创意入场券设计\",\"totalFee\":98.86,\"type\":1}],\"logisticsCompany\":\"\",\"logisticsOrderNo\":\"\",\"mark2\":[],\"openBuyerNick\":\"0**\",\"openSellerNick\":\"万慕办公旗舰店\",\"posCode\":\"wanmu\",\"posId\":598798,\"reason\":\"订单信息拍错(规格/尺码/颜色等)\",\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"\",\"receiverState\":\"\",\"receiverTown\":\"\",\"receiverZip\":\"\",\"refAid\":\"313001208133750610\",\"refOid\":\"4181722704291751006\",\"refPlatform\":\"TB\",\"refType\":\"TMALL\",\"refundCreateTime\":1735287358000,\"refundFee\":\"98.86\",\"refundPhase\":\"ON_SALE\",\"refundTime\":1735289443000,\"refundUpdateTime\":1735289443000,\"refundVersion\":1735287358100,\"senderAddress\":\"\",\"senderCity\":\"\",\"senderCountry\":\"中国\",\"senderDistrict\":\"\",\"senderMobile\":\"\",\"senderName\":\"\",\"senderPhone\":\"\",\"senderState\":\"\",\"senderTown\":\"\",\"senderZip\":\"\",\"status\":\"SUCCESS\",\"statusCode\":\"SUCCESS\",\"statusName\":\"退款成功\",\"totalFee\":\"98.86\",\"type\":\"REFUND\",\"updateTime\":1735289479000}}");
  63. List<string> lw = new List<string>();
  64. string tid = GetPostString("ctid");
  65. string date1 = GetPostString("date1");
  66. //12-1 修改
  67. string urgent = GetPostString("urgent");
  68. string back = GetPostString("back");
  69. string offlineSearch = GetPostString("offlineSearch");
  70. int paramsCount = 0;
  71. if (!string.IsNullOrWhiteSpace(urgent))
  72. {
  73. if (urgent.Equals("true"))
  74. {
  75. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  76. }
  77. }
  78. if (!string.IsNullOrWhiteSpace(back))
  79. {
  80. if (back.Equals("true"))
  81. {
  82. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  83. }
  84. }
  85. if (!string.IsNullOrWhiteSpace(offlineSearch))
  86. {
  87. if (offlineSearch.Equals("true"))
  88. {
  89. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  90. }
  91. }
  92. //end
  93. string date2 = GetPostString("date2");
  94. string buyernick = GetPostString("buyer_nick");
  95. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  96. {
  97. if (tid.Length <= 0 && buyernick.Length <= 0)
  98. {
  99. return;
  100. }
  101. }
  102. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  103. {
  104. if (tid.Length > 0)
  105. {
  106. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
  107. }
  108. if (buyernick.Length > 0)
  109. {
  110. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  111. }
  112. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  113. if (dw.Length > 0)
  114. {
  115. lw.Add(dw);
  116. }
  117. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  118. {
  119. string usershop = CurrentUser.User.pemShop;
  120. lw.Add(string.Format("ShopId in ({0})", usershop));
  121. }
  122. }
  123. else
  124. {
  125. if (ex_psize == 0)
  126. {
  127. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  128. }
  129. if (PKey != "admin")
  130. {
  131. string usershop = CurrentUser.User.pemShop;
  132. lw.Add(string.Format("ShopId in ({0})", usershop));
  133. paramsCount++;
  134. }
  135. }
  136. string uploaddate1 = GetPostString("uploaddate1");
  137. string uploaddate2 = GetPostString("uploaddate2");
  138. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  139. if (update.Length > 0) lw.Add(update);
  140. string deliverydate1 = GetPostString("deliverydate1");
  141. string deliverydate2 = GetPostString("deliverydate2");
  142. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  143. if (deliverydate.Length > 0)
  144. {
  145. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  146. };
  147. string shopname = GetPostString("shopname");
  148. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  149. string addwechat = GetPostString("addwechat");
  150. if (addwechat.Length > 0)
  151. {
  152. int addWt = Convert.ToInt32(addwechat);
  153. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  154. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  155. }
  156. string customer = GetPostString("customer");
  157. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  158. string design = GetPostString("design");
  159. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  160. string orderState = GetPostString("orderState");
  161. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  162. string address = GetPostString("address");
  163. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  164. string sellermemo = GetPostString("seller_memo");
  165. if (sellermemo.Length > 0)
  166. {
  167. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  168. }
  169. string backReason = GetPostString("backReason");
  170. if (backReason.Length > 0)
  171. {
  172. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  173. }
  174. string apdate1 = GetPostString("apdate1");
  175. string apdate2 = GetPostString("apdate2");
  176. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  177. if (dwap.Length > 0) lw.Add(dwap);
  178. string price1 = GetPostString("price1");
  179. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  180. string price2 = GetPostString("price2");
  181. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  182. string isoldcustomer = GetPostString("isoldcus");
  183. string finishdate1 = GetPostString("finishdate1");
  184. string finishdate2 = GetPostString("finishdate2");
  185. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  186. bool isFinish = false;
  187. if (finishdate.Length > 0)
  188. {
  189. lw.Add(finishdate);
  190. isFinish = true;
  191. paramsCount++;
  192. }
  193. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  194. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  195. if (ex_psize > 0)
  196. {
  197. int UserID = CurrentUser.UserID;
  198. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  199. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  200. {
  201. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  202. }
  203. dStruct.Order = "pay_time desc";
  204. }
  205. string isNew = GetPostString("isNew");
  206. if (isNew == "true")
  207. {
  208. lw.Add(string.Format("IsNew = {0}", 1));
  209. }
  210. string overtime = GetPostString("overtime");
  211. if (overtime == "1")
  212. {
  213. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  214. }
  215. String usePost = CurrentUser.UserPost.Post.Code;
  216. if (usePost.Equals("Operation") == true)
  217. {
  218. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  219. }
  220. else
  221. {
  222. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  223. }
  224. //dStruct.Fileds = "tid,ctid,SplitTag,pay_time,seller_nick,buyer_nick,payment,seller_memo,OrderState,status,CustomerTb,DesignUserName,DesignPrice,end_time,WaitDesignTime,FinishDesignTime,FinishDeliveryTime,buyer_message,SupplierName,OutSid,receiver_name,receiver_mobile,receiver_state,receiver_city,receiver_address,isRefund,IsUrgency";
  225. if (dStruct.PageSize == 100000)
  226. {
  227. dStruct.Order = "";
  228. }
  229. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  230. DataTable dt = null;
  231. string tablename = "view_orderlist";
  232. if (isFinish)
  233. {
  234. tablename = "view_orderlist_end";
  235. }
  236. dt = WebCache.GetData(tablename, dStruct);
  237. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  238. if (dt != null && dt.Rows.Count > 0)
  239. {
  240. foreach (DataRow dr in dt.Rows)
  241. {
  242. try
  243. {
  244. if (dr["refund_fees"] != null)
  245. {
  246. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  247. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  248. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  249. if (payment == refund_fees)
  250. {
  251. dr["refund_fees"] = Math.Round(refund_fees, 2);
  252. continue; // 跳过当前迭代
  253. }
  254. else if (refund_fees == total_fee)
  255. {
  256. dr["refund_fees"] = payment;
  257. continue; // 跳过当前迭代
  258. }
  259. else
  260. {
  261. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  262. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  263. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  264. }
  265. }
  266. // 对象操作
  267. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  268. ceErpTradeCell.ctid = dr["ctid"].ToString();
  269. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  270. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  271. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  272. if (dStruct.PageSize != 100000)
  273. {
  274. if (dr["DispatchSort"].ToString() == "2")
  275. {
  276. dr["gongchuang"] = 200;
  277. }
  278. else
  279. {
  280. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  281. dr["gongchuang"] = response.code;
  282. }
  283. }
  284. }
  285. catch (NullReferenceException ex)
  286. {
  287. // 处理空引用异常
  288. dr["refund_fees"] = "0.00";
  289. }
  290. }
  291. }
  292. writeGridDataTableJson(dStruct.TotalCount, dt);
  293. }
  294. public void get_erp_orderlist_sumprice()
  295. {
  296. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  297. return;
  298. List<string> lw = new List<string>();
  299. string tid = GetPostString("ctid");
  300. string date1 = GetPostString("date1");
  301. string date2 = GetPostString("date2");
  302. if (tid.Length > 0 || date1.Length > 0)
  303. {
  304. lw.Add(string.Format("ctid like '%{0}%'", tid));
  305. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  306. if (dw.Length > 0) lw.Add(dw);
  307. }
  308. else
  309. {
  310. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  311. }
  312. string shopname = GetPostString("shopname");
  313. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  314. string buyernick = GetPostString("buyer_nick");
  315. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  316. string customer = GetPostString("customer");
  317. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  318. string design = GetPostString("design");
  319. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  320. string orderState = GetPostString("orderState");
  321. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  322. string address = GetPostString("address");
  323. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  324. string sellermemo = GetPostString("seller_memo");
  325. if (sellermemo.Length > 0)
  326. {
  327. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  328. }
  329. string apdate1 = GetPostString("apdate1");
  330. string apdate2 = GetPostString("apdate2");
  331. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  332. if (dwap.Length > 0) lw.Add(dwap);
  333. string price1 = GetPostString("price1");
  334. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  335. string price2 = GetPostString("price2");
  336. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  337. string isoldcustomer = GetPostString("isoldcus");
  338. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  339. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  340. if (PKey != "admin")
  341. {
  342. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  343. lw.Add(string.Format("shopId in ({0})", usershop));
  344. }
  345. //dStruct.Fileds = "tid,ctid,SplitTag,pay_time,seller_nick,buyer_nick,payment,seller_memo,OrderState,status,CustomerTb,DesignUserName,DesignPrice,end_time,WaitDesignTime,FinishDesignTime,FinishDeliveryTime,buyer_message,SupplierName,OutSid,receiver_name,receiver_mobile,receiver_state,receiver_city,receiver_address,isRefund,IsUrgency";
  346. string mainWhere = string.Join(" and ", lw.ToArray());
  347. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  348. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  349. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  350. decimal total = 0;
  351. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  352. {
  353. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  354. }
  355. var res = new
  356. {
  357. data = total
  358. };
  359. string ro_jsond = JsonConvert.SerializeObject(res);
  360. returnSuccess(ro_jsond);
  361. return;
  362. }
  363. public void get_erp_CustomerServiceGather()
  364. {
  365. string userWhere = "", orderWhere = "";
  366. List<string> lw = new List<string>();
  367. string customer = GetPostString("customer");
  368. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  369. string shopname = GetPostString("shopname");
  370. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  371. string date1 = GetPostString("date1");
  372. string date2 = GetPostString("date2");
  373. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  374. if (dw.Length > 0) lw.Add(dw);
  375. orderWhere = string.Join(" and ", lw.ToArray());
  376. string sql = string.Format("select a.Name CusName,isnull(b.Amount,0) Amount, isnull(b.AllOrder,0) AllOrder, isnull(d.WaitRelease,0) WaitRelease, isnull(e.WaitRob,0) WaitRob, isnull(f.RefundCount,0) RefundCount, isnull(f.RefundSum,0) RefundSum " +
  377. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  378. "left join " +
  379. "( " +
  380. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  381. ") as b on a.ID = b.CustomerUserId " +
  382. "left join " +
  383. "( " +
  384. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  385. ") as d on a.ID = d.CustomerUserId " +
  386. "left join " +
  387. "( " +
  388. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  389. ") as e on a.ID = e.CustomerUserId " +
  390. "left join " +
  391. "( " +
  392. " select CustomerUserId, RefundCount, RefundSum from " +
  393. " ( " +
  394. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  395. " from CE_ErpTradeRefund a " +
  396. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  397. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  398. " group by CustomerUserId " +
  399. " ) as a " +
  400. ") as f on a.ID = f.CustomerUserId " +
  401. "where a.PostCode = 'CustomerService'",
  402. userWhere, orderWhere);
  403. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  404. writeGridDataTableJson(dt.Rows.Count, dt);
  405. //writeGridDataTableJson(dt.Rows.Count, dt);
  406. }
  407. //设计汇总
  408. public void get_erp_DesignerGather()
  409. {
  410. string userWhere = "", orderWhere = "";
  411. List<string> lw = new List<string>();
  412. string Designer = GetPostString("designer");
  413. int org = GetPostInt("org");
  414. if (Designer.Length > 0)
  415. {
  416. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  417. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  418. }
  419. else if (org > 0)
  420. {
  421. userWhere = string.Format(" where OrgID ={0}", org);
  422. }
  423. string shopname = GetPostString("shopname");
  424. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  425. string state = GetPostString("state");
  426. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  427. string OrderArea = GetPostString("order_area");
  428. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  429. string date1 = GetPostString("date1");
  430. string date2 = GetPostString("date2");
  431. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  432. if (dw.Length > 0) lw.Add(dw);
  433. string UpDate1 = GetPostString("UpDate1");
  434. string UpDate2 = GetPostString("UpDate2");
  435. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  436. if (dw.Length > 0) lw.Add(dw);
  437. orderWhere = string.Join(" and ", lw.ToArray());
  438. string sql = string.Format("select *,cast(cast(z.DesignFinish as float) / (case z.AllOrder when 0 then 1 else z.AllOrder end) * 100 as numeric(18,2)) as FinalizationRate from (" +
  439. "select a.Name DesignerName,isnull(b.Amount,0) Amount, isnull(b.AllOrder,0) AllOrder, isnull(d.WaitDesign,0) WaitDesign, isnull(e.Designing,0) Designing, isnull(g.DesignFinish,0) DesignFinish, isnull(f.RefundCount,0) RefundCount, isnull(f.RefundSum,0) RefundSum " +
  440. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  441. "left join " +
  442. "( " +
  443. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  444. ") as b on a.ID = b.DesignUserId " +
  445. "left join " +
  446. "( " +
  447. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  448. ") as d on a.ID = d.DesignUserId " +
  449. "left join " +
  450. "( " +
  451. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  452. ") as e on a.ID = e.DesignUserId " +
  453. "left join " +
  454. "( " +
  455. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  456. ") as g on a.ID = g.DesignUserId " +
  457. "left join " +
  458. "( " +
  459. " select CustomerUserId, RefundCount, RefundSum from " +
  460. " ( " +
  461. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  462. " from CE_ErpTradeRefund a " +
  463. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  464. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  465. " group by CustomerUserId " +
  466. " ) as a " +
  467. ") as f on a.ID = f.CustomerUserId " +
  468. "where a.PostCode = 'Designer') as z",
  469. userWhere, orderWhere);
  470. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  471. writeGridDataTableJson(dt.Rows.Count, dt);
  472. }
  473. //删除tradecell的订单
  474. public void del_erp_cellorder()
  475. {
  476. if (UrlPostParmsCheck("ctid"))
  477. {
  478. string eid = GetPostString("ctid");
  479. CeErpTradeCell.DelByCtid(eid);
  480. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  481. returnSuccessMsg("删除成功");
  482. }
  483. }
  484. public void clear_erp_refundstate()
  485. {
  486. if (UrlPostParmsCheck("ids"))
  487. {
  488. string eids = GetPostString("ids");
  489. string[] ctidList = eids.Split(',');
  490. foreach (string ctid in ctidList)
  491. {
  492. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  493. if (entity != null)
  494. {
  495. entity.IsRefund = 0;
  496. entity.Update();
  497. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  498. }
  499. else
  500. continue;
  501. }
  502. returnSuccessMsg("操作成功");
  503. return;
  504. }
  505. returnErrorMsg("缺少必要参数");
  506. }
  507. public void set_erp_urgency()
  508. {
  509. if (UrlPostParmsCheck("ctid"))
  510. {
  511. string eid = GetPostString("ctid");
  512. CeErpTradeCell entity = null;
  513. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  514. if (entity != null)
  515. {
  516. string utime = GetPostString("urgencytime");
  517. if (utime.Length > 0)
  518. {
  519. entity.UrgencyTime = Convert.ToDateTime(utime);
  520. }
  521. else
  522. {
  523. returnErrorMsg("请选择加急时间");
  524. return;
  525. }
  526. if (entity.OrderState <= 4)
  527. {
  528. //entity.seller_memo = entity.seller_memo + "-加急";
  529. string smemo = entity.seller_memo;
  530. int kindex = smemo.IndexOf(")");
  531. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  532. if (lastoneStr != "-")
  533. {
  534. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  535. }
  536. string prememo = smemo.Substring(0, kindex + 2);
  537. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  538. int lastkindex = lastmemo.IndexOf("(");
  539. DateTime urgtime = Convert.ToDateTime(utime);
  540. string newlastmemo = "";
  541. if (lastkindex == 0)
  542. {
  543. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  544. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  545. }
  546. else
  547. {
  548. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  549. }
  550. entity.seller_memo = prememo + newlastmemo;
  551. }
  552. entity.IsUrgency = true;
  553. entity.Update();
  554. ApiVo apiVo = new ApiVo();
  555. apiVo.orderNumber = entity.ctid;
  556. apiVo.actionName = "changeDesign";
  557. apiVo.orderRemarks = entity.seller_memo;
  558. apiVo.remarkSign = 3;
  559. designHelper.API_WorkCore(apiVo); //changeDesign
  560. CeErpSukuraData.createInfo(entity.ctid, 7);
  561. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  562. returnSuccessMsg("设置成功!");
  563. return;
  564. }
  565. returnErrorMsg("找不到记录");
  566. }
  567. }
  568. public void set_erp_reset()
  569. {
  570. if (UrlPostParmsCheck("ctid"))
  571. {
  572. string eid = GetPostString("ctid");
  573. CeErpTradeCell entity = null;
  574. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  575. if (entity != null)
  576. {
  577. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  578. {
  579. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  580. {
  581. returnErrorMsg("财务要求已下单已发货无法重置");
  582. return;
  583. }
  584. }
  585. entity.IsUrgency = false;
  586. entity.seller_memo = "";
  587. entity.OtherMemo = "";
  588. entity.OrderState = 0;
  589. entity.IsReturn = 0;
  590. //entity.IsRefund = 0;
  591. entity.MemoOpt = 0;
  592. entity.AfterSaleState = 0;
  593. entity.AfterSaleResponsible = "";
  594. entity.AfterSaleUserId = 0;
  595. entity.IsNeedBill = 0;
  596. entity.CustomerUserId = 0;
  597. entity.DesignUserId = 0;
  598. entity.SupplierId = 0;
  599. entity.PlaceUserId = 0;
  600. entity.ptid = "";
  601. entity.IsSample = 0;
  602. entity.IsXianHuo = 0;
  603. entity.isDianziOrder = 0;
  604. entity.DispatchSort = 0;
  605. entity.FinishPlaceTime = null;
  606. entity.Update();
  607. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  608. if (trade != null)
  609. {
  610. trade.seller_memo = "";
  611. trade.Update();
  612. }
  613. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  614. returnSuccessMsg("重置成功!");
  615. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  616. if (desginBill != null)
  617. {
  618. desginBill.isDel = 1;
  619. desginBill.Update();
  620. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  621. }
  622. ApiVo apiVo = new ApiVo();
  623. apiVo.orderNumber = entity.ctid;
  624. apiVo.actionName = "resetDesign";
  625. designHelper.API_WorkCore(apiVo);//resetDesign
  626. return;
  627. }
  628. returnErrorMsg("找不到记录");
  629. }
  630. }
  631. public void save_erp_sellermemo()
  632. {
  633. if (UrlPostParmsCheck("ctid"))
  634. {
  635. string ctid = GetPostString("ctid");
  636. CeErpTradeCell entity = null;
  637. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  638. if (entity != null)
  639. {
  640. string memo = GetPostString("seller_memo");
  641. memo = memo.Replace(" ", "");
  642. if (memo.Contains("补差"))
  643. {
  644. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  645. return;
  646. }
  647. if (entity.seller_memo != memo)
  648. {
  649. if (entity.IsSample == 2)
  650. {
  651. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  652. return;
  653. }
  654. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  655. {
  656. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  657. {
  658. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  659. return;
  660. }
  661. }
  662. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  663. }
  664. commonHelper.getCytPrice(entity);
  665. int memoopt = GetPostInt("MemoOpt");
  666. Boolean ismemoopt = false;
  667. if (memoopt > 0)
  668. {
  669. string stropt = "";
  670. if (memoopt == 1)
  671. {
  672. stropt = "“改稿”";
  673. ismemoopt = true;
  674. }
  675. else if (memoopt == 2)
  676. {
  677. stropt = "“定稿”";
  678. }
  679. else if (memoopt == 3)
  680. {
  681. stropt = "“查货”";
  682. CeErpSukuraData.createInfo(entity.ctid, 6);
  683. }
  684. entity.MemoOpt = Convert.ToInt32(memoopt);
  685. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  686. }
  687. if (entity.OrderState < 5)
  688. {
  689. memo = memo.Replace("(", "(");
  690. memo = memo.Replace(")", ")");
  691. }
  692. entity.seller_memo = memo;
  693. entity.Update();
  694. ApiVo apiVo = new ApiVo();
  695. apiVo.orderNumber = entity.ctid;
  696. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  697. apiVo.orderRemarks = memo;
  698. apiVo.remarkSign = memoopt;
  699. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  700. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  701. returnSuccessMsg("保存成功!");
  702. return;
  703. }
  704. returnErrorMsg("找不到记录");
  705. }
  706. }
  707. public void ins_erp_checkorder()
  708. {
  709. if (UrlPostParmsCheck("ctid"))
  710. {
  711. string ctid = GetPostString("ctid");
  712. CeErpTradeCell entity = null;
  713. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  714. if (entity != null)
  715. {
  716. if (entity.OrderState < 6)
  717. {
  718. returnErrorMsg("下单完成后才可查货");
  719. return;
  720. }
  721. /*if (entity.OrderState > 6)
  722. {
  723. returnErrorMsg("订单已发货");
  724. return;
  725. }*/
  726. if (entity.FinishPlaceTime != null)
  727. {
  728. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  729. {
  730. returnErrorMsg("下单时间不足,无法查货");
  731. return;
  732. }
  733. }
  734. entity.MemoOpt = 3;
  735. entity.CheckOrderTime = DateTime.Now;
  736. entity.Update();
  737. CeErpSukuraData.createInfo(entity.ctid, 6);
  738. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  739. returnSuccessMsg("操作成功!");
  740. return;
  741. }
  742. returnErrorMsg("找不到记录");
  743. }
  744. }
  745. public void save_erp_othermemo()
  746. {
  747. if (UrlPostParmsCheck("ctid"))
  748. {
  749. string ctid = GetPostString("ctid");
  750. CeErpTradeCell entity = null;
  751. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  752. if (entity != null)
  753. {
  754. entity.OtherMemo = GetPostString("otherMemo");
  755. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  756. {
  757. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  758. StringBuilder sql = new StringBuilder();
  759. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  760. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  761. if (dt != null && dt.Rows.Count > 0)
  762. {
  763. foreach (DataRow dr in dt.Rows)
  764. {
  765. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  766. {
  767. //品类一直
  768. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  769. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  770. if (ceErpSampleCustomer == null)
  771. {
  772. ceErpSampleCustomer = new CeErpSampleCustomer();
  773. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  774. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  775. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  776. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  777. ceErpSampleCustomer.shopId = entity.ShopId;
  778. }
  779. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  780. ceErpSampleCustomer.lastTid = entity.tid;
  781. if (ceErpSampleCustomer.ID > 0)
  782. {
  783. ceErpSampleCustomer.Update();
  784. }
  785. else
  786. {
  787. ceErpSampleCustomer.Create();
  788. }
  789. }
  790. }
  791. }
  792. }
  793. //if (entity.IsOldCustomer == 1)
  794. //{
  795. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  796. //{
  797. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  798. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  799. //}
  800. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  801. //{
  802. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  803. // {
  804. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  805. // {
  806. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  807. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  808. // }
  809. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  810. // {
  811. // entity.OrderState = 2;
  812. // entity.DesignUserId = 0;
  813. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  814. // }
  815. // else
  816. // {
  817. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  818. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  819. // }
  820. // }
  821. //}
  822. //}
  823. entity.Update();
  824. returnSuccessMsg("保存成功!");
  825. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  826. return;
  827. }
  828. returnErrorMsg("找不到记录");
  829. }
  830. }
  831. public void save_erp_customermemo()
  832. {
  833. if (UrlPostParmsCheck("ctid"))
  834. {
  835. string ctid = GetPostString("ctid");
  836. CeErpTradeCell entity = null;
  837. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  838. if (entity != null)
  839. {
  840. entity.CustomerMemo = GetPostString("CustomerMemo");
  841. entity.Update();
  842. ApiVo apiVo = new ApiVo();
  843. apiVo.orderNumber = entity.ctid;
  844. apiVo.actionName = "followRemarks";
  845. apiVo.orderRemarks = entity.CustomerMemo;
  846. designHelper.API_WorkCore(apiVo);//followRemarks
  847. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  848. returnSuccessMsg("保存成功!");
  849. return;
  850. }
  851. returnErrorMsg("找不到记录");
  852. }
  853. }
  854. public void upd_erp_addmemotag()
  855. {
  856. if (UrlPostParmsCheck("ctid"))
  857. {
  858. ;
  859. string eid = GetPostString("ctid");
  860. string sfTagstr = GetPostString("memotag");
  861. CeErpTradeCell entity = null;
  862. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  863. if (entity != null)
  864. {
  865. if (entity.OrderState == 0)
  866. {
  867. returnErrorMsg("请先领单");
  868. return;
  869. }
  870. //撤销顺丰
  871. if (sfTagstr == "撤销顺丰")
  872. {
  873. entity.IsSF = 0;
  874. string reMsg = "";
  875. string oldmemo = entity.seller_memo;
  876. if (entity.OrderState < 5)
  877. {
  878. oldmemo = oldmemo.Replace("顺丰到付", "");
  879. oldmemo = oldmemo.Replace("顺丰寄付", "");
  880. entity.seller_memo = oldmemo;
  881. }
  882. else
  883. {
  884. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  885. {
  886. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  887. }
  888. }
  889. entity.Update();
  890. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  891. api.orderNumber = entity.ctid;
  892. api.actionName = "followRemarks";
  893. api.orderRemarks = entity.seller_memo;
  894. api.isSf = entity.IsSF.ToString();
  895. designHelper.API_WorkCore(api);//followRemarks
  896. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  897. returnSuccessMsg("撤销成功!" + reMsg);
  898. return;
  899. }
  900. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  901. {
  902. //string oldmemo = entity.seller_memo;
  903. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  904. string sfStr = GetPostString("memotag");
  905. string smemo = entity.seller_memo;
  906. int kindex = smemo.IndexOf(")");
  907. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  908. if (lastoneStr != "-")
  909. {
  910. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  911. }
  912. string prememo = smemo.Substring(0, kindex + 2);
  913. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  914. int lastkindex = lastmemo.IndexOf("(");
  915. string newlastmemo = "";
  916. if (lastkindex == 0)
  917. {
  918. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  919. newlastmemo = "(" + sfStr + "." + useLastmemo;
  920. }
  921. else
  922. {
  923. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  924. }
  925. entity.seller_memo = prememo + newlastmemo;
  926. }
  927. string sfTagMSg = "";
  928. if (sfTagstr == "顺丰寄付")
  929. {
  930. entity.IsSF = 1;
  931. sfTagMSg = "顺丰寄付";
  932. }
  933. else if (sfTagstr == "顺丰到付")
  934. {
  935. entity.IsSF = 2;
  936. sfTagMSg = "顺丰到付";
  937. }
  938. entity.Update();
  939. ApiVo apiVo = new ApiVo();
  940. apiVo.orderNumber = entity.ctid;
  941. apiVo.actionName = "orderRemarks";
  942. apiVo.orderRemarks = entity.seller_memo;
  943. apiVo.isSf = entity.IsSF.ToString();
  944. designHelper.API_WorkCore(apiVo);//orderRemarks
  945. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  946. returnSuccessMsg("标记成功!");
  947. return;
  948. }
  949. returnErrorMsg("找不到记录");
  950. }
  951. }
  952. public void upd_erp_ordertag()
  953. {
  954. if (UrlPostParmsCheck("ctid"))
  955. {
  956. string eid = GetPostString("ctid");
  957. CeErpTradeCell entity = null;
  958. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  959. if (entity != null)
  960. {
  961. int tag = GetPostInt("wechattag");
  962. //if(tag==4 && entity.IsSample == 2)
  963. //{
  964. // returnErrorMsg("补差价单不能标记微信单");
  965. // return;
  966. //}
  967. entity.wechatTag = tag;
  968. entity.Update();
  969. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  970. if (tag == 1)
  971. {
  972. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  973. if (cash == null)
  974. {
  975. CeErpTrade main = CeErpTrade.Get(entity.tid);
  976. cash = new CeErpReturnCash();
  977. cash.tid = entity.tid;
  978. cash.seller_nick = main.seller_nick;
  979. cash.payment = trade.payment;
  980. cash.buyer_nick = main.buyer_nick;
  981. cash.cashstate = 0;
  982. cash.rtype = "微信返现";
  983. cash.returnprice = 0;
  984. cash.created = DateTime.Now;
  985. cash.con = "订单标记微信单";
  986. cash.img = "";
  987. cash.applyuserid = CurrentUser.UserID;
  988. cash.Create();
  989. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  990. }
  991. else
  992. {
  993. cash.cashstate = 0;
  994. cash.Update();
  995. }
  996. CeErpSukuraData.createInfo(entity.ctid, 9);
  997. }
  998. else if (tag == 2)
  999. {
  1000. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1001. if (cash == null)
  1002. {
  1003. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1004. cash = new CeErpReturnCash();
  1005. cash.tid = entity.tid;
  1006. cash.seller_nick = main.seller_nick;
  1007. cash.payment = trade.payment;
  1008. cash.buyer_nick = main.buyer_nick;
  1009. cash.cashstate = 0;
  1010. cash.rtype = "推购返现";
  1011. cash.returnprice = 5;
  1012. cash.created = DateTime.Now;
  1013. cash.con = "订单标记推购单";
  1014. cash.img = "";
  1015. cash.applyuserid = CurrentUser.UserID;
  1016. cash.Create();
  1017. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1018. }
  1019. else
  1020. {
  1021. cash.cashstate = 0;
  1022. cash.Update();
  1023. }
  1024. CeErpSukuraData.createInfo(entity.ctid, 9);
  1025. }
  1026. else if (tag == 3)
  1027. {
  1028. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1029. if (pers == null)
  1030. {
  1031. pers = new CeErpPersuade();
  1032. pers.ctid = entity.ctid;
  1033. pers.pstate = 0;
  1034. pers.created = DateTime.Now;
  1035. pers.applyuserid = CurrentUser.UserID;
  1036. pers.Create();
  1037. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1038. }
  1039. else
  1040. {
  1041. pers.pstate = 0;
  1042. pers.Update();
  1043. }
  1044. }
  1045. else if (tag == 4 || tag == 5)
  1046. {
  1047. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1048. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1049. if (pers == null)
  1050. {
  1051. pers = new CeErpStayGoods();
  1052. pers.t_id = entity.tid;
  1053. pers.status = "待审核";
  1054. pers.audit_type = 0;
  1055. if (tag == 4)
  1056. {
  1057. pers.stay_type = "微信推购";
  1058. }
  1059. else
  1060. {
  1061. pers.stay_type = "旺旺推购";
  1062. }
  1063. if (entity.IsXianHuo == 0)
  1064. {
  1065. pers.product_id = entity.ProductId;
  1066. }
  1067. pers.wangwang = main.buyer_nick;
  1068. pers.shop_name = main.seller_nick;
  1069. pers.creata_time = DateTime.Now;
  1070. pers.create_u_id = CurrentUser.UserID;
  1071. pers.create_u_name = CurrentUser.UserName;
  1072. pers.Create();
  1073. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1074. }
  1075. else
  1076. {
  1077. pers.audit_type = 0;
  1078. pers.Update();
  1079. }
  1080. CeErpSukuraData.createInfo(entity.ctid, 10);
  1081. }
  1082. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1083. returnSuccessMsg("标记成功!");
  1084. return;
  1085. }
  1086. returnErrorMsg("找不到记录");
  1087. }
  1088. }
  1089. public void upd_erp_ordertag_cancel()
  1090. {
  1091. if (UrlPostParmsCheck("ctid"))
  1092. {
  1093. string eid = GetPostString("ctid");
  1094. CeErpTradeCell entity = null;
  1095. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1096. if (entity != null)
  1097. {
  1098. entity.wechatTag = 0;
  1099. entity.Update();
  1100. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1101. if (pers != null)
  1102. {
  1103. pers.status = "取消推购";
  1104. pers.audit_type = 3;
  1105. pers.Update();
  1106. }
  1107. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1108. returnSuccessMsg("标记成功!");
  1109. return;
  1110. }
  1111. returnErrorMsg("找不到记录");
  1112. }
  1113. }
  1114. public void upd_erp_addweichattag()
  1115. {
  1116. if (UrlPostParmsCheck("ctid"))
  1117. {
  1118. ;
  1119. string eid = GetPostString("ctid");
  1120. CeErpTradeCell entity = null;
  1121. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1122. if (entity != null)
  1123. {
  1124. if (entity.IsAddWechat > 0)
  1125. {
  1126. returnErrorMsg("此单已经标记过了");
  1127. return;
  1128. }
  1129. 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);
  1130. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1131. if (dt.Rows.Count > 0)
  1132. {
  1133. entity.IsAddWechat = 2;
  1134. }
  1135. else
  1136. {
  1137. entity.IsAddWechat = 1;
  1138. }
  1139. entity.Update();
  1140. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1141. returnSuccessMsg("标记成功!");
  1142. return;
  1143. }
  1144. returnErrorMsg("找不到记录");
  1145. }
  1146. }
  1147. public void upd_erp_getmyorder()
  1148. {
  1149. if (UrlPostParmsCheck("ctid"))
  1150. {
  1151. ;
  1152. string eid = GetPostString("ctid");
  1153. CeErpTradeCell entity = null;
  1154. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1155. if (entity != null)
  1156. {
  1157. if (entity.ctid.IndexOf("C") != -1)
  1158. {
  1159. StringBuilder sql = new StringBuilder();
  1160. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1161. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1162. if (dt.Rows.Count > 0)
  1163. {
  1164. decimal total = 0;
  1165. foreach (DataRow dr in dt.Rows)
  1166. {
  1167. total += Convert.ToDecimal(dr["payment"]);
  1168. }
  1169. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1170. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1171. {
  1172. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1173. return;
  1174. }
  1175. }
  1176. }
  1177. entity.CustomerUserId = CurrentUser.UserID;
  1178. if (entity.OrderState < 2)
  1179. {
  1180. entity.OrderState = 2;
  1181. if (entity.ShopId != 0)
  1182. {
  1183. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1184. }
  1185. }
  1186. entity.Update();
  1187. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1188. returnSuccessMsg("领单成功!");
  1189. return;
  1190. }
  1191. returnErrorMsg("找不到记录");
  1192. }
  1193. }
  1194. public void getmyorder_from_init()
  1195. {
  1196. if (UrlPostParmsCheck("ctid"))
  1197. {
  1198. string eid = GetPostString("ctid");
  1199. CeErpTradeCell entity = null;
  1200. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1201. if (entity != null)
  1202. {
  1203. string sellerMemo = GetPostString("sellerMemo");
  1204. if (sellerMemo.Length > 0)
  1205. {
  1206. entity.seller_memo = sellerMemo;
  1207. }
  1208. string oterhMemo = GetPostString("otherMemo");
  1209. if (oterhMemo.Length > 0)
  1210. {
  1211. entity.OtherMemo = oterhMemo;
  1212. }
  1213. int urg = GetPostInt("urgency");
  1214. entity.IsUrgency = (urg == 1 ? true : false);
  1215. int wechat = GetPostInt("wechat");
  1216. int command = GetPostInt("command");
  1217. if (wechat == 1)
  1218. {
  1219. entity.wechatTag = 1;
  1220. }
  1221. if (command == 1)
  1222. {
  1223. entity.wechatTag = 2;
  1224. }
  1225. string pPro = GetPostString("pprofession");
  1226. if (pPro.Length > 0)
  1227. {
  1228. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1229. string spro = GetPostString("profession");
  1230. if (spro.Length > 0)
  1231. {
  1232. entity.ProfessionId = Convert.ToInt32(spro);
  1233. }
  1234. }
  1235. string proId = GetPostString("productId");
  1236. if (proId.Length > 0)
  1237. {
  1238. entity.ProductId = Convert.ToInt32(proId);
  1239. }
  1240. entity.Material = GetPostString("material");
  1241. entity.Craft = GetPostString("craft");
  1242. entity.CustomerUserId = CurrentUser.UserID;
  1243. if (entity.OrderState < 2)
  1244. {
  1245. entity.OrderState = 2;
  1246. if (entity.ShopId != 0)
  1247. {
  1248. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1249. }
  1250. }
  1251. entity.Update();
  1252. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1253. returnSuccessMsg("领单成功!");
  1254. return;
  1255. }
  1256. returnErrorMsg("找不到记录");
  1257. }
  1258. }
  1259. public void upd_erp_setrelationorder()
  1260. {
  1261. if (UrlPostParmsCheck("ctid"))
  1262. {
  1263. ;
  1264. string eid = GetPostString("ctid");
  1265. string ftid = GetPostString("ftid");
  1266. CeErpTradeCell entity = null;
  1267. CeErpTradeCell fentity = null;
  1268. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1269. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1270. if (fentity == null)
  1271. {
  1272. returnErrorMsg("找不到关联的主订单");
  1273. return;
  1274. }
  1275. if (entity != null)
  1276. {
  1277. if (entity.OrderState >= 5)
  1278. {
  1279. returnErrorMsg("本单已经设计完成无法关联");
  1280. return;
  1281. }
  1282. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1283. {
  1284. returnErrorMsg("线下单续审核后才能关联!");
  1285. return;
  1286. }
  1287. entity.ptid = ftid;
  1288. entity.OrderState = fentity.OrderState;
  1289. //entity.status = fentity.status;
  1290. entity.CustomerUserId = fentity.CustomerUserId;
  1291. entity.DesignUserId = fentity.DesignUserId;
  1292. entity.seller_memo = "补差价单:" + ftid;
  1293. entity.IsSample = 2;
  1294. entity.Update();
  1295. ApiVo apiVo = new ApiVo();
  1296. apiVo.orderNumber = ftid;
  1297. apiVo.payment = entity.payment;
  1298. apiVo.actionName = "repairDesign";
  1299. designHelper.API_WorkCore(apiVo);//repairDesign
  1300. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1301. returnSuccessMsg("关联成功!");
  1302. return;
  1303. }
  1304. else
  1305. returnErrorMsg("找不到记录");
  1306. }
  1307. }
  1308. public void download_erp_neworder()
  1309. {
  1310. string seller = GetPostString("seller_nick");
  1311. string tid = GetPostString("tid");
  1312. if (seller.Length <= 0 || tid.Length <= 0)
  1313. {
  1314. returnErrorMsg("数据错误");
  1315. }
  1316. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1317. //{
  1318. // returnErrorMsg("找不到店铺Sessionkey");
  1319. //}
  1320. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1321. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1322. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1323. if (res.IndexOf("refOid") == -1)
  1324. {
  1325. returnErrorMsg("下载订单数据失败");
  1326. return;
  1327. }
  1328. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1329. returnSuccessMsg("下载完成");
  1330. //tmcHelper.createNewOrder(res);
  1331. //CeErpTrade entr = null;
  1332. //entr = CeErpTrade.Get(tid);
  1333. //if (entr != null)
  1334. //{
  1335. // returnSuccess("下载成功");
  1336. // //下载成功之后,Cell表生成对应的订单;
  1337. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1338. //}
  1339. //else
  1340. //{
  1341. // returnErrorMsg("下载失败或者创建订单失败");
  1342. //}
  1343. }
  1344. public void set_erp_atersale()
  1345. {
  1346. if (UrlPostParmsCheck("ctid"))
  1347. {
  1348. string eid = GetPostString("ctid");
  1349. string reason = GetPostString("AfterSaleReason");
  1350. CeErpTradeCell entity = null;
  1351. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1352. if (entity != null)
  1353. {
  1354. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1355. {
  1356. returnErrorMsg("此订单已经在售后");
  1357. return;
  1358. }
  1359. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1360. //entity.AfterSaleReason = reason;
  1361. entity.AfterSaleTime = DateTime.Now;
  1362. entity.Update();
  1363. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1364. returnSuccessMsg("转售后成功!");
  1365. return;
  1366. }
  1367. returnErrorMsg("找不到记录");
  1368. }
  1369. }
  1370. public void set_erp_withdraw()
  1371. {
  1372. if (UrlPostParmsCheck("ctid"))
  1373. {
  1374. try
  1375. {
  1376. string eid = GetPostString("ctid");//商品id
  1377. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1378. CeWithdraw ceWithdrawSelect = null;
  1379. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1380. if (ceWithdrawSelect != null)
  1381. {
  1382. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1383. {
  1384. ceWithdrawSelect.status = -1;
  1385. ceWithdrawSelect.Update();
  1386. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1387. returnSuccessMsg("重新发起审核成功");
  1388. return;
  1389. }
  1390. else
  1391. {
  1392. returnSuccessMsg("请勿重复申请!");
  1393. return;
  1394. }
  1395. }
  1396. else
  1397. {
  1398. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1399. if (string.IsNullOrEmpty(CustomerUserId))
  1400. {
  1401. CustomerUserId = "-1";
  1402. }
  1403. int Userid = CurrentUser.UserID;//用户id
  1404. CeWithdraw ceWithdraw = new CeWithdraw();
  1405. ceWithdraw.tid = eid;
  1406. ceWithdraw.userid = Userid;
  1407. ceWithdraw.providerid = CustomerUserId;
  1408. ceWithdraw.status = 3;
  1409. ceWithdraw.creationtime = DateTime.Now;
  1410. ceWithdraw.Create();
  1411. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1412. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1413. return;
  1414. }
  1415. }
  1416. catch
  1417. {
  1418. returnErrorMsg("申请撤回订单失败");
  1419. return;
  1420. }
  1421. }
  1422. }
  1423. public void ins_erp_billinfo()
  1424. {
  1425. if (UrlPostParmsCheck("ctid"))
  1426. {
  1427. string eid = GetPostString("ctid");
  1428. CeErpTradeCell entity = null;
  1429. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1430. if (entity != null)
  1431. {
  1432. CeErpBill bill = CeErpBill.GetByTid(eid);
  1433. bool isHave = false;
  1434. if (bill != null)
  1435. {
  1436. isHave = true;
  1437. if (bill.state != 4)
  1438. {
  1439. returnErrorMsg("此单已经申请过发票了");
  1440. return;
  1441. }
  1442. }
  1443. if (entity.IsNeedBill == 0)
  1444. {
  1445. entity.IsNeedBill = 1;
  1446. }
  1447. entity.Update();
  1448. string errjson = "";
  1449. try
  1450. {
  1451. CeErpBill bill_entity = new CeErpBill();
  1452. bill_entity.tid = entity.tid;
  1453. bill_entity.title = GetPostString("title");
  1454. string taxstr = GetPostString("tax");
  1455. taxstr = taxstr.Replace(" ", "");
  1456. bill_entity.tax = taxstr;
  1457. bill_entity.bank = GetPostString("bank");
  1458. string bankacstr = GetPostString("bankac");
  1459. bankacstr = bankacstr.Replace(" ", "");
  1460. bill_entity.bankac = bankacstr;
  1461. bill_entity.address = GetPostString("address");
  1462. bill_entity.phone = GetPostString("phone");
  1463. bill_entity.price = GetPostString("price");
  1464. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1465. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1466. {
  1467. billCount += 1;
  1468. }
  1469. string prebill = "ltb";
  1470. for (int idx = 1; idx <= billCount; idx++)
  1471. {
  1472. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1473. string billoid = prebill + idx + dtstr;
  1474. bill_entity.billOrderId += billoid;
  1475. if (idx < billCount)
  1476. {
  1477. bill_entity.billOrderId += ",";
  1478. }
  1479. }
  1480. bill_entity.productId = GetPostInt("ProductName");
  1481. bill_entity.num = GetPostInt("num");
  1482. bill_entity.unit = GetPostString("unit");
  1483. bill_entity.type = GetPostString("type");
  1484. bill_entity.sendType = GetPostString("SendType");
  1485. bill_entity.email = GetPostString("email");
  1486. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1487. bill_entity.shopName = GetPostString("ShopName");
  1488. bill_entity.applymemo = GetPostString("applyMemo");
  1489. bill_entity.createTime = DateTime.Now;
  1490. bill_entity.state = 0;
  1491. bill_entity.userId = CurrentUser.UserID;
  1492. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1493. bill_entity.Create();
  1494. }
  1495. catch (Exception ex)
  1496. {
  1497. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1498. returnErrorMsg("创建发票出错!");
  1499. return;
  1500. }
  1501. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1502. returnSuccessMsg("发票申请成功!");
  1503. return;
  1504. }
  1505. returnErrorMsg("找不到记录");
  1506. }
  1507. }
  1508. public void ins_erp_neworder()
  1509. {
  1510. if (UrlPostParmsCheck("receiver_name"))
  1511. {
  1512. CeErpTrade entity = new CeErpTrade();
  1513. string plat_form = GetPostString("platform");
  1514. string preStr = "N_";
  1515. if (plat_form == "拼多多")
  1516. {
  1517. preStr = "P_";
  1518. }
  1519. else if (plat_form == "阿里巴巴")
  1520. {
  1521. preStr = "A_";
  1522. }
  1523. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1524. entity.seller_nick = GetPostString("seller_nick");
  1525. entity.buyer_nick = GetPostString("buyer_nick");
  1526. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1527. entity.total_fee = entity.payment;
  1528. entity.pay_time = DateTime.Now;
  1529. entity.status = "NOT_SHIPPED";
  1530. entity.receiver_name = GetPostString("receiver_name");
  1531. entity.receiver_mobile = GetPostString("receiver_mobile");
  1532. entity.receiver_state = GetPostString("receiver_state");
  1533. entity.receiver_city = GetPostString("receiver_city");
  1534. entity.receiver_district = GetPostString("receiver_district");
  1535. entity.receiver_address = GetPostString("receiver_address");
  1536. if (entity.receiver_state == "" || entity.receiver_city == "")
  1537. {
  1538. returnErrorMsg("收件地址不能为空");
  1539. return;
  1540. }
  1541. int shopId = 0;
  1542. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1543. if (nShop != null)
  1544. {
  1545. shopId = nShop.ID;
  1546. }
  1547. if (shopId != 34 && entity.payment == 0)
  1548. {
  1549. returnErrorMsg("公司自用的单金额才能为0");
  1550. return;
  1551. }
  1552. entity.Create();
  1553. CeErpTradeCell entitycell = new CeErpTradeCell();
  1554. entitycell.ctid = entity.tid;
  1555. entitycell.tid = entity.tid;
  1556. entitycell.ShopId = shopId;
  1557. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1558. entitycell.OrderState = 0;
  1559. entitycell.pay_time = entity.pay_time;
  1560. entitycell.IsOffLineOrder = 1;
  1561. entitycell.Create();
  1562. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1563. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1564. return;
  1565. }
  1566. }
  1567. public void ins_erp_neworder2()
  1568. {
  1569. if (UrlPostParmsCheck("receiver_name"))
  1570. {
  1571. //string plat_form = GetPostString("platform");
  1572. string preStr = "X_";
  1573. string memo = GetPostString("memo");
  1574. string productId = GetPostString("productId");
  1575. string primg = GetPostString("proofimg");
  1576. string sellerNick = GetPostString("seller_nick");
  1577. string addFrom = GetPostString("addfrom");
  1578. if (addFrom == "1")
  1579. {
  1580. preStr = "N_";
  1581. }
  1582. int shopId = 0;
  1583. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1584. if (nShop != null)
  1585. {
  1586. shopId = nShop.ID;
  1587. }
  1588. else
  1589. {
  1590. returnErrorMsg("找不到对应店铺");
  1591. return;
  1592. }
  1593. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1594. {
  1595. returnErrorMsg("必须上传付款凭证");
  1596. return;
  1597. }
  1598. CeErpTrade entity = new CeErpTrade();
  1599. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1600. entity.seller_nick = sellerNick;
  1601. entity.buyer_nick = GetPostString("buyer_nick");
  1602. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1603. entity.total_fee = entity.payment;
  1604. entity.pay_time = DateTime.Now;
  1605. entity.status = "NOT_SHIPPED";
  1606. entity.receiver_name = GetPostString("receiver_name");
  1607. entity.receiver_mobile = GetPostString("receiver_mobile");
  1608. entity.receiver_state = GetPostString("receiver_state");
  1609. entity.receiver_city = GetPostString("receiver_city");
  1610. entity.receiver_district = GetPostString("receiver_district");
  1611. entity.receiver_address = GetPostString("receiver_address");
  1612. entity.seller_memo = memo;
  1613. entity.orderFrom = 20;
  1614. entity.orderType = 15;
  1615. if (entity.receiver_state == "" || entity.receiver_city == "")
  1616. {
  1617. returnErrorMsg("收件地址不能为空");
  1618. return;
  1619. }
  1620. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1621. {
  1622. returnErrorMsg("公司自用的单金额才能为0");
  1623. return;
  1624. }
  1625. entity.Create();
  1626. string toWhere = GetPostString("towhere");
  1627. CeErpTradeCell entitycell = new CeErpTradeCell();
  1628. entitycell.ctid = entity.tid;
  1629. //唯一标识
  1630. entitycell.OrderSn = entity.tid;
  1631. //string orderSn = dataHelper.getSaleOrderSn();
  1632. //if (orderSn != "")
  1633. // {
  1634. // entitycell.OrderSn = orderSn;
  1635. // }
  1636. entitycell.tid = entity.tid;
  1637. //if (preStr == "X_")
  1638. //{
  1639. entitycell.IsOffLineOrder = 1;
  1640. //}
  1641. entitycell.CustomerUserId = CurrentUser.UserID;
  1642. entitycell.PayProofImg = primg;
  1643. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1644. entitycell.ProductId = Convert.ToInt32(productId);
  1645. entitycell.ShopId = shopId;
  1646. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1647. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1648. {
  1649. entitycell.IsXianHuo = 1;
  1650. }
  1651. entitycell.pay_time = entity.pay_time;
  1652. if (toWhere == "1")
  1653. {
  1654. entitycell.OrderState = 2;
  1655. }
  1656. else
  1657. {
  1658. entitycell.OrderState = 6;
  1659. entitycell.FinishPlaceTime = entitycell.pay_time;
  1660. }
  1661. if (shopId == 94)
  1662. {
  1663. entitycell.OrderState = 4;
  1664. entitycell.WaitDesignTime = entitycell.pay_time;
  1665. entitycell.StartDesignTime = entitycell.pay_time;
  1666. entitycell.DesignUserId = 218;
  1667. }
  1668. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1669. {
  1670. entitycell.OrderState = -1;//修改12-5
  1671. CeWithdraw ceWithdraw = new CeWithdraw();
  1672. ceWithdraw.tid = entity.tid;
  1673. ceWithdraw.providerid = "-1";
  1674. ceWithdraw.status = -1;
  1675. ceWithdraw.creationtime = DateTime.Now;
  1676. ceWithdraw.userid = 1337;
  1677. ceWithdraw.Create();
  1678. }
  1679. entitycell.Create();
  1680. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1681. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1682. {
  1683. addPlaceRegist(entitycell, CurrentUser.UserID);
  1684. }
  1685. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1686. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1687. return;
  1688. }
  1689. }
  1690. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1691. {
  1692. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1693. entity.PlactTime = tradecell.pay_time;
  1694. entity.AddUserId = userid;
  1695. entity.FileName = tradecell.seller_memo;
  1696. entity.Supplier = 24;
  1697. entity.CreateTime = DateTime.Now;
  1698. entity.Did = tradecell.ctid;
  1699. entity.tid = tradecell.tid;
  1700. entity.splitTag = tradecell.SplitTag;
  1701. entity.CurState = "未完成";
  1702. entity.Create();
  1703. }
  1704. public void get_erp_offlinelist()
  1705. {
  1706. DataStruct dStruct = GetPostStruct();
  1707. List<string> lw = new List<string>();
  1708. string tid = GetPostString("ctid");
  1709. string date1 = GetPostString("date1");
  1710. string date2 = GetPostString("date2");
  1711. if (tid.Length > 0 || date1.Length > 0)
  1712. {
  1713. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1714. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1715. if (dw.Length > 0) lw.Add(dw);
  1716. }
  1717. else
  1718. {
  1719. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1720. }
  1721. string shopname = GetPostString("shopname");
  1722. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1723. string buyernick = GetPostString("buyer_nick");
  1724. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1725. string customer = GetPostString("customer");
  1726. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1727. string design = GetPostString("design");
  1728. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1729. string orderState = GetPostString("orderState");
  1730. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1731. string address = GetPostString("address");
  1732. 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));
  1733. string sellermemo = GetPostString("seller_memo");
  1734. if (sellermemo.Length > 0)
  1735. {
  1736. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1737. }
  1738. string price1 = GetPostString("price1");
  1739. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1740. string price2 = GetPostString("price2");
  1741. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1742. //if (PKey != "admin")
  1743. //{
  1744. // string usershop = CurrentUser.User.pemShop;
  1745. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1746. //}
  1747. //if (ex_psize > 0)
  1748. //{
  1749. dStruct.Order = "pay_time desc";
  1750. //}
  1751. //else
  1752. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1753. lw.Add(string.Format("IsOffLineOrder=1"));
  1754. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1755. DataTable dt = null;
  1756. dt = WebCache.GetData("view_erptradecell", dStruct);
  1757. writeGridDataTableJson(dStruct.TotalCount, dt);
  1758. }
  1759. public void get_erp_returncashrecord()
  1760. {
  1761. DataStruct dStruct = GetPostStruct();
  1762. List<string> lw = new List<string>();
  1763. string tid = GetPostString("ctid");
  1764. if (tid.Length > 0)
  1765. {
  1766. lw.Add(string.Format("tid like '%{0}%'", tid));
  1767. dStruct.Order = "id desc";
  1768. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1769. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1770. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1771. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1772. return;
  1773. }
  1774. returnErrorMsg("id数据错误!");
  1775. }
  1776. public void ins_erp_returncashrecord()
  1777. {
  1778. if (UrlPostParmsCheck("tid"))
  1779. {
  1780. string tid = GetPostString("tid");
  1781. string retype = GetPostString("type");
  1782. StringBuilder sql = new StringBuilder();
  1783. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1784. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1785. if (dt.Rows.Count > 0)
  1786. {
  1787. returnErrorMsg("相同返现类型记录已存在");
  1788. return;
  1789. }
  1790. CeErpReturnCash entity = new CeErpReturnCash();
  1791. entity.tid = tid;
  1792. entity.seller_nick = GetPostString("seller_nick");
  1793. string pment = GetPostString("payment");
  1794. if (pment.Length > 0)
  1795. {
  1796. entity.payment = Convert.ToDouble(pment);
  1797. }
  1798. entity.buyer_nick = GetPostString("buyer_nick");
  1799. entity.cashstate = 0;
  1800. entity.rtype = retype;
  1801. string rPrice = GetPostString("returnprice");
  1802. if (rPrice.Length > 0)
  1803. {
  1804. entity.returnprice = Convert.ToDouble(rPrice);
  1805. }
  1806. entity.created = DateTime.Now;
  1807. entity.con = GetPostString("con");
  1808. entity.img = GetPostString("img");
  1809. entity.applyuserid = CurrentUser.UserID;
  1810. entity.Create();
  1811. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1812. returnSuccessMsg("操作成功!");
  1813. return;
  1814. }
  1815. }
  1816. public void set_erp_predelivery()
  1817. {
  1818. if (UrlPostParmsCheck("ctid"))
  1819. {
  1820. string eid = GetPostString("ctid");
  1821. CeErpTradeCell entity = null;
  1822. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1823. if (entity != null)
  1824. {
  1825. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1826. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1827. //{
  1828. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1829. // return;
  1830. //}
  1831. entity.IsPreDelivery = 1;
  1832. entity.Update();
  1833. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1834. returnSuccessMsg("预发货成功!");
  1835. return;
  1836. //string shop = GetPostString("seller_nick");
  1837. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1838. //string comName = GetPostString("comName");
  1839. //string comCode = GetPostString("comCode");
  1840. //string outSid = GetPostString("outSid");//运单号
  1841. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1842. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1843. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1844. //string apires = "";
  1845. //if (deliveryType == "虚拟发货")
  1846. //{
  1847. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1848. //}
  1849. //else
  1850. //{
  1851. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1852. //}
  1853. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1854. ////{
  1855. //if (apires.IndexOf("发货成功") != -1)
  1856. //{
  1857. // if (deliveryType != "虚拟发货")
  1858. // {
  1859. // //还要插入快递信息到 快递信息表
  1860. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1861. // exinfo.tid = eid;
  1862. // exinfo.out_sid = outSid;
  1863. // exinfo.company_code = comCode;
  1864. // exinfo.company_name = comName;
  1865. // exinfo.delivery_memo = deliveryMemo;
  1866. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1867. // exinfo.deliveryType = deliveryType;
  1868. // exinfo.Create();
  1869. // }
  1870. // returnSuccessMsg("发货成功!");
  1871. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1872. //}
  1873. //else
  1874. //{
  1875. // returnErrorMsg("淘宝发货失败!!");
  1876. //}
  1877. //return;
  1878. }
  1879. returnErrorMsg("找不到订单记录");
  1880. }
  1881. }
  1882. public void get_erp_unusuallist()
  1883. {
  1884. DataStruct dStruct = GetPostStruct();
  1885. List<string> lw = new List<string>();
  1886. string tid = GetPostString("ctid");
  1887. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1888. string shopname = GetPostString("shopname");
  1889. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1890. string buyernick = GetPostString("buyer_nick");
  1891. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1892. string ResponsibleMan = GetPostString("responsible");
  1893. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1894. string date1 = GetPostString("date1");
  1895. string date2 = GetPostString("date2");
  1896. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1897. if (dw.Length > 0) lw.Add(dw);
  1898. string price1 = GetPostString("price1");
  1899. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1900. string price2 = GetPostString("price2");
  1901. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1902. string orderState = GetPostString("orderState");
  1903. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1904. string sellermemo = GetPostString("seller_memo");
  1905. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1906. lw.Add(string.Format("UnusualTag > 0"));
  1907. lw.Add(string.Format("IsRefund<={0}", 1));
  1908. dStruct.Order = "pay_time desc";
  1909. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1910. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1911. writeGridDataTableJson(dStruct.TotalCount, dt);
  1912. }
  1913. public void set_erp_unusualtonomal()
  1914. {
  1915. if (UrlPostParmsCheck("ctid"))
  1916. {
  1917. string eid = GetPostString("ctid");
  1918. CeErpTradeCell entity = null;
  1919. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1920. if (entity != null)
  1921. {
  1922. entity.UnusualTag = -1;
  1923. entity.Update();
  1924. returnSuccessMsg("忽略成功!");
  1925. return;
  1926. }
  1927. returnErrorMsg("找不到记录");
  1928. }
  1929. }
  1930. public void ins_erp_unusualreason()
  1931. {
  1932. if (UrlPostParmsCheck("ctid"))
  1933. {
  1934. string eid = GetPostString("ctid");
  1935. CeErpTradeCell entity = null;
  1936. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1937. if (entity != null)
  1938. {
  1939. entity.MemoOpt = 4;
  1940. entity.UnusualCon = GetPostString("con");
  1941. entity.Update();
  1942. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1943. if (trade != null)
  1944. {
  1945. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1946. }
  1947. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1948. returnSuccessMsg("操作成功!");
  1949. return;
  1950. }
  1951. returnErrorMsg("找不到记录");
  1952. }
  1953. }
  1954. public void upd_erp_sampleorder()
  1955. {
  1956. if (UrlPostParmsCheck("ctid"))
  1957. {
  1958. string eid = GetPostString("ctid");
  1959. string[] eArr = eid.Split(',');
  1960. if (eArr.Length > 1)
  1961. {
  1962. List<string> eLst = new List<string>();
  1963. for (int i = 0; i < eArr.Length; i++)
  1964. {
  1965. eLst.Add("'" + eArr[i] + "'");
  1966. }
  1967. eid = string.Join(",", eLst.ToArray());
  1968. }
  1969. else
  1970. {
  1971. eid = "'" + eid + "'";
  1972. }
  1973. StringBuilder sql = new StringBuilder();
  1974. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1975. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1976. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1977. if (dt.Rows.Count > 0)
  1978. {
  1979. string errmsg = "";
  1980. foreach (DataRow dr in dt.Rows)
  1981. {
  1982. StringBuilder sqlsb = new StringBuilder();
  1983. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  1984. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  1985. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  1986. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  1987. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  1988. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  1989. {
  1990. continue;
  1991. }
  1992. else
  1993. {
  1994. string emsg = commonHelper.KeepChinese(apires);
  1995. errmsg += emsg;
  1996. }
  1997. }
  1998. if (errmsg.Length > 0)
  1999. {
  2000. returnErrorMsg(errmsg);
  2001. return;
  2002. }
  2003. returnSuccessMsg("操作成功");
  2004. return;
  2005. }
  2006. returnErrorMsg("找不到记录");
  2007. }
  2008. }
  2009. public void upd_erp_transcustomer()
  2010. {
  2011. if (UrlPostParmsCheck("ctid"))
  2012. {
  2013. string eid = GetPostString("ctid");
  2014. int userid = GetPostInt("CustomerUserId");
  2015. CeErpTradeCell entity = null;
  2016. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2017. if (entity != null)
  2018. {
  2019. //string[] mlist = entity.seller_memo.Split('-');
  2020. //string sql = "select * from view_erpuser where id=" + userid;
  2021. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2022. //if (dt != null && dt.Rows.Count > 0)
  2023. //{
  2024. // string nmemo = "";
  2025. // for(int i = 0; i < mlist.Length - 1; i++)
  2026. // {
  2027. // nmemo += mlist[i];
  2028. // nmemo += "-";
  2029. // }
  2030. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2031. // entity.seller_memo = nmemo;
  2032. //}
  2033. entity.CustomerUserId = userid;
  2034. entity.Update();
  2035. returnSuccessMsg("操作成功!");
  2036. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2037. return;
  2038. }
  2039. returnErrorMsg("找不到记录");
  2040. }
  2041. }
  2042. public void upd_erp_transdesigner()
  2043. {
  2044. if (UrlPostParmsCheck("ctid"))
  2045. {
  2046. string eids = GetPostString("ctid");
  2047. string[] ctidList = eids.Split(',');
  2048. int userid = GetPostInt("DesignUserId");
  2049. foreach (string ctid in ctidList)
  2050. {
  2051. CeErpTradeCell entity = null;
  2052. CeErpDesignerBill entitys = null;
  2053. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2054. entitys = CeErpDesignerBill.GetByTid(ctid);
  2055. if (entity != null)
  2056. {
  2057. if (entity.OrderState > 4)
  2058. {
  2059. continue;
  2060. }
  2061. //存在退款不能流转
  2062. if (entity.IsRefund > 0)
  2063. {
  2064. continue;
  2065. }
  2066. entity.DesignUserId = userid;
  2067. entity.WaitDesignTime = DateTime.Now;
  2068. entity.Update();
  2069. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2070. }
  2071. }
  2072. returnSuccessMsg("操作成功!");
  2073. }
  2074. }
  2075. public void upd_erp_distributedesigner()
  2076. {
  2077. if (UrlPostParmsCheck("ctid"))
  2078. {
  2079. string eid = GetPostString("ctid");
  2080. int userid = GetPostInt("DesignUserId");
  2081. string[] idlist = eid.Split(',');
  2082. if (idlist.Length <= 0)
  2083. {
  2084. returnErrorMsg("订单不能为空");
  2085. return;
  2086. }
  2087. foreach (string ctid in idlist)
  2088. {
  2089. CeErpTradeCell entity = null;
  2090. CeErpDesignerBill entitys = null;
  2091. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2092. else continue;
  2093. if (entity != null)
  2094. {
  2095. if (userid == 2125 || userid == 3542)
  2096. { }
  2097. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2098. {
  2099. returnErrorMsg("金额错误的订单无法指派");
  2100. return;
  2101. }
  2102. if (entity.OrderState >= 5)
  2103. {
  2104. returnErrorMsg("已经设计完成无法指派");
  2105. return;
  2106. }
  2107. if (entity.OrderState == -1)
  2108. {
  2109. returnErrorMsg("审核中的订单无法指派");
  2110. return;
  2111. }
  2112. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2113. {
  2114. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2115. return;
  2116. }
  2117. if (entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize")
  2118. {
  2119. returnErrorMsg("指派设计共创无法再次指派!");
  2120. return;
  2121. }
  2122. entity.OrderState = 3;
  2123. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2124. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2125. {
  2126. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2127. entity.SupplierId = suid;
  2128. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2129. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2130. }
  2131. if (userid == 2125 && entity.seller_memo != "")
  2132. {
  2133. apiDesign.API_GetPrintData_CreateOrder(entity);
  2134. }
  2135. if (userid == 3542 && entity.seller_memo != "")
  2136. {
  2137. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2138. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2139. if (response.msg != "设计共创:成功")
  2140. {
  2141. returnErrorMsg(response.msg);
  2142. return;
  2143. }
  2144. entity.DispatchSort = 2;
  2145. entity.OrderState = 3;
  2146. }
  2147. entity.DesignUserId = userid;
  2148. entity.WaitDesignTime = DateTime.Now;
  2149. entity.Update();
  2150. string name = commonHelper.getUserNameById(userid);
  2151. commonHelper.UpdateRelationOrder(entity.ctid);
  2152. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2153. }
  2154. }
  2155. returnSuccessMsg("操作成功!");
  2156. return;
  2157. }
  2158. }
  2159. public void get_erp_myorderlist()
  2160. {
  2161. DataStruct dStruct = GetPostStruct();
  2162. List<string> lw = new List<string>();
  2163. string tid = GetPostString("ctid");
  2164. if (tid.Length > 0)
  2165. {
  2166. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2167. }
  2168. else
  2169. {
  2170. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2171. }
  2172. //12-1 修改
  2173. string urgent = GetPostString("urgent");
  2174. string back = GetPostString("back");
  2175. string offlineSearch = GetPostString("offlineSearch");
  2176. if (!string.IsNullOrWhiteSpace(urgent))
  2177. {
  2178. if (urgent.Equals("true"))
  2179. {
  2180. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2181. }
  2182. }
  2183. if (!string.IsNullOrWhiteSpace(back))
  2184. {
  2185. if (back.Equals("true"))
  2186. {
  2187. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2188. }
  2189. }
  2190. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2191. {
  2192. if (offlineSearch.Equals("true"))
  2193. {
  2194. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2195. }
  2196. }
  2197. //end
  2198. string shopname = GetPostString("shopname");
  2199. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2200. string buyernick = GetPostString("buyer_nick");
  2201. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2202. string design = GetPostString("design");
  2203. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2204. string orderState = GetPostString("orderState");
  2205. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2206. string sellermemo = GetPostString("seller_memo");
  2207. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2208. string date1 = GetPostString("date1");
  2209. string date2 = GetPostString("date2");
  2210. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2211. if (dw.Length > 0) lw.Add(dw);
  2212. string price1 = GetPostString("price1");
  2213. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2214. string price2 = GetPostString("price2");
  2215. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2216. string urgency = GetPostString("urgency");
  2217. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2218. string after = GetPostString("after");
  2219. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2220. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2221. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2222. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2223. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2224. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2225. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2226. if (dt != null && dt.Rows.Count > 0)
  2227. {
  2228. foreach (DataRow dr in dt.Rows)
  2229. {
  2230. try
  2231. {
  2232. // 对象操作
  2233. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2234. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2235. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2236. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2237. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2238. if (dStruct.PageSize != 100000)
  2239. {
  2240. if (dr["DispatchSort"].ToString() == "2")
  2241. {
  2242. dr["gongchuang"] = 200;
  2243. }
  2244. else
  2245. {
  2246. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2247. dr["gongchuang"] = response.code;
  2248. }
  2249. }
  2250. }
  2251. catch (NullReferenceException ex)
  2252. {
  2253. }
  2254. }
  2255. }
  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. int toType = GetPostInt("totype");
  3483. string fromType = "3";
  3484. if (entity.OrderState < 5)
  3485. {
  3486. fromType = "3";
  3487. }
  3488. else
  3489. {
  3490. fromType = "4";
  3491. }
  3492. if (entity.IsXianHuo == 0)
  3493. {
  3494. if (returnTag == 2)
  3495. {
  3496. if (toType == 1)
  3497. {
  3498. entity.OrderState = 0;
  3499. entity.ReturnUserType = 1;
  3500. string clearman = GetPostString("clearman");
  3501. if (!string.IsNullOrEmpty(clearman))
  3502. {
  3503. entity.DesignUserId = 0;
  3504. }
  3505. }
  3506. else
  3507. {
  3508. entity.OrderState = 3;
  3509. entity.ReturnUserType = 2;
  3510. }
  3511. entity.IsReadTag = 1;
  3512. }
  3513. else if (returnTag == 1)
  3514. {
  3515. entity.OrderState = 5;
  3516. }
  3517. entity.IsVerifyToSupplier = false;
  3518. }
  3519. if (entity.IsXianHuo == 1)
  3520. {
  3521. entity.OrderState = 5;
  3522. }
  3523. entity.UnusualTag = 0;
  3524. entity.UnusualTime = null;
  3525. entity.UnusualCon = "";
  3526. entity.IsReturn = returnTag;
  3527. entity.ReturnTime = DateTime.Now;
  3528. entity.ReturnReason = GetPostString("returnreason");
  3529. entity.Update();
  3530. if (entity.OrderState == 3)
  3531. {
  3532. ApiVo apiVo = new ApiVo();
  3533. apiVo.orderNumber = entity.ctid;
  3534. apiVo.actionName = "rebutDesign";
  3535. apiVo.orderRemarks = entity.ReturnReason;
  3536. designHelper.API_WorkCore(apiVo);//rebutDesign
  3537. }
  3538. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3539. if (ceErpTradeCellExtend.orderFrom == 30)
  3540. {
  3541. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3542. }
  3543. CeErpSukuraData.createInfo(entity.ctid, 5);
  3544. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3545. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3546. if (isPlace)
  3547. {
  3548. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3549. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3550. if (dth != null && dth.Rows.Count > 0)
  3551. {
  3552. dataSendOrderBean dataSendOrderBean = null;
  3553. foreach (DataRow item in dth.Rows)
  3554. {
  3555. try
  3556. {
  3557. dataSendOrderBean = new dataSendOrderBean();
  3558. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3559. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3560. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3561. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3562. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3563. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3564. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3565. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3566. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3567. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3568. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3569. dataSendOrderBean.Radio1723534706288 = "打回";
  3570. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3571. if (result != null)
  3572. {
  3573. if ("0".Equals(result.errcode))
  3574. {
  3575. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3576. }
  3577. else
  3578. {
  3579. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3580. }
  3581. }
  3582. }
  3583. catch (Exception ex)
  3584. {
  3585. }
  3586. }
  3587. }
  3588. }
  3589. if (isNeedUpdateCell2)
  3590. {
  3591. if (entity.MakeSupplier.IndexOf(",") != -1)
  3592. {
  3593. StringBuilder sql2 = new StringBuilder();
  3594. 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);
  3595. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3596. }
  3597. else
  3598. {
  3599. StringBuilder sql2 = new StringBuilder();
  3600. 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);
  3601. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3602. }
  3603. }
  3604. returnSuccessMsg("操作成功!");
  3605. return;
  3606. }
  3607. returnErrorMsg("找不到订单记录");
  3608. }
  3609. }
  3610. public void cyt_erp_returnreason()
  3611. {
  3612. if (UrlPostParmsCheck("ctid"))
  3613. {
  3614. string eid = GetPostString("ctid");
  3615. CeErpTradeCell entity = null;
  3616. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3617. string userpost = CurrentUser.UserPost.Post.Code;
  3618. if (entity != null)
  3619. {
  3620. if (entity.OrderState > 6)
  3621. {
  3622. returnErrorMsg("已发货无法打回!");
  3623. return;
  3624. }
  3625. JObject jsonObject = new JObject
  3626. {
  3627. { "Userid", "77886" },
  3628. { "Pwd", "lt666888" },
  3629. { "LTOrderId",eid }
  3630. };
  3631. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3632. JObject jsonObjects = JObject.Parse(response);
  3633. string msg = (string)jsonObjects["msg"];
  3634. if (msg != "取消成功")
  3635. {
  3636. returnErrorMsg(msg);
  3637. return;
  3638. }
  3639. bool isNeedUpdateCell2 = false;
  3640. if (entity.OrderState >= 6)
  3641. {
  3642. isNeedUpdateCell2 = true;
  3643. }
  3644. int returnTag = 2;
  3645. if (userpost == "Supplier")
  3646. {
  3647. returnTag = 1;
  3648. }
  3649. if (entity.IsXianHuo == 0)
  3650. {
  3651. if (returnTag == 2)
  3652. {
  3653. int toType = GetPostInt("totype");
  3654. if (toType == 1)
  3655. {
  3656. entity.OrderState = 0;
  3657. entity.ReturnUserType = 1;
  3658. }
  3659. else
  3660. {
  3661. entity.OrderState = 4;
  3662. entity.ReturnUserType = 2;
  3663. }
  3664. entity.IsReadTag = 1;
  3665. }
  3666. else if (returnTag == 1)
  3667. {
  3668. entity.OrderState = 5;
  3669. }
  3670. entity.IsVerifyToSupplier = false;
  3671. }
  3672. entity.UnusualTag = 0;
  3673. entity.UnusualTime = null;
  3674. entity.UnusualCon = "";
  3675. entity.IsReturn = returnTag;
  3676. entity.ReturnTime = DateTime.Now;
  3677. entity.ReturnReason = GetPostString("returnreason");
  3678. entity.Update();
  3679. if (entity.OrderState == 4)
  3680. {
  3681. ApiVo apiVo = new ApiVo();
  3682. apiVo.orderNumber = entity.ctid;
  3683. apiVo.actionName = "rebutDesign";
  3684. apiVo.orderRemarks = entity.ReturnReason;
  3685. designHelper.API_WorkCore(apiVo);//rebutDesign
  3686. }
  3687. CeErpSukuraData.createInfo(entity.ctid, 5);
  3688. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3689. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3690. if (isNeedUpdateCell2)
  3691. {
  3692. if (entity.MakeSupplier.IndexOf(",") != -1)
  3693. {
  3694. StringBuilder sql2 = new StringBuilder();
  3695. 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);
  3696. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3697. }
  3698. else
  3699. {
  3700. StringBuilder sql2 = new StringBuilder();
  3701. 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);
  3702. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3703. }
  3704. }
  3705. returnSuccessMsg("操作成功!");
  3706. return;
  3707. }
  3708. returnErrorMsg("找不到订单记录");
  3709. }
  3710. }
  3711. public void upd_erp_xianhuoreturntag()
  3712. {
  3713. if (UrlPostParmsCheck("ctid"))
  3714. {
  3715. string eids = GetPostString("ctid");
  3716. string[] ctids = eids.Split(',');
  3717. foreach (string ctid in ctids)
  3718. {
  3719. CeErpTradeCell entity = null;
  3720. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3721. if (entity != null)
  3722. {
  3723. entity.IsReturn = 0;
  3724. entity.Update();
  3725. CeErpSukuraData.createInfo(entity.ctid, 5);
  3726. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3727. }
  3728. }
  3729. returnSuccessMsg("操作成功!");
  3730. return;
  3731. }
  3732. }
  3733. public void get_erp_waitdeliverylist()
  3734. {
  3735. DataStruct dStruct = GetPostStruct();
  3736. List<string> lw = new List<string>();
  3737. string tid = GetPostString("ctid");
  3738. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3739. string shopname = GetPostString("shopname");
  3740. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3741. string buyernick = GetPostString("buyer_nick");
  3742. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3743. //if (tid.Length == 0 && buyernick.Length == 0)
  3744. //{
  3745. // lw.Add(string.Format("IsRefund<={0}", 1));
  3746. //}
  3747. string customer = GetPostString("customer");
  3748. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3749. string design = GetPostString("design");
  3750. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3751. string orderState = GetPostString("orderState");
  3752. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3753. string address = GetPostString("address");
  3754. 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));
  3755. string sellermemo = GetPostString("seller_memo");
  3756. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3757. string supplier = GetPostString("supplier");
  3758. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3759. string OrderArea = GetPostString("order_area");
  3760. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3761. string placedate1 = GetPostString("placedate1");
  3762. string placedate2 = GetPostString("placedate2");
  3763. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3764. if (fdw.Length > 0) lw.Add(fdw);
  3765. string price1 = GetPostString("price1");
  3766. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3767. string price2 = GetPostString("price2");
  3768. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3769. string unusualCon = GetPostString("unusualcon");
  3770. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3771. string otherMemo = GetPostString("otherMemo");
  3772. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3773. string posTag = CurrentUser.UserPost.Post.Code;
  3774. if (posTag == "Supplier")
  3775. {
  3776. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3777. }
  3778. lw.Add(string.Format("OrderState = 6 "));
  3779. lw.Add(string.Format("type != 'PDD' "));
  3780. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3781. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3782. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3783. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3784. writeGridDataTableJson(dStruct.TotalCount, dt);
  3785. }
  3786. public void get_erp_pddderiving()
  3787. {
  3788. DataStruct dStruct = GetPostStruct();
  3789. List<string> lw = new List<string>();
  3790. string tid = GetPostString("ctid");
  3791. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3792. string shopname = GetPostString("shopname");
  3793. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3794. string buyernick = GetPostString("buyer_nick");
  3795. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3796. //if (tid.Length == 0 && buyernick.Length == 0)
  3797. //{
  3798. // lw.Add(string.Format("IsRefund<={0}", 1));
  3799. //}
  3800. string customer = GetPostString("customer");
  3801. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3802. string design = GetPostString("design");
  3803. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3804. string orderState = GetPostString("orderState");
  3805. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3806. string address = GetPostString("address");
  3807. 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));
  3808. string sellermemo = GetPostString("seller_memo");
  3809. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3810. string supplier = GetPostString("supplier");
  3811. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3812. string OrderArea = GetPostString("order_area");
  3813. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3814. string placedate1 = GetPostString("placedate1");
  3815. string placedate2 = GetPostString("placedate2");
  3816. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3817. if (fdw.Length > 0) lw.Add(fdw);
  3818. string price1 = GetPostString("price1");
  3819. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3820. string price2 = GetPostString("price2");
  3821. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3822. string unusualCon = GetPostString("unusualcon");
  3823. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3824. string posTag = CurrentUser.UserPost.Post.Code;
  3825. if (posTag == "Supplier")
  3826. {
  3827. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3828. }
  3829. lw.Add(string.Format("OrderState = 6 "));
  3830. lw.Add(string.Format("type = 'PDD' "));
  3831. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3832. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3833. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3834. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3835. writeGridDataTableJson(dStruct.TotalCount, dt);
  3836. }
  3837. public void get_erp_jdderiving()
  3838. {
  3839. DataStruct dStruct = GetPostStruct();
  3840. List<string> lw = new List<string>();
  3841. string tid = GetPostString("ctid");
  3842. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3843. string shopname = GetPostString("shopname");
  3844. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3845. string buyernick = GetPostString("buyer_nick");
  3846. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3847. //if (tid.Length == 0 && buyernick.Length == 0)
  3848. //{
  3849. // lw.Add(string.Format("IsRefund<={0}", 1));
  3850. //}
  3851. string customer = GetPostString("customer");
  3852. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3853. string design = GetPostString("design");
  3854. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3855. string orderState = GetPostString("orderState");
  3856. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3857. string address = GetPostString("address");
  3858. 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));
  3859. string sellermemo = GetPostString("seller_memo");
  3860. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3861. string supplier = GetPostString("supplier");
  3862. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3863. string OrderArea = GetPostString("order_area");
  3864. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3865. string placedate1 = GetPostString("placedate1");
  3866. string placedate2 = GetPostString("placedate2");
  3867. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3868. if (fdw.Length > 0) lw.Add(fdw);
  3869. string price1 = GetPostString("price1");
  3870. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3871. string price2 = GetPostString("price2");
  3872. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3873. string unusualCon = GetPostString("unusualcon");
  3874. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3875. string posTag = CurrentUser.UserPost.Post.Code;
  3876. if (posTag == "Supplier")
  3877. {
  3878. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3879. }
  3880. lw.Add(string.Format("OrderState = 6 "));
  3881. lw.Add(string.Format("type = 'JD' "));
  3882. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3883. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3884. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3885. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3886. writeGridDataTableJson(dStruct.TotalCount, dt);
  3887. }
  3888. public void get_erp_demoorderlist()
  3889. {
  3890. DataStruct dStruct = GetPostStruct();
  3891. List<string> lw = new List<string>();
  3892. string tid = GetPostString("ctid");
  3893. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3894. string shopname = GetPostString("shopname");
  3895. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3896. string buyernick = GetPostString("buyer_nick");
  3897. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3898. string customer = GetPostString("customer");
  3899. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3900. string design = GetPostString("design");
  3901. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3902. string orderState = GetPostString("orderState");
  3903. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3904. string address = GetPostString("address");
  3905. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3906. string sellermemo = GetPostString("seller_memo");
  3907. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3908. string supplier = GetPostString("supplier");
  3909. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3910. string OrderArea = GetPostString("order_area");
  3911. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3912. string date1 = GetPostString("date1");
  3913. string date2 = GetPostString("date2");
  3914. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3915. if (dw.Length > 0) lw.Add(dw);
  3916. string price1 = GetPostString("price1");
  3917. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3918. string price2 = GetPostString("price2");
  3919. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3920. string posTag = CurrentUser.UserPost.Post.Code;
  3921. if (posTag == "Supplier")
  3922. {
  3923. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3924. }
  3925. //lw.Add(string.Format("OrderState = 6 "));
  3926. lw.Add(string.Format("IsSample={0}", 3));
  3927. lw.Add(string.Format("IsRefund<={0}", 1));
  3928. dStruct.Order = "pay_time desc";
  3929. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3930. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3931. writeGridDataTableJson(dStruct.TotalCount, dt);
  3932. }
  3933. public void save_erp_checkmemo()
  3934. {
  3935. if (UrlPostParmsCheck("ctid"))
  3936. {
  3937. string ctid = GetPostString("ctid");
  3938. CeErpTradeCell entity = null;
  3939. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3940. if (entity != null)
  3941. {
  3942. entity.CheckMemo = GetPostString("CheckMemo");
  3943. entity.Update();
  3944. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  3945. if (trade != null)
  3946. {
  3947. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  3948. }
  3949. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  3950. returnSuccessMsg("保存成功!");
  3951. return;
  3952. }
  3953. returnErrorMsg("找不到记录");
  3954. }
  3955. }
  3956. public void get_erp_returnlist()
  3957. {
  3958. DataStruct dStruct = GetPostStruct();
  3959. List<string> lw = new List<string>();
  3960. string tid = GetPostString("ctid");
  3961. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3962. string shopname = GetPostString("shopname");
  3963. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3964. string buyernick = GetPostString("buyer_nick");
  3965. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3966. string customer = GetPostString("customer");
  3967. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3968. string design = GetPostString("design");
  3969. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3970. string orderState = GetPostString("orderState");
  3971. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3972. string address = GetPostString("address");
  3973. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3974. string sellermemo = GetPostString("seller_memo");
  3975. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3976. string supplier = GetPostString("supplier");
  3977. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3978. string date1 = GetPostString("date1");
  3979. string date2 = GetPostString("date2");
  3980. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3981. if (dw.Length > 0) lw.Add(dw);
  3982. string bdate1 = GetPostString("backdate1");
  3983. string bdate2 = GetPostString("backdate2");
  3984. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3985. if (dw_back.Length > 0) lw.Add(dw_back);
  3986. string price1 = GetPostString("price1");
  3987. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3988. string price2 = GetPostString("price2");
  3989. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3990. lw.Add(string.Format("IsReturn>0"));
  3991. lw.Add(string.Format("IsXianHuo=0"));
  3992. lw.Add(string.Format("IsReturn!=3"));
  3993. string backtype = GetPostString("backtype");
  3994. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  3995. dStruct.Order = "FinishDesignTime desc";
  3996. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3997. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3998. writeGridDataTableJson(dStruct.TotalCount, dt);
  3999. }
  4000. public void get_erp_today_sumreturn()
  4001. {
  4002. DataStruct dStruct = GetPostStruct();
  4003. List<string> lw = new List<string>();
  4004. string bdate1 = GetPostString("returnTimeS");
  4005. string bdate2 = GetPostString("returnTimeE");
  4006. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4007. if (dw_back.Length > 0) lw.Add(dw_back);
  4008. lw.Add(string.Format("IsReturn=0"));
  4009. lw.Add(string.Format("IsXianHuo=0"));
  4010. string mainWhere = string.Join(" and ", lw.ToArray());
  4011. string sql = "";
  4012. if (dw_back.Length > 0)
  4013. {
  4014. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4015. }
  4016. else
  4017. {
  4018. 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 + "'";
  4019. }
  4020. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4021. decimal total = 0, today_finish = 0;
  4022. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4023. {
  4024. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4025. }
  4026. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4027. {
  4028. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4029. }
  4030. var res = new
  4031. {
  4032. data = total,
  4033. data1 = today_finish,
  4034. };
  4035. string ro_jsond = JsonConvert.SerializeObject(res);
  4036. returnSuccess(ro_jsond);
  4037. return;
  4038. }
  4039. public void get_erp_allreturnlist()
  4040. {
  4041. DataStruct dStruct = GetPostStruct();
  4042. List<string> lw = new List<string>();
  4043. string tid = GetPostString("ctid");
  4044. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4045. string shopname = GetPostString("shopname");
  4046. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4047. string buyernick = GetPostString("buyer_nick");
  4048. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4049. string customer = GetPostString("customer");
  4050. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4051. string design = GetPostString("design");
  4052. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4053. string orderState = GetPostString("orderState");
  4054. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4055. string address = GetPostString("address");
  4056. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4057. string sellermemo = GetPostString("seller_memo");
  4058. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4059. string supplier = GetPostString("supplier");
  4060. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4061. string date1 = GetPostString("date1");
  4062. string date2 = GetPostString("date2");
  4063. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4064. if (dw.Length > 0) lw.Add(dw);
  4065. string bdate1 = GetPostString("backdate1");
  4066. string bdate2 = GetPostString("backdate2");
  4067. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4068. if (dw_back.Length > 0) lw.Add(dw_back);
  4069. string price1 = GetPostString("price1");
  4070. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4071. string price2 = GetPostString("price2");
  4072. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4073. string backreason = GetPostString("backreason");
  4074. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4075. lw.Add(string.Format("IsXianHuo=0"));
  4076. lw.Add(string.Format("ReturnTime != ''"));
  4077. string backtype = GetPostString("backtype");
  4078. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4079. dStruct.Order = "FinishDesignTime desc";
  4080. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4081. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4082. writeGridDataTableJson(dStruct.TotalCount, dt);
  4083. }
  4084. public void get_erp_aftersalereturnlist()
  4085. {
  4086. DataStruct dStruct = GetPostStruct();
  4087. List<string> lw = new List<string>();
  4088. string tid = GetPostString("ctid");
  4089. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4090. string shopname = GetPostString("shopname");
  4091. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4092. string buyernick = GetPostString("buyer_nick");
  4093. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4094. string customer = GetPostString("customer");
  4095. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4096. string design = GetPostString("design");
  4097. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4098. string orderState = GetPostString("orderState");
  4099. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4100. string address = GetPostString("address");
  4101. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4102. string sellermemo = GetPostString("seller_memo");
  4103. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4104. string supplier = GetPostString("supplier");
  4105. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4106. string date1 = GetPostString("date1");
  4107. string date2 = GetPostString("date2");
  4108. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4109. if (dw.Length > 0) lw.Add(dw);
  4110. string bdate1 = GetPostString("backdate1");
  4111. string bdate2 = GetPostString("backdate2");
  4112. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4113. if (dw_back.Length > 0) lw.Add(dw_back);
  4114. string price1 = GetPostString("price1");
  4115. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4116. string price2 = GetPostString("price2");
  4117. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4118. lw.Add(string.Format("IsReturn=3"));
  4119. string backtype = GetPostString("backtype");
  4120. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4121. string backreason = GetPostString("backreason");
  4122. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4123. dStruct.Order = "ReturnTime desc";
  4124. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4125. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4126. writeGridDataTableJson(dStruct.TotalCount, dt);
  4127. }
  4128. public void get_erp_xianhuoreturnlist()
  4129. {
  4130. DataStruct dStruct = GetPostStruct();
  4131. List<string> lw = new List<string>();
  4132. string tid = GetPostString("ctid");
  4133. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4134. string shopname = GetPostString("shopname");
  4135. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4136. string buyernick = GetPostString("buyer_nick");
  4137. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4138. string customer = GetPostString("customer");
  4139. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4140. string design = GetPostString("design");
  4141. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4142. string orderState = GetPostString("orderState");
  4143. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4144. string address = GetPostString("address");
  4145. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4146. string sellermemo = GetPostString("seller_memo");
  4147. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4148. string supplier = GetPostString("supplier");
  4149. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4150. string OrderArea = GetPostString("order_area");
  4151. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4152. string date1 = GetPostString("date1");
  4153. string date2 = GetPostString("date2");
  4154. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4155. if (dw.Length > 0) lw.Add(dw);
  4156. string price1 = GetPostString("price1");
  4157. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4158. string price2 = GetPostString("price2");
  4159. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4160. string posTag = CurrentUser.UserPost.Post.Code;
  4161. if (posTag == "Supplier")
  4162. {
  4163. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4164. }
  4165. lw.Add(string.Format("OrderState=6 "));
  4166. lw.Add(string.Format("IsXianHuo=1 "));
  4167. lw.Add(string.Format("IsReturn>0 "));
  4168. lw.Add(string.Format("IsReturn!=3"));
  4169. lw.Add(string.Format("IsRefund<={0}", 1));
  4170. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4171. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4172. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4173. writeGridDataTableJson(dStruct.TotalCount, dt);
  4174. }
  4175. public void set_erp_orderdelivery()
  4176. {
  4177. if (UrlPostParmsCheck("ctid"))
  4178. {
  4179. string eid = GetPostString("ctid");
  4180. CeErpTradeCell entity = null;
  4181. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4182. if (entity != null)
  4183. {
  4184. if (entity.OrderState >= 7)
  4185. {
  4186. returnErrorMsg("此单已发货,无需重复发货");
  4187. return;
  4188. }
  4189. if (entity.OrderState != 6)
  4190. {
  4191. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4192. return;
  4193. }
  4194. string shop = GetPostString("seller_nick");
  4195. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4196. string comName = GetPostString("comName");
  4197. string comCode = GetPostString("comCode");
  4198. string outSid = GetPostString("outSid");
  4199. string deliveryType = GetPostString("deliveryType");
  4200. string deliveryMemo = GetPostString("deliveryMemo");
  4201. outSid = outSid.Trim();
  4202. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4203. if (mainEn == null)
  4204. {
  4205. returnErrorMsg("找不到原始订单记录");
  4206. return;
  4207. }
  4208. bool isInitOrderDeliv = false;
  4209. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4210. {
  4211. isInitOrderDeliv = true;
  4212. }
  4213. string apires = "";
  4214. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4215. 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)
  4216. {
  4217. apires = "发货成功true";
  4218. }
  4219. else
  4220. {
  4221. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4222. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4223. }
  4224. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4225. {
  4226. entity.OrderState = 7;//发货后订单已发货
  4227. entity.OutSid = outSid;
  4228. entity.MemoOpt = 0;
  4229. entity.FinishDeliveryTime = DateTime.Now;
  4230. entity.Update();
  4231. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4232. commonHelper.UpdateRelationOrder(entity.ctid);
  4233. //还要插入快递信息到 快递信息表
  4234. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4235. exinfo.tid = eid;
  4236. exinfo.out_sid = outSid;
  4237. exinfo.company_code = comCode;
  4238. exinfo.company_name = comName;
  4239. exinfo.delivery_memo = deliveryMemo;
  4240. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4241. exinfo.deliveryType = deliveryType;
  4242. exinfo.Create();
  4243. returnSuccessMsg("发货操作成功!");
  4244. commonHelper.UpdateRelationOrder(entity.ctid);
  4245. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4246. CeErpSukuraData.createInfo(entity.ctid, 4);
  4247. if (entity.SupplierId == 64)
  4248. {
  4249. commonHelper.sendCytExpress(exinfo);
  4250. }
  4251. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4252. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4253. }
  4254. else
  4255. {
  4256. string errmsg = commonHelper.KeepChinese(apires);
  4257. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4258. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4259. }
  4260. return;
  4261. }
  4262. returnErrorMsg("找不到订单记录");
  4263. }
  4264. }
  4265. public void set_erp_multidelivery()
  4266. {
  4267. string eids = GetPostString("tids");
  4268. string[] eidList = eids.Split(',');
  4269. if (eidList.Length <= 0)
  4270. {
  4271. returnErrorMsg("发货不能为空");
  4272. return;
  4273. }
  4274. foreach (string ctid in eidList)
  4275. {
  4276. if (ctid.Length <= 0) continue;
  4277. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4278. if (expInfo != null)
  4279. {
  4280. StringBuilder sql = new StringBuilder();
  4281. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4282. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4283. if (dt.Rows.Count > 0)
  4284. {
  4285. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4286. {
  4287. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4288. expInfo.state = "异常";
  4289. expInfo.isMultiDelivery = 1;
  4290. expInfo.Update();
  4291. continue;
  4292. }
  4293. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4294. {
  4295. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4296. expInfo.state = "异常";
  4297. expInfo.Update();
  4298. continue;
  4299. }
  4300. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4301. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4302. bool isInitOrderDeliv = false;
  4303. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4304. {
  4305. isInitOrderDeliv = true;
  4306. expInfo.isMultiDelivery = 1;
  4307. }
  4308. if (ctid.IndexOf("N") != -1)
  4309. {
  4310. StringBuilder sqlbucha = new StringBuilder();
  4311. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4312. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4313. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4314. commonHelper.UpdateRelationOrder(ctid);
  4315. expInfo.delivery_memo = "发货成功";
  4316. expInfo.state = "发货成功";
  4317. expInfo.isMultiDelivery = 1;
  4318. expInfo.Update();
  4319. }
  4320. else
  4321. {
  4322. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4323. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4324. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4325. {
  4326. expInfo.delivery_memo = "发货成功";
  4327. expInfo.state = "发货成功";
  4328. expInfo.isMultiDelivery = 1;
  4329. expInfo.Update();
  4330. commonHelper.UpdateRelationOrder(ctid);
  4331. CeErpSukuraData.createInfo(ctid, 4);
  4332. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4333. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4334. }
  4335. else
  4336. {
  4337. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4338. expInfo.state = "异常";
  4339. expInfo.Update();
  4340. }
  4341. }
  4342. }
  4343. }
  4344. }
  4345. returnSuccessMsg("操作完成");
  4346. }
  4347. public void reset_erp_memoopt()
  4348. {
  4349. if (UrlPostParmsCheck("ctid"))
  4350. {
  4351. string eid = GetPostString("ctid");
  4352. CeErpTradeCell entity = null;
  4353. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4354. if (entity != null)
  4355. {
  4356. string stropt = "";
  4357. if (entity.MemoOpt == 1)
  4358. {
  4359. stropt = "“改稿”";
  4360. }
  4361. else if (entity.MemoOpt == 2)
  4362. {
  4363. stropt = "“定稿”";
  4364. }
  4365. else if (entity.MemoOpt == 3)
  4366. {
  4367. stropt = "“完成查货”";
  4368. CeErpSukuraData.createInfo(entity.ctid, 6);
  4369. }
  4370. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4371. entity.MemoOpt = 0;
  4372. entity.Update();
  4373. returnSuccessMsg("操作成功!");
  4374. return;
  4375. }
  4376. returnErrorMsg("找不到记录");
  4377. }
  4378. }
  4379. public void get_erp_deliveryunusual()
  4380. {
  4381. DataStruct dStruct = GetPostStruct();
  4382. List<string> lw = new List<string>();
  4383. string tid = GetPostString("ctid");
  4384. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4385. string shopname = GetPostString("shopname");
  4386. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4387. string buyernick = GetPostString("buyer_nick");
  4388. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4389. string customer = GetPostString("customer");
  4390. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4391. string design = GetPostString("design");
  4392. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4393. string sellermemo = GetPostString("seller_memo");
  4394. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4395. string supplier = GetPostString("supplier");
  4396. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4397. string date1 = GetPostString("date1");
  4398. string date2 = GetPostString("date2");
  4399. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4400. if (dw.Length > 0) lw.Add(dw);
  4401. string placedate1 = GetPostString("placedate1");
  4402. string placedate2 = GetPostString("placedate2");
  4403. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4404. if (dw_place.Length > 0) lw.Add(dw_place);
  4405. string price1 = GetPostString("price1");
  4406. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4407. string price2 = GetPostString("price2");
  4408. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4409. string unusualCon = GetPostString("unusualcon");
  4410. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4411. string posTag = CurrentUser.UserPost.Post.Code;
  4412. if (posTag == "Supplier")
  4413. {
  4414. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4415. }
  4416. lw.Add(string.Format("OrderState = 6"));
  4417. lw.Add(string.Format("UnusualTag = 5"));
  4418. lw.Add(string.Format("IsRefund<={0}", 1));
  4419. dStruct.Order = "FinishPlaceTime desc";
  4420. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4421. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4422. writeGridDataTableJson(dStruct.TotalCount, dt);
  4423. }
  4424. public void get_erp_deliveryedlist()
  4425. {
  4426. DataStruct dStruct = GetPostStruct();
  4427. List<string> lw = new List<string>();
  4428. string tid = GetPostString("ctid");
  4429. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4430. string shopname = GetPostString("shopname");
  4431. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4432. string buyernick = GetPostString("buyer_nick");
  4433. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4434. string customer = GetPostString("customer");
  4435. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4436. string design = GetPostString("design");
  4437. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4438. string sellermemo = GetPostString("seller_memo");
  4439. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4440. string logistics = GetPostString("logistics");
  4441. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4442. string date1 = GetPostString("date1");
  4443. string date2 = GetPostString("date2");
  4444. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4445. //if (dw.Length > 0) lw.Add(dw);
  4446. string placedate1 = GetPostString("placedate1");
  4447. string placedate2 = GetPostString("placedate2");
  4448. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4449. if (fdw.Length > 0) lw.Add(fdw);
  4450. string devdate1 = GetPostString("deliverydate1");
  4451. string devdate2 = GetPostString("deliverydate2");
  4452. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4453. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4454. string price1 = GetPostString("price1");
  4455. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4456. string price2 = GetPostString("price2");
  4457. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4458. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4459. {
  4460. if (tid.Length > 0)
  4461. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4462. if (buyernick.Length > 0)
  4463. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4464. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4465. if (dw.Length > 0) lw.Add(dw);
  4466. }
  4467. else
  4468. {
  4469. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4470. }
  4471. string posTag = CurrentUser.UserPost.Post.Code;
  4472. if (posTag == "Supplier")
  4473. {
  4474. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4475. }
  4476. else
  4477. {
  4478. string supplier = GetPostString("supplier");
  4479. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4480. }
  4481. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4482. lw.Add(string.Format("IsRefund!={0}", 2));
  4483. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4484. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4485. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4486. if (dt != null)
  4487. {
  4488. foreach (DataRow dr in dt.Rows)
  4489. {
  4490. 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();
  4491. }
  4492. }
  4493. writeGridDataTableJson(dStruct.TotalCount, dt);
  4494. }
  4495. public void get_erp_pdddeliveryed()
  4496. {
  4497. DataStruct dStruct = GetPostStruct();
  4498. List<string> lw = new List<string>();
  4499. string tid = GetPostString("ctid");
  4500. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4501. string shopname = GetPostString("shopname");
  4502. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4503. string buyernick = GetPostString("buyer_nick");
  4504. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4505. string customer = GetPostString("customer");
  4506. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4507. string design = GetPostString("design");
  4508. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4509. string sellermemo = GetPostString("seller_memo");
  4510. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4511. string logistics = GetPostString("logistics");
  4512. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4513. string date1 = GetPostString("date1");
  4514. string date2 = GetPostString("date2");
  4515. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4516. //if (dw.Length > 0) lw.Add(dw);
  4517. string placedate1 = GetPostString("placedate1");
  4518. string placedate2 = GetPostString("placedate2");
  4519. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4520. if (fdw.Length > 0) lw.Add(fdw);
  4521. string devdate1 = GetPostString("deliverydate1");
  4522. string devdate2 = GetPostString("deliverydate2");
  4523. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4524. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4525. string price1 = GetPostString("price1");
  4526. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4527. string price2 = GetPostString("price2");
  4528. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4529. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4530. {
  4531. if (tid.Length > 0)
  4532. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4533. if (buyernick.Length > 0)
  4534. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4535. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4536. if (dw.Length > 0) lw.Add(dw);
  4537. }
  4538. else
  4539. {
  4540. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4541. }
  4542. string posTag = CurrentUser.UserPost.Post.Code;
  4543. if (posTag == "Supplier")
  4544. {
  4545. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4546. }
  4547. else
  4548. {
  4549. string supplier = GetPostString("supplier");
  4550. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4551. }
  4552. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4553. lw.Add(string.Format("type = 'PDD' "));
  4554. lw.Add(string.Format("IsRefund!={0}", 2));
  4555. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4556. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4557. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4558. foreach (DataRow dr in dt.Rows)
  4559. {
  4560. 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();
  4561. }
  4562. writeGridDataTableJson(dStruct.TotalCount, dt);
  4563. }
  4564. public void get_erp_jddeliveryed()
  4565. {
  4566. DataStruct dStruct = GetPostStruct();
  4567. List<string> lw = new List<string>();
  4568. string tid = GetPostString("ctid");
  4569. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4570. string shopname = GetPostString("shopname");
  4571. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4572. string buyernick = GetPostString("buyer_nick");
  4573. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4574. string customer = GetPostString("customer");
  4575. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4576. string design = GetPostString("design");
  4577. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4578. string sellermemo = GetPostString("seller_memo");
  4579. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4580. string date1 = GetPostString("date1");
  4581. string date2 = GetPostString("date2");
  4582. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4583. //if (dw.Length > 0) lw.Add(dw);
  4584. string placedate1 = GetPostString("placedate1");
  4585. string placedate2 = GetPostString("placedate2");
  4586. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4587. if (fdw.Length > 0) lw.Add(fdw);
  4588. string devdate1 = GetPostString("deliverydate1");
  4589. string devdate2 = GetPostString("deliverydate2");
  4590. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4591. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4592. string price1 = GetPostString("price1");
  4593. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4594. string price2 = GetPostString("price2");
  4595. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4596. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4597. {
  4598. if (tid.Length > 0)
  4599. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4600. if (buyernick.Length > 0)
  4601. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4602. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4603. if (dw.Length > 0) lw.Add(dw);
  4604. }
  4605. else
  4606. {
  4607. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4608. }
  4609. string posTag = CurrentUser.UserPost.Post.Code;
  4610. if (posTag == "Supplier")
  4611. {
  4612. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4613. }
  4614. else
  4615. {
  4616. string supplier = GetPostString("supplier");
  4617. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4618. }
  4619. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4620. lw.Add(string.Format("type = 'JD' "));
  4621. lw.Add(string.Format("IsRefund!={0}", 2));
  4622. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4623. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4624. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4625. foreach (DataRow dr in dt.Rows)
  4626. {
  4627. 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();
  4628. }
  4629. writeGridDataTableJson(dStruct.TotalCount, dt);
  4630. }
  4631. public void get_erp_allplacelist()
  4632. {
  4633. DataStruct dStruct = GetPostStruct();
  4634. List<string> lw = new List<string>();
  4635. string tid = GetPostString("ctid");
  4636. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4637. string shopname = GetPostString("shopname");
  4638. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4639. string buyernick = GetPostString("buyer_nick");
  4640. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4641. string customer = GetPostString("customer");
  4642. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4643. string design = GetPostString("design");
  4644. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4645. string sellermemo = GetPostString("seller_memo");
  4646. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4647. string supplier = GetPostString("supplier");
  4648. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4649. string date1 = GetPostString("date1");
  4650. string date2 = GetPostString("date2");
  4651. string pldate1 = GetPostString("placedate1");
  4652. string pldate2 = GetPostString("placedate2");
  4653. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4654. //if (dw.Length > 0) lw.Add(dw);
  4655. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4656. {
  4657. if (tid.Length > 0)
  4658. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4659. if (buyernick.Length > 0)
  4660. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4661. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4662. if (dw.Length > 0) lw.Add(dw);
  4663. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4664. if (dw_place.Length > 0) lw.Add(dw_place);
  4665. }
  4666. else
  4667. {
  4668. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4669. {
  4670. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4671. }
  4672. }
  4673. string price1 = GetPostString("price1");
  4674. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4675. string price2 = GetPostString("price2");
  4676. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4677. string posTag = CurrentUser.UserPost.Post.Code;
  4678. if (posTag == "Supplier")
  4679. {
  4680. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4681. }
  4682. lw.Add(string.Format("OrderState >= 6"));
  4683. lw.Add(string.Format("IsSample != 2 "));
  4684. lw.Add(string.Format("isDianziOrder = 0 "));
  4685. //lw.Add(string.Format("IsRefund<={0}", 1));
  4686. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4687. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4688. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4689. foreach (DataRow dr in dt.Rows)
  4690. {
  4691. 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();
  4692. }
  4693. writeGridDataTableJson(dStruct.TotalCount, dt);
  4694. }
  4695. public void get_erp_financeallplacelist()
  4696. {
  4697. DataStruct dStruct = GetPostStruct();
  4698. List<string> lw = new List<string>();
  4699. string tid = GetPostString("ctid");
  4700. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4701. string shopname = GetPostString("shopname");
  4702. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4703. string buyernick = GetPostString("buyer_nick");
  4704. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4705. string customer = GetPostString("customer");
  4706. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4707. string design = GetPostString("design");
  4708. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4709. string sellermemo = GetPostString("seller_memo");
  4710. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4711. string supplier = GetPostString("supplier");
  4712. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4713. string date1 = GetPostString("date1");
  4714. string date2 = GetPostString("date2");
  4715. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4716. if (dw.Length > 0) lw.Add(dw);
  4717. string pldate1 = GetPostString("placedate1");
  4718. string pldate2 = GetPostString("placedate2");
  4719. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4720. if (dw_place.Length > 0) lw.Add(dw_place);
  4721. string price1 = GetPostString("price1");
  4722. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4723. string price2 = GetPostString("price2");
  4724. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4725. string posTag = CurrentUser.UserPost.Post.Code;
  4726. if (posTag == "Supplier")
  4727. {
  4728. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4729. }
  4730. //lw.Add(string.Format("OrderState >= 6"));
  4731. lw.Add(string.Format("IsSample != 2 "));
  4732. lw.Add(string.Format("isDianziOrder = 0 "));
  4733. //lw.Add(string.Format("IsRefund<={0}", 1));
  4734. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4735. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4736. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4737. foreach (DataRow dr in dt.Rows)
  4738. {
  4739. 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();
  4740. }
  4741. writeGridDataTableJson(dStruct.TotalCount, dt);
  4742. }
  4743. public void get_erp_expresslist()
  4744. {
  4745. int listtype = GetInt("ltype");
  4746. DataStruct dStruct = GetPostStruct();
  4747. List<string> lw = new List<string>();
  4748. string tid = GetPostString("tid");
  4749. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4750. string outsid = GetPostString("out_sid");
  4751. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4752. string importer = GetPostString("ImportUserName");
  4753. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4754. string file = GetPostString("import_file");
  4755. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4756. string printman = GetPostString("printman");
  4757. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4758. string date1 = GetPostString("date1");
  4759. string date2 = GetPostString("date2");
  4760. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4761. if (dw.Length > 0) lw.Add(dw);
  4762. string fdate1 = GetPostString("finishdate1");
  4763. string fdate2 = GetPostString("finishdate2");
  4764. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4765. if (fdw.Length > 0) lw.Add(fdw);
  4766. if (listtype == 1)
  4767. {
  4768. lw.Add(string.Format("importUserId !=0"));
  4769. }
  4770. string posTag = CurrentUser.UserPost.Post.Code;
  4771. if (posTag == "Supplier")
  4772. {
  4773. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4774. }
  4775. if (dStruct.PageSize != 100000)
  4776. {
  4777. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4778. }
  4779. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4780. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4781. writeGridDataTableJson(dStruct.TotalCount, dt);
  4782. }
  4783. public void set_erp_buchaorderdelivery()
  4784. {
  4785. if (UrlPostParmsCheck("ctid"))
  4786. {
  4787. string eid = GetPostString("ctid");
  4788. CeErpTradeCell entity = null;
  4789. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4790. if (entity != null)
  4791. {
  4792. if (entity.IsSample != 2)
  4793. {
  4794. returnErrorMsg("补差价单才能标记为已发货");
  4795. return;
  4796. }
  4797. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4798. entity.OrderState = 7;
  4799. entity.Update();
  4800. returnSuccessMsg("操作成功!");
  4801. return;
  4802. }
  4803. returnErrorMsg("找不到记录");
  4804. }
  4805. }
  4806. public void get_stdtemplates()
  4807. {
  4808. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4809. //string res = taobaoHelper.test();
  4810. string res = apiHelper.API_PrintTemplate();
  4811. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4812. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4813. {
  4814. int sidx = res.IndexOf("error_code");
  4815. int eidx = res.IndexOf("success");
  4816. string msg = res.Substring(sidx, eidx - sidx);
  4817. returnErrorMsg(msg);
  4818. return;
  4819. }
  4820. if (res.Length <= 0)
  4821. {
  4822. returnErrorMsg("模板数据为空!");
  4823. return;
  4824. }
  4825. ReturnSuccess(res);
  4826. }
  4827. public void cancel_print_order()
  4828. {
  4829. if (UrlPostParmsCheck("ctid"))
  4830. {
  4831. string ctid = GetPostString("ctid");
  4832. CeErpTradeCell entity = null;
  4833. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4834. if (entity != null)
  4835. {
  4836. string res = "";
  4837. string code = entity.LastBillWaybillCode;
  4838. if (code == "")
  4839. {
  4840. code = entity.OutSid;
  4841. }
  4842. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  4843. XLog.SaveLog(0, "取消面单" + res);
  4844. }
  4845. }
  4846. }
  4847. public void set_erp_printwaybill()
  4848. {
  4849. if (UrlPostParmsCheck("ctid"))
  4850. {
  4851. string ctid = GetPostString("ctid");
  4852. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  4853. string cpName = GetPostString("cpname");
  4854. string isTogether = GetPostString("together");
  4855. //var res_obj = new
  4856. //{
  4857. // restype = 1,
  4858. // 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\"}"
  4859. //};
  4860. //string ro_json = JsonConvert.SerializeObject(res_obj);
  4861. //ReturnSuccess(ro_json);
  4862. //return;
  4863. bool isUseLastWayBillCode = false;
  4864. CeErpTradeCell entity = null;
  4865. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4866. if (entity != null)
  4867. {
  4868. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  4869. {
  4870. isUseLastWayBillCode = true;
  4871. }
  4872. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  4873. {
  4874. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  4875. return;
  4876. }
  4877. }
  4878. string res = "";
  4879. Api_waybill_code_response_Obj fullObj = null;
  4880. string pData_str = "";
  4881. string curUseWayBillCode = "";
  4882. if (isUseLastWayBillCode == false)
  4883. {
  4884. res = apiHelper.API_GetWaybill(cpCode, ctid);
  4885. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  4886. if (res.IndexOf("failure") != -1)
  4887. {
  4888. //int idx = res.IndexOf("sub_message");
  4889. //int idx2 = res.IndexOf("flag");
  4890. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  4891. string errMsgNeed = commonHelper.KeepChinese(res);
  4892. var res_objd = new
  4893. {
  4894. restype = 0,
  4895. data = "获取面单失败" + errMsgNeed
  4896. };
  4897. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  4898. returnSuccess(ro_jsond);
  4899. if (res.IndexOf("停发") != -1)
  4900. {
  4901. entity.UnusualCon = "物流停发";
  4902. entity.Update();
  4903. }
  4904. //returnErrorMsg("获取面单失败,"+emsg);
  4905. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  4906. return;
  4907. }
  4908. else if (res.IndexOf("errorMsg") != -1)
  4909. {
  4910. //int idx = res.IndexOf("errorMsg");
  4911. //int idx2 = res.IndexOf("}]}");
  4912. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  4913. string errMsgNeed = commonHelper.KeepChinese(res);
  4914. var res_objf = new
  4915. {
  4916. restype = 0,
  4917. data = "获取面单失败2" + errMsgNeed
  4918. };
  4919. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4920. if (res.IndexOf("停发") != -1)
  4921. {
  4922. entity.UnusualCon = "物流停发";
  4923. entity.Update();
  4924. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4925. if (trade != null)
  4926. {
  4927. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  4928. }
  4929. }
  4930. returnSuccess(ro_jsonf);
  4931. //returnErrorMsg("获取面单失败," + emsg);
  4932. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  4933. return;
  4934. }
  4935. try
  4936. {
  4937. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4938. //res = res.Replace(" ", "");
  4939. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  4940. }
  4941. catch (Exception ex)
  4942. {
  4943. XLog.SaveLog(0, "生成fullObj" + res);
  4944. var res_objf = new
  4945. {
  4946. restype = 0,
  4947. data = "生成fullObj发生错误" + ex.Message
  4948. };
  4949. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4950. returnSuccess(ro_jsonf);
  4951. return;
  4952. }
  4953. if (fullObj.response.data.content.Count > 0)
  4954. {
  4955. ContentItem codeObj = fullObj.response.data.content[0];
  4956. if (cpCode.IndexOf("SFFQ-") != -1)
  4957. {
  4958. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  4959. }
  4960. else
  4961. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  4962. curUseWayBillCode = codeObj.waybillCode;
  4963. }
  4964. else
  4965. {
  4966. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  4967. var res_objf = new
  4968. {
  4969. restype = 0,
  4970. data = "生成fullObj找不到快递单号waybillCode"
  4971. };
  4972. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4973. returnSuccess(ro_jsonf);
  4974. return;
  4975. }
  4976. }
  4977. else
  4978. {
  4979. //使用上次打印的快递单号
  4980. if (cpCode == "SFFQ-LY")
  4981. {
  4982. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  4983. }
  4984. else
  4985. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  4986. curUseWayBillCode = entity.LastBillWaybillCode;
  4987. }
  4988. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  4989. {
  4990. var res_obje = new
  4991. {
  4992. restype = 0,
  4993. data = "获取加密打印数据失败"
  4994. };
  4995. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  4996. returnSuccess(ro_jsone);
  4997. entity.LastBillCpCode = cpCode;
  4998. entity.LastBillWaybillCode = curUseWayBillCode;
  4999. entity.Update();
  5000. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5001. //returnErrorMsg("获取加密打印数据失败");
  5002. return;
  5003. }
  5004. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5005. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5006. string btnType = "";
  5007. if (entity != null)
  5008. {
  5009. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5010. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5011. //cpcode是 YTO-CAINIAO
  5012. //string comCode = cpCode.Split('-')[0].ToString();
  5013. string apires = "";
  5014. if (ctid.IndexOf("N") != -1)
  5015. {
  5016. apires = "发货成功";
  5017. }
  5018. else
  5019. {
  5020. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5021. }
  5022. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5023. //打单后发货
  5024. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5025. {
  5026. try
  5027. {
  5028. btnType = "待发货";
  5029. entity.OutSid = curUseWayBillCode;
  5030. entity.OrderState = 7;
  5031. entity.IsUrgency = false;
  5032. entity.LastBillCpCode = "";
  5033. entity.LastBillWaybillCode = "";
  5034. entity.FinishDeliveryTime = DateTime.Now;
  5035. entity.IsReturn = 0;
  5036. entity.MemoOpt = 0;
  5037. entity.Update();
  5038. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5039. //还要插入快递信息到 快递信息表
  5040. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5041. exinfo.tid = entity.ctid;
  5042. exinfo.out_sid = entity.OutSid;
  5043. exinfo.company_code = cpCode;
  5044. exinfo.company_name = cpName;
  5045. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5046. exinfo.deliveryType = "发货成功";
  5047. exinfo.print_time = DateTime.Now;
  5048. exinfo.printUser = CurrentUser.UserName;
  5049. exinfo.Create();
  5050. commonHelper.UpdateRelationOrder(entity.ctid);
  5051. CeErpSukuraData.createInfo(ctid, 4);
  5052. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5053. if (entity.SupplierId == 64)
  5054. {
  5055. commonHelper.sendCytExpress(exinfo);
  5056. }
  5057. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5058. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5059. if (isTogether == "1")
  5060. {
  5061. StringBuilder sqlsb = new StringBuilder();
  5062. 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);
  5063. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5064. }
  5065. }
  5066. catch (Exception ex)
  5067. {
  5068. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5069. }
  5070. }
  5071. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5072. {
  5073. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5074. if (entity.OrderState == 6)
  5075. {
  5076. entity.OrderState = 7;
  5077. }
  5078. entity.FinishDeliveryTime = DateTime.Now;
  5079. btnType = "已发货";
  5080. entity.Update();
  5081. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5082. exinfo.tid = entity.ctid;
  5083. exinfo.out_sid = entity.OutSid;
  5084. exinfo.company_code = cpCode;
  5085. exinfo.company_name = cpName;
  5086. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5087. exinfo.deliveryType = "发货成功";
  5088. exinfo.print_time = DateTime.Now;
  5089. exinfo.printUser = CurrentUser.UserName;
  5090. exinfo.Create();
  5091. commonHelper.UpdateRelationOrder(entity.ctid);
  5092. CeErpSukuraData.createInfo(entity.ctid, 4);
  5093. if (entity.SupplierId == 64)
  5094. {
  5095. commonHelper.sendCytExpress(exinfo);
  5096. }
  5097. if (isTogether == "1")
  5098. {
  5099. StringBuilder sqlsb = new StringBuilder();
  5100. 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);
  5101. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5102. }
  5103. //不处理
  5104. }
  5105. else
  5106. {
  5107. entity.LastBillCpCode = cpCode;
  5108. entity.LastBillWaybillCode = curUseWayBillCode;
  5109. entity.Update();
  5110. string errmsg = commonHelper.KeepChinese(apires);
  5111. var res_objz = new
  5112. {
  5113. restype = 0,
  5114. data = "打单后发货失败"
  5115. };
  5116. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5117. returnSuccess(ro_jsonz);
  5118. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5119. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5120. return;
  5121. }
  5122. }
  5123. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5124. var res_obj = new
  5125. {
  5126. restype = 1,
  5127. data = pData_str
  5128. };
  5129. string ro_json = JsonConvert.SerializeObject(res_obj);
  5130. ReturnSuccess(ro_json);
  5131. return;
  5132. }
  5133. }
  5134. private string GetUTF8String(byte[] vs)
  5135. {
  5136. throw new NotImplementedException();
  5137. }
  5138. public void set_erp_printwaybill_cn()
  5139. {
  5140. if (UrlPostParmsCheck("ctid"))
  5141. {
  5142. string ctid = GetPostString("ctid");
  5143. string cpCode = GetPostString("cpcode");
  5144. string cpName = GetPostString("cpname");
  5145. string tempUrl = GetPostString("tempurl");
  5146. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5147. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5148. //string res = taobaoHelper.test();
  5149. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5150. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5151. {
  5152. int sidx = res.IndexOf("errorMsg");
  5153. int eidx = res.IndexOf("}");
  5154. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5155. var res_objzxx = new
  5156. {
  5157. restype = 0,
  5158. data = msg
  5159. };
  5160. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5161. returnSuccess(ro_jsonzxx);
  5162. //returnErrorMsg(msg);
  5163. return;
  5164. }
  5165. int idx = res.IndexOf("waybillCode");
  5166. int idx2 = res.IndexOf("printData");
  5167. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5168. string eid = GetPostString("ctid");
  5169. CeErpTradeCell entity = null;
  5170. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5171. if (entity != null)
  5172. {
  5173. string osid = entity.OutSid;
  5174. entity.OutSid = osid + "," + outsid;
  5175. entity.FinishDeliveryTime = DateTime.Now;
  5176. entity.OrderState = 7;
  5177. entity.IsReturn = 0;
  5178. entity.Update();
  5179. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5180. exinfo.tid = entity.ctid;
  5181. exinfo.out_sid = outsid;
  5182. exinfo.company_code = cpCode;
  5183. exinfo.company_name = cpName;
  5184. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5185. exinfo.deliveryType = "发货成功";
  5186. exinfo.print_time = DateTime.Now;
  5187. exinfo.printUser = CurrentUser.UserName;
  5188. exinfo.Create();
  5189. if (entity.SupplierId == 64)
  5190. {
  5191. commonHelper.sendCytExpress(exinfo);
  5192. }
  5193. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5194. }
  5195. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5196. var res_objz = new
  5197. {
  5198. restype = 1,
  5199. data = res
  5200. };
  5201. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5202. returnSuccess(ro_jsonz);
  5203. //ReturnSuccess(res);
  5204. }
  5205. }
  5206. ////打单,打印面单 获取面单号
  5207. //public void set_erp_printwaybill()
  5208. //{
  5209. // if (UrlPostParmsCheck("ctid"))
  5210. // {
  5211. // string ctid = GetPostString("ctid");
  5212. // string cpCode = GetPostString("cpcode");
  5213. // string tempUrl = GetPostString("tempurl");
  5214. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5215. // //string res = taobaoHelper.test();
  5216. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5217. // if (res.IndexOf("error_response") != -1)
  5218. // {
  5219. // int sidx = res.IndexOf("sub_msg");
  5220. // int eidx = res.IndexOf("request_id");
  5221. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5222. // returnErrorMsg(msg);
  5223. // return;
  5224. // }
  5225. // int idx = res.IndexOf("waybill_code");
  5226. // int idx2 = res.IndexOf("}]}");
  5227. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5228. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5229. // ReturnSuccess(res);
  5230. // }
  5231. //}
  5232. public void cancel_erp_aftersale()
  5233. {
  5234. if (UrlPostParmsCheck("ctid"))
  5235. {
  5236. string eid = GetPostString("ctid");
  5237. CeErpTradeCell entity = null;
  5238. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5239. if (entity != null)
  5240. {
  5241. //有过处理的售后,取消也不能删除 售 字,保留
  5242. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5243. {
  5244. entity.AfterSaleState = 4;
  5245. }
  5246. else
  5247. entity.AfterSaleState = 0;
  5248. entity.Update();
  5249. returnSuccessMsg("操作成功!");
  5250. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5251. return;
  5252. }
  5253. returnErrorMsg("找不到订单记录");
  5254. }
  5255. }
  5256. public void get_erp_aftersalelist()
  5257. {
  5258. DataStruct dStruct = GetPostStruct();
  5259. List<string> lw = new List<string>();
  5260. int st = GetInt("st");
  5261. string tid = GetPostString("ctid");
  5262. if (st == 3)
  5263. {
  5264. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5265. }
  5266. else
  5267. {
  5268. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5269. }
  5270. string shopname = GetPostString("shopname");
  5271. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5272. string buyernick = GetPostString("buyer_nick");
  5273. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5274. string sellermemo = GetPostString("seller_memo");
  5275. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5276. string orderState = GetPostString("orderState");
  5277. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5278. string afterState = GetPostString("afterstate");
  5279. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5280. string date1 = GetPostString("date1");
  5281. string date2 = GetPostString("date2");
  5282. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5283. if (dw.Length > 0) lw.Add(dw);
  5284. string price1 = GetPostString("price1");
  5285. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5286. string price2 = GetPostString("price2");
  5287. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5288. //lw.Add(string.Format("IsRefund!={0}", 1));
  5289. string reason = GetPostString("reason");
  5290. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5291. string method = GetPostString("method");
  5292. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5293. string handler = GetPostString("handler");
  5294. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5295. string handledate1 = GetPostString("handledate1");
  5296. string handledate2 = GetPostString("handledate2");
  5297. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5298. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5299. string finish1 = GetPostString("finishdate1");
  5300. string finish2 = GetPostString("finishdate2");
  5301. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5302. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5303. string afterdate1 = GetPostString("afterdate1");
  5304. string afterdate2 = GetPostString("afterdate2");
  5305. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5306. if (afterDate.Length > 0) lw.Add(afterDate);
  5307. string supplier = GetPostString("supplier");
  5308. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5309. string responsible = GetPostString("responsibleman");
  5310. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5311. string customer = GetPostString("customer");
  5312. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5313. string design = GetPostString("design");
  5314. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5315. string afterMemoType = GetPostString("aftermemotype");
  5316. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5317. string posCode = CurrentUser.UserPost.Post.Code;
  5318. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5319. //{
  5320. // string vstate = GetPostString("vstate");
  5321. // if (vstate.Length > 0)
  5322. // {
  5323. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5324. // }
  5325. // if (posCode == "Supplier")
  5326. // {
  5327. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5328. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5329. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5330. // }
  5331. // else
  5332. // {
  5333. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5334. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5335. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5336. // {
  5337. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5338. // }
  5339. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5340. // {
  5341. // int orgid = CurrentUser.UserPost.OrgID;
  5342. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5343. // }
  5344. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5345. // {
  5346. // string shopid = CurrentUser.User.pemShop;
  5347. // lw.Add(string.Format("shopId in ({0})", shopid));
  5348. // }
  5349. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5350. // //{
  5351. // // int org_id = CurrentUser.UserPost.OrgID;
  5352. // // lw.Add(string.Format("OrgID={0}", org_id));
  5353. // //}
  5354. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5355. // }
  5356. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5357. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5358. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5359. //}
  5360. if (st == 5)
  5361. {
  5362. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5363. {
  5364. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5365. {
  5366. string shopid = CurrentUser.User.pemShop;
  5367. lw.Add(string.Format("shopId in ({0})", shopid));
  5368. }
  5369. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5370. {
  5371. int mrOrgid = CurrentUser.UserPost.OrgID;
  5372. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5373. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5374. }
  5375. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5376. //{
  5377. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5378. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5379. //}
  5380. else
  5381. {
  5382. string userIdStr = "";
  5383. if (posCode == "CustomerService")
  5384. {
  5385. userIdStr = CurrentUser.UserID + "_k";
  5386. }
  5387. else if (posCode == "Designer" || posCode == "wxDesigner")
  5388. {
  5389. userIdStr = CurrentUser.UserID + "_s";
  5390. }
  5391. else if (posCode == "Place")
  5392. {
  5393. userIdStr = CurrentUser.UserID + "_x";
  5394. }
  5395. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5396. }
  5397. }
  5398. string placedate1 = GetPostString("placedate1");
  5399. string placedate2 = GetPostString("placedate2");
  5400. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5401. if (dwplace.Length > 0) lw.Add(dwplace);
  5402. string supState = GetPostString("supState");
  5403. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5404. string searchType = GetPostString("searchType");
  5405. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5406. {
  5407. lw.Add(string.Format("BackNum>1"));
  5408. }
  5409. lw.Add(string.Format("AfterSaleState>0"));
  5410. if (ex_psize > 0)
  5411. {
  5412. if (CurrentUser.UserPost.Post.Code == "Finance")
  5413. dStruct.Order = "pay_time desc";
  5414. else
  5415. dStruct.Order = "HandleTime desc";
  5416. }
  5417. else
  5418. dStruct.Order = "HandleTime desc";
  5419. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5420. DataTable dt = WebCache.GetData("view_test", dStruct);
  5421. writeGridDataTableJson(dStruct.TotalCount, dt);
  5422. }
  5423. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5424. //{
  5425. // lw.Add(string.Format("AfterSaleState=4"));
  5426. // string code = CurrentUser.UserPost.Post.Code;
  5427. // if (code == "CustomerService")
  5428. // {
  5429. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5430. // }
  5431. // else if (code == "Designer" || code == "DesignerMr")
  5432. // {
  5433. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5434. // }
  5435. // else if (code == "Place" || code == "PlaceMr")
  5436. // {
  5437. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5438. // }
  5439. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5440. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5441. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5442. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5443. //}
  5444. //else //处理中的售后,待处理和处理中合并
  5445. //{
  5446. // if (afterState.Length <= 0)
  5447. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5448. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5449. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5450. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5451. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5452. //}
  5453. }
  5454. public void get_erp_disagreeftersalelist()
  5455. {
  5456. DataStruct dStruct = GetPostStruct();
  5457. List<string> lw = new List<string>();
  5458. int st = 2;
  5459. string tid = GetPostString("ctid");
  5460. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5461. string shopname = GetPostString("shopname");
  5462. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5463. string buyernick = GetPostString("buyer_nick");
  5464. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5465. string sellermemo = GetPostString("seller_memo");
  5466. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5467. string orderState = GetPostString("orderState");
  5468. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5469. string afterState = GetPostString("afterstate");
  5470. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5471. string date1 = GetPostString("date1");
  5472. string date2 = GetPostString("date2");
  5473. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5474. if (dw.Length > 0) lw.Add(dw);
  5475. string price1 = GetPostString("price1");
  5476. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5477. string price2 = GetPostString("price2");
  5478. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5479. //lw.Add(string.Format("IsRefund!={0}", 1));
  5480. string reason = GetPostString("reason");
  5481. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5482. string method = GetPostString("method");
  5483. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5484. string handler = GetPostString("handler");
  5485. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5486. string handledate1 = GetPostString("handledate1");
  5487. string handledate2 = GetPostString("handledate2");
  5488. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5489. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5490. string afterdate1 = GetPostString("afterdate1");
  5491. string afterdate2 = GetPostString("afterdate2");
  5492. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5493. if (afterDate.Length > 0) lw.Add(afterDate);
  5494. string backdate1 = GetPostString("backdate1");
  5495. string backdate2 = GetPostString("backdate2");
  5496. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5497. if (backDate.Length > 0) lw.Add(backDate);
  5498. string supplier = GetPostString("supplier");
  5499. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5500. string responsible = GetPostString("responsibleman");
  5501. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5502. string customer = GetPostString("customer");
  5503. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5504. string design = GetPostString("design");
  5505. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5506. string afterSaleMemo = GetPostString("afterSaleMemo");
  5507. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5508. string afterMemoType = GetPostString("aftermemotype");
  5509. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5510. string aftersakereason = GetPostString("aftersakereason");
  5511. if (aftersakereason.Length > 0)
  5512. {
  5513. if (aftersakereason == "1")
  5514. {
  5515. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5516. }
  5517. if (aftersakereason == "2")
  5518. {
  5519. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5520. }
  5521. }
  5522. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5523. string poscode = CurrentUser.UserPost.Post.Code;
  5524. if (poscode != "SysAdmin")
  5525. {
  5526. string shopid = CurrentUser.User.pemShop;
  5527. lw.Add(string.Format("shopId in ({0})", shopid));
  5528. }
  5529. string searchType = GetPostString("searchType");
  5530. if (searchType == "wait")
  5531. {
  5532. lw.Add(string.Format("HandleTime is null"));
  5533. }
  5534. if (searchType == "handling")
  5535. {
  5536. lw.Add(string.Format("HandleTime is not null "));
  5537. }
  5538. if (searchType == "back" || searchType == "puBack")
  5539. {
  5540. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5541. }
  5542. if (searchType == "reBack")
  5543. {
  5544. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5545. }
  5546. if (searchType == "moreBack")
  5547. {
  5548. lw.Add(string.Format("backNum > 1"));
  5549. }
  5550. lw.Add(string.Format("(AfterSaleState=5)"));
  5551. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5552. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5553. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5554. writeGridDataTableJson(dStruct.TotalCount, dt);
  5555. }
  5556. public void get_erp_handlingaftersalelist()
  5557. {
  5558. DataStruct dStruct = GetPostStruct();
  5559. List<string> lw = new List<string>();
  5560. int st = 2;
  5561. string tid = GetPostString("ctid");
  5562. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5563. string shopname = GetPostString("shopname");
  5564. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5565. string buyernick = GetPostString("buyer_nick");
  5566. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5567. string sellermemo = GetPostString("seller_memo");
  5568. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5569. string orderState = GetPostString("orderState");
  5570. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5571. string afterState = GetPostString("afterstate");
  5572. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5573. string date1 = GetPostString("date1");
  5574. string date2 = GetPostString("date2");
  5575. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5576. if (dw.Length > 0) lw.Add(dw);
  5577. string price1 = GetPostString("price1");
  5578. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5579. string price2 = GetPostString("price2");
  5580. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5581. //lw.Add(string.Format("IsRefund!={0}", 1));
  5582. string reason = GetPostString("reason");
  5583. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5584. string method = GetPostString("method");
  5585. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5586. string handler = GetPostString("handler");
  5587. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5588. string handledate1 = GetPostString("handledate1");
  5589. string handledate2 = GetPostString("handledate2");
  5590. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5591. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5592. string afterdate1 = GetPostString("afterdate1");
  5593. string afterdate2 = GetPostString("afterdate2");
  5594. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5595. if (afterDate.Length > 0) lw.Add(afterDate);
  5596. string supplier = GetPostString("supplier");
  5597. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5598. string responsible = GetPostString("responsibleman");
  5599. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5600. string customer = GetPostString("customer");
  5601. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5602. string design = GetPostString("design");
  5603. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5604. string afterSaleMemo = GetPostString("afterSaleMemo");
  5605. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5606. string afterMemoType = GetPostString("aftermemotype");
  5607. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5608. string afterresult = GetPostString("afterresult");
  5609. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5610. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5611. string poscode = CurrentUser.UserPost.Post.Code;
  5612. if (poscode != "SysAdmin")
  5613. {
  5614. string shopid = CurrentUser.User.pemShop;
  5615. lw.Add(string.Format("shopId in ({0})", shopid));
  5616. }
  5617. string searchType = GetPostString("searchType");
  5618. if (searchType == "wait")
  5619. {
  5620. lw.Add(string.Format("HandleTime is null"));
  5621. }
  5622. if (searchType == "documentary")
  5623. {
  5624. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5625. }
  5626. if (searchType == "handling")
  5627. {
  5628. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5629. }
  5630. if (searchType == "back" || searchType == "puBack")
  5631. {
  5632. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5633. }
  5634. if (searchType == "reBack")
  5635. {
  5636. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5637. }
  5638. if (afterState.Length <= 0)
  5639. {
  5640. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5641. }
  5642. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5643. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5644. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5645. writeGridDataTableJson(dStruct.TotalCount, dt);
  5646. }
  5647. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5648. //public void get_erp_back_handlingaftersalelist()
  5649. //{
  5650. // DataStruct dStruct = GetPostStruct();
  5651. // List<string> lw = new List<string>();
  5652. // string tid = GetPostString("ctid");
  5653. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5654. // string shopname = GetPostString("shopname");
  5655. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5656. // string buyernick = GetPostString("buyer_nick");
  5657. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5658. // string sellermemo = GetPostString("seller_memo");
  5659. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5660. // string orderState = GetPostString("orderState");
  5661. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5662. // string afterState = GetPostString("afterstate");
  5663. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5664. // string date1 = GetPostString("date1");
  5665. // string date2 = GetPostString("date2");
  5666. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5667. // if (dw.Length > 0) lw.Add(dw);
  5668. // string price1 = GetPostString("price1");
  5669. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5670. // string price2 = GetPostString("price2");
  5671. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5672. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5673. // string reason = GetPostString("reason");
  5674. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5675. // string method = GetPostString("method");
  5676. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5677. // string handler = GetPostString("handler");
  5678. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5679. // string handledate1 = GetPostString("handledate1");
  5680. // string handledate2 = GetPostString("handledate2");
  5681. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5682. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5683. // string afterdate1 = GetPostString("afterdate1");
  5684. // string afterdate2 = GetPostString("afterdate2");
  5685. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5686. // if (afterDate.Length > 0) lw.Add(afterDate);
  5687. // string supplier = GetPostString("supplier");
  5688. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5689. // string responsible = GetPostString("responsibleman");
  5690. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5691. // string customer = GetPostString("customer");
  5692. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5693. // string design = GetPostString("design");
  5694. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5695. // string afterMemoType = GetPostString("aftermemotype");
  5696. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5697. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5698. // if (afterState.Length <= 0)
  5699. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5700. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5701. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5702. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5703. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5704. //}
  5705. public void get_erp_aftersaleverifylist()
  5706. {
  5707. DataStruct dStruct = GetPostStruct();
  5708. List<string> lw = new List<string>();
  5709. string tid = GetPostString("ctid");
  5710. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5711. string shopname = GetPostString("shopname");
  5712. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5713. string buyernick = GetPostString("buyer_nick");
  5714. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5715. string sellermemo = GetPostString("seller_memo");
  5716. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5717. string orderState = GetPostString("orderState");
  5718. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5719. //lw.Add(string.Format("IsRefund!={0}", 1));
  5720. string reason = GetPostString("reason");
  5721. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5722. string method = GetPostString("method");
  5723. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5724. string handler = GetPostString("handler");
  5725. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5726. string handledate1 = GetPostString("handledate1");
  5727. string handledate2 = GetPostString("handledate2");
  5728. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5729. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5730. string finish1 = GetPostString("finishdate1");
  5731. string finish2 = GetPostString("finishdate2");
  5732. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5733. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5734. string supplier = GetPostString("supplier");
  5735. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5736. string responsible = GetPostString("responsibleman");
  5737. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5738. string posCode = CurrentUser.UserPost.Post.Code;
  5739. string vstate = GetPostString("vstate");
  5740. if (vstate.Length > 0)
  5741. {
  5742. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5743. }
  5744. if (posCode == "Supplier")
  5745. {
  5746. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5747. lw.Add(string.Format("VerifyState = 0"));
  5748. lw.Add("type = 1");
  5749. lw.Add(string.Format("AfterSaleState={0}", 3));
  5750. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5751. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5752. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5753. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5754. writeGridDataTableJson(dStruct.TotalCount, dt);
  5755. }
  5756. else if (posCode == "logistics")
  5757. {
  5758. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5759. lw.Add(string.Format("VerifyState = 0"));
  5760. lw.Add("type = 2");
  5761. lw.Add(string.Format("AfterSaleState={0}", 3));
  5762. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5763. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5764. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5765. writeGridDataTableJson(dStruct.TotalCount, dt);
  5766. }
  5767. else
  5768. {
  5769. lw.Add(string.Format("(AfterSaleState = 3)"));
  5770. string reasonState = GetPostString("reasonState");
  5771. lw.Add("type = 0");
  5772. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5773. || posCode == "Summarize" || posCode == "Finance")
  5774. {
  5775. if (reasonState == "2")
  5776. {
  5777. lw.Add("VerifyState = 3");
  5778. }
  5779. else if (reasonState == "1")
  5780. {
  5781. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5782. }
  5783. else
  5784. {
  5785. lw.Add("VerifyState in (0,3)");
  5786. }
  5787. //不加条件,可以看全部
  5788. }
  5789. 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")
  5790. {
  5791. int orgid = CurrentUser.UserPost.OrgID;
  5792. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5793. if (string.IsNullOrEmpty(manageOrgId))
  5794. {
  5795. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5796. }
  5797. else
  5798. {
  5799. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5800. }
  5801. if (reasonState == "1")
  5802. {
  5803. lw.Add("VerifyState = 3");
  5804. }
  5805. else if (reasonState == "2")
  5806. {
  5807. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5808. }
  5809. else
  5810. {
  5811. }
  5812. }
  5813. else
  5814. {
  5815. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5816. }
  5817. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5818. //{
  5819. // int org_id = CurrentUser.UserPost.OrgID;
  5820. // lw.Add(string.Format("OrgID={0}", org_id));
  5821. //}
  5822. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  5823. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5824. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5825. writeGridDataTableJson(dStruct.TotalCount, dt);
  5826. }
  5827. }
  5828. public void get_erp_finishaftersalelist()
  5829. {
  5830. DataStruct dStruct = GetPostStruct();
  5831. List<string> lw = new List<string>();
  5832. int st = 4;
  5833. string tid = GetPostString("ctid");
  5834. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  5835. string shopname = GetPostString("shopname");
  5836. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5837. //lw.Add(string.Format("IsRefund!={0}", 1));
  5838. string reason = GetPostString("reason");
  5839. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5840. string method = GetPostString("method");
  5841. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5842. string buyernick = GetPostString("buyer_nick");
  5843. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5844. string handler = GetPostString("handler");
  5845. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5846. string handledate1 = GetPostString("handledate1");
  5847. string handledate2 = GetPostString("handledate2");
  5848. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5849. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5850. string finish1 = GetPostString("finishdate1");
  5851. string finish2 = GetPostString("finishdate2");
  5852. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5853. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5854. string supplier = GetPostString("supplier");
  5855. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5856. string responsible = GetPostString("responsibleman");
  5857. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5858. string vstate = GetPostString("vstate");
  5859. if (vstate.Length > 0)
  5860. {
  5861. if ("3".Equals(vstate))
  5862. {
  5863. lw.Add(string.Format("IsTem=1"));
  5864. }
  5865. else
  5866. {
  5867. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5868. }
  5869. }
  5870. lw.Add(string.Format("AfterSaleState=4"));
  5871. string code = CurrentUser.UserPost.Post.Code;
  5872. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  5873. {
  5874. //不加条件,可以看全部
  5875. }
  5876. else if (code == "Supplier")
  5877. {
  5878. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5879. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5880. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5881. }
  5882. else if (code == "logistics")
  5883. {
  5884. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  5885. lw.Add("type = 2");
  5886. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5887. }
  5888. 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")
  5889. {
  5890. int orgid = CurrentUser.UserPost.OrgID;
  5891. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  5892. if (string.IsNullOrEmpty(manageOrgIds))
  5893. {
  5894. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  5895. }
  5896. else
  5897. {
  5898. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  5899. }
  5900. }
  5901. else
  5902. {
  5903. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  5904. }
  5905. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5906. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5907. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5908. writeGridDataTableJson(dStruct.TotalCount, dt);
  5909. }
  5910. public void handle_erp_aftersale()
  5911. {
  5912. if (UrlPostParmsCheck("ctid"))
  5913. {
  5914. string eid = GetPostString("ctid");
  5915. string responStr = GetPostString("AfterSaleResponsible");
  5916. if (responStr.Length <= 0)
  5917. {
  5918. returnErrorMsg("售后责任人不能为空");
  5919. return;
  5920. }
  5921. bool isDesign = false;
  5922. double designFree = 0.00;
  5923. int responsibleId = 0;
  5924. CeErpTradeCell entity = null;
  5925. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5926. if (entity != null)
  5927. {
  5928. int isNeedNewOrder = GetPostInt("IsNewOrder");
  5929. string afterMethod = GetPostString("AfterSaleMethod");
  5930. if (isNeedNewOrder == 1)
  5931. {
  5932. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  5933. bool ishav = true;
  5934. if (newentity == null)
  5935. {
  5936. newentity = entity.Clone() as CeErpTradeCell;
  5937. ishav = false;
  5938. newentity.ctid = "S_" + entity.ctid;
  5939. newentity.OrderState = 0;
  5940. }
  5941. //唯一标识
  5942. newentity.OrderSn = newentity.ctid;
  5943. /* string orderSn = dataHelper.getSaleOrderSn();
  5944. if (orderSn != "")
  5945. {
  5946. newentity.OrderSn = orderSn;
  5947. }*/
  5948. newentity.AfterSaleState = 0;
  5949. newentity.AfterSaleMethod = afterMethod;
  5950. if (!ishav)
  5951. {
  5952. string memo_str = newentity.seller_memo;
  5953. memo_str = memo_str.Replace("(", "(");
  5954. memo_str = memo_str.Replace(")", ")");
  5955. int sIndex = memo_str.IndexOf("(");
  5956. int eIndex = memo_str.IndexOf(")");
  5957. if (sIndex == -1 || eIndex == -1)
  5958. {
  5959. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  5960. return;
  5961. }
  5962. string first = memo_str.Substring(0, sIndex + 1);
  5963. string memoCtid = newentity.OrderSn;
  5964. //if (memoCtid.IndexOf("C") != -1)
  5965. //{
  5966. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  5967. //if (CIdx.IndexOf("+") != -1)
  5968. //{
  5969. //CIdx = "C" + CIdx.Split('+')[1];
  5970. //}
  5971. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  5972. //}
  5973. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  5974. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  5975. string newMemo = first + memoCtid + last;
  5976. newentity.seller_memo = newMemo;
  5977. newentity.FinishPlaceTime = null;
  5978. newentity.UnusualTag = 0;
  5979. newentity.UnusualCon = "";
  5980. newentity.UnusualTime = null;
  5981. newentity.AfterSaleMemo = "";
  5982. newentity.AfterSaleMethod = afterMethod;
  5983. newentity.AfterSalePreTime = null;
  5984. newentity.AfterSaleReason = "";
  5985. newentity.AfterSaleResponsible = "";
  5986. newentity.AfterSaleState = 0;
  5987. newentity.AfterSaleTime = null;
  5988. newentity.AfterSaleUserId = 0;
  5989. newentity.AfterSaleSupplierState = 0;
  5990. newentity.LastBillWaybillCode = "";
  5991. newentity.LastBillCpCode = "";
  5992. newentity.FinishAfterSaleTime = null;
  5993. newentity.HandleTime = null;
  5994. newentity.IsSF = 0;
  5995. newentity.IsOldCustomer = 0;
  5996. newentity.UrgencyTime = null;
  5997. newentity.ResponsibleUserId = "";
  5998. newentity.IsVerifyToSupplier = false;
  5999. newentity.payment = 0;
  6000. newentity.CheckMemo = "";
  6001. newentity.OutSid = "";
  6002. newentity.CheckOrderTime = null;
  6003. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6004. }
  6005. newentity.isAfterSaleOrder = 1;
  6006. newentity.IsRefund = 0;
  6007. string receiveMobile = GetPostString("receiver_mobile");
  6008. if (receiveMobile.Length > 0)
  6009. {
  6010. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6011. if (trade != null)
  6012. {
  6013. trade.receiver_name = GetPostString("receiver_name");
  6014. trade.receiver_mobile = receiveMobile;
  6015. trade.receiver_state = GetPostString("receiver_state");
  6016. trade.receiver_city = GetPostString("receiver_city");
  6017. trade.receiver_district = GetPostString("receiver_district");
  6018. trade.receiver_address = GetPostString("receiver_address");
  6019. newentity.IsOffLineOrder = 1;
  6020. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6021. }
  6022. }
  6023. string st = GetPostString("ToState");
  6024. if (st.Length > 0)
  6025. {
  6026. if (newentity.OrderState <= 3)
  6027. {
  6028. newentity.WaitDesignTime = DateTime.Now;
  6029. newentity.StartDesignTime = null;
  6030. newentity.FinishDesignTime = null;
  6031. newentity.OrderState = 3;
  6032. if (st == "下单员")
  6033. {
  6034. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6035. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6036. {
  6037. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6038. }
  6039. }
  6040. else
  6041. {
  6042. newentity.WaitDesignTime = DateTime.Now;
  6043. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6044. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6045. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6046. {
  6047. DataRow user = dt1.Rows[0];
  6048. //找主管
  6049. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6050. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6051. if (dt != null && dt.Rows.Count > 0)
  6052. {
  6053. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6054. newentity.DesignUserId = designMr;
  6055. string key = "aftersale_order_" + designMr;
  6056. if (RedisHelper.HasKey(key))
  6057. {
  6058. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6059. list.Add(newentity.ctid);
  6060. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6061. }
  6062. }
  6063. //账号正常
  6064. if (user["State"].ToString() == "0")
  6065. {
  6066. newentity.DesignUserId = entity.DesignUserId;
  6067. string key = "aftersale_order_" + entity.DesignUserId;
  6068. if (RedisHelper.HasKey(key))
  6069. {
  6070. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6071. list.Add(newentity.ctid);
  6072. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6073. }
  6074. }
  6075. }
  6076. }
  6077. }
  6078. if (entity.IsXianHuo == 1)
  6079. {
  6080. newentity.OrderState = 6;
  6081. entity.FinishPlaceTime = DateTime.Now;
  6082. }
  6083. }
  6084. if (ishav)
  6085. {
  6086. newentity.Update();
  6087. }
  6088. else
  6089. {
  6090. newentity.Create();
  6091. CeErpTradeCellExtend.createInfo(newentity.ctid, 30, 20);
  6092. }
  6093. if (st != "下单员")
  6094. {
  6095. designHelper.API_GetPrintData_CreateOrder(newentity);
  6096. }
  6097. }
  6098. //处理售后扩展
  6099. string resIdStr = GetPostString("ResponsibleUserId");
  6100. string refundFees = GetPostString("refundFrees");
  6101. int IsComplain = GetPostInt("isComplain");
  6102. int IsBad = GetPostInt("isBad");
  6103. string IsOriginal = GetPostString("isOriginal");
  6104. double diffResultPrice = GetPostDouble("diffResultPrice");
  6105. string textResult = GetPostString("textResult");
  6106. string supplierResponsible = GetPostString("supplierResponsible");
  6107. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6108. if (ceErpTradeAfterSaleExtend == null)
  6109. {
  6110. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6111. ceErpTradeAfterSaleExtend.tid = eid;
  6112. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6113. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6114. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6115. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6116. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6117. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6118. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6119. ceErpTradeAfterSaleExtend.Create();
  6120. }
  6121. else
  6122. {
  6123. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6124. {
  6125. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6126. }
  6127. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6128. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6129. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6130. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6131. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6132. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6133. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6134. ceErpTradeAfterSaleExtend.Update();
  6135. }
  6136. int gysid = GetPostInt("ResponsibleSupId");
  6137. entity.AfterSaleUserId = CurrentUser.UserID;
  6138. entity.ResponsibleUserId = resIdStr;
  6139. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6140. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6141. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6142. {
  6143. CeErpTradeResponsible.DelByTid(eid, -1);
  6144. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6145. int backNum = 0;
  6146. if (number != null)
  6147. {
  6148. backNum = number.BackNum;
  6149. }
  6150. char[] separator = { ',' };
  6151. string[] sArray = resIdStr.Split(separator);
  6152. string[] refundFreeList = { };
  6153. if (refundFees.Length > 0)
  6154. {
  6155. refundFreeList = refundFees.Split(separator);
  6156. }
  6157. int index = -1;
  6158. foreach (string i in sArray)
  6159. {
  6160. index++;
  6161. if (i.Length <= 0) continue;
  6162. char[] separator2 = { '_' };
  6163. string idstr = i.Split(separator2)[0];
  6164. string idtype = i.Split(separator2)[1];
  6165. double refudFree = 0;
  6166. if (refundFreeList.Length > 0)
  6167. {
  6168. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6169. }
  6170. if (idtype == "s")
  6171. {
  6172. isDesign = true;
  6173. designFree = refudFree;
  6174. }
  6175. int userId = Convert.ToInt32(idstr);
  6176. int type = 0;
  6177. if (idtype == "g")
  6178. {
  6179. type = 1;
  6180. }
  6181. if (idtype == "w")
  6182. {
  6183. type = 2;
  6184. }
  6185. if (idtype == "t")
  6186. {
  6187. type = 3;
  6188. }
  6189. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6190. if (ceErpTradeResponsible == null)
  6191. {
  6192. ceErpTradeResponsible = new CeErpTradeResponsible();
  6193. ceErpTradeResponsible.tid = eid;
  6194. ceErpTradeResponsible.UserId = userId;
  6195. ceErpTradeResponsible.createdTime = DateTime.Now;
  6196. ceErpTradeResponsible.type = type;
  6197. if (type == 1)
  6198. {
  6199. ceErpTradeResponsible.IsSup = 1;
  6200. }
  6201. if (type == 2)
  6202. {
  6203. ceErpTradeResponsible.IsFlow = 1;
  6204. }
  6205. }
  6206. ceErpTradeResponsible.RefundFee = refudFree;
  6207. ceErpTradeResponsible.VerifyState = 0;
  6208. if (userId == 2125 || idtype == "w")
  6209. {
  6210. ceErpTradeResponsible.VerifyState = 1;
  6211. }
  6212. if (idtype == "w" && userId == 101)
  6213. {
  6214. ceErpTradeResponsible.VerifyState = 0;
  6215. }
  6216. if (ceErpTradeResponsible.ID > 0)
  6217. {
  6218. ceErpTradeResponsible.Update();
  6219. }
  6220. else
  6221. {
  6222. ceErpTradeResponsible.Create();
  6223. }
  6224. if (isDesign)
  6225. {
  6226. responsibleId = ceErpTradeResponsible.ID;
  6227. }
  6228. }
  6229. CeErpTradeResponsible.NumByTid(backNum, eid);
  6230. }
  6231. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6232. if (ceErpTradeCellExtend != null)
  6233. {
  6234. ceErpTradeCellExtend.returnVisit = 0;
  6235. ceErpTradeCellExtend.Update();
  6236. }
  6237. if (entity.HandleTime != null)
  6238. {
  6239. if (entity.AfterSaleState == 1)
  6240. {
  6241. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6242. }
  6243. else
  6244. {
  6245. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6246. }
  6247. }
  6248. else
  6249. {
  6250. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6251. entity.HandleTime = DateTime.Now;
  6252. }
  6253. bool isCompale = false;
  6254. if (entity.AfterSaleState == 5)
  6255. {
  6256. isCompale = true;
  6257. entity.AfterSaleState = 3;
  6258. }
  6259. entity.AfterSaleSupplierState = 0;
  6260. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6261. {
  6262. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6263. }
  6264. string sImgs = GetPostString("img");
  6265. entity.AfterSaleSupplierImg = sImgs;
  6266. entity.supRefundType = GetPostString("supRefundType");
  6267. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6268. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6269. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6270. entity.AfterSaleMemoType = GetPostString("MemoType");
  6271. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6272. {
  6273. //entity.AfterSaleSupplierState = 2;
  6274. }
  6275. string df = GetPostString("DeductFee");
  6276. if (df == "")
  6277. {
  6278. df = "0";
  6279. }
  6280. string rf = GetPostString("RefundFee");
  6281. if (rf == "")
  6282. {
  6283. rf = "0";
  6284. }
  6285. string pm = GetPostString("AfterSalePayment");
  6286. if (pm == "")
  6287. {
  6288. pm = "0";
  6289. }
  6290. entity.AfterSalePayment = Convert.ToDouble(pm);
  6291. entity.DeductFee = Convert.ToDouble(df);
  6292. entity.RefundFee = Convert.ToDouble(rf);
  6293. entity.Update();
  6294. string toState = GetPostString("ToState");
  6295. string original = GetPostString("isOriginal");
  6296. ApiVo apiVo = new ApiVo();
  6297. apiVo.orderNumber = entity.ctid;
  6298. apiVo.actionName = "afterDesign";
  6299. apiVo.orderRemarks = entity.AfterSaleMethod;
  6300. apiVo.reasonRemarks = entity.AfterSaleReason;
  6301. apiVo.isDesign = isDesign;
  6302. apiVo.designFree = designFree;
  6303. apiVo.responsibleId = responsibleId;
  6304. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6305. if (toState == "设计师")
  6306. {
  6307. apiVo.isOriginal = Convert.ToBoolean(original);
  6308. }
  6309. designHelper.API_WorkCore(apiVo);//afterDesign
  6310. CeErpMethod methodSql = new CeErpMethod();
  6311. methodSql.con = entity.AfterSaleMethod;
  6312. methodSql.addTime = DateTime.Now;
  6313. methodSql.Create();
  6314. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6315. CeErpMethod.ExecuteNonQuery(delsql);
  6316. if (isCompale)
  6317. {
  6318. aftersale_data_change(entity.ctid);
  6319. }
  6320. returnSuccessMsg("操作成功!");
  6321. return;
  6322. }
  6323. returnErrorMsg("找不到订单记录");
  6324. }
  6325. }
  6326. public void ins_erp_toresponsible()
  6327. {
  6328. if (UrlPostParmsCheck("ctid"))
  6329. {
  6330. string eid = GetPostString("ctid");
  6331. CeErpTradeCell entity = null;
  6332. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6333. if (entity != null)
  6334. {
  6335. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6336. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6337. {
  6338. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6339. return;
  6340. }
  6341. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6342. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6343. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6344. entity.AfterSalePreTime = DateTime.Now;
  6345. //预完成给售后主管审核客户问题直接完成
  6346. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6347. {
  6348. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) == 0)
  6349. {
  6350. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6351. }
  6352. }
  6353. entity.AfterSaleState = 2;
  6354. entity.Update();
  6355. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6356. aftersale_data_change(entity.ctid);
  6357. returnSuccessMsg("操作成功!");
  6358. return;
  6359. }
  6360. returnErrorMsg("找不到订单记录");
  6361. }
  6362. }
  6363. public void cancel_erp_aftersaleanddelnew()
  6364. {
  6365. if (UrlPostParmsCheck("ctid"))
  6366. {
  6367. string eid = GetPostString("ctid");
  6368. CeErpTradeCell entity = null;
  6369. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6370. if (entity != null)
  6371. {
  6372. entity.AfterSaleState = 0;
  6373. entity.AfterSaleReason = "";
  6374. entity.AfterSaleMethod = "";
  6375. entity.AfterSaleMemo = "";
  6376. entity.AfterSaleResponsible = "";
  6377. entity.ResponsibleUserId = "";
  6378. entity.DeductFee = 0;
  6379. entity.RefundFee = 0;
  6380. entity.IsArbitrate = 0;
  6381. CeErpTradeResponsible.DelByTid(eid, -1);
  6382. entity.Update();
  6383. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6384. if (after != null)
  6385. {
  6386. if (after.OrderState < 5)
  6387. CeErpTradeCell.DelByCtid("S_" + eid);
  6388. }
  6389. returnSuccessMsg("操作成功!");
  6390. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6391. return;
  6392. }
  6393. returnErrorMsg("找不到订单记录");
  6394. }
  6395. }
  6396. public void get_erp_aftersale_pregather()
  6397. {
  6398. List<string> lw = new List<string>();
  6399. int st = GetInt("st");
  6400. string tid = GetPostString("ctid");
  6401. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or orderSn = '{0}')", tid));
  6402. string shopname = GetPostString("shopname");
  6403. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6404. string buyernick = GetPostString("buyer_nick");
  6405. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6406. string sellermemo = GetPostString("seller_memo");
  6407. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6408. string orderState = GetPostString("orderState");
  6409. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6410. string reason = GetPostString("reason");
  6411. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6412. string method = GetPostString("method");
  6413. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6414. string handler = GetPostString("handler");
  6415. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6416. string handledate1 = GetPostString("handledate1");
  6417. string handledate2 = GetPostString("handledate2");
  6418. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6419. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6420. string supplier = GetPostString("supplier");
  6421. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6422. string responsible = GetPostString("responsibleman");
  6423. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6424. string customer = GetPostString("customer");
  6425. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6426. string design = GetPostString("design");
  6427. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6428. string afterMemoType = GetPostString("aftermemotype");
  6429. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6430. string afterSaleMemo = GetPostString("afterSaleMemo");
  6431. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6432. string afterresult = GetPostString("afterresult");
  6433. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6434. string poscode = CurrentUser.UserPost.Post.Code;
  6435. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6436. {
  6437. string shopid = CurrentUser.User.pemShop;
  6438. lw.Add(string.Format("shopId in ({0})", shopid));
  6439. }
  6440. var mainwhere = string.Join(" and ", lw.ToArray());
  6441. string ro_json = "";
  6442. string type = GetPostString("gather_type");
  6443. if (poscode == "AfterSale")
  6444. {
  6445. //处理中
  6446. if (type == "Handling")
  6447. {
  6448. 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) : ""));
  6449. DataTable dt = null;
  6450. try
  6451. {
  6452. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6453. }
  6454. catch (Exception e)
  6455. {
  6456. dt = new DataTable();
  6457. }
  6458. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6459. return;
  6460. }
  6461. if (type == "Wait")
  6462. {
  6463. //待处理
  6464. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6465. DataTable dt1 = null;
  6466. try
  6467. {
  6468. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6469. }
  6470. catch (Exception e)
  6471. {
  6472. dt1 = new DataTable();
  6473. }
  6474. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6475. return;
  6476. }
  6477. if (type == "back")
  6478. {
  6479. //打回
  6480. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6481. DataTable dt2 = null;
  6482. try
  6483. {
  6484. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6485. }
  6486. catch (Exception e)
  6487. {
  6488. dt2 = new DataTable();
  6489. }
  6490. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6491. return;
  6492. }
  6493. if (type == "preCompletion")
  6494. {
  6495. //预完成
  6496. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6497. DataTable dt3 = null;
  6498. try
  6499. {
  6500. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6501. }
  6502. catch (Exception e)
  6503. {
  6504. dt3 = new DataTable();
  6505. }
  6506. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6507. return;
  6508. }
  6509. if (type == "documentary")
  6510. {
  6511. //跟单中
  6512. 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) : ""));
  6513. DataTable dt4 = null;
  6514. try
  6515. {
  6516. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6517. }
  6518. catch (Exception e)
  6519. {
  6520. dt4 = new DataTable();
  6521. }
  6522. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6523. return;
  6524. }
  6525. if (type == "reBack")
  6526. {
  6527. //被打回
  6528. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6529. DataTable dt1 = null;
  6530. try
  6531. {
  6532. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6533. }
  6534. catch (Exception e)
  6535. {
  6536. dt1 = new DataTable();
  6537. }
  6538. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6539. return;
  6540. }
  6541. }
  6542. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6543. {
  6544. if (type == "puBack")
  6545. {
  6546. //退回
  6547. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6548. DataTable dt = null;
  6549. try
  6550. {
  6551. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6552. }
  6553. catch (Exception e)
  6554. {
  6555. dt = new DataTable();
  6556. }
  6557. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6558. return;
  6559. }
  6560. if (type == "reBack")
  6561. {
  6562. //打回
  6563. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6564. DataTable dt1 = null;
  6565. try
  6566. {
  6567. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6568. }
  6569. catch (Exception e)
  6570. {
  6571. dt1 = new DataTable();
  6572. }
  6573. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6574. return;
  6575. }
  6576. if (type == "examEd")
  6577. {
  6578. //已审核
  6579. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6580. DataTable dt2 = null;
  6581. try
  6582. {
  6583. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6584. }
  6585. catch (Exception e)
  6586. {
  6587. dt2 = new DataTable();
  6588. }
  6589. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6590. return;
  6591. }
  6592. if (type == "waitExam")
  6593. {
  6594. //待审核
  6595. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6596. DataTable dt3 = null;
  6597. try
  6598. {
  6599. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6600. }
  6601. catch (Exception e)
  6602. {
  6603. dt3 = new DataTable();
  6604. }
  6605. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6606. return;
  6607. }
  6608. if (type == "Handling")
  6609. {
  6610. //处理中
  6611. 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) : ""));
  6612. DataTable dt4 = null;
  6613. try
  6614. {
  6615. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6616. }
  6617. catch (Exception e)
  6618. {
  6619. dt4 = new DataTable();
  6620. }
  6621. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6622. return;
  6623. }
  6624. if (type == "Wait")
  6625. {
  6626. //待处理
  6627. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6628. DataTable dt5 = null;
  6629. try
  6630. {
  6631. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6632. }
  6633. catch (Exception e)
  6634. {
  6635. dt5 = new DataTable();
  6636. }
  6637. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6638. return;
  6639. }
  6640. if (type == "documentary")
  6641. {
  6642. //跟单中
  6643. 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) : ""));
  6644. DataTable dt6 = null;
  6645. try
  6646. {
  6647. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6648. }
  6649. catch (Exception e)
  6650. {
  6651. dt6 = new DataTable();
  6652. }
  6653. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6654. return;
  6655. }
  6656. }
  6657. returnSuccess(ro_json);
  6658. }
  6659. public void end_erp_aftersale()
  6660. {
  6661. if (UrlPostParmsCheck("ctid"))
  6662. {
  6663. string eid = GetPostString("ctid");
  6664. CeErpTradeCell entity = null;
  6665. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6666. if (entity != null)
  6667. {
  6668. string stype = GetPostString("stype");
  6669. string typeStr = stype;
  6670. entity.AfterSaleState = 4;
  6671. entity.FinishAfterSaleTime = DateTime.Now;
  6672. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6673. entity.Update();
  6674. ApiVo apiVo = new ApiVo();
  6675. apiVo.orderNumber = entity.ctid;
  6676. apiVo.actionName = "afterOver";
  6677. designHelper.API_WorkCore(apiVo); //afterOver
  6678. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6679. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6680. CeErpSukuraData.createInfo(entity.ctid, 8);
  6681. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6682. returnSuccessMsg("操作成功!");
  6683. return;
  6684. }
  6685. returnErrorMsg("找不到订单记录");
  6686. }
  6687. }
  6688. public void ins_erp_finishaftersale()
  6689. {
  6690. if (UrlPostParmsCheck("id"))
  6691. {
  6692. string eid = GetPostString("id");
  6693. CeErpTradeResponsible entity = null;
  6694. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6695. if (entity != null)
  6696. {
  6697. entity.VerifyState = 1;
  6698. entity.VerifyTime = DateTime.Now;
  6699. entity.Update();
  6700. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6701. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6702. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6703. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6704. if (dt.Rows.Count <= 0)
  6705. {
  6706. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6707. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6708. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6709. CeErpSukuraData.createInfo(entity.tid, 8);
  6710. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6711. {
  6712. CeErpDesignerBill.Del(entity.tid);
  6713. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6714. }
  6715. }
  6716. returnSuccessMsg("操作成功!");
  6717. return;
  6718. }
  6719. returnErrorMsg("找不到订单记录");
  6720. }
  6721. }
  6722. public void upd_erp_arbitrateaftersale()
  6723. {
  6724. if (UrlPostParmsCheck("id"))
  6725. {
  6726. string eid = GetPostString("id");
  6727. CeErpTradeResponsible entity = null;
  6728. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6729. if (entity != null)
  6730. {
  6731. entity.IsArbitrate = 1;
  6732. entity.ArbitradeMemo = GetPostString("reason");
  6733. entity.VerifyState = 2;
  6734. entity.Update();
  6735. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6736. if (tradecell != null)
  6737. {
  6738. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6739. tradecell.IsArbitrate = 1;
  6740. tradecell.Update();
  6741. }
  6742. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6743. returnSuccessMsg("操作成功!");
  6744. return;
  6745. }
  6746. returnErrorMsg("找不到订单记录");
  6747. }
  6748. }
  6749. public void upd_erp_backaftersale()
  6750. {
  6751. if (UrlPostParmsCheck("tid"))
  6752. {
  6753. string eid = GetPostString("tid");
  6754. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6755. int backNum = 0;
  6756. if (number != null)
  6757. {
  6758. backNum = number.BackNum;
  6759. }
  6760. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6761. CeErpTradeCell entity = null;
  6762. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6763. if (entity != null)
  6764. {
  6765. entity.AfterSaleBackReason = GetPostString("backreason");
  6766. entity.AfterSaleState = 1;
  6767. entity.AfterSaleSupplierState = 0;
  6768. entity.Update();
  6769. returnSuccessMsg("操作成功!");
  6770. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6771. return;
  6772. }
  6773. returnErrorMsg("找不到订单记录");
  6774. }
  6775. }
  6776. public void get_erp_supplieraftersalelist()
  6777. {
  6778. DataStruct dStruct = GetPostStruct();
  6779. List<string> lw = new List<string>();
  6780. string tid = GetPostString("ctid");
  6781. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6782. string shopname = GetPostString("shopname");
  6783. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6784. string buyernick = GetPostString("buyer_nick");
  6785. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6786. string sellermemo = GetPostString("seller_memo");
  6787. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6788. string orderState = GetPostString("orderState");
  6789. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6790. string afterState = GetPostString("afterstate");
  6791. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6792. string date1 = GetPostString("date1");
  6793. string date2 = GetPostString("date2");
  6794. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6795. if (dw.Length > 0) lw.Add(dw);
  6796. string price1 = GetPostString("price1");
  6797. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6798. string price2 = GetPostString("price2");
  6799. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6800. string reason = GetPostString("reason");
  6801. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6802. string method = GetPostString("method");
  6803. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6804. string handledate1 = GetPostString("handledate1");
  6805. string handledate2 = GetPostString("handledate2");
  6806. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6807. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6808. string handler = GetPostString("handler");
  6809. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6810. string afterdate1 = GetPostString("afterdate1");
  6811. string afterdate2 = GetPostString("afterdate2");
  6812. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6813. if (afterDate.Length > 0) lw.Add(afterDate);
  6814. string customer = GetPostString("customer");
  6815. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6816. string design = GetPostString("design");
  6817. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6818. string afterMemoType = GetPostString("aftermemotype");
  6819. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6820. string vstate = GetPostString("vstate");
  6821. if (vstate.Length > 0)
  6822. {
  6823. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6824. }
  6825. lw.Add(string.Format("AfterSaleState>={0}", 2));
  6826. string supplier = GetPostString("supplier");
  6827. int supid = commonHelper.getSupplierIDByName(supplier);
  6828. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  6829. string posCode = CurrentUser.UserPost.Post.Code;
  6830. if (posCode == "Supplier")
  6831. {
  6832. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6833. }
  6834. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  6835. {
  6836. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  6837. }
  6838. else
  6839. {
  6840. lw.Add(string.Format("AfterSaleResSupId != 0"));
  6841. }
  6842. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6843. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6844. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6845. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6846. writeGridDataTableJson(dStruct.TotalCount, dt);
  6847. }
  6848. public void upd_erp_supverifyaftersale()
  6849. {
  6850. if (UrlPostParmsCheck("id"))
  6851. {
  6852. string id = GetPostString("id");
  6853. int st = GetPostInt("afterstate");
  6854. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6855. CeErpTradeCell entity = null;
  6856. if (ceErpTradeResponsible != null)
  6857. {
  6858. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6859. }
  6860. string afmemo = GetPostString("supmemo");
  6861. string image = GetPostString("image");
  6862. if (entity != null)
  6863. {
  6864. entity.AfterSaleSupplierState = st;
  6865. entity.AfterSaleSupplierMemo = afmemo;
  6866. if (st == 1)
  6867. {
  6868. ceErpTradeResponsible.VerifyState = 1;
  6869. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6870. ceErpTradeResponsible.Update();
  6871. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6872. if (isAll)
  6873. {
  6874. entity.AfterSaleState = 4;
  6875. entity.FinishAfterSaleTime = DateTime.Now;
  6876. }
  6877. }
  6878. else
  6879. {
  6880. CeErpTradeResponsible.dateByTid(entity.ctid);
  6881. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6882. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6883. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6884. if (num <= 1)
  6885. {
  6886. entity.AfterSaleState = 1;
  6887. }
  6888. else
  6889. {
  6890. entity.AfterSaleState = 5;
  6891. }
  6892. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6893. if (ceErpTradeAfterSaleExtend != null)
  6894. {
  6895. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6896. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6897. ceErpTradeAfterSaleExtend.Update();
  6898. }
  6899. else
  6900. {
  6901. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6902. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6903. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6904. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6905. ceErpTradeAfterSaleExtend.Create();
  6906. }
  6907. }
  6908. if (entity.AfterSaleState == 4)
  6909. {
  6910. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6911. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  6912. {
  6913. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6914. }
  6915. ApiVo apiVo = new ApiVo();
  6916. apiVo.orderNumber = entity.ctid;
  6917. apiVo.actionName = "afterOver";
  6918. designHelper.API_WorkCore(apiVo); //afterOver
  6919. }
  6920. entity.Update();
  6921. returnSuccessMsg("操作成功!");
  6922. CeErpSukuraData.createInfo(entity.ctid, 8);
  6923. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6924. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6925. return;
  6926. }
  6927. returnErrorMsg("找不到订单记录");
  6928. }
  6929. }
  6930. public void upd_erp_masteraftersale()
  6931. {
  6932. if (UrlPostParmsCheck("id"))
  6933. {
  6934. string id = GetPostString("id");
  6935. int st = GetPostInt("afterstate");
  6936. string afmemo = GetPostString("supmemo");
  6937. string image = GetPostString("image");
  6938. string textResult = GetPostString("textResult");
  6939. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6940. if (ceErpTradeResponsible != null)
  6941. {
  6942. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  6943. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6944. ceErpTradeResponsible.Update();
  6945. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6946. if (entity != null)
  6947. {
  6948. entity.AfterSaleSupplierState = st;
  6949. entity.AfterSaleSupplierMemo = afmemo;
  6950. if (st == 1)
  6951. {
  6952. }
  6953. else
  6954. {
  6955. CeErpTradeResponsible.dateByTid(entity.ctid);
  6956. //退回到售后
  6957. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6958. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6959. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6960. if (num <= 1)
  6961. {
  6962. entity.AfterSaleState = 1;
  6963. }
  6964. else
  6965. {
  6966. entity.AfterSaleState = 5;
  6967. }
  6968. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6969. if (ceErpTradeAfterSaleExtend != null)
  6970. {
  6971. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6972. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6973. ceErpTradeAfterSaleExtend.Update();
  6974. }
  6975. else
  6976. {
  6977. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6978. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6979. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6980. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6981. ceErpTradeAfterSaleExtend.Create();
  6982. }
  6983. }
  6984. entity.Update();
  6985. returnSuccessMsg("操作成功!");
  6986. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6987. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6988. return;
  6989. }
  6990. }
  6991. returnErrorMsg("找不到订单记录");
  6992. }
  6993. }
  6994. public void upd_erp_personaftersale()
  6995. {
  6996. if (UrlPostParmsCheck("id"))
  6997. {
  6998. string id = GetPostString("id");
  6999. int st = GetPostInt("afterstate");
  7000. string afmemo = GetPostString("supmemo");
  7001. string image = GetPostString("image");
  7002. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7003. if (ceErpTradeResponsible != null)
  7004. {
  7005. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7006. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7007. ceErpTradeResponsible.Update();
  7008. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7009. if (entity != null)
  7010. {
  7011. entity.AfterSaleSupplierMemo = afmemo;
  7012. entity.AfterSaleSupplierState = st;
  7013. if (st == 1)
  7014. {
  7015. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7016. if (isAll)
  7017. {
  7018. entity.AfterSaleState = 4;
  7019. entity.FinishAfterSaleTime = DateTime.Now;
  7020. }
  7021. }
  7022. else
  7023. {
  7024. CeErpTradeResponsible.dateByTid(entity.ctid);
  7025. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7026. if (ceErpTradeAfterSaleExtend != null)
  7027. {
  7028. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7029. ceErpTradeAfterSaleExtend.Update();
  7030. }
  7031. else
  7032. {
  7033. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7034. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7035. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7036. ceErpTradeAfterSaleExtend.Create();
  7037. }
  7038. //退回到主管
  7039. //entity.AfterSaleState = 2;
  7040. }
  7041. if (entity.AfterSaleState == 4)
  7042. {
  7043. ApiVo apiVo = new ApiVo();
  7044. apiVo.orderNumber = entity.ctid;
  7045. apiVo.actionName = "afterOver";
  7046. designHelper.API_WorkCore(apiVo); //afterOver
  7047. }
  7048. entity.Update();
  7049. returnSuccessMsg("操作成功!");
  7050. CeErpSukuraData.createInfo(entity.ctid, 8);
  7051. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7052. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7053. return;
  7054. }
  7055. }
  7056. returnErrorMsg("找不到订单记录");
  7057. }
  7058. }
  7059. public void set_erp_supplierrefundtag()
  7060. {
  7061. if (UrlPostParmsCheck("ctid"))
  7062. {
  7063. string eid = GetPostString("ctid");
  7064. CeErpTradeCell entity = null;
  7065. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7066. if (entity != null)
  7067. {
  7068. entity.IsSupplierRefund = GetPostInt("tag");
  7069. entity.Update();
  7070. returnSuccessMsg("操作成功!");
  7071. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7072. return;
  7073. }
  7074. returnErrorMsg("找不到订单记录");
  7075. }
  7076. }
  7077. public void get_erp_refundlist()
  7078. {
  7079. DataStruct dStruct = GetPostStruct();
  7080. List<string> lw = new List<string>();
  7081. string tid = GetPostString("tid");
  7082. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7083. //string rid = GetPostString("refund_id");
  7084. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7085. string shopname = GetPostString("shopname");
  7086. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7087. string buyernick = GetPostString("buyer_nick");
  7088. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7089. string customer = GetPostString("customer");
  7090. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7091. string design = GetPostString("design");
  7092. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7093. string sellermemo = GetPostString("seller_memo");
  7094. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7095. //string date1 = GetPostString("date1");
  7096. //string date2 = GetPostString("date2");
  7097. //string dateType = GetPostString("dateType");
  7098. //if (dateType.Length > 0)
  7099. //{
  7100. // if (dateType == "1001") dateType = "0";
  7101. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7102. // if (searchDT.Count == 2)
  7103. // {
  7104. // date1 = searchDT[0].ToString();
  7105. // date2 = searchDT[1].ToString();
  7106. // }
  7107. //}
  7108. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7109. //if (dw.Length > 0) lw.Add(dw);
  7110. string redate1 = GetPostString("refunddate1");
  7111. string redate2 = GetPostString("refunddate2");
  7112. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7113. if (dwdate.Length > 0) lw.Add(dwdate);
  7114. string price1 = GetPostString("price1");
  7115. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7116. string price2 = GetPostString("price2");
  7117. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7118. string ispartrefund = GetPostString("ispartrefund");
  7119. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7120. string refundState = GetPostString("refundvstate");
  7121. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7122. int st = GetInt("st");
  7123. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7124. {
  7125. string responsible = GetPostString("responsibleman");
  7126. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7127. lw.Add(string.Format("RefundState>={0}", st));
  7128. string code = CurrentUser.UserPost.Post.Code;
  7129. if (code == "CustomerService")
  7130. {
  7131. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7132. }
  7133. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7134. {
  7135. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7136. }
  7137. else if (code == "Place" || code == "PlaceMr")
  7138. {
  7139. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7140. }
  7141. dStruct.Order = "RefundState asc,created desc";
  7142. }
  7143. else if (st == 10)
  7144. {
  7145. string responsible = GetPostString("responsibleman");
  7146. if (responsible == "空白")
  7147. {
  7148. lw.Add(string.Format("ResponsibleUserName = ''"));
  7149. }
  7150. else if (responsible.Length > 0)
  7151. {
  7152. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7153. }
  7154. lw.Add(string.Format("RefundState>=0"));
  7155. dStruct.Order = "created desc";
  7156. }
  7157. else
  7158. {
  7159. string responsible = GetPostString("responsibleman");
  7160. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7161. lw.Add(string.Format("RefundState={0}", st));
  7162. dStruct.Order = "created desc";
  7163. }
  7164. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7165. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7166. dt.Columns.Add("refund_fees");
  7167. foreach (DataRow dr in dt.Rows)
  7168. {
  7169. String status = dr["status"].ToString();
  7170. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7171. {
  7172. dr["refund_fees"] = dr["refund_fee"];
  7173. }
  7174. else
  7175. {
  7176. dr["refund_fees"] = "0.0";
  7177. }
  7178. }
  7179. writeGridDataTableJson(dStruct.TotalCount, dt);
  7180. }
  7181. public void get_erp_refunddesignlist()
  7182. {
  7183. DataStruct dStruct = GetPostStruct();
  7184. List<string> lw = new List<string>();
  7185. string tid = GetPostString("tid");
  7186. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7187. string shopname = GetPostString("shopname");
  7188. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7189. string buyernick = GetPostString("buyer_nick");
  7190. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7191. string customer = GetPostString("customer");
  7192. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7193. string design = GetPostString("design");
  7194. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7195. string sellermemo = GetPostString("seller_memo");
  7196. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7197. string redate1 = GetPostString("refunddate1");
  7198. string redate2 = GetPostString("refunddate2");
  7199. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7200. if (dwdate.Length > 0) lw.Add(dwdate);
  7201. string price1 = GetPostString("price1");
  7202. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7203. string price2 = GetPostString("price2");
  7204. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7205. string ispartrefund = GetPostString("ispartrefund");
  7206. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7207. string designerorg = GetPostString("designerorg");
  7208. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7209. string refundState = GetPostString("refundState");
  7210. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7211. int myOrgid = CurrentUser.UserPost.OrgID;
  7212. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7213. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7214. {
  7215. if (CurrentUser.User.TeamIds.Length > 0)
  7216. {
  7217. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7218. }
  7219. else
  7220. {
  7221. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7222. }
  7223. }
  7224. else if ("SysAdmin".Equals(myOrgCode))
  7225. {
  7226. }
  7227. else
  7228. {
  7229. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7230. {
  7231. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7232. }
  7233. else
  7234. {
  7235. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7236. }
  7237. }
  7238. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7239. dStruct.Order = "created desc";
  7240. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7241. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7242. dt.Columns.Add("refund_fees");
  7243. foreach (DataRow dr in dt.Rows)
  7244. {
  7245. String status = dr["status"].ToString();
  7246. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7247. {
  7248. dr["refund_fees"] = dr["refund_fee"];
  7249. }
  7250. else
  7251. {
  7252. dr["refund_fees"] = "0.0";
  7253. }
  7254. }
  7255. writeGridDataTableJson(dStruct.TotalCount, dt);
  7256. }
  7257. public void handle_erp_refundtag()
  7258. {
  7259. if (UrlPostParmsCheck("refund_id"))
  7260. {
  7261. string eid = GetPostString("refund_id");
  7262. string respMan = GetPostString("ResponsibleName");
  7263. if (respMan.Length <= 0)
  7264. {
  7265. returnErrorMsg("责任人不能为空");
  7266. return;
  7267. }
  7268. CeErpTradeRefund entity = null;
  7269. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7270. if (entity != null)
  7271. {
  7272. entity.ResponsibleUserName = respMan;
  7273. string userid = GetPostString("ResponsibleUserId");
  7274. if (userid.Length > 0)
  7275. {
  7276. entity.ResponsibleUserId = userid;
  7277. }
  7278. entity.Memo = GetPostString("Memo");
  7279. if (respMan.IndexOf("客服") != -1 ||
  7280. respMan.IndexOf("设计师") != -1 ||
  7281. respMan.IndexOf("下单员") != -1)
  7282. {
  7283. entity.RefundState = 2;
  7284. }
  7285. else
  7286. {
  7287. entity.RefundState = 3;
  7288. }
  7289. entity.modified = DateTime.Now;
  7290. entity.Update();
  7291. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7292. returnSuccessMsg("操作成功!");
  7293. return;
  7294. }
  7295. returnErrorMsg("找不到订单记录");
  7296. }
  7297. }
  7298. public void handle_erp_designrefundtag()
  7299. {
  7300. if (UrlPostParmsCheck("refund_id"))
  7301. {
  7302. string eid = GetPostString("refund_id");
  7303. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7304. if (ceErpTradeCellExtend == null)
  7305. {
  7306. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7307. ceErpTradeCellExtend.ctid = eid;
  7308. }
  7309. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7310. if (ceErpTradeCellExtend.ID > 0)
  7311. {
  7312. ceErpTradeCellExtend.Update();
  7313. }
  7314. else
  7315. {
  7316. ceErpTradeCellExtend.Create();
  7317. }
  7318. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7319. returnSuccessMsg("操作成功!");
  7320. return;
  7321. }
  7322. returnErrorMsg("找不到订单记录");
  7323. }
  7324. public void upd_erp_refundverify()
  7325. {
  7326. if (UrlPostParmsCheck("refund_id"))
  7327. {
  7328. string eid = GetPostString("refund_id");
  7329. CeErpTradeRefund entity = null;
  7330. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7331. if (entity != null)
  7332. {
  7333. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7334. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7335. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7336. {
  7337. entity.RefundState = 2;
  7338. }
  7339. else
  7340. {
  7341. entity.RefundState = 3;
  7342. }
  7343. entity.Update();
  7344. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7345. returnSuccessMsg("操作成功!");
  7346. return;
  7347. }
  7348. returnErrorMsg("找不到订单记录");
  7349. }
  7350. }
  7351. public void upd_erp_refundapprove()
  7352. {
  7353. if (UrlPostParmsCheck("refund_id"))
  7354. {
  7355. string eid = GetPostString("refund_id");
  7356. CeErpTradeRefund entity = null;
  7357. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7358. if (entity != null)
  7359. {
  7360. int apr = GetPostInt("approve");
  7361. if (apr == 0)
  7362. {
  7363. entity.RefundState = 1;
  7364. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7365. }
  7366. else if (apr == 1)
  7367. {
  7368. entity.RefundState = 3;
  7369. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7370. }
  7371. entity.modified = DateTime.Now;
  7372. entity.Update();
  7373. returnSuccessMsg("操作成功!");
  7374. return;
  7375. }
  7376. returnErrorMsg("找不到订单记录");
  7377. }
  7378. }
  7379. public void get_erp_billlist()
  7380. {
  7381. DataStruct dStruct = GetPostStruct();
  7382. List<string> lw = new List<string>();
  7383. string title = GetPostString("title");
  7384. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7385. string tid = GetPostString("tid");
  7386. string tids = GetPostString("tids");
  7387. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7388. if (tids.Length > 0)
  7389. {
  7390. tids = "'" + tids + "'";
  7391. tids = tids.Replace(",", "','");
  7392. lw.Add(string.Format("tid in ({0})", tids));
  7393. }
  7394. string shopname = GetPostString("shopname");
  7395. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7396. string buyernick = GetPostString("buyer_nick");
  7397. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7398. string customer = GetPostString("customer");
  7399. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7400. string date1 = GetPostString("date1");
  7401. string date2 = GetPostString("date2");
  7402. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7403. if (dw.Length > 0) lw.Add(dw);
  7404. string price1 = GetPostString("price1");
  7405. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7406. string price2 = GetPostString("price2");
  7407. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7408. string returndate1 = GetPostString("returndate1");
  7409. string returndate2 = GetPostString("returndate2");
  7410. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7411. if (dw1.Length > 0) lw.Add(dw1);
  7412. string billtype = GetPostString("billtype");
  7413. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7414. string billstate = GetPostString("billstate");
  7415. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7416. string usershop = CurrentUser.User.pemShop;
  7417. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7418. dStruct.Order = "createTime desc";
  7419. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7420. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7421. //foreach (DataRow dr in dt.Rows)
  7422. //{
  7423. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7424. //}
  7425. writeGridDataTableJson(dStruct.TotalCount, dt);
  7426. }
  7427. public void modify_erp_billinfo()
  7428. {
  7429. if (UrlPostParmsCheck("ID"))
  7430. {
  7431. string eid = GetPostString("ID");
  7432. CeErpBill bill_entity = null;
  7433. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7434. if (bill_entity != null)
  7435. {
  7436. bill_entity.tid = GetPostString("tid");
  7437. bill_entity.title = GetPostString("title");
  7438. bill_entity.tax = GetPostString("tax");
  7439. bill_entity.bank = GetPostString("bank");
  7440. bill_entity.bankac = GetPostString("bankac");
  7441. bill_entity.address = GetPostString("address");
  7442. bill_entity.phone = GetPostString("phone");
  7443. bill_entity.price = GetPostString("price");
  7444. bill_entity.productId = GetPostInt("ProductName");
  7445. bill_entity.num = GetPostInt("num");
  7446. bill_entity.unit = GetPostString("unit");
  7447. bill_entity.type = GetPostString("type");
  7448. bill_entity.sendType = GetPostString("SendType");
  7449. bill_entity.email = GetPostString("email");
  7450. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7451. bill_entity.shopName = GetPostString("ShopName");
  7452. bill_entity.applymemo = GetPostString("applymemo");
  7453. bill_entity.modifyTime = DateTime.Now;
  7454. bill_entity.createTime = DateTime.Now;
  7455. bill_entity.state = 0;
  7456. bill_entity.Update();
  7457. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7458. returnSuccessMsg("发票修改成功!");
  7459. return;
  7460. }
  7461. returnErrorMsg("找不到对应记录");
  7462. }
  7463. }
  7464. public void set_erp_invoicing()
  7465. {
  7466. if (UrlPostParmsCheck("id"))
  7467. {
  7468. try
  7469. {
  7470. string eid = GetPostString("id");
  7471. CeErpBill bill_entity = null;
  7472. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7473. if (bill_entity != null)
  7474. {
  7475. int ComId = GetPostInt("ComId");
  7476. //string memo = GetPostString("Memo");
  7477. int allInfo = GetPostInt("allinfo");
  7478. string clert = CurrentUser.User.Name;
  7479. //string detailValue = GetPostString("detailvalue");
  7480. string billId = bill_entity.billOrderId;
  7481. string[] billIdList = billId.Split(',');
  7482. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7483. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7484. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7485. {
  7486. billCount += 1;
  7487. }
  7488. if (billId.Length <= 0 || billIdList.Length != billCount)
  7489. {
  7490. bill_entity.billOrderId = "";
  7491. string prebill = "ltb";
  7492. for (int idx = 1; idx <= billCount; idx++)
  7493. {
  7494. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7495. string billoid = prebill + idx + dtstr;
  7496. bill_entity.billOrderId += billoid;
  7497. if (idx < billCount)
  7498. {
  7499. bill_entity.billOrderId += ",";
  7500. }
  7501. }
  7502. }
  7503. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7504. if (bill_entity.state == 5)
  7505. {
  7506. string errMsg = bill_entity.failerror;
  7507. string[] errlist = errMsg.Split('|');
  7508. string[] errTags = new string[errlist.Length];
  7509. for (int itag = 0; itag < errlist.Length; itag++)
  7510. {
  7511. if (errlist[itag].Length <= 0) continue;
  7512. errTags[itag] = errlist[itag].Split('&')[0];
  7513. }
  7514. for (int iii = 0; iii < errTags.Length; iii++)
  7515. {
  7516. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7517. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7518. if (billOrderList.Length >= erroBillOrderTag)
  7519. {
  7520. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7521. if (needModifyBillId.Length <= 19)
  7522. {
  7523. needModifyBillId = needModifyBillId + "1";
  7524. }
  7525. else
  7526. {
  7527. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7528. last = last + 1;
  7529. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7530. }
  7531. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7532. }
  7533. }
  7534. }
  7535. bool isHaveBillSucces = false;
  7536. string totalRes = "";
  7537. bill_entity.failerror = "";
  7538. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7539. {
  7540. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7541. totalRes += res;
  7542. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7543. {
  7544. isHaveBillSucces = true;
  7545. bill_entity.comId = ComId;
  7546. bill_entity.state = 1;
  7547. bill_entity.executeTime = DateTime.Now;
  7548. bill_entity.executeUser = clert;
  7549. }
  7550. else
  7551. {
  7552. bill_entity.state = 5;
  7553. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7554. }
  7555. }
  7556. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7557. bill_entity.Update();
  7558. if (isHaveBillSucces)
  7559. {
  7560. StringBuilder sql = new StringBuilder();
  7561. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7562. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7563. }
  7564. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7565. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7566. {
  7567. returnErrorMsg("开票失败");
  7568. }
  7569. else
  7570. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7571. return;
  7572. }
  7573. returnErrorMsg("找不到对应记录");
  7574. }
  7575. catch (Exception ex)
  7576. {
  7577. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7578. returnErrorMsg("操作失败");
  7579. }
  7580. }
  7581. }
  7582. public void get_erp_invoicing_back()
  7583. {
  7584. if (UrlPostParmsCheck("id"))
  7585. {
  7586. try
  7587. {
  7588. string id = GetPostString("id");
  7589. CeErpBill entiy = CeErpBill.Get(id);
  7590. if (entiy != null)
  7591. {
  7592. if (entiy.state == 0)
  7593. {
  7594. returnErrorMsg("发票还未开具");
  7595. return;
  7596. }
  7597. string[] billOrderList = entiy.billOrderId.Split(',');
  7598. int iTag = 0;
  7599. entiy.fplsh = "";
  7600. entiy.fpdm = "";
  7601. entiy.fphm = "";
  7602. foreach (string billOrderId in billOrderList)
  7603. {
  7604. iTag++;
  7605. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7606. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7607. {
  7608. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7609. try
  7610. {
  7611. Invoicing_get_response_Obj iObj = null;
  7612. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7613. if (iObj != null)
  7614. {
  7615. entiy.state = 2;
  7616. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7617. entiy.fpdm += iObj.list[0].c_fpdm;
  7618. entiy.fphm += iObj.list[0].c_fphm;
  7619. if (iTag < billOrderList.Length)
  7620. {
  7621. entiy.fplsh += ",";
  7622. entiy.fpdm += ",";
  7623. entiy.fphm += ",";
  7624. }
  7625. entiy.Update();
  7626. }
  7627. StringBuilder sql = new StringBuilder();
  7628. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7629. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7630. returnSuccessMsg("开票成功");
  7631. }
  7632. catch (Exception ex)
  7633. {
  7634. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7635. }
  7636. return;
  7637. }
  7638. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7639. {
  7640. var res_obj = new
  7641. {
  7642. data = "开票中"
  7643. };
  7644. string ro_json = JsonConvert.SerializeObject(res_obj);
  7645. returnSuccess(ro_json);
  7646. return;
  7647. }
  7648. else
  7649. {
  7650. int eidx = res.IndexOf("c_resultmsg");
  7651. int lidx = res.IndexOf("c_status");
  7652. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7653. entiy.state = 5;
  7654. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7655. entiy.Update();
  7656. returnErrorMsg("开票失败");
  7657. return;
  7658. }
  7659. }
  7660. }
  7661. }
  7662. catch (Exception ex)
  7663. {
  7664. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7665. }
  7666. return;
  7667. }
  7668. }
  7669. public void get_erp_invoicing()
  7670. {
  7671. if (UrlPostParmsCheck("id"))
  7672. {
  7673. try
  7674. {
  7675. string id = GetPostString("id");
  7676. CeErpBill entiy = CeErpBill.Get(id);
  7677. if (entiy != null)
  7678. {
  7679. if (entiy.state == 0)
  7680. {
  7681. returnErrorMsg("发票还未开具");
  7682. return;
  7683. }
  7684. if (entiy.sendType == "纸质发票")
  7685. {
  7686. if (entiy.img.Length <= 0)
  7687. {
  7688. returnErrorMsg("查无纸质发票");
  7689. return;
  7690. }
  7691. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7692. returnSuccess(returnres);
  7693. return;
  7694. }
  7695. string[] billOrderList = entiy.billOrderId.Split(',');
  7696. int iTag = 0;
  7697. string fpUrl = "";
  7698. entiy.fplsh = "";
  7699. entiy.fpdm = "";
  7700. entiy.fphm = "";
  7701. foreach (string billOrderId in billOrderList)
  7702. {
  7703. iTag++;
  7704. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7705. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7706. {
  7707. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7708. Invoicing_get_response_Obj iObj = null;
  7709. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7710. if (iObj != null)
  7711. {
  7712. //entiy.state = 2;
  7713. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7714. entiy.fpdm += iObj.list[0].c_fpdm;
  7715. entiy.fphm += iObj.list[0].c_fphm;
  7716. if (iTag < billOrderList.Length)
  7717. {
  7718. entiy.fplsh += ",";
  7719. entiy.fpdm += ",";
  7720. entiy.fphm += ",";
  7721. }
  7722. entiy.Update();
  7723. fpUrl += iObj.list[0].c_url + ",";
  7724. }
  7725. //returnSuccess(res);
  7726. StringBuilder sql = new StringBuilder();
  7727. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7728. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7729. }
  7730. else
  7731. {
  7732. int eidx = res.IndexOf("c_resultmsg");
  7733. //int lidx = res.IndexOf("c_status");
  7734. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7735. //开票失败
  7736. entiy.state = 5;
  7737. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7738. entiy.Update();
  7739. returnErrorMsg("开票失败");
  7740. return;
  7741. }
  7742. }
  7743. var returnObj = new
  7744. {
  7745. data = fpUrl
  7746. };
  7747. string ro_json = JsonConvert.SerializeObject(returnObj);
  7748. returnSuccess(ro_json);
  7749. }
  7750. }
  7751. catch (Exception ex)
  7752. {
  7753. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7754. }
  7755. return;
  7756. }
  7757. }
  7758. public void save_erp_billimg()
  7759. {
  7760. if (UrlPostParmsCheck("id"))
  7761. {
  7762. string eid = GetPostString("id");
  7763. CeErpBill bill_entity = null;
  7764. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7765. if (bill_entity != null)
  7766. {
  7767. bill_entity.img = GetPostString("img");
  7768. bill_entity.executeTime = DateTime.Now;
  7769. bill_entity.state = 2;
  7770. bill_entity.Update();
  7771. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7772. returnSuccessMsg("保存成功");
  7773. }
  7774. return;
  7775. }
  7776. }
  7777. public void upd_erp_billreturnback()
  7778. {
  7779. if (UrlPostParmsCheck("id"))
  7780. {
  7781. int eid = GetPostInt("id");
  7782. CeErpBill bill_entity = null;
  7783. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7784. if (bill_entity != null)
  7785. {
  7786. bill_entity.state = 3;
  7787. bill_entity.returnReason = GetPostString("reason");
  7788. bill_entity.Update();
  7789. returnSuccessMsg("驳回成功!");
  7790. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7791. }
  7792. return;
  7793. }
  7794. }
  7795. public void cancel_erp_bill()
  7796. {
  7797. if (UrlPostParmsCheck("id"))
  7798. {
  7799. int eid = GetPostInt("id");
  7800. int detailValue = GetPostInt("detailvalue");
  7801. CeErpBill bill_entity = null;
  7802. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7803. string cres = "";
  7804. string gres = "";
  7805. if (bill_entity != null)
  7806. {
  7807. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7808. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  7809. {
  7810. int iTag = 0;
  7811. bill_entity.fplsh = "";
  7812. bill_entity.fpdm = "";
  7813. bill_entity.fphm = "";
  7814. foreach (string billOrderId in billOrderList)
  7815. {
  7816. iTag++;
  7817. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  7818. if (gres.IndexOf("success") != -1)
  7819. {
  7820. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  7821. Invoicing_get_response_Obj iObj = null;
  7822. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  7823. if (iObj != null)
  7824. {
  7825. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  7826. bill_entity.fpdm += iObj.list[0].c_fpdm;
  7827. bill_entity.fphm += iObj.list[0].c_fphm;
  7828. if (iTag < billOrderList.Length)
  7829. {
  7830. bill_entity.fplsh += ",";
  7831. bill_entity.fpdm += ",";
  7832. bill_entity.fphm += ",";
  7833. }
  7834. bill_entity.Update();
  7835. }
  7836. }
  7837. else
  7838. {
  7839. returnErrorMsg(gres);
  7840. return;
  7841. }
  7842. }
  7843. }
  7844. if (bill_entity.sendType == "纸质发票")
  7845. {
  7846. //作废
  7847. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  7848. //if (DateTime.Now.Month == extime.Month)
  7849. //{
  7850. //cres = taobaoHelper.cancel_invoicing(eid);
  7851. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  7852. //{
  7853. bill_entity.state = 4;//已作废
  7854. bill_entity.Update();
  7855. returnSuccessMsg("发票已作废");
  7856. return;
  7857. //}
  7858. //else
  7859. //{
  7860. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  7861. // bill_entity.Update();
  7862. // returnErrorMsg(cres);
  7863. // return;
  7864. //}
  7865. //}
  7866. //else
  7867. //{
  7868. // returnErrorMsg("纸质发票只能作废本月的发票");
  7869. // return;
  7870. //}
  7871. }
  7872. //红冲
  7873. int redTag = 0;
  7874. string[] fpdmList = bill_entity.fpdm.Split(',');
  7875. string[] fphmList = bill_entity.fphm.Split(',');
  7876. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  7877. {
  7878. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  7879. return;
  7880. }
  7881. foreach (string billOrderId in billOrderList)
  7882. {
  7883. redTag++;
  7884. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  7885. cres += onecres;
  7886. cres += ",";
  7887. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  7888. {
  7889. bill_entity.state = 4;//已作废
  7890. //bill_entity.Update();
  7891. //returnSuccessMsg("发票已红冲");
  7892. }
  7893. else if (onecres.IndexOf("重复冲红") != -1)
  7894. {
  7895. bill_entity.state = 4;//已作废
  7896. //bill_entity.Update();
  7897. //returnSuccessMsg("发票已红冲");
  7898. }
  7899. else
  7900. {
  7901. string errmsg = commonHelper.KeepChinese(onecres);
  7902. bill_entity.failerror += redTag + "&" + errmsg + "|";
  7903. }
  7904. }
  7905. bill_entity.Update();
  7906. if (cres.IndexOf("失败") != -1)
  7907. returnErrorMsg("红冲失败");
  7908. else
  7909. returnSuccessMsg("发票已红冲");
  7910. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  7911. return;
  7912. }
  7913. return;
  7914. }
  7915. }
  7916. public void del_erp_billorder()
  7917. {
  7918. if (UrlPostParmsCheck("id"))
  7919. {
  7920. string eid = GetPostString("id");
  7921. CeErpBill.Del(eid);
  7922. CeErpBill bill = CeErpBill.Get(eid);
  7923. if (bill != null)
  7924. {
  7925. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  7926. }
  7927. returnSuccessMsg("删除成功");
  7928. }
  7929. }
  7930. public void finish_erp_bill()
  7931. {
  7932. if (UrlPostParmsCheck("ids"))
  7933. {
  7934. string eids = GetPostString("ids");
  7935. string[] list = eids.Split(',');
  7936. foreach (string eid in list)
  7937. {
  7938. CeErpBill bill = CeErpBill.Get(eid);
  7939. if (bill != null)
  7940. {
  7941. bill.state = 2;
  7942. bill.Update();
  7943. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  7944. }
  7945. }
  7946. returnSuccessMsg("操作成功");
  7947. }
  7948. }
  7949. public void get_erp_returncash()
  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("seller_nick = '{0}'", shopname));
  7957. string buyernick = GetPostString("buyer_nick");
  7958. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7959. string customer = GetPostString("customer");
  7960. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  7961. string returndate1 = GetPostString("returndate1");
  7962. string returndate2 = GetPostString("returndate2");
  7963. string dw = GetDateMinuteWhere("created", 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("verifytime", finishDate1, finishDate2);
  7968. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7969. string returntype = GetPostString("returntype");
  7970. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  7971. string returnvstate = GetPostString("returnvstate");
  7972. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  7973. dStruct.Order = "created desc";
  7974. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7975. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  7976. writeGridDataTableJson(dStruct.TotalCount, dt);
  7977. }
  7978. public void get_erp_staygoods()
  7979. {
  7980. DataStruct dStruct = GetPostStruct();
  7981. List<string> lw = new List<string>();
  7982. string tid = GetPostString("tid");
  7983. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7984. string shopname = GetPostString("shopname");
  7985. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  7986. string wangwang = GetPostString("wangwang");
  7987. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  7988. string customer = GetPostString("customer");
  7989. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  7990. string returndate1 = GetPostString("returndate1");
  7991. string returndate2 = GetPostString("returndate2");
  7992. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  7993. if (dw.Length > 0) lw.Add(dw);
  7994. string finishDate1 = GetPostString("finishdate1");
  7995. string finishDate2 = GetPostString("finishdate2");
  7996. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  7997. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7998. string returnvstate = GetPostString("returnvstate");
  7999. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8000. string persuadetype = GetPostString("persuadetype");
  8001. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8002. string customerOrg = GetPostString("customerOrg");
  8003. if (customerOrg.Length > 0)
  8004. {
  8005. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8006. }
  8007. dStruct.Order = "creata_time desc";
  8008. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8009. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8010. writeGridDataTableJson(dStruct.TotalCount, dt);
  8011. }
  8012. public void upd_erp_staygoods()
  8013. {
  8014. if (UrlPostParmsCheck("id"))
  8015. {
  8016. int eid = GetPostInt("id");
  8017. CeErpStayGoods entity = null;
  8018. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8019. if (entity != null)
  8020. {
  8021. entity.audit_type = 1;
  8022. entity.audit_time = DateTime.Now;
  8023. entity.audit_u_id = CurrentUser.UserID;
  8024. entity.audit_u_name = CurrentUser.UserName;
  8025. entity.Update();
  8026. returnSuccessMsg("审核成功!");
  8027. return;
  8028. }
  8029. returnErrorMsg("找不到订单记录");
  8030. }
  8031. }
  8032. public void upd_erp_stayGoodsback()
  8033. {
  8034. if (UrlPostParmsCheck("id"))
  8035. {
  8036. int eid = GetPostInt("id");
  8037. CeErpStayGoods entity = null;
  8038. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8039. if (entity != null)
  8040. {
  8041. entity.audit_text = GetPostString("reason");
  8042. entity.audit_type = 2;
  8043. entity.audit_time = DateTime.Now;
  8044. entity.audit_u_id = CurrentUser.UserID;
  8045. entity.audit_u_name = CurrentUser.UserName;
  8046. entity.Update();
  8047. returnSuccessMsg("退回成功!");
  8048. return;
  8049. }
  8050. returnErrorMsg("找不到订单记录");
  8051. }
  8052. }
  8053. public void upd_erp_returncashverify()
  8054. {
  8055. if (UrlPostParmsCheck("ID"))
  8056. {
  8057. int eid = GetPostInt("ID");
  8058. CeErpReturnCash entity = null;
  8059. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8060. if (entity != null)
  8061. {
  8062. entity.cashstate = 1;
  8063. entity.verifytime = DateTime.Now;
  8064. entity.verifyuserid = CurrentUser.UserID;
  8065. entity.Update();
  8066. returnSuccessMsg("审核成功!");
  8067. return;
  8068. }
  8069. returnErrorMsg("找不到订单记录");
  8070. }
  8071. }
  8072. public void upd_all_erp_returncashverify()
  8073. {
  8074. if (UrlPostParmsCheck("ID"))
  8075. {
  8076. String[] list = GetPostString("ID").Split(',');
  8077. CeErpReturnCash entity = null;
  8078. for (int i = 0; i < list.Length; i++)
  8079. {
  8080. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8081. if (entity != null)
  8082. {
  8083. if (entity.cashstate == 1)
  8084. {
  8085. returnErrorMsg("已审核过的订单不需要在审核!");
  8086. return;
  8087. }
  8088. entity.cashstate = 1;
  8089. entity.verifytime = DateTime.Now;
  8090. entity.verifyuserid = CurrentUser.UserID;
  8091. entity.Update();
  8092. }
  8093. }
  8094. returnSuccessMsg("审核成功!");
  8095. return;
  8096. }
  8097. }
  8098. public void upd_erp_returncashback()
  8099. {
  8100. if (UrlPostParmsCheck("ID"))
  8101. {
  8102. int eid = GetPostInt("ID");
  8103. CeErpReturnCash entity = null;
  8104. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8105. if (entity != null)
  8106. {
  8107. entity.backreason = GetPostString("reason");
  8108. entity.cashstate = 2;
  8109. entity.verifytime = DateTime.Now;
  8110. entity.verifyuserid = CurrentUser.UserID;
  8111. entity.Update();
  8112. returnSuccessMsg("退回成功!");
  8113. return;
  8114. }
  8115. returnErrorMsg("找不到订单记录");
  8116. }
  8117. }
  8118. public void upd_erp_returnprice()
  8119. {
  8120. if (UrlPostParmsCheck("ID"))
  8121. {
  8122. int eid = GetPostInt("ID");
  8123. CeErpReturnCash entity = null;
  8124. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8125. if (entity != null)
  8126. {
  8127. if (entity.cashstate == 1)
  8128. {
  8129. returnErrorMsg("审核通过了不能改");
  8130. return;
  8131. }
  8132. entity.returnprice = GetPostDouble("returnprice");
  8133. entity.Update();
  8134. returnSuccessMsg("修改成功!");
  8135. return;
  8136. }
  8137. returnErrorMsg("找不到订单记录");
  8138. }
  8139. }
  8140. public void del_erp_returncash()
  8141. {
  8142. if (UrlPostParmsCheck("ID"))
  8143. {
  8144. int eid = GetPostInt("ID");
  8145. CeErpReturnCash.Del(eid);
  8146. returnSuccessMsg("操作成功");
  8147. return;
  8148. }
  8149. }
  8150. public void test_for_do_sql()
  8151. {
  8152. string sql = GetPostString("sqlstr");
  8153. if (sql.Length > 0)
  8154. {
  8155. try
  8156. {
  8157. DbHelper.DbConn.ExecuteNonQuery(sql);
  8158. var res_obj = new
  8159. {
  8160. data = "成功",
  8161. };
  8162. string ro_json = JsonConvert.SerializeObject(res_obj);
  8163. returnSuccess(ro_json);
  8164. }
  8165. catch (Exception ex)
  8166. {
  8167. var res_obj = new
  8168. {
  8169. data = ex.Message,
  8170. };
  8171. string ro_json = JsonConvert.SerializeObject(res_obj);
  8172. returnSuccess(ro_json);
  8173. }
  8174. }
  8175. }
  8176. public void get_user_info()
  8177. {
  8178. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8179. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8180. }
  8181. public void get_total_data()
  8182. {
  8183. int userId = CurrentUser.UserID;
  8184. string sql = "";
  8185. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8186. {
  8187. 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);
  8188. }
  8189. else
  8190. {
  8191. 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 " +
  8192. "(select ID from CE_ErpUser where ID = {0}) d " +
  8193. "left join " +
  8194. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8195. ") a on d.ID = a.id left join " +
  8196. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8197. ") b on a.id = b.id1 left join" +
  8198. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8199. ") c on a.id = c.id2;", userId);
  8200. }
  8201. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8202. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8203. }
  8204. public void get_date_area_total_data2()
  8205. {
  8206. int userId = CurrentUser.UserID;
  8207. string date_type = GetPostString("timetype");
  8208. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8209. string sql = "";
  8210. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8211. {
  8212. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8213. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8214. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8215. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8216. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8217. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8218. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8219. ") a on e.ID = a.id left join " +
  8220. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8221. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8222. ") b on a.id = b.id1 " +
  8223. "left join " +
  8224. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8225. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8226. ") c on a.id = c.id2 " +
  8227. "left join " +
  8228. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8229. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8230. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8231. }
  8232. else
  8233. {
  8234. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8235. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8236. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8237. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8238. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8239. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8240. ") a on e.ID = a.id left join " +
  8241. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8242. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8243. ") c on a.id = c.id2 " +
  8244. "left join " +
  8245. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8246. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8247. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8248. }
  8249. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8250. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8251. }
  8252. public void get_date_area_total_data()
  8253. {
  8254. int userId = CurrentUser.UserID;
  8255. string date_type = GetPostString("timetype");
  8256. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8257. string date1 = searchDT[0].ToString();
  8258. string date2 = searchDT[1].ToString();
  8259. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8260. {
  8261. SqlParameter[] sqlParameter ={
  8262. new SqlParameter("@userId", SqlDbType.Int,4),
  8263. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8264. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8265. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8266. };
  8267. sqlParameter[0].Value = userId;
  8268. sqlParameter[1].Value = date1;
  8269. sqlParameter[2].Value = date2;
  8270. sqlParameter[3].Direction = ParameterDirection.Output;
  8271. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8272. string res = sqlParameter[3].Value.ToString();
  8273. var res_obj = new
  8274. {
  8275. data = res
  8276. };
  8277. string ro_json = JsonConvert.SerializeObject(res_obj);
  8278. returnSuccess(ro_json);
  8279. }
  8280. else
  8281. {
  8282. SqlParameter[] sqlParameter ={
  8283. new SqlParameter("@userId", SqlDbType.Int,4),
  8284. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8285. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8286. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8287. };
  8288. sqlParameter[0].Value = userId;
  8289. sqlParameter[1].Value = date1;
  8290. sqlParameter[2].Value = date2;
  8291. sqlParameter[3].Direction = ParameterDirection.Output;
  8292. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8293. string res = sqlParameter[3].Value.ToString();
  8294. var res_obj = new
  8295. {
  8296. data = res
  8297. };
  8298. string ro_json = JsonConvert.SerializeObject(res_obj);
  8299. returnSuccess(ro_json);
  8300. }
  8301. //writeGridDataViewJson(dt.Rows.Count, dv);
  8302. }
  8303. public void get_order_list()
  8304. {
  8305. string strFields = GetPostString("paraFields");
  8306. string strOrder = GetPostString("paraOrder");
  8307. string strWhere = GetPostString("paraWhere");
  8308. string strPageSize = GetPostString("paraPageSize");
  8309. DataStruct dStruct = GetPostStruct();
  8310. dStruct.PageSize = int.Parse(strPageSize);
  8311. dStruct.Fileds = strFields;
  8312. dStruct.Order = strOrder;
  8313. dStruct.MainWhere = strWhere;
  8314. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8315. writeGridDataTableJson(dStruct.TotalCount, dt);
  8316. }
  8317. ////获取待开始订单列表
  8318. //public void get_wait_design_order_list()
  8319. //{
  8320. // string date_type = GetPostString("date_type");
  8321. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8322. // DataStruct dStruct = GetPostStruct();
  8323. // dStruct.PageSize = 1000;
  8324. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8325. // List<string> lw = new List<string>();
  8326. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8327. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8328. // dStruct.Order = "WaitDesignTime asc";
  8329. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8330. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8331. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8332. //}
  8333. //获取完成单量排名
  8334. public void get_finish_order_count_ranking()
  8335. {
  8336. /* string date_type = GetPostString("date_type");
  8337. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8338. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8339. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8340. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8341. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8342. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8343. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8344. writeGridDataTableJson(0, new DataTable());
  8345. }
  8346. public void get_finish_order_amount_ranking()
  8347. {
  8348. /*string date_type = GetPostString("date_type");
  8349. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8350. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8351. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8352. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8353. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8354. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8355. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8356. writeGridDataTableJson(0, new DataTable());
  8357. }
  8358. public void get_finish_refund_count_ranking()
  8359. {
  8360. string date_type = GetPostString("date_type");
  8361. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8362. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8363. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8364. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8365. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8366. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8367. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8368. writeGridDataTableJson(dt.Rows.Count, dt);
  8369. }
  8370. public void get_finish_refund_amount_ranking()
  8371. {
  8372. string date_type = GetPostString("date_type");
  8373. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8374. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8375. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8376. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8377. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8378. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8379. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8380. writeGridDataTableJson(dt.Rows.Count, dt);
  8381. }
  8382. public void set_erp_finishorder_director()
  8383. {
  8384. if (UrlPostParmsCheck("ctid"))
  8385. {
  8386. string eid = GetPostString("ctid");
  8387. CeErpTradeCell entity = null;
  8388. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8389. if (entity != null)
  8390. {
  8391. entity.OrderState = 8;
  8392. entity.Update();
  8393. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8394. returnSuccessMsg("操作成功!");
  8395. return;
  8396. }
  8397. returnErrorMsg("找不到记录");
  8398. }
  8399. }
  8400. public void get_erp_placeregistlist()
  8401. {
  8402. DataStruct dStruct = GetPostStruct();
  8403. List<string> lw = new List<string>();
  8404. string outsid = GetPostString("outsid");
  8405. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8406. string memo = GetPostString("memo");
  8407. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8408. string filename = GetPostString("filename");
  8409. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8410. string islate = GetPostString("islate");
  8411. if (islate.Length > 0)
  8412. {
  8413. if (islate == "1")
  8414. lw.Add(string.Format("OutLate>0"));
  8415. else
  8416. lw.Add(string.Format("OutLate=0"));
  8417. }
  8418. string placedate1 = GetPostString("placedate1");
  8419. string placedate2 = GetPostString("placedate2");
  8420. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8421. if (dw.Length > 0) lw.Add(dw);
  8422. string deliveryDate1 = GetPostString("deliverydate1");
  8423. string deliveryDate2 = GetPostString("deliverydate2");
  8424. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8425. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8426. dStruct.Order = "ID desc";
  8427. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8428. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8429. writeGridDataTableJson(dStruct.TotalCount, dt);
  8430. }
  8431. public void ins_erp_placeregist()
  8432. {
  8433. if (UrlPostParmsCheck("id"))
  8434. {
  8435. string eid = GetPostString("id");
  8436. CeErpPlaceRegister entity = null;
  8437. if (eid == "0")//新增
  8438. {
  8439. entity = new CeErpPlaceRegister();
  8440. string xdTime = GetPostString("placeTime");
  8441. if (xdTime.Length > 0)
  8442. {
  8443. entity.PlactTime = Convert.ToDateTime(xdTime);
  8444. }
  8445. string fhTime = GetPostString("deliveryTime");
  8446. if (fhTime.Length > 0)
  8447. {
  8448. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8449. }
  8450. string preTime = GetPostString("preOutTime");
  8451. if (preTime.Length > 0)
  8452. {
  8453. entity.PreOutTime = Convert.ToDateTime(preTime);
  8454. }
  8455. entity.DeliveryCount = GetPostInt("deliveryCount");
  8456. entity.ReceiveCount = GetPostInt("receiveCount");
  8457. entity.OutSid = GetPostString("outSid");
  8458. entity.FileName = GetPostString("fileName");
  8459. entity.Memo = GetPostString("memo");
  8460. entity.AddUserId = CurrentUser.UserID;
  8461. entity.CreateTime = DateTime.Now;
  8462. entity.Img = GetPostString("img");
  8463. entity.Supplier = GetPostInt("supplier");
  8464. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8465. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8466. {
  8467. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8468. DateTime dt2 = (DateTime)entity.PreOutTime;
  8469. TimeSpan span = dt1.Subtract(dt2);
  8470. if (span.Days > 0)
  8471. {
  8472. entity.OutLate = span.Days;
  8473. }
  8474. }
  8475. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8476. entity.Create();
  8477. returnSuccessMsg("添加成功!");
  8478. return;
  8479. }
  8480. else //修改
  8481. {
  8482. entity = CeErpPlaceRegister.Get(eid);
  8483. if (entity != null)
  8484. {
  8485. string xdTime = GetPostString("placeTime");
  8486. if (xdTime.Length > 0)
  8487. {
  8488. entity.PlactTime = Convert.ToDateTime(xdTime);
  8489. }
  8490. string fhTime = GetPostString("deliveryTime");
  8491. if (fhTime.Length > 0)
  8492. {
  8493. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8494. }
  8495. string preTime = GetPostString("preOutTime");
  8496. if (preTime.Length > 0)
  8497. {
  8498. entity.PreOutTime = Convert.ToDateTime(preTime);
  8499. }
  8500. entity.DeliveryCount = GetPostInt("deliveryCount");
  8501. entity.ReceiveCount = GetPostInt("receiveCount");
  8502. if (entity.DeliveryCount == entity.ReceiveCount)
  8503. {
  8504. entity.CurState = "已完成";
  8505. }
  8506. else
  8507. {
  8508. entity.CurState = "未完成";
  8509. }
  8510. entity.OutSid = GetPostString("outSid");
  8511. entity.FileName = GetPostString("fileName");
  8512. entity.Memo = GetPostString("memo");
  8513. entity.Img = GetPostString("img");
  8514. entity.Supplier = GetPostInt("supplier");
  8515. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8516. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8517. {
  8518. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8519. DateTime dt2 = (DateTime)entity.PreOutTime;
  8520. TimeSpan span = dt1.Subtract(dt2);
  8521. if (span.Days > 0)
  8522. {
  8523. entity.OutLate = span.Days;
  8524. }
  8525. }
  8526. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8527. entity.Update();
  8528. returnSuccessMsg("修改成功");
  8529. return;
  8530. }
  8531. returnErrorMsg("找不到对应的记录");
  8532. return;
  8533. }
  8534. }
  8535. returnErrorMsg("缺少必要参数");
  8536. }
  8537. public void del_erp_placeregist()
  8538. {
  8539. string eid = GetPostString("id");
  8540. CeErpPlaceRegister.Del(eid);
  8541. returnSuccessMsg("删除成功!");
  8542. return;
  8543. }
  8544. public void ins_erp_placeregistbyorder()
  8545. {
  8546. string ctid = GetPostString("ctid");
  8547. if (ctid.Length > 0)
  8548. {
  8549. StringBuilder sql = new StringBuilder();
  8550. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8551. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8552. if (dt.Rows.Count > 0)
  8553. {
  8554. foreach (DataRow dr in dt.Rows)
  8555. {
  8556. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8557. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8558. entity.AddUserId = CurrentUser.UserID;
  8559. entity.tid = dr["tid"].ToString();
  8560. entity.Did = Convert.ToString(dr["ctid"]);
  8561. entity.splitTag = dr["SplitTag"].ToString();
  8562. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8563. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8564. if (pre_ctid.Length > 0)
  8565. {
  8566. sellmemo = sellmemo.Replace(pre_ctid, "");
  8567. }
  8568. sellmemo = sellmemo.Replace("[", "");
  8569. sellmemo = sellmemo.Replace("]", "");
  8570. entity.FileName = sellmemo;
  8571. string count = dr["ProductCount"].ToString();
  8572. int usecount = commonHelper.getIntCountFromString(count);
  8573. entity.DeliveryCount = usecount;
  8574. entity.CurState = "未完成";
  8575. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8576. {
  8577. entity.Supplier = 24;//dl手提袋定制
  8578. }
  8579. else
  8580. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8581. entity.CreateTime = DateTime.Now;
  8582. entity.Create();
  8583. }
  8584. returnSuccessMsg("操作成功");
  8585. return;
  8586. }
  8587. returnErrorMsg("没有找到对应订单");
  8588. return;
  8589. }
  8590. returnErrorMsg("缺少订单编号");
  8591. return;
  8592. }
  8593. public void get_erp_persuadelist()
  8594. {
  8595. DataStruct dStruct = GetPostStruct();
  8596. List<string> lw = new List<string>();
  8597. string ctid = GetPostString("ctid");
  8598. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8599. string shopname = GetPostString("shopname");
  8600. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8601. string buyernick = GetPostString("buyer_nick");
  8602. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8603. string customer = GetPostString("customer");
  8604. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8605. string returndate1 = GetPostString("returndate1");
  8606. string returndate2 = GetPostString("returndate2");
  8607. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8608. if (dw.Length > 0) lw.Add(dw);
  8609. string finishDate1 = GetPostString("finishdate1");
  8610. string finishDate2 = GetPostString("finishdate2");
  8611. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8612. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8613. string persuadetype = GetPostString("persuadetype");
  8614. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8615. string returnvstate = GetPostString("returnvstate");
  8616. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8617. dStruct.Order = "created desc";
  8618. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8619. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8620. writeGridDataTableJson(dStruct.TotalCount, dt);
  8621. }
  8622. public void upd_erp_returnpersuadeback()
  8623. {
  8624. if (UrlPostParmsCheck("ID"))
  8625. {
  8626. int eid = GetPostInt("ID");
  8627. CeErpPersuade entity = null;
  8628. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8629. if (entity != null)
  8630. {
  8631. entity.backreason = GetPostString("reason");
  8632. entity.pstate = 2;
  8633. entity.verifytime = DateTime.Now;
  8634. entity.verifyuserid = CurrentUser.UserID;
  8635. entity.Update();
  8636. returnSuccessMsg("退回成功!");
  8637. return;
  8638. }
  8639. returnErrorMsg("找不到订单记录");
  8640. }
  8641. }
  8642. public void upd_erp_returnpersuadeverify()
  8643. {
  8644. if (UrlPostParmsCheck("ID"))
  8645. {
  8646. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8647. {
  8648. returnErrorMsg("暂无权限审核");
  8649. return;
  8650. }
  8651. int eid = GetPostInt("ID");
  8652. CeErpPersuade entity = null;
  8653. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8654. if (entity != null)
  8655. {
  8656. entity.pstate = 1;
  8657. entity.verifytime = DateTime.Now;
  8658. entity.verifyuserid = CurrentUser.UserID;
  8659. entity.Update();
  8660. returnSuccessMsg("审核成功!");
  8661. return;
  8662. }
  8663. returnErrorMsg("找不到订单记录");
  8664. }
  8665. }
  8666. public void del_erp_persuade()
  8667. {
  8668. if (UrlPostParmsCheck("ID"))
  8669. {
  8670. int eid = GetPostInt("ID");
  8671. CeErpPersuade.Del(eid);
  8672. returnSuccessMsg("操作成功");
  8673. return;
  8674. }
  8675. }
  8676. public void get_erp_oldcustoupload()
  8677. {
  8678. DataStruct dStruct = GetPostStruct();
  8679. List<string> lw = new List<string>();
  8680. string buyernick = GetPostString("buyer_nick");
  8681. if (buyernick.Length > 0)
  8682. {
  8683. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8684. }
  8685. else
  8686. return;
  8687. dStruct.Order = "pay_time desc";
  8688. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8689. DataTable dt = null;
  8690. dt = WebCache.GetData("view_erptradecell", dStruct);
  8691. writeGridDataTableJson(dStruct.TotalCount, dt);
  8692. }
  8693. public void get_erp_checkorderlist()
  8694. {
  8695. DataStruct dStruct = GetPostStruct();
  8696. List<string> lw = new List<string>();
  8697. string tid = GetPostString("ctid");
  8698. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8699. string shopname = GetPostString("shopname");
  8700. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8701. string buyernick = GetPostString("buyer_nick");
  8702. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8703. string customer = GetPostString("customer");
  8704. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8705. string design = GetPostString("design");
  8706. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8707. string orderState = GetPostString("orderState");
  8708. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8709. string address = GetPostString("address");
  8710. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8711. string sellermemo = GetPostString("seller_memo");
  8712. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8713. string supplier = GetPostString("supplier");
  8714. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8715. {
  8716. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8717. }
  8718. else
  8719. {
  8720. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8721. }
  8722. string checkst = GetPostString("checkstate");
  8723. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8724. string date1 = GetPostString("date1");
  8725. string date2 = GetPostString("date2");
  8726. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8727. if (dw.Length > 0) lw.Add(dw);
  8728. string placedate1 = GetPostString("placedate1");
  8729. string placedate2 = GetPostString("placedate2");
  8730. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8731. if (fdw.Length > 0) lw.Add(fdw);
  8732. string price1 = GetPostString("price1");
  8733. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8734. string price2 = GetPostString("price2");
  8735. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8736. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8737. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8738. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8739. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8740. writeGridDataTableJson(dStruct.TotalCount, dt);
  8741. }
  8742. public void ins_erp_startCheck()
  8743. {
  8744. if (UrlPostParmsCheck("ctid"))
  8745. {
  8746. string eid = GetPostString("ctid");
  8747. CeErpTradeCell entity = null;
  8748. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8749. if (entity != null)
  8750. {
  8751. entity.MemoOpt = 4;
  8752. entity.Update();
  8753. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8754. CeErpSukuraData.createInfo(entity.ctid, 6);
  8755. returnSuccessMsg("操作成功!");
  8756. return;
  8757. }
  8758. returnErrorMsg("找不到记录");
  8759. }
  8760. }
  8761. public void upd_erp_sendXlw()
  8762. {
  8763. if (UrlPostParmsCheck("ctid"))
  8764. {
  8765. string eid = GetPostString("ctid");
  8766. CeErpTradeCell entity = null;
  8767. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8768. if (entity != null)
  8769. {
  8770. if (entity.IsSendGift == 1)
  8771. {
  8772. returnErrorMsg("请勿重复标记");
  8773. return;
  8774. }
  8775. entity.IsSendGift = 1;
  8776. entity.Update();
  8777. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8778. returnSuccessMsg("操作成功!");
  8779. return;
  8780. }
  8781. returnErrorMsg("找不到记录");
  8782. }
  8783. }
  8784. public void cancel_sendXlw()
  8785. {
  8786. if (UrlPostParmsCheck("ctid"))
  8787. {
  8788. string eid = GetPostString("ctid");
  8789. CeErpTradeCell entity = null;
  8790. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8791. if (entity != null)
  8792. {
  8793. if (entity.IsSendGift == 0)
  8794. {
  8795. returnErrorMsg("未标记小礼物");
  8796. return;
  8797. }
  8798. entity.IsSendGift = 0;
  8799. entity.Update();
  8800. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  8801. returnSuccessMsg("操作成功!");
  8802. return;
  8803. }
  8804. returnErrorMsg("找不到记录");
  8805. }
  8806. }
  8807. public void get_erp_designbill()
  8808. {
  8809. DataStruct dStruct = GetPostStruct();
  8810. List<string> lw = new List<string>();
  8811. int isMy = GetInt("my");
  8812. if (isMy == 1)
  8813. {
  8814. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  8815. }
  8816. string tid = GetPostString("tid");
  8817. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8818. string userName = GetPostString("design");
  8819. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  8820. string price1 = GetPostString("price1");
  8821. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  8822. string price2 = GetPostString("price2");
  8823. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  8824. string rePrice1 = GetPostString("rePrice1");
  8825. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  8826. string rePrice2 = GetPostString("rePrice2");
  8827. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  8828. string designerType = GetPostString("designerType");
  8829. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  8830. string orderState = GetPostString("orderState");
  8831. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  8832. string endTime1 = GetPostString("endTime1");
  8833. string endTime2 = GetPostString("endTime2");
  8834. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  8835. if (dw.Length > 0) lw.Add(dw);
  8836. string isDk = GetPostString("isDk");
  8837. if (isDk == "1")
  8838. {
  8839. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  8840. }
  8841. else if (isDk == "0")
  8842. {
  8843. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  8844. }
  8845. dStruct.Order = "oid, create_time desc";
  8846. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8847. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  8848. writeGridDataTableJson(dStruct.TotalCount, dt);
  8849. }
  8850. public void upd_erp_designerbill()
  8851. {
  8852. if (UrlPostParmsCheck("ID"))
  8853. {
  8854. string eid = GetPostString("ID");
  8855. CeErpDesignerBill entity = null;
  8856. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8857. if (entity != null)
  8858. {
  8859. if (GetPostDouble("designerpirce") > 0)
  8860. {
  8861. entity.realPrice = GetPostDouble("designerpirce");
  8862. entity.update_time = DateTime.Now;
  8863. entity.update_u_id = CurrentUser.UserID;
  8864. entity.update_u_name = CurrentUser.UserName;
  8865. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  8866. entity.Update();
  8867. returnSuccessMsg("操作成功!");
  8868. return;
  8869. }
  8870. else
  8871. {
  8872. entity.price = GetPostDouble("price");
  8873. entity.update_time = DateTime.Now;
  8874. entity.update_u_id = CurrentUser.UserID;
  8875. entity.update_u_name = CurrentUser.UserName;
  8876. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  8877. entity.Update();
  8878. returnSuccessMsg("操作成功!");
  8879. return;
  8880. }
  8881. }
  8882. returnErrorMsg("找不到记录");
  8883. }
  8884. }
  8885. public void audit_erp_designerbill()
  8886. {
  8887. if (UrlPostParmsCheck("ID"))
  8888. {
  8889. string eid = GetPostString("ID");
  8890. CeErpDesignerBill entity = null;
  8891. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8892. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  8893. if (entity != null)
  8894. {
  8895. entity.realPrice = GetPostDouble("designerpirce");
  8896. entity.update_time = DateTime.Now;
  8897. entity.update_u_id = CurrentUser.UserID;
  8898. entity.update_u_name = CurrentUser.UserName;
  8899. entity.isAudit = 1;
  8900. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8901. entity.Update();
  8902. if (orderEntity != null)
  8903. {
  8904. orderEntity.IsReadTag = 3;
  8905. orderEntity.Update();
  8906. }
  8907. returnSuccessMsg("操作成功!");
  8908. return;
  8909. }
  8910. returnErrorMsg("找不到记录");
  8911. }
  8912. }
  8913. public void all_audit_erp_designerbill()
  8914. {
  8915. if (UrlPostParmsCheck("idList"))
  8916. {
  8917. string[] list = GetPostString("idList").Split(',');
  8918. CeErpDesignerBill entity = null;
  8919. for (int i = 0; i < list.Length; i++)
  8920. {
  8921. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  8922. if (entity == null) return;
  8923. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  8924. if (orderEntity == null) return;
  8925. if (entity.realPrice == 0) entity.realPrice = entity.price;
  8926. entity.update_time = DateTime.Now;
  8927. entity.update_u_id = CurrentUser.UserID;
  8928. entity.update_u_name = CurrentUser.UserName;
  8929. entity.isAudit = 1;
  8930. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8931. entity.Update();
  8932. orderEntity.IsReadTag = 3;
  8933. orderEntity.Update();
  8934. }
  8935. returnSuccessMsg("操作成功!");
  8936. return;
  8937. }
  8938. }
  8939. public void get_erp_sameorders()
  8940. {
  8941. if (UrlPostParmsCheck("ctid"))
  8942. {
  8943. string eid = GetPostString("ctid");
  8944. CeErpTradeCell entity = null;
  8945. entity = CeErpTradeCell.GetByCtid(eid);
  8946. if (entity != null)
  8947. {
  8948. StringBuilder sql = new StringBuilder();
  8949. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  8950. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8951. var res = new
  8952. {
  8953. data = dt.Rows.Count
  8954. };
  8955. string ro_jsond = JsonConvert.SerializeObject(res);
  8956. returnSuccess(ro_jsond);
  8957. return;
  8958. }
  8959. returnErrorMsg("未找到订单");
  8960. return;
  8961. }
  8962. returnErrorMsg("缺少必要的参数");
  8963. }
  8964. public void get_erp_islasthavesameorder()
  8965. {
  8966. if (UrlPostParmsCheck("ctid"))
  8967. {
  8968. string eid = GetPostString("ctid");
  8969. string[] ctidList = eid.Split(',');
  8970. StringBuilder sql = new StringBuilder();
  8971. string tisCtid = "";
  8972. foreach (string ctid in ctidList)
  8973. {
  8974. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  8975. if (entity != null)
  8976. {
  8977. sql = new StringBuilder();
  8978. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  8979. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8980. if (dth.Rows.Count > 0)
  8981. {
  8982. tisCtid += entity.ctid;
  8983. tisCtid += ",";
  8984. }
  8985. }
  8986. }
  8987. if (tisCtid.Length > 0)
  8988. {
  8989. var res = new
  8990. {
  8991. data = tisCtid
  8992. };
  8993. string ro_jsond = JsonConvert.SerializeObject(res);
  8994. returnSuccess(ro_jsond);
  8995. }
  8996. else
  8997. {
  8998. var res = new
  8999. {
  9000. data = ""
  9001. };
  9002. string ro_jsond = JsonConvert.SerializeObject(res);
  9003. returnSuccess(ro_jsond);
  9004. }
  9005. return;
  9006. }
  9007. returnErrorMsg("缺少必要的参数");
  9008. }
  9009. public void file_client_down_url()
  9010. {
  9011. if (!UrlPostParmsCheck("userId"))
  9012. {
  9013. returnErrorMsg("缺少必要的参数");
  9014. }
  9015. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9016. }
  9017. public void checkout_form_data()
  9018. {
  9019. if (!UrlPostParmsCheck("tid"))
  9020. {
  9021. returnErrorMsg("缺少必要的参数");
  9022. }
  9023. string tid = GetPostString("tid");
  9024. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9025. if (ceErpOrderFormData != null)
  9026. {
  9027. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9028. returnSuccess(ro_jsond);
  9029. return;
  9030. }
  9031. returnErrorMsg("尚未有文件!");
  9032. }
  9033. public void back_supplier_audit()
  9034. {
  9035. int userId = CurrentUser.UserID;
  9036. StringBuilder sql = new StringBuilder();
  9037. 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);
  9038. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9039. if (dt.Rows.Count > 0)
  9040. {
  9041. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9042. }
  9043. else
  9044. {
  9045. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9046. }
  9047. }
  9048. public void back_supplier_query()
  9049. {
  9050. string eid = GetPostString("ctid");
  9051. if (eid != "")
  9052. {
  9053. StringBuilder sql = new StringBuilder();
  9054. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9055. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9056. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9057. }
  9058. else
  9059. {
  9060. returnErrorMsg("找不到订单记录");
  9061. return;
  9062. }
  9063. }
  9064. public void verified_to_order()
  9065. {
  9066. int userId = CurrentUser.UserID;
  9067. StringBuilder sql = new StringBuilder();
  9068. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9069. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9070. if (dt.Rows.Count > 0)
  9071. {
  9072. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9073. }
  9074. else
  9075. {
  9076. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9077. }
  9078. }
  9079. public void upd_supplier_audit()
  9080. {
  9081. if (UrlPostParmsCheck("ctid"))
  9082. {
  9083. string eid = GetPostString("ctid");
  9084. string reason = GetPostString("returnreason");
  9085. CeErpTradeCell entity = null;
  9086. CeWithdraw withdraw = null;
  9087. withdraw = CeWithdraw.GetByTid(eid);
  9088. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9089. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9090. {
  9091. if (withdraw != null)
  9092. {
  9093. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9094. {
  9095. returnSuccessMsg("您没有权限操作!");
  9096. return;
  9097. }
  9098. else
  9099. {
  9100. if (reason.Equals("1"))
  9101. {
  9102. if (entity.OrderState == -1)
  9103. {
  9104. if (entity.FinishPlaceTime == null)
  9105. {
  9106. entity.OrderState = 2;
  9107. }
  9108. else
  9109. {
  9110. entity.OrderState = 6;
  9111. }
  9112. }
  9113. entity.Update();
  9114. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9115. if (withdraw != null)
  9116. {
  9117. withdraw.status = int.Parse(reason);
  9118. withdraw.Update();
  9119. }
  9120. returnSuccessMsg("操作成功!");
  9121. return;
  9122. }
  9123. else
  9124. {
  9125. withdraw.status = int.Parse(reason);
  9126. withdraw.acknowledgingtime = DateTime.Now;
  9127. withdraw.Update();
  9128. returnSuccessMsg("查看详细请点击线下订单查询");
  9129. return;
  9130. }
  9131. }
  9132. }
  9133. // 第一个字符是 'N'
  9134. }
  9135. if (eid[0] != 'N')
  9136. {
  9137. }
  9138. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9139. {
  9140. entity.IsVerifyToSupplier = false;
  9141. entity.IsReturn = 1;
  9142. entity.ReturnTime = DateTime.Now;
  9143. entity.ReturnReason = reason;
  9144. if (entity.OrderState == 6)
  9145. {
  9146. entity.OrderState = 5;
  9147. }
  9148. entity.Update();
  9149. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9150. if (withdraw != null)
  9151. {
  9152. withdraw.status = int.Parse(reason);
  9153. withdraw.Update();
  9154. }
  9155. returnSuccessMsg("操作成功!");
  9156. return;
  9157. }
  9158. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9159. {
  9160. ;
  9161. if (withdraw != null)
  9162. {
  9163. withdraw.status = int.Parse(reason);
  9164. withdraw.acknowledgingtime = DateTime.Now;
  9165. withdraw.Update();
  9166. returnSuccessMsg("供应商取消撤回!");
  9167. return;
  9168. }
  9169. }
  9170. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9171. {
  9172. if (entity.OrderState == -1)
  9173. {
  9174. if (entity.FinishPlaceTime == null)
  9175. {
  9176. entity.OrderState = 2;
  9177. }
  9178. else
  9179. {
  9180. entity.OrderState = 3;
  9181. }
  9182. commonHelper.getCytPrice(entity);
  9183. }
  9184. entity.Update();
  9185. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9186. if (withdraw != null)
  9187. {
  9188. withdraw.status = int.Parse(reason);
  9189. withdraw.Update();
  9190. }
  9191. returnSuccessMsg("操作成功!");
  9192. return;
  9193. }
  9194. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9195. {
  9196. if (withdraw == null)
  9197. {
  9198. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9199. return;
  9200. }
  9201. }
  9202. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9203. {
  9204. if (withdraw != null)
  9205. {
  9206. withdraw.status = int.Parse(reason);
  9207. withdraw.acknowledgingtime = DateTime.Now;
  9208. withdraw.Update();
  9209. returnSuccessMsg("查看详细请点击线下订单查询");
  9210. return;
  9211. }
  9212. }
  9213. return;
  9214. }
  9215. }
  9216. //校验报价
  9217. public void refund_order_tip()
  9218. {
  9219. int userid = CurrentUser.UserID;
  9220. int sectionId = CurrentUser.UserPost.OrgID;
  9221. StringBuilder sql = new StringBuilder();
  9222. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9223. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9224. List<string> ids = new List<string>();
  9225. if (dth.Rows.Count > 0)
  9226. {
  9227. foreach (DataRow dr in dth.Rows)
  9228. {
  9229. ids.Add(dr["ID"].ToString());
  9230. }
  9231. try
  9232. {
  9233. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9234. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9235. }
  9236. catch (Exception ex)
  9237. {
  9238. }
  9239. }
  9240. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9241. }
  9242. public void refund_order_Design()
  9243. {
  9244. int userid = CurrentUser.UserID;
  9245. int sectionId = CurrentUser.UserPost.OrgID;
  9246. StringBuilder sql = new StringBuilder();
  9247. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9248. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9249. List<string> ids = new List<string>();
  9250. if (dth.Rows.Count > 0)
  9251. {
  9252. foreach (DataRow dr in dth.Rows)
  9253. {
  9254. ids.Add(dr["ID"].ToString());
  9255. }
  9256. try
  9257. {
  9258. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9259. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9260. }
  9261. catch (Exception ex)
  9262. {
  9263. }
  9264. }
  9265. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9266. }
  9267. public void change_order_info()
  9268. {
  9269. int userid = CurrentUser.UserID;
  9270. StringBuilder sql = new StringBuilder();
  9271. 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);
  9272. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9273. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9274. }
  9275. public void change_win_mome()
  9276. {
  9277. if (UrlPostParmsCheck("id,ctid"))
  9278. {
  9279. string id = GetPostString("id");
  9280. string ctid = GetPostString("ctid");
  9281. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9282. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9283. if (ce == null || ceErpMessageTip == null)
  9284. {
  9285. returnSuccessMsg("未找到对应的订单!");
  9286. return;
  9287. }
  9288. int type = GetPostInt("type");
  9289. string content = GetPostString("content");
  9290. if (type == 0)
  9291. {
  9292. content = content.Replace("(", "(");
  9293. content = content.Replace(")", ")");
  9294. string check = MidStrEx(content, "(", ")").Trim();
  9295. if (string.IsNullOrEmpty(check))
  9296. {
  9297. returnSuccessMsg("文件名格式不正确");
  9298. return;
  9299. }
  9300. }
  9301. ce.seller_memo = content;
  9302. ce.Update();
  9303. ceErpMessageTip.isVisit = true;
  9304. ceErpMessageTip.Update();
  9305. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9306. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9307. ApiVo apiVo = new ApiVo();
  9308. apiVo.orderNumber = ce.ctid;
  9309. apiVo.actionName = "demandDesign";
  9310. apiVo.orderRemarks = content;
  9311. apiVo.demandExamine = type + 1;
  9312. designHelper.API_WorkCore(apiVo);//demandDesign
  9313. returnSuccessMsg("修改成功!");
  9314. }
  9315. }
  9316. public static string MidStrEx(string sourse, string startstr, string endstr)
  9317. {
  9318. string result = string.Empty;
  9319. int startindex, endindex;
  9320. try
  9321. {
  9322. startindex = sourse.IndexOf(startstr);
  9323. if (startindex == -1)
  9324. return result;
  9325. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9326. endindex = tmpstr.IndexOf(endstr);
  9327. if (endindex == -1)
  9328. return result;
  9329. result = tmpstr.Remove(endindex);
  9330. }
  9331. catch (Exception ex)
  9332. {
  9333. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9334. }
  9335. return result;
  9336. }
  9337. public void refund_order_list()
  9338. {
  9339. int userid = CurrentUser.UserID;
  9340. int sectionId = CurrentUser.UserPost.OrgID;
  9341. StringBuilder sql = new StringBuilder();
  9342. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9343. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9344. DataStruct dStruct = GetPostStruct();
  9345. DataTable dt = null;
  9346. List<string> ids = new List<string>();
  9347. List<string> tids = new List<string>();
  9348. if (dth.Rows.Count > 0)
  9349. {
  9350. foreach (DataRow dr in dth.Rows)
  9351. {
  9352. tids.Add("'" + dr["tid"].ToString() + "'");
  9353. ids.Add(dr["id"].ToString());
  9354. }
  9355. try
  9356. {
  9357. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9358. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9359. List<string> lw = new List<string>();
  9360. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9361. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9362. dt = WebCache.GetData("view_orderlist", dStruct);
  9363. }
  9364. catch (Exception ex)
  9365. {
  9366. }
  9367. }
  9368. writeGridDataTableJson(dStruct.TotalCount, dt);
  9369. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9370. }
  9371. //新增
  9372. public void order_batch_downloads()
  9373. {
  9374. string ceid = GetPostString("tid");
  9375. String[] tid = ceid.Split(',');
  9376. order_batch_caiyingtong(tid);
  9377. /* (string success, string errors) = UploadFiles(tid);
  9378. returnSuccessMsg(success + errors);*/
  9379. return;
  9380. }
  9381. //报价接口
  9382. public void Get_To_Quote()
  9383. {
  9384. string ceid = GetPostString("ctid");
  9385. if (ceid != null)
  9386. {
  9387. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9388. if (entity != null)
  9389. {
  9390. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9391. {
  9392. return;
  9393. }
  9394. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9395. double price = 0;
  9396. if (cp == null)
  9397. {
  9398. JObject jsonObject12 = new JObject
  9399. {
  9400. { "UserId", "77886" },
  9401. { "Pwd", "lt666888" },
  9402. { "Filename", entity.seller_memo }
  9403. };
  9404. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9405. JObject jsonObjects1 = JObject.Parse(response1);
  9406. string ms1g = (string)jsonObjects1["msg"];
  9407. if (ms1g == "报价成功")
  9408. {
  9409. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9410. string data = (string)jsonObject1["price"];
  9411. 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 + "');";
  9412. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9413. returnSuccessMsg("获取报价成功:" + data);
  9414. price = Convert.ToDouble(data);
  9415. }
  9416. else
  9417. {
  9418. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9419. return;
  9420. }
  9421. }
  9422. String[] beizhu = entity.seller_memo.Split('-');
  9423. String chanp = "";
  9424. if (beizhu.Length > 0)
  9425. {
  9426. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9427. }
  9428. else
  9429. {
  9430. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9431. }
  9432. JObject jsonObject = new JObject
  9433. {
  9434. { "UserId", "77886" },
  9435. { "Pwd", "lt666888" },
  9436. { "Filename", chanp }
  9437. };
  9438. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9439. JObject jsonObjects = JObject.Parse(response);
  9440. string msg = (string)jsonObjects["msg"];
  9441. if (msg == "报价成功")
  9442. {
  9443. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9444. string data = (string)jsonObject1["price"];
  9445. 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 + "');";
  9446. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9447. returnSuccessMsg("获取报价成功:" + data);
  9448. price = Convert.ToDouble(data);
  9449. }
  9450. else
  9451. {
  9452. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9453. return;
  9454. }
  9455. if (price > 0)
  9456. {
  9457. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9458. if (ceErpTradeCellExtend == null)
  9459. {
  9460. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9461. ceErpTradeCellExtend.ctid = entity.ctid;
  9462. ceErpTradeCellExtend.payment_cyt = price;
  9463. ceErpTradeCellExtend.Create();
  9464. }
  9465. else
  9466. {
  9467. ceErpTradeCellExtend.payment_cyt = price;
  9468. ceErpTradeCellExtend.Update();
  9469. }
  9470. }
  9471. return;
  9472. }
  9473. }
  9474. else
  9475. {
  9476. returnErrorMsg("请至少选择一条数据");
  9477. return;
  9478. }
  9479. }
  9480. //新增
  9481. public void order_To_Supplier()
  9482. {
  9483. string ceid = GetPostString("tid");
  9484. String[] tid = ceid.Split(',');
  9485. if (tid.Length > 0)
  9486. {
  9487. try
  9488. {
  9489. for (int i = 0; i < tid.Length; i++)
  9490. {
  9491. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9492. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9493. entity.SupplierId = suid;
  9494. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9495. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9496. entity.Update();
  9497. }
  9498. }
  9499. catch (Exception ex)
  9500. {
  9501. returnErrorMsg("自动匹配供应商失败");
  9502. return;
  9503. }
  9504. }
  9505. else
  9506. {
  9507. returnErrorMsg("请至少选择一条数据");
  9508. return;
  9509. }
  9510. returnSuccessMsg("自动匹配供应商成功");
  9511. return;
  9512. }
  9513. public (string, string) UploadFiles(string[] urls)
  9514. {
  9515. string success = "";
  9516. string errors = "";
  9517. int userid = CurrentUser.UserID;
  9518. foreach (string url in urls)
  9519. {
  9520. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9521. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9522. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9523. {
  9524. JObject jsonObject = new JObject
  9525. {
  9526. { "Userid", "77886" },
  9527. { "pwd", "cyt86435015" },
  9528. { "content", base64FileContent },
  9529. { "ext", Path.GetExtension(fileName) }
  9530. };
  9531. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9532. JObject jsonObjects = JObject.Parse(response);
  9533. string msg = (string)jsonObjects["msg"];
  9534. if (msg.Equals("上传成功"))
  9535. {
  9536. success += url + " 上传成功";
  9537. }
  9538. else
  9539. {
  9540. errors += url + " 上传失败";
  9541. }
  9542. }
  9543. else
  9544. {
  9545. errors += url + " 格式出现问题";
  9546. }
  9547. }
  9548. if (urls.Length == 0)
  9549. {
  9550. return (success, errors);
  9551. }
  9552. return (success, errors);
  9553. }
  9554. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9555. {
  9556. return true; //总是接受
  9557. }
  9558. public static string HttpPost(string url, string param = null)
  9559. {
  9560. HttpWebRequest request;
  9561. //如果是发送HTTPS请求
  9562. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9563. {
  9564. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9565. request = WebRequest.Create(url) as HttpWebRequest;
  9566. request.ProtocolVersion = HttpVersion.Version10;
  9567. }
  9568. else
  9569. {
  9570. request = WebRequest.Create(url) as HttpWebRequest;
  9571. }
  9572. request.Method = "POST";
  9573. request.ContentType = "application/json";
  9574. request.Accept = "*/*";
  9575. request.Timeout = 120000;
  9576. request.AllowAutoRedirect = false;
  9577. StreamWriter requestStream = null;
  9578. WebResponse response = null;
  9579. string responseStr = null;
  9580. try
  9581. {
  9582. requestStream = new StreamWriter(request.GetRequestStream());
  9583. requestStream.Write(param);
  9584. requestStream.Close();
  9585. response = request.GetResponse();
  9586. if (response != null)
  9587. {
  9588. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9589. responseStr = reader.ReadToEnd();
  9590. reader.Close();
  9591. }
  9592. }
  9593. catch (Exception ex)
  9594. {
  9595. return ex.Message;
  9596. }
  9597. finally
  9598. {
  9599. request = null;
  9600. requestStream = null;
  9601. response = null;
  9602. }
  9603. return responseStr;
  9604. }
  9605. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9606. {
  9607. string base64FileContent;
  9608. string fileName;
  9609. using (WebClient webClient = new WebClient())
  9610. {
  9611. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9612. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9613. {
  9614. using (Stream stream = response.GetResponseStream())
  9615. {
  9616. using (MemoryStream memoryStream = new MemoryStream())
  9617. {
  9618. stream.CopyTo(memoryStream);
  9619. byte[] fileBytes = memoryStream.ToArray();
  9620. base64FileContent = Convert.ToBase64String(fileBytes);
  9621. fileName = response.Headers["Content-Disposition"];
  9622. if (!string.IsNullOrEmpty(fileName))
  9623. {
  9624. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9625. if (index >= 0)
  9626. {
  9627. fileName = fileName.Substring(index + 9).Trim('\"');
  9628. }
  9629. }
  9630. else
  9631. {
  9632. fileName = Path.GetFileName(downloadUrl);
  9633. }
  9634. }
  9635. }
  9636. }
  9637. }
  9638. return (fileName, base64FileContent);
  9639. }
  9640. //新增
  9641. public void order_batch_caiyingtong(string[] downloadUrls)
  9642. {
  9643. try
  9644. {
  9645. //遍历文件
  9646. DataStruct dStruct = GetPostStruct();
  9647. DataTable dt = null;
  9648. int userid = CurrentUser.UserID;
  9649. List<string> ids = new List<string>();//失败组
  9650. List<string> tids = new List<string>();
  9651. using (WebClient webClient = new WebClient())
  9652. {
  9653. foreach (var url in downloadUrls)
  9654. {
  9655. try
  9656. {
  9657. tids.Add("'" + url + "'");
  9658. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9659. if (entity != null)
  9660. {
  9661. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9662. if (cp == null)
  9663. {
  9664. JObject jsonObject = new JObject
  9665. {
  9666. { "Userid", "77886" },
  9667. { "pwd", "lt666888" },
  9668. { "Filename",entity.seller_memo }
  9669. };
  9670. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9671. JObject jsonObjects = JObject.Parse(response);
  9672. string msg = (string)jsonObjects["msg"];
  9673. if (msg == "报价成功")
  9674. {
  9675. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9676. DownloadAndConvertToBase64(url1);
  9677. }
  9678. else
  9679. {
  9680. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9681. }
  9682. }
  9683. else
  9684. {
  9685. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9686. JObject jsonObject = new JObject
  9687. {
  9688. { "Userid", "77886" },
  9689. { "pwd", "lt666888" },
  9690. { "Filename",chanp }
  9691. };
  9692. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9693. JObject jsonObjects = JObject.Parse(response);
  9694. string msg = (string)jsonObjects["msg"];
  9695. if (msg == "报价成功")
  9696. {
  9697. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9698. DownloadAndConvertToBase64(url1);
  9699. }
  9700. else
  9701. {
  9702. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9703. }
  9704. }
  9705. }
  9706. // 上传文件到FTP
  9707. }
  9708. catch (Exception ex)
  9709. {
  9710. Console.WriteLine($"An error occurred: {ex.Message}");
  9711. }
  9712. }
  9713. List<string> lw = new List<string>();
  9714. lw.Add(string.Format("( OrderState < 6 )"));
  9715. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9716. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9717. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9718. if (dt.Rows.Count > 0)
  9719. {
  9720. foreach (DataRow dr in dt.Rows)
  9721. {
  9722. ids.Add(dr["ctid"].ToString());
  9723. }
  9724. }
  9725. String ErrorMsgs = "";
  9726. foreach (String id in ids)
  9727. {
  9728. ErrorMsgs += id + ",";
  9729. }
  9730. if (ErrorMsgs.Length > 1)
  9731. {
  9732. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9733. }
  9734. if (ErrorMsgs.Length < 1)
  9735. {
  9736. ErrorMsgs = "上传成功";
  9737. returnSuccessMsg(ErrorMsgs);
  9738. }
  9739. else
  9740. {
  9741. returnErrorMsg("以下订单" + ErrorMsgs);
  9742. }
  9743. }
  9744. // 删除文件夹及其内容
  9745. /* Directory.Delete(localDirectory, true);*/
  9746. }
  9747. catch { }
  9748. }
  9749. public void get_center_data()
  9750. {
  9751. int userId = CurrentUser.UserID;
  9752. string postCode = CurrentUser.UserPost.Post.Code;
  9753. List<string> lw = new List<string>();
  9754. List<string> ww = new List<string>();
  9755. DateTime currentTime = DateTime.Now;
  9756. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9757. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9758. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9759. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9760. string sql = " SELECT ";
  9761. string startTime = "2023-10-01 11:22:31";
  9762. //设计
  9763. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9764. {
  9765. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9766. 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));
  9767. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9768. 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));
  9769. }
  9770. //客服
  9771. else if (postCode == "CustomerService" || postCode == "Director")
  9772. {
  9773. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9774. 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));
  9775. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9776. 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));
  9777. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9778. 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));
  9779. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9780. 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));
  9781. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9782. 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));
  9783. }
  9784. //售后
  9785. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9786. {
  9787. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9788. 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));
  9789. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9790. 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));
  9791. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9792. ww.Add(string.Format("( SELECT COUNT ( * ) AS checkCount FROM CE_ErpTradeCell WHERE CheckOrderTime < '{1}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND pay_time > '{0}' ) AS cc", startTime, checkOrderTime));
  9793. }
  9794. //下单部
  9795. else if (postCode == "Place" || postCode == "PlaceMr")
  9796. {
  9797. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9798. 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));
  9799. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9800. 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));
  9801. }
  9802. //车间
  9803. else if (postCode == "Supplier")
  9804. {
  9805. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9806. 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));
  9807. }
  9808. DataTable dt = new DataTable();
  9809. if (lw.Count > 0)
  9810. {
  9811. sql += string.Join(" , ", lw);
  9812. sql += " FROM ";
  9813. sql += string.Join(" , ", ww);
  9814. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9815. }
  9816. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9817. }
  9818. public void get_center_data_list()
  9819. {
  9820. int userId = CurrentUser.UserID;
  9821. string postCode = CurrentUser.UserPost.Post.Code;
  9822. string shopIds = CurrentUser.User.pemShop;
  9823. DataStruct dStruct = GetPostStruct();
  9824. List<string> lw = new List<string>();
  9825. DateTime currentTime = DateTime.Now;
  9826. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9827. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9828. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9829. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9830. string startTime = "2023-10-01 11:22:31";
  9831. int order_type = GetPostInt("order_type");
  9832. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9833. {
  9834. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  9835. if (order_type == 0)
  9836. {
  9837. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9838. }
  9839. else if (order_type == 3)
  9840. {
  9841. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  9842. }
  9843. else
  9844. {
  9845. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9846. }
  9847. }
  9848. //客服
  9849. if (postCode == "CustomerService" || postCode == "Director")
  9850. {
  9851. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  9852. if (order_type == 0)
  9853. {
  9854. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9855. }
  9856. else if (order_type == 1)
  9857. {
  9858. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9859. }
  9860. else if (order_type == 2)
  9861. {
  9862. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9863. }
  9864. else if (order_type == 3)
  9865. {
  9866. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  9867. }
  9868. else if (order_type == 4)
  9869. {
  9870. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9871. }
  9872. else
  9873. {
  9874. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9875. }
  9876. }
  9877. //售后
  9878. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9879. {
  9880. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9881. if (shopIds != "")
  9882. {
  9883. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9884. }
  9885. if (order_type == 2)
  9886. {
  9887. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9888. }
  9889. else if (order_type == 4)
  9890. {
  9891. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9892. }
  9893. else if (order_type == 5)
  9894. {
  9895. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  9896. }
  9897. else
  9898. {
  9899. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9900. }
  9901. }
  9902. //下单部
  9903. if (postCode == "Place" || postCode == "PlaceMr")
  9904. {
  9905. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9906. if (shopIds != "")
  9907. {
  9908. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9909. }
  9910. else if (order_type == 1)
  9911. {
  9912. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9913. }
  9914. else if (order_type == 2)
  9915. {
  9916. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9917. }
  9918. else
  9919. {
  9920. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9921. }
  9922. }
  9923. //车间
  9924. if (postCode == "Supplier")
  9925. {
  9926. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9927. if (order_type == 5)
  9928. {
  9929. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  9930. }
  9931. else
  9932. {
  9933. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9934. }
  9935. }
  9936. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9937. dStruct.Fileds = "tid,ctid";
  9938. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  9939. writeGridDataTableJson(dStruct.TotalCount, dt);
  9940. }
  9941. public void aftersale_audit_master()
  9942. {
  9943. if (UrlPostParmsCheck("ctid"))
  9944. {
  9945. string ctid = GetPostString("ctid");
  9946. if (ctid.Length > 0)
  9947. {
  9948. bool result = aftersale_data_change(ctid);
  9949. if (result)
  9950. {
  9951. returnSuccessMsg("修改成功!");
  9952. return;
  9953. }
  9954. }
  9955. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9956. }
  9957. }
  9958. public void aftersale_batch_audit_master()
  9959. {
  9960. if (UrlPostParmsCheck("ctids"))
  9961. {
  9962. string ctids = GetPostString("ctids");
  9963. if (ctids.Length > 0)
  9964. {
  9965. List<string> list = new List<string>();
  9966. string[] ctid_list = ctids.Split(',');
  9967. foreach (var item in ctid_list)
  9968. {
  9969. bool result = aftersale_data_change(item);
  9970. if (!result)
  9971. {
  9972. list.Add(item);
  9973. }
  9974. }
  9975. if (list.Count > 0)
  9976. {
  9977. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  9978. return;
  9979. }
  9980. returnSuccessMsg("修改成功!");
  9981. return;
  9982. }
  9983. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9984. }
  9985. }
  9986. public bool aftersale_data_change(string ctid)
  9987. {
  9988. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  9989. if (ceErpTradeCell != null)
  9990. {
  9991. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  9992. ceErpTradeCell.AfterSaleSupplierState = 0;
  9993. StringBuilder sql = new StringBuilder();
  9994. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  9995. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9996. CeErpTradeResponsible.DelByTid(ctid, 0);
  9997. 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 == "不理赔")
  9998. {
  9999. CeErpTradeResponsible.DelByTid(ctid, 1);
  10000. ceErpTradeCell.AfterSaleSupplierState = 1;
  10001. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10002. ceErpTradeCell.AfterSaleState = 4;
  10003. }
  10004. else
  10005. {
  10006. ceErpTradeCell.AfterSaleState = 3;
  10007. }
  10008. bool needCyt = false;
  10009. if (dt != null)
  10010. {
  10011. if (dt.Rows.Count == 1)
  10012. {
  10013. bool isEnd = false;
  10014. foreach (DataRow dr in dt.Rows)
  10015. {
  10016. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10017. {
  10018. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10019. isEnd = true;
  10020. }
  10021. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10022. {
  10023. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10024. isEnd = true;
  10025. }
  10026. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10027. {
  10028. needCyt = true;
  10029. }
  10030. }
  10031. if (isEnd)
  10032. {
  10033. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10034. ceErpTradeCell.AfterSaleState = 4;
  10035. ceErpTradeCell.AfterSaleSupplierState = 1;
  10036. }
  10037. }
  10038. else
  10039. {
  10040. bool isAll = true;
  10041. foreach (DataRow dr in dt.Rows)
  10042. {
  10043. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10044. {
  10045. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10046. continue;
  10047. }
  10048. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10049. {
  10050. string path = "";
  10051. int OrgID = 0;
  10052. if (!Convert.IsDBNull(dr["OrgPath"]))
  10053. {
  10054. path = dr["OrgPath"].ToString();
  10055. }
  10056. if (!Convert.IsDBNull(dr["OrgID"]))
  10057. {
  10058. OrgID = Convert.ToInt32(dr["OrgID"]);
  10059. }
  10060. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10061. {
  10062. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10063. continue;
  10064. }
  10065. }
  10066. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10067. {
  10068. needCyt = true;
  10069. }
  10070. isAll = false;
  10071. }
  10072. if (isAll)
  10073. {
  10074. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10075. ceErpTradeCell.AfterSaleState = 4;
  10076. ceErpTradeCell.AfterSaleSupplierState = 1;
  10077. }
  10078. }
  10079. }
  10080. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10081. {
  10082. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10083. }
  10084. if (ceErpTradeCell.AfterSaleState == 4)
  10085. {
  10086. ApiVo apiVo = new ApiVo();
  10087. apiVo.orderNumber = ceErpTradeCell.ctid;
  10088. apiVo.actionName = "afterOver";
  10089. designHelper.API_WorkCore(apiVo); //afterOver
  10090. }
  10091. ceErpTradeCell.Update();
  10092. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10093. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10094. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10095. return true;
  10096. }
  10097. return false;
  10098. }
  10099. public void get_erp_wechatorder()
  10100. {
  10101. DataStruct dStruct = GetPostStruct();
  10102. List<string> lw = new List<string>();
  10103. string tid = GetPostString("tid");
  10104. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10105. string shopname = GetPostString("shopname");
  10106. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10107. string buyernick = GetPostString("buyer_nick");
  10108. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10109. string customer = GetPostString("customer");
  10110. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10111. string returndate1 = GetPostString("returndate1");
  10112. string returndate2 = GetPostString("returndate2");
  10113. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10114. if (dw.Length > 0) lw.Add(dw);
  10115. string finishDate1 = GetPostString("finishdate1");
  10116. string finishDate2 = GetPostString("finishdate2");
  10117. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10118. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10119. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10120. dStruct.Order = "created desc";
  10121. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10122. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10123. writeGridDataTableJson(dStruct.TotalCount, dt);
  10124. }
  10125. public void get_erp_wechatlist_sumprice()
  10126. {
  10127. DataStruct dStruct = GetPostStruct();
  10128. List<string> lw = new List<string>();
  10129. string tid = GetPostString("tid");
  10130. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10131. string shopname = GetPostString("shopname");
  10132. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10133. string buyernick = GetPostString("buyer_nick");
  10134. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10135. string customer = GetPostString("customer");
  10136. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10137. string returndate1 = GetPostString("returndate1");
  10138. string returndate2 = GetPostString("returndate2");
  10139. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10140. if (dw.Length > 0) lw.Add(dw);
  10141. string finishDate1 = GetPostString("finishdate1");
  10142. string finishDate2 = GetPostString("finishdate2");
  10143. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10144. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10145. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10146. string mainWhere = string.Join(" and ", lw.ToArray());
  10147. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10148. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10149. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10150. decimal total = 0;
  10151. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10152. {
  10153. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10154. }
  10155. var res = new
  10156. {
  10157. data = total
  10158. };
  10159. string ro_jsond = JsonConvert.SerializeObject(res);
  10160. returnSuccess(ro_jsond);
  10161. return;
  10162. }
  10163. public void get_erp_qr_waitdeliverylist()
  10164. {
  10165. DataStruct dStruct = GetPostStruct();
  10166. List<string> lw = new List<string>();
  10167. string tid = GetPostString("ctid");
  10168. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10169. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10170. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10171. var res_objz = new
  10172. {
  10173. restype = 1,
  10174. data = dt
  10175. };
  10176. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10177. returnSuccess(ro_jsonz);
  10178. }
  10179. public void get_erp_yield_list()
  10180. {
  10181. DataStruct dStruct = GetPostStruct();
  10182. List<string> lw = new List<string>();
  10183. string tid = GetPostString("ctid");
  10184. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10185. string shopname = GetPostString("shopname");
  10186. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10187. string buyernick = GetPostString("buyer_nick");
  10188. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10189. //if (tid.Length == 0 && buyernick.Length == 0)
  10190. //{
  10191. // lw.Add(string.Format("IsRefund<={0}", 1));
  10192. //}
  10193. string customer = GetPostString("customer");
  10194. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10195. string design = GetPostString("design");
  10196. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10197. string orderState = GetPostString("orderState");
  10198. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10199. string address = GetPostString("address");
  10200. 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));
  10201. string sellermemo = GetPostString("seller_memo");
  10202. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10203. string supplier = GetPostString("supplier");
  10204. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10205. string OrderArea = GetPostString("order_area");
  10206. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10207. string placedate1 = GetPostString("placedate1");
  10208. string placedate2 = GetPostString("placedate2");
  10209. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10210. if (fdw.Length > 0) lw.Add(fdw);
  10211. string price1 = GetPostString("price1");
  10212. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10213. string price2 = GetPostString("price2");
  10214. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10215. string unusualCon = GetPostString("unusualcon");
  10216. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10217. string posTag = CurrentUser.UserPost.Post.Code;
  10218. if (posTag == "Supplier")
  10219. {
  10220. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10221. }
  10222. lw.Add(string.Format("OrderState = 6 "));
  10223. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10224. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10225. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10226. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10227. writeGridDataTableJson(dStruct.TotalCount, dt);
  10228. }
  10229. public void change_erp_sup_state()
  10230. {
  10231. if (UrlPostParmsCheck("ctid"))
  10232. {
  10233. string ctid = GetPostString("ctid");
  10234. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10235. if (ceErpTradeCell != null)
  10236. {
  10237. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10238. if (ceErpTradeCellExtend == null)
  10239. {
  10240. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10241. ceErpTradeCellExtend.ctid = ctid;
  10242. ceErpTradeCellExtend.SupState = 1;
  10243. ceErpTradeCellExtend.Create();
  10244. }
  10245. else
  10246. {
  10247. ceErpTradeCellExtend.SupState = 1;
  10248. ceErpTradeCellExtend.Update();
  10249. }
  10250. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10251. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10252. return;
  10253. }
  10254. returnErrorMsg("找不到订单");
  10255. }
  10256. }
  10257. public void supplier_all_downs()
  10258. {
  10259. if (UrlPostParmsCheck("tids"))
  10260. {
  10261. string tids = GetPostString("tids");
  10262. if (tids != null && tids.Length > 0)
  10263. {
  10264. StringBuilder sql = new StringBuilder();
  10265. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10266. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10267. sql = new StringBuilder();
  10268. 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, "下载设计文件");
  10269. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10270. string[] list = tids.Split(',');
  10271. foreach (string ctid in list)
  10272. {
  10273. CeErpSukuraData.createInfo(ctid, 3);
  10274. }
  10275. designHelper.api_approveDesign(tids); //approveDesign
  10276. returnSuccessMsg("下载成功!");
  10277. return;
  10278. }
  10279. returnErrorMsg("下载订单更新失败");
  10280. }
  10281. }
  10282. public void uploaderFileSuccess()
  10283. {
  10284. if (UrlPostParmsCheck("fileName"))
  10285. {
  10286. string fileName = GetPostString("fileName");
  10287. ApiVo apiVo = new ApiVo();
  10288. apiVo.orderNumber = fileName;
  10289. apiVo.actionName = "finishDesign";
  10290. designHelper.API_WorkCore(apiVo);//finishDesign
  10291. returnSuccessMsg("");
  10292. }
  10293. }
  10294. public void get_sample2_order()
  10295. {
  10296. if (UrlPostParmsCheck("ctid"))
  10297. {
  10298. string ctid = GetPostString("ctid");
  10299. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10300. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10301. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10302. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10303. double total = 0.0;
  10304. double order_price = 0.0;
  10305. if (dt_bu.Rows.Count > 0)
  10306. {
  10307. foreach (DataRow dr in dt_bu.Rows)
  10308. {
  10309. total += Convert.ToDouble(dr["payment"]);
  10310. }
  10311. }
  10312. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10313. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10314. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10315. string tid = ctid.Replace("S_", "");
  10316. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10317. double paymant = 0.0;
  10318. if (entity != null)
  10319. {
  10320. paymant = entity.payment;
  10321. }
  10322. string return_reason = "";
  10323. if (dt_after != null && dt_after.Rows.Count > 0)
  10324. {
  10325. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10326. }
  10327. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10328. }
  10329. }
  10330. public void get_erp_design_status()
  10331. {
  10332. string designName = GetPostString("designName");
  10333. DataStruct dStruct = GetPostStruct();
  10334. if (designName.Length > 0)
  10335. {
  10336. 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";
  10337. sql_user += " and Name like '%" + designName + "%'";
  10338. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10339. List<string> ids_list = new List<string>();
  10340. if (user_table.Rows.Count > 0)
  10341. {
  10342. foreach (DataRow item in user_table.Rows)
  10343. {
  10344. ids_list.Add(item["id"].ToString());
  10345. string ids_s = item["TeamIds"].ToString();
  10346. if (ids_s.Length > 0)
  10347. {
  10348. ids_list.AddRange(ids_s.Split(','));
  10349. }
  10350. }
  10351. }
  10352. HashSet<string> set = new HashSet<string>(ids_list);
  10353. ids_list = set.ToList();
  10354. if (ids_list.Count > 0)
  10355. {
  10356. 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));
  10357. dStruct.MainWhere = sql;
  10358. DataTable dt = null;
  10359. dt = WebCache.GetData("view_ErpUser", dStruct);
  10360. writeGridDataTableJson(dStruct.TotalCount, dt);
  10361. }
  10362. }
  10363. }
  10364. public void change_erp_order_price()
  10365. {
  10366. string ctid = GetPostString("ctid");
  10367. double price = GetPostDouble("price");
  10368. if (ctid.Length > 0)
  10369. {
  10370. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10371. if (ceErpTradeCellExtend == null)
  10372. {
  10373. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10374. ceErpTradeCellExtend.ctid = ctid;
  10375. ceErpTradeCellExtend.payment_cyt = price;
  10376. ceErpTradeCellExtend.Create();
  10377. }
  10378. else
  10379. {
  10380. ceErpTradeCellExtend.payment_cyt = price;
  10381. ceErpTradeCellExtend.Update();
  10382. }
  10383. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10384. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10385. {
  10386. ceErpDataSendOrderInfo.isSync = false;
  10387. ceErpDataSendOrderInfo.Update();
  10388. }
  10389. if (ceErpDataSendOrderInfo == null)
  10390. {
  10391. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10392. ceErpDataSendOrderInfo.isSync = false;
  10393. ceErpDataSendOrderInfo.ctid = ctid;
  10394. ceErpDataSendOrderInfo.Create();
  10395. }
  10396. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10397. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10398. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10399. if (dth != null && dth.Rows.Count > 0)
  10400. {
  10401. dataSendOrderBean dataSendOrderBean = null;
  10402. foreach (DataRow item in dth.Rows)
  10403. {
  10404. try
  10405. {
  10406. dataSendOrderBean = new dataSendOrderBean();
  10407. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10408. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10409. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10410. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10411. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10412. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10413. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10414. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10415. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10416. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10417. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10418. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10419. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10420. if (result != null)
  10421. {
  10422. if ("0".Equals(result.errcode))
  10423. {
  10424. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10425. }
  10426. else
  10427. {
  10428. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10429. }
  10430. }
  10431. }
  10432. catch (Exception ex)
  10433. {
  10434. }
  10435. }
  10436. }
  10437. returnSuccessMsg("修改成功!");
  10438. return;
  10439. }
  10440. returnErrorMsg("找不到订单");
  10441. }
  10442. public void find_he_together()
  10443. {
  10444. string ctid = GetPostString("ctid");
  10445. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10446. List<string> list = new List<string>();
  10447. if (ceErpTradeCell != null)
  10448. {
  10449. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10450. {
  10451. 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);
  10452. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10453. if (table != null && table.Rows.Count > 0)
  10454. {
  10455. foreach (TableRow row in table.Rows)
  10456. {
  10457. }
  10458. }
  10459. }
  10460. }
  10461. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10462. }
  10463. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10464. {
  10465. //chy----19
  10466. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10467. //GD-CYT-----64
  10468. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10469. //ZHX----3
  10470. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10471. //JK----97
  10472. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10473. //ZT----70
  10474. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10475. //LHCY-----98
  10476. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10477. //XD-----90
  10478. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10479. //CYCY-----14
  10480. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10481. };
  10482. //其他改名
  10483. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10484. {
  10485. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10486. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10487. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10488. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10489. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10490. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10491. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10492. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10493. };
  10494. //不统计
  10495. List<int> no_suppliers = new List<int>()
  10496. {
  10497. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10498. };
  10499. //配件单
  10500. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10501. {
  10502. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10503. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10504. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10505. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10506. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10507. {"旗杆",new List<string>(){ "班旗" } },
  10508. {"牙签",new List<string>(){ "不干胶" } }
  10509. };
  10510. public void get_place_order_data()
  10511. {
  10512. string date1 = GetPostString("date1");
  10513. string date2 = GetPostString("date2");
  10514. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10515. DateTime start = DateTime.Parse(starttime);
  10516. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10517. DateTime end = DateTime.Parse(endtime);
  10518. if (date1 != null && date1.Length > 0)
  10519. {
  10520. DateTime dateTime = DateTime.Parse(date1);
  10521. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10522. start = DateTime.Parse(starttime);
  10523. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10524. end = DateTime.Parse(endtime);
  10525. }
  10526. if (date2 != null && date2.Length > 0)
  10527. {
  10528. DateTime dateTime = DateTime.Parse(date2);
  10529. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10530. end = DateTime.Parse(endtime);
  10531. }
  10532. 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);
  10533. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10534. //不干胶-----1,卡片-----29
  10535. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10536. foreach (DataRow row in data.Rows)
  10537. {
  10538. int productId = Convert.ToInt32(row["ProductId"]);
  10539. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10540. if (no_suppliers.Contains(supplierId))
  10541. {
  10542. continue;
  10543. }
  10544. string seller_memo = row["seller_memo"].ToString();
  10545. bool ispj = false;//是否配件单
  10546. bool isfirst = true;//第一个配
  10547. maps.Keys.ForEach(key =>
  10548. {
  10549. //备注包含配件
  10550. if (seller_memo.Contains(key) && isfirst)
  10551. {
  10552. List<string> list = maps[key];
  10553. ispj = true;
  10554. isfirst = false;
  10555. for (int i = 0; i < list.Count; i++)
  10556. {
  10557. if (seller_memo.Contains(list[i]))
  10558. {
  10559. ispj = false;
  10560. break;
  10561. }
  10562. }
  10563. }
  10564. });
  10565. if (ispj)
  10566. {
  10567. continue;
  10568. }
  10569. seller_memo = seller_memo.Replace("UV", "uv");
  10570. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10571. //吊牌归到卡片
  10572. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10573. seller_memo = seller_memo.Replace("卡套", "卡片");
  10574. seller_memo = seller_memo.Replace("封套", "卡片");
  10575. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10576. seller_memo = seller_memo.Replace("腰封", "卡片");
  10577. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10578. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10579. seller_memo = seller_memo.Replace("横幅", "条幅");
  10580. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10581. string map_key = "";
  10582. string type = "";
  10583. if (supplierMap.ContainsKey(supplierId))
  10584. {
  10585. foreach (var kvp in supplierMap[supplierId])
  10586. {
  10587. if (seller_memo.Contains(kvp.Key))
  10588. {
  10589. map_key = kvp.Value;
  10590. type = kvp.Value;
  10591. break;
  10592. }
  10593. }
  10594. }
  10595. if (map_key == "")
  10596. {
  10597. type = "其他";
  10598. map_key = "其他";
  10599. }
  10600. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10601. {
  10602. map_key = suppliers[supplierId];
  10603. }
  10604. if (supplierId == 70)
  10605. {
  10606. supplierId = 70;
  10607. }
  10608. map_key += "_" + row["SupplierName"].ToString();
  10609. Dictionary<string, int> map = null;
  10610. if (other_map.ContainsKey(map_key))
  10611. {
  10612. other_map.TryGetValue(map_key, out map);
  10613. }
  10614. else
  10615. {
  10616. map = new Dictionary<string, int>();
  10617. map.Add("dayDev", 0);//当天出货
  10618. map.Add("dayTotal", 0);//下单总数
  10619. map.Add("payTotal", 0);//500以上
  10620. map.Add("today", 0);//当天出货数量
  10621. map.Add("unusua", 0);//异常数
  10622. other_map.Add(map_key, map);
  10623. other_map.TryGetValue(map_key, out map);
  10624. }
  10625. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10626. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10627. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10628. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10629. {
  10630. map["dayTotal"]++;
  10631. if (supplierId == 97)
  10632. {
  10633. supplierId = 97;
  10634. }
  10635. }
  10636. if (Convert.ToDecimal(row["payment"]) >= 500)
  10637. {
  10638. map["payTotal"]++;
  10639. }
  10640. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10641. {
  10642. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10643. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10644. {
  10645. map["today"]++;
  10646. }
  10647. }
  10648. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10649. {
  10650. map["unusua"]++;
  10651. }
  10652. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10653. //GD-CYT-----64
  10654. DateTime two = palceTimeStart.AddHours(14);
  10655. DateTime three = palceTimeStart.AddHours(15);
  10656. DateTime four = palceTimeStart.AddHours(16);
  10657. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10658. {
  10659. //下午四点前 500-1000
  10660. string count = row["ProductCount"].ToString();
  10661. if (count != null && count.Length > 0)
  10662. {
  10663. int productCount = commonHelper.getPlaceProductCount(count);
  10664. if (productCount >= 500 && productCount <= 1000)
  10665. {
  10666. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10667. {
  10668. map["dayDev"]++;
  10669. }
  10670. }
  10671. }
  10672. }
  10673. //UV
  10674. else if ("uv".Equals(type))
  10675. {
  10676. //ZT----70
  10677. //ZHX----3
  10678. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10679. {
  10680. map["dayDev"]++;
  10681. }
  10682. //JK----97
  10683. //HZX----105
  10684. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10685. {
  10686. map["dayDev"]++;
  10687. if (supplierId == 97)
  10688. {
  10689. supplierId = 97;
  10690. Debug.WriteLine(map["dayTotal"].ToString() + "-" + map["dayDev"].ToString());
  10691. }
  10692. }
  10693. }
  10694. //帆布---52|条幅---27
  10695. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10696. {
  10697. //LHCY-----98
  10698. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10699. {
  10700. map["dayDev"]++;
  10701. }
  10702. }
  10703. //条幅
  10704. else if ("条幅".Equals(type))
  10705. {
  10706. //XD-----90
  10707. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10708. {
  10709. map["dayDev"]++;
  10710. }
  10711. }
  10712. //桌布
  10713. else if ("桌布".Equals(type))
  10714. {
  10715. //XD-----90
  10716. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10717. {
  10718. map["dayDev"]++;
  10719. }
  10720. }
  10721. //DL---10
  10722. //AYTW---119
  10723. //FS-CYT-DY ----80
  10724. //JK----97
  10725. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10726. {
  10727. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10728. {
  10729. map["dayDev"]++;
  10730. }
  10731. }
  10732. }
  10733. DataTable dt = new DataTable();
  10734. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10735. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10736. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10737. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10738. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10739. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10740. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10741. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10742. other_map.Keys.ForEach(key =>
  10743. {
  10744. DataRow dr = dt.NewRow();
  10745. Dictionary<string, int> map = other_map[key];
  10746. string[] key_list = key.Split('_');
  10747. dr[0] = key_list[0];
  10748. dr[1] = key_list[1];
  10749. if (key_list.Length > 2)
  10750. {
  10751. dr[1] += "(" + key_list[2] + ")";
  10752. }
  10753. dr[2] = map["dayTotal"];
  10754. dr[3] = map["payTotal"];
  10755. dr[4] = map["today"];
  10756. dr[5] = map["unusua"];
  10757. dr[6] = map["dayDev"];
  10758. double rate = 0.00;
  10759. if (map["dayDev"] > 0)
  10760. {
  10761. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10762. }
  10763. dr[7] = rate.ToString();
  10764. dt.Rows.Add(dr);
  10765. });
  10766. DataView dv = new DataView(dt);
  10767. dv.Sort = "SupplierName";
  10768. //dv.Sort = "AllOrder desc";
  10769. DataTable dtNew = dv.ToTable();
  10770. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10771. }
  10772. public void check_order_desing_info()
  10773. {
  10774. string ctid = GetPostString("ctid");
  10775. if (!string.IsNullOrEmpty(ctid))
  10776. {
  10777. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10778. if (ceErpTradeCell != null)
  10779. {
  10780. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10781. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10782. return;
  10783. }
  10784. returnErrorMsg("找不到订单");
  10785. return;
  10786. }
  10787. returnErrorMsg("找不到订单");
  10788. }
  10789. public void get_timeout_detail()
  10790. {
  10791. string poscode = CurrentUser.UserPost.Post.Code;
  10792. DataStruct dStruct = GetPostStruct();
  10793. List<string> lw = new List<string>();
  10794. string id = GetPostString("id");
  10795. string pay_date1 = GetPostString("pay_date1");
  10796. string pay_date2 = GetPostString("pay_date2");
  10797. int type = GetPostInt("type");
  10798. if (type == 0)
  10799. {
  10800. if (pay_date1.Length > 0)
  10801. {
  10802. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  10803. }
  10804. if (pay_date2.Length > 0)
  10805. {
  10806. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  10807. }
  10808. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  10809. }
  10810. if (type == 1)
  10811. {
  10812. if (pay_date1.Length > 0)
  10813. {
  10814. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  10815. }
  10816. if (pay_date2.Length > 0)
  10817. {
  10818. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  10819. }
  10820. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  10821. }
  10822. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10823. DataTable dt = null;
  10824. dt = WebCache.GetData("view_orderlist", dStruct);
  10825. writeGridDataTableJson(dStruct.TotalCount, dt);
  10826. }
  10827. public void saveUrgentChargePrice()
  10828. {
  10829. string ctid = GetPostString("ctid");
  10830. if (!string.IsNullOrEmpty(ctid))
  10831. {
  10832. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10833. if (ceErpTradeCell != null)
  10834. {
  10835. double price = GetPostDouble("price");
  10836. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  10837. if (ceErpTradeCellExtend == null)
  10838. {
  10839. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10840. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  10841. }
  10842. ceErpTradeCellExtend.urgentCharge = price;
  10843. if (ceErpTradeCellExtend.ID > 0)
  10844. {
  10845. ceErpTradeCellExtend.Update();
  10846. }
  10847. else
  10848. {
  10849. ceErpTradeCellExtend.Save();
  10850. }
  10851. returnSuccessMsg("修改成功!");
  10852. return;
  10853. }
  10854. returnErrorMsg("找不到订单");
  10855. return;
  10856. }
  10857. returnErrorMsg("找不到订单");
  10858. }
  10859. public void finish_erp_order()
  10860. {
  10861. string ctid = GetPostString("ctid");
  10862. if (!string.IsNullOrEmpty(ctid))
  10863. {
  10864. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  10865. {
  10866. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10867. if (ceErpTradeCell != null)
  10868. {
  10869. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  10870. ceErpTradeCell.Update();
  10871. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  10872. returnSuccessMsg("修改成功!");
  10873. return;
  10874. }
  10875. }
  10876. }
  10877. returnErrorMsg("找不到订单");
  10878. }
  10879. public void get_trade_order_list()
  10880. {
  10881. string tid = GetPostString("tid");
  10882. if (!string.IsNullOrEmpty(tid))
  10883. {
  10884. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  10885. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10886. writeGridDataTableJson(data.Rows.Count, data);
  10887. return;
  10888. }
  10889. returnErrorMsg("找不到订单");
  10890. }
  10891. public void save_cell_spu()
  10892. {
  10893. string ctid = GetPostString("ctid");
  10894. string spu_id = GetPostString("spu_id");
  10895. if (!string.IsNullOrEmpty(ctid))
  10896. {
  10897. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10898. if (ceErpTradeCellExtend == null)
  10899. {
  10900. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10901. ceErpTradeCellExtend.ctid = ctid;
  10902. }
  10903. ceErpTradeCellExtend.spu_id = spu_id;
  10904. if (ceErpTradeCellExtend.ID == 0)
  10905. {
  10906. ceErpTradeCellExtend.Create();
  10907. }
  10908. else
  10909. {
  10910. ceErpTradeCellExtend.Update();
  10911. }
  10912. returnSuccessMsg("修改成功!");
  10913. return;
  10914. }
  10915. returnErrorMsg("找不到订单");
  10916. }
  10917. public void change_express_info()
  10918. {
  10919. string ctid = GetPostString("ctid");
  10920. string transNo = GetPostString("transNo");
  10921. string transCom = GetPostString("transCom");
  10922. if (!string.IsNullOrEmpty(ctid))
  10923. {
  10924. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10925. if (ceErpTradeCellExtend == null)
  10926. {
  10927. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10928. ceErpTradeCellExtend.ctid = ctid;
  10929. }
  10930. ceErpTradeCellExtend.modExpressNo = transNo;
  10931. ceErpTradeCellExtend.modExpressCom = transCom;
  10932. ceErpTradeCellExtend.readMod = 2;
  10933. if (ceErpTradeCellExtend.ID == 0)
  10934. {
  10935. ceErpTradeCellExtend.Create();
  10936. }
  10937. else
  10938. {
  10939. ceErpTradeCellExtend.Update();
  10940. }
  10941. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  10942. returnSuccessMsg("修改成功!");
  10943. return;
  10944. }
  10945. returnErrorMsg("找不到订单");
  10946. }
  10947. public void get_change_express_list()
  10948. {
  10949. DataStruct dStruct = GetPostStruct();
  10950. List<string> lw = new List<string>();
  10951. int st = 2;
  10952. string tid = GetPostString("ctid");
  10953. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  10954. string shopname = GetPostString("shopname");
  10955. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10956. string buyernick = GetPostString("buyer_nick");
  10957. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10958. string sellermemo = GetPostString("seller_memo");
  10959. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10960. string supplier = GetPostString("supplier");
  10961. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10962. string customer = GetPostString("customer");
  10963. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10964. string design = GetPostString("design");
  10965. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10966. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  10967. string poscode = CurrentUser.UserPost.Post.Code;
  10968. if (poscode != "SysAdmin")
  10969. {
  10970. string shopid = CurrentUser.User.pemShop;
  10971. lw.Add(string.Format("shopId in ({0})", shopid));
  10972. }
  10973. lw.Add("readMod = 2");
  10974. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10975. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10976. writeGridDataTableJson(dStruct.TotalCount, dt);
  10977. }
  10978. public void deal_express_complete()
  10979. {
  10980. string ctid = GetPostString("ctid");
  10981. if (!string.IsNullOrEmpty(ctid))
  10982. {
  10983. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10984. if (ceErpTradeCellExtend == null)
  10985. {
  10986. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10987. ceErpTradeCellExtend.ctid = ctid;
  10988. }
  10989. ceErpTradeCellExtend.readMod = 1;
  10990. if (ceErpTradeCellExtend.ID == 0)
  10991. {
  10992. ceErpTradeCellExtend.Create();
  10993. }
  10994. else
  10995. {
  10996. ceErpTradeCellExtend.Update();
  10997. }
  10998. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  10999. returnSuccessMsg("修改成功!");
  11000. return;
  11001. }
  11002. returnErrorMsg("找不到订单");
  11003. }
  11004. public void aftersale_return_visit()
  11005. {
  11006. string ctid = GetPostString("ctid");
  11007. if (!string.IsNullOrEmpty(ctid))
  11008. {
  11009. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11010. if (ceErpTradeCellExtend == null)
  11011. {
  11012. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11013. ceErpTradeCellExtend.ctid = ctid;
  11014. }
  11015. ceErpTradeCellExtend.returnVisit = 1;
  11016. if (ceErpTradeCellExtend.ID == 0)
  11017. {
  11018. ceErpTradeCellExtend.Create();
  11019. }
  11020. else
  11021. {
  11022. ceErpTradeCellExtend.Update();
  11023. }
  11024. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11025. if (ceErpTradeAfterSaleExtend != null)
  11026. {
  11027. ceErpTradeAfterSaleExtend.TextResult = "";
  11028. ceErpTradeAfterSaleExtend.Update();
  11029. }
  11030. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11031. returnSuccessMsg("修改成功!");
  11032. return;
  11033. }
  11034. returnErrorMsg("找不到订单");
  11035. }
  11036. public void orderPlaceInfo()
  11037. {
  11038. string ctids = GetPostString("ctids");
  11039. string[] list = ctids.Split(',');
  11040. foreach (string ctid in list)
  11041. {
  11042. CeErpSukuraData.createInfo(ctid, 3);
  11043. }
  11044. designHelper.api_approveDesign(ctids); //approveDesign
  11045. returnSuccessMsg("");
  11046. }
  11047. }
  11048. }